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
Vova23/limbo-android
jni/qemu/tests/qemu-iotests/iotests.py
48
6227
# Common utilities and Python wrappers for qemu-iotests # # Copyright (C) 2012 IBM Corp. # # 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, see <http://www.gnu.org/licenses/>. # import os import re import subprocess import unittest import sys; sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'QMP')) import qmp __all__ = ['imgfmt', 'imgproto', 'test_dir' 'qemu_img', 'qemu_io', 'VM', 'QMPTestCase', 'notrun', 'main'] # This will not work if arguments or path contain spaces but is necessary if we # want to support the override options that ./check supports. qemu_img_args = os.environ.get('QEMU_IMG', 'qemu-img').strip().split(' ') qemu_io_args = os.environ.get('QEMU_IO', 'qemu-io').strip().split(' ') qemu_args = os.environ.get('QEMU', 'qemu').strip().split(' ') imgfmt = os.environ.get('IMGFMT', 'raw') imgproto = os.environ.get('IMGPROTO', 'file') test_dir = os.environ.get('TEST_DIR', '/var/tmp') def qemu_img(*args): '''Run qemu-img and return the exit code''' devnull = open('/dev/null', 'r+') return subprocess.call(qemu_img_args + list(args), stdin=devnull, stdout=devnull) def qemu_io(*args): '''Run qemu-io and return the stdout data''' args = qemu_io_args + list(args) return subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0] class VM(object): '''A QEMU VM''' def __init__(self): self._monitor_path = os.path.join(test_dir, 'qemu-mon.%d' % os.getpid()) self._qemu_log_path = os.path.join(test_dir, 'qemu-log.%d' % os.getpid()) self._args = qemu_args + ['-chardev', 'socket,id=mon,path=' + self._monitor_path, '-mon', 'chardev=mon,mode=control', '-nographic'] self._num_drives = 0 def add_drive(self, path, opts=''): '''Add a virtio-blk drive to the VM''' options = ['if=virtio', 'format=%s' % imgfmt, 'cache=none', 'file=%s' % path, 'id=drive%d' % self._num_drives] if opts: options.append(opts) self._args.append('-drive') self._args.append(','.join(options)) self._num_drives += 1 return self def launch(self): '''Launch the VM and establish a QMP connection''' devnull = open('/dev/null', 'rb') qemulog = open(self._qemu_log_path, 'wb') try: self._qmp = qmp.QEMUMonitorProtocol(self._monitor_path, server=True) self._popen = subprocess.Popen(self._args, stdin=devnull, stdout=qemulog, stderr=subprocess.STDOUT) self._qmp.accept() except: os.remove(self._monitor_path) raise def shutdown(self): '''Terminate the VM and clean up''' if not self._popen is None: self._qmp.cmd('quit') self._popen.wait() os.remove(self._monitor_path) os.remove(self._qemu_log_path) self._popen = None def qmp(self, cmd, **args): '''Invoke a QMP command and return the result dict''' return self._qmp.cmd(cmd, args=args) def get_qmp_events(self, wait=False): '''Poll for queued QMP events and return a list of dicts''' events = self._qmp.get_events(wait=wait) self._qmp.clear_events() return events index_re = re.compile(r'([^\[]+)\[([^\]]+)\]') class QMPTestCase(unittest.TestCase): '''Abstract base class for QMP test cases''' def dictpath(self, d, path): '''Traverse a path in a nested dict''' for component in path.split('/'): m = index_re.match(component) if m: component, idx = m.groups() idx = int(idx) if not isinstance(d, dict) or component not in d: self.fail('failed path traversal for "%s" in "%s"' % (path, str(d))) d = d[component] if m: if not isinstance(d, list): self.fail('path component "%s" in "%s" is not a list in "%s"' % (component, path, str(d))) try: d = d[idx] except IndexError: self.fail('invalid index "%s" in path "%s" in "%s"' % (idx, path, str(d))) return d def assert_qmp(self, d, path, value): '''Assert that the value for a specific path in a QMP dict matches''' result = self.dictpath(d, path) self.assertEqual(result, value, 'values not equal "%s" and "%s"' % (str(result), str(value))) def notrun(reason): '''Skip this test suite''' # Each test in qemu-iotests has a number ("seq") seq = os.path.basename(sys.argv[0]) open('%s.notrun' % seq, 'wb').write(reason + '\n') print '%s not run: %s' % (seq, reason) sys.exit(0) def main(supported_fmts=[]): '''Run tests''' if supported_fmts and (imgfmt not in supported_fmts): notrun('not suitable for this image format: %s' % imgfmt) # We need to filter out the time taken from the output so that qemu-iotest # can reliably diff the results against master output. import StringIO output = StringIO.StringIO() class MyTestRunner(unittest.TextTestRunner): def __init__(self, stream=output, descriptions=True, verbosity=1): unittest.TextTestRunner.__init__(self, stream, descriptions, verbosity) # unittest.main() will use sys.exit() so expect a SystemExit exception try: unittest.main(testRunner=MyTestRunner) finally: sys.stderr.write(re.sub(r'Ran (\d+) test[s] in [\d.]+s', r'Ran \1 tests', output.getvalue()))
gpl-2.0
[ 3, 13964, 15841, 436, 2018, 17995, 367, 1894, 14756, 13, 2308, 2219, 199, 3, 199, 3, 1898, 334, 35, 9, 6029, 26202, 22304, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 646, 747, 199, 646, 295, 199, 646, 3873, 199, 646, 2882, 199, 646, 984, 27, 984, 14, 515, 14, 740, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 19155, 19155, 283, 49, 1658, 1333, 199, 646, 1894, 311, 199, 199, 363, 452, 363, 275, 788, 4060, 5045, 297, 283, 4060, 2625, 297, 283, 396, 63, 694, 7, 283, 19839, 63, 4060, 297, 283, 19839, 63, 2308, 297, 1779, 283, 6849, 297, 283, 49, 1658, 1746, 297, 283, 1397, 1065, 297, 283, 973, 418, 199, 199, 3, 961, 911, 440, 1736, 340, 2368, 503, 931, 1395, 7883, 1325, 365, 5784, 340, 781, 199, 3, 2934, 370, 2291, 314, 4278, 1511, 626, 16605, 1074, 5171, 14, 199, 19839, 63, 4060, 63, 589, 275, 747, 14, 2314, 14, 362, 360, 49, 2769, 53, 63, 26246, 297, 283, 19839, 13, 4060, 1959, 1913, 1252, 1294, 360, 5320, 199, 19839, 63, 2308, 63, 589, 275, 747, 14, 2314, 14, 362, 360, 49, 2769, 53, 63, 2090, 297, 283, 19839, 13, 2308, 1959, 1913, 1252, 1294, 360, 5320, 199, 19839, 63, 589, 275, 747, 14, 2314, 14, 362, 360, 49, 2769, 53, 297, 283, 19839, 1959, 1913, 1252, 1294, 360, 5320, 199, 199, 4060, 5045, 275, 747, 14, 2314, 14, 362, 360, 1469, 17395, 5747, 297, 283, 1773, 358, 199, 4060, 2625, 275, 747, 14, 2314, 14, 362, 360, 26246, 7459, 297, 283, 493, 358, 199, 396, 63, 694, 275, 747, 14, 2314, 14, 362, 360, 2864, 63, 3022, 297, 1994, 1391, 15, 2791, 358, 199, 199, 318, 1894, 14756, 63, 4060, 2031, 589, 304, 272, 1449, 2540, 1894, 14756, 13, 4060, 436, 372, 314, 4458, 1233, 2344, 272, 4866, 2307, 275, 1551, 2336, 2374, 15, 2307, 297, 283, 82, 13854, 272, 372, 3873, 14, 1250, 8, 19839, 63, 4060, 63, 589, 435, 769, 8, 589, 395, 9009, 29, 19778, 12, 3839, 29, 19778, 9, 199, 199, 318, 1894, 14756, 63, 2308, 2031, 589, 304, 272, 1449, 2540, 1894, 14756, 13, 2308, 436, 372, 314, 3839, 666, 2344, 272, 1249, 275, 1894, 14756, 63, 2308, 63, 589, 435, 769, 8, 589, 9, 272, 372, 3873, 14, 7942, 8, 589, 12, 3839, 29, 5781, 14, 6089, 680, 10664, 3430, 16, 61, 199, 199, 533, 7525, 8, 785, 304, 272, 1449, 33, 1413, 2769, 53, 7525, 2344, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 7157, 63, 515, 275, 747, 14, 515, 14, 904, 8, 396, 63, 694, 12, 283, 19839, 13, 2106, 4111, 68, 7, 450, 747, 14, 17829, 1012, 267, 291, 423, 19839, 63, 793, 63, 515, 275, 747, 14, 515, 14, 904, 8, 396, 63, 694, 12, 283, 19839, 13, 793, 4111, 68, 7, 450, 747, 14, 17829, 1012, 267, 291, 423, 589, 275, 1894, 14756, 63, 589, 435, 11573, 1560, 2374, 297, 2151, 283, 3450, 12, 344, 29, 2106, 12, 515, 534, 435, 291, 423, 7157, 63, 515, 12, 2151, 2475, 2106, 297, 283, 1560, 2374, 29, 2106, 12, 632, 29, 2785, 297, 2475, 889, 9770, 418, 267, 291, 423, 1507, 63, 17824, 2310, 275, 378, 339, 347, 1050, 63, 9541, 8, 277, 12, 931, 12, 3999, 9280, 267, 1449, 1123, 282, 18291, 4538, 13, 14023, 12912, 370, 314, 7525, 2344, 267, 1511, 275, 788, 692, 29, 1042, 4538, 297, 673, 283, 908, 2458, 83, 7, 450, 6050, 5045, 12, 673, 283, 1637, 29, 3592, 297, 673, 283, 493, 2458, 83, 7, 450, 931, 12, 673, 283, 344, 29, 9541, 5, 68, 7, 450, 291, 423, 1507, 63, 17824, 2310, 61, 267, 340, 3999, 26, 288, 1511, 14, 740, 8, 3291, 9, 398, 291, 423, 589, 14, 740, 3654, 9541, 358, 267, 291, 423, 589, 14, 740, 5102, 1370, 904, 8, 1419, 430, 267, 291, 423, 1507, 63, 17824, 2310, 847, 413, 267, 372, 291, 339, 347, 10623, 8, 277, 304, 267, 1449, 18543, 314, 7525, 436, 16873, 282, 1413, 1658, 1950, 2344, 267, 4866, 2307, 275, 1551, 2336, 2374, 15, 2307, 297, 283, 4848, 358, 267, 1894, 14756, 793, 275, 1551, 8, 277, 423, 19839, 63, 793, 63, 515, 12, 283, 6603, 358, 267, 862, 26, 288, 291, 423, 81, 311, 275, 1894, 311, 14, 49, 2769, 2639, 265, 4330, 3658, 8, 277, 423, 7157, 63, 515, 12, 1654, 29, 549, 9, 288, 291, 423, 12207, 275, 3873, 14, 7942, 8, 277, 423, 589, 12, 9009, 29, 19778, 12, 3839, 29, 19839, 793, 12, 5644, 4635, 29, 5781, 14, 13850, 9, 288, 291, 423, 81, 311, 14, 5694, 342, 267, 871, 26, 288, 747, 14, 2168, 8, 277, 423, 7157, 63, 515, 9, 288, 746, 339, 347, 12842, 8, 277, 304, 267, 1449, 12154, 323, 314, 7525, 436, 3633, 1536, 2344, 267, 340, 440, 291, 423, 12207, 365, 488, 26, 288, 291, 423, 81, 311, 14, 1760, 360, 10589, 358, 288, 291, 423, 12207, 14, 2573, 342, 288, 747, 14, 2168, 8, 277, 423, 7157, 63, 515, 9, 288, 747, 14, 2168, 8, 277, 423, 19839, 63, 793, 63, 515, 9, 288, 291, 423, 12207, 275, 488, 339, 347, 1894, 311, 8, 277, 12, 2088, 12, 1011, 589, 304 ]
[ 13964, 15841, 436, 2018, 17995, 367, 1894, 14756, 13, 2308, 2219, 199, 3, 199, 3, 1898, 334, 35, 9, 6029, 26202, 22304, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 646, 747, 199, 646, 295, 199, 646, 3873, 199, 646, 2882, 199, 646, 984, 27, 984, 14, 515, 14, 740, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 19155, 19155, 283, 49, 1658, 1333, 199, 646, 1894, 311, 199, 199, 363, 452, 363, 275, 788, 4060, 5045, 297, 283, 4060, 2625, 297, 283, 396, 63, 694, 7, 283, 19839, 63, 4060, 297, 283, 19839, 63, 2308, 297, 1779, 283, 6849, 297, 283, 49, 1658, 1746, 297, 283, 1397, 1065, 297, 283, 973, 418, 199, 199, 3, 961, 911, 440, 1736, 340, 2368, 503, 931, 1395, 7883, 1325, 365, 5784, 340, 781, 199, 3, 2934, 370, 2291, 314, 4278, 1511, 626, 16605, 1074, 5171, 14, 199, 19839, 63, 4060, 63, 589, 275, 747, 14, 2314, 14, 362, 360, 49, 2769, 53, 63, 26246, 297, 283, 19839, 13, 4060, 1959, 1913, 1252, 1294, 360, 5320, 199, 19839, 63, 2308, 63, 589, 275, 747, 14, 2314, 14, 362, 360, 49, 2769, 53, 63, 2090, 297, 283, 19839, 13, 2308, 1959, 1913, 1252, 1294, 360, 5320, 199, 19839, 63, 589, 275, 747, 14, 2314, 14, 362, 360, 49, 2769, 53, 297, 283, 19839, 1959, 1913, 1252, 1294, 360, 5320, 199, 199, 4060, 5045, 275, 747, 14, 2314, 14, 362, 360, 1469, 17395, 5747, 297, 283, 1773, 358, 199, 4060, 2625, 275, 747, 14, 2314, 14, 362, 360, 26246, 7459, 297, 283, 493, 358, 199, 396, 63, 694, 275, 747, 14, 2314, 14, 362, 360, 2864, 63, 3022, 297, 1994, 1391, 15, 2791, 358, 199, 199, 318, 1894, 14756, 63, 4060, 2031, 589, 304, 272, 1449, 2540, 1894, 14756, 13, 4060, 436, 372, 314, 4458, 1233, 2344, 272, 4866, 2307, 275, 1551, 2336, 2374, 15, 2307, 297, 283, 82, 13854, 272, 372, 3873, 14, 1250, 8, 19839, 63, 4060, 63, 589, 435, 769, 8, 589, 395, 9009, 29, 19778, 12, 3839, 29, 19778, 9, 199, 199, 318, 1894, 14756, 63, 2308, 2031, 589, 304, 272, 1449, 2540, 1894, 14756, 13, 2308, 436, 372, 314, 3839, 666, 2344, 272, 1249, 275, 1894, 14756, 63, 2308, 63, 589, 435, 769, 8, 589, 9, 272, 372, 3873, 14, 7942, 8, 589, 12, 3839, 29, 5781, 14, 6089, 680, 10664, 3430, 16, 61, 199, 199, 533, 7525, 8, 785, 304, 272, 1449, 33, 1413, 2769, 53, 7525, 2344, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 7157, 63, 515, 275, 747, 14, 515, 14, 904, 8, 396, 63, 694, 12, 283, 19839, 13, 2106, 4111, 68, 7, 450, 747, 14, 17829, 1012, 267, 291, 423, 19839, 63, 793, 63, 515, 275, 747, 14, 515, 14, 904, 8, 396, 63, 694, 12, 283, 19839, 13, 793, 4111, 68, 7, 450, 747, 14, 17829, 1012, 267, 291, 423, 589, 275, 1894, 14756, 63, 589, 435, 11573, 1560, 2374, 297, 2151, 283, 3450, 12, 344, 29, 2106, 12, 515, 534, 435, 291, 423, 7157, 63, 515, 12, 2151, 2475, 2106, 297, 283, 1560, 2374, 29, 2106, 12, 632, 29, 2785, 297, 2475, 889, 9770, 418, 267, 291, 423, 1507, 63, 17824, 2310, 275, 378, 339, 347, 1050, 63, 9541, 8, 277, 12, 931, 12, 3999, 9280, 267, 1449, 1123, 282, 18291, 4538, 13, 14023, 12912, 370, 314, 7525, 2344, 267, 1511, 275, 788, 692, 29, 1042, 4538, 297, 673, 283, 908, 2458, 83, 7, 450, 6050, 5045, 12, 673, 283, 1637, 29, 3592, 297, 673, 283, 493, 2458, 83, 7, 450, 931, 12, 673, 283, 344, 29, 9541, 5, 68, 7, 450, 291, 423, 1507, 63, 17824, 2310, 61, 267, 340, 3999, 26, 288, 1511, 14, 740, 8, 3291, 9, 398, 291, 423, 589, 14, 740, 3654, 9541, 358, 267, 291, 423, 589, 14, 740, 5102, 1370, 904, 8, 1419, 430, 267, 291, 423, 1507, 63, 17824, 2310, 847, 413, 267, 372, 291, 339, 347, 10623, 8, 277, 304, 267, 1449, 18543, 314, 7525, 436, 16873, 282, 1413, 1658, 1950, 2344, 267, 4866, 2307, 275, 1551, 2336, 2374, 15, 2307, 297, 283, 4848, 358, 267, 1894, 14756, 793, 275, 1551, 8, 277, 423, 19839, 63, 793, 63, 515, 12, 283, 6603, 358, 267, 862, 26, 288, 291, 423, 81, 311, 275, 1894, 311, 14, 49, 2769, 2639, 265, 4330, 3658, 8, 277, 423, 7157, 63, 515, 12, 1654, 29, 549, 9, 288, 291, 423, 12207, 275, 3873, 14, 7942, 8, 277, 423, 589, 12, 9009, 29, 19778, 12, 3839, 29, 19839, 793, 12, 5644, 4635, 29, 5781, 14, 13850, 9, 288, 291, 423, 81, 311, 14, 5694, 342, 267, 871, 26, 288, 747, 14, 2168, 8, 277, 423, 7157, 63, 515, 9, 288, 746, 339, 347, 12842, 8, 277, 304, 267, 1449, 12154, 323, 314, 7525, 436, 3633, 1536, 2344, 267, 340, 440, 291, 423, 12207, 365, 488, 26, 288, 291, 423, 81, 311, 14, 1760, 360, 10589, 358, 288, 291, 423, 12207, 14, 2573, 342, 288, 747, 14, 2168, 8, 277, 423, 7157, 63, 515, 9, 288, 747, 14, 2168, 8, 277, 423, 19839, 63,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
louietsai/python-for-android
python3-alpha/extra_modules/pyxmpp2/ext/vcard.py
46
55422
# # (C) Copyright 2003-2010 Jacek Konieczny <jajcus@jajcus.net> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License Version # 2.1 as published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # pylint: disable-msg=W0302 """Jabber vCard and MIME (RFC 2426) vCard implementation. Normative reference: - `JEP 54 <http://www.jabber.org/jeps/jep-0054.html>`__ - `RFC 2425 <http://www.ietf.org/rfc/rfc2425.txt>`__ - `RFC 2426 <http://www.ietf.org/rfc/rfc2426.txt>`__ """ __docformat__="restructuredtext en" raise ImportError("{0} is not yet rewritten for PyXMPP2".format(__name__)) import base64 import binascii import libxml2 import re import pyxmpp.jid from ..utils import to_utf8,from_utf8 from ..xmlextra import get_node_ns from ..objects import StanzaPayloadObject from ..exceptions import BadRequestProtocolError, JIDMalformedProtocolError, JIDError VCARD_NS="vcard-temp" class Empty(Exception): """Exception raised when parsing empty vcard element. Such element will be ignored.""" pass valid_string_re=re.compile(r"^[\w\d \t]*$") non_quoted_semicolon_re=re.compile(r'(?<!\\);') def quote_semicolon(value): return value.replace(r';', r'\;') def unquote_semicolon(value): return value.replace(r'\;', r';') def rfc2425encode(name,value,parameters=None,charset="utf-8"): """Encodes a vCard field into an RFC2425 line. :Parameters: - `name`: field type name - `value`: field value - `parameters`: optional parameters - `charset`: encoding of the output and of the `value` (if not `str`) :Types: - `name`: `str` - `value`: `str` or `str` - `parameters`: `dict` of `str` -> `str` - `charset`: `str` :return: the encoded RFC2425 line (possibly folded) :returntype: `str`""" if not parameters: parameters={} if type(value) is str: value=value.replace("\r\n","\\n") value=value.replace("\n","\\n") value=value.replace("\r","\\n") value=value.encode(charset,"replace") elif type(value) is not str: raise TypeError("Bad type for rfc2425 value") elif not valid_string_re.match(value): parameters["encoding"]="b" value=binascii.b2a_base64(value) ret=str(name).lower() for k,v in list(parameters.items()): ret+=";%s=%s" % (str(k),str(v)) ret+=":" while(len(value)>70): ret+=value[:70]+"\r\n " value=value[70:] ret+=value+"\r\n" return ret class VCardField: """Base class for vCard fields. :Ivariables: - `name`: name of the field. """ def __init__(self,name): """Initialize a `VCardField` object. Set its name. :Parameters: - `name`: field name :Types: - `name`: `str`""" self.name=name def __repr__(self): return "<%s %r>" % (self.__class__,self.rfc2426()) def rfc2426(self): """RFC2426-encode the field content. :return: the field in the RFC 2426 format. :returntype: `str`""" return "" class VCardString(VCardField): """Generic class for all standard text fields in the vCard. :Ivariables: - `value`: field value. :Types: - `value`: `str`""" def __init__(self,name, value, rfc2425parameters = None, empty_ok = False): """Initialize a `VCardString` object. :Parameters: - `name`: field name - `value`: field value as string or an XML node - `rfc2425parameters`: optional RFC 2425 parameters :Types: - `name`: `str` - `value`: `str` or `libxml2.xmlNode` - `rfc2425parameters`: `dict`""" _unused = rfc2425parameters VCardField.__init__(self,name) if isinstance(value,libxml2.xmlNode): value=value.getContent() if value: self.value=str(value,"utf-8","replace").strip() else: self.value="" else: self.value=value if not self.value and not empty_ok: raise Empty("Empty string value") def rfc2426(self): """RFC2426-encode the field content. :return: the field in the RFC 2426 format. :returntype: `str`""" return rfc2425encode(self.name,self.value) def as_xml(self,parent): """Create vcard-tmp XML representation of the field. :Parameters: - `parent`: parent node for the element :Types: - `parent`: `libxml2.xmlNode` :return: xml node with the field data. :returntype: `libxml2.xmlNode`""" return parent.newTextChild(None, to_utf8(self.name.upper()), to_utf8(self.value)) def __str__(self): return self.value def __str__(self): return self.value.encode("utf-8") class VCardXString(VCardString): """Generic class for all text vCard fields not defined in RFC 2426. In the RFC 2425 representation field name will be prefixed with 'x-'. :Ivariables: - `value`: field value. :Types: - `value`: `str`""" def rfc2426(self): """RFC2426-encode the field content. :return: the field in the RFC 2426 format. :returntype: `str`""" return rfc2425encode("x-"+self.name,self.value) class VCardJID(VCardField): """JID vCard field. This field is not defined in RFC 2426, so it will be named 'x-jabberid' in RFC 2425 output. :Ivariables: - `value`: field value. :Types: - `value`: `JID`""" def __init__(self,name,value,rfc2425parameters=None): """Initialize a `VCardJID` object. :Parameters: - `name`: field name - `value`: field value as string or an XML node - `rfc2425parameters`: optional RFC 2425 parameters :Types: - `name`: `str` - `value`: `str` or `libxml2.xmlNode` - `rfc2425parameters`: `dict`""" _unused = rfc2425parameters VCardField.__init__(self,name) if isinstance(value,libxml2.xmlNode): try: self.value=pyxmpp.jid.JID(value.getContent()) except JIDError: raise JIDMalformedProtocolError("JID malformed") else: self.value=pyxmpp.jid.JID(value) if not self.value: raise Empty("Empty JID value") def rfc2426(self): """RFC2426-encode the field content. :return: the field in the RFC 2426 format. :returntype: `str`""" return rfc2425encode("x-jabberid",self.value.as_unicode()) def as_xml(self,parent): """Create vcard-tmp XML representation of the field. :Parameters: - `parent`: parent node for the element :Types: - `parent`: `libxml2.xmlNode` :return: xml node with the field data. :returntype: `libxml2.xmlNode`""" name=to_utf8(self.name.upper()) content=self.value.as_utf8() return parent.newTextChild(None, name, content) def __str__(self): return self.value.as_unicode() def __str__(self): return self.value.as_string() class VCardName(VCardField): """Name vCard field. :Ivariables: - `family`: family name. - `given`: given name. - `middle`: middle name. - `prefix`: name prefix. - `suffix`: name suffix. :Types: - `family`: `str` - `given`: `str` - `middle`: `str` - `prefix`: `str` - `suffix`: `str`""" def __init__(self,name,value,rfc2425parameters=None): """Initialize a `VCardName` object. :Parameters: - `name`: field name - `value`: field value as string or an XML node - `rfc2425parameters`: optional RFC 2425 parameters :Types: - `name`: `str` - `value`: `str` or `libxml2.xmlNode` - `rfc2425parameters`: `dict`""" _unused = rfc2425parameters VCardField.__init__(self,name) if self.name.upper()!="N": raise RuntimeError("VCardName handles only 'N' type") if isinstance(value,libxml2.xmlNode): self.family,self.given,self.middle,self.prefix,self.suffix=[""]*5 empty=1 n=value.children vns=get_node_ns(value) while n: if n.type!='element': n=n.__next__ continue ns=get_node_ns(n) if (ns and vns and ns.getContent()!=vns.getContent()): n=n.__next__ continue if n.name=='FAMILY': self.family=str(n.getContent(),"utf-8") empty=0 if n.name=='GIVEN': self.given=str(n.getContent(),"utf-8") empty=0 if n.name=='MIDDLE': self.middle=str(n.getContent(),"utf-8") empty=0 if n.name=='PREFIX': self.prefix=str(n.getContent(),"utf-8") empty=0 if n.name=='SUFFIX': self.suffix=str(n.getContent(),"utf-8") empty=0 n=n.__next__ if empty: raise Empty("Empty N value") else: v=non_quoted_semicolon_re.split(value) value=[""]*5 value[:len(v)]=v self.family,self.given,self.middle,self.prefix,self.suffix=( unquote_semicolon(val) for val in value) def rfc2426(self): """RFC2426-encode the field content. :return: the field in the RFC 2426 format. :returntype: `str`""" return rfc2425encode("n",';'.join(quote_semicolon(val) for val in (self.family,self.given,self.middle,self.prefix,self.suffix))) def as_xml(self,parent): """Create vcard-tmp XML representation of the field. :Parameters: - `parent`: parent node for the element :Types: - `parent`: `libxml2.xmlNode` :return: xml node with the field data. :returntype: `libxml2.xmlNode`""" n=parent.newChild(None,"N",None) n.newTextChild(None,"FAMILY",to_utf8(self.family)) n.newTextChild(None,"GIVEN",to_utf8(self.given)) n.newTextChild(None,"MIDDLE",to_utf8(self.middle)) n.newTextChild(None,"PREFIX",to_utf8(self.prefix)) n.newTextChild(None,"SUFFIX",to_utf8(self.suffix)) return n def __str__(self): r=[] if self.prefix: r.append(self.prefix.replace(","," ")) if self.given: r.append(self.given.replace(","," ")) if self.middle: r.append(self.middle.replace(","," ")) if self.family: r.append(self.family.replace(","," ")) if self.suffix: r.append(self.suffix.replace(","," ")) return " ".join(r) def __str__(self): return self.__unicode__().encode("utf-8") class VCardImage(VCardField): """Image vCard field. :Ivariables: - `image`: image binary data (when `uri` is None) - `uri`: image URI (when `image` is None) - `type`: optional image type :Types: - `image`: `str` - `uri`: `str` - `type`: `str`""" def __init__(self,name,value,rfc2425parameters=None): """Initialize a `VCardImage` object. :Parameters: - `name`: field name - `value`: field value as string or an XML node - `rfc2425parameters`: optional RFC 2425 parameters :Types: - `name`: `str` - `value`: `str` or `libxml2.xmlNode` - `rfc2425parameters`: `dict`""" VCardField.__init__(self,name) if not rfc2425parameters: rfc2425parameters={} self.uri,self.type,self.image=[None]*3 if isinstance(value,libxml2.xmlNode): n=value.children vns=get_node_ns(value) while n: if n.type!='element': n=n.__next__ continue ns=get_node_ns(n) if (ns and vns and ns.getContent()!=vns.getContent()): n=n.__next__ continue if n.name=='TYPE': self.type=str(n.getContent(),"utf-8","replace") if n.name=='BINVAL': self.image=base64.decodestring(n.getContent()) if n.name=='EXTVAL': self.uri=str(n.getContent(),"utf-8","replace") n=n.__next__ if (self.uri and self.image) or (not self.uri and not self.image): raise ValueError("Bad %s value in vcard" % (name,)) if (not self.uri and not self.image): raise Empty("Bad %s value in vcard" % (name,)) else: if rfc2425parameters.get("value", "").lower()=="uri": self.uri=value self.type=None else: self.type=rfc2425parameters.get("type") self.image=value def rfc2426(self): """RFC2426-encode the field content. :return: the field in the RFC 2426 format. :returntype: `str`""" if self.uri: return rfc2425encode(self.name,self.uri,{"value":"uri"}) elif self.image: if self.type: p={"type":self.type} else: p={} return rfc2425encode(self.name,self.image,p) def as_xml(self,parent): """Create vcard-tmp XML representation of the field. :Parameters: - `parent`: parent node for the element :Types: - `parent`: `libxml2.xmlNode` :return: xml node with the field data. :returntype: `libxml2.xmlNode`""" n=parent.newChild(None,self.name.upper(),None) if self.uri: n.newTextChild(None,"EXTVAL",to_utf8(self.uri)) else: if self.type: n.newTextChild(None,"TYPE",self.type) n.newTextChild(None,"BINVAL",binascii.b2a_base64(self.image)) return n def __str__(self): if self.uri: return self.uri if self.type: return "(%s data)" % (self.type,) return "(binary data)" def __str__(self): return self.__unicode__().encode("utf-8") class VCardAdr(VCardField): """Address vCard field. :Ivariables: - `type`: type of the address. - `pobox`: the post office box. - `extadr`: the extended address. - `street`: the street address. - `locality`: the locality (e.g. city). - `region`: the region. - `pcode`: the postal code. - `ctry`: the country. :Types: - `type`: `list` of "home","work","postal","parcel","dom","intl" or "pref" - `pobox`: `str` - `extadr`: `str` - `street`: `str` - `locality`: `str` - `region`: `str` - `pcode`: `str` - `ctry`: `str`""" def __init__(self,name,value,rfc2425parameters=None): """Initialize a `VCardAdr` object. :Parameters: - `name`: field name - `value`: field value as string or an XML node - `rfc2425parameters`: optional RFC 2425 parameters :Types: - `name`: `str` - `value`: `str` or `libxml2.xmlNode` - `rfc2425parameters`: `dict`""" VCardField.__init__(self,name) if not rfc2425parameters: rfc2425parameters={} if self.name.upper()!="ADR": raise RuntimeError("VCardAdr handles only 'ADR' type") (self.pobox,self.extadr,self.street,self.locality, self.region,self.pcode,self.ctry)=[""]*7 self.type=[] if isinstance(value,libxml2.xmlNode): self.__from_xml(value) else: t=rfc2425parameters.get("type") if t: self.type=t.split(",") else: self.type=["intl","postal","parcel","work"] v=non_quoted_semicolon_re.split(value) value=[""]*7 value[:len(v)]=v (self.pobox,self.extadr,self.street,self.locality, self.region,self.pcode,self.ctry)=( unquote_semicolon(val) for val in value) def __from_xml(self,value): """Initialize a `VCardAdr` object from and XML element. :Parameters: - `value`: field value as an XML node :Types: - `value`: `libxml2.xmlNode`""" n=value.children vns=get_node_ns(value) while n: if n.type!='element': n=n.__next__ continue ns=get_node_ns(n) if (ns and vns and ns.getContent()!=vns.getContent()): n=n.__next__ continue if n.name=='POBOX': self.pobox=str(n.getContent(),"utf-8","replace") elif n.name in ('EXTADR', 'EXTADD'): self.extadr=str(n.getContent(),"utf-8","replace") elif n.name=='STREET': self.street=str(n.getContent(),"utf-8","replace") elif n.name=='LOCALITY': self.locality=str(n.getContent(),"utf-8","replace") elif n.name=='REGION': self.region=str(n.getContent(),"utf-8","replace") elif n.name=='PCODE': self.pcode=str(n.getContent(),"utf-8","replace") elif n.name=='CTRY': self.ctry=str(n.getContent(),"utf-8","replace") elif n.name in ("HOME","WORK","POSTAL","PARCEL","DOM","INTL", "PREF"): self.type.append(n.name.lower()) n=n.__next__ if self.type==[]: self.type=["intl","postal","parcel","work"] elif "dom" in self.type and "intl" in self.type: raise ValueError("Both 'dom' and 'intl' specified in vcard ADR") def rfc2426(self): """RFC2426-encode the field content. :return: the field in the RFC 2426 format. :returntype: `str`""" return rfc2425encode("adr",';'.join(quote_semicolon(val) for val in (self.pobox,self.extadr,self.street,self.locality, self.region,self.pcode,self.ctry)), {"type":",".join(self.type)}) def as_xml(self,parent): """Create vcard-tmp XML representation of the field. :Parameters: - `parent`: parent node for the element :Types: - `parent`: `libxml2.xmlNode` :return: xml node with the field data. :returntype: `libxml2.xmlNode`""" n=parent.newChild(None,"ADR",None) for t in ("home","work","postal","parcel","dom","intl","pref"): if t in self.type: n.newChild(None,t.upper(),None) n.newTextChild(None,"POBOX",to_utf8(self.pobox)) n.newTextChild(None,"EXTADD",to_utf8(self.extadr)) n.newTextChild(None,"STREET",to_utf8(self.street)) n.newTextChild(None,"LOCALITY",to_utf8(self.locality)) n.newTextChild(None,"REGION",to_utf8(self.region)) n.newTextChild(None,"PCODE",to_utf8(self.pcode)) n.newTextChild(None,"CTRY",to_utf8(self.ctry)) return n class VCardLabel(VCardField): """Address label vCard field. :Ivariables: - `lines`: list of label text lines. - `type`: type of the label. :Types: - `lines`: `list` of `str` - `type`: `list` of "home","work","postal","parcel","dom","intl" or "pref" """ def __init__(self,name,value,rfc2425parameters=None): """Initialize a `VCardLabel` object. :Parameters: - `name`: field name - `value`: field value as string or an XML node - `rfc2425parameters`: optional RFC 2425 parameters :Types: - `name`: `str` - `value`: `str` or `libxml2.xmlNode` - `rfc2425parameters`: `dict`""" VCardField.__init__(self,name) if not rfc2425parameters: rfc2425parameters={} if self.name.upper()!="LABEL": raise RuntimeError("VCardAdr handles only 'LABEL' type") if isinstance(value,libxml2.xmlNode): self.lines=[] self.type=[] n=value.children vns=get_node_ns(value) while n: if n.type!='element': n=n.__next__ continue ns=get_node_ns(n) if (ns and vns and ns.getContent()!=vns.getContent()): n=n.__next__ continue if n.name=='LINE': l=str(n.getContent(),"utf-8","replace").strip() l=l.replace("\n"," ").replace("\r"," ") self.lines.append(l) elif n.name in ("HOME","WORK","POSTAL","PARCEL","DOM","INTL", "PREF"): self.type.append(n.name.lower()) n=n.__next__ if self.type==[]: self.type=["intl","postal","parcel","work"] elif "dom" in self.type and "intl" in self.type: raise ValueError("Both 'dom' and 'intl' specified in vcard LABEL") if not self.lines: self.lines=[""] else: t=rfc2425parameters.get("type") if t: self.type=t.split(",") else: self.type=["intl","postal","parcel","work"] self.lines=value.split("\\n") def rfc2426(self): """RFC2426-encode the field content. :return: the field in the RFC 2426 format. :returntype: `str`""" return rfc2425encode("label","\n".join(self.lines), {"type":",".join(self.type)}) def as_xml(self,parent): """Create vcard-tmp XML representation of the field. :Parameters: - `parent`: parent node for the element :Types: - `parent`: `libxml2.xmlNode` :return: xml node with the field data. :returntype: `libxml2.xmlNode`""" n=parent.newChild(None,"ADR",None) for t in ("home","work","postal","parcel","dom","intl","pref"): if t in self.type: n.newChild(None,t.upper(),None) for l in self.lines: n.newTextChild(None,"LINE",l) return n class VCardTel(VCardField): """Telephone vCard field. :Ivariables: - `number`: phone number. - `type`: type of the phone number. :Types: - `number`: `str` - `type`: `list` of "home","work","voice","fax","pager","msg","cell","video","bbs","modem","isdn","pcs" or "pref". """ def __init__(self,name,value,rfc2425parameters=None): """Initialize a `VCardTel` object. :Parameters: - `name`: field name - `value`: field value as string or an XML node - `rfc2425parameters`: optional RFC 2425 parameters :Types: - `name`: `str` - `value`: `str` or `libxml2.xmlNode` - `rfc2425parameters`: `dict`""" VCardField.__init__(self,name) if not rfc2425parameters: rfc2425parameters={} if self.name.upper()!="TEL": raise RuntimeError("VCardTel handles only 'TEL' type") if isinstance(value,libxml2.xmlNode): self.number=None self.type=[] n=value.children vns=get_node_ns(value) while n: if n.type!='element': n=n.__next__ continue ns=get_node_ns(n) if (ns and vns and ns.getContent()!=vns.getContent()): n=n.__next__ continue if n.name=='NUMBER': self.number=str(n.getContent(),"utf-8","replace") elif n.name in ("HOME","WORK","VOICE","FAX","PAGER","MSG", "CELL","VIDEO","BBS","MODEM","ISDN","PCS", "PREF"): self.type.append(n.name.lower()) n=n.__next__ if self.type==[]: self.type=["voice"] if not self.number: raise Empty("No tel number") else: t=rfc2425parameters.get("type") if t: self.type=t.split(",") else: self.type=["voice"] self.number=value def rfc2426(self): """RFC2426-encode the field content. :return: the field in the RFC 2426 format. :returntype: `str`""" return rfc2425encode("tel",self.number,{"type":",".join(self.type)}) def as_xml(self,parent): """Create vcard-tmp XML representation of the field. :Parameters: - `parent`: parent node for the element :Types: - `parent`: `libxml2.xmlNode` :return: xml node with the field data. :returntype: `libxml2.xmlNode`""" n=parent.newChild(None,"TEL",None) for t in ("home","work","voice","fax","pager","msg","cell","video", "bbs","modem","isdn","pcs","pref"): if t in self.type: n.newChild(None,t.upper(),None) n.newTextChild(None,"NUMBER",to_utf8(self.number)) return n class VCardEmail(VCardField): """E-mail vCard field. :Ivariables: - `address`: e-mail address. - `type`: type of the address. :Types: - `address`: `str` - `type`: `list` of "home","work","internet" or "x400". """ def __init__(self,name,value,rfc2425parameters=None): """Initialize a `VCardEmail` object. :Parameters: - `name`: field name - `value`: field value as string or an XML node - `rfc2425parameters`: optional RFC 2425 parameters :Types: - `name`: `str` - `value`: `str` or `libxml2.xmlNode` - `rfc2425parameters`: `dict`""" VCardField.__init__(self,name) if not rfc2425parameters: rfc2425parameters={} if self.name.upper()!="EMAIL": raise RuntimeError("VCardEmail handles only 'EMAIL' type") if isinstance(value,libxml2.xmlNode): self.address=None self.type=[] n=value.children vns=get_node_ns(value) while n: if n.type!='element': n=n.__next__ continue ns=get_node_ns(n) if (ns and vns and ns.getContent()!=vns.getContent()): n=n.__next__ continue if n.name=='USERID': self.address=str(n.getContent(),"utf-8","replace") elif n.name in ("HOME","WORK","INTERNET","X400"): self.type.append(n.name.lower()) n=n.__next__ if self.type==[]: self.type=["internet"] if not self.address: raise Empty("No USERID") else: t=rfc2425parameters.get("type") if t: self.type=t.split(",") else: self.type=["internet"] self.address=value def rfc2426(self): """RFC2426-encode the field content. :return: the field in the RFC 2426 format. :returntype: `str`""" return rfc2425encode("email",self.address,{"type":",".join(self.type)}) def as_xml(self,parent): """Create vcard-tmp XML representation of the field. :Parameters: - `parent`: parent node for the element :Types: - `parent`: `libxml2.xmlNode` :return: xml node with the field data. :returntype: `libxml2.xmlNode`""" n=parent.newChild(None,"EMAIL",None) for t in ("home","work","internet","x400"): if t in self.type: n.newChild(None,t.upper(),None) n.newTextChild(None,"USERID",to_utf8(self.address)) return n class VCardGeo(VCardField): """Geographical location vCard field. :Ivariables: - `lat`: the latitude. - `lon`: the longitude. :Types: - `lat`: `str` - `lon`: `str` """ def __init__(self,name,value,rfc2425parameters=None): """Initialize a `VCardGeo` object. :Parameters: - `name`: field name - `value`: field value as string or an XML node - `rfc2425parameters`: optional RFC 2425 parameters :Types: - `name`: `str` - `value`: `str` or `libxml2.xmlNode` - `rfc2425parameters`: `dict`""" _unused = rfc2425parameters VCardField.__init__(self,name) if self.name.upper()!="GEO": raise RuntimeError("VCardName handles only 'GEO' type") if isinstance(value,libxml2.xmlNode): self.lat,self.lon=[None]*2 n=value.children vns=get_node_ns(value) while n: if n.type!='element': n=n.__next__ continue ns=get_node_ns(n) if (ns and vns and ns.getContent()!=vns.getContent()): n=n.__next__ continue if n.name=='LAT': self.lat=str(n.getContent(),"utf-8") if n.name=='LON': self.lon=str(n.getContent(),"utf-8") n=n.__next__ if not self.lat or not self.lon: raise ValueError("Bad vcard GEO value") else: self.lat,self.lon=(unquote_semicolon(val) for val in non_quoted_semicolon_re.split(value)) def rfc2426(self): """RFC2426-encode the field content. :return: the field in the RFC 2426 format. :returntype: `str`""" return rfc2425encode("geo",';'.join(quote_semicolon(val) for val in (self.lat,self.lon))) def as_xml(self,parent): """Create vcard-tmp XML representation of the field. :Parameters: - `parent`: parent node for the element :Types: - `parent`: `libxml2.xmlNode` :return: xml node with the field data. :returntype: `libxml2.xmlNode`""" n=parent.newChild(None,"GEO",None) n.newTextChild(None,"LAT",to_utf8(self.lat)) n.newTextChild(None,"LON",to_utf8(self.lon)) return n class VCardOrg(VCardField): """Organization vCard field. :Ivariables: - `name`: organization name. - `unit`: organizational unit. :Types: - `name`: `str` - `unit`: `str` """ def __init__(self,name,value,rfc2425parameters=None): """Initialize a `VCardOrg` object. :Parameters: - `name`: field name - `value`: field value as string or an XML node - `rfc2425parameters`: optional RFC 2425 parameters :Types: - `name`: `str` - `value`: `str` or `libxml2.xmlNode` - `rfc2425parameters`: `dict`""" _unused = rfc2425parameters VCardField.__init__(self,name) if self.name.upper()!="ORG": raise RuntimeError("VCardName handles only 'ORG' type") if isinstance(value,libxml2.xmlNode): self.name,self.unit=None,"" n=value.children vns=get_node_ns(value) while n: if n.type!='element': n=n.__next__ continue ns=get_node_ns(n) if (ns and vns and ns.getContent()!=vns.getContent()): n=n.__next__ continue if n.name=='ORGNAME': self.name=str(n.getContent(),"utf-8") if n.name=='ORGUNIT': self.unit=str(n.getContent(),"utf-8") n=n.__next__ if not self.name: raise Empty("Bad vcard ORG value") else: sp=non_quoted_semicolon_re.split(value,1) if len(sp)>1: self.name,self.unit=(unquote_semicolon(val) for val in sp) else: self.name=unquote_semicolon(sp[0]) self.unit=None def rfc2426(self): """RFC2426-encode the field content. :return: the field in the RFC 2426 format. :returntype: `str`""" if self.unit: return rfc2425encode("org",';'.join(quote_semicolon(val) for val in (self.name,self.unit))) else: return rfc2425encode("org",str(quote_semicolon(self.name))) def as_xml(self,parent): """Create vcard-tmp XML representation of the field. :Parameters: - `parent`: parent node for the element :Types: - `parent`: `libxml2.xmlNode` :return: xml node with the field data. :returntype: `libxml2.xmlNode`""" n=parent.newChild(None,"ORG",None) n.newTextChild(None,"ORGNAME",to_utf8(self.name)) n.newTextChild(None,"ORGUNIT",to_utf8(self.unit)) return n class VCardCategories(VCardField): """Categories vCard field. :Ivariables: - `keywords`: category keywords. :Types: - `keywords`: `list` of `str` """ def __init__(self,name,value,rfc2425parameters=None): """Initialize a `VCardCategories` object. :Parameters: - `name`: field name - `value`: field value as string or an XML node - `rfc2425parameters`: optional RFC 2425 parameters :Types: - `name`: `str` - `value`: `str` or `libxml2.xmlNode` - `rfc2425parameters`: `dict`""" _unused = rfc2425parameters VCardField.__init__(self,name) self.name=name if self.name.upper()!="CATEGORIES": raise RuntimeError("VCardName handles only 'CATEGORIES' type") if isinstance(value,libxml2.xmlNode): self.keywords=[] n=value.children vns=get_node_ns(value) while n: if n.type!='element': n=n.__next__ continue ns=get_node_ns(n) if (ns and vns and ns.getContent()!=vns.getContent()): n=n.__next__ continue if n.name=='KEYWORD': self.keywords.append(str(n.getContent(),"utf-8")) n=n.__next__ if not self.keywords: raise Empty("Bad vcard CATEGORIES value") else: self.keywords=value.split(",") def rfc2426(self): """RFC2426-encode the field content. :return: the field in the RFC 2426 format. :returntype: `str`""" return rfc2425encode("keywords",",".join(self.keywords)) def as_xml(self,parent): """Create vcard-tmp XML representation of the field. :Parameters: - `parent`: parent node for the element :Types: - `parent`: `libxml2.xmlNode` :return: xml node with the field data. :returntype: `libxml2.xmlNode`""" n=parent.newChild(None,"CATEGORIES",None) for k in self.keywords: n.newTextChild(None,"KEYWORD",to_utf8(k)) return n class VCardSound(VCardField): """Sound vCard field. :Ivariables: - `sound`: binary sound data (when `uri` is None) - `uri`: sound URI (when `sound` is None) - `phonetic`: phonetic transcription :Types: - `sound`: `str` - `uri`: `str` - `phonetic`: `str`""" def __init__(self,name,value,rfc2425parameters=None): """Initialize a `VCardSound` object. :Parameters: - `name`: field name - `value`: field value as string or an XML node - `rfc2425parameters`: optional RFC 2425 parameters :Types: - `name`: `str` - `value`: `str` or `libxml2.xmlNode` - `rfc2425parameters`: `dict`""" VCardField.__init__(self,name) if not rfc2425parameters: rfc2425parameters={} self.uri,self.sound,self.phonetic=[None]*3 if isinstance(value,libxml2.xmlNode): n=value.children vns=get_node_ns(value) while n: if n.type!='element': n=n.__next__ continue ns=get_node_ns(n) if (ns and vns and ns.getContent()!=vns.getContent()): n=n.__next__ continue if n.name=='BINVAL': if (self.phonetic or self.uri): raise ValueError("Bad SOUND value in vcard") self.sound=base64.decodestring(n.getContent()) if n.name=='PHONETIC': if (self.sound or self.uri): raise ValueError("Bad SOUND value in vcard") self.phonetic=str(n.getContent(),"utf-8","replace") if n.name=='EXTVAL': if (self.phonetic or self.sound): raise ValueError("Bad SOUND value in vcard") self.uri=str(n.getContent(),"utf-8","replace") n=n.__next__ if (not self.phonetic and not self.uri and not self.sound): raise Empty("Bad SOUND value in vcard") else: if rfc2425parameters.get("value", "").lower()=="uri": self.uri=value self.sound=None self.phonetic=None else: self.sound=value self.uri=None self.phonetic=None def rfc2426(self): """RFC2426-encode the field content. :return: the field in the RFC 2426 format. :returntype: `str`""" if self.uri: return rfc2425encode(self.name,self.uri,{"value":"uri"}) elif self.sound: return rfc2425encode(self.name,self.sound) def as_xml(self,parent): """Create vcard-tmp XML representation of the field. :Parameters: - `parent`: parent node for the element :Types: - `parent`: `libxml2.xmlNode` :return: xml node with the field data. :returntype: `libxml2.xmlNode`""" n=parent.newChild(None,self.name.upper(),None) if self.uri: n.newTextChild(None,"EXTVAL",to_utf8(self.uri)) elif self.phonetic: n.newTextChild(None,"PHONETIC",to_utf8(self.phonetic)) else: n.newTextChild(None,"BINVAL",binascii.b2a_base64(self.sound)) return n class VCardPrivacy(VCardField): """Privacy vCard field. :Ivariables: - `value`: privacy information about the vcard data ("public", "private" or "confidental") :Types: - `value`: `str` """ def __init__(self,name,value,rfc2425parameters=None): """Initialize a `VCardPrivacy` object. :Parameters: - `name`: field name - `value`: field value as string or an XML node - `rfc2425parameters`: optional RFC 2425 parameters :Types: - `name`: `str` - `value`: `str` or `libxml2.xmlNode` - `rfc2425parameters`: `dict`""" _unused = rfc2425parameters VCardField.__init__(self,name) if isinstance(value,libxml2.xmlNode): self.value=None n=value.children vns=get_node_ns(value) while n: if n.type!='element': n=n.__next__ continue ns=get_node_ns(n) if (ns and vns and ns.getContent()!=vns.getContent()): n=n.__next__ continue if n.name=='PUBLIC': self.value="public" elif n.name=='PRIVATE': self.value="private" elif n.name=='CONFIDENTAL': self.value="confidental" n=n.__next__ if not self.value: raise Empty else: self.value=value def rfc2426(self): """RFC2426-encode the field content. :return: the field in the RFC 2426 format. :returntype: `str`""" return rfc2425encode(self.name,self.value) def as_xml(self,parent): """Create vcard-tmp XML representation of the field. :Parameters: - `parent`: parent node for the element :Types: - `parent`: `libxml2.xmlNode` :return: xml node with the field data. :returntype: `libxml2.xmlNode`""" if self.value in ("public","private","confidental"): n=parent.newChild(None,self.name.upper(),None) n.newChild(None,self.value.upper(),None) return n return None class VCardKey(VCardField): """Key vCard field. :Ivariables: - `type`: key type. - `cred`: key data. :Types: - `type`: `str` - `cred`: `str` """ def __init__(self,name,value,rfc2425parameters=None): """Initialize a `VCardKey` object. :Parameters: - `name`: field name - `value`: field value as string or an XML node - `rfc2425parameters`: optional RFC 2425 parameters :Types: - `name`: `str` - `value`: `str` or `libxml2.xmlNode` - `rfc2425parameters`: `dict`""" VCardField.__init__(self,name) if not rfc2425parameters: rfc2425parameters={} if isinstance(value,libxml2.xmlNode): self.type,self.cred=None,None n=value.children vns=get_node_ns(value) while n: if n.type!='element': n=n.__next__ continue ns=get_node_ns(n) if (ns and vns and ns.getContent()!=vns.getContent()): n=n.__next__ continue if n.name=='TYPE': self.type=str(n.getContent(),"utf-8","replace") if n.name=='CRED': self.cred=base64.decodestring(n.getContent()) n=n.__next__ if not self.cred: raise Empty("Bad %s value in vcard" % (name,)) else: self.type=rfc2425parameters.get("type") self.cred=value def rfc2426(self): """RFC2426-encode the field content. :return: the field in the RFC 2426 format. :returntype: `str`""" if self.type: p={"type":self.type} else: p={} return rfc2425encode(self.name,self.cred,p) def as_xml(self,parent): """Create vcard-tmp XML representation of the field. :Parameters: - `parent`: parent node for the element :Types: - `parent`: `libxml2.xmlNode` :return: xml node with the field data. :returntype: `libxml2.xmlNode`""" n=parent.newChild(None,self.name.upper(),None) if self.type: n.newTextChild(None,"TYPE",self.type) n.newTextChild(None,"CRED",binascii.b2a_base64(self.cred)) return n class VCard(StanzaPayloadObject): """Jabber (vcard-temp) or RFC2426 vCard. :Ivariables: - `fn`: full name. - `n`: structural name. - `nickname`: nickname(s). - `photo`: photo(s). - `bday`: birthday date(s). - `adr`: address(es). - `label`: address label(s). - `tel`: phone number(s). - `email`: e-mail address(es). - `jabberid`: JID(s). - `mailer`: mailer(s). - `tz`: timezone(s). - `geo`: geolocation(s). - `title`: title(s). - `role`: role(s). - `logo`: logo(s). - `org`: organization(s). - `categories`: categories. - `note`: note(s). - `prodid`: product id(s). - `rev`: revision(s). - `sort-string`: sort string(s). - `sound`: sound(s). - `uid`: user identifier(s). - `url`: URL(s). - `class`: class(es). - `key`: key(s). - `desc`: description. :Types: - `fn`: `VCardString`, - `n`: `VCardName`, - `nickname`: `list` of `VCardString` - `photo`: `list` of `VCardImage` - `bday`: `list` of `VCardString` - `adr`: `list` of `VCardAdr` - `label`: `list` of `VCardLabel` - `tel`: `list` of `VCardTel` - `email`: `list` of `VCardEmail` - `jabberid`: `list` of `VCardJID` - `mailer`: `list` of `VCardString` - `tz`: `list` of `VCardString` - `geo`: `list` of `VCardGeo` - `title`: `list` of `VCardString` - `role`: `list` of `VCardString` - `logo`: `list` of `VCardImage` - `org`: `list` of `VCardOrg` - `categories`: `list` of `VCardCategories` - `note`: `list` of `VCardString` - `prodid`: `list` of `VCardString` - `rev`: `list` of `VCardString` - `sort-string`: `list` of `VCardString` - `sound`: `list` of `VCardSound` - `uid`: `list` of `VCardString` - `url`: `list` of `VCardString` - `class`: `list` of `VCardString` - `key`: `list` of `VCardKey` - `desc`: `list` of `VCardXString` """ xml_element_name = "vCard" xml_element_namespace = VCARD_NS components={ #"VERSION": (VCardString,"optional"), "FN": (VCardString,"required"), "N": (VCardName,"required"), "NICKNAME": (VCardString,"multi"), "PHOTO": (VCardImage,"multi"), "BDAY": (VCardString,"multi"), "ADR": (VCardAdr,"multi"), "LABEL": (VCardLabel,"multi"), "TEL": (VCardTel,"multi"), "EMAIL": (VCardEmail,"multi"), "JABBERID": (VCardJID,"multi"), "MAILER": (VCardString,"multi"), "TZ": (VCardString,"multi"), "GEO": (VCardGeo,"multi"), "TITLE": (VCardString,"multi"), "ROLE": (VCardString,"multi"), "LOGO": (VCardImage,"multi"), "AGENT": ("VCardAgent","ignore"), #FIXME: agent field "ORG": (VCardOrg,"multi"), "CATEGORIES": (VCardCategories,"multi"), "NOTE": (VCardString,"multi"), "PRODID": (VCardString,"multi"), "REV": (VCardString,"multi"), "SORT-STRING": (VCardString,"multi"), "SOUND": (VCardSound,"multi"), "UID": (VCardString,"multi"), "URL": (VCardString,"multi"), "CLASS": (VCardString,"multi"), "KEY": (VCardKey,"multi"), "DESC": (VCardXString,"multi"), }; def __init__(self,data): """Initialize a VCard object from data which may be XML node or an RFC2426 string. :Parameters: - `data`: vcard to parse. :Types: - `data`: `libxml2.xmlNode`, `str` or `str`""" # to make pylint happy self.n = None del self.n self.content={} if isinstance(data,libxml2.xmlNode): self.__from_xml(data) else: self.__from_rfc2426(data) if not self.content.get("N") and self.content.get("FN"): s=self.content['FN'].value.replace(";",",") s=s.split(None,2) if len(s)==2: s="%s;%s;;;" % (s[1],s[0]) elif len(s)==3: s="%s;%s;%s" % (s[2],s[0],s[1]) else: s="%s;;;;" % (s[0],) self.content["N"]=VCardName("N",s) elif not self.content.get("FN") and self.content.get("N"): self.__make_fn() for c, (_unused, tp) in list(self.components.items()): if c in self.content: continue if tp=="required": raise ValueError("%s is missing" % (c,)) elif tp=="multi": self.content[c]=[] elif tp=="optional": self.content[c]=None else: continue def __make_fn(self): """Initialize the mandatory `self.fn` from `self.n`. This is a workaround for buggy clients which set only one of them.""" s=[] if self.n.prefix: s.append(self.n.prefix) if self.n.given: s.append(self.n.given) if self.n.middle: s.append(self.n.middle) if self.n.family: s.append(self.n.family) if self.n.suffix: s.append(self.n.suffix) s=" ".join(s) self.content["FN"]=VCardString("FN", s, empty_ok = True) def __from_xml(self,data): """Initialize a VCard object from XML node. :Parameters: - `data`: vcard to parse. :Types: - `data`: `libxml2.xmlNode`""" ns=get_node_ns(data) if ns and ns.getContent()!=VCARD_NS: raise ValueError("Not in the %r namespace" % (VCARD_NS,)) if data.name!="vCard": raise ValueError("Bad root element name: %r" % (data.name,)) n=data.children dns=get_node_ns(data) while n: if n.type!='element': n=n.__next__ continue ns=get_node_ns(n) if (ns and dns and ns.getContent()!=dns.getContent()): n=n.__next__ continue if n.name not in self.components: n=n.__next__ continue cl,tp=self.components[n.name] if tp in ("required","optional"): if n.name in self.content: raise ValueError("Duplicate %s" % (n.name,)) try: self.content[n.name]=cl(n.name,n) except Empty: pass elif tp=="multi": if n.name not in self.content: self.content[n.name]=[] try: self.content[n.name].append(cl(n.name,n)) except Empty: pass n=n.__next__ def __from_rfc2426(self,data): """Initialize a VCard object from an RFC2426 string. :Parameters: - `data`: vcard to parse. :Types: - `data`: `libxml2.xmlNode`, `str` or `str`""" data=from_utf8(data) lines=data.split("\n") started=0 current=None for l in lines: if not l: continue if l[-1]=="\r": l=l[:-1] if not l: continue if l[0] in " \t": if current is None: continue current+=l[1:] continue if not started and current and current.upper().strip()=="BEGIN:VCARD": started=1 elif started and current.upper().strip()=="END:VCARD": current=None break elif current and started: self._process_rfc2425_record(current) current=l if started and current: self._process_rfc2425_record(current) def _process_rfc2425_record(self,data): """Parse single RFC2425 record and update attributes of `self`. :Parameters: - `data`: the record (probably multiline) :Types: - `data`: `str`""" label,value=data.split(":",1) value=value.replace("\\n","\n").replace("\\N","\n") psplit=label.lower().split(";") name=psplit[0] params=psplit[1:] if "." in name: name=name.split(".",1)[1] name=name.upper() if name in ("X-DESC","X-JABBERID"): name=name[2:] if name not in self.components: return if params: params=dict([p.split("=",1) for p in params]) cl,tp=self.components[name] if tp in ("required","optional"): if name in self.content: raise ValueError("Duplicate %s" % (name,)) try: self.content[name]=cl(name,value,params) except Empty: pass elif tp=="multi": if name not in self.content: self.content[name]=[] try: self.content[name].append(cl(name,value,params)) except Empty: pass else: return def __repr__(self): return "<vCard of %r>" % (self.content["FN"].value,) def rfc2426(self): """Get the RFC2426 representation of `self`. :return: the UTF-8 encoded RFC2426 representation. :returntype: `str`""" ret="begin:VCARD\r\n" ret+="version:3.0\r\n" for _unused, value in list(self.content.items()): if value is None: continue if type(value) is list: for v in value: ret+=v.rfc2426() else: v=value.rfc2426() ret+=v return ret+"end:VCARD\r\n" def complete_xml_element(self, xmlnode, _unused): """Complete the XML node with `self` content. Should be overriden in classes derived from `StanzaPayloadObject`. :Parameters: - `xmlnode`: XML node with the element being built. It has already right name and namespace, but no attributes or content. - `_unused`: document to which the element belongs. :Types: - `xmlnode`: `libxml2.xmlNode` - `_unused`: `libxml2.xmlDoc`""" for _unused1, value in list(self.content.items()): if value is None: continue if type(value) is list: for v in value: v.as_xml(xmlnode) else: value.as_xml(xmlnode) def __getattr__(self,name): try: return self.content[name.upper().replace("_","-")] except KeyError: raise AttributeError("Attribute %r not found" % (name,)) def __getitem__(self,name): return self.content[name.upper()] # vi: sts=4 et sw=4
apache-2.0
[ 3, 199, 3, 334, 35, 9, 1898, 13004, 13, 6542, 1603, 7984, 75, 1804, 265, 73, 825, 90, 9745, 665, 3387, 22760, 527, 32, 3387, 22760, 527, 14, 846, 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, 6401, 1696, 1684, 844, 3394, 199, 3, 499, 14, 17, 465, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 1227, 2194, 603, 405, 437, 432, 12, 445, 455, 9528, 12, 4828, 12497, 7491, 12, 8217, 14, 199, 3, 199, 3, 4287, 26, 3507, 13, 1328, 29, 55, 1644, 996, 199, 624, 42, 20280, 373, 13832, 436, 14735, 334, 14468, 5504, 1479, 9, 373, 13832, 4514, 14, 199, 199, 23008, 391, 857, 3659, 26, 523, 446, 658, 42, 6102, 13470, 665, 1014, 921, 1544, 14, 25075, 14, 1308, 15, 6532, 1190, 15, 74, 1545, 13, 32683, 14, 1360, 8637, 363, 523, 446, 658, 14468, 5504, 821, 665, 1014, 921, 1544, 14, 15799, 14, 1308, 15, 8973, 15, 8973, 1194, 821, 14, 2424, 8637, 363, 523, 446, 658, 14468, 5504, 1479, 665, 1014, 921, 1544, 14, 15799, 14, 1308, 15, 8973, 15, 8973, 1194, 1479, 14, 2424, 8637, 363, 199, 624, 6905, 199, 363, 21841, 363, 628, 26854, 655, 2, 199, 199, 3730, 3545, 13076, 16, 93, 365, 440, 5966, 28286, 367, 1611, 56, 1658, 48, 18, 1674, 908, 3460, 354, 8964, 199, 199, 646, 1300, 772, 199, 646, 14755, 199, 646, 15404, 18, 199, 646, 295, 199, 199, 646, 1134, 26608, 14, 14203, 199, 504, 2508, 1208, 492, 370, 63, 1624, 24, 12, 504, 63, 1624, 24, 199, 504, 2508, 10198, 274, 400, 345, 492, 664, 63, 932, 63, 561, 199, 504, 2508, 1462, 492, 1933, 19024, 17215, 1692, 199, 504, 2508, 3924, 492, 8857, 2017, 3658, 547, 12, 1603, 998, 29513, 3658, 547, 12, 1603, 998, 547, 199, 199, 9454, 7816, 63, 2709, 628, 86, 5841, 13, 808, 2, 199, 199, 533, 9630, 8, 1726, 304, 272, 408, 1726, 4915, 1380, 6057, 2701, 373, 5841, 1819, 14, 32753, 1819, 911, 272, 506, 5525, 1041, 272, 986, 199, 199, 1078, 63, 875, 63, 264, 29, 264, 14, 2014, 8, 82, 16136, 7023, 87, 60, 68, 971, 84, 3672, 22550, 199, 2865, 63, 9888, 63, 19290, 12167, 63, 264, 29, 264, 14, 2014, 8, 82, 10120, 11230, 1103, 2736, 358, 199, 199, 318, 6313, 63, 19290, 12167, 8, 585, 304, 272, 372, 574, 14, 1814, 8, 82, 7, 10805, 519, 1154, 10784, 199, 199, 318, 14342, 63, 19290, 12167, 8, 585, 304, 272, 372, 574, 14, 1814, 8, 82, 1154, 10805, 519, 7, 10784, 199, 199, 318, 18158, 1194, 821, 2143, 8, 354, 12, 585, 12, 3214, 29, 403, 12, 6043, 628, 1624, 13, 24, 2349, 272, 408, 1327, 6021, 282, 373, 13832, 901, 1901, 376, 7329, 1194, 821, 1004, 14, 339, 520, 5976, 26, 267, 446, 658, 354, 8340, 901, 730, 536, 267, 446, 658, 585, 8340, 901, 574, 267, 446, 658, 3214, 8340, 2716, 2633, 267, 446, 658, 6043, 8340, 2644, 402, 314, 1072, 436, 402, 314, 658, 585, 64, 334, 692, 440, 881, 658, 495, 10522, 272, 520, 4100, 26, 267, 446, 658, 354, 8340, 658, 495, 64, 267, 446, 658, 585, 8340, 658, 495, 64, 503, 658, 495, 64, 267, 446, 658, 3214, 8340, 658, 807, 64, 402, 658, 495, 64, 1035, 658, 495, 64, 267, 446, 658, 6043, 8340, 658, 495, 64, 339, 520, 1107, 26, 314, 5737, 7329, 1194, 821, 1004, 334, 19614, 1699, 770, 9, 272, 520, 3292, 300, 25116, 26, 658, 495, 64, 624, 272, 340, 440, 2633, 26, 267, 2633, 7622, 272, 340, 730, 8, 585, 9, 365, 620, 26, 267, 574, 29, 585, 14, 1814, 4582, 82, 60, 78, 2266, 1103, 78, 531, 267, 574, 29, 585, 14, 1814, 4582, 78, 2266, 1103, 78, 531, 267, 574, 29, 585, 14, 1814, 4582, 82, 2266, 1103, 78, 531, 267, 574, 29, 585, 14, 2143, 8, 6043, 4589, 1814, 531, 272, 916, 730, 8, 585, 9, 365, 440, 620, 26, 267, 746, 3146, 480, 5725, 730, 367, 18158, 1194, 821, 574, 531, 272, 916, 440, 1686, 63, 875, 63, 264, 14, 1431, 8, 585, 304, 267, 2633, 905, 2991, 937, 628, 66, 2, 267, 574, 29, 27460, 14, 66, 18, 65, 63, 1095, 772, 8, 585, 9, 339, 2203, 29, 495, 8, 354, 680, 2325, 342, 272, 367, 1022, 12, 86, 315, 769, 8, 3214, 14, 1744, 5109, 267, 2203, 11, 628, 27, 5, 83, 2458, 83, 2, 450, 334, 495, 8, 75, 395, 495, 8, 86, 430, 272, 2203, 10365, 5122, 272, 1830, 8, 552, 8, 585, 13032, 2760, 304, 267, 2203, 10365, 585, 1491, 2760, 2807, 3212, 82, 60, 78, 298, 267, 574, 29, 585, 59, 2760, 2938, 272, 2203, 10365, 585, 25789, 82, 60, 78, 2, 272, 372, 2203, 199, 199, 533, 812, 13832, 792, 26, 272, 408, 1563, 1021, 367, 373, 13832, 1504, 14, 339, 520, 41, 3669, 26, 267, 446, 658, 354, 8340, 536, 402, 314, 901, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 354, 304, 267, 408, 9345, 282, 658, 9454, 1005, 792, 64, 909, 14, 398, 2494, 2399, 536, 14, 398, 520, 5976, 26, 288, 446, 658, 354, 8340, 901, 536, 267, 520, 4100, 26, 288, 446, 658, 354, 8340, 658, 495, 64, 624, 267, 291, 14, 354, 29, 354, 272, 347, 636, 2722, 721, 277, 304, 267, 372, 23054, 83, 450, 82, 4335, 450, 334, 277, 855, 533, 3108, 277, 14, 8973, 1194, 1479, 1012, 272, 347, 18158, 1194, 1479, 8, 277, 304, 267, 408, 14468, 1194, 1479, 13 ]
[ 199, 3, 334, 35, 9, 1898, 13004, 13, 6542, 1603, 7984, 75, 1804, 265, 73, 825, 90, 9745, 665, 3387, 22760, 527, 32, 3387, 22760, 527, 14, 846, 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, 6401, 1696, 1684, 844, 3394, 199, 3, 499, 14, 17, 465, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 1227, 2194, 603, 405, 437, 432, 12, 445, 455, 9528, 12, 4828, 12497, 7491, 12, 8217, 14, 199, 3, 199, 3, 4287, 26, 3507, 13, 1328, 29, 55, 1644, 996, 199, 624, 42, 20280, 373, 13832, 436, 14735, 334, 14468, 5504, 1479, 9, 373, 13832, 4514, 14, 199, 199, 23008, 391, 857, 3659, 26, 523, 446, 658, 42, 6102, 13470, 665, 1014, 921, 1544, 14, 25075, 14, 1308, 15, 6532, 1190, 15, 74, 1545, 13, 32683, 14, 1360, 8637, 363, 523, 446, 658, 14468, 5504, 821, 665, 1014, 921, 1544, 14, 15799, 14, 1308, 15, 8973, 15, 8973, 1194, 821, 14, 2424, 8637, 363, 523, 446, 658, 14468, 5504, 1479, 665, 1014, 921, 1544, 14, 15799, 14, 1308, 15, 8973, 15, 8973, 1194, 1479, 14, 2424, 8637, 363, 199, 624, 6905, 199, 363, 21841, 363, 628, 26854, 655, 2, 199, 199, 3730, 3545, 13076, 16, 93, 365, 440, 5966, 28286, 367, 1611, 56, 1658, 48, 18, 1674, 908, 3460, 354, 8964, 199, 199, 646, 1300, 772, 199, 646, 14755, 199, 646, 15404, 18, 199, 646, 295, 199, 199, 646, 1134, 26608, 14, 14203, 199, 504, 2508, 1208, 492, 370, 63, 1624, 24, 12, 504, 63, 1624, 24, 199, 504, 2508, 10198, 274, 400, 345, 492, 664, 63, 932, 63, 561, 199, 504, 2508, 1462, 492, 1933, 19024, 17215, 1692, 199, 504, 2508, 3924, 492, 8857, 2017, 3658, 547, 12, 1603, 998, 29513, 3658, 547, 12, 1603, 998, 547, 199, 199, 9454, 7816, 63, 2709, 628, 86, 5841, 13, 808, 2, 199, 199, 533, 9630, 8, 1726, 304, 272, 408, 1726, 4915, 1380, 6057, 2701, 373, 5841, 1819, 14, 32753, 1819, 911, 272, 506, 5525, 1041, 272, 986, 199, 199, 1078, 63, 875, 63, 264, 29, 264, 14, 2014, 8, 82, 16136, 7023, 87, 60, 68, 971, 84, 3672, 22550, 199, 2865, 63, 9888, 63, 19290, 12167, 63, 264, 29, 264, 14, 2014, 8, 82, 10120, 11230, 1103, 2736, 358, 199, 199, 318, 6313, 63, 19290, 12167, 8, 585, 304, 272, 372, 574, 14, 1814, 8, 82, 7, 10805, 519, 1154, 10784, 199, 199, 318, 14342, 63, 19290, 12167, 8, 585, 304, 272, 372, 574, 14, 1814, 8, 82, 1154, 10805, 519, 7, 10784, 199, 199, 318, 18158, 1194, 821, 2143, 8, 354, 12, 585, 12, 3214, 29, 403, 12, 6043, 628, 1624, 13, 24, 2349, 272, 408, 1327, 6021, 282, 373, 13832, 901, 1901, 376, 7329, 1194, 821, 1004, 14, 339, 520, 5976, 26, 267, 446, 658, 354, 8340, 901, 730, 536, 267, 446, 658, 585, 8340, 901, 574, 267, 446, 658, 3214, 8340, 2716, 2633, 267, 446, 658, 6043, 8340, 2644, 402, 314, 1072, 436, 402, 314, 658, 585, 64, 334, 692, 440, 881, 658, 495, 10522, 272, 520, 4100, 26, 267, 446, 658, 354, 8340, 658, 495, 64, 267, 446, 658, 585, 8340, 658, 495, 64, 503, 658, 495, 64, 267, 446, 658, 3214, 8340, 658, 807, 64, 402, 658, 495, 64, 1035, 658, 495, 64, 267, 446, 658, 6043, 8340, 658, 495, 64, 339, 520, 1107, 26, 314, 5737, 7329, 1194, 821, 1004, 334, 19614, 1699, 770, 9, 272, 520, 3292, 300, 25116, 26, 658, 495, 64, 624, 272, 340, 440, 2633, 26, 267, 2633, 7622, 272, 340, 730, 8, 585, 9, 365, 620, 26, 267, 574, 29, 585, 14, 1814, 4582, 82, 60, 78, 2266, 1103, 78, 531, 267, 574, 29, 585, 14, 1814, 4582, 78, 2266, 1103, 78, 531, 267, 574, 29, 585, 14, 1814, 4582, 82, 2266, 1103, 78, 531, 267, 574, 29, 585, 14, 2143, 8, 6043, 4589, 1814, 531, 272, 916, 730, 8, 585, 9, 365, 440, 620, 26, 267, 746, 3146, 480, 5725, 730, 367, 18158, 1194, 821, 574, 531, 272, 916, 440, 1686, 63, 875, 63, 264, 14, 1431, 8, 585, 304, 267, 2633, 905, 2991, 937, 628, 66, 2, 267, 574, 29, 27460, 14, 66, 18, 65, 63, 1095, 772, 8, 585, 9, 339, 2203, 29, 495, 8, 354, 680, 2325, 342, 272, 367, 1022, 12, 86, 315, 769, 8, 3214, 14, 1744, 5109, 267, 2203, 11, 628, 27, 5, 83, 2458, 83, 2, 450, 334, 495, 8, 75, 395, 495, 8, 86, 430, 272, 2203, 10365, 5122, 272, 1830, 8, 552, 8, 585, 13032, 2760, 304, 267, 2203, 10365, 585, 1491, 2760, 2807, 3212, 82, 60, 78, 298, 267, 574, 29, 585, 59, 2760, 2938, 272, 2203, 10365, 585, 25789, 82, 60, 78, 2, 272, 372, 2203, 199, 199, 533, 812, 13832, 792, 26, 272, 408, 1563, 1021, 367, 373, 13832, 1504, 14, 339, 520, 41, 3669, 26, 267, 446, 658, 354, 8340, 536, 402, 314, 901, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 354, 304, 267, 408, 9345, 282, 658, 9454, 1005, 792, 64, 909, 14, 398, 2494, 2399, 536, 14, 398, 520, 5976, 26, 288, 446, 658, 354, 8340, 901, 536, 267, 520, 4100, 26, 288, 446, 658, 354, 8340, 658, 495, 64, 624, 267, 291, 14, 354, 29, 354, 272, 347, 636, 2722, 721, 277, 304, 267, 372, 23054, 83, 450, 82, 4335, 450, 334, 277, 855, 533, 3108, 277, 14, 8973, 1194, 1479, 1012, 272, 347, 18158, 1194, 1479, 8, 277, 304, 267, 408, 14468, 1194, 1479, 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, 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 ]
hulop/SfMLocalization
PyViewMatch/src/viewMatchPyCV.py
1
5231
################################################################################ # Copyright (c) 2015 IBM Corporation # # 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 argparse import os import json import csv import scipy as sp import cv2 MATCH_FILE = "matches.f.txt" def showKeypointMatch(matchFolder, matchFile, ind1, ind2): sfm_data_dir = os.path.join(matchFolder,"sfm_data.json") matchFile = os.path.join(matchFolder,matchFile) with open(sfm_data_dir) as sfm_data_file: sfm_data = json.load(sfm_data_file) rootpath = sfm_data["root_path"] file1 = sfm_data["views"][ind1]["value"]["ptr_wrapper"]["data"]["filename"] img1 = os.path.join(rootpath,file1) img1Mat = cv2.imread(img1) feat1 = os.path.join(matchFolder,file1[0:-3]+"feat") file2 = sfm_data["views"][ind2]["value"]["ptr_wrapper"]["data"]["filename"] img2 = os.path.join(rootpath,file2) img2Mat = cv2.imread(img2) feat2 = os.path.join(matchFolder,file2[0:-3]+"feat") feat1Data = [ row for row in csv.reader(open(feat1, "r"), delimiter=' ') if len(row) != 0] feat2Data = [ row for row in csv.reader(open(feat2, "r"), delimiter=' ') if len(row) != 0] matchData = [] with open(matchFile, "r") as f: reader = csv.reader(f, delimiter=' ') while True: try: imagePair = next(reader) matchNum = next(reader) for x in range(int(matchNum[0])): keypointPair = next(reader) if (int(imagePair[0])==ind1 and int(imagePair[1])==ind2): matchData.append([int(keypointPair[0]),int(keypointPair[1])]) elif (int(imagePair[0])==ind2 and int(imagePair[1])==ind1): matchData.append([int(keypointPair[1]),int(keypointPair[0])]) except csv.Error: print "Error" except StopIteration: break # visualization h1, w1 = img1Mat.shape[:2] h2, w2 = img2Mat.shape[:2] view = sp.zeros((max(h1, h2), w1 + w2, 3), sp.uint8) view[:h1, :w1] = img1Mat view[:h2, w1:] = img2Mat for m in matchData: # draw the keypoints # print m.queryIdx, m.trainIdx, m.distance color = tuple([sp.random.randint(0, 255) for _ in xrange(3)]) cv2.line(view, (int(float(feat1Data[m[0]][0])), int(float(feat1Data[m[0]][1]))), (int(float(feat2Data[m[1]][0])) + w1, int(float(feat2Data[m[1]][1]))), color) cv2.imshow("image 1", cv2.resize(img1Mat, (0,0), fx=0.5, fy=0.5)) cv2.imshow("image 2", cv2.resize(img2Mat, (0,0), fx=0.5, fy=0.5)) cv2.imshow("matching", cv2.resize(view, (0,0), fx=0.5, fy=0.5)) cv2.waitKey(1) def main(): description = 'This script is for visualizing putative matching result created by OpenMVG. ' parser = argparse.ArgumentParser(description=description) parser.add_argument('match_dir', action='store', nargs=None, const=None, \ default=None, type=str, choices=None, metavar=None, \ help='Directory path where matches results is stored.') parser.add_argument('ind1', action='store', nargs=None, const=None, \ default=None, type=int, choices=None, metavar=None, \ help='view index 1.') parser.add_argument('ind2', action='store', nargs=None, const=None, \ default=None, type=int, choices=None, metavar=None, \ help='view index 2.') args = parser.parse_args() matchFolder = args.match_dir ind1 = args.ind1 ind2 = args.ind2 while True: print "show matching images : ",ind1," <-> ",ind2 showKeypointMatch(matchFolder, MATCH_FILE, ind1, ind2) key = cv2.waitKey(-1) if key==65362: # up ind1 += 1 elif key==65364: # down ind1 -= 1 elif key==65361: # left ind2 += 1 elif key==65363: # right ind2 -= 1 elif key==27: break if __name__ == "__main__": main()
mit
[ 13289, 199, 3, 1898, 334, 67, 9, 6900, 26202, 11098, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 3, 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, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 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, 1621, 199, 3, 2334, 4141, 14, 199, 13289, 199, 199, 646, 7534, 199, 646, 747, 199, 646, 2022, 199, 646, 7392, 199, 646, 7026, 465, 2249, 199, 646, 6277, 18, 199, 199, 14747, 63, 3817, 275, 298, 6742, 14, 70, 14, 2424, 2, 199, 199, 318, 2498, 1197, 1403, 4486, 8, 1431, 7850, 12, 1336, 1173, 12, 7654, 17, 12, 7654, 18, 304, 272, 308, 10886, 63, 576, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1431, 7850, 4589, 7646, 77, 63, 576, 14, 1001, 531, 272, 1336, 1173, 275, 747, 14, 515, 14, 904, 8, 1431, 7850, 12, 1431, 1173, 9, 2286, 543, 1551, 8, 7646, 77, 63, 576, 63, 694, 9, 465, 308, 10886, 63, 576, 63, 493, 26, 267, 308, 10886, 63, 576, 275, 2022, 14, 912, 8, 7646, 77, 63, 576, 63, 493, 9, 5493, 1738, 515, 275, 308, 10886, 63, 576, 905, 1231, 63, 515, 937, 2286, 570, 17, 275, 308, 10886, 63, 576, 905, 4196, 9210, 688, 17, 7541, 585, 6611, 4695, 63, 5029, 6611, 576, 6611, 1501, 937, 272, 6050, 17, 275, 747, 14, 515, 14, 904, 8, 1231, 515, 12, 493, 17, 9, 272, 6050, 17, 14817, 275, 6277, 18, 14, 1017, 739, 8, 4060, 17, 9, 272, 13953, 17, 275, 747, 14, 515, 14, 904, 8, 1431, 7850, 12, 493, 17, 59, 16, 6809, 19, 2807, 2, 11873, 531, 2286, 570, 18, 275, 308, 10886, 63, 576, 905, 4196, 9210, 688, 18, 7541, 585, 6611, 4695, 63, 5029, 6611, 576, 6611, 1501, 937, 272, 6050, 18, 275, 747, 14, 515, 14, 904, 8, 1231, 515, 12, 493, 18, 9, 272, 6050, 18, 14817, 275, 6277, 18, 14, 1017, 739, 8, 4060, 18, 9, 272, 13953, 18, 275, 747, 14, 515, 14, 904, 8, 1431, 7850, 12, 493, 18, 59, 16, 6809, 19, 2807, 2, 11873, 531, 2286, 13953, 17, 1451, 275, 359, 1962, 367, 1962, 315, 7392, 14, 5503, 8, 1490, 8, 11873, 17, 12, 298, 82, 1288, 11172, 534, 5320, 340, 822, 8, 1143, 9, 1137, 378, 61, 272, 13953, 18, 1451, 275, 359, 1962, 367, 1962, 315, 7392, 14, 5503, 8, 1490, 8, 11873, 18, 12, 298, 82, 1288, 11172, 534, 5320, 340, 822, 8, 1143, 9, 1137, 378, 61, 272, 1336, 1451, 275, 942, 272, 543, 1551, 8, 1431, 1173, 12, 298, 82, 531, 465, 289, 26, 267, 7002, 275, 7392, 14, 5503, 8, 70, 12, 11172, 534, 5320, 267, 1830, 715, 26, 288, 862, 26, 3777, 355, 1834, 12882, 275, 2163, 8, 5503, 9, 355, 1336, 5667, 275, 2163, 8, 5503, 9, 355, 367, 671, 315, 1425, 8, 442, 8, 1431, 5667, 59, 16, 18710, 490, 790, 1403, 12882, 275, 2163, 8, 5503, 9, 490, 340, 334, 442, 8, 1569, 12882, 59, 16, 566, 389, 688, 17, 436, 1109, 8, 1569, 12882, 59, 17, 566, 389, 688, 18, 304, 717, 1336, 1451, 14, 740, 779, 442, 8, 498, 1403, 12882, 59, 16, 2522, 442, 8, 498, 1403, 12882, 59, 17, 24310, 490, 916, 334, 442, 8, 1569, 12882, 59, 16, 566, 389, 688, 18, 436, 1109, 8, 1569, 12882, 59, 17, 566, 389, 688, 17, 304, 717, 1336, 1451, 14, 740, 779, 442, 8, 498, 1403, 12882, 59, 17, 2522, 442, 8, 498, 1403, 12882, 59, 16, 24310, 288, 871, 7392, 14, 547, 26, 355, 870, 298, 547, 2, 288, 871, 10852, 26, 355, 2059, 2286, 327, 13104, 2072, 272, 394, 17, 12, 336, 17, 275, 6050, 17, 14817, 14, 1392, 1491, 18, 61, 272, 394, 18, 12, 336, 18, 275, 6050, 18, 14817, 14, 1392, 1491, 18, 61, 272, 2455, 275, 2249, 14, 4250, 1332, 988, 8, 72, 17, 12, 394, 18, 395, 336, 17, 435, 336, 18, 12, 650, 395, 2249, 14, 1635, 24, 9, 272, 2455, 1491, 72, 17, 12, 520, 87, 17, 61, 275, 6050, 17, 14817, 272, 2455, 1491, 72, 18, 12, 336, 17, 2938, 275, 6050, 18, 14817, 2286, 367, 333, 315, 1336, 1451, 26, 267, 327, 5954, 314, 790, 3438, 267, 327, 870, 333, 14, 1131, 12215, 12, 333, 14, 2834, 12215, 12, 333, 14, 5590, 267, 3164, 275, 2008, 779, 681, 14, 2355, 14, 8393, 8, 16, 12, 5450, 9, 367, 485, 315, 4945, 8, 19, 3948, 267, 6277, 18, 14, 604, 8, 1345, 12, 334, 442, 8, 1609, 8, 11873, 17, 1451, 59, 77, 59, 16, 22235, 16, 12884, 1109, 8, 1609, 8, 11873, 17, 1451, 59, 77, 59, 16, 22235, 17, 2459, 395, 334, 442, 8, 1609, 8, 11873, 18, 1451, 59, 77, 59, 17, 22235, 16, 2459, 435, 336, 17, 12, 1109, 8, 1609, 8, 11873, 18, 1451, 59, 77, 59, 17, 22235, 17, 2459, 395, 3164, 9, 2286, 6277, 18, 14, 20413, 480, 1569, 413, 401, 6277, 18, 14, 8709, 8, 4060, 17, 14817, 12 ]
[ 199, 3, 1898, 334, 67, 9, 6900, 26202, 11098, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 3, 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, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 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, 1621, 199, 3, 2334, 4141, 14, 199, 13289, 199, 199, 646, 7534, 199, 646, 747, 199, 646, 2022, 199, 646, 7392, 199, 646, 7026, 465, 2249, 199, 646, 6277, 18, 199, 199, 14747, 63, 3817, 275, 298, 6742, 14, 70, 14, 2424, 2, 199, 199, 318, 2498, 1197, 1403, 4486, 8, 1431, 7850, 12, 1336, 1173, 12, 7654, 17, 12, 7654, 18, 304, 272, 308, 10886, 63, 576, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1431, 7850, 4589, 7646, 77, 63, 576, 14, 1001, 531, 272, 1336, 1173, 275, 747, 14, 515, 14, 904, 8, 1431, 7850, 12, 1431, 1173, 9, 2286, 543, 1551, 8, 7646, 77, 63, 576, 63, 694, 9, 465, 308, 10886, 63, 576, 63, 493, 26, 267, 308, 10886, 63, 576, 275, 2022, 14, 912, 8, 7646, 77, 63, 576, 63, 493, 9, 5493, 1738, 515, 275, 308, 10886, 63, 576, 905, 1231, 63, 515, 937, 2286, 570, 17, 275, 308, 10886, 63, 576, 905, 4196, 9210, 688, 17, 7541, 585, 6611, 4695, 63, 5029, 6611, 576, 6611, 1501, 937, 272, 6050, 17, 275, 747, 14, 515, 14, 904, 8, 1231, 515, 12, 493, 17, 9, 272, 6050, 17, 14817, 275, 6277, 18, 14, 1017, 739, 8, 4060, 17, 9, 272, 13953, 17, 275, 747, 14, 515, 14, 904, 8, 1431, 7850, 12, 493, 17, 59, 16, 6809, 19, 2807, 2, 11873, 531, 2286, 570, 18, 275, 308, 10886, 63, 576, 905, 4196, 9210, 688, 18, 7541, 585, 6611, 4695, 63, 5029, 6611, 576, 6611, 1501, 937, 272, 6050, 18, 275, 747, 14, 515, 14, 904, 8, 1231, 515, 12, 493, 18, 9, 272, 6050, 18, 14817, 275, 6277, 18, 14, 1017, 739, 8, 4060, 18, 9, 272, 13953, 18, 275, 747, 14, 515, 14, 904, 8, 1431, 7850, 12, 493, 18, 59, 16, 6809, 19, 2807, 2, 11873, 531, 2286, 13953, 17, 1451, 275, 359, 1962, 367, 1962, 315, 7392, 14, 5503, 8, 1490, 8, 11873, 17, 12, 298, 82, 1288, 11172, 534, 5320, 340, 822, 8, 1143, 9, 1137, 378, 61, 272, 13953, 18, 1451, 275, 359, 1962, 367, 1962, 315, 7392, 14, 5503, 8, 1490, 8, 11873, 18, 12, 298, 82, 1288, 11172, 534, 5320, 340, 822, 8, 1143, 9, 1137, 378, 61, 272, 1336, 1451, 275, 942, 272, 543, 1551, 8, 1431, 1173, 12, 298, 82, 531, 465, 289, 26, 267, 7002, 275, 7392, 14, 5503, 8, 70, 12, 11172, 534, 5320, 267, 1830, 715, 26, 288, 862, 26, 3777, 355, 1834, 12882, 275, 2163, 8, 5503, 9, 355, 1336, 5667, 275, 2163, 8, 5503, 9, 355, 367, 671, 315, 1425, 8, 442, 8, 1431, 5667, 59, 16, 18710, 490, 790, 1403, 12882, 275, 2163, 8, 5503, 9, 490, 340, 334, 442, 8, 1569, 12882, 59, 16, 566, 389, 688, 17, 436, 1109, 8, 1569, 12882, 59, 17, 566, 389, 688, 18, 304, 717, 1336, 1451, 14, 740, 779, 442, 8, 498, 1403, 12882, 59, 16, 2522, 442, 8, 498, 1403, 12882, 59, 17, 24310, 490, 916, 334, 442, 8, 1569, 12882, 59, 16, 566, 389, 688, 18, 436, 1109, 8, 1569, 12882, 59, 17, 566, 389, 688, 17, 304, 717, 1336, 1451, 14, 740, 779, 442, 8, 498, 1403, 12882, 59, 17, 2522, 442, 8, 498, 1403, 12882, 59, 16, 24310, 288, 871, 7392, 14, 547, 26, 355, 870, 298, 547, 2, 288, 871, 10852, 26, 355, 2059, 2286, 327, 13104, 2072, 272, 394, 17, 12, 336, 17, 275, 6050, 17, 14817, 14, 1392, 1491, 18, 61, 272, 394, 18, 12, 336, 18, 275, 6050, 18, 14817, 14, 1392, 1491, 18, 61, 272, 2455, 275, 2249, 14, 4250, 1332, 988, 8, 72, 17, 12, 394, 18, 395, 336, 17, 435, 336, 18, 12, 650, 395, 2249, 14, 1635, 24, 9, 272, 2455, 1491, 72, 17, 12, 520, 87, 17, 61, 275, 6050, 17, 14817, 272, 2455, 1491, 72, 18, 12, 336, 17, 2938, 275, 6050, 18, 14817, 2286, 367, 333, 315, 1336, 1451, 26, 267, 327, 5954, 314, 790, 3438, 267, 327, 870, 333, 14, 1131, 12215, 12, 333, 14, 2834, 12215, 12, 333, 14, 5590, 267, 3164, 275, 2008, 779, 681, 14, 2355, 14, 8393, 8, 16, 12, 5450, 9, 367, 485, 315, 4945, 8, 19, 3948, 267, 6277, 18, 14, 604, 8, 1345, 12, 334, 442, 8, 1609, 8, 11873, 17, 1451, 59, 77, 59, 16, 22235, 16, 12884, 1109, 8, 1609, 8, 11873, 17, 1451, 59, 77, 59, 16, 22235, 17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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 ]
nvoron23/arangodb
3rdParty/V8-4.3.61/third_party/python_26/Lib/test/test_mimetools.py
58
1780
import unittest from test import test_support import string import StringIO mimetools = test_support.import_module("mimetools", deprecated=True) msgtext1 = mimetools.Message(StringIO.StringIO( """Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8bit Foo! """)) class MimeToolsTest(unittest.TestCase): def test_decodeencode(self): start = string.ascii_letters + "=" + string.digits + "\n" for enc in ['7bit','8bit','base64','quoted-printable', 'uuencode', 'x-uuencode', 'uue', 'x-uue']: i = StringIO.StringIO(start) o = StringIO.StringIO() mimetools.encode(i, o, enc) i = StringIO.StringIO(o.getvalue()) o = StringIO.StringIO() mimetools.decode(i, o, enc) self.assertEqual(o.getvalue(), start) def test_boundary(self): s = set([""]) for i in xrange(100): nb = mimetools.choose_boundary() self.assert_(nb not in s) s.add(nb) def test_message(self): msg = mimetools.Message(StringIO.StringIO(msgtext1)) self.assertEqual(msg.gettype(), "text/plain") self.assertEqual(msg.getmaintype(), "text") self.assertEqual(msg.getsubtype(), "plain") self.assertEqual(msg.getplist(), ["charset=iso-8859-1", "format=flowed"]) self.assertEqual(msg.getparamnames(), ["charset", "format"]) self.assertEqual(msg.getparam("charset"), "iso-8859-1") self.assertEqual(msg.getparam("format"), "flowed") self.assertEqual(msg.getparam("spam"), None) self.assertEqual(msg.getencoding(), "8bit") def test_main(): test_support.run_unittest(MimeToolsTest) if __name__=="__main__": test_main()
apache-2.0
[ 646, 2882, 199, 504, 511, 492, 511, 63, 4058, 199, 199, 646, 1059, 199, 646, 5228, 199, 199, 7626, 2537, 275, 511, 63, 4058, 14, 646, 63, 578, 480, 7626, 2537, 401, 5906, 29, 549, 9, 199, 199, 1328, 505, 17, 275, 6660, 2537, 14, 2209, 8, 6424, 14, 6424, 8, 199, 624, 2714, 13, 804, 26, 1318, 15, 6104, 27, 5960, 29, 4595, 13, 4830, 13, 17, 27, 1475, 29, 1659, 379, 199, 2714, 13, 11761, 13, 7630, 26, 1695, 2075, 199, 199, 5686, 1, 199, 624, 430, 199, 199, 533, 603, 1036, 11654, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 2708, 2143, 8, 277, 304, 267, 1343, 275, 1059, 14, 4371, 63, 16415, 435, 22250, 435, 1059, 14, 7022, 435, 1867, 78, 2, 267, 367, 12011, 315, 788, 23, 2075, 1673, 24, 2075, 1673, 1095, 772, 1673, 9888, 13, 20557, 297, 490, 283, 17031, 2143, 297, 283, 88, 13, 17031, 2143, 297, 283, 85, 310, 297, 283, 88, 13, 85, 310, 2565, 288, 284, 275, 5228, 14, 6424, 8, 928, 9, 288, 312, 275, 5228, 14, 6424, 342, 288, 6660, 2537, 14, 2143, 8, 73, 12, 312, 12, 12011, 9, 288, 284, 275, 5228, 14, 6424, 8, 79, 14, 7150, 1012, 288, 312, 275, 5228, 14, 6424, 342, 288, 6660, 2537, 14, 2708, 8, 73, 12, 312, 12, 12011, 9, 288, 291, 14, 629, 8, 79, 14, 7150, 1062, 1343, 9, 339, 347, 511, 63, 9891, 8, 277, 304, 267, 308, 275, 663, 779, 341, 566, 267, 367, 284, 315, 4945, 8, 1960, 304, 288, 8526, 275, 6660, 2537, 14, 16143, 63, 9891, 342, 288, 291, 14, 479, 2531, 4994, 440, 315, 308, 9, 288, 308, 14, 525, 8, 4994, 9, 339, 347, 511, 63, 1188, 8, 277, 304, 267, 1499, 275, 6660, 2537, 14, 2209, 8, 6424, 14, 6424, 8, 1328, 505, 17, 430, 267, 291, 14, 629, 8, 1328, 14, 362, 466, 1062, 298, 505, 15, 6104, 531, 267, 291, 14, 629, 8, 1328, 14, 362, 973, 466, 1062, 298, 505, 531, 267, 291, 14, 629, 8, 1328, 14, 362, 10512, 1062, 298, 6104, 531, 267, 291, 14, 629, 8, 1328, 14, 362, 10265, 1062, 2097, 6043, 29, 4595, 13, 4830, 13, 17, 401, 298, 908, 29, 1659, 379, 3135, 267, 291, 14, 629, 8, 1328, 14, 362, 635, 1247, 1062, 2097, 6043, 401, 298, 908, 3135, 267, 291, 14, 629, 8, 1328, 14, 362, 635, 480, 6043, 1288, 298, 4595, 13, 4830, 13, 17, 531, 267, 291, 14, 629, 8, 1328, 14, 362, 635, 480, 908, 1288, 298, 1659, 379, 531, 267, 291, 14, 629, 8, 1328, 14, 362, 635, 480, 8283, 1288, 488, 9, 267, 291, 14, 629, 8, 1328, 14, 303, 28139, 1062, 298, 24, 2075, 531, 199, 199, 318, 511, 63, 973, 837, 272, 511, 63, 4058, 14, 1065, 63, 2796, 8, 45, 1036, 11654, 774, 9, 199, 199, 692, 636, 354, 363, 11800, 363, 973, 5727, 272, 511, 63, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2882, 199, 504, 511, 492, 511, 63, 4058, 199, 199, 646, 1059, 199, 646, 5228, 199, 199, 7626, 2537, 275, 511, 63, 4058, 14, 646, 63, 578, 480, 7626, 2537, 401, 5906, 29, 549, 9, 199, 199, 1328, 505, 17, 275, 6660, 2537, 14, 2209, 8, 6424, 14, 6424, 8, 199, 624, 2714, 13, 804, 26, 1318, 15, 6104, 27, 5960, 29, 4595, 13, 4830, 13, 17, 27, 1475, 29, 1659, 379, 199, 2714, 13, 11761, 13, 7630, 26, 1695, 2075, 199, 199, 5686, 1, 199, 624, 430, 199, 199, 533, 603, 1036, 11654, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 2708, 2143, 8, 277, 304, 267, 1343, 275, 1059, 14, 4371, 63, 16415, 435, 22250, 435, 1059, 14, 7022, 435, 1867, 78, 2, 267, 367, 12011, 315, 788, 23, 2075, 1673, 24, 2075, 1673, 1095, 772, 1673, 9888, 13, 20557, 297, 490, 283, 17031, 2143, 297, 283, 88, 13, 17031, 2143, 297, 283, 85, 310, 297, 283, 88, 13, 85, 310, 2565, 288, 284, 275, 5228, 14, 6424, 8, 928, 9, 288, 312, 275, 5228, 14, 6424, 342, 288, 6660, 2537, 14, 2143, 8, 73, 12, 312, 12, 12011, 9, 288, 284, 275, 5228, 14, 6424, 8, 79, 14, 7150, 1012, 288, 312, 275, 5228, 14, 6424, 342, 288, 6660, 2537, 14, 2708, 8, 73, 12, 312, 12, 12011, 9, 288, 291, 14, 629, 8, 79, 14, 7150, 1062, 1343, 9, 339, 347, 511, 63, 9891, 8, 277, 304, 267, 308, 275, 663, 779, 341, 566, 267, 367, 284, 315, 4945, 8, 1960, 304, 288, 8526, 275, 6660, 2537, 14, 16143, 63, 9891, 342, 288, 291, 14, 479, 2531, 4994, 440, 315, 308, 9, 288, 308, 14, 525, 8, 4994, 9, 339, 347, 511, 63, 1188, 8, 277, 304, 267, 1499, 275, 6660, 2537, 14, 2209, 8, 6424, 14, 6424, 8, 1328, 505, 17, 430, 267, 291, 14, 629, 8, 1328, 14, 362, 466, 1062, 298, 505, 15, 6104, 531, 267, 291, 14, 629, 8, 1328, 14, 362, 973, 466, 1062, 298, 505, 531, 267, 291, 14, 629, 8, 1328, 14, 362, 10512, 1062, 298, 6104, 531, 267, 291, 14, 629, 8, 1328, 14, 362, 10265, 1062, 2097, 6043, 29, 4595, 13, 4830, 13, 17, 401, 298, 908, 29, 1659, 379, 3135, 267, 291, 14, 629, 8, 1328, 14, 362, 635, 1247, 1062, 2097, 6043, 401, 298, 908, 3135, 267, 291, 14, 629, 8, 1328, 14, 362, 635, 480, 6043, 1288, 298, 4595, 13, 4830, 13, 17, 531, 267, 291, 14, 629, 8, 1328, 14, 362, 635, 480, 908, 1288, 298, 1659, 379, 531, 267, 291, 14, 629, 8, 1328, 14, 362, 635, 480, 8283, 1288, 488, 9, 267, 291, 14, 629, 8, 1328, 14, 303, 28139, 1062, 298, 24, 2075, 531, 199, 199, 318, 511, 63, 973, 837, 272, 511, 63, 4058, 14, 1065, 63, 2796, 8, 45, 1036, 11654, 774, 9, 199, 199, 692, 636, 354, 363, 11800, 363, 973, 5727, 272, 511, 63, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sunios/android_kernel_xiaomi_msm8x74pro
tools/perf/scripts/python/sched-migration.py
11215
11670
#!/usr/bin/python # # Cpu task migration overview toy # # Copyright (C) 2010 Frederic Weisbecker <fweisbec@gmail.com> # # perf script event handlers have been generated by perf script -g python # # This software is distributed under the terms of the GNU General # Public License ("GPL") version 2 as published by the Free Software # Foundation. import os import sys from collections import defaultdict from UserList import UserList sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') sys.path.append('scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * from SchedGui import * threads = { 0 : "idle"} def thread_name(pid): return "%s:%d" % (threads[pid], pid) class RunqueueEventUnknown: @staticmethod def color(): return None def __repr__(self): return "unknown" class RunqueueEventSleep: @staticmethod def color(): return (0, 0, 0xff) def __init__(self, sleeper): self.sleeper = sleeper def __repr__(self): return "%s gone to sleep" % thread_name(self.sleeper) class RunqueueEventWakeup: @staticmethod def color(): return (0xff, 0xff, 0) def __init__(self, wakee): self.wakee = wakee def __repr__(self): return "%s woke up" % thread_name(self.wakee) class RunqueueEventFork: @staticmethod def color(): return (0, 0xff, 0) def __init__(self, child): self.child = child def __repr__(self): return "new forked task %s" % thread_name(self.child) class RunqueueMigrateIn: @staticmethod def color(): return (0, 0xf0, 0xff) def __init__(self, new): self.new = new def __repr__(self): return "task migrated in %s" % thread_name(self.new) class RunqueueMigrateOut: @staticmethod def color(): return (0xff, 0, 0xff) def __init__(self, old): self.old = old def __repr__(self): return "task migrated out %s" % thread_name(self.old) class RunqueueSnapshot: def __init__(self, tasks = [0], event = RunqueueEventUnknown()): self.tasks = tuple(tasks) self.event = event def sched_switch(self, prev, prev_state, next): event = RunqueueEventUnknown() if taskState(prev_state) == "R" and next in self.tasks \ and prev in self.tasks: return self if taskState(prev_state) != "R": event = RunqueueEventSleep(prev) next_tasks = list(self.tasks[:]) if prev in self.tasks: if taskState(prev_state) != "R": next_tasks.remove(prev) elif taskState(prev_state) == "R": next_tasks.append(prev) if next not in next_tasks: next_tasks.append(next) return RunqueueSnapshot(next_tasks, event) def migrate_out(self, old): if old not in self.tasks: return self next_tasks = [task for task in self.tasks if task != old] return RunqueueSnapshot(next_tasks, RunqueueMigrateOut(old)) def __migrate_in(self, new, event): if new in self.tasks: self.event = event return self next_tasks = self.tasks[:] + tuple([new]) return RunqueueSnapshot(next_tasks, event) def migrate_in(self, new): return self.__migrate_in(new, RunqueueMigrateIn(new)) def wake_up(self, new): return self.__migrate_in(new, RunqueueEventWakeup(new)) def wake_up_new(self, new): return self.__migrate_in(new, RunqueueEventFork(new)) def load(self): """ Provide the number of tasks on the runqueue. Don't count idle""" return len(self.tasks) - 1 def __repr__(self): ret = self.tasks.__repr__() ret += self.origin_tostring() return ret class TimeSlice: def __init__(self, start, prev): self.start = start self.prev = prev self.end = start # cpus that triggered the event self.event_cpus = [] if prev is not None: self.total_load = prev.total_load self.rqs = prev.rqs.copy() else: self.rqs = defaultdict(RunqueueSnapshot) self.total_load = 0 def __update_total_load(self, old_rq, new_rq): diff = new_rq.load() - old_rq.load() self.total_load += diff def sched_switch(self, ts_list, prev, prev_state, next, cpu): old_rq = self.prev.rqs[cpu] new_rq = old_rq.sched_switch(prev, prev_state, next) if old_rq is new_rq: return self.rqs[cpu] = new_rq self.__update_total_load(old_rq, new_rq) ts_list.append(self) self.event_cpus = [cpu] def migrate(self, ts_list, new, old_cpu, new_cpu): if old_cpu == new_cpu: return old_rq = self.prev.rqs[old_cpu] out_rq = old_rq.migrate_out(new) self.rqs[old_cpu] = out_rq self.__update_total_load(old_rq, out_rq) new_rq = self.prev.rqs[new_cpu] in_rq = new_rq.migrate_in(new) self.rqs[new_cpu] = in_rq self.__update_total_load(new_rq, in_rq) ts_list.append(self) if old_rq is not out_rq: self.event_cpus.append(old_cpu) self.event_cpus.append(new_cpu) def wake_up(self, ts_list, pid, cpu, fork): old_rq = self.prev.rqs[cpu] if fork: new_rq = old_rq.wake_up_new(pid) else: new_rq = old_rq.wake_up(pid) if new_rq is old_rq: return self.rqs[cpu] = new_rq self.__update_total_load(old_rq, new_rq) ts_list.append(self) self.event_cpus = [cpu] def next(self, t): self.end = t return TimeSlice(t, self) class TimeSliceList(UserList): def __init__(self, arg = []): self.data = arg def get_time_slice(self, ts): if len(self.data) == 0: slice = TimeSlice(ts, TimeSlice(-1, None)) else: slice = self.data[-1].next(ts) return slice def find_time_slice(self, ts): start = 0 end = len(self.data) found = -1 searching = True while searching: if start == end or start == end - 1: searching = False i = (end + start) / 2 if self.data[i].start <= ts and self.data[i].end >= ts: found = i end = i continue if self.data[i].end < ts: start = i elif self.data[i].start > ts: end = i return found def set_root_win(self, win): self.root_win = win def mouse_down(self, cpu, t): idx = self.find_time_slice(t) if idx == -1: return ts = self[idx] rq = ts.rqs[cpu] raw = "CPU: %d\n" % cpu raw += "Last event : %s\n" % rq.event.__repr__() raw += "Timestamp : %d.%06d\n" % (ts.start / (10 ** 9), (ts.start % (10 ** 9)) / 1000) raw += "Duration : %6d us\n" % ((ts.end - ts.start) / (10 ** 6)) raw += "Load = %d\n" % rq.load() for t in rq.tasks: raw += "%s \n" % thread_name(t) self.root_win.update_summary(raw) def update_rectangle_cpu(self, slice, cpu): rq = slice.rqs[cpu] if slice.total_load != 0: load_rate = rq.load() / float(slice.total_load) else: load_rate = 0 red_power = int(0xff - (0xff * load_rate)) color = (0xff, red_power, red_power) top_color = None if cpu in slice.event_cpus: top_color = rq.event.color() self.root_win.paint_rectangle_zone(cpu, color, top_color, slice.start, slice.end) def fill_zone(self, start, end): i = self.find_time_slice(start) if i == -1: return for i in xrange(i, len(self.data)): timeslice = self.data[i] if timeslice.start > end: return for cpu in timeslice.rqs: self.update_rectangle_cpu(timeslice, cpu) def interval(self): if len(self.data) == 0: return (0, 0) return (self.data[0].start, self.data[-1].end) def nr_rectangles(self): last_ts = self.data[-1] max_cpu = 0 for cpu in last_ts.rqs: if cpu > max_cpu: max_cpu = cpu return max_cpu class SchedEventProxy: def __init__(self): self.current_tsk = defaultdict(lambda : -1) self.timeslices = TimeSliceList() def sched_switch(self, headers, prev_comm, prev_pid, prev_prio, prev_state, next_comm, next_pid, next_prio): """ Ensure the task we sched out this cpu is really the one we logged. Otherwise we may have missed traces """ on_cpu_task = self.current_tsk[headers.cpu] if on_cpu_task != -1 and on_cpu_task != prev_pid: print "Sched switch event rejected ts: %s cpu: %d prev: %s(%d) next: %s(%d)" % \ (headers.ts_format(), headers.cpu, prev_comm, prev_pid, next_comm, next_pid) threads[prev_pid] = prev_comm threads[next_pid] = next_comm self.current_tsk[headers.cpu] = next_pid ts = self.timeslices.get_time_slice(headers.ts()) ts.sched_switch(self.timeslices, prev_pid, prev_state, next_pid, headers.cpu) def migrate(self, headers, pid, prio, orig_cpu, dest_cpu): ts = self.timeslices.get_time_slice(headers.ts()) ts.migrate(self.timeslices, pid, orig_cpu, dest_cpu) def wake_up(self, headers, comm, pid, success, target_cpu, fork): if success == 0: return ts = self.timeslices.get_time_slice(headers.ts()) ts.wake_up(self.timeslices, pid, target_cpu, fork) def trace_begin(): global parser parser = SchedEventProxy() def trace_end(): app = wx.App(False) timeslices = parser.timeslices frame = RootFrame(timeslices, "Migration") app.MainLoop() def sched__sched_stat_runtime(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, runtime, vruntime): pass def sched__sched_stat_iowait(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, delay): pass def sched__sched_stat_sleep(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, delay): pass def sched__sched_stat_wait(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, delay): pass def sched__sched_process_fork(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, parent_comm, parent_pid, child_comm, child_pid): pass def sched__sched_process_wait(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, prio): pass def sched__sched_process_exit(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, prio): pass def sched__sched_process_free(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, prio): pass def sched__sched_migrate_task(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, prio, orig_cpu, dest_cpu): headers = EventHeaders(common_cpu, common_secs, common_nsecs, common_pid, common_comm) parser.migrate(headers, pid, prio, orig_cpu, dest_cpu) def sched__sched_switch(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, prev_comm, prev_pid, prev_prio, prev_state, next_comm, next_pid, next_prio): headers = EventHeaders(common_cpu, common_secs, common_nsecs, common_pid, common_comm) parser.sched_switch(headers, prev_comm, prev_pid, prev_prio, prev_state, next_comm, next_pid, next_prio) def sched__sched_wakeup_new(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, prio, success, target_cpu): headers = EventHeaders(common_cpu, common_secs, common_nsecs, common_pid, common_comm) parser.wake_up(headers, comm, pid, success, target_cpu, 1) def sched__sched_wakeup(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, prio, success, target_cpu): headers = EventHeaders(common_cpu, common_secs, common_nsecs, common_pid, common_comm) parser.wake_up(headers, comm, pid, success, target_cpu, 0) def sched__sched_wait_task(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, prio): pass def sched__sched_kthread_stop_ret(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, ret): pass def sched__sched_kthread_stop(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid): pass def trace_unhandled(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm): pass
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 445, 3165, 2120, 8367, 23503, 31239, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 481, 21919, 1567, 2136, 374, 1235, 22043, 665, 70, 1129, 374, 24554, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 8582, 2884, 1566, 8297, 1172, 2757, 4046, 701, 8582, 2884, 446, 71, 2366, 199, 3, 199, 3, 961, 2032, 365, 1854, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 1689, 12006, 531, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 14, 421, 199, 646, 747, 199, 646, 984, 199, 199, 504, 5055, 492, 10018, 199, 504, 28639, 492, 28639, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 1274, 14, 515, 14, 740, 360, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 428, 1809, 4324, 492, 627, 421, 199, 6962, 275, 469, 378, 520, 298, 12000, 3570, 199, 199, 318, 2462, 63, 354, 8, 3150, 304, 199, 198, 1107, 2071, 83, 2689, 68, 2, 450, 334, 6962, 59, 3150, 467, 4422, 9, 199, 199, 533, 25406, 5912, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 488, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 298, 5187, 2, 199, 199, 533, 25406, 17306, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 12, 378, 12, 378, 3581, 9, 421, 198, 318, 636, 826, 721, 277, 12, 26220, 15033, 304, 507, 198, 277, 14, 23042, 15033, 275, 26220, 15033, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 2071, 83, 21737, 370, 9435, 2, 450, 2462, 63, 354, 8, 277, 14, 23042, 15033, 9, 199, 199, 533, 25406, 23424, 384, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 3581, 12, 378, 3581, 12, 378, 9, 421, 198, 318, 636, 826, 721, 277, 12, 21560, 69, 304, 507, 198, 277, 14, 15181, 69, 275, 21560, 69, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 2071, 83, 336, 79, 415, 1536, 2, 450, 2462, 63, 354, 8, 277, 14, 15181, 69, 9, 199, 199, 533, 25406, 1858, 75, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 12, 378, 3581, 12, 378, 9, 421, 198, 318, 636, 826, 721, 277, 12, 1982, 304, 507, 198, 277, 14, 1739, 275, 1982, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 298, 1222, 14926, 379, 2120, 450, 83, 2, 450, 2462, 63, 354, 8, 277, 14, 1739, 9, 199, 199, 533, 17664, 26641, 607, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 12, 378, 1949, 16, 12, 378, 3581, 9, 421, 198, 318, 636, 826, 721, 277, 12, 892, 304, 507, 198, 277, 14, 1222, 275, 892, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 298, 1765, 28322, 315, 450, 83, 2, 450, 2462, 63, 354, 8, 277, 14, 1222, 9, 199, 199, 533, 17664, 26641, 2204, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 3581, 12, 378, 12, 378, 3581, 9, 421, 198, 318, 636, 826, 721, 277, 12, 2269, 304, 507, 198, 277, 14, 1753, 275, 2269, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 298, 1765, 28322, 734, 450, 83, 2, 450, 2462, 63, 354, 8, 277, 14, 1753, 9, 199, 199, 533, 17664, 12038, 26, 199, 198, 318, 636, 826, 721, 277, 12, 6527, 275, 359, 16, 467, 1566, 275, 25406, 5912, 5109, 507, 198, 277, 14, 5054, 275, 2008, 8, 5054, 9, 507, 198, 277, 14, 1430, 275, 1566, 421, 198, 318, 10286, 63, 5656, 8, 277, 12, 5071, 12, 5071, 63, 929, 12, 2163, 304, 507, 198, 1430, 275, 25406, 5912, 342, 2742, 198, 692, 2120, 2223, 8, 5701, 63, 929, 9, 508, 298, 50, 2, 436, 2163, 315, 291, 14, 5054, 971, 686, 198, 460, 5071, 315, 291, 14, 5054, 26, 686, 198, 1107, 291, 2742, 198, 692, 2120, 2223, 8, 5701, 63, 929, 9, 1137, 298, 50, 582, 686, 198, 1430, 275, 25406, 17306, 8, 5701, 9, 2742, 198, 2184, 63, 5054, 275, 769, 8, 277, 14, 5054, 1491, 566, 507, 198, 692, 5071, 315, 291, 14, 5054, 26, 686, 198, 692, 2120, 2223, 8, 5701, 63, 929, 9, 1137, 298, 50, 582, 1585, 198, 2184, 63, 5054, 14, 2168, 8, 5701, 9, 507, 198, 4164, 2120, 2223, 8, 5701, 63, 929, 9, 508, 298, 50, 582, 686, 198, 2184, 63, 5054, 14, 740, 8, 5701, 9, 2742, 198, 692, 2163, 440, 315, 2163, 63, 5054, 26, 686, 198, 2184, 63, 5054, 14, 740, 8, 2184, 9, 2742, 198, 1107, 17664, 12038, 8, 2184, 63, 5054, 12, 1566, 9, 421, 198, 318, 12810, 63, 548, 8, 277, 12, 2269, 304, 507, 198, 692, 2269, 440, 315, 291, 14, 5054, 26, 686, 198, 1107, 291, 507, 198, 2184, 63, 5054, 275, 359, 1765, 367, 2120, 315, 291, 14, 5054, 340, 2120, 1137, 2269, 61, 2742, 198, 1107, 17664, 12038, 8, 2184, 63, 5054, 12, 17664, 26641, 2204, 8, 1753, 430, 421, 198, 318, 636, 8462, 63, 262, 8, 277, 12, 892, 12, 1566, 304, 507, 198, 692, 892, 315, 291, 14, 5054, 26, 686, 198, 277, 14, 1430, 275, 1566, 686, 198, 1107, 291, 507, 198, 2184, 63, 5054, 275, 291, 14, 5054, 5873, 435, 2008, 779, 1222, 566, 2742, 198, 1107, 17664, 12038, 8, 2184, 63, 5054, 12, 1566, 9, 421, 198, 318, 12810, 63, 262, 8, 277, 12, 892, 304, 507, 198, 1107, 291, 855, 8462, 63, 262, 8, 1222, 12, 17664, 26641, 607, 8, 1222, 430, 421, 198, 318, 21560, 63, 384, 8, 277, 12, 892, 304, 507, 198, 1107, 291, 855, 8462, 63, 262, 8, 1222, 12 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 445, 3165, 2120, 8367, 23503, 31239, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 481, 21919, 1567, 2136, 374, 1235, 22043, 665, 70, 1129, 374, 24554, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 8582, 2884, 1566, 8297, 1172, 2757, 4046, 701, 8582, 2884, 446, 71, 2366, 199, 3, 199, 3, 961, 2032, 365, 1854, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 1689, 12006, 531, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 14, 421, 199, 646, 747, 199, 646, 984, 199, 199, 504, 5055, 492, 10018, 199, 504, 28639, 492, 28639, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 1274, 14, 515, 14, 740, 360, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 428, 1809, 4324, 492, 627, 421, 199, 6962, 275, 469, 378, 520, 298, 12000, 3570, 199, 199, 318, 2462, 63, 354, 8, 3150, 304, 199, 198, 1107, 2071, 83, 2689, 68, 2, 450, 334, 6962, 59, 3150, 467, 4422, 9, 199, 199, 533, 25406, 5912, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 488, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 298, 5187, 2, 199, 199, 533, 25406, 17306, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 12, 378, 12, 378, 3581, 9, 421, 198, 318, 636, 826, 721, 277, 12, 26220, 15033, 304, 507, 198, 277, 14, 23042, 15033, 275, 26220, 15033, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 2071, 83, 21737, 370, 9435, 2, 450, 2462, 63, 354, 8, 277, 14, 23042, 15033, 9, 199, 199, 533, 25406, 23424, 384, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 3581, 12, 378, 3581, 12, 378, 9, 421, 198, 318, 636, 826, 721, 277, 12, 21560, 69, 304, 507, 198, 277, 14, 15181, 69, 275, 21560, 69, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 2071, 83, 336, 79, 415, 1536, 2, 450, 2462, 63, 354, 8, 277, 14, 15181, 69, 9, 199, 199, 533, 25406, 1858, 75, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 12, 378, 3581, 12, 378, 9, 421, 198, 318, 636, 826, 721, 277, 12, 1982, 304, 507, 198, 277, 14, 1739, 275, 1982, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 298, 1222, 14926, 379, 2120, 450, 83, 2, 450, 2462, 63, 354, 8, 277, 14, 1739, 9, 199, 199, 533, 17664, 26641, 607, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 12, 378, 1949, 16, 12, 378, 3581, 9, 421, 198, 318, 636, 826, 721, 277, 12, 892, 304, 507, 198, 277, 14, 1222, 275, 892, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 298, 1765, 28322, 315, 450, 83, 2, 450, 2462, 63, 354, 8, 277, 14, 1222, 9, 199, 199, 533, 17664, 26641, 2204, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 3581, 12, 378, 12, 378, 3581, 9, 421, 198, 318, 636, 826, 721, 277, 12, 2269, 304, 507, 198, 277, 14, 1753, 275, 2269, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 298, 1765, 28322, 734, 450, 83, 2, 450, 2462, 63, 354, 8, 277, 14, 1753, 9, 199, 199, 533, 17664, 12038, 26, 199, 198, 318, 636, 826, 721, 277, 12, 6527, 275, 359, 16, 467, 1566, 275, 25406, 5912, 5109, 507, 198, 277, 14, 5054, 275, 2008, 8, 5054, 9, 507, 198, 277, 14, 1430, 275, 1566, 421, 198, 318, 10286, 63, 5656, 8, 277, 12, 5071, 12, 5071, 63, 929, 12, 2163, 304, 507, 198, 1430, 275, 25406, 5912, 342, 2742, 198, 692, 2120, 2223, 8, 5701, 63, 929, 9, 508, 298, 50, 2, 436, 2163, 315, 291, 14, 5054, 971, 686, 198, 460, 5071, 315, 291, 14, 5054, 26, 686, 198, 1107, 291, 2742, 198, 692, 2120, 2223, 8, 5701, 63, 929, 9, 1137, 298, 50, 582, 686, 198, 1430, 275, 25406, 17306, 8, 5701, 9, 2742, 198, 2184, 63, 5054, 275, 769, 8, 277, 14, 5054, 1491, 566, 507, 198, 692, 5071, 315, 291, 14, 5054, 26, 686, 198, 692, 2120, 2223, 8, 5701, 63, 929, 9, 1137, 298, 50, 582, 1585, 198, 2184, 63, 5054, 14, 2168, 8, 5701, 9, 507, 198, 4164, 2120, 2223, 8, 5701, 63, 929, 9, 508, 298, 50, 582, 686, 198, 2184, 63, 5054, 14, 740, 8, 5701, 9, 2742, 198, 692, 2163, 440, 315, 2163, 63, 5054, 26, 686, 198, 2184, 63, 5054, 14, 740, 8, 2184, 9, 2742, 198, 1107, 17664, 12038, 8, 2184, 63, 5054, 12, 1566, 9, 421, 198, 318, 12810, 63, 548, 8, 277, 12, 2269, 304, 507, 198, 692, 2269, 440, 315, 291, 14, 5054, 26, 686, 198, 1107, 291, 507, 198, 2184, 63, 5054, 275, 359, 1765, 367, 2120, 315, 291, 14, 5054, 340, 2120, 1137, 2269, 61, 2742, 198, 1107, 17664, 12038, 8, 2184, 63, 5054, 12, 17664, 26641, 2204, 8, 1753, 430, 421, 198, 318, 636, 8462, 63, 262, 8, 277, 12, 892, 12, 1566, 304, 507, 198, 692, 892, 315, 291, 14, 5054, 26, 686, 198, 277, 14, 1430, 275, 1566, 686, 198, 1107, 291, 507, 198, 2184, 63, 5054, 275, 291, 14, 5054, 5873, 435, 2008, 779, 1222, 566, 2742, 198, 1107, 17664, 12038, 8, 2184, 63, 5054, 12, 1566, 9, 421, 198, 318, 12810, 63, 262, 8, 277, 12, 892, 304, 507, 198, 1107, 291, 855, 8462, 63, 262, 8, 1222, 12, 17664, 26641, 607, 8, 1222, 430, 421, 198, 318, 21560, 63, 384, 8, 277, 12, 892, 304, 507, 198, 1107, 291, 855, 8462, 63, 262, 8, 1222, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
ArianaGashi/Techstitution
venv/lib/python2.7/site-packages/flask_cors/decorator.py
8
4916
# -*- coding: utf-8 -*- """ flask_cors ~~~~ Flask-CORS is a simple extension to Flask allowing you to support cross origin resource sharing (CORS) using a simple decorator. :copyright: (c) 2014 by Cory Dolphin. :license: MIT, see LICENSE for more details. """ from functools import update_wrapper from flask import make_response, request, current_app from .core import * LOG = logging.getLogger(__name__) def cross_origin(*args, **kwargs): """ This function is the decorator which is used to wrap a Flask route with. In the simplest case, simply use the default parameters to allow all origins in what is the most permissive configuration. If this method modifies state or performs authentication which may be brute-forced, you should add some degree of protection, such as Cross Site Forgery Request protection. :param origins: The origin, or list of origins to allow requests from. The origin(s) may be regular expressions, case-sensitive strings, or else an asterisk Default : '*' :type origins: list, string or regex :param methods: The method or list of methods which the allowed origins are allowed to access for non-simple requests. Default : [GET, HEAD, POST, OPTIONS, PUT, PATCH, DELETE] :type methods: list or string :param expose_headers: The header or list which are safe to expose to the API of a CORS API specification. Default : None :type expose_headers: list or string :param allow_headers: The header or list of header field names which can be used when this resource is accessed by allowed origins. The header(s) may be regular expressions, case-sensitive strings, or else an asterisk. Default : '*', allow all headers :type allow_headers: list, string or regex :param supports_credentials: Allows users to make authenticated requests. If true, injects the `Access-Control-Allow-Credentials` header in responses. This allows cookies and credentials to be submitted across domains. :note: This option cannot be used in conjuction with a '*' origin Default : False :type supports_credentials: bool :param max_age: The maximum time for which this CORS request maybe cached. This value is set as the `Access-Control-Max-Age` header. Default : None :type max_age: timedelta, integer, string or None :param send_wildcard: If True, and the origins parameter is `*`, a wildcard `Access-Control-Allow-Origin` header is sent, rather than the request's `Origin` header. Default : False :type send_wildcard: bool :param vary_header: If True, the header Vary: Origin will be returned as per the W3 implementation guidelines. Setting this header when the `Access-Control-Allow-Origin` is dynamically generated (e.g. when there is more than one allowed origin, and an Origin than '*' is returned) informs CDNs and other caches that the CORS headers are dynamic, and cannot be cached. If False, the Vary header will never be injected or altered. Default : True :type vary_header: bool :param automatic_options: Only applies to the `cross_origin` decorator. If True, Flask-CORS will override Flask's default OPTIONS handling to return CORS headers for OPTIONS requests. Default : True :type automatic_options: bool """ _options = kwargs def decorator(f): LOG.debug("Enabling %s for cross_origin using options:%s", f, _options) # If True, intercept OPTIONS requests by modifying the view function, # replicating Flask's default behavior, and wrapping the response with # CORS headers. # # If f.provide_automatic_options is unset or True, Flask's route # decorator (which is actually wraps the function object we return) # intercepts OPTIONS handling, and requests will not have CORS headers if _options.get('automatic_options', True): f.required_methods = getattr(f, 'required_methods', set()) f.required_methods.add('OPTIONS') f.provide_automatic_options = False def wrapped_function(*args, **kwargs): # Handle setting of Flask-Cors parameters options = get_cors_options(current_app, _options) if options.get('automatic_options') and request.method == 'OPTIONS': resp = current_app.make_default_options_response() else: resp = make_response(f(*args, **kwargs)) set_cors_headers(resp, options) setattr(resp, FLASK_CORS_EVALUATED, True) return resp return update_wrapper(wrapped_function, f) return decorator
cc0-1.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 7209, 63, 30967, 272, 221, 2878, 272, 16704, 13, 35, 4149, 365, 282, 3486, 3329, 370, 16704, 17266, 1265, 370, 2291, 8059, 272, 6330, 2073, 26994, 334, 35, 4149, 9, 1808, 282, 3486, 7531, 14, 339, 520, 7307, 26, 334, 67, 9, 6927, 701, 445, 1089, 577, 393, 838, 262, 14, 272, 520, 1682, 26, 10697, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 504, 9143, 492, 1678, 63, 5029, 199, 504, 7209, 492, 1852, 63, 1310, 12, 1056, 12, 1453, 63, 571, 199, 504, 1275, 1018, 492, 627, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 318, 8059, 63, 6493, 2031, 589, 12, 1011, 958, 304, 272, 408, 272, 961, 805, 365, 314, 7531, 1314, 365, 1202, 370, 4816, 282, 16704, 7475, 543, 14, 272, 1010, 314, 3486, 270, 1930, 12, 9329, 675, 314, 849, 2633, 370, 2040, 1006, 272, 2306, 3617, 315, 4052, 365, 314, 4750, 1126, 32237, 2897, 14, 982, 642, 1083, 272, 26473, 1174, 503, 18628, 6299, 1314, 1443, 506, 11665, 938, 13, 28074, 12, 1265, 272, 1077, 1050, 2005, 13666, 402, 23977, 12, 4066, 465, 28965, 11666, 2104, 836, 89, 272, 4784, 23977, 14, 339, 520, 635, 2306, 3617, 26, 267, 710, 6330, 12, 503, 769, 402, 2306, 3617, 370, 2040, 4145, 687, 14, 267, 710, 6330, 8, 83, 9, 1443, 506, 5578, 8455, 12, 1930, 13, 7361, 3326, 12, 267, 503, 587, 376, 465, 6236, 1339, 398, 3758, 520, 13626, 272, 520, 466, 2306, 3617, 26, 769, 12, 1059, 503, 5163, 339, 520, 635, 3102, 26, 267, 710, 1083, 503, 769, 402, 3102, 1314, 314, 4370, 2306, 3617, 787, 4370, 370, 267, 2879, 367, 2222, 13, 4129, 4145, 14, 398, 3758, 520, 359, 2970, 12, 13053, 12, 8761, 12, 23860, 12, 18337, 12, 510, 8078, 12, 15137, 61, 272, 520, 466, 3102, 26, 769, 503, 1059, 339, 520, 635, 23705, 63, 2139, 26, 267, 710, 1406, 503, 769, 1314, 787, 5048, 370, 23705, 370, 314, 3261, 402, 282, 445, 4149, 3261, 267, 8929, 14, 398, 3758, 520, 488, 272, 520, 466, 23705, 63, 2139, 26, 769, 503, 1059, 339, 520, 635, 2040, 63, 2139, 26, 267, 710, 1406, 503, 769, 402, 1406, 901, 1561, 1314, 883, 506, 1202, 1380, 642, 267, 2073, 365, 13810, 701, 4370, 2306, 3617, 14, 710, 1406, 8, 83, 9, 1443, 506, 5578, 267, 8455, 12, 1930, 13, 7361, 3326, 12, 503, 587, 376, 465, 6236, 1339, 14, 398, 3758, 520, 24999, 2040, 1006, 2323, 272, 520, 466, 2040, 63, 2139, 26, 769, 12, 1059, 503, 5163, 339, 520, 635, 5171, 63, 6942, 26, 267, 22819, 4390, 370, 1852, 15082, 4145, 14, 982, 2549, 12, 16182, 83, 314, 267, 658, 3946, 13, 3717, 13, 7852, 13, 13428, 64, 1406, 315, 9320, 14, 961, 6127, 267, 10049, 436, 6235, 370, 506, 16930, 9371, 14006, 14, 398, 520, 4610, 26, 961, 945, 3913, 506, 1202, 315, 14643, 85, 414, 543, 282, 13626, 6330, 398, 3758, 520, 756, 272, 520, 466, 5171, 63, 6942, 26, 2155, 339, 520, 635, 1390, 63, 474, 26, 267, 710, 5696, 900, 367, 1314, 642, 445, 4149, 1056, 11703, 6328, 14, 961, 574, 267, 365, 663, 465, 314, 658, 3946, 13, 3717, 13, 4261, 13, 20480, 64, 1406, 14, 398, 3758, 520, 488, 272, 520, 466, 1390, 63, 474, 26, 6871, 12, 3000, 12, 1059, 503, 488, 339, 520, 635, 3222, 63, 16692, 26, 982, 715, 12, 436, 314, 2306, 3617, 2725, 365, 658, 10, 3559, 282, 16792, 267, 658, 3946, 13, 3717, 13, 7852, 13, 12834, 64, 1406, 365, 4847, 12, 7830, 2419, 314, 267, 1056, 1159, 658, 12834, 64, 1406, 14, 398, 3758, 520, 756, 272, 520, 466, 3222, 63, 16692, 26, 2155, 339, 520, 635, 17083, 63, 1291, 26, 267, 982, 715, 12, 314, 1406, 812, 695, 26, 31534, 911, 506, 2138, 465, 1126, 314, 644, 19, 267, 4514, 22885, 1278, 14, 398, 13510, 642, 1406, 1380, 314, 658, 3946, 13, 3717, 13, 7852, 13, 12834, 64, 365, 267, 18774, 4046, 334, 69, 14, 71, 14, 1380, 2337, 365, 1655, 2419, 1373, 4370, 267, 6330, 12, 436, 376, 31534, 2419, 13626, 365, 2138, 9, 315, 3351, 445, 36, 2438, 436, 1163, 267, 18014, 626, 314, 445, 4149, 2323, 787, 8336, 12, 436, 3913, 506, 6328, 14, 398, 982, 756, 12, 314, 812, 695, 1406, 911, 7078, 506, 26121, 503, 29815, 14, 398, 3758, 520, 715, 272, 520, 466, 17083, 63, 1291, 26, 2155, 339, 520, 635, 4834, 63, 1419, 26, 267, 5972, 12966, 370, 314, 658, 7925, 63, 6493, 64, 7531, 14, 982, 715, 12, 16704, 13, 35, 4149, 911, 267, 4278, 16704, 1159, 849, 23860, 7252, 370, 372, 445, 4149, 2323, 367, 267, 23860, 4145, 14, 398, 3758, 520, 715, 272, 520, 466, 4834, 63, 1419, 26, 2155, 339, 408, 272, 485, 1419, 275, 2074, 339, 347, 7531, 8, 70, 304, 267, 5051, 14, 1757, 480, 1327, 14744, 450, 83, 367, 8059, 63, 6493, 1808, 1511, 2689, 83, 401, 289, 12, 485, 1419, 9, 398, 327, 982, 715, 12, 13926, 23860, 4145, 701, 24662, 314, 2455, 805, 12, 267, 327, 1833, 606, 1958, 16704, 1159, 849, 5953, 12, 436, 19696, 314, 1177, 543, 267, 327, 445, 4149, 2323, 14, 267, 327, 267, 327, 982, 289, 14, 20824, 63, 23292, 63, 1419, 365, 15376, 503, 715, 12, 16704, 1159, 7475, 267, 327, 7531, 334, 6777, 365, 5965, 14018, 314, 805, 909, 781, 372, 9, 267, 327, 13926, 83, 23860, 7252, 12, 436, 4145, 911, 440, 1172, 445, 4149, 2323, 267, 340, 485, 1419, 14, 362, 360, 23292, 63, 1419, 297, 715, 304, 288, 289, 14, 2427, 63, 2474, 275, 2519, 8, 70, 12, 283, 2427, 63, 2474, 297, 663, 1012, 288, 289, 14, 2427, 63, 2474, 14, 525, 360, 8808, 358, 288, 289, 14, 20824, 63, 23292, 63, 1419, 275, 756, 398, 347, 8072, 63, 1593, 2031, 589, 12, 1011, 958, 304, 288, 327, 8690, 4260, 402, 16704, 13, 35, 1384, 2633, 288, 1511, 275, 664, 63, 30967, 63, 1419, 8, 1818, 63, 571, 12, 485, 1419, 9, 953, 340, 1511, 14, 362, 360, 23292, 63, 1419, 358, 436, 1056, 14, 765 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 7209, 63, 30967, 272, 221, 2878, 272, 16704, 13, 35, 4149, 365, 282, 3486, 3329, 370, 16704, 17266, 1265, 370, 2291, 8059, 272, 6330, 2073, 26994, 334, 35, 4149, 9, 1808, 282, 3486, 7531, 14, 339, 520, 7307, 26, 334, 67, 9, 6927, 701, 445, 1089, 577, 393, 838, 262, 14, 272, 520, 1682, 26, 10697, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 504, 9143, 492, 1678, 63, 5029, 199, 504, 7209, 492, 1852, 63, 1310, 12, 1056, 12, 1453, 63, 571, 199, 504, 1275, 1018, 492, 627, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 318, 8059, 63, 6493, 2031, 589, 12, 1011, 958, 304, 272, 408, 272, 961, 805, 365, 314, 7531, 1314, 365, 1202, 370, 4816, 282, 16704, 7475, 543, 14, 272, 1010, 314, 3486, 270, 1930, 12, 9329, 675, 314, 849, 2633, 370, 2040, 1006, 272, 2306, 3617, 315, 4052, 365, 314, 4750, 1126, 32237, 2897, 14, 982, 642, 1083, 272, 26473, 1174, 503, 18628, 6299, 1314, 1443, 506, 11665, 938, 13, 28074, 12, 1265, 272, 1077, 1050, 2005, 13666, 402, 23977, 12, 4066, 465, 28965, 11666, 2104, 836, 89, 272, 4784, 23977, 14, 339, 520, 635, 2306, 3617, 26, 267, 710, 6330, 12, 503, 769, 402, 2306, 3617, 370, 2040, 4145, 687, 14, 267, 710, 6330, 8, 83, 9, 1443, 506, 5578, 8455, 12, 1930, 13, 7361, 3326, 12, 267, 503, 587, 376, 465, 6236, 1339, 398, 3758, 520, 13626, 272, 520, 466, 2306, 3617, 26, 769, 12, 1059, 503, 5163, 339, 520, 635, 3102, 26, 267, 710, 1083, 503, 769, 402, 3102, 1314, 314, 4370, 2306, 3617, 787, 4370, 370, 267, 2879, 367, 2222, 13, 4129, 4145, 14, 398, 3758, 520, 359, 2970, 12, 13053, 12, 8761, 12, 23860, 12, 18337, 12, 510, 8078, 12, 15137, 61, 272, 520, 466, 3102, 26, 769, 503, 1059, 339, 520, 635, 23705, 63, 2139, 26, 267, 710, 1406, 503, 769, 1314, 787, 5048, 370, 23705, 370, 314, 3261, 402, 282, 445, 4149, 3261, 267, 8929, 14, 398, 3758, 520, 488, 272, 520, 466, 23705, 63, 2139, 26, 769, 503, 1059, 339, 520, 635, 2040, 63, 2139, 26, 267, 710, 1406, 503, 769, 402, 1406, 901, 1561, 1314, 883, 506, 1202, 1380, 642, 267, 2073, 365, 13810, 701, 4370, 2306, 3617, 14, 710, 1406, 8, 83, 9, 1443, 506, 5578, 267, 8455, 12, 1930, 13, 7361, 3326, 12, 503, 587, 376, 465, 6236, 1339, 14, 398, 3758, 520, 24999, 2040, 1006, 2323, 272, 520, 466, 2040, 63, 2139, 26, 769, 12, 1059, 503, 5163, 339, 520, 635, 5171, 63, 6942, 26, 267, 22819, 4390, 370, 1852, 15082, 4145, 14, 982, 2549, 12, 16182, 83, 314, 267, 658, 3946, 13, 3717, 13, 7852, 13, 13428, 64, 1406, 315, 9320, 14, 961, 6127, 267, 10049, 436, 6235, 370, 506, 16930, 9371, 14006, 14, 398, 520, 4610, 26, 961, 945, 3913, 506, 1202, 315, 14643, 85, 414, 543, 282, 13626, 6330, 398, 3758, 520, 756, 272, 520, 466, 5171, 63, 6942, 26, 2155, 339, 520, 635, 1390, 63, 474, 26, 267, 710, 5696, 900, 367, 1314, 642, 445, 4149, 1056, 11703, 6328, 14, 961, 574, 267, 365, 663, 465, 314, 658, 3946, 13, 3717, 13, 4261, 13, 20480, 64, 1406, 14, 398, 3758, 520, 488, 272, 520, 466, 1390, 63, 474, 26, 6871, 12, 3000, 12, 1059, 503, 488, 339, 520, 635, 3222, 63, 16692, 26, 982, 715, 12, 436, 314, 2306, 3617, 2725, 365, 658, 10, 3559, 282, 16792, 267, 658, 3946, 13, 3717, 13, 7852, 13, 12834, 64, 1406, 365, 4847, 12, 7830, 2419, 314, 267, 1056, 1159, 658, 12834, 64, 1406, 14, 398, 3758, 520, 756, 272, 520, 466, 3222, 63, 16692, 26, 2155, 339, 520, 635, 17083, 63, 1291, 26, 267, 982, 715, 12, 314, 1406, 812, 695, 26, 31534, 911, 506, 2138, 465, 1126, 314, 644, 19, 267, 4514, 22885, 1278, 14, 398, 13510, 642, 1406, 1380, 314, 658, 3946, 13, 3717, 13, 7852, 13, 12834, 64, 365, 267, 18774, 4046, 334, 69, 14, 71, 14, 1380, 2337, 365, 1655, 2419, 1373, 4370, 267, 6330, 12, 436, 376, 31534, 2419, 13626, 365, 2138, 9, 315, 3351, 445, 36, 2438, 436, 1163, 267, 18014, 626, 314, 445, 4149, 2323, 787, 8336, 12, 436, 3913, 506, 6328, 14, 398, 982, 756, 12, 314, 812, 695, 1406, 911, 7078, 506, 26121, 503, 29815, 14, 398, 3758, 520, 715, 272, 520, 466, 17083, 63, 1291, 26, 2155, 339, 520, 635, 4834, 63, 1419, 26, 267, 5972, 12966, 370, 314, 658, 7925, 63, 6493, 64, 7531, 14, 982, 715, 12, 16704, 13, 35, 4149, 911, 267, 4278, 16704, 1159, 849, 23860, 7252, 370, 372, 445, 4149, 2323, 367, 267, 23860, 4145, 14, 398, 3758, 520, 715, 272, 520, 466, 4834, 63, 1419, 26, 2155, 339, 408, 272, 485, 1419, 275, 2074, 339, 347, 7531, 8, 70, 304, 267, 5051, 14, 1757, 480, 1327, 14744, 450, 83, 367, 8059, 63, 6493, 1808, 1511, 2689, 83, 401, 289, 12, 485, 1419, 9, 398, 327, 982, 715, 12, 13926, 23860, 4145, 701, 24662, 314, 2455, 805, 12, 267, 327, 1833, 606, 1958, 16704, 1159, 849, 5953, 12, 436, 19696, 314, 1177, 543, 267, 327, 445, 4149, 2323, 14, 267, 327, 267, 327, 982, 289, 14, 20824, 63, 23292, 63, 1419, 365, 15376, 503, 715, 12, 16704, 1159, 7475, 267, 327, 7531, 334, 6777, 365, 5965, 14018, 314, 805, 909, 781, 372, 9, 267, 327, 13926, 83, 23860, 7252, 12, 436, 4145, 911, 440, 1172, 445, 4149, 2323, 267, 340, 485, 1419, 14, 362, 360, 23292, 63, 1419, 297, 715, 304, 288, 289, 14, 2427, 63, 2474, 275, 2519, 8, 70, 12, 283, 2427, 63, 2474, 297, 663, 1012, 288, 289, 14, 2427, 63, 2474, 14, 525, 360, 8808, 358, 288, 289, 14, 20824, 63, 23292, 63, 1419, 275, 756, 398, 347, 8072, 63, 1593, 2031, 589, 12, 1011, 958, 304, 288, 327, 8690, 4260, 402, 16704, 13, 35, 1384, 2633, 288, 1511, 275, 664, 63, 30967, 63, 1419, 8, 1818, 63, 571, 12, 485, 1419, 9, 953, 340, 1511, 14, 362, 360, 23292, 63, 1419, 358, 436, 1056, 14, 765, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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ware/cache.py
52
8883
""" Cache middleware. If enabled, each Django-powered page will be cached based on URL. The canonical way to enable cache middleware is to set ``UpdateCacheMiddleware`` as your first piece of middleware, and ``FetchFromCacheMiddleware`` as the last:: MIDDLEWARE_CLASSES = [ 'django.middleware.cache.UpdateCacheMiddleware', ... 'django.middleware.cache.FetchFromCacheMiddleware' ] This is counter-intuitive, but correct: ``UpdateCacheMiddleware`` needs to run last during the response phase, which processes middleware bottom-up; ``FetchFromCacheMiddleware`` needs to run last during the request phase, which processes middleware top-down. The single-class ``CacheMiddleware`` can be used for some simple sites. However, if any other piece of middleware needs to affect the cache key, you'll need to use the two-part ``UpdateCacheMiddleware`` and ``FetchFromCacheMiddleware``. This'll most often happen when you're using Django's ``LocaleMiddleware``. More details about how the caching works: * Only GET or HEAD-requests with status code 200 are cached. * The number of seconds each page is stored for is set by the "max-age" section of the response's "Cache-Control" header, falling back to the CACHE_MIDDLEWARE_SECONDS setting if the section was not found. * This middleware expects that a HEAD request is answered with the same response headers exactly like the corresponding GET request. * When a hit occurs, a shallow copy of the original response object is returned from process_request. * Pages will be cached based on the contents of the request headers listed in the response's "Vary" header. * This middleware also sets ETag, Last-Modified, Expires and Cache-Control headers on the response object. """ import warnings from django.conf import settings from django.core.cache import caches, DEFAULT_CACHE_ALIAS from django.utils.cache import (get_cache_key, get_max_age, has_vary_header, learn_cache_key, patch_response_headers) from django.utils.deprecation import RemovedInDjango18Warning class UpdateCacheMiddleware(object): """ Response-phase cache middleware that updates the cache if the response is cacheable. Must be used as part of the two-part update/fetch cache middleware. UpdateCacheMiddleware must be the first piece of middleware in MIDDLEWARE_CLASSES so that it'll get called last during the response phase. """ def __init__(self): self.cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS self.key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX self.cache_anonymous_only = getattr(settings, 'CACHE_MIDDLEWARE_ANONYMOUS_ONLY', False) self.cache_alias = settings.CACHE_MIDDLEWARE_ALIAS self.cache = caches[self.cache_alias] def _session_accessed(self, request): try: return request.session.accessed except AttributeError: return False def _should_update_cache(self, request, response): if not hasattr(request, '_cache_update_cache') or not request._cache_update_cache: return False # If the session has not been accessed otherwise, we don't want to # cause it to be accessed here. If it hasn't been accessed, then the # user's logged-in status has not affected the response anyway. if self.cache_anonymous_only and self._session_accessed(request): assert hasattr(request, 'user'), "The Django cache middleware with CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True requires authentication middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.auth.middleware.AuthenticationMiddleware' before the CacheMiddleware." if request.user.is_authenticated(): # Don't cache user-variable requests from authenticated users. return False return True def process_response(self, request, response): """Sets the cache, if needed.""" if not self._should_update_cache(request, response): # We don't need to update the cache, just return. return response if response.streaming or response.status_code != 200: return response # Don't cache responses that set a user-specific (and maybe security # sensitive) cookie in response to a cookie-less request. if not request.COOKIES and response.cookies and has_vary_header(response, 'Cookie'): return response # Try to get the timeout from the "max-age" section of the "Cache- # Control" header before reverting to using the default cache_timeout # length. timeout = get_max_age(response) if timeout is None: timeout = self.cache_timeout elif timeout == 0: # max-age was set to 0, don't bother caching. return response patch_response_headers(response, timeout) if timeout: cache_key = learn_cache_key(request, response, timeout, self.key_prefix, cache=self.cache) if hasattr(response, 'render') and callable(response.render): response.add_post_render_callback( lambda r: self.cache.set(cache_key, r, timeout) ) else: self.cache.set(cache_key, response, timeout) return response class FetchFromCacheMiddleware(object): """ Request-phase cache middleware that fetches a page from the cache. Must be used as part of the two-part update/fetch cache middleware. FetchFromCacheMiddleware must be the last piece of middleware in MIDDLEWARE_CLASSES so that it'll get called last during the request phase. """ def __init__(self): self.key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX self.cache_alias = settings.CACHE_MIDDLEWARE_ALIAS self.cache = caches[self.cache_alias] def process_request(self, request): """ Checks whether the page is already cached and returns the cached version if available. """ if request.method not in ('GET', 'HEAD'): request._cache_update_cache = False return None # Don't bother checking the cache. # try and get the cached GET response cache_key = get_cache_key(request, self.key_prefix, 'GET', cache=self.cache) if cache_key is None: request._cache_update_cache = True return None # No cache information available, need to rebuild. response = self.cache.get(cache_key, None) # if it wasn't found and we are looking for a HEAD, try looking just for that if response is None and request.method == 'HEAD': cache_key = get_cache_key(request, self.key_prefix, 'HEAD', cache=self.cache) response = self.cache.get(cache_key, None) if response is None: request._cache_update_cache = True return None # No cache information available, need to rebuild. # hit, return cached response request._cache_update_cache = False return response class CacheMiddleware(UpdateCacheMiddleware, FetchFromCacheMiddleware): """ Cache middleware that provides basic behavior for many simple sites. Also used as the hook point for the cache decorator, which is generated using the decorator-from-middleware utility. """ def __init__(self, cache_timeout=None, cache_anonymous_only=None, **kwargs): # We need to differentiate between "provided, but using default value", # and "not provided". If the value is provided using a default, then # we fall back to system defaults. If it is not provided at all, # we need to use middleware defaults. try: key_prefix = kwargs['key_prefix'] if key_prefix is None: key_prefix = '' except KeyError: key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX self.key_prefix = key_prefix try: cache_alias = kwargs['cache_alias'] if cache_alias is None: cache_alias = DEFAULT_CACHE_ALIAS except KeyError: cache_alias = settings.CACHE_MIDDLEWARE_ALIAS self.cache_alias = cache_alias if cache_timeout is None: cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS self.cache_timeout = cache_timeout if cache_anonymous_only is None: cache_anonymous_only = getattr(settings, 'CACHE_MIDDLEWARE_ANONYMOUS_ONLY', False) self.cache_anonymous_only = cache_anonymous_only if self.cache_anonymous_only: msg = "CACHE_MIDDLEWARE_ANONYMOUS_ONLY has been deprecated and will be removed in Django 1.8." warnings.warn(msg, RemovedInDjango18Warning, stacklevel=1) self.cache = caches[self.cache_alias]
gpl-2.0
[ 624, 199, 4437, 10816, 14, 982, 5223, 12, 1924, 5634, 13, 555, 21221, 2034, 911, 506, 6328, 4079, 641, 199, 2632, 14, 710, 11358, 4340, 370, 4756, 2581, 10816, 365, 370, 663, 199, 1040, 4152, 4437, 6608, 1040, 465, 2195, 1642, 14854, 402, 10816, 12, 436, 199, 1040, 11135, 2532, 4437, 6608, 1040, 465, 314, 2061, 447, 339, 30718, 63, 13748, 275, 359, 267, 283, 1176, 14, 5754, 14, 1637, 14, 4152, 4437, 6608, 297, 267, 2263, 267, 283, 1176, 14, 5754, 14, 1637, 14, 11135, 2532, 4437, 6608, 7, 272, 1622, 199, 199, 2765, 365, 7055, 13, 442, 1907, 857, 12, 1325, 3211, 26, 1124, 4152, 4437, 6608, 1040, 4839, 370, 1255, 199, 2019, 5309, 314, 1177, 7669, 12, 1314, 10358, 10816, 9048, 13, 384, 27, 199, 1040, 11135, 2532, 4437, 6608, 1040, 4839, 370, 1255, 2061, 5309, 314, 1056, 7669, 12, 1314, 199, 11816, 10816, 2746, 13, 2110, 14, 199, 199, 1918, 2849, 13, 533, 1124, 4437, 6608, 1040, 883, 506, 1202, 367, 2005, 3486, 15424, 14, 199, 18335, 5907, 12, 340, 1263, 1163, 14854, 402, 10816, 4839, 370, 12787, 314, 2581, 790, 12, 1265, 7171, 199, 9321, 370, 675, 314, 2877, 13, 2064, 1124, 4152, 4437, 6608, 1040, 436, 199, 1040, 11135, 2532, 4437, 6608, 4345, 961, 7171, 4750, 14115, 5992, 1380, 1265, 3984, 1808, 199, 9323, 1159, 1124, 20342, 6608, 4345, 199, 199, 11053, 2436, 3595, 4212, 314, 13627, 5419, 26, 199, 199, 10, 5972, 9576, 503, 13053, 13, 6615, 543, 2004, 1233, 1926, 787, 6328, 14, 199, 199, 10, 710, 1329, 402, 4696, 1924, 2034, 365, 5489, 367, 365, 663, 701, 314, 298, 988, 13, 474, 2, 3420, 523, 402, 314, 1177, 1159, 298, 4437, 13, 3717, 2, 1406, 12, 32039, 1771, 370, 314, 523, 7240, 4576, 63, 19987, 63, 23319, 4260, 340, 314, 3420, 1990, 440, 1911, 14, 199, 199, 10, 961, 10816, 14292, 626, 282, 13053, 1056, 365, 4987, 21221, 543, 314, 2011, 1177, 523, 2323, 8840, 2839, 314, 5226, 9576, 1056, 14, 199, 199, 10, 3979, 282, 9793, 11058, 12, 282, 23834, 1331, 402, 314, 3379, 1177, 909, 365, 2138, 523, 687, 2112, 63, 1069, 14, 199, 199, 10, 510, 7441, 911, 506, 6328, 4079, 641, 314, 4072, 402, 314, 1056, 2323, 10532, 315, 523, 314, 1177, 1159, 298, 54, 695, 2, 1406, 14, 199, 199, 10, 961, 10816, 2597, 5951, 662, 1931, 12, 15237, 13, 11911, 12, 1316, 1038, 470, 436, 11977, 13, 3717, 523, 2323, 641, 314, 1177, 909, 14, 199, 199, 624, 199, 199, 646, 3598, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 1637, 492, 18014, 12, 6186, 63, 8677, 63, 12644, 199, 504, 1639, 14, 1208, 14, 1637, 492, 334, 362, 63, 1637, 63, 498, 12, 664, 63, 988, 63, 474, 12, 965, 63, 21989, 63, 1291, 12, 272, 12537, 63, 1637, 63, 498, 12, 3371, 63, 1310, 63, 2139, 9, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 1085, 3849, 421, 199, 533, 6162, 4437, 6608, 8, 785, 304, 272, 408, 272, 7232, 13, 6971, 2581, 10816, 626, 7029, 314, 2581, 340, 314, 1177, 365, 272, 2581, 461, 14, 339, 9498, 506, 1202, 465, 1777, 402, 314, 2877, 13, 2064, 1678, 15, 3535, 2581, 10816, 14, 272, 6162, 4437, 6608, 1471, 506, 314, 1642, 14854, 402, 10816, 315, 272, 30718, 63, 13748, 880, 626, 652, 7171, 664, 2797, 2061, 5309, 314, 1177, 7669, 14, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1637, 63, 2593, 275, 2202, 14, 8677, 63, 19987, 63, 23319, 267, 291, 14, 498, 63, 1861, 275, 2202, 14, 8677, 63, 19987, 63, 3078, 63, 6351, 267, 291, 14, 1637, 63, 12628, 63, 2118, 275, 2519, 8, 1751, 12, 283, 8677, 63, 19987, 63, 879, 32537, 2679, 1668, 63, 10452, 297, 756, 9, 267, 291, 14, 1637, 63, 3620, 275, 2202, 14, 8677, 63, 19987, 63, 12644, 267, 291, 14, 1637, 275, 18014, 59, 277, 14, 1637, 63, 3620, 61, 339, 347, 485, 1730, 63, 29433, 8, 277, 12, 1056, 304, 267, 862, 26, 288, 372, 1056, 14, 1730, 14, 29433, 267, 871, 4281, 26, 288, 372, 756, 339, 347, 485, 5626, 63, 873, 63, 1637, 8, 277, 12, 1056, 12, 1177, 304, 267, 340, 440, 2688, 8, 1069, 12, 2513, 1637, 63, 873, 63, 1637, 358, 503, 440, 1056, 423, 1637, 63, 873, 63, 1637, 26, 288, 372, 756, 267, 327, 982, 314, 2351, 965, 440, 2757, 13810, 4257, 12, 781, 2793, 1133, 2934, 370, 267, 327, 7675, 652, 370, 506, 13810, 2348, 14, 982, 652, 18699, 1133, 2757, 13810, 12, 2066, 314, 267, 327, 922, 1159, 10367, 13, 262, 2004, 965, 440, 16955, 314, 1177, 15988, 14, 267, 340, 291, 14, 1637, 63, 12628, 63, 2118, 436, 291, 423, 1730, 63, 29433, 8, 1069, 304, 288, 702, 2688, 8, 1069, 12, 283, 751, 659, 298, 1918, 5634, 2581, 10816, 543, 7240, 4576, 63, 19987, 63, 879, 32537, 2679, 1668, 63, 10452, 29, 549, 5074, 6299, 10816, 370, 506, 4903, 14, 16407, 2195, 30718, 63, 13748, 4260, 370, 5518, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 7, 2544, 314, 11977, 6608, 2122, 288, 340, 1056, 14, 751, 14, 374, 63, 12177, 837, 355, 327, 7529, 1133, 2581, 922, 13, 1975, 4145, 687, 15082, 4390, 14, 355, 372, 756, 267, 372, 715, 339, 347, 2112, 63, 1310, 8, 277, 12, 1056, 12, 1177, 304, 267, 408, 9899, 314, 2581, 12, 340, 4346, 1041, 267, 340, 440, 291, 423, 5626, 63, 873, 63, 1637, 8, 1069, 12, 1177, 304, 288, 327, 2136, 2793, 1133, 1929, 370, 1678, 314, 2581, 12, 2951, 372, 14, 288, 372, 1177, 398, 340, 1177, 14, 12076, 503, 1177, 14, 1205, 63, 600, 1137, 1926, 26, 288, 372, 1177, 398, 327, 7529, 1133, 2581, 9320, 626, 663, 282, 922, 13, 6100, 334, 460, 11703, 6391, 267, 327, 18423, 9, 5494, 315, 1177, 370, 282, 5494, 13, 2003, 1056, 14, 267, 340, 440, 1056, 14, 12189, 2563, 436, 1177, 14, 7792, 436, 965, 63, 21989, 63, 1291, 8, 1310, 12, 283, 7810, 735, 288, 372, 1177, 398, 327, 7649, 370, 664, 314, 2653, 687, 314, 298, 988, 13, 474, 2 ]
[ 199, 4437, 10816, 14, 982, 5223, 12, 1924, 5634, 13, 555, 21221, 2034, 911, 506, 6328, 4079, 641, 199, 2632, 14, 710, 11358, 4340, 370, 4756, 2581, 10816, 365, 370, 663, 199, 1040, 4152, 4437, 6608, 1040, 465, 2195, 1642, 14854, 402, 10816, 12, 436, 199, 1040, 11135, 2532, 4437, 6608, 1040, 465, 314, 2061, 447, 339, 30718, 63, 13748, 275, 359, 267, 283, 1176, 14, 5754, 14, 1637, 14, 4152, 4437, 6608, 297, 267, 2263, 267, 283, 1176, 14, 5754, 14, 1637, 14, 11135, 2532, 4437, 6608, 7, 272, 1622, 199, 199, 2765, 365, 7055, 13, 442, 1907, 857, 12, 1325, 3211, 26, 1124, 4152, 4437, 6608, 1040, 4839, 370, 1255, 199, 2019, 5309, 314, 1177, 7669, 12, 1314, 10358, 10816, 9048, 13, 384, 27, 199, 1040, 11135, 2532, 4437, 6608, 1040, 4839, 370, 1255, 2061, 5309, 314, 1056, 7669, 12, 1314, 199, 11816, 10816, 2746, 13, 2110, 14, 199, 199, 1918, 2849, 13, 533, 1124, 4437, 6608, 1040, 883, 506, 1202, 367, 2005, 3486, 15424, 14, 199, 18335, 5907, 12, 340, 1263, 1163, 14854, 402, 10816, 4839, 370, 12787, 314, 2581, 790, 12, 1265, 7171, 199, 9321, 370, 675, 314, 2877, 13, 2064, 1124, 4152, 4437, 6608, 1040, 436, 199, 1040, 11135, 2532, 4437, 6608, 4345, 961, 7171, 4750, 14115, 5992, 1380, 1265, 3984, 1808, 199, 9323, 1159, 1124, 20342, 6608, 4345, 199, 199, 11053, 2436, 3595, 4212, 314, 13627, 5419, 26, 199, 199, 10, 5972, 9576, 503, 13053, 13, 6615, 543, 2004, 1233, 1926, 787, 6328, 14, 199, 199, 10, 710, 1329, 402, 4696, 1924, 2034, 365, 5489, 367, 365, 663, 701, 314, 298, 988, 13, 474, 2, 3420, 523, 402, 314, 1177, 1159, 298, 4437, 13, 3717, 2, 1406, 12, 32039, 1771, 370, 314, 523, 7240, 4576, 63, 19987, 63, 23319, 4260, 340, 314, 3420, 1990, 440, 1911, 14, 199, 199, 10, 961, 10816, 14292, 626, 282, 13053, 1056, 365, 4987, 21221, 543, 314, 2011, 1177, 523, 2323, 8840, 2839, 314, 5226, 9576, 1056, 14, 199, 199, 10, 3979, 282, 9793, 11058, 12, 282, 23834, 1331, 402, 314, 3379, 1177, 909, 365, 2138, 523, 687, 2112, 63, 1069, 14, 199, 199, 10, 510, 7441, 911, 506, 6328, 4079, 641, 314, 4072, 402, 314, 1056, 2323, 10532, 315, 523, 314, 1177, 1159, 298, 54, 695, 2, 1406, 14, 199, 199, 10, 961, 10816, 2597, 5951, 662, 1931, 12, 15237, 13, 11911, 12, 1316, 1038, 470, 436, 11977, 13, 3717, 523, 2323, 641, 314, 1177, 909, 14, 199, 199, 624, 199, 199, 646, 3598, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 1637, 492, 18014, 12, 6186, 63, 8677, 63, 12644, 199, 504, 1639, 14, 1208, 14, 1637, 492, 334, 362, 63, 1637, 63, 498, 12, 664, 63, 988, 63, 474, 12, 965, 63, 21989, 63, 1291, 12, 272, 12537, 63, 1637, 63, 498, 12, 3371, 63, 1310, 63, 2139, 9, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 1085, 3849, 421, 199, 533, 6162, 4437, 6608, 8, 785, 304, 272, 408, 272, 7232, 13, 6971, 2581, 10816, 626, 7029, 314, 2581, 340, 314, 1177, 365, 272, 2581, 461, 14, 339, 9498, 506, 1202, 465, 1777, 402, 314, 2877, 13, 2064, 1678, 15, 3535, 2581, 10816, 14, 272, 6162, 4437, 6608, 1471, 506, 314, 1642, 14854, 402, 10816, 315, 272, 30718, 63, 13748, 880, 626, 652, 7171, 664, 2797, 2061, 5309, 314, 1177, 7669, 14, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1637, 63, 2593, 275, 2202, 14, 8677, 63, 19987, 63, 23319, 267, 291, 14, 498, 63, 1861, 275, 2202, 14, 8677, 63, 19987, 63, 3078, 63, 6351, 267, 291, 14, 1637, 63, 12628, 63, 2118, 275, 2519, 8, 1751, 12, 283, 8677, 63, 19987, 63, 879, 32537, 2679, 1668, 63, 10452, 297, 756, 9, 267, 291, 14, 1637, 63, 3620, 275, 2202, 14, 8677, 63, 19987, 63, 12644, 267, 291, 14, 1637, 275, 18014, 59, 277, 14, 1637, 63, 3620, 61, 339, 347, 485, 1730, 63, 29433, 8, 277, 12, 1056, 304, 267, 862, 26, 288, 372, 1056, 14, 1730, 14, 29433, 267, 871, 4281, 26, 288, 372, 756, 339, 347, 485, 5626, 63, 873, 63, 1637, 8, 277, 12, 1056, 12, 1177, 304, 267, 340, 440, 2688, 8, 1069, 12, 2513, 1637, 63, 873, 63, 1637, 358, 503, 440, 1056, 423, 1637, 63, 873, 63, 1637, 26, 288, 372, 756, 267, 327, 982, 314, 2351, 965, 440, 2757, 13810, 4257, 12, 781, 2793, 1133, 2934, 370, 267, 327, 7675, 652, 370, 506, 13810, 2348, 14, 982, 652, 18699, 1133, 2757, 13810, 12, 2066, 314, 267, 327, 922, 1159, 10367, 13, 262, 2004, 965, 440, 16955, 314, 1177, 15988, 14, 267, 340, 291, 14, 1637, 63, 12628, 63, 2118, 436, 291, 423, 1730, 63, 29433, 8, 1069, 304, 288, 702, 2688, 8, 1069, 12, 283, 751, 659, 298, 1918, 5634, 2581, 10816, 543, 7240, 4576, 63, 19987, 63, 879, 32537, 2679, 1668, 63, 10452, 29, 549, 5074, 6299, 10816, 370, 506, 4903, 14, 16407, 2195, 30718, 63, 13748, 4260, 370, 5518, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 7, 2544, 314, 11977, 6608, 2122, 288, 340, 1056, 14, 751, 14, 374, 63, 12177, 837, 355, 327, 7529, 1133, 2581, 922, 13, 1975, 4145, 687, 15082, 4390, 14, 355, 372, 756, 267, 372, 715, 339, 347, 2112, 63, 1310, 8, 277, 12, 1056, 12, 1177, 304, 267, 408, 9899, 314, 2581, 12, 340, 4346, 1041, 267, 340, 440, 291, 423, 5626, 63, 873, 63, 1637, 8, 1069, 12, 1177, 304, 288, 327, 2136, 2793, 1133, 1929, 370, 1678, 314, 2581, 12, 2951, 372, 14, 288, 372, 1177, 398, 340, 1177, 14, 12076, 503, 1177, 14, 1205, 63, 600, 1137, 1926, 26, 288, 372, 1177, 398, 327, 7529, 1133, 2581, 9320, 626, 663, 282, 922, 13, 6100, 334, 460, 11703, 6391, 267, 327, 18423, 9, 5494, 315, 1177, 370, 282, 5494, 13, 2003, 1056, 14, 267, 340, 440, 1056, 14, 12189, 2563, 436, 1177, 14, 7792, 436, 965, 63, 21989, 63, 1291, 8, 1310, 12, 283, 7810, 735, 288, 372, 1177, 398, 327, 7649, 370, 664, 314, 2653, 687, 314, 298, 988, 13, 474, 2, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
MrTheodor/espressopp
examples/tabulated_potential/table_interpolation.py
5
6396
#!/usr/bin/env python2 # Copyright (C) 2016-2017(H) # Max Planck Institute for Polymer Research # # This file is part of ESPResSo++. # # ESPResSo++ is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # ESPResSo++ is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. ########################################################################### # ESPResSo++ # # Test script for Interpolation of tabulated LJ simulation # # # ########################################################################### import sys import time import os import espressopp import mpi4py.MPI as MPI import math import logging from espressopp import Real3D, Int3D from espressopp.tools import timers # Input values for system N = 10 # box size size = (float(N), float(N), float(N)) numParticles = N**3 # number of particles nsteps = 1000 # number of steps cutoff = 2.5 # cutoff for LJ potential tabfile = "pot-lj.txt" # file for tabulated potential skin = 0.3 # skin for Verlet lists splinetypes = ['Linear','Akima','Cubic'] # implemented spline types ###################################################################### ## IT SHOULD BE UNNECESSARY TO MAKE MODIFICATIONS BELOW THIS LINE ## ###################################################################### print '\n-- Tabulated Interpolation Test -- \n' print 'Steps: %3s' % nsteps print 'Particles: %3s' % numParticles print 'Cutoff: %3s' % cutoff # writes the tabulated potential file def writeTabFile(pot, name, N, low=0.0, high=2.5, body=2): outfile = open(name, "w") delta = (high - low) / (N - 1) for i in range(N): r = low + i * delta energy = pot.computeEnergy(r) if body == 2:# this is for 2-body potentials force = pot.computeForce(Real3D(r, 0.0, 0.0))[0] else: # this is for 3- and 4-body potentials force = pot.computeForce(r) outfile.write("%15.8g %15.8g %15.8g\n"%(r, energy, force)) outfile.close() # write the tabulated file for a LJ potential print 'Generating potential file ... (%2s)' % tabfile potLJ = espressopp.interaction.LennardJones(epsilon=1.0, sigma=1.0, shift=0.0, cutoff=cutoff) writeTabFile(potLJ, tabfile, N=257, low=0.01, high=potLJ.cutoff) # compute the number of cells on each node def calcNumberCells(size, nodes, cutoff): ncells = 1 while size / (ncells * nodes) >= cutoff: ncells = ncells + 1 return ncells - 1 # run simulation for all interpolation types for spline in range(1,len(splinetypes)+1): print '\nSpline interpolation (%0d/%0d): %0s'% (spline, len(splinetypes), splinetypes[spline-1]) # set up system system = espressopp.System() system.rng = espressopp.esutil.RNG() system.bc = espressopp.bc.OrthorhombicBC(system.rng, size) system.skin = skin comm = MPI.COMM_WORLD nodeGrid = Int3D(1, 1, comm.size) cellGrid = Int3D( calcNumberCells(size[0], nodeGrid[0], cutoff), calcNumberCells(size[1], nodeGrid[1], cutoff), calcNumberCells(size[2], nodeGrid[2], cutoff) ) system.storage = espressopp.storage.DomainDecomposition(system, nodeGrid, cellGrid) pid = 0 for i in range(N): for j in range(N): for k in range(N): m = (i + 2*j + 3*k) % 11 r = 0.45 + m * 0.01 x = (i + r) / N * size[0] y = (j + r) / N * size[1] z = (k + r) / N * size[2] x = 1.0 * i y = 1.0 * j z = 1.0 * k system.storage.addParticle(pid, Real3D(x, y, z)) # not yet: dd.setVelocity(id, (1.0, 0.0, 0.0)) pid = pid + 1 system.storage.decompose() # integrator integrator = espressopp.integrator.VelocityVerlet(system) integrator.dt = 0.005 # now build Verlet List # ATTENTION: you must not add the skin explicitly here logging.getLogger("Interpolation").setLevel(logging.INFO) vl = espressopp.VerletList(system, cutoff = cutoff) potTab = espressopp.interaction.Tabulated(itype=spline, filename=tabfile, cutoff=cutoff) # ATTENTION: auto shift was enabled interTab = espressopp.interaction.VerletListTabulated(vl) interTab.setPotential(type1=0, type2=0, potential=potTab) system.addInteraction(interTab) temp = espressopp.analysis.Temperature(system) press = espressopp.analysis.Pressure(system) temperature = temp.compute() p = press.compute() Ek = 0.5 * temperature * (3 * numParticles) Ep = interTab.computeEnergy() print 'Start %5s: tot energy = %10.3f pot = %10.3f kin = %10.3f temp = %10.3f p = %10.3f' \ % ("", Ek + Ep, Ep, Ek, temperature, p) # langevin thermostat langevin = espressopp.integrator.LangevinThermostat(system) integrator.addExtension(langevin) langevin.gamma = 1.0 langevin.temperature = 1.0 start_time = time.clock() integrator.run(nsteps) temperature = temp.compute() p = press.compute() Ek = 0.5 * temperature * (3 * numParticles) Ep = interTab.computeEnergy() print 'Step %6d: tot energy = %10.3f pot = %10.3f kin = %10.3f temp = %10.3f p = %10.3f\n' % \ (nsteps, Ek + Ep, Ep, Ek, temperature, p) end_time = time.clock() timers.show(integrator.getTimers(), precision=2) os.system('rm '+tabfile) print '\nDone.'
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 221, 1898, 334, 35, 9, 7800, 13, 10680, 8, 40, 9, 199, 3, 420, 8228, 32427, 346, 1010, 25585, 367, 16869, 2626, 26993, 199, 3, 199, 3, 221, 961, 570, 365, 1777, 402, 31334, 1322, 5158, 4176, 14, 199, 3, 199, 3, 221, 31334, 1322, 5158, 4176, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 221, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 221, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 221, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 31334, 1322, 5158, 4176, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3949, 5680, 199, 3, 221, 31334, 1322, 5158, 4176, 2476, 17907, 327, 199, 3, 221, 1379, 2884, 367, 6551, 9536, 402, 5174, 8097, 491, 42, 17625, 5185, 327, 199, 3, 17997, 327, 199, 3949, 5680, 199, 199, 646, 984, 199, 646, 900, 199, 646, 747, 199, 646, 9455, 2915, 26740, 199, 646, 26806, 20, 647, 14, 28983, 465, 26024, 199, 646, 3473, 199, 646, 2050, 199, 504, 9455, 2915, 26740, 492, 14849, 19, 36, 12, 9805, 19, 36, 199, 504, 9455, 2915, 26740, 14, 2537, 492, 900, 2393, 4388, 199, 3, 6924, 1338, 367, 2656, 199, 46, 275, 1616, 27503, 327, 5689, 1568, 199, 890, 221, 275, 334, 1609, 8, 46, 395, 2069, 8, 46, 395, 2069, 8, 46, 430, 199, 1507, 14986, 83, 275, 653, 538, 19, 9668, 327, 1329, 402, 26115, 199, 561, 6224, 221, 275, 5198, 14960, 327, 1329, 402, 7124, 199, 17708, 221, 275, 499, 14, 21, 17907, 327, 17875, 367, 491, 42, 12330, 199, 2902, 493, 275, 298, 14173, 13, 31025, 14, 2424, 2, 8540, 327, 570, 367, 5174, 8097, 12330, 199, 16409, 259, 275, 378, 14, 19, 17907, 327, 28337, 367, 5444, 2723, 5548, 199, 27066, 1313, 275, 788, 10608, 1673, 33, 8810, 391, 1673, 35, 456, 530, 418, 221, 327, 6366, 30213, 2943, 421, 199, 18022, 199, 309, 473, 52, 428, 31909, 6262, 6778, 46, 4220, 1608, 4392, 2296, 4828, 2430, 10362, 1914, 23380, 12969, 6262, 5896, 5749, 13587, 257, 925, 199, 18022, 199, 199, 1361, 1557, 78, 306, 23159, 8097, 6551, 9536, 1379, 1553, 971, 78, 7, 199, 1361, 283, 20960, 26, 450, 19, 83, 7, 450, 700, 6224, 199, 1361, 283, 14986, 83, 26, 450, 19, 83, 7, 450, 1967, 14986, 83, 199, 1361, 283, 35, 11222, 26, 450, 19, 83, 7, 450, 17875, 421, 199, 3, 14511, 314, 5174, 8097, 12330, 570, 199, 318, 2218, 7690, 1173, 8, 14173, 12, 536, 12, 653, 12, 6465, 29, 16, 14, 16, 12, 4721, 29, 18, 14, 21, 12, 2396, 29, 18, 304, 272, 4386, 275, 1551, 8, 354, 12, 298, 87, 531, 272, 5762, 275, 334, 6260, 446, 6465, 9, 1182, 334, 46, 446, 413, 9, 489, 272, 367, 284, 315, 1425, 8, 46, 304, 267, 519, 275, 6465, 435, 284, 627, 5762, 267, 12304, 275, 27701, 14, 3357, 9900, 8, 82, 9, 267, 340, 2396, 508, 499, 15596, 642, 365, 367, 499, 13, 2030, 12330, 83, 288, 3542, 275, 27701, 14, 3357, 13606, 8, 10099, 19, 36, 8, 82, 12, 378, 14, 16, 12, 378, 14, 16, 11515, 16, 61, 267, 587, 26, 327, 642, 365, 367, 650, 13, 436, 841, 13, 2030, 12330, 83, 288, 3542, 275, 27701, 14, 3357, 13606, 8, 82, 9, 267, 4386, 14, 952, 3647, 1046, 14, 24, 71, 450, 1046, 14, 24, 71, 450, 1046, 14, 24, 71, 60, 78, 14007, 82, 12, 12304, 12, 3542, 430, 489, 272, 4386, 14, 1600, 342, 199, 199, 3, 2218, 314, 5174, 8097, 570, 367, 282, 491, 42, 12330, 199, 1361, 283, 29244, 12330, 570, 2263, 4366, 18, 83, 3171, 450, 5174, 493, 199, 14173, 23215, 275, 9455, 2915, 26740, 14, 21679, 14, 3166, 78, 1005, 42, 4548, 8, 15761, 29, 17, 14, 16, 12, 10819, 29, 17, 14, 16, 12, 7706, 29, 16, 14, 16, 12, 17875, 29, 17708, 9, 199, 952, 7690, 1173, 8, 14173, 23215, 12, 5174, 493, 12, 653, 29, 11551, 12, 6465, 29, 16, 14, 614, 12, 4721, 29, 14173, 23215, 14, 17708, 9, 421, 199, 3, 4526, 314, 1329, 402, 10106, 641, 1924, 1031, 199, 318, 12831, 3259, 16852, 8, 890, 12, 3380, 12, 17875, 304, 272, 302, 9041, 275, 413, 272, 1830, 1568, 1182, 334, 78, 9041, 627, 3380, 9, 2356, 17875, 26, 2126, 302, 9041, 275, 302, 9041, 435, 413, 272, 372, 302, 9041, 446, 413, 6905, 199, 3, 1255, 17625, 367, 1006, 14046, 2943, 199, 509, 30213, 315, 1425, 8, 17, 12, 552, 8, 27066, 1313, 6393, 17, 304, 2286, 870, 1557, 78, 27558, 14046, 4366, 16, 68, 3149, 16, 68, 304, 450, 16, 83, 5956, 334, 27066, 12, 822, 8, 27066, 1313, 395, 30213, 1313, 59, 27066, 13, 17, 566, 5493, 327, 663, 1536, 2656, 272, 2656, 275, 9455, 2915, 26740, 14, 3989, 342, 272, 2656, 14, 12686, 221, 275, 9455, 2915, 26740, 14, 397, 1974, 14, 50, 12259, 342, 272, 2656, 14, 3776, 275, 9455, 2915, 26740, 14, 3776, 14, 2844, 273, 269, 526, 20596, 6265, 8, 2253, 14, 12686, 12, 1568, 9, 272, 2656, 14, 16409, 275, 28337, 5493, 1923, 275, 26024, 14, 5378, 63, 22125, 5493, 1031, 7900, 275, 9805, 19, 36, 8, 17, 12, 413, 12, 1923, 14, 890, 9, 272, 4917, 7900, 275, 9805, 19, 36, 8, 267, 12831, 3259, 16852, 8, 890, 59, 16, 467, 1031, 7900, 59, 16, 467, 17875, 395, 267, 12831, 3259, 16852, 8, 890, 59, 17, 467, 1031, 7900, 59, 17, 467, 17875, 395, 267, 12831, 3259 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 221, 1898, 334, 35, 9, 7800, 13, 10680, 8, 40, 9, 199, 3, 420, 8228, 32427, 346, 1010, 25585, 367, 16869, 2626, 26993, 199, 3, 199, 3, 221, 961, 570, 365, 1777, 402, 31334, 1322, 5158, 4176, 14, 199, 3, 199, 3, 221, 31334, 1322, 5158, 4176, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 221, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 221, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 221, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 31334, 1322, 5158, 4176, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3949, 5680, 199, 3, 221, 31334, 1322, 5158, 4176, 2476, 17907, 327, 199, 3, 221, 1379, 2884, 367, 6551, 9536, 402, 5174, 8097, 491, 42, 17625, 5185, 327, 199, 3, 17997, 327, 199, 3949, 5680, 199, 199, 646, 984, 199, 646, 900, 199, 646, 747, 199, 646, 9455, 2915, 26740, 199, 646, 26806, 20, 647, 14, 28983, 465, 26024, 199, 646, 3473, 199, 646, 2050, 199, 504, 9455, 2915, 26740, 492, 14849, 19, 36, 12, 9805, 19, 36, 199, 504, 9455, 2915, 26740, 14, 2537, 492, 900, 2393, 4388, 199, 3, 6924, 1338, 367, 2656, 199, 46, 275, 1616, 27503, 327, 5689, 1568, 199, 890, 221, 275, 334, 1609, 8, 46, 395, 2069, 8, 46, 395, 2069, 8, 46, 430, 199, 1507, 14986, 83, 275, 653, 538, 19, 9668, 327, 1329, 402, 26115, 199, 561, 6224, 221, 275, 5198, 14960, 327, 1329, 402, 7124, 199, 17708, 221, 275, 499, 14, 21, 17907, 327, 17875, 367, 491, 42, 12330, 199, 2902, 493, 275, 298, 14173, 13, 31025, 14, 2424, 2, 8540, 327, 570, 367, 5174, 8097, 12330, 199, 16409, 259, 275, 378, 14, 19, 17907, 327, 28337, 367, 5444, 2723, 5548, 199, 27066, 1313, 275, 788, 10608, 1673, 33, 8810, 391, 1673, 35, 456, 530, 418, 221, 327, 6366, 30213, 2943, 421, 199, 18022, 199, 309, 473, 52, 428, 31909, 6262, 6778, 46, 4220, 1608, 4392, 2296, 4828, 2430, 10362, 1914, 23380, 12969, 6262, 5896, 5749, 13587, 257, 925, 199, 18022, 199, 199, 1361, 1557, 78, 306, 23159, 8097, 6551, 9536, 1379, 1553, 971, 78, 7, 199, 1361, 283, 20960, 26, 450, 19, 83, 7, 450, 700, 6224, 199, 1361, 283, 14986, 83, 26, 450, 19, 83, 7, 450, 1967, 14986, 83, 199, 1361, 283, 35, 11222, 26, 450, 19, 83, 7, 450, 17875, 421, 199, 3, 14511, 314, 5174, 8097, 12330, 570, 199, 318, 2218, 7690, 1173, 8, 14173, 12, 536, 12, 653, 12, 6465, 29, 16, 14, 16, 12, 4721, 29, 18, 14, 21, 12, 2396, 29, 18, 304, 272, 4386, 275, 1551, 8, 354, 12, 298, 87, 531, 272, 5762, 275, 334, 6260, 446, 6465, 9, 1182, 334, 46, 446, 413, 9, 489, 272, 367, 284, 315, 1425, 8, 46, 304, 267, 519, 275, 6465, 435, 284, 627, 5762, 267, 12304, 275, 27701, 14, 3357, 9900, 8, 82, 9, 267, 340, 2396, 508, 499, 15596, 642, 365, 367, 499, 13, 2030, 12330, 83, 288, 3542, 275, 27701, 14, 3357, 13606, 8, 10099, 19, 36, 8, 82, 12, 378, 14, 16, 12, 378, 14, 16, 11515, 16, 61, 267, 587, 26, 327, 642, 365, 367, 650, 13, 436, 841, 13, 2030, 12330, 83, 288, 3542, 275, 27701, 14, 3357, 13606, 8, 82, 9, 267, 4386, 14, 952, 3647, 1046, 14, 24, 71, 450, 1046, 14, 24, 71, 450, 1046, 14, 24, 71, 60, 78, 14007, 82, 12, 12304, 12, 3542, 430, 489, 272, 4386, 14, 1600, 342, 199, 199, 3, 2218, 314, 5174, 8097, 570, 367, 282, 491, 42, 12330, 199, 1361, 283, 29244, 12330, 570, 2263, 4366, 18, 83, 3171, 450, 5174, 493, 199, 14173, 23215, 275, 9455, 2915, 26740, 14, 21679, 14, 3166, 78, 1005, 42, 4548, 8, 15761, 29, 17, 14, 16, 12, 10819, 29, 17, 14, 16, 12, 7706, 29, 16, 14, 16, 12, 17875, 29, 17708, 9, 199, 952, 7690, 1173, 8, 14173, 23215, 12, 5174, 493, 12, 653, 29, 11551, 12, 6465, 29, 16, 14, 614, 12, 4721, 29, 14173, 23215, 14, 17708, 9, 421, 199, 3, 4526, 314, 1329, 402, 10106, 641, 1924, 1031, 199, 318, 12831, 3259, 16852, 8, 890, 12, 3380, 12, 17875, 304, 272, 302, 9041, 275, 413, 272, 1830, 1568, 1182, 334, 78, 9041, 627, 3380, 9, 2356, 17875, 26, 2126, 302, 9041, 275, 302, 9041, 435, 413, 272, 372, 302, 9041, 446, 413, 6905, 199, 3, 1255, 17625, 367, 1006, 14046, 2943, 199, 509, 30213, 315, 1425, 8, 17, 12, 552, 8, 27066, 1313, 6393, 17, 304, 2286, 870, 1557, 78, 27558, 14046, 4366, 16, 68, 3149, 16, 68, 304, 450, 16, 83, 5956, 334, 27066, 12, 822, 8, 27066, 1313, 395, 30213, 1313, 59, 27066, 13, 17, 566, 5493, 327, 663, 1536, 2656, 272, 2656, 275, 9455, 2915, 26740, 14, 3989, 342, 272, 2656, 14, 12686, 221, 275, 9455, 2915, 26740, 14, 397, 1974, 14, 50, 12259, 342, 272, 2656, 14, 3776, 275, 9455, 2915, 26740, 14, 3776, 14, 2844, 273, 269, 526, 20596, 6265, 8, 2253, 14, 12686, 12, 1568, 9, 272, 2656, 14, 16409, 275, 28337, 5493, 1923, 275, 26024, 14, 5378, 63, 22125, 5493, 1031, 7900, 275, 9805, 19, 36, 8, 17, 12, 413, 12, 1923, 14, 890, 9, 272, 4917, 7900, 275, 9805, 19, 36, 8, 267, 12831, 3259, 16852, 8, 890, 59, 16, 467, 1031, 7900, 59, 16, 467, 17875, 395, 267, 12831, 3259, 16852, 8, 890, 59, 17, 467, 1031, 7900, 59, 17, 467, 17875, 395, 267, 12831, 3259, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
tamsky/ansible-upstream
lib/ansible/parsing/splitter.py
9
10866
# (c) 2014 James Cammarata, <jcammarata@ansible.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type import re import codecs from ansible.errors import AnsibleError from ansible.parsing.quoting import unquote # Decode escapes adapted from rspeer's answer here: # http://stackoverflow.com/questions/4020539/process-escape-sequences-in-a-string-in-python _HEXCHAR = '[a-fA-F0-9]' _ESCAPE_SEQUENCE_RE = re.compile(r''' ( \\U{0} # 8-digit hex escapes | \\u{1} # 4-digit hex escapes | \\x{2} # 2-digit hex escapes | \\N\{{[^}}]+\}} # Unicode characters by name | \\[\\'"abfnrtv] # Single-character escapes )'''.format(_HEXCHAR*8, _HEXCHAR*4, _HEXCHAR*2), re.UNICODE | re.VERBOSE) def _decode_escapes(s): def decode_match(match): return codecs.decode(match.group(0), 'unicode-escape') return _ESCAPE_SEQUENCE_RE.sub(decode_match, s) def parse_kv(args, check_raw=False): ''' Convert a string of key/value items to a dict. If any free-form params are found and the check_raw option is set to True, they will be added to a new parameter called '_raw_params'. If check_raw is not enabled, they will simply be ignored. ''' ### FIXME: args should already be a unicode string from ansible.utils.unicode import to_unicode args = to_unicode(args, nonstring='passthru') options = {} if args is not None: try: vargs = split_args(args) except ValueError as ve: if 'no closing quotation' in str(ve).lower(): raise AnsibleError("error parsing argument string, try quoting the entire line.") else: raise raw_params = [] for x in vargs: x = _decode_escapes(x) if "=" in x: pos = 0 try: while True: pos = x.index('=', pos + 1) if pos > 0 and x[pos - 1] != '\\': break except ValueError: # ran out of string, but we must have some escaped equals, # so replace those and append this to the list of raw params raw_params.append(x.replace('\\=', '=')) continue k = x[:pos] v = x[pos + 1:] # only internal variables can start with an underscore, so # we don't allow users to set them directy in arguments if k.startswith('_'): raise AnsibleError("invalid parameter specified: '%s'" % k) # FIXME: make the retrieval of this list of shell/command # options a function, so the list is centralized if check_raw and k not in ('creates', 'removes', 'chdir', 'executable', 'warn'): raw_params.append(x) else: options[k.strip()] = unquote(v.strip()) else: raw_params.append(x) # recombine the free-form params, if any were found, and assign # them to a special option for use later by the shell/command module if len(raw_params) > 0: options[u'_raw_params'] = ' '.join(raw_params) return options def _get_quote_state(token, quote_char): ''' the goal of this block is to determine if the quoted string is unterminated in which case it needs to be put back together ''' # the char before the current one, used to see if # the current character is escaped prev_char = None for idx, cur_char in enumerate(token): if idx > 0: prev_char = token[idx-1] if cur_char in '"\'' and prev_char != '\\': if quote_char: if cur_char == quote_char: quote_char = None else: quote_char = cur_char return quote_char def _count_jinja2_blocks(token, cur_depth, open_token, close_token): ''' this function counts the number of opening/closing blocks for a given opening/closing type and adjusts the current depth for that block based on the difference ''' num_open = token.count(open_token) num_close = token.count(close_token) if num_open != num_close: cur_depth += (num_open - num_close) if cur_depth < 0: cur_depth = 0 return cur_depth def split_args(args): ''' Splits args on whitespace, but intelligently reassembles those that may have been split over a jinja2 block or quotes. When used in a remote module, we won't ever have to be concerned about jinja2 blocks, however this function is/will be used in the core portions as well before the args are templated. example input: a=b c="foo bar" example output: ['a=b', 'c="foo bar"'] Basically this is a variation shlex that has some more intelligence for how Ansible needs to use it. ''' # the list of params parsed out of the arg string # this is going to be the result value when we are done params = [] # Initial split on white space args = args.strip() items = args.strip().split('\n') # iterate over the tokens, and reassemble any that may have been # split on a space inside a jinja2 block. # ex if tokens are "{{", "foo", "}}" these go together # These variables are used # to keep track of the state of the parsing, since blocks and quotes # may be nested within each other. quote_char = None inside_quotes = False print_depth = 0 # used to count nested jinja2 {{ }} blocks block_depth = 0 # used to count nested jinja2 {% %} blocks comment_depth = 0 # used to count nested jinja2 {# #} blocks # now we loop over each split chunk, coalescing tokens if the white space # split occurred within quotes or a jinja2 block of some kind for itemidx,item in enumerate(items): # we split on spaces and newlines separately, so that we # can tell which character we split on for reassembly # inside quotation characters tokens = item.strip().split(' ') line_continuation = False for idx,token in enumerate(tokens): # if we hit a line continuation character, but # we're not inside quotes, ignore it and continue # on to the next token while setting a flag if token == '\\' and not inside_quotes: line_continuation = True continue # store the previous quoting state for checking later was_inside_quotes = inside_quotes quote_char = _get_quote_state(token, quote_char) inside_quotes = quote_char is not None # multiple conditions may append a token to the list of params, # so we keep track with this flag to make sure it only happens once # append means add to the end of the list, don't append means concatenate # it to the end of the last token appended = False # if we're inside quotes now, but weren't before, append the token # to the end of the list, since we'll tack on more to it later # otherwise, if we're inside any jinja2 block, inside quotes, or we were # inside quotes (but aren't now) concat this token to the last param if inside_quotes and not was_inside_quotes: params.append(token) appended = True elif print_depth or block_depth or comment_depth or inside_quotes or was_inside_quotes: if idx == 0 and was_inside_quotes: params[-1] = "%s%s" % (params[-1], token) elif len(tokens) > 1: spacer = '' if idx > 0: spacer = ' ' params[-1] = "%s%s%s" % (params[-1], spacer, token) else: params[-1] = "%s\n%s" % (params[-1], token) appended = True # if the number of paired block tags is not the same, the depth has changed, so we calculate that here # and may append the current token to the params (if we haven't previously done so) prev_print_depth = print_depth print_depth = _count_jinja2_blocks(token, print_depth, "{{", "}}") if print_depth != prev_print_depth and not appended: params.append(token) appended = True prev_block_depth = block_depth block_depth = _count_jinja2_blocks(token, block_depth, "{%", "%}") if block_depth != prev_block_depth and not appended: params.append(token) appended = True prev_comment_depth = comment_depth comment_depth = _count_jinja2_blocks(token, comment_depth, "{#", "#}") if comment_depth != prev_comment_depth and not appended: params.append(token) appended = True # finally, if we're at zero depth for all blocks and not inside quotes, and have not # yet appended anything to the list of params, we do so now if not (print_depth or block_depth or comment_depth) and not inside_quotes and not appended and token != '': params.append(token) # if this was the last token in the list, and we have more than # one item (meaning we split on newlines), add a newline back here # to preserve the original structure if len(items) > 1 and itemidx != len(items) - 1 and not line_continuation: params[-1] += '\n' # always clear the line continuation flag line_continuation = False # If we're done and things are not at zero depth or we're still inside quotes, # raise an error to indicate that the args were unbalanced if print_depth or block_depth or comment_depth or inside_quotes: raise Exception("error while splitting arguments, either an unbalanced jinja2 block or quotes") return params
gpl-3.0
[ 3, 334, 67, 9, 6927, 1603, 14015, 445, 455, 4584, 419, 12, 665, 74, 15176, 4584, 419, 32, 4853, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 295, 199, 646, 6010, 199, 199, 504, 3242, 14, 2550, 492, 13358, 199, 504, 3242, 14, 11059, 14, 25272, 492, 14342, 199, 199, 3, 22462, 24644, 26266, 687, 10717, 7866, 1159, 6385, 2348, 26, 199, 3, 1455, 921, 23153, 14, 957, 15, 16069, 15, 13314, 1717, 1355, 15, 1412, 13, 3765, 13, 13436, 13, 262, 13, 65, 13, 875, 13, 262, 13, 1548, 199, 63, 21377, 5901, 275, 6730, 65, 13, 13753, 13, 38, 16, 13, 25, 6616, 199, 63, 28879, 63, 16585, 63, 907, 275, 295, 14, 2014, 8, 82, 2344, 272, 334, 8522, 53, 91, 16, 93, 3698, 327, 1695, 13, 8573, 6318, 24644, 272, 1204, 8522, 85, 91, 17, 93, 3698, 327, 841, 13, 8573, 6318, 24644, 272, 1204, 8522, 88, 91, 18, 93, 3698, 327, 499, 13, 8573, 6318, 24644, 272, 1204, 8522, 46, 60, 3638, 4735, 4863, 24621, 4863, 221, 327, 6140, 4110, 701, 536, 272, 1204, 8522, 59, 1103, 4065, 371, 2324, 2591, 86, 61, 221, 327, 13050, 13, 10856, 24644, 272, 776, 891, 1370, 908, 1547, 21377, 5901, 10, 24, 12, 485, 21377, 5901, 10, 20, 12, 485, 21377, 5901, 10, 18, 395, 295, 14, 12819, 1204, 295, 14, 16075, 9, 199, 199, 318, 485, 2708, 63, 3765, 83, 8, 83, 304, 272, 347, 4849, 63, 1431, 8, 1431, 304, 267, 372, 6010, 14, 2708, 8, 1431, 14, 923, 8, 16, 395, 283, 2975, 13, 3765, 358, 339, 372, 485, 28879, 63, 16585, 63, 907, 14, 954, 8, 2708, 63, 1431, 12, 308, 9, 199, 199, 318, 2198, 63, 11475, 8, 589, 12, 1104, 63, 1773, 29, 797, 304, 272, 1449, 272, 7905, 282, 1059, 402, 790, 15, 585, 2974, 370, 282, 1211, 14, 982, 1263, 2867, 13, 964, 1862, 272, 787, 1911, 436, 314, 1104, 63, 1773, 945, 365, 663, 370, 715, 12, 2985, 911, 506, 3483, 272, 370, 282, 892, 2725, 2797, 2513, 1773, 63, 1162, 1370, 982, 1104, 63, 1773, 365, 440, 5223, 12, 272, 2985, 911, 9329, 506, 5525, 14, 272, 1449, 339, 6754, 7600, 26, 1249, 1077, 2575, 506, 282, 2649, 1059, 272, 687, 3242, 14, 1208, 14, 2975, 492, 370, 63, 2975, 272, 1249, 275, 370, 63, 2975, 8, 589, 12, 2222, 875, 534, 15534, 270, 6271, 85, 358, 339, 1511, 275, 1052, 272, 340, 1249, 365, 440, 488, 26, 267, 862, 26, 288, 373, 589, 275, 3715, 63, 589, 8, 589, 9, 267, 871, 1722, 465, 11199, 26, 288, 340, 283, 889, 11261, 25101, 7, 315, 620, 8, 432, 680, 2325, 837, 355, 746, 13358, 480, 705, 6057, 1423, 1059, 12, 862, 18593, 314, 8039, 1004, 2685, 288, 587, 26, 355, 746, 398, 3066, 63, 1162, 275, 942, 267, 367, 671, 315, 373, 589, 26, 288, 671, 275, 485, 2708, 63, 3765, 83, 8, 88, 9, 288, 340, 22250, 315, 671, 26, 355, 2086, 275, 378, 355, 862, 26, 490, 1830, 715, 26, 717, 2086, 275, 671, 14, 1080, 25283, 2086, 435, 413, 9, 717, 340, 2086, 690, 378, 436, 671, 59, 1712, 446, 413, 61, 1137, 29082, 1169, 2059, 355, 871, 1722, 26, 490, 327, 21471, 734, 402, 1059, 12, 1325, 781, 1471, 1172, 2005, 11077, 18527, 12, 490, 327, 880, 3350, 5204, 436, 5666, 642, 370, 314, 769, 402, 3066, 1862, 490, 3066, 63, 1162, 14, 740, 8, 88, 14, 1814, 11671, 4009, 26143, 1333, 490, 1980, 2234, 1022, 275, 671, 1491, 1712, 61, 355, 373, 275, 671, 59, 1712, 435, 413, 2938, 2234, 327, 1454, 5007, 2860, 883, 1343, 543, 376, 18888, 12, 880, 355, 327, 781, 2793, 1133, 2040, 4390, 370, 663, 3062, 4125, 89, 315, 2368, 355, 340, 1022, 14, 2460, 30018, 490, 746, 13358, 480, 3197, 2725, 2013, 26, 1543, 83, 4065, 450, 1022, 9, 2234, 327, 7600, 26, 1852, 314, 27157, 402, 642, 769, 402, 5218, 15, 1531, 355, 327, 263, 1511, 282, 805, 12, 880, 314, 769, 365, 18796, 1759, 355, 340, 1104, 63, 1773, 436, 1022, 440, 315, 661, 28219, 297, 283, 264, 4912, 297, 283, 8563, 297, 283, 5904, 297, 283, 4050, 735, 490, 3066, 63, 1162, 14, 740, 8, 88, 9, 355, 587, 26, 490, 1511, 59, 75, 14, 1913, 5106, 275, 14342, 8, 86, 14, 1913, 1012, 288, 587, 26, 355, 3066, 63, 1162, 14, 740, 8, 88, 9, 398, 327, 295, 13307, 314, 2867, 13, 964, 1862, 12, 340, 1263, 4898, 1911, 12, 436, 5090, 267, 327, 3062, 370, 282, 4539, 945, 367, 675, 2945, 701, 314, 5218, 15, 1531, 859, 267, 340, 822, 8, 1773, 63, 1162, 9, 690, 378, 26, 288, 1511, 59, 85, 26142, 1773, 63, 1162, 418, 275, 283, 1987, 904, 8, 1773, 63, 1162, 9, 339, 372, 1511, 199, 199, 318, 485, 362, 63, 3513, 63, 929, 8, 1418, 12, 6313, 63, 1560, 304, 272, 1449, 272, 314, 14850, 402, 642, 1853, 365, 370, 6705, 340, 314, 10999, 1059, 272, 365, 625, 18375, 315, 1314, 1930 ]
[ 334, 67, 9, 6927, 1603, 14015, 445, 455, 4584, 419, 12, 665, 74, 15176, 4584, 419, 32, 4853, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 295, 199, 646, 6010, 199, 199, 504, 3242, 14, 2550, 492, 13358, 199, 504, 3242, 14, 11059, 14, 25272, 492, 14342, 199, 199, 3, 22462, 24644, 26266, 687, 10717, 7866, 1159, 6385, 2348, 26, 199, 3, 1455, 921, 23153, 14, 957, 15, 16069, 15, 13314, 1717, 1355, 15, 1412, 13, 3765, 13, 13436, 13, 262, 13, 65, 13, 875, 13, 262, 13, 1548, 199, 63, 21377, 5901, 275, 6730, 65, 13, 13753, 13, 38, 16, 13, 25, 6616, 199, 63, 28879, 63, 16585, 63, 907, 275, 295, 14, 2014, 8, 82, 2344, 272, 334, 8522, 53, 91, 16, 93, 3698, 327, 1695, 13, 8573, 6318, 24644, 272, 1204, 8522, 85, 91, 17, 93, 3698, 327, 841, 13, 8573, 6318, 24644, 272, 1204, 8522, 88, 91, 18, 93, 3698, 327, 499, 13, 8573, 6318, 24644, 272, 1204, 8522, 46, 60, 3638, 4735, 4863, 24621, 4863, 221, 327, 6140, 4110, 701, 536, 272, 1204, 8522, 59, 1103, 4065, 371, 2324, 2591, 86, 61, 221, 327, 13050, 13, 10856, 24644, 272, 776, 891, 1370, 908, 1547, 21377, 5901, 10, 24, 12, 485, 21377, 5901, 10, 20, 12, 485, 21377, 5901, 10, 18, 395, 295, 14, 12819, 1204, 295, 14, 16075, 9, 199, 199, 318, 485, 2708, 63, 3765, 83, 8, 83, 304, 272, 347, 4849, 63, 1431, 8, 1431, 304, 267, 372, 6010, 14, 2708, 8, 1431, 14, 923, 8, 16, 395, 283, 2975, 13, 3765, 358, 339, 372, 485, 28879, 63, 16585, 63, 907, 14, 954, 8, 2708, 63, 1431, 12, 308, 9, 199, 199, 318, 2198, 63, 11475, 8, 589, 12, 1104, 63, 1773, 29, 797, 304, 272, 1449, 272, 7905, 282, 1059, 402, 790, 15, 585, 2974, 370, 282, 1211, 14, 982, 1263, 2867, 13, 964, 1862, 272, 787, 1911, 436, 314, 1104, 63, 1773, 945, 365, 663, 370, 715, 12, 2985, 911, 506, 3483, 272, 370, 282, 892, 2725, 2797, 2513, 1773, 63, 1162, 1370, 982, 1104, 63, 1773, 365, 440, 5223, 12, 272, 2985, 911, 9329, 506, 5525, 14, 272, 1449, 339, 6754, 7600, 26, 1249, 1077, 2575, 506, 282, 2649, 1059, 272, 687, 3242, 14, 1208, 14, 2975, 492, 370, 63, 2975, 272, 1249, 275, 370, 63, 2975, 8, 589, 12, 2222, 875, 534, 15534, 270, 6271, 85, 358, 339, 1511, 275, 1052, 272, 340, 1249, 365, 440, 488, 26, 267, 862, 26, 288, 373, 589, 275, 3715, 63, 589, 8, 589, 9, 267, 871, 1722, 465, 11199, 26, 288, 340, 283, 889, 11261, 25101, 7, 315, 620, 8, 432, 680, 2325, 837, 355, 746, 13358, 480, 705, 6057, 1423, 1059, 12, 862, 18593, 314, 8039, 1004, 2685, 288, 587, 26, 355, 746, 398, 3066, 63, 1162, 275, 942, 267, 367, 671, 315, 373, 589, 26, 288, 671, 275, 485, 2708, 63, 3765, 83, 8, 88, 9, 288, 340, 22250, 315, 671, 26, 355, 2086, 275, 378, 355, 862, 26, 490, 1830, 715, 26, 717, 2086, 275, 671, 14, 1080, 25283, 2086, 435, 413, 9, 717, 340, 2086, 690, 378, 436, 671, 59, 1712, 446, 413, 61, 1137, 29082, 1169, 2059, 355, 871, 1722, 26, 490, 327, 21471, 734, 402, 1059, 12, 1325, 781, 1471, 1172, 2005, 11077, 18527, 12, 490, 327, 880, 3350, 5204, 436, 5666, 642, 370, 314, 769, 402, 3066, 1862, 490, 3066, 63, 1162, 14, 740, 8, 88, 14, 1814, 11671, 4009, 26143, 1333, 490, 1980, 2234, 1022, 275, 671, 1491, 1712, 61, 355, 373, 275, 671, 59, 1712, 435, 413, 2938, 2234, 327, 1454, 5007, 2860, 883, 1343, 543, 376, 18888, 12, 880, 355, 327, 781, 2793, 1133, 2040, 4390, 370, 663, 3062, 4125, 89, 315, 2368, 355, 340, 1022, 14, 2460, 30018, 490, 746, 13358, 480, 3197, 2725, 2013, 26, 1543, 83, 4065, 450, 1022, 9, 2234, 327, 7600, 26, 1852, 314, 27157, 402, 642, 769, 402, 5218, 15, 1531, 355, 327, 263, 1511, 282, 805, 12, 880, 314, 769, 365, 18796, 1759, 355, 340, 1104, 63, 1773, 436, 1022, 440, 315, 661, 28219, 297, 283, 264, 4912, 297, 283, 8563, 297, 283, 5904, 297, 283, 4050, 735, 490, 3066, 63, 1162, 14, 740, 8, 88, 9, 355, 587, 26, 490, 1511, 59, 75, 14, 1913, 5106, 275, 14342, 8, 86, 14, 1913, 1012, 288, 587, 26, 355, 3066, 63, 1162, 14, 740, 8, 88, 9, 398, 327, 295, 13307, 314, 2867, 13, 964, 1862, 12, 340, 1263, 4898, 1911, 12, 436, 5090, 267, 327, 3062, 370, 282, 4539, 945, 367, 675, 2945, 701, 314, 5218, 15, 1531, 859, 267, 340, 822, 8, 1773, 63, 1162, 9, 690, 378, 26, 288, 1511, 59, 85, 26142, 1773, 63, 1162, 418, 275, 283, 1987, 904, 8, 1773, 63, 1162, 9, 339, 372, 1511, 199, 199, 318, 485, 362, 63, 3513, 63, 929, 8, 1418, 12, 6313, 63, 1560, 304, 272, 1449, 272, 314, 14850, 402, 642, 1853, 365, 370, 6705, 340, 314, 10999, 1059, 272, 365, 625, 18375, 315, 1314, 1930, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bssrikanth/virt-test
virttest/utils_conn.py
9
52295
""" connection tools to manage kinds of connection. """ import logging import os import shutil import tempfile import commands from autotest.client import utils, os_dep from virttest import propcan, remote, utils_libvirtd from virttest import data_dir, aexpect class ConnectionError(Exception): """ The base error in connection. """ pass class ConnForbiddenError(ConnectionError): """ Error in forbidden operation. """ def __init__(self, detail): ConnectionError.__init__(self) self.detail = detail def __str__(self): return ('Operation is forbidden.\n' 'Message: %s' % self.detail) class ConnCopyError(ConnectionError): """ Error in coping file. """ def __init__(self, src_path, dest_path): ConnectionError.__init__(self) self.src_path = src_path self.dest_path = dest_path def __str__(self): return ('Copy file from %s to %s failed.' % (self.src_path, self.dest_path)) class ConnNotImplementedError(ConnectionError): """ Error in calling unimplemented method """ def __init__(self, method_type, class_type): ConnectionError.__init__(self) self.method_type = method_type self.class_type = class_type def __str__(self): return ('Method %s is not implemented in class %s\n' % (self.method_type, self.class_type)) class ConnLoginError(ConnectionError): """ Error in login. """ def __init__(self, dest, detail): ConnectionError.__init__(self) self.dest = dest self.detail = detail def __str__(self): return ("Got a error when login to %s.\n" "Error: %s\n" % (self.dest, self.detail)) class ConnToolNotFoundError(ConnectionError): """ Error in not found tools. """ def __init__(self, tool, detail): ConnectionError.__init__(self) self.tool = tool self.detail = detail def __str__(self): return ("Got a error when access the tool (%s).\n" "Error: %s\n" % (self.tool, self.detail)) class ConnSCPError(ConnectionError): """ Error in SCP. """ def __init__(self, src_ip, src_path, dest_ip, dest_path, detail): ConnectionError.__init__(self) self.src_ip = src_ip self.src_path = src_path self.dest_ip = dest_ip self.dest_path = dest_path self.detail = detail def __str__(self): return ("Failed scp from %s on %s to %s on %s.\n" "error: %s.\n" % (self.src_path, self.src_ip, self.dest_path, self.dest_ip, self.detail)) class SSHCheckError(ConnectionError): """ Base Error in check of SSH connection. """ def __init__(self, server_ip, output): ConnectionError.__init__(self) self.server_ip = server_ip self.output = output def __str__(self): return ("SSH to %s failed.\n" "output: %s " % (self.server_ip, self.output)) class SSHRmAuthKeysError(ConnectionError): """ Error in removing authorized_keys file. """ def __init__(self, auth_keys, output): ConnectionError.__init__(self) self.auth_keys = auth_keys self.output = output def __str__(self): return ("Failed to remove authorized_keys file (%s).\n" "output: %s .\n" % (self.auth_keys, self.output)) class ConnCmdClientError(ConnectionError): """ Error in executing cmd on client. """ def __init__(self, cmd, output): ConnectionError.__init__(self) self.cmd = cmd self.output = output def __str__(self): return ("Execute command '%s' on client failed.\n" "output: %s" % (self.cmd, self.output)) class ConnPrivKeyError(ConnectionError): """ Error in building private key with certtool command. """ def __init__(self, key, output): ConnectionError.__init__(self) self.key = key self.output = output def __str__(self): return ("Failed to build private key file (%s).\n" "output: %s .\n" % (self.key, self.output)) class ConnCertError(ConnectionError): """ Error in building certificate file with certtool command. """ def __init__(self, cert, output): ConnectionError.__init__(self) self.cert = cert self.output = output def __str__(self): return ("Failed to build certificate file (%s).\n" "output: %s .\n" % (self.cert, self.output)) class ConnRmCertError(ConnectionError): """ Error in removing certificate file with rm command. """ def __init__(self, cert, output): ConnectionError.__init__(self) self.cert = cert self.output = output def __str__(self): return ("Failed to remove certificate file/path (%s).\n" "output: %s .\n" % (self.cert, self.output)) class ConnMkdirError(ConnectionError): """ Error in making directory. """ def __init__(self, directory, output): ConnectionError.__init__(self) self.directory = directory self.output = output def __str__(self): return ("Failed to make directory %s \n" "output: %s.\n" % (self.directory, self.output)) class ConnServerRestartError(ConnectionError): """ Error in restarting libvirtd on server. """ def __init__(self, output): ConnectionError.__init__(self) self.output = output def __str__(self): return ("Failed to restart libvirtd service on server.\n" "output: %s.\n" % (self.output)) class ConnectionBase(propcan.PropCanBase): """ Base class of a connection between server and client. Connection is build to from client to server. And there are some information for server and client in ConnectionBase. """ __slots__ = ('server_ip', 'server_user', 'server_pwd', 'client_ip', 'client_user', 'client_pwd', 'server_session', 'client_session', 'tmp_dir', 'auto_recover') def __init__(self, *args, **dargs): """ Initialize instance with server info and client info. :param server_ip: Ip of server. :param server_user: Username to login server. :param server_pwd: Password for server_user. :param client_ip: IP of client. :param client_user: Username to login client. :param client_pwd: Password for client_user. :param server_session: Session to server and execute command on server. :param client_session: Session to client and execute command on client. :param tmp_dir: A tmp dir to store some tmp file. :param auto_recover: If it is False same as the default, conn_recover() will not called by __del__() If it is True, Connection class will call conn_recover() in __del__(), then user need not call it manually. But the errors in conn_recover() will be ignored. Example: :: connection = ConnectionBase(server_ip=server_ip, server_user=server_user, server_pwd=server_pwd, client_ip=client_ip, client_user=client_user, client_pwd=client_pwd) connection.conn_setup() virsh.connect(URI) connection.conn_recover() We suggest *not* to pass auto_recover=True to __init__(), and call conn_recover() manually when you don't need this connection any more. """ init_dict = dict(*args, **dargs) init_dict['server_ip'] = init_dict.get('server_ip', 'SERVER.IP') init_dict['server_user'] = init_dict.get('server_user', 'root') init_dict['server_pwd'] = init_dict.get('server_pwd', None) init_dict['client_ip'] = init_dict.get('client_ip', 'CLIENT.IP') init_dict['client_user'] = init_dict.get('client_user', 'root') init_dict['client_pwd'] = init_dict.get('client_pwd', None) init_dict['auto_recover'] = init_dict.get('auto_recover', False) super(ConnectionBase, self).__init__(init_dict) self.__dict_set__('client_session', None) self.__dict_set__('server_session', None) # make a tmp dir as a workspace tmp_dir = tempfile.mkdtemp(dir=data_dir.get_tmp_dir()) if not os.path.isdir(tmp_dir): os.makedirs(tmp_dir) self.tmp_dir = tmp_dir def __del__(self): """ Clean up any leftover sessions and tmp_dir. """ self.close_session() if self.auto_recover: try: self.conn_recover() except ConnNotImplementedError: pass tmp_dir = self.tmp_dir if (tmp_dir is not None) and (os.path.exists(tmp_dir)): shutil.rmtree(tmp_dir) def close_session(self): """ If some session exists, close it down. """ session_list = ['client_session', 'server_session'] for session_name in session_list: session = self.__dict_get__(session_name) if session is not None: session.close() else: continue def conn_setup(self): """ waiting for implemented by subclass. """ raise ConnNotImplementedError('conn_setup', self.__class__) def conn_check(self): """ waiting for implemented by subclass. """ raise ConnNotImplementedError('conn_check', self.__class__) def conn_recover(self): """ waiting for implemented by subclass. """ raise ConnNotImplementedError('conn_recover', self.__class__) def _new_client_session(self): """ Build a new client session. """ transport = 'ssh' host = self.client_ip port = 22 username = self.client_user password = self.client_pwd prompt = r"[\#\$]\s*$" try: client_session = remote.wait_for_login(transport, host, port, username, password, prompt) except remote.LoginTimeoutError: raise ConnLoginError("Got a timeout error when login to client.") except remote.LoginAuthenticationError: raise ConnLoginError("Authentication failed to login to client.") except remote.LoginProcessTerminatedError: raise ConnLoginError("Host terminates during login to client.") except remote.LoginError: raise ConnLoginError("Some error occurs login to client failed.") return client_session def get_client_session(self): """ If the client session exists,return it. else create a session to client and set client_session. """ client_session = self.__dict_get__('client_session') if (client_session is not None) and (client_session.is_alive()): return client_session else: client_session = self._new_client_session() self.__dict_set__('client_session', client_session) return client_session def set_client_session(self, value): """ Set client session to value. """ if value: message = "Forbid to set client_session to %s." % value else: message = "Forbid to set client_session." raise ConnForbiddenError(message) def del_client_session(self): """ Delete client session. """ raise ConnForbiddenError('Forbid to del client_session') def _new_server_session(self): """ Build a new server session. """ transport = 'ssh' host = self.server_ip port = 22 username = self.server_user password = self.server_pwd prompt = r"[\#\$]\s*$" try: server_session = remote.wait_for_login(transport, host, port, username, password, prompt) except remote.LoginTimeoutError: raise ConnLoginError("Got a timeout error when login to server.") except remote.LoginAuthenticationError: raise ConnLoginError("Authentication failed to login to server.") except remote.LoginProcessTerminatedError: raise ConnLoginError("Host terminates during login to server.") except remote.LoginError: raise ConnLoginError("Some error occurs login to client server.") return server_session def get_server_session(self): """ If the server session exists,return it. else create a session to server and set server_session. """ server_session = self.__dict_get__('server_session') if (server_session is not None) and (server_session.is_alive()): return server_session else: server_session = self._new_server_session() self.__dict_set__('server_session', server_session) return server_session def set_server_session(self, value=None): """ Set server session to value. """ if value: message = "Forbid to set server_session to %s." % value else: message = "Forbid to set server_session." raise ConnForbiddenError(message) def del_server_session(self): """ Delete server session. """ raise ConnForbiddenError('Forbid to del server_session') class SSHConnection(ConnectionBase): """ Connection of SSH transport. Some specific variables in SSHConnection class. ssh_rsa_pub_path: Path of id_rsa.pub, default is /root/.ssh/id_rsa.pub. ssh_id_rsa_path: Path of id_rsa, default is /root/.ssh/id_rsa. SSH_KEYGEN, SSH_ADD, SSH_COPY_ID, SSH_AGENT, SHELL, SSH: tools to build a non-pwd connection. """ __slots__ = ('ssh_rsa_pub_path', 'ssh_id_rsa_path', 'SSH_KEYGEN', 'SSH_ADD', 'SSH_COPY_ID', 'SSH_AGENT', 'SHELL', 'SSH') def __init__(self, *args, **dargs): """ Initialization of SSH connection. (1). Call __init__ of class ConnectionBase. (2). Initialize tools will be used in conn setup. """ init_dict = dict(*args, **dargs) init_dict['ssh_rsa_pub_path'] = init_dict.get('ssh_rsa_pub_path', '/root/.ssh/id_rsa.pub') init_dict['ssh_id_rsa_path'] = init_dict.get('ssh_id_rsa_path', '/root/.ssh/id_rsa') super(SSHConnection, self).__init__(init_dict) # set the tool for ssh setup. tool_dict = {'SSH_KEYGEN': 'ssh-keygen', 'SSH_ADD': 'ssh-add', 'SSH_COPY_ID': 'ssh-copy-id', 'SSH_AGENT': 'ssh-agent', 'SHELL': 'sh', 'SSH': 'ssh'} for key in tool_dict: toolName = tool_dict[key] try: tool = os_dep.command(toolName) except ValueError: logging.debug("%s executable not set or found on path," "some function of connection will fail.", toolName) tool = '/bin/true' self.__dict_set__(key, tool) def conn_check(self): """ Check the SSH connection. (1).Initialize some variables. (2).execute ssh command to check conn. """ client_session = self.client_session server_user = self.server_user server_ip = self.server_ip ssh = self.SSH if ssh is '/bin/true': raise ConnToolNotFoundError('ssh', "executable not set or found on path, ") cmd = "%s %s@%s exit 0" % (ssh, server_user, server_ip) try: client_session.cmd(cmd, timeout=5) except aexpect.ShellError, detail: client_session.close() raise SSHCheckError(server_ip, detail) logging.debug("Check the SSH to %s OK.", server_ip) def conn_recover(self): """ Clean up authentication host. """ # initialize variables server_ip = self.server_ip server_user = self.server_user server_pwd = self.server_pwd client_ip = self.client_ip ssh_authorized_keys_path = '/root/.ssh/authorized_keys' cmd = "rm -rf %s" % ssh_authorized_keys_path server_session = remote.wait_for_login('ssh', server_ip, '22', server_user, server_pwd, r"[\#\$]\s*$") # remove authentication file status, output = server_session.cmd_status_output(cmd) if status: raise SSHRmAuthKeysError(ssh_authorized_keys_path, output) # restart libvirtd service on server try: libvirtd_service = utils_libvirtd.Libvirtd(session=server_session) libvirtd_service.restart() server_session.close() except (remote.LoginError, aexpect.ShellError), detail: server_session.close() raise ConnServerRestartError(detail) logging.debug("SSH authentication recover successfully.") def conn_setup(self): """ Setup of SSH connection. (1).Initialization of some variables. (2).Check tools. (3).Initialization of id_rsa. (4).set a ssh_agent. (5).copy pub key to server. """ client_session = self.client_session ssh_rsa_pub_path = self.ssh_rsa_pub_path ssh_id_rsa_path = self.ssh_id_rsa_path server_user = self.server_user server_ip = self.server_ip server_pwd = self.server_pwd ssh_keygen = self.SSH_KEYGEN ssh_add = self.SSH_ADD ssh_copy_id = self.SSH_COPY_ID ssh_agent = self.SSH_AGENT shell = self.SHELL tool_dict = {'ssh_keygen': ssh_keygen, 'ssh_add': ssh_add, 'ssh_copy_id': ssh_copy_id, 'ssh_agent': ssh_agent, 'shell': shell} for tool_name in tool_dict: tool = tool_dict[tool_name] if tool is '/bin/true': raise ConnToolNotFoundError(tool_name, "executable not set or found on path,") if os.path.exists("/root/.ssh/id_rsa"): pass else: cmd = "%s -t rsa -f /root/.ssh/id_rsa -N '' " % (ssh_keygen) status, output = client_session.cmd_status_output(cmd) if status: raise ConnCmdClientError(cmd, output) cmd = "%s %s" % (ssh_agent, shell) status, output = client_session.cmd_status_output(cmd) if status: raise ConnCmdClientError(cmd, output) cmd = "%s %s" % (ssh_add, ssh_id_rsa_path) status, output = client_session.cmd_status_output(cmd) if status: raise ConnCmdClientError(cmd, output) cmd = "%s -i %s %s@%s" % (ssh_copy_id, ssh_rsa_pub_path, server_user, server_ip) client_session.sendline(cmd) try: remote.handle_prompts(client_session, server_user, server_pwd, prompt=r"[\#\$]\s*$") except remote.LoginError, detail: raise ConnCmdClientError(cmd, detail) client_session.close() logging.debug("SSH connection setup successfully.") class TCPConnection(ConnectionBase): """ Connection class for TCP transport. Some specific variables for TCPConnection class. """ __slots__ = ('tcp_port', 'remote_syslibvirtd', 'remote_libvirtdconf', 'sasl_allowed_users', 'auth_tcp', 'listen_addr') def __init__(self, *args, **dargs): """ init params for TCP connection and init tmp_dir. :param tcp_port: Port of tcp connection, default is 16509. :param sysconfig_libvirtd_path: Path of libvirtd file, default is ``/etc/sysconfig/libvirtd``. :param libvirtd_conf_path: Path of libvirtd.conf, default is ``/etc/libvirt/libvirtd.conf``. """ init_dict = dict(*args, **dargs) init_dict['tcp_port'] = init_dict.get('tcp_port', '16509') init_dict['auth_tcp'] = init_dict.get('auth_tcp', 'none') init_dict['listen_addr'] = init_dict.get('listen_addr') init_dict['sasl_allowed_users'] = init_dict.get('sasl_allowed_users') super(TCPConnection, self).__init__(init_dict) self.remote_syslibvirtd = remote.RemoteFile( address=self.server_ip, client='scp', username=self.server_user, password=self.server_pwd, port='22', remote_path='/etc/sysconfig/libvirtd') self.remote_libvirtdconf = remote.RemoteFile( address=self.server_ip, client='scp', username=self.server_user, password=self.server_pwd, port='22', remote_path='/etc/libvirt/libvirtd.conf') def conn_recover(self): """ Clean up for TCP connection. (1).initialize variables. (2).Delete the RemoteFile. (3).restart libvirtd on server. """ # initialize variables server_ip = self.server_ip server_user = self.server_user server_pwd = self.server_pwd # delete the RemoteFile object to recover remote file. del self.remote_syslibvirtd del self.remote_libvirtdconf # restart libvirtd service on server try: session = remote.wait_for_login('ssh', server_ip, '22', server_user, server_pwd, r"[\#\$]\s*$") libvirtd_service = utils_libvirtd.Libvirtd(session=session) libvirtd_service.restart() except (remote.LoginError, aexpect.ShellError), detail: raise ConnServerRestartError(detail) logging.debug("TCP connection recover successfully.") def conn_setup(self): """ Enable tcp connect of libvirtd on server. (1).initialization for variables. (2).edit /etc/sysconfig/libvirtd on server. (3).edit /etc/libvirt/libvirtd.conf on server. (4).restart libvirtd service on server. """ # initialize variables server_ip = self.server_ip server_user = self.server_user server_pwd = self.server_pwd tcp_port = self.tcp_port auth_tcp = self.auth_tcp # require a list data type sasl_allowed_users = self.sasl_allowed_users listen_addr = self.listen_addr # edit the /etc/sysconfig/libvirtd to add --listen args in libvirtd pattern2repl = {r".*LIBVIRTD_ARGS\s*=\s*\"\s*--listen\s*\".*": "LIBVIRTD_ARGS=\"--listen\""} self.remote_syslibvirtd.sub_else_add(pattern2repl) # edit the /etc/libvirt/libvirtd.conf # listen_tcp=1, tcp_port=$tcp_port, auth_tcp="none" # listen_tcp=1, tcp_port=$tcp_port, auth_tcp=$auth_tcp pattern2repl = {r".*listen_tls\s*=.*": 'listen_tls=0', r".*listen_tcp\s*=.*": 'listen_tcp=1', r".*tcp_port\s*=.*": 'tcp_port="%s"' % (tcp_port), r".*auth_tcp\s*=.*": 'auth_tcp="%s"' % (auth_tcp)} # a whitelist of allowed SASL usernames, it's a list. # If the list is an empty, no client can connect if sasl_allowed_users: pattern2repl[r".*sasl_allowed_username_list\s*=.*"] = \ 'sasl_allowed_username_list=%s' % (sasl_allowed_users) if listen_addr: pattern2repl[r".*listen_addr\s*=.*"] = \ "listen_addr='%s'" % (listen_addr) self.remote_libvirtdconf.sub_else_add(pattern2repl) # restart libvirtd service on server try: session = remote.wait_for_login('ssh', server_ip, '22', server_user, server_pwd, r"[\#\$]\s*$") libvirtd_service = utils_libvirtd.Libvirtd(session=session) libvirtd_service.restart() except (remote.LoginError, aexpect.ShellError), detail: raise ConnServerRestartError(detail) logging.debug("TCP connection setup successfully.") class TLSConnection(ConnectionBase): """ Connection of TLS transport. Some specific variables for TLSConnection class. server_cn, client_cn, ca_cn: Info to build pki key. CERTOOL: tool to build key for TLS connection. pki_CA_dir: Dir to store CA key. libvirt_pki_dir, libvirt_pki_private_dir: Dir to store pki in libvirt. sysconfig_libvirtd_path, libvirtd_conf_path: Path of libvirt config file. hosts_path: /etc/hosts auth_tls, tls_port, listen_addr: custom TLS Auth, port and listen address tls_allowed_dn_list: DN's list are checked tls_verify_cert: disable verification, default is to always verify tls_sanity_cert: disable checks, default is to always run sanity checks custom_pki_path: custom pki path ca_cakey_path: CA certification path, sometimes need to reuse previous cert scp_new_cacert: copy new CA certification, default is to always copy restart_libvirtd: default is to restart libvirtd """ __slots__ = ('server_cn', 'client_cn', 'ca_cn', 'CERTTOOL', 'pki_CA_dir', 'libvirt_pki_dir', 'libvirt_pki_private_dir', 'client_hosts', 'server_libvirtdconf', 'server_syslibvirtd', 'auth_tls', 'tls_port', 'listen_addr', 'tls_allowed_dn_list', 'custom_pki_path', 'tls_verify_cert', 'tls_sanity_cert', 'ca_cakey_path', 'scp_new_cacert', 'restart_libvirtd') def __init__(self, *args, **dargs): """ Initialization of TLSConnection. (1).call the init func in ConnectionBase. (2).check and set CERTTOOL. (3).make a tmp directory as a workspace. (4).set values of pki related. """ init_dict = dict(*args, **dargs) init_dict['server_cn'] = init_dict.get('server_cn', 'TLSServer') init_dict['client_cn'] = init_dict.get('client_cn', 'TLSClient') init_dict['ca_cn'] = init_dict.get('ca_cn', 'AUTOTEST.VIRT') init_dict['ca_cakey_path'] = init_dict.get('ca_cakey_path', None) init_dict['auth_tls'] = init_dict.get('auth_tls', 'none') init_dict['tls_port'] = init_dict.get('tls_port', '16514') init_dict['listen_addr'] = init_dict.get('listen_addr') init_dict['custom_pki_path'] = init_dict.get('custom_pki_path') init_dict['tls_verify_cert'] = init_dict.get('tls_verify_cert', 'yes') init_dict['tls_sanity_cert'] = init_dict.get('tls_sanity_cert', 'yes') init_dict['tls_allowed_dn_list'] = init_dict.get('tls_allowed_dn_list') init_dict['scp_new_cacert'] = init_dict.get('scp_new_cacert', 'yes') init_dict['restart_libvirtd'] = init_dict.get('restart_libvirtd', 'yes') super(TLSConnection, self).__init__(init_dict) # check and set CERTTOOL in slots try: CERTTOOL = os_dep.command("certtool") except ValueError: logging.warning("certtool executable not set or found on path, " "TLS connection will not setup normally") CERTTOOL = '/bin/true' self.CERTTOOL = CERTTOOL # set some pki related dir values if not self.custom_pki_path: self.pki_CA_dir = ('/etc/pki/CA/') self.libvirt_pki_dir = ('/etc/pki/libvirt/') self.libvirt_pki_private_dir = ('/etc/pki/libvirt/private/') else: # set custom certifications path dir_dict = {'CA': 'pki_CA_dir', 'libvirt': 'libvirt_pki_dir', 'libvirt/private': 'libvirt_pki_private_dir'} if not os.path.exists(self.custom_pki_path): os.makedirs(self.custom_pki_path) for dir_name in dir_dict: setattr(self, dir_dict[dir_name], self.custom_pki_path) self.client_hosts = remote.RemoteFile(address=self.client_ip, client='scp', username=self.client_user, password=self.client_pwd, port='22', remote_path='/etc/hosts') self.server_syslibvirtd = remote.RemoteFile( address=self.server_ip, client='scp', username=self.server_user, password=self.server_pwd, port='22', remote_path='/etc/sysconfig/libvirtd') self.server_libvirtdconf = remote.RemoteFile( address=self.server_ip, client='scp', username=self.server_user, password=self.server_pwd, port='22', remote_path='/etc/libvirt/libvirtd.conf') def conn_recover(self): """ Do the clean up work. (1).initialize variables. (2).Delete remote file. (3).Restart libvirtd on server. """ # clean up certifications firstly if self.auto_recover: self.cert_recover() # initialize variables server_ip = self.server_ip server_user = self.server_user server_pwd = self.server_pwd del self.client_hosts del self.server_syslibvirtd del self.server_libvirtdconf # restart libvirtd service on server try: session = remote.wait_for_login('ssh', server_ip, '22', server_user, server_pwd, r"[\#\$]\s*$") libvirtd_service = utils_libvirtd.Libvirtd(session=session) libvirtd_service.restart() except (remote.LoginError, aexpect.ShellError), detail: raise ConnServerRestartError(detail) logging.debug("TLS connection recover successfully.") def cert_recover(self): """ Do the clean up certifications work. (1).initialize variables. (2).Delete local and remote generated certifications file. """ # initialize variables server_ip = self.server_ip server_user = self.server_user server_pwd = self.server_pwd cert_dict = {'CA': '%s*' % self.pki_CA_dir, 'cert': self.libvirt_pki_dir, 'key': self.libvirt_pki_private_dir} # remove local generated certifications file for cert in cert_dict: cert_path = cert_dict[cert] cmd = "rm -rf %s" % cert_path if os.path.exists(cert_path): shutil.rmtree(cert_path) else: status, output = commands.getstatusoutput(cmd) if status: raise ConnRmCertError(cert_path, output) # remove remote generated certifications file server_session = remote.wait_for_login('ssh', server_ip, '22', server_user, server_pwd, r"[\#\$]\s*$") for cert in cert_dict: cert_path = cert_dict[cert] cmd = "rm -rf %s" % cert_path status, output = server_session.cmd_status_output(cmd) if status: raise ConnRmCertError(cert_path, output) server_session.close() logging.debug("TLS certifications recover successfully.") def conn_setup(self, server_setup=True, client_setup=True): """ setup a TLS connection between server and client. At first check the certtool needed to setup. Then call some setup functions to complete connection setup. """ if self.CERTTOOL == '/bin/true': raise ConnToolNotFoundError('certtool', "certtool executable not set or found on path.") # support build multiple CAs with different CA CN build_CA(self.tmp_dir, self.ca_cn, self.ca_cakey_path, self.CERTTOOL) # not always need to setup CA, client and server together if server_setup: self.server_setup() if client_setup: self.client_setup() self.close_session() logging.debug("TLS connection setup successfully.") def server_setup(self): """ setup private key and certificate file for server. (1).initialization for variables. (2).build server key. (3).copy files to server. (4).edit /etc/sysconfig/libvirtd on server. (5).edit /etc/libvirt/libvirtd.conf on server. (6).restart libvirtd service on server. """ # initialize variables tmp_dir = self.tmp_dir scp_new_cacert = self.scp_new_cacert # sometimes, need to reuse previous CA cert if self.ca_cakey_path and scp_new_cacert == 'no': cacert_path = '%s/cacert.pem' % self.ca_cakey_path else: cacert_path = '%s/cacert.pem' % tmp_dir serverkey_path = '%s/serverkey.pem' % tmp_dir servercert_path = '%s/servercert.pem' % tmp_dir server_ip = self.server_ip server_user = self.server_user server_pwd = self.server_pwd auth_tls = self.auth_tls tls_port = self.tls_port listen_addr = self.listen_addr restart_libvirtd = self.restart_libvirtd tls_allowed_dn_list = self.tls_allowed_dn_list pki_path = self.custom_pki_path tls_verify_cert = self.tls_verify_cert tls_sanity_cert = self.tls_sanity_cert # build a server key. build_server_key(tmp_dir, self.ca_cakey_path, self.server_cn, self.CERTTOOL) # scp cacert.pem, servercert.pem and serverkey.pem to server. server_session = self.server_session cmd = "mkdir -p %s" % self.libvirt_pki_private_dir status, output = server_session.cmd_status_output(cmd) if status: raise ConnMkdirError(self.libvirt_pki_private_dir, output) scp_dict = {cacert_path: self.pki_CA_dir, servercert_path: self.libvirt_pki_dir, serverkey_path: self.libvirt_pki_private_dir} for key in scp_dict: local_path = key remote_path = scp_dict[key] try: remote.copy_files_to(server_ip, 'scp', server_user, server_pwd, '22', local_path, remote_path) except remote.SCPError, detail: raise ConnSCPError('AdminHost', local_path, server_ip, remote_path, detail) # edit the /etc/sysconfig/libvirtd to add --listen args in libvirtd pattern2repl = {r".*LIBVIRTD_ARGS\s*=\s*\"\s*--listen\s*\".*": "LIBVIRTD_ARGS=\"--listen\""} self.server_syslibvirtd.sub_else_add(pattern2repl) # edit the /etc/libvirt/libvirtd.conf to add listen_tls=1 pattern2repl = {r".*listen_tls\s*=\s*.*": "listen_tls=1"} self.server_libvirtdconf.sub_else_add(pattern2repl) # edit the /etc/libvirt/libvirtd.conf to add # listen_addr=$listen_addr if listen_addr: pattern2repl[r".*listen_addr\s*=.*"] = \ "listen_addr='%s'" % (listen_addr) self.server_libvirtdconf.sub_else_add(pattern2repl) # edit the /etc/libvirt/libvirtd.conf to add auth_tls=$auth_tls if auth_tls != 'none': pattern2repl = {r".*auth_tls\s*=\s*.*": 'auth_tls="%s"' % auth_tls} self.server_libvirtdconf.sub_else_add(pattern2repl) # edit the /etc/libvirt/libvirtd.conf to add tls_port=$tls_port if tls_port != '16514': pattern2repl = {r".*tls_port\s*=\s*.*": 'tls_port="%s"' % tls_port} self.server_libvirtdconf.sub_else_add(pattern2repl) # edit the /etc/libvirt/libvirtd.conf to add # tls_allowed_dn_list=$tls_allowed_dn_list if isinstance(tls_allowed_dn_list, list): pattern2repl = {r".*tls_allowed_dn_list\s*=\s*.*": 'tls_allowed_dn_list=%s' % tls_allowed_dn_list} self.server_libvirtdconf.sub_else_add(pattern2repl) # edit the /etc/libvirt/libvirtd.conf to override # the default server certification file path if pki_path: cert_path_dict = {'ca_file': cacert_path, 'key_file': serverkey_path, 'cert_file': servercert_path} pattern2repl = {} for cert_name in cert_path_dict: cert_file = os.path.basename(cert_path_dict[cert_name]) abs_cert_file = os.path.join(pki_path, cert_file) pattern2repl[r".*%s\s*=.*" % (cert_name)] = \ '%s="%s"' % (cert_name, abs_cert_file) self.server_libvirtdconf.sub_else_add(pattern2repl) # edit the /etc/libvirt/libvirtd.conf to disable client verification if tls_verify_cert == "no": pattern2repl = {r".*tls_no_verify_certificate\s*=\s*.*": 'tls_no_verify_certificate=1'} self.server_libvirtdconf.sub_else_add(pattern2repl) # edit the /etc/libvirt/libvirtd.conf to disable server sanity checks if tls_sanity_cert == "no": pattern2repl = {r".*tls_no_sanity_certificate\s*=\s*.*": 'tls_no_sanity_certificate=1'} self.server_libvirtdconf.sub_else_add(pattern2repl) # restart libvirtd service on server if restart_libvirtd == "yes": try: session = remote.wait_for_login('ssh', server_ip, '22', server_user, server_pwd, r"[\#\$]\s*$") libvirtd_service = utils_libvirtd.Libvirtd(session=session) libvirtd_service.restart() except (remote.LoginError, aexpect.ShellError), detail: raise ConnServerRestartError(detail) def client_setup(self): """ setup private key and certificate file for client. (1).initialization for variables. (2).build a key for client. (3).copy files to client. (4).edit /etc/hosts on client. """ # initialize variables tmp_dir = self.tmp_dir cacert_path = '%s/cacert.pem' % tmp_dir clientkey_path = '%s/clientkey.pem' % tmp_dir clientcert_path = '%s/clientcert.pem' % tmp_dir client_ip = self.client_ip client_user = self.client_user client_pwd = self.client_pwd # build a client key. build_client_key(tmp_dir, self.client_cn, self.CERTTOOL) # scp cacert.pem, clientcert.pem and clientkey.pem to client. client_session = self.client_session cmd = "mkdir -p %s" % self.libvirt_pki_private_dir status, output = client_session.cmd_status_output(cmd) if status: raise ConnMkdirError(self.libvirt_pki_private_dir, output) scp_dict = {cacert_path: self.pki_CA_dir, clientcert_path: self.libvirt_pki_dir, clientkey_path: self.libvirt_pki_private_dir} for key in scp_dict: local_path = key remote_path = scp_dict[key] try: remote.copy_files_to(client_ip, 'scp', client_user, client_pwd, '22', local_path, remote_path) except remote.SCPError, detail: raise ConnSCPError('AdminHost', local_path, client_ip, remote_path, detail) # edit /etc/hosts on client pattern2repl = {r".*%s.*" % self.server_cn: "%s %s" % (self.server_ip, self.server_cn)} self.client_hosts.sub_else_add(pattern2repl) def build_client_key(tmp_dir, client_cn="TLSClient", certtool="certtool"): """ (1).initialization for variables. (2).make a private key with certtool command. (3).prepare a info file. (4).make a certificate file with certtool command. """ # Initialize variables cakey_path = '%s/cakey.pem' % tmp_dir cacert_path = '%s/cacert.pem' % tmp_dir clientkey_path = '%s/clientkey.pem' % tmp_dir clientcert_path = '%s/clientcert.pem' % tmp_dir clientinfo_path = '%s/client.info' % tmp_dir # make a private key. cmd = "%s --generate-privkey > %s" % (certtool, clientkey_path) CmdResult = utils.run(cmd, ignore_status=True) if CmdResult.exit_status: raise ConnPrivKeyError(CmdResult.stderr) # prepare a info file to build clientcert. clientinfo_file = open(clientinfo_path, "w") clientinfo_file.write("organization = AUTOTEST.VIRT\n") clientinfo_file.write("cn = %s\n" % (client_cn)) clientinfo_file.write("tls_www_client\n") clientinfo_file.write("encryption_key\n") clientinfo_file.write("signing_key\n") clientinfo_file.close() # make a client certificate file and a client key file. cmd = ("%s --generate-certificate --load-privkey %s \ --load-ca-certificate %s --load-ca-privkey %s \ --template %s --outfile %s" % (certtool, clientkey_path, cacert_path, cakey_path, clientinfo_path, clientcert_path)) CmdResult = utils.run(cmd, ignore_status=True) if CmdResult.exit_status: raise ConnCertError(clientinfo_path, CmdResult.stderr) def build_server_key(tmp_dir, ca_cakey_path=None, server_cn="TLSServer", certtool="certtool"): """ (1).initialization for variables. (2).make a private key with certtool command. (3).prepare a info file. (4).make a certificate file with certtool command. """ # initialize variables # sometimes, need to reuse previous CA cert if not ca_cakey_path: cakey_path = '%s/cakey.pem' % tmp_dir else: cakey_path = '%s/cakey.pem' % ca_cakey_path serverkey_path = '%s/serverkey.pem' % tmp_dir cacert_path = '%s/cacert.pem' % tmp_dir servercert_path = '%s/servercert.pem' % tmp_dir serverinfo_path = '%s/server.info' % tmp_dir # make a private key cmd = "%s --generate-privkey > %s" % (certtool, serverkey_path) cmd_result = utils.run(cmd, ignore_status=True) if cmd_result.exit_status: raise ConnPrivKeyError(serverkey_path, cmd_result.stderr) # prepare a info file to build servercert and serverkey serverinfo_file = open(serverinfo_path, "w") serverinfo_file.write("organization = AUTOTEST.VIRT\n") serverinfo_file.write("cn = %s\n" % (server_cn)) serverinfo_file.write("tls_www_server\n") serverinfo_file.write("encryption_key\n") serverinfo_file.write("signing_key\n") serverinfo_file.close() # make a server certificate file and a server key file cmd = ("%s --generate-certificate --load-privkey %s \ --load-ca-certificate %s --load-ca-privkey %s \ --template %s --outfile %s" % (certtool, serverkey_path, cacert_path, cakey_path, serverinfo_path, servercert_path)) CmdResult = utils.run(cmd, ignore_status=True) if CmdResult.exit_status: raise ConnCertError(serverinfo_path, CmdResult.stderr) def build_CA(tmp_dir, cn="AUTOTEST.VIRT", ca_cakey_path=None, certtool="certtool"): """ setup private key and certificate file which are needed to build. certificate file for client and server. (1).initialization for variables. (2).make a private key with certtool command. (3).prepare a info file. (4).make a certificate file with certtool command. """ # initialize variables if not ca_cakey_path: cakey_path = '%s/cakey.pem' % tmp_dir else: cakey_path = '%s/cakey.pem' % ca_cakey_path cainfo_path = '%s/ca.info' % tmp_dir cacert_path = '%s/cacert.pem' % tmp_dir # make a private key # sometimes, may reuse previous CA cert, so don't always need to # generate private key if not ca_cakey_path: cmd = "%s --generate-privkey > %s " % (certtool, cakey_path) cmd_result = utils.run(cmd, ignore_status=True, timeout=10) if cmd_result.exit_status: raise ConnPrivKeyError(cakey_path, cmd_result.stderr) # prepare a info file to build certificate file cainfo_file = open(cainfo_path, "w") cainfo_file.write("cn = %s\n" % cn) cainfo_file.write("ca\n") cainfo_file.write("cert_signing_key\n") cainfo_file.close() # make a certificate file to build clientcert and servercert cmd = ("%s --generate-self-signed --load-privkey %s\ --template %s --outfile %s" % (certtool, cakey_path, cainfo_path, cacert_path)) CmdResult = utils.run(cmd, ignore_status=True) if CmdResult.exit_status: raise ConnCertError(cainfo_path, CmdResult.stderr) class UNIXConnection(ConnectionBase): """ Connection class for UNIX transport. Some specific variables for UNIXConnection class. """ __slots__ = ('auth_unix_ro', 'auth_unix_rw', 'unix_sock_dir', 'unix_sock_group', 'unix_sock_ro_perms', 'unix_sock_rw_perms', 'access_drivers', 'client_ip', 'client_user', 'client_pwd', 'client_libvirtdconf', 'restart_libvirtd') def __init__(self, *args, **dargs): """ init params for UNIX connection. :param auth_unix_ro: UNIX R/O sockets, default is 'none'. :param auth_unix_rw: UNIX R/W sockets, default is 'none'. :param unix_sock_group: UNIX domain socket group ownership, default is 'libvirt'. :param access_drivers: access control restrictions, default is '["polkit"]'. :param unix_sock_ro_perms: UNIX socket permissions for the R/O socket, default is '0777'. :param unix_sock_rw_perms: UNIX socket permissions for the R/W socket, default is '0770'. :param client_libvirtdconf: Path of client libvirtd.conf, default is '/etc/libvirt/libvirtd.conf'. :param restart_libvirtd: default is to restart libvirtd. """ init_dict = dict(*args, **dargs) init_dict['auth_unix_ro'] = init_dict.get('auth_unix_ro', 'none') init_dict['auth_unix_rw'] = init_dict.get('auth_unix_rw', 'none') init_dict['unix_sock_dir'] = init_dict.get('unix_sock_dir', '/var/run/libvirt') init_dict['unix_sock_group'] = init_dict.get('unix_sock_group', 'libvirt') init_dict['access_drivers'] = init_dict.get('access_drivers', ["polkit"]) init_dict['unix_sock_ro_perms'] = init_dict.get('unix_sock_ro_perms', '0777') init_dict['unix_sock_rw_perms'] = init_dict.get('unix_sock_rw_perms', '0770') init_dict['restart_libvirtd'] = init_dict.get('restart_libvirtd', 'yes') super(UNIXConnection, self).__init__(init_dict) self.client_libvirtdconf = remote.RemoteFile( address=self.client_ip, client='scp', username=self.client_user, password=self.client_pwd, port='22', remote_path='/etc/libvirt/libvirtd.conf') def conn_recover(self): """ Do the clean up work. (1).Delete remote file. (2).Restart libvirtd on server. """ del self.client_libvirtdconf # restart libvirtd service on server client_session = self.client_session try: libvirtd_service = utils_libvirtd.Libvirtd(session=client_session) libvirtd_service.restart() except (remote.LoginError, aexpect.ShellError), detail: raise ConnServerRestartError(detail) logging.debug("UNIX connection recover successfully.") def conn_setup(self): """ Setup a UNIX connection. (1).Initialize variables. (2).Update libvirtd.conf configuration. (3).Restart libvirtd on client. """ # initialize variables auth_unix_ro = self.auth_unix_ro auth_unix_rw = self.auth_unix_rw unix_sock_group = self.unix_sock_group unix_sock_dir = self.unix_sock_dir unix_sock_ro_perms = self.unix_sock_ro_perms unix_sock_rw_perms = self.unix_sock_rw_perms access_drivers = self.access_drivers restart_libvirtd = self.restart_libvirtd client_session = self.client_session # edit the /etc/libvirt/libvirtd.conf to add auth_unix_ro arg if auth_unix_ro: pattern2repl = {r".*auth_unix_ro\s*=.*": 'auth_unix_ro="%s"' % auth_unix_ro} self.client_libvirtdconf.sub_else_add(pattern2repl) # edit the /etc/libvirt/libvirtd.conf to add auth_unix_rw arg if auth_unix_rw: pattern2repl = {r".*auth_unix_rw\s*=.*": 'auth_unix_rw="%s"' % auth_unix_rw} self.client_libvirtdconf.sub_else_add(pattern2repl) # edit the /etc/libvirt/libvirtd.conf to add unix_sock_group arg if unix_sock_group != 'libvirt': pattern2repl = {r".*unix_sock_group\s*=.*": 'unix_sock_group="%s"' % unix_sock_group} self.client_libvirtdconf.sub_else_add(pattern2repl) # edit the /etc/libvirt/libvirtd.conf to add unix_sock_dir arg if unix_sock_dir != '/var/run/libvirt': pattern2repl = {r".*unix_sock_dir\s*=.*": 'unix_sock_dir="%s"' % unix_sock_dir} self.client_libvirtdconf.sub_else_add(pattern2repl) # edit the /etc/libvirt/libvirtd.conf to add access_drivers arg if access_drivers != ["polkit"]: pattern2repl = {r".*access_drivers\s*=.*": 'access_drivers="%s"' % access_drivers} self.client_libvirtdconf.sub_else_add(pattern2repl) # edit the /etc/libvirt/libvirtd.conf to add unix_sock_ro_perms arg if unix_sock_ro_perms: pattern2repl = {r".*unix_sock_ro_perms\s*=.*": 'unix_sock_ro_perms="%s"' % unix_sock_ro_perms} self.client_libvirtdconf.sub_else_add(pattern2repl) # edit the /etc/libvirt/libvirtd.conf to add unix_sock_rw_perms arg if unix_sock_rw_perms: pattern2repl = {r".*unix_sock_rw_perms\s*=.*": 'unix_sock_rw_perms="%s"' % unix_sock_rw_perms} self.client_libvirtdconf.sub_else_add(pattern2repl) # restart libvirtd service on server if restart_libvirtd == "yes": try: libvirtd_service = utils_libvirtd.Libvirtd(session=client_session) libvirtd_service.restart() except (remote.LoginError, aexpect.ShellError), detail: raise ConnServerRestartError(detail) logging.debug("UNIX connection setup successfully.")
gpl-2.0
[ 624, 199, 2105, 7249, 370, 9635, 24241, 402, 1950, 14, 199, 624, 199, 199, 646, 2050, 199, 646, 747, 199, 646, 5145, 199, 646, 5549, 199, 646, 3718, 199, 199, 504, 2599, 396, 14, 1258, 492, 3778, 12, 747, 63, 2601, 199, 504, 12043, 396, 492, 557, 2352, 290, 12, 3982, 12, 3778, 63, 773, 1042, 2076, 199, 504, 12043, 396, 492, 666, 63, 694, 12, 282, 4921, 421, 199, 533, 25417, 8, 1726, 304, 339, 408, 272, 710, 1300, 1125, 315, 1950, 14, 272, 408, 272, 986, 421, 199, 533, 13482, 17454, 547, 8, 20349, 304, 339, 408, 272, 4520, 315, 24786, 3439, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 10093, 304, 267, 25417, 855, 826, 721, 277, 9, 267, 291, 14, 5506, 275, 10093, 339, 347, 636, 495, 721, 277, 304, 267, 372, 661, 6044, 365, 24786, 3134, 78, 7, 355, 283, 2209, 26, 450, 83, 7, 450, 291, 14, 5506, 9, 421, 199, 533, 13482, 5116, 547, 8, 20349, 304, 339, 408, 272, 4520, 315, 4870, 316, 570, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2928, 63, 515, 12, 2053, 63, 515, 304, 267, 25417, 855, 826, 721, 277, 9, 267, 291, 14, 2164, 63, 515, 275, 2928, 63, 515, 267, 291, 14, 2614, 63, 515, 275, 2053, 63, 515, 339, 347, 636, 495, 721, 277, 304, 267, 372, 661, 5116, 570, 687, 450, 83, 370, 450, 83, 3405, 3530, 355, 450, 334, 277, 14, 2164, 63, 515, 12, 291, 14, 2614, 63, 515, 430, 421, 199, 533, 13482, 18097, 8, 20349, 304, 339, 408, 272, 4520, 315, 6358, 625, 13825, 1083, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1083, 63, 466, 12, 1021, 63, 466, 304, 267, 25417, 855, 826, 721, 277, 9, 267, 291, 14, 765, 63, 466, 275, 1083, 63, 466, 267, 291, 14, 533, 63, 466, 275, 1021, 63, 466, 339, 347, 636, 495, 721, 277, 304, 267, 372, 661, 3767, 450, 83, 365, 440, 6366, 315, 1021, 450, 83, 60, 78, 7, 355, 450, 334, 277, 14, 765, 63, 466, 12, 291, 14, 533, 63, 466, 430, 421, 199, 533, 13482, 8880, 547, 8, 20349, 304, 339, 408, 272, 4520, 315, 4676, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2053, 12, 10093, 304, 267, 25417, 855, 826, 721, 277, 9, 267, 291, 14, 2614, 275, 2053, 267, 291, 14, 5506, 275, 10093, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1689, 13662, 282, 1125, 1380, 4676, 370, 450, 83, 3134, 78, 2, 355, 298, 547, 26, 450, 83, 60, 78, 2, 450, 334, 277, 14, 2614, 12, 291, 14, 5506, 430, 421, 199, 533, 13482, 5157, 10870, 8, 20349, 304, 339, 408, 272, 4520, 315, 440, 1911, 7249, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 4744, 12, 10093, 304, 267, 25417, 855, 826, 721, 277, 9, 267, 291, 14, 3557, 275, 4744, 267, 291, 14, 5506, 275, 10093, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1689, 13662, 282, 1125, 1380, 2879, 314, 4744, 4366, 83, 12013, 78, 2, 355, 298, 547, 26, 450, 83, 60, 78, 2, 450, 334, 277, 14, 3557, 12, 291, 14, 5506, 430, 421, 199, 533, 13482, 51, 2890, 547, 8, 20349, 304, 339, 408, 272, 4520, 315, 428, 2890, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2928, 63, 711, 12, 2928, 63, 515, 12, 2053, 63, 711, 12, 2053, 63, 515, 12, 10093, 304, 267, 25417, 855, 826, 721, 277, 9, 267, 291, 14, 2164, 63, 711, 275, 2928, 63, 711, 267, 291, 14, 2164, 63, 515, 275, 2928, 63, 515, 267, 291, 14, 2614, 63, 711, 275, 2053, 63, 711, 267, 291, 14, 2614, 63, 515, 275, 2053, 63, 515, 267, 291, 14, 5506, 275, 10093, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1689, 4276, 308, 1850, 687, 450, 83, 641, 450, 83, 370, 450, 83, 641, 450, 83, 3134, 78, 2, 355, 298, 705, 26, 450, 83, 3134, 78, 2, 450, 355, 334, 277, 14, 2164, 63, 515, 12, 291, 14, 2164, 63, 711, 12, 291, 14, 2614, 63, 515, 12, 326, 291, 14, 2614, 63, 711, 12, 291, 14, 5506, 430, 421, 199, 533, 12027, 1799, 547, 8, 20349, 304, 339, 408, 272, 3523, 4520, 315, 1104, 402, 12027, 1950, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1654, 63, 711, 12, 1072, 304, 267, 25417, 855, 826, 721, 277, 9, 267, 291, 14, 1000, 63, 711, 275, 1654, 63, 711, 267, 291, 14, 1199, 275, 1072, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1689, 13716, 370, 450, 83, 3405, 3134, 78, 2, 355, 298, 1199, 26, 450, 83, 298, 450, 334, 277, 14, 1000, 63, 711, 12, 291, 14, 1199, 430, 421, 199, 533, 12027, 31330, 2817, 6340, 547, 8, 20349, 304, 339, 408, 272, 4520, 315, 12881, 18788, 63, 1612, 570, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1790, 63, 1612, 12, 1072, 304, 267, 25417, 855, 826, 721, 277, 9, 267, 291, 14, 1178, 63, 1612, 275, 1790, 63, 1612, 267, 291, 14, 1199, 275, 1072, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1689, 4276, 370, 2813, 18788, 63, 1612, 570, 4366, 83, 12013, 78, 2, 355, 298, 1199, 26, 450, 83, 1275, 60, 78, 2, 450, 334, 277, 14, 1178, 63, 1612, 12, 291, 14, 1199, 430, 421, 199, 533, 13482, 7874, 19992, 8, 20349, 304, 339, 408, 272, 4520, 315, 14043, 2088, 641, 1890, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2088, 12, 1072, 304, 267, 25417, 855, 826, 721, 277, 9, 267, 291, 14, 1760, 275, 2088, 267, 291, 14, 1199, 275, 1072, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1689, 12049, 1414, 1543, 83, 7, 641, 1890, 3405, 3134, 78, 2, 355, 298, 1199, 26, 450, 83, 2, 450, 334, 277, 14, 1760, 12, 291, 14, 1199, 430, 421, 199, 533, 13482, 4562, 86, 10230, 8, 20349, 304, 339, 408, 272, 4520, 315, 10015, 5726, 790, 543, 6250, 3557, 1414, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 790, 12, 1072, 304, 267 ]
[ 199, 2105, 7249, 370, 9635, 24241, 402, 1950, 14, 199, 624, 199, 199, 646, 2050, 199, 646, 747, 199, 646, 5145, 199, 646, 5549, 199, 646, 3718, 199, 199, 504, 2599, 396, 14, 1258, 492, 3778, 12, 747, 63, 2601, 199, 504, 12043, 396, 492, 557, 2352, 290, 12, 3982, 12, 3778, 63, 773, 1042, 2076, 199, 504, 12043, 396, 492, 666, 63, 694, 12, 282, 4921, 421, 199, 533, 25417, 8, 1726, 304, 339, 408, 272, 710, 1300, 1125, 315, 1950, 14, 272, 408, 272, 986, 421, 199, 533, 13482, 17454, 547, 8, 20349, 304, 339, 408, 272, 4520, 315, 24786, 3439, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 10093, 304, 267, 25417, 855, 826, 721, 277, 9, 267, 291, 14, 5506, 275, 10093, 339, 347, 636, 495, 721, 277, 304, 267, 372, 661, 6044, 365, 24786, 3134, 78, 7, 355, 283, 2209, 26, 450, 83, 7, 450, 291, 14, 5506, 9, 421, 199, 533, 13482, 5116, 547, 8, 20349, 304, 339, 408, 272, 4520, 315, 4870, 316, 570, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2928, 63, 515, 12, 2053, 63, 515, 304, 267, 25417, 855, 826, 721, 277, 9, 267, 291, 14, 2164, 63, 515, 275, 2928, 63, 515, 267, 291, 14, 2614, 63, 515, 275, 2053, 63, 515, 339, 347, 636, 495, 721, 277, 304, 267, 372, 661, 5116, 570, 687, 450, 83, 370, 450, 83, 3405, 3530, 355, 450, 334, 277, 14, 2164, 63, 515, 12, 291, 14, 2614, 63, 515, 430, 421, 199, 533, 13482, 18097, 8, 20349, 304, 339, 408, 272, 4520, 315, 6358, 625, 13825, 1083, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1083, 63, 466, 12, 1021, 63, 466, 304, 267, 25417, 855, 826, 721, 277, 9, 267, 291, 14, 765, 63, 466, 275, 1083, 63, 466, 267, 291, 14, 533, 63, 466, 275, 1021, 63, 466, 339, 347, 636, 495, 721, 277, 304, 267, 372, 661, 3767, 450, 83, 365, 440, 6366, 315, 1021, 450, 83, 60, 78, 7, 355, 450, 334, 277, 14, 765, 63, 466, 12, 291, 14, 533, 63, 466, 430, 421, 199, 533, 13482, 8880, 547, 8, 20349, 304, 339, 408, 272, 4520, 315, 4676, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2053, 12, 10093, 304, 267, 25417, 855, 826, 721, 277, 9, 267, 291, 14, 2614, 275, 2053, 267, 291, 14, 5506, 275, 10093, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1689, 13662, 282, 1125, 1380, 4676, 370, 450, 83, 3134, 78, 2, 355, 298, 547, 26, 450, 83, 60, 78, 2, 450, 334, 277, 14, 2614, 12, 291, 14, 5506, 430, 421, 199, 533, 13482, 5157, 10870, 8, 20349, 304, 339, 408, 272, 4520, 315, 440, 1911, 7249, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 4744, 12, 10093, 304, 267, 25417, 855, 826, 721, 277, 9, 267, 291, 14, 3557, 275, 4744, 267, 291, 14, 5506, 275, 10093, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1689, 13662, 282, 1125, 1380, 2879, 314, 4744, 4366, 83, 12013, 78, 2, 355, 298, 547, 26, 450, 83, 60, 78, 2, 450, 334, 277, 14, 3557, 12, 291, 14, 5506, 430, 421, 199, 533, 13482, 51, 2890, 547, 8, 20349, 304, 339, 408, 272, 4520, 315, 428, 2890, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2928, 63, 711, 12, 2928, 63, 515, 12, 2053, 63, 711, 12, 2053, 63, 515, 12, 10093, 304, 267, 25417, 855, 826, 721, 277, 9, 267, 291, 14, 2164, 63, 711, 275, 2928, 63, 711, 267, 291, 14, 2164, 63, 515, 275, 2928, 63, 515, 267, 291, 14, 2614, 63, 711, 275, 2053, 63, 711, 267, 291, 14, 2614, 63, 515, 275, 2053, 63, 515, 267, 291, 14, 5506, 275, 10093, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1689, 4276, 308, 1850, 687, 450, 83, 641, 450, 83, 370, 450, 83, 641, 450, 83, 3134, 78, 2, 355, 298, 705, 26, 450, 83, 3134, 78, 2, 450, 355, 334, 277, 14, 2164, 63, 515, 12, 291, 14, 2164, 63, 711, 12, 291, 14, 2614, 63, 515, 12, 326, 291, 14, 2614, 63, 711, 12, 291, 14, 5506, 430, 421, 199, 533, 12027, 1799, 547, 8, 20349, 304, 339, 408, 272, 3523, 4520, 315, 1104, 402, 12027, 1950, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1654, 63, 711, 12, 1072, 304, 267, 25417, 855, 826, 721, 277, 9, 267, 291, 14, 1000, 63, 711, 275, 1654, 63, 711, 267, 291, 14, 1199, 275, 1072, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1689, 13716, 370, 450, 83, 3405, 3134, 78, 2, 355, 298, 1199, 26, 450, 83, 298, 450, 334, 277, 14, 1000, 63, 711, 12, 291, 14, 1199, 430, 421, 199, 533, 12027, 31330, 2817, 6340, 547, 8, 20349, 304, 339, 408, 272, 4520, 315, 12881, 18788, 63, 1612, 570, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1790, 63, 1612, 12, 1072, 304, 267, 25417, 855, 826, 721, 277, 9, 267, 291, 14, 1178, 63, 1612, 275, 1790, 63, 1612, 267, 291, 14, 1199, 275, 1072, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1689, 4276, 370, 2813, 18788, 63, 1612, 570, 4366, 83, 12013, 78, 2, 355, 298, 1199, 26, 450, 83, 1275, 60, 78, 2, 450, 334, 277, 14, 1178, 63, 1612, 12, 291, 14, 1199, 430, 421, 199, 533, 13482, 7874, 19992, 8, 20349, 304, 339, 408, 272, 4520, 315, 14043, 2088, 641, 1890, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2088, 12, 1072, 304, 267, 25417, 855, 826, 721, 277, 9, 267, 291, 14, 1760, 275, 2088, 267, 291, 14, 1199, 275, 1072, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1689, 12049, 1414, 1543, 83, 7, 641, 1890, 3405, 3134, 78, 2, 355, 298, 1199, 26, 450, 83, 2, 450, 334, 277, 14, 1760, 12, 291, 14, 1199, 430, 421, 199, 533, 13482, 4562, 86, 10230, 8, 20349, 304, 339, 408, 272, 4520, 315, 10015, 5726, 790, 543, 6250, 3557, 1414, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 790, 12, 1072, 304, 267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
apache/beam
sdks/python/apache_beam/testing/test_stream_service.py
5
3203
# # 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. # # pytype: skip-file from concurrent.futures import ThreadPoolExecutor import grpc from apache_beam.portability.api import beam_runner_api_pb2_grpc from apache_beam.portability.api.beam_runner_api_pb2_grpc import TestStreamServiceServicer class TestStreamServiceController(TestStreamServiceServicer): """A server that streams TestStreamPayload.Events from a single EventRequest. This server is used as a way for TestStreams to receive events from file. """ def __init__(self, reader, endpoint=None, exception_handler=None): self._server = grpc.server(ThreadPoolExecutor(max_workers=10)) self._server_started = False self._server_stopped = False if endpoint: self.endpoint = endpoint self._server.add_insecure_port(self.endpoint) else: port = self._server.add_insecure_port('localhost:0') self.endpoint = 'localhost:{}'.format(port) beam_runner_api_pb2_grpc.add_TestStreamServiceServicer_to_server( self, self._server) self._reader = reader self._exception_handler = exception_handler if not self._exception_handler: self._exception_handler = lambda _: False def start(self): # A server can only be started if never started and never stopped before. if self._server_started or self._server_stopped: return self._server_started = True self._server.start() def stop(self): # A server can only be stopped if already started and never stopped before. if not self._server_started or self._server_stopped: return self._server_started = False self._server_stopped = True self._server.stop(0) # This was introduced in grpcio 1.24 and might be gone in the future. Keep # this check in case the runtime is on a older, current or future grpcio. if hasattr(self._server, 'wait_for_termination'): self._server.wait_for_termination() def Events(self, request, context): """Streams back all of the events from the streaming cache.""" # TODO(srohde): Once we get rid of the CacheManager, get rid of this 'full' # label. tags = [None if tag == 'None' else tag for tag in request.output_ids] try: reader = self._reader.read_multiple([('full', tag) for tag in tags]) while True: e = next(reader) yield e except StopIteration: pass except Exception as e: if not self._exception_handler(e): raise e
apache-2.0
[ 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 3, 1134, 466, 26, 3372, 13, 493, 199, 199, 504, 23002, 14, 25513, 492, 11086, 5453, 16752, 199, 199, 646, 19753, 199, 199, 504, 17098, 63, 14529, 14, 719, 3616, 14, 1246, 492, 17453, 63, 5933, 63, 1246, 63, 3317, 18, 63, 15391, 199, 504, 17098, 63, 14529, 14, 719, 3616, 14, 1246, 14, 14529, 63, 5933, 63, 1246, 63, 3317, 18, 63, 15391, 492, 1379, 3296, 3167, 1505, 30150, 421, 199, 533, 1379, 3296, 3167, 7506, 8, 774, 3296, 3167, 1505, 30150, 304, 523, 408, 33, 1654, 626, 13788, 1379, 3296, 17215, 14, 11770, 687, 282, 2849, 6763, 2017, 14, 819, 961, 1654, 365, 1202, 465, 282, 4340, 367, 1379, 19358, 370, 9128, 4474, 687, 570, 14, 523, 408, 523, 347, 636, 826, 721, 277, 12, 7002, 12, 6037, 29, 403, 12, 1919, 63, 2232, 29, 403, 304, 272, 291, 423, 1000, 275, 19753, 14, 1000, 8, 4436, 5453, 16752, 8, 988, 63, 11009, 29, 709, 430, 272, 291, 423, 1000, 63, 8924, 275, 756, 272, 291, 423, 1000, 63, 14661, 275, 756, 339, 340, 6037, 26, 489, 291, 14, 6520, 275, 6037, 489, 291, 423, 1000, 14, 525, 63, 24824, 63, 719, 8, 277, 14, 6520, 9, 272, 587, 26, 489, 1844, 275, 291, 423, 1000, 14, 525, 63, 24824, 63, 719, 360, 5967, 26, 16, 358, 489, 291, 14, 6520, 275, 283, 5967, 26, 11123, 908, 8, 719, 9, 339, 17453, 63, 5933, 63, 1246, 63, 3317, 18, 63, 15391, 14, 525, 63, 774, 3296, 3167, 1505, 30150, 63, 475, 63, 1000, 8, 267, 291, 12, 291, 423, 1000, 9, 272, 291, 423, 5503, 275, 7002, 272, 291, 423, 1971, 63, 2232, 275, 1919, 63, 2232, 272, 340, 440, 291, 423, 1971, 63, 2232, 26, 489, 291, 423, 1971, 63, 2232, 275, 2400, 24700, 756, 819, 347, 1343, 8, 277, 304, 272, 327, 437, 1654, 883, 1454, 506, 8239, 340, 7078, 8239, 436, 7078, 15248, 2544, 14, 272, 340, 291, 423, 1000, 63, 8924, 503, 291, 423, 1000, 63, 14661, 26, 489, 372, 272, 291, 423, 1000, 63, 8924, 275, 715, 272, 291, 423, 1000, 14, 928, 342, 819, 347, 3631, 8, 277, 304, 272, 327, 437, 1654, 883, 1454, 506, 15248, 340, 2575, 8239, 436, 7078, 15248, 2544, 14, 272, 340, 440, 291, 423, 1000, 63, 8924, 503, 291, 423, 1000, 63, 14661, 26, 489, 372, 272, 291, 423, 1000, 63, 8924, 275, 756, 272, 291, 423, 1000, 63, 14661, 275, 715, 272, 291, 423, 1000, 14, 2379, 8, 16, 9, 272, 327, 961, 1990, 21399, 315, 18598, 10377, 413, 14, 1194, 436, 5594, 506, 21737, 315, 314, 6466, 14, 14797, 272, 327, 642, 1104, 315, 1930, 314, 8836, 365, 641, 282, 12731, 12, 1453, 503, 6466, 18598, 10377, 14, 272, 340, 2688, 8, 277, 423, 1000, 12, 283, 2573, 63, 509, 63, 20667, 735, 489, 291, 423, 1000, 14, 2573, 63, 509, 63, 20667, 342, 819, 347, 27982, 8, 277, 12, 1056, 12, 1067, 304, 272, 408, 19358, 1771, 1006, 402, 314, 4474, 687, 314, 18490, 2581, 1041, 339, 327, 3254, 8, 83, 293, 72, 271, 304, 19468, 781, 664, 16146, 402, 314, 11977, 2988, 12, 664, 16146, 402, 642, 283, 2861, 7, 272, 327, 1768, 14, 272, 3762, 275, 359, 403, 340, 1947, 508, 283, 403, 7, 587, 1947, 367, 1947, 315, 1056, 14, 1199, 63, 1580, 61, 272, 862, 26, 489, 7002, 275, 291, 423, 5503, 14, 739, 63, 6048, 8318, 2861, 297, 1947, 9, 367, 1947, 315, 3762, 566, 489, 1830, 715, 26, 267, 325, 275, 2163, 8, 5503, 9, 267, 1995, 325, 272, 871, 10852, 26, 489, 986, 272, 871, 2186, 465, 325, 26, 489, 340, 440, 291, 423, 1971, 63, 2232, 8, 69, 304, 267, 746, 325, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 3, 1134, 466, 26, 3372, 13, 493, 199, 199, 504, 23002, 14, 25513, 492, 11086, 5453, 16752, 199, 199, 646, 19753, 199, 199, 504, 17098, 63, 14529, 14, 719, 3616, 14, 1246, 492, 17453, 63, 5933, 63, 1246, 63, 3317, 18, 63, 15391, 199, 504, 17098, 63, 14529, 14, 719, 3616, 14, 1246, 14, 14529, 63, 5933, 63, 1246, 63, 3317, 18, 63, 15391, 492, 1379, 3296, 3167, 1505, 30150, 421, 199, 533, 1379, 3296, 3167, 7506, 8, 774, 3296, 3167, 1505, 30150, 304, 523, 408, 33, 1654, 626, 13788, 1379, 3296, 17215, 14, 11770, 687, 282, 2849, 6763, 2017, 14, 819, 961, 1654, 365, 1202, 465, 282, 4340, 367, 1379, 19358, 370, 9128, 4474, 687, 570, 14, 523, 408, 523, 347, 636, 826, 721, 277, 12, 7002, 12, 6037, 29, 403, 12, 1919, 63, 2232, 29, 403, 304, 272, 291, 423, 1000, 275, 19753, 14, 1000, 8, 4436, 5453, 16752, 8, 988, 63, 11009, 29, 709, 430, 272, 291, 423, 1000, 63, 8924, 275, 756, 272, 291, 423, 1000, 63, 14661, 275, 756, 339, 340, 6037, 26, 489, 291, 14, 6520, 275, 6037, 489, 291, 423, 1000, 14, 525, 63, 24824, 63, 719, 8, 277, 14, 6520, 9, 272, 587, 26, 489, 1844, 275, 291, 423, 1000, 14, 525, 63, 24824, 63, 719, 360, 5967, 26, 16, 358, 489, 291, 14, 6520, 275, 283, 5967, 26, 11123, 908, 8, 719, 9, 339, 17453, 63, 5933, 63, 1246, 63, 3317, 18, 63, 15391, 14, 525, 63, 774, 3296, 3167, 1505, 30150, 63, 475, 63, 1000, 8, 267, 291, 12, 291, 423, 1000, 9, 272, 291, 423, 5503, 275, 7002, 272, 291, 423, 1971, 63, 2232, 275, 1919, 63, 2232, 272, 340, 440, 291, 423, 1971, 63, 2232, 26, 489, 291, 423, 1971, 63, 2232, 275, 2400, 24700, 756, 819, 347, 1343, 8, 277, 304, 272, 327, 437, 1654, 883, 1454, 506, 8239, 340, 7078, 8239, 436, 7078, 15248, 2544, 14, 272, 340, 291, 423, 1000, 63, 8924, 503, 291, 423, 1000, 63, 14661, 26, 489, 372, 272, 291, 423, 1000, 63, 8924, 275, 715, 272, 291, 423, 1000, 14, 928, 342, 819, 347, 3631, 8, 277, 304, 272, 327, 437, 1654, 883, 1454, 506, 15248, 340, 2575, 8239, 436, 7078, 15248, 2544, 14, 272, 340, 440, 291, 423, 1000, 63, 8924, 503, 291, 423, 1000, 63, 14661, 26, 489, 372, 272, 291, 423, 1000, 63, 8924, 275, 756, 272, 291, 423, 1000, 63, 14661, 275, 715, 272, 291, 423, 1000, 14, 2379, 8, 16, 9, 272, 327, 961, 1990, 21399, 315, 18598, 10377, 413, 14, 1194, 436, 5594, 506, 21737, 315, 314, 6466, 14, 14797, 272, 327, 642, 1104, 315, 1930, 314, 8836, 365, 641, 282, 12731, 12, 1453, 503, 6466, 18598, 10377, 14, 272, 340, 2688, 8, 277, 423, 1000, 12, 283, 2573, 63, 509, 63, 20667, 735, 489, 291, 423, 1000, 14, 2573, 63, 509, 63, 20667, 342, 819, 347, 27982, 8, 277, 12, 1056, 12, 1067, 304, 272, 408, 19358, 1771, 1006, 402, 314, 4474, 687, 314, 18490, 2581, 1041, 339, 327, 3254, 8, 83, 293, 72, 271, 304, 19468, 781, 664, 16146, 402, 314, 11977, 2988, 12, 664, 16146, 402, 642, 283, 2861, 7, 272, 327, 1768, 14, 272, 3762, 275, 359, 403, 340, 1947, 508, 283, 403, 7, 587, 1947, 367, 1947, 315, 1056, 14, 1199, 63, 1580, 61, 272, 862, 26, 489, 7002, 275, 291, 423, 5503, 14, 739, 63, 6048, 8318, 2861, 297, 1947, 9, 367, 1947, 315, 3762, 566, 489, 1830, 715, 26, 267, 325, 275, 2163, 8, 5503, 9, 267, 1995, 325, 272, 871, 10852, 26, 489, 986, 272, 871, 2186, 465, 325, 26, 489, 340, 440, 291, 423, 1971, 63, 2232, 8, 69, 304, 267, 746, 325, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
PLyczkowski/Sticky-Keymap
2.74/scripts/addons/add_mesh_extra_objects/add_mesh_pipe_joint.py
1
33743
# ##### BEGIN GPL LICENSE BLOCK ##### # # 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. # # ##### END GPL LICENSE BLOCK ##### ''' "name": "Pipe Joints", "author": "Buerbaum Martin (Pontiac)", "version": (0, 10, 7), ''' import bpy from math import * from bpy.props import * # Create a new mesh (object) from verts/edges/faces. # verts/edges/faces ... List of vertices/edges/faces for the # new mesh (as used in from_pydata). # name ... Name of the new mesh (& object). def create_mesh_object(context, verts, edges, faces, name): # Create new mesh mesh = bpy.data.meshes.new(name) # Make a mesh from a list of verts/edges/faces. mesh.from_pydata(verts, edges, faces) # Update mesh geometry after adding stuff. mesh.update() from bpy_extras import object_utils return object_utils.object_data_add(context, mesh, operator=None) # A very simple "bridge" tool. # Connects two equally long vertex rows with faces. # Returns a list of the new faces (list of lists) # # vertIdx1 ... First vertex list (list of vertex indices). # vertIdx2 ... Second vertex list (list of vertex indices). # closed ... Creates a loop (first & last are closed). # flipped ... Invert the normal of the face(s). # # Note: You can set vertIdx1 to a single vertex index to create # a fan/star of faces. # Note: If both vertex idx list are the same length they have # to have at least 2 vertices. def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False): faces = [] if not vertIdx1 or not vertIdx2: return None if len(vertIdx1) < 2 and len(vertIdx2) < 2: return None fan = False if (len(vertIdx1) != len(vertIdx2)): if (len(vertIdx1) == 1 and len(vertIdx2) > 1): fan = True else: return None total = len(vertIdx2) if closed: # Bridge the start with the end. if flipped: face = [ vertIdx1[0], vertIdx2[0], vertIdx2[total - 1]] if not fan: face.append(vertIdx1[total - 1]) faces.append(face) else: face = [vertIdx2[0], vertIdx1[0]] if not fan: face.append(vertIdx1[total - 1]) face.append(vertIdx2[total - 1]) faces.append(face) # Bridge the rest of the faces. for num in range(total - 1): if flipped: if fan: face = [vertIdx2[num], vertIdx1[0], vertIdx2[num + 1]] else: face = [vertIdx2[num], vertIdx1[num], vertIdx1[num + 1], vertIdx2[num + 1]] faces.append(face) else: if fan: face = [vertIdx1[0], vertIdx2[num], vertIdx2[num + 1]] else: face = [vertIdx1[num], vertIdx2[num], vertIdx2[num + 1], vertIdx1[num + 1]] faces.append(face) return faces class AddElbowJoint(bpy.types.Operator): # Create the vertices and polygons for a simple elbow (bent pipe). """Add an Elbow pipe mesh""" bl_idname = "mesh.primitive_elbow_joint_add" bl_label = "Add Pipe Elbow" bl_options = {'REGISTER', 'UNDO', 'PRESET'} radius = FloatProperty(name="Radius", description="The radius of the pipe", default=1.0, min=0.01, max=100.0, unit="LENGTH") div = IntProperty(name="Divisions", description="Number of vertices (divisions)", default=32, min=3, max=256) angle = FloatProperty(name="Angle", description="The angle of the branching pipe (i.e. the 'arm' - " \ "Measured from the center line of the main pipe", default=radians(45.0), min=radians(-179.9), max=radians(179.9), unit="ROTATION") startLength = FloatProperty(name="Length Start", description="Length of the beginning of the pipe", default=3.0, min=0.01, max=100.0, unit="LENGTH") endLength = FloatProperty(name="End Length", description="Length of the end of the pipe", default=3.0, min=0.01, max=100.0, unit="LENGTH") def execute(self, context): radius = self.radius div = self.div angle = self.angle startLength = self.startLength endLength = self.endLength verts = [] faces = [] loop1 = [] # The starting circle loop2 = [] # The elbow circle loop3 = [] # The end circle # Create start circle for vertIdx in range(div): curVertAngle = vertIdx * (2.0 * pi / div) locX = sin(curVertAngle) locY = cos(curVertAngle) locZ = -startLength loop1.append(len(verts)) verts.append([locX * radius, locY * radius, locZ]) # Create deformed joint circle for vertIdx in range(div): curVertAngle = vertIdx * (2.0 * pi / div) locX = sin(curVertAngle) locY = cos(curVertAngle) locZ = locX * tan(angle / 2.0) loop2.append(len(verts)) verts.append([locX * radius, locY * radius, locZ * radius]) # Create end circle baseEndLocX = -endLength * sin(angle) baseEndLocZ = endLength * cos(angle) for vertIdx in range(div): curVertAngle = vertIdx * (2.0 * pi / div) # Create circle locX = sin(curVertAngle) * radius locY = cos(curVertAngle) * radius locZ = 0.0 # Rotate circle locZ = locX * cos(pi / 2.0 - angle) locX = locX * sin(pi / 2.0 - angle) loop3.append(len(verts)) # Translate and add circle vertices to the list. verts.append([baseEndLocX + locX, locY, baseEndLocZ + locZ]) # Create faces faces.extend(createFaces(loop1, loop2, closed=True)) faces.extend(createFaces(loop2, loop3, closed=True)) base = create_mesh_object(context, verts, [], faces, "Elbow Joint") return {'FINISHED'} class AddTeeJoint(bpy.types.Operator): # Create the vertices and polygons for a simple tee (T) joint. # The base arm of the T can be positioned in an angle if needed though. """Add a Tee-Joint mesh""" bl_idname = "mesh.primitive_tee_joint_add" bl_label = "Add Pipe Tee-Joint" bl_options = {'REGISTER', 'UNDO', 'PRESET'} radius = FloatProperty(name="Radius", description="The radius of the pipe", default=1.0, min=0.01, max=100.0, unit="LENGTH") div = IntProperty(name="Divisions", description="Number of vertices (divisions)", default=32, min=4, max=256) angle = FloatProperty(name="Angle", description="The angle of the branching pipe (i.e. the 'arm' - " \ "Measured from the center line of the main pipe", default=radians(90.0), min=radians(0.1), max=radians(179.9), unit="ROTATION") startLength = FloatProperty(name="Length Start", description="Length of the beginning of the" \ " main pipe (the straight one)", default=3.0, min=0.01, max=100.0, unit="LENGTH") endLength = FloatProperty(name="End Length", description="Length of the end of the" \ " main pipe (the straight one)", default=3.0, min=0.01, max=100.0, unit="LENGTH") branchLength = FloatProperty(name="Arm Length", description="Length of the arm pipe (the bent one)", default=3.0, min=0.01, max=100.0, unit="LENGTH") def execute(self, context): radius = self.radius div = self.div angle = self.angle startLength = self.startLength endLength = self.endLength branchLength = self.branchLength if (div % 2): # Odd vertice number not supported (yet). return {'CANCELLED'} verts = [] faces = [] # List of vert indices of each cross section loopMainStart = [] # Vert indices for the # beginning of the main pipe. loopJoint1 = [] # Vert indices for joint that is used # to connect the joint & loopMainStart. loopJoint2 = [] # Vert indices for joint that is used # to connect the joint & loopArm. loopJoint3 = [] # Vert index for joint that is used # to connect the joint & loopMainEnd. loopArm = [] # Vert indices for the end of the arm. loopMainEnd = [] # Vert indices for the # end of the main pipe. # Create start circle (main pipe) for vertIdx in range(div): curVertAngle = vertIdx * (2.0 * pi / div) locX = sin(curVertAngle) locY = cos(curVertAngle) locZ = -startLength loopMainStart.append(len(verts)) verts.append([locX * radius, locY * radius, locZ]) # Create deformed joint circle vertTemp1 = None vertTemp2 = None for vertIdx in range(div): curVertAngle = vertIdx * (2.0 * pi / div) locX = sin(curVertAngle) locY = cos(curVertAngle) if vertIdx == 0: vertTemp1 = len(verts) if vertIdx == div / 2: # @todo: This will possibly break if we # ever support odd divisions. vertTemp2 = len(verts) loopJoint1.append(len(verts)) if (vertIdx < div / 2): # Straight side of main pipe. locZ = 0 loopJoint3.append(len(verts)) else: # Branching side locZ = locX * tan(angle / 2.0) loopJoint2.append(len(verts)) verts.append([locX * radius, locY * radius, locZ * radius]) # Create 2. deformed joint (half-)circle loopTemp = [] for vertIdx in range(div): if (vertIdx > div / 2): curVertAngle = vertIdx * (2.0 * pi / div) locX = sin(curVertAngle) locY = -cos(curVertAngle) locZ = -(radius * locX * tan((pi - angle) / 2.0)) loopTemp.append(len(verts)) verts.append([locX * radius, locY * radius, locZ]) loopTemp2 = loopTemp[:] # Finalise 2. loop loopTemp.reverse() loopTemp.append(vertTemp1) loopJoint2.reverse() loopJoint2.extend(loopTemp) loopJoint2.reverse() # Finalise 3. loop loopTemp2.append(vertTemp2) loopTemp2.reverse() loopJoint3.extend(loopTemp2) # Create end circle (branching pipe) baseEndLocX = -branchLength * sin(angle) baseEndLocZ = branchLength * cos(angle) for vertIdx in range(div): curVertAngle = vertIdx * (2.0 * pi / div) # Create circle locX = sin(curVertAngle) * radius locY = cos(curVertAngle) * radius locZ = 0.0 # Rotate circle locZ = locX * cos(pi / 2.0 - angle) locX = locX * sin(pi / 2.0 - angle) loopArm.append(len(verts)) # Add translated circle. verts.append([baseEndLocX + locX, locY, baseEndLocZ + locZ]) # Create end circle (main pipe) for vertIdx in range(div): curVertAngle = vertIdx * (2.0 * pi / div) locX = sin(curVertAngle) locY = cos(curVertAngle) locZ = endLength loopMainEnd.append(len(verts)) verts.append([locX * radius, locY * radius, locZ]) # Create faces faces.extend(createFaces(loopMainStart, loopJoint1, closed=True)) faces.extend(createFaces(loopJoint2, loopArm, closed=True)) faces.extend(createFaces(loopJoint3, loopMainEnd, closed=True)) base = create_mesh_object(context, verts, [], faces, "Tee Joint") return {'FINISHED'} class AddWyeJoint(bpy.types.Operator): """Add a Wye-Joint mesh""" bl_idname = "mesh.primitive_wye_joint_add" bl_label = "Add Pipe Wye-Joint" bl_options = {'REGISTER', 'UNDO', 'PRESET'} radius = FloatProperty(name="Radius", description="The radius of the pipe", default=1.0, min=0.01, max=100.0, unit="LENGTH") div = IntProperty(name="Divisions", description="Number of vertices (divisions)", default=32, min=4, max=256) angle1 = FloatProperty(name="Angle 1", description="The angle of the 1. branching pipe " \ "(measured from the center line of the main pipe)", default=radians(45.0), min=radians(-179.9), max=radians(179.9), unit="ROTATION") angle2 = FloatProperty(name="Angle 2", description="The angle of the 2. branching pipe " \ "(measured from the center line of the main pipe) ", default=radians(45.0), min=radians(-179.9), max=radians(179.9), unit="ROTATION") startLength = FloatProperty(name="Length Start", description="Length of the beginning of the" \ " main pipe (the straight one)", default=3.0, min=0.01, max=100.0, unit="LENGTH") branch1Length = FloatProperty(name="Length Arm 1", description="Length of the 1. arm", default=3.0, min=0.01, max=100.0, unit="LENGTH") branch2Length = FloatProperty(name="Length Arm 2", description="Length of the 2. arm", default=3.0, min=0.01, max=100.0, unit="LENGTH") def execute(self, context): radius = self.radius div = self.div angle1 = self.angle1 angle2 = self.angle2 startLength = self.startLength branch1Length = self.branch1Length branch2Length = self.branch2Length if (div % 2): # Odd vertice number not supported (yet). return {'CANCELLED'} verts = [] faces = [] # List of vert indices of each cross section loopMainStart = [] # Vert indices for # the beginning of the main pipe. loopJoint1 = [] # Vert index for joint that is used # to connect the joint & loopMainStart. loopJoint2 = [] # Vert index for joint that # is used to connect the joint & loopArm1. loopJoint3 = [] # Vert index for joint that is # used to connect the joint & loopArm2. loopArm1 = [] # Vert idxs for end of the 1. arm. loopArm2 = [] # Vert idxs for end of the 2. arm. # Create start circle for vertIdx in range(div): curVertAngle = vertIdx * (2.0 * pi / div) locX = sin(curVertAngle) locY = cos(curVertAngle) locZ = -startLength loopMainStart.append(len(verts)) verts.append([locX * radius, locY * radius, locZ]) # Create deformed joint circle vertTemp1 = None vertTemp2 = None for vertIdx in range(div): curVertAngle = vertIdx * (2.0 * pi / div) locX = sin(curVertAngle) locY = cos(curVertAngle) if vertIdx == 0: vertTemp2 = len(verts) if vertIdx == div / 2: # @todo: This will possibly break if we # ever support odd divisions. vertTemp1 = len(verts) loopJoint1.append(len(verts)) if (vertIdx > div / 2): locZ = locX * tan(angle1 / 2.0) loopJoint2.append(len(verts)) else: locZ = locX * tan(-angle2 / 2.0) loopJoint3.append(len(verts)) verts.append([locX * radius, locY * radius, locZ * radius]) # Create 2. deformed joint (half-)circle loopTemp = [] angleJoint = (angle2 - angle1) / 2.0 for vertIdx in range(div): if (vertIdx > div / 2): curVertAngle = vertIdx * (2.0 * pi / div) locX = (-sin(curVertAngle) * sin(angleJoint) / sin(angle2 - angleJoint)) locY = -cos(curVertAngle) locZ = (-(sin(curVertAngle) * cos(angleJoint) / sin(angle2 - angleJoint))) loopTemp.append(len(verts)) verts.append([locX * radius, locY * radius, locZ * radius]) loopTemp2 = loopTemp[:] # Finalise 2. loop loopTemp.append(vertTemp1) loopTemp.reverse() loopTemp.append(vertTemp2) loopJoint2.reverse() loopJoint2.extend(loopTemp) loopJoint2.reverse() # Finalise 3. loop loopTemp2.reverse() loopJoint3.extend(loopTemp2) # Create end circle (1. branching pipe) baseEndLocX = -branch1Length * sin(angle1) baseEndLocZ = branch1Length * cos(angle1) for vertIdx in range(div): curVertAngle = vertIdx * (2.0 * pi / div) # Create circle locX = sin(curVertAngle) * radius locY = cos(curVertAngle) * radius locZ = 0.0 # Rotate circle locZ = locX * cos(pi / 2.0 - angle1) locX = locX * sin(pi / 2.0 - angle1) loopArm1.append(len(verts)) # Add translated circle. verts.append([baseEndLocX + locX, locY, baseEndLocZ + locZ]) # Create end circle (2. branching pipe) baseEndLocX = branch2Length * sin(angle2) baseEndLocZ = branch2Length * cos(angle2) for vertIdx in range(div): curVertAngle = vertIdx * (2.0 * pi / div) # Create circle locX = sin(curVertAngle) * radius locY = cos(curVertAngle) * radius locZ = 0.0 # Rotate circle locZ = locX * cos(pi / 2.0 + angle2) locX = locX * sin(pi / 2.0 + angle2) loopArm2.append(len(verts)) # Add translated circle verts.append([baseEndLocX + locX, locY, baseEndLocZ + locZ]) # Create faces faces.extend(createFaces(loopMainStart, loopJoint1, closed=True)) faces.extend(createFaces(loopJoint2, loopArm1, closed=True)) faces.extend(createFaces(loopJoint3, loopArm2, closed=True)) base = create_mesh_object(context, verts, [], faces, "Wye Joint") return {'FINISHED'} class AddCrossJoint(bpy.types.Operator): """Add a Cross-Joint mesh""" # Create the vertices and polygons for a coss (+ or X) pipe joint. bl_idname = "mesh.primitive_cross_joint_add" bl_label = "Add Pipe Cross-Joint" bl_options = {'REGISTER', 'UNDO', 'PRESET'} radius = FloatProperty(name="Radius", description="The radius of the pipe", default=1.0, min=0.01, max=100.0, unit="LENGTH") div = IntProperty(name="Divisions", description="Number of vertices (divisions)", default=32, min=4, max=256) angle1 = FloatProperty(name="Angle 1", description="The angle of the 1. arm (from the main axis)", default=radians(90.0), min=radians(-179.9), max=radians(179.9), unit="ROTATION") angle2 = FloatProperty(name="Angle 2", description="The angle of the 2. arm (from the main axis)", default=radians(90.0), min=radians(-179.9), max=radians(179.9), unit="ROTATION") angle3 = FloatProperty(name="Angle 3 (center)", description="The angle of the center arm (from the main axis)", default=radians(0.0), min=radians(-179.9), max=radians(179.9), unit="ROTATION") startLength = FloatProperty(name="Length Start", description="Length of the beginning of the " \ "main pipe (the straight one)", default=3.0, min=0.01, max=100.0, unit="LENGTH") branch1Length = FloatProperty(name="Length Arm 1", description="Length of the 1. arm", default=3.0, min=0.01, max=100.0, unit="LENGTH") branch2Length = FloatProperty(name="Length Arm 2", description="Length of the 2. arm", default=3.0, min=0.01, max=100.0, unit="LENGTH") branch3Length = FloatProperty(name="Length Arm 3 (center)", description="Length of the center arm", default=3.0, min=0.01, max=100.0, unit="LENGTH") def execute(self, context): radius = self.radius div = self.div angle1 = self.angle1 angle2 = self.angle2 angle3 = self.angle3 startLength = self.startLength branch1Length = self.branch1Length branch2Length = self.branch2Length branch3Length = self.branch3Length if (div % 2): # Odd vertice number not supported (yet). return {'CANCELLED'} verts = [] faces = [] # List of vert indices of each cross section loopMainStart = [] # Vert indices for the # beginning of the main pipe. loopJoint1 = [] # Vert index for joint that is used # to connect the joint & loopMainStart. loopJoint2 = [] # Vert index for joint that is used # to connect the joint & loopArm1. loopJoint3 = [] # Vert index for joint that is used # to connect the joint & loopArm2. loopJoint4 = [] # Vert index for joint that is used # to connect the joint & loopArm3. loopArm1 = [] # Vert idxs for the end of the 1. arm. loopArm2 = [] # Vert idxs for the end of the 2. arm. loopArm3 = [] # Vert idxs for the center arm end. # Create start circle for vertIdx in range(div): curVertAngle = vertIdx * (2.0 * pi / div) locX = sin(curVertAngle) locY = cos(curVertAngle) locZ = -startLength loopMainStart.append(len(verts)) verts.append([locX * radius, locY * radius, locZ]) # Create 1. deformed joint circle vertTemp1 = None vertTemp2 = None for vertIdx in range(div): curVertAngle = vertIdx * (2.0 * pi / div) locX = sin(curVertAngle) locY = cos(curVertAngle) if vertIdx == 0: vertTemp2 = len(verts) if vertIdx == div / 2: # @todo: This will possibly break if we # ever support odd divisions. vertTemp1 = len(verts) loopJoint1.append(len(verts)) if (vertIdx > div / 2): locZ = locX * tan(angle1 / 2.0) loopJoint2.append(len(verts)) else: locZ = locX * tan(-angle2 / 2.0) loopJoint3.append(len(verts)) verts.append([locX * radius, locY * radius, locZ * radius]) # loopTemp2 = loopJoint2[:] # UNUSED # Create 2. deformed joint circle loopTempA = [] loopTempB = [] angleJoint1 = (angle1 - angle3) / 2.0 angleJoint2 = (angle2 + angle3) / 2.0 for vertIdx in range(div): curVertAngle = vertIdx * (2.0 * pi / div) # Skip pole vertices # @todo: This will possibly break if # we ever support odd divisions. if not (vertIdx == 0) and not (vertIdx == div / 2): if (vertIdx > div / 2): angleJoint = angleJoint1 angle = angle1 Z = -1.0 loopTempA.append(len(verts)) else: angleJoint = angleJoint2 angle = angle2 Z = 1.0 loopTempB.append(len(verts)) locX = (sin(curVertAngle) * sin(angleJoint) / sin(angle - angleJoint)) locY = -cos(curVertAngle) locZ = (Z * (sin(curVertAngle) * cos(angleJoint) / sin(angle - angleJoint))) verts.append([locX * radius, locY * radius, locZ * radius]) loopTempA2 = loopTempA[:] loopTempB2 = loopTempB[:] loopTempB3 = loopTempB[:] # Finalise 2. loop loopTempA.append(vertTemp1) loopTempA.reverse() loopTempA.append(vertTemp2) loopJoint2.reverse() loopJoint2.extend(loopTempA) loopJoint2.reverse() # Finalise 3. loop loopJoint3.extend(loopTempB3) # Finalise 4. loop loopTempA2.append(vertTemp1) loopTempA2.reverse() loopTempB2.append(vertTemp2) loopJoint4.extend(reversed(loopTempB2)) loopJoint4.extend(loopTempA2) # Create end circle (1. branching pipe) baseEndLocX = -branch1Length * sin(angle1) baseEndLocZ = branch1Length * cos(angle1) for vertIdx in range(div): curVertAngle = vertIdx * (2.0 * pi / div) # Create circle locX = sin(curVertAngle) * radius locY = cos(curVertAngle) * radius locZ = 0.0 # Rotate circle locZ = locX * cos(pi / 2.0 - angle1) locX = locX * sin(pi / 2.0 - angle1) loopArm1.append(len(verts)) # Add translated circle. verts.append([baseEndLocX + locX, locY, baseEndLocZ + locZ]) # Create end circle (2. branching pipe) baseEndLocX = branch2Length * sin(angle2) baseEndLocZ = branch2Length * cos(angle2) for vertIdx in range(div): curVertAngle = vertIdx * (2.0 * pi / div) # Create circle locX = sin(curVertAngle) * radius locY = cos(curVertAngle) * radius locZ = 0.0 # Rotate circle locZ = locX * cos(pi / 2.0 + angle2) locX = locX * sin(pi / 2.0 + angle2) loopArm2.append(len(verts)) # Add translated circle verts.append([baseEndLocX + locX, locY, baseEndLocZ + locZ]) # Create end circle (center pipe) baseEndLocX = branch3Length * sin(angle3) baseEndLocZ = branch3Length * cos(angle3) for vertIdx in range(div): curVertAngle = vertIdx * (2.0 * pi / div) # Create circle locX = sin(curVertAngle) * radius locY = cos(curVertAngle) * radius locZ = 0.0 # Rotate circle locZ = locX * cos(pi / 2.0 + angle3) locX = locX * sin(pi / 2.0 + angle3) loopArm3.append(len(verts)) # Add translated circle verts.append([baseEndLocX + locX, locY, baseEndLocZ + locZ]) # Create faces faces.extend(createFaces(loopMainStart, loopJoint1, closed=True)) faces.extend(createFaces(loopJoint2, loopArm1, closed=True)) faces.extend(createFaces(loopJoint3, loopArm2, closed=True)) faces.extend(createFaces(loopJoint4, loopArm3, closed=True)) base = create_mesh_object(context, verts, [], faces, "Cross Joint") return {'FINISHED'} class AddNJoint(bpy.types.Operator): """Add a N-Joint mesh""" # Create the vertices and polygons for a regular n-joint. bl_idname = "mesh.primitive_n_joint_add" bl_label = "Add Pipe N-Joint" bl_options = {'REGISTER', 'UNDO', 'PRESET'} radius = FloatProperty(name="Radius", description="The radius of the pipe", default=1.0, min=0.01, max=100.0, unit="LENGTH") div = IntProperty(name="Divisions", description="Number of vertices (divisions)", default=32, min=4, max=256) number = IntProperty(name="Arms/Joints", description="Number of joints/arms", default=5, min=2, max=99999) length = FloatProperty(name="Length", description="Length of each joint/arm", default=3.0, min=0.01, max=100.0, unit="LENGTH") def execute(self, context): radius = self.radius div = self.div number = self.number length = self.length if (div % 2): # Odd vertice number not supported (yet). return {'CANCELLED'} if (number < 2): return {'CANCELLED'} verts = [] faces = [] loopsEndCircles = [] loopsJointsTemp = [] loopsJoints = [] vertTemp1 = None vertTemp2 = None angleDiv = (2.0 * pi / number) # Create vertices for the end circles. for num in range(number): circle = [] # Create start circle angle = num * angleDiv baseEndLocX = length * sin(angle) baseEndLocZ = length * cos(angle) for vertIdx in range(div): curVertAngle = vertIdx * (2.0 * pi / div) # Create circle locX = sin(curVertAngle) * radius locY = cos(curVertAngle) * radius locZ = 0.0 # Rotate circle locZ = locX * cos(pi / 2.0 + angle) locX = locX * sin(pi / 2.0 + angle) circle.append(len(verts)) # Add translated circle verts.append([baseEndLocX + locX, locY, baseEndLocZ + locZ]) loopsEndCircles.append(circle) # Create vertices for the joint circles. loopJoint = [] for vertIdx in range(div): curVertAngle = vertIdx * (2.0 * pi / div) locX = sin(curVertAngle) locY = cos(curVertAngle) skipVert = False # Store pole vertices if vertIdx == 0: if (num == 0): vertTemp2 = len(verts) else: skipVert = True elif vertIdx == div / 2: # @todo: This will possibly break if we # ever support odd divisions. if (num == 0): vertTemp1 = len(verts) else: skipVert = True if not skipVert: if (vertIdx > div / 2): locZ = -locX * tan((pi - angleDiv) / 2.0) loopJoint.append(len(verts)) # Rotate the vert cosAng = cos(-angle) sinAng = sin(-angle) LocXnew = locX * cosAng - locZ * sinAng LocZnew = locZ * cosAng + locX * sinAng locZ = LocZnew locX = LocXnew verts.append([ locX * radius, locY * radius, locZ * radius]) else: # These two vertices will only be # added the very first time. if vertIdx == 0 or vertIdx == div / 2: verts.append([locX * radius, locY * radius, locZ]) loopsJointsTemp.append(loopJoint) # Create complete loops (loopsJoints) out of the # double number of half loops in loopsJointsTemp. for halfLoopIdx in range(len(loopsJointsTemp)): if (halfLoopIdx == len(loopsJointsTemp) - 1): idx1 = halfLoopIdx idx2 = 0 else: idx1 = halfLoopIdx idx2 = halfLoopIdx + 1 loopJoint = [] loopJoint.append(vertTemp2) loopJoint.extend(reversed(loopsJointsTemp[idx2])) loopJoint.append(vertTemp1) loopJoint.extend(loopsJointsTemp[idx1]) loopsJoints.append(loopJoint) # Create faces from the two # loop arrays (loopsJoints -> loopsEndCircles). for loopIdx in range(len(loopsEndCircles)): faces.extend( createFaces(loopsJoints[loopIdx], loopsEndCircles[loopIdx], closed=True)) base = create_mesh_object(context, verts, [], faces, "N Joint") return {'FINISHED'} ################################
gpl-2.0
[ 3, 22906, 16427, 14629, 5113, 8068, 22906, 199, 3, 199, 3, 221, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 221, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 3, 221, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 199, 3, 221, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 3, 22906, 7729, 14629, 5113, 8068, 22906, 199, 2344, 272, 298, 354, 582, 298, 11867, 7135, 13141, 401, 272, 298, 2502, 582, 298, 1713, 281, 2470, 453, 603, 26788, 334, 48, 265, 280, 645, 4186, 272, 298, 1023, 582, 334, 16, 12, 1616, 12, 1520, 395, 199, 2344, 199, 646, 20575, 199, 504, 3473, 492, 627, 199, 504, 20575, 14, 6750, 492, 627, 199, 199, 3, 2790, 282, 892, 9364, 334, 785, 9, 687, 809, 1086, 15, 6929, 15, 4309, 14, 199, 3, 809, 1086, 15, 6929, 15, 4309, 2263, 3820, 402, 14971, 15, 6929, 15, 4309, 367, 314, 199, 3, 9668, 892, 9364, 334, 305, 1202, 315, 687, 63, 647, 576, 680, 199, 3, 536, 2263, 2812, 402, 314, 892, 9364, 334, 6, 909, 680, 199, 318, 1218, 63, 6480, 63, 785, 8, 1100, 12, 809, 1086, 12, 8207, 12, 21143, 12, 536, 304, 272, 327, 2790, 892, 9364, 272, 9364, 275, 20575, 14, 576, 14, 6480, 397, 14, 1222, 8, 354, 9, 339, 327, 4155, 282, 9364, 687, 282, 769, 402, 809, 1086, 15, 6929, 15, 4309, 14, 272, 9364, 14, 504, 63, 647, 576, 8, 21505, 12, 8207, 12, 21143, 9, 339, 327, 6162, 9364, 3400, 2410, 7791, 8292, 14, 272, 9364, 14, 873, 342, 339, 687, 20575, 63, 9975, 492, 909, 63, 1208, 272, 372, 909, 63, 1208, 14, 785, 63, 576, 63, 525, 8, 1100, 12, 9364, 12, 4182, 29, 403, 9, 199, 199, 3, 437, 7437, 3486, 298, 9528, 2, 4744, 14, 199, 3, 15175, 83, 2877, 11960, 1183, 1846, 12759, 4730, 543, 21143, 14, 199, 3, 1803, 282, 769, 402, 314, 892, 21143, 334, 513, 402, 221, 5548, 9, 199, 3, 199, 3, 809, 84, 12215, 17, 2263, 7758, 12759, 769, 334, 513, 402, 12759, 4918, 680, 199, 3, 809, 84, 12215, 18, 2263, 16707, 12759, 769, 334, 513, 402, 12759, 4918, 680, 199, 3, 6876, 2263, 10560, 282, 4438, 334, 2246, 1253, 2061, 787, 6876, 680, 199, 3, 18761, 1915, 2263, 1010, 1884, 314, 3293, 402, 314, 8870, 8, 83, 680, 199, 3, 199, 3, 3390, 26, 2047, 883, 663, 809, 84, 12215, 17, 370, 282, 2849, 12759, 1478, 370, 1218, 199, 3, 755, 282, 13758, 15, 7848, 402, 21143, 14, 199, 3, 3390, 26, 982, 3865, 12759, 4280, 769, 787, 314, 2011, 2582, 2985, 1172, 199, 3, 755, 370, 1172, 737, 5210, 499, 14971, 14, 199, 318, 1218, 1906, 823, 8, 1884, 12215, 17, 12, 809, 84, 12215, 18, 12, 6876, 29, 797, 12, 18761, 1915, 29, 797, 304, 272, 21143, 275, 942, 339, 340, 440, 809, 84, 12215, 17, 503, 440, 809, 84, 12215, 18, 26, 267, 372, 488, 339, 340, 822, 8, 1884, 12215, 17, 9, 665, 499, 436, 822, 8, 1884, 12215, 18, 9, 665, 499, 26, 267, 372, 488, 339, 13758, 275, 756, 272, 340, 334, 552, 8, 1884, 12215, 17, 9, 1137, 822, 8, 1884, 12215, 18, 2298, 267, 340, 334, 552, 8, 1884, 12215, 17, 9, 508, 413, 436, 822, 8, 1884, 12215, 18, 9, 690, 413, 304, 288, 13758, 275, 715, 267, 587, 26, 288, 372, 488, 339, 3141, 275, 822, 8, 1884, 12215, 18, 9, 339, 340, 6876, 26, 267, 327, 699, 5562, 314, 1343, 543, 314, 1284, 14, 267, 340, 18761, 1915, 26, 288, 8870, 275, 359, 355, 809, 84, 12215, 17, 59, 16, 467, 355, 809, 84, 12215, 18, 59, 16, 467, 355, 809, 84, 12215, 18, 59, 2923, 446, 413, 2677, 288, 340, 440, 13758, 26, 355, 8870, 14, 740, 8, 1884, 12215, 17, 59, 2923, 446, 413, 566, 288, 21143, 14, 740, 8, 1409, 9, 398, 587, 26, 288, 8870, 275, 359, 1884, 12215, 18, 59, 16, 467, 809, 84, 12215, 17, 59, 16, 2677, 288, 340, 440, 13758, 26, 355, 8870, 14, 740, 8, 1884, 12215, 17, 59, 2923, 446, 413, 566, 288, 8870, 14, 740, 8, 1884, 12215, 18, 59, 2923, 446, 413, 566, 288, 21143, 14, 740, 8, 1409, 9, 339, 327, 699, 5562, 314, 4618, 402, 314, 21143, 14, 272, 367, 1967, 315, 1425, 8, 2923, 446, 413, 304, 267, 340, 18761, 1915, 26, 288, 340, 13758, 26, 355, 8870, 275, 359, 1884, 12215, 18, 59, 1507, 467, 809, 84, 12215, 17, 59, 16, 467, 809, 84, 12215, 18, 59, 1507, 435, 413, 2677, 288, 587, 26, 355, 8870, 275, 359, 1884, 12215, 18, 59, 1507, 467, 809, 84, 12215, 17, 59, 1507, 467, 490, 809, 84, 12215, 17, 59, 1507, 435, 413, 467, 809, 84, 12215, 18, 59, 1507, 435, 413, 2677, 288, 21143, 14, 740, 8, 1409, 9, 267, 587, 26, 288, 340, 13758, 26, 355, 8870, 275, 359, 1884, 12215, 17, 59, 16, 467, 809, 84, 12215, 18, 59, 1507, 467, 809, 84, 12215, 18, 59, 1507, 435, 413, 2677, 288, 587, 26, 355, 8870, 275, 359, 1884, 12215, 17, 59, 1507, 467, 809, 84, 12215, 18, 59, 1507, 467, 490, 809, 84, 12215, 18, 59, 1507, 435, 413, 467, 809, 84, 12215, 17, 59, 1507, 435, 413, 2677, 288, 21143, 14, 740, 8, 1409, 9, 339, 372, 21143, 199 ]
[ 22906, 16427, 14629, 5113, 8068, 22906, 199, 3, 199, 3, 221, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 221, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 3, 221, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 199, 3, 221, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 3, 22906, 7729, 14629, 5113, 8068, 22906, 199, 2344, 272, 298, 354, 582, 298, 11867, 7135, 13141, 401, 272, 298, 2502, 582, 298, 1713, 281, 2470, 453, 603, 26788, 334, 48, 265, 280, 645, 4186, 272, 298, 1023, 582, 334, 16, 12, 1616, 12, 1520, 395, 199, 2344, 199, 646, 20575, 199, 504, 3473, 492, 627, 199, 504, 20575, 14, 6750, 492, 627, 199, 199, 3, 2790, 282, 892, 9364, 334, 785, 9, 687, 809, 1086, 15, 6929, 15, 4309, 14, 199, 3, 809, 1086, 15, 6929, 15, 4309, 2263, 3820, 402, 14971, 15, 6929, 15, 4309, 367, 314, 199, 3, 9668, 892, 9364, 334, 305, 1202, 315, 687, 63, 647, 576, 680, 199, 3, 536, 2263, 2812, 402, 314, 892, 9364, 334, 6, 909, 680, 199, 318, 1218, 63, 6480, 63, 785, 8, 1100, 12, 809, 1086, 12, 8207, 12, 21143, 12, 536, 304, 272, 327, 2790, 892, 9364, 272, 9364, 275, 20575, 14, 576, 14, 6480, 397, 14, 1222, 8, 354, 9, 339, 327, 4155, 282, 9364, 687, 282, 769, 402, 809, 1086, 15, 6929, 15, 4309, 14, 272, 9364, 14, 504, 63, 647, 576, 8, 21505, 12, 8207, 12, 21143, 9, 339, 327, 6162, 9364, 3400, 2410, 7791, 8292, 14, 272, 9364, 14, 873, 342, 339, 687, 20575, 63, 9975, 492, 909, 63, 1208, 272, 372, 909, 63, 1208, 14, 785, 63, 576, 63, 525, 8, 1100, 12, 9364, 12, 4182, 29, 403, 9, 199, 199, 3, 437, 7437, 3486, 298, 9528, 2, 4744, 14, 199, 3, 15175, 83, 2877, 11960, 1183, 1846, 12759, 4730, 543, 21143, 14, 199, 3, 1803, 282, 769, 402, 314, 892, 21143, 334, 513, 402, 221, 5548, 9, 199, 3, 199, 3, 809, 84, 12215, 17, 2263, 7758, 12759, 769, 334, 513, 402, 12759, 4918, 680, 199, 3, 809, 84, 12215, 18, 2263, 16707, 12759, 769, 334, 513, 402, 12759, 4918, 680, 199, 3, 6876, 2263, 10560, 282, 4438, 334, 2246, 1253, 2061, 787, 6876, 680, 199, 3, 18761, 1915, 2263, 1010, 1884, 314, 3293, 402, 314, 8870, 8, 83, 680, 199, 3, 199, 3, 3390, 26, 2047, 883, 663, 809, 84, 12215, 17, 370, 282, 2849, 12759, 1478, 370, 1218, 199, 3, 755, 282, 13758, 15, 7848, 402, 21143, 14, 199, 3, 3390, 26, 982, 3865, 12759, 4280, 769, 787, 314, 2011, 2582, 2985, 1172, 199, 3, 755, 370, 1172, 737, 5210, 499, 14971, 14, 199, 318, 1218, 1906, 823, 8, 1884, 12215, 17, 12, 809, 84, 12215, 18, 12, 6876, 29, 797, 12, 18761, 1915, 29, 797, 304, 272, 21143, 275, 942, 339, 340, 440, 809, 84, 12215, 17, 503, 440, 809, 84, 12215, 18, 26, 267, 372, 488, 339, 340, 822, 8, 1884, 12215, 17, 9, 665, 499, 436, 822, 8, 1884, 12215, 18, 9, 665, 499, 26, 267, 372, 488, 339, 13758, 275, 756, 272, 340, 334, 552, 8, 1884, 12215, 17, 9, 1137, 822, 8, 1884, 12215, 18, 2298, 267, 340, 334, 552, 8, 1884, 12215, 17, 9, 508, 413, 436, 822, 8, 1884, 12215, 18, 9, 690, 413, 304, 288, 13758, 275, 715, 267, 587, 26, 288, 372, 488, 339, 3141, 275, 822, 8, 1884, 12215, 18, 9, 339, 340, 6876, 26, 267, 327, 699, 5562, 314, 1343, 543, 314, 1284, 14, 267, 340, 18761, 1915, 26, 288, 8870, 275, 359, 355, 809, 84, 12215, 17, 59, 16, 467, 355, 809, 84, 12215, 18, 59, 16, 467, 355, 809, 84, 12215, 18, 59, 2923, 446, 413, 2677, 288, 340, 440, 13758, 26, 355, 8870, 14, 740, 8, 1884, 12215, 17, 59, 2923, 446, 413, 566, 288, 21143, 14, 740, 8, 1409, 9, 398, 587, 26, 288, 8870, 275, 359, 1884, 12215, 18, 59, 16, 467, 809, 84, 12215, 17, 59, 16, 2677, 288, 340, 440, 13758, 26, 355, 8870, 14, 740, 8, 1884, 12215, 17, 59, 2923, 446, 413, 566, 288, 8870, 14, 740, 8, 1884, 12215, 18, 59, 2923, 446, 413, 566, 288, 21143, 14, 740, 8, 1409, 9, 339, 327, 699, 5562, 314, 4618, 402, 314, 21143, 14, 272, 367, 1967, 315, 1425, 8, 2923, 446, 413, 304, 267, 340, 18761, 1915, 26, 288, 340, 13758, 26, 355, 8870, 275, 359, 1884, 12215, 18, 59, 1507, 467, 809, 84, 12215, 17, 59, 16, 467, 809, 84, 12215, 18, 59, 1507, 435, 413, 2677, 288, 587, 26, 355, 8870, 275, 359, 1884, 12215, 18, 59, 1507, 467, 809, 84, 12215, 17, 59, 1507, 467, 490, 809, 84, 12215, 17, 59, 1507, 435, 413, 467, 809, 84, 12215, 18, 59, 1507, 435, 413, 2677, 288, 21143, 14, 740, 8, 1409, 9, 267, 587, 26, 288, 340, 13758, 26, 355, 8870, 275, 359, 1884, 12215, 17, 59, 16, 467, 809, 84, 12215, 18, 59, 1507, 467, 809, 84, 12215, 18, 59, 1507, 435, 413, 2677, 288, 587, 26, 355, 8870, 275, 359, 1884, 12215, 17, 59, 1507, 467, 809, 84, 12215, 18, 59, 1507, 467, 490, 809, 84, 12215, 18, 59, 1507, 435, 413, 467, 809, 84, 12215, 17, 59, 1507, 435, 413, 2677, 288, 21143, 14, 740, 8, 1409, 9, 339, 372, 21143, 199, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
gugahoi/maraschino
lib/sqlalchemy/orm/scoping.py
14
4561
# orm/scoping.py # Copyright (C) 2005-2011 the SQLAlchemy authors and contributors <see AUTHORS file> # # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php from sqlalchemy import exc as sa_exc from sqlalchemy.util import ScopedRegistry, ThreadLocalRegistry, warn from sqlalchemy.orm import class_mapper from sqlalchemy.orm import exc as orm_exc from sqlalchemy.orm.session import Session __all__ = ['ScopedSession'] class ScopedSession(object): """Provides thread-local management of Sessions. Typical invocation is via the :func:`.scoped_session` function:: Session = scoped_session(sessionmaker()) The internal registry is accessible, and by default is an instance of :class:`.ThreadLocalRegistry`. See also: :ref:`unitofwork_contextual`. """ def __init__(self, session_factory, scopefunc=None): self.session_factory = session_factory if scopefunc: self.registry = ScopedRegistry(session_factory, scopefunc) else: self.registry = ThreadLocalRegistry(session_factory) def __call__(self, **kwargs): if kwargs: scope = kwargs.pop('scope', False) if scope is not None: if self.registry.has(): raise sa_exc.InvalidRequestError("Scoped session is already present; " "no new arguments may be specified.") else: sess = self.session_factory(**kwargs) self.registry.set(sess) return sess else: return self.session_factory(**kwargs) else: return self.registry() def remove(self): """Dispose of the current contextual session.""" if self.registry.has(): self.registry().close() self.registry.clear() def configure(self, **kwargs): """reconfigure the sessionmaker used by this ScopedSession.""" if self.registry.has(): warn('At least one scoped session is already present. ' ' configure() can not affect sessions that have ' 'already been created.') self.session_factory.configure(**kwargs) def query_property(self, query_cls=None): """return a class property which produces a `Query` object against the class when called. e.g.:: Session = scoped_session(sessionmaker()) class MyClass(object): query = Session.query_property() # after mappers are defined result = MyClass.query.filter(MyClass.name=='foo').all() Produces instances of the session's configured query class by default. To override and use a custom implementation, provide a ``query_cls`` callable. The callable will be invoked with the class's mapper as a positional argument and a session keyword argument. There is no limit to the number of query properties placed on a class. """ class query(object): def __get__(s, instance, owner): try: mapper = class_mapper(owner) if mapper: if query_cls: # custom query class return query_cls(mapper, session=self.registry()) else: # session's configured query class return self.registry().query(mapper) except orm_exc.UnmappedClassError: return None return query() def instrument(name): def do(self, *args, **kwargs): return getattr(self.registry(), name)(*args, **kwargs) return do for meth in Session.public_methods: setattr(ScopedSession, meth, instrument(meth)) def makeprop(name): def set(self, attr): setattr(self.registry(), name, attr) def get(self): return getattr(self.registry(), name) return property(get, set) for prop in ('bind', 'dirty', 'deleted', 'new', 'identity_map', 'is_active', 'autoflush'): setattr(ScopedSession, prop, makeprop(prop)) def clslevel(name): def do(cls, *args, **kwargs): return getattr(Session, name)(*args, **kwargs) return classmethod(do) for prop in ('close_all', 'object_session', 'identity_key'): setattr(ScopedSession, prop, clslevel(prop))
mit
[ 3, 9813, 15, 20845, 4073, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 8128, 314, 14303, 11462, 436, 8417, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 14303, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 504, 8335, 492, 3178, 465, 2937, 63, 2804, 199, 504, 8335, 14, 1974, 492, 20488, 68, 10899, 12, 11086, 5339, 10899, 12, 7987, 199, 504, 8335, 14, 1025, 492, 1021, 63, 7153, 199, 504, 8335, 14, 1025, 492, 3178, 465, 9813, 63, 2804, 199, 504, 8335, 14, 1025, 14, 1730, 492, 8596, 421, 199, 363, 452, 363, 275, 788, 7812, 68, 4434, 418, 421, 199, 533, 20488, 68, 4434, 8, 785, 304, 272, 408, 17473, 2462, 13, 1832, 10041, 402, 428, 30414, 14, 2286, 29267, 19569, 365, 4799, 314, 520, 1532, 5026, 23254, 63, 1730, 64, 272, 805, 447, 1362, 489, 8596, 275, 27582, 63, 1730, 8, 1730, 14367, 1012, 339, 710, 5007, 7086, 365, 17909, 12, 272, 436, 701, 849, 365, 376, 1256, 402, 520, 533, 5026, 4436, 5339, 10899, 2313, 339, 1666, 2597, 26, 520, 1121, 1705, 3248, 1618, 800, 63, 1100, 1061, 2313, 339, 408, 339, 347, 636, 826, 721, 277, 12, 2351, 63, 3702, 12, 4194, 1532, 29, 403, 304, 267, 291, 14, 1730, 63, 3702, 275, 2351, 63, 3702, 267, 340, 4194, 1532, 26, 288, 291, 14, 5189, 275, 20488, 68, 10899, 8, 1730, 63, 3702, 12, 4194, 1532, 9, 267, 587, 26, 288, 291, 14, 5189, 275, 11086, 5339, 10899, 8, 1730, 63, 3702, 9, 339, 347, 636, 1250, 721, 277, 12, 1011, 958, 304, 267, 340, 2074, 26, 288, 4194, 275, 2074, 14, 1935, 360, 2645, 297, 756, 9, 288, 340, 4194, 365, 440, 488, 26, 355, 340, 291, 14, 5189, 14, 1989, 837, 490, 746, 2937, 63, 2804, 14, 26585, 480, 7812, 68, 2351, 365, 2575, 3451, 27, 298, 8105, 298, 889, 892, 2368, 1443, 506, 2013, 2685, 355, 587, 26, 490, 4043, 275, 291, 14, 1730, 63, 3702, 3682, 958, 9, 490, 291, 14, 5189, 14, 409, 8, 5480, 9, 490, 372, 4043, 288, 587, 26, 355, 372, 291, 14, 1730, 63, 3702, 3682, 958, 9, 267, 587, 26, 288, 372, 291, 14, 5189, 342, 339, 347, 2813, 8, 277, 304, 267, 408, 15613, 402, 314, 1453, 1067, 1061, 2351, 1041, 398, 340, 291, 14, 5189, 14, 1989, 837, 288, 291, 14, 5189, 1252, 1600, 342, 267, 291, 14, 5189, 14, 3584, 342, 339, 347, 7908, 8, 277, 12, 1011, 958, 304, 267, 408, 264, 6472, 314, 2351, 14367, 1202, 701, 642, 20488, 68, 4434, 1041, 398, 340, 291, 14, 5189, 14, 1989, 837, 288, 7987, 360, 1271, 5210, 1373, 27582, 2351, 365, 2575, 3451, 14, 283, 1993, 283, 7908, 342, 883, 440, 12787, 12184, 626, 1172, 283, 1993, 283, 14039, 2757, 2737, 2659, 398, 291, 14, 1730, 63, 3702, 14, 6472, 3682, 958, 9, 339, 347, 1827, 63, 1829, 8, 277, 12, 1827, 63, 1886, 29, 403, 304, 267, 408, 1107, 282, 1021, 3324, 1314, 16904, 282, 658, 3227, 64, 909, 6169, 314, 267, 1021, 1380, 2797, 14, 398, 325, 14, 71, 28383, 953, 8596, 275, 27582, 63, 1730, 8, 1730, 14367, 1012, 953, 1021, 4932, 2543, 8, 785, 304, 355, 1827, 275, 8596, 14, 1131, 63, 1829, 342, 953, 327, 2410, 7796, 83, 787, 3247, 288, 754, 275, 4932, 2543, 14, 1131, 14, 1541, 8, 5713, 2543, 14, 354, 6803, 1421, 1959, 452, 342, 398, 2165, 10569, 4454, 402, 314, 2351, 1159, 7526, 1827, 1021, 701, 267, 849, 14, 221, 4005, 4278, 436, 675, 282, 3537, 4514, 12, 5647, 267, 282, 1124, 1131, 63, 1886, 1040, 4550, 14, 221, 710, 4550, 911, 506, 10302, 543, 267, 314, 1021, 1159, 7796, 465, 282, 11333, 1423, 436, 282, 2351, 267, 4252, 1423, 14, 398, 6006, 365, 949, 2304, 370, 314, 1329, 402, 1827, 4382, 15090, 641, 267, 282, 1021, 14, 398, 408, 267, 1021, 1827, 8, 785, 304, 288, 347, 636, 362, 721, 83, 12, 1256, 12, 5771, 304, 355, 862, 26, 490, 7796, 275, 1021, 63, 7153, 8, 4597, 9, 490, 340, 7796, 26, 717, 340, 1827, 63, 1886, 26, 1169, 327, 3537, 1827, 1021, 1169, 372, 1827, 63, 1886, 8, 7153, 12, 2351, 29, 277, 14, 5189, 1012, 717, 587, 26, 1169, 327, 2351, 1159, 7526, 1827, 1021, 1169, 372, 291, 14, 5189, 1252, 1131, 8, 7153, 9, 355, 871, 9813, 63, 2804, 14, 1358, 11663, 2543, 547, 26, 490, 372, 488, 267, 372, 1827, 342, 199, 199, 318, 14498, 8, 354, 304, 272, 347, 886, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 2519, 8, 277, 14, 5189, 1062, 536, 25967, 589, 12, 1011, 958, 9, 272, 372, 886, 199, 509, 12750, 315, 8596, 14, 3455, 63, 2474, 26, 272, 5371, 8, 7812, 68, 4434, 12, 12750, 12, 14498, 8, 5247, 430, 199, 199, 318, 1852, 4469, 8, 354, 304, 272, 347, 663, 8, 277, 12, 1921, 304, 267, 5371, 8, 277, 14, 5189, 1062, 536, 12, 1921, 9, 272, 347, 664, 8, 277, 304, 267, 372, 2519, 8, 277, 14, 5189, 1062, 536, 9, 272, 372, 3324, 8, 362, 12, 663, 9, 199, 509, 5931, 315, 661, 3409, 297, 283, 8799, 297, 283, 6062, 297, 283, 1222, 297, 283, 5582, 63, 1130, 297, 283, 374, 63, 2682, 297, 283, 2495, 4939, 735, 272, 5371, 8, 7812, 68, 4434, 12, 5931, 12, 1852, 4469, 8, 4469, 430, 199, 199, 318, 843, 1896, 8, 354, 304, 272, 347, 886, 8, 1886, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 2519, 8, 4434, 12, 536, 25967, 589, 12, 1011, 958, 9, 272, 372, 18990, 8, 1117, 9, 199, 509, 5931, 315, 661, 1600, 63, 452, 297, 283, 785, 63, 1730, 297, 283, 5582, 63, 498, 735, 272, 5371, 8, 7812, 68, 4434, 12, 5931, 12, 843, 1896, 8, 4469, 430, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 9813, 15, 20845, 4073, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 8128, 314, 14303, 11462, 436, 8417, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 14303, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 504, 8335, 492, 3178, 465, 2937, 63, 2804, 199, 504, 8335, 14, 1974, 492, 20488, 68, 10899, 12, 11086, 5339, 10899, 12, 7987, 199, 504, 8335, 14, 1025, 492, 1021, 63, 7153, 199, 504, 8335, 14, 1025, 492, 3178, 465, 9813, 63, 2804, 199, 504, 8335, 14, 1025, 14, 1730, 492, 8596, 421, 199, 363, 452, 363, 275, 788, 7812, 68, 4434, 418, 421, 199, 533, 20488, 68, 4434, 8, 785, 304, 272, 408, 17473, 2462, 13, 1832, 10041, 402, 428, 30414, 14, 2286, 29267, 19569, 365, 4799, 314, 520, 1532, 5026, 23254, 63, 1730, 64, 272, 805, 447, 1362, 489, 8596, 275, 27582, 63, 1730, 8, 1730, 14367, 1012, 339, 710, 5007, 7086, 365, 17909, 12, 272, 436, 701, 849, 365, 376, 1256, 402, 520, 533, 5026, 4436, 5339, 10899, 2313, 339, 1666, 2597, 26, 520, 1121, 1705, 3248, 1618, 800, 63, 1100, 1061, 2313, 339, 408, 339, 347, 636, 826, 721, 277, 12, 2351, 63, 3702, 12, 4194, 1532, 29, 403, 304, 267, 291, 14, 1730, 63, 3702, 275, 2351, 63, 3702, 267, 340, 4194, 1532, 26, 288, 291, 14, 5189, 275, 20488, 68, 10899, 8, 1730, 63, 3702, 12, 4194, 1532, 9, 267, 587, 26, 288, 291, 14, 5189, 275, 11086, 5339, 10899, 8, 1730, 63, 3702, 9, 339, 347, 636, 1250, 721, 277, 12, 1011, 958, 304, 267, 340, 2074, 26, 288, 4194, 275, 2074, 14, 1935, 360, 2645, 297, 756, 9, 288, 340, 4194, 365, 440, 488, 26, 355, 340, 291, 14, 5189, 14, 1989, 837, 490, 746, 2937, 63, 2804, 14, 26585, 480, 7812, 68, 2351, 365, 2575, 3451, 27, 298, 8105, 298, 889, 892, 2368, 1443, 506, 2013, 2685, 355, 587, 26, 490, 4043, 275, 291, 14, 1730, 63, 3702, 3682, 958, 9, 490, 291, 14, 5189, 14, 409, 8, 5480, 9, 490, 372, 4043, 288, 587, 26, 355, 372, 291, 14, 1730, 63, 3702, 3682, 958, 9, 267, 587, 26, 288, 372, 291, 14, 5189, 342, 339, 347, 2813, 8, 277, 304, 267, 408, 15613, 402, 314, 1453, 1067, 1061, 2351, 1041, 398, 340, 291, 14, 5189, 14, 1989, 837, 288, 291, 14, 5189, 1252, 1600, 342, 267, 291, 14, 5189, 14, 3584, 342, 339, 347, 7908, 8, 277, 12, 1011, 958, 304, 267, 408, 264, 6472, 314, 2351, 14367, 1202, 701, 642, 20488, 68, 4434, 1041, 398, 340, 291, 14, 5189, 14, 1989, 837, 288, 7987, 360, 1271, 5210, 1373, 27582, 2351, 365, 2575, 3451, 14, 283, 1993, 283, 7908, 342, 883, 440, 12787, 12184, 626, 1172, 283, 1993, 283, 14039, 2757, 2737, 2659, 398, 291, 14, 1730, 63, 3702, 14, 6472, 3682, 958, 9, 339, 347, 1827, 63, 1829, 8, 277, 12, 1827, 63, 1886, 29, 403, 304, 267, 408, 1107, 282, 1021, 3324, 1314, 16904, 282, 658, 3227, 64, 909, 6169, 314, 267, 1021, 1380, 2797, 14, 398, 325, 14, 71, 28383, 953, 8596, 275, 27582, 63, 1730, 8, 1730, 14367, 1012, 953, 1021, 4932, 2543, 8, 785, 304, 355, 1827, 275, 8596, 14, 1131, 63, 1829, 342, 953, 327, 2410, 7796, 83, 787, 3247, 288, 754, 275, 4932, 2543, 14, 1131, 14, 1541, 8, 5713, 2543, 14, 354, 6803, 1421, 1959, 452, 342, 398, 2165, 10569, 4454, 402, 314, 2351, 1159, 7526, 1827, 1021, 701, 267, 849, 14, 221, 4005, 4278, 436, 675, 282, 3537, 4514, 12, 5647, 267, 282, 1124, 1131, 63, 1886, 1040, 4550, 14, 221, 710, 4550, 911, 506, 10302, 543, 267, 314, 1021, 1159, 7796, 465, 282, 11333, 1423, 436, 282, 2351, 267, 4252, 1423, 14, 398, 6006, 365, 949, 2304, 370, 314, 1329, 402, 1827, 4382, 15090, 641, 267, 282, 1021, 14, 398, 408, 267, 1021, 1827, 8, 785, 304, 288, 347, 636, 362, 721, 83, 12, 1256, 12, 5771, 304, 355, 862, 26, 490, 7796, 275, 1021, 63, 7153, 8, 4597, 9, 490, 340, 7796, 26, 717, 340, 1827, 63, 1886, 26, 1169, 327, 3537, 1827, 1021, 1169, 372, 1827, 63, 1886, 8, 7153, 12, 2351, 29, 277, 14, 5189, 1012, 717, 587, 26, 1169, 327, 2351, 1159, 7526, 1827, 1021, 1169, 372, 291, 14, 5189, 1252, 1131, 8, 7153, 9, 355, 871, 9813, 63, 2804, 14, 1358, 11663, 2543, 547, 26, 490, 372, 488, 267, 372, 1827, 342, 199, 199, 318, 14498, 8, 354, 304, 272, 347, 886, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 2519, 8, 277, 14, 5189, 1062, 536, 25967, 589, 12, 1011, 958, 9, 272, 372, 886, 199, 509, 12750, 315, 8596, 14, 3455, 63, 2474, 26, 272, 5371, 8, 7812, 68, 4434, 12, 12750, 12, 14498, 8, 5247, 430, 199, 199, 318, 1852, 4469, 8, 354, 304, 272, 347, 663, 8, 277, 12, 1921, 304, 267, 5371, 8, 277, 14, 5189, 1062, 536, 12, 1921, 9, 272, 347, 664, 8, 277, 304, 267, 372, 2519, 8, 277, 14, 5189, 1062, 536, 9, 272, 372, 3324, 8, 362, 12, 663, 9, 199, 509, 5931, 315, 661, 3409, 297, 283, 8799, 297, 283, 6062, 297, 283, 1222, 297, 283, 5582, 63, 1130, 297, 283, 374, 63, 2682, 297, 283, 2495, 4939, 735, 272, 5371, 8, 7812, 68, 4434, 12, 5931, 12, 1852, 4469, 8, 4469, 430, 199, 199, 318, 843, 1896, 8, 354, 304, 272, 347, 886, 8, 1886, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 2519, 8, 4434, 12, 536, 25967, 589, 12, 1011, 958, 9, 272, 372, 18990, 8, 1117, 9, 199, 509, 5931, 315, 661, 1600, 63, 452, 297, 283, 785, 63, 1730, 297, 283, 5582, 63, 498, 735, 272, 5371, 8, 7812, 68, 4434, 12, 5931, 12, 843, 1896, 8, 4469, 430, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ping/youtube-dl
youtube_dl/extractor/ruv.py
49
3359
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( determine_ext, unified_timestamp, ) class RuvIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ruv\.is/(?:sarpurinn/[^/]+|node)/(?P<id>[^/]+(?:/\d+)?)' _TESTS = [{ # m3u8 'url': 'http://ruv.is/sarpurinn/ruv-aukaras/fh-valur/20170516', 'md5': '66347652f4e13e71936817102acc1724', 'info_dict': { 'id': '1144499', 'display_id': 'fh-valur/20170516', 'ext': 'mp4', 'title': 'FH - Valur', 'description': 'Bein útsending frá 3. leik FH og Vals í úrslitum Olísdeildar karla í handbolta.', 'timestamp': 1494963600, 'upload_date': '20170516', }, }, { # mp3 'url': 'http://ruv.is/sarpurinn/ras-2/morgunutvarpid/20170619', 'md5': '395ea250c8a13e5fdb39d4670ef85378', 'info_dict': { 'id': '1153630', 'display_id': 'morgunutvarpid/20170619', 'ext': 'mp3', 'title': 'Morgunútvarpið', 'description': 'md5:a4cf1202c0a1645ca096b06525915418', 'timestamp': 1497855000, 'upload_date': '20170619', }, }, { 'url': 'http://ruv.is/sarpurinn/ruv/frettir/20170614', 'only_matching': True, }, { 'url': 'http://www.ruv.is/node/1151854', 'only_matching': True, }, { 'url': 'http://ruv.is/sarpurinn/klippa/secret-soltice-hefst-a-morgun', 'only_matching': True, }, { 'url': 'http://ruv.is/sarpurinn/ras-1/morgunvaktin/20170619', 'only_matching': True, }] def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) title = self._og_search_title(webpage) FIELD_RE = r'video\.%s\s*=\s*(["\'])(?P<url>(?:(?!\1).)+)\1' media_url = self._html_search_regex( FIELD_RE % 'src', webpage, 'video URL', group='url') video_id = self._search_regex( r'<link\b[^>]+\bhref=["\']https?://www\.ruv\.is/node/(\d+)', webpage, 'video id', default=display_id) ext = determine_ext(media_url) if ext == 'm3u8': formats = self._extract_m3u8_formats( media_url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls') elif ext == 'mp3': formats = [{ 'format_id': 'mp3', 'url': media_url, 'vcodec': 'none', }] else: formats = [{ 'url': media_url, }] description = self._og_search_description(webpage, default=None) thumbnail = self._og_search_thumbnail( webpage, default=None) or self._search_regex( FIELD_RE % 'poster', webpage, 'thumbnail', fatal=False) timestamp = unified_timestamp(self._html_search_meta( 'article:published_time', webpage, 'timestamp', fatal=False)) return { 'id': video_id, 'display_id': display_id, 'title': title, 'description': description, 'thumbnail': thumbnail, 'timestamp': timestamp, 'formats': formats, }
unlicense
[ 3, 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 6705, 63, 832, 12, 272, 25344, 63, 3954, 12, 199, 9, 421, 199, 533, 820, 9154, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 6558, 86, 4537, 374, 32576, 29637, 6653, 262, 78, 15, 26285, 92, 932, 2447, 2229, 48, 28, 344, 26906, 5169, 6307, 68, 19544, 3171, 272, 485, 7569, 275, 8910, 267, 327, 333, 19, 85, 24, 267, 283, 633, 356, 283, 1014, 921, 6558, 86, 14, 374, 15, 29637, 6653, 262, 78, 15, 6558, 86, 13, 65, 3210, 285, 305, 15, 12853, 13, 637, 300, 15, 10680, 1717, 975, 297, 267, 283, 1064, 21, 356, 283, 1272, 1082, 2114, 2528, 70, 20, 69, 969, 69, 30003, 10997, 1196, 7759, 5470, 1196, 1194, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 845, 18078, 1020, 297, 288, 283, 2918, 63, 344, 356, 283, 12853, 13, 637, 300, 15, 10680, 1717, 975, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 32259, 446, 26263, 300, 297, 288, 283, 1802, 356, 283, 3655, 262, 13333, 119, 84, 24450, 9513, 11302, 650, 14, 1026, 3258, 481, 40, 312, 71, 812, 2551, 13333, 256, 13333, 119, 2393, 1051, 453, 593, 76, 13676, 83, 271, 668, 285, 1022, 285, 416, 13333, 256, 4926, 23484, 502, 3130, 288, 283, 3954, 356, 28528, 18105, 11035, 12, 288, 283, 5064, 63, 602, 356, 283, 10680, 1717, 975, 297, 267, 1660, 272, 1660, 469, 267, 327, 6118, 19, 267, 283, 633, 356, 283, 1014, 921, 6558, 86, 14, 374, 15, 29637, 6653, 262, 78, 15, 6360, 13, 18, 15, 77, 1308, 324, 337, 1391, 3150, 15, 10680, 1690, 1167, 297, 267, 283, 1064, 21, 356, 283, 14099, 4489, 7991, 67, 24, 65, 969, 69, 21, 29636, 1355, 68, 16226, 16, 2829, 2426, 12046, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 7680, 1344, 1216, 297, 288, 283, 2918, 63, 344, 356, 283, 77, 1308, 324, 337, 1391, 3150, 15, 10680, 1690, 1167, 297, 288, 283, 832, 356, 283, 311, 19, 297, 288, 283, 1213, 356, 283, 45, 1308, 324, 24602, 84, 1391, 1038, 29769, 297, 288, 283, 1802, 356, 283, 1064, 21, 26, 65, 20, 2177, 713, 996, 67, 16, 65, 8982, 21, 696, 9211, 66, 21254, 11990, 10478, 1085, 297, 288, 283, 3954, 356, 28528, 2277, 1229, 1493, 12, 288, 283, 5064, 63, 602, 356, 283, 10680, 1690, 1167, 297, 267, 1660, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 6558, 86, 14, 374, 15, 29637, 6653, 262, 78, 15, 6558, 86, 15, 70, 3292, 280, 82, 15, 10680, 1690, 1079, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 6558, 86, 14, 374, 15, 932, 15, 7680, 1085, 1477, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 6558, 86, 14, 374, 15, 29637, 6653, 262, 78, 15, 75, 3587, 387, 15, 4731, 13, 7873, 3548, 13, 426, 15624, 13, 65, 13, 77, 1308, 324, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 6558, 86, 14, 374, 15, 29637, 6653, 262, 78, 15, 6360, 13, 17, 15, 77, 1308, 324, 86, 1151, 1346, 15, 10680, 1690, 1167, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 14877, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 2929, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 398, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 2929, 63, 344, 9, 398, 2538, 275, 291, 423, 974, 63, 1733, 63, 1213, 8, 12022, 9, 398, 26130, 63, 907, 275, 519, 7, 3722, 60, 4111, 83, 60, 83, 23440, 83, 10, 779, 3212, 1105, 2229, 48, 28, 633, 30, 5169, 2229, 12525, 17, 680, 6393, 2862, 17, 7, 398, 5898, 63, 633, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 26130, 63, 907, 450, 283, 2164, 297, 9248, 12, 283, 3722, 2851, 297, 1572, 534, 633, 358, 398, 3991, 63, 344, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 7601, 1073, 60, 66, 17478, 24621, 66, 6399, 6270, 26889, 2859, 14144, 1544, 4537, 6558, 86, 4537, 374, 15, 932, 15, 2961, 68, 14705, 288, 9248, 12, 283, 3722, 1305, 297, 849, 29, 2918, 63, 344, 9, 398, 1599, 275, 6705, 63, 832, 8, 4603, 63, 633, 9, 398, 340, 1599, 508, 283, 77, 19, 85, 24, 356, 288, 6752, 275, 291, 423, 5005, 63, 77, 19, 85, 24, 63, 6321, 8, 355, 5898, 63, 633, 12, 3991, 63, 344, 12, 283, 311, 20, 297, 2397, 63, 3922, 534, 77, 19, 85, 24, 63, 6106, 297, 355, 333, 19, 85, 24, 63, 344, 534, 30252, 358, 267, 916, 1599, 508, 283, 311, 19, 356, 288, 6752, 275, 8910, 355, 283, 908, 63, 344, 356, 283, 311, 19, 297, 355, 283, 633, 356, 5898, 63, 633, 12, 355, 283, 86, 9276, 356, 283, 3592, 297, 288, 14877, 267, 587, 26, 288, 6752, 275, 8910, 355, 283, 633, 356, 5898, 63, 633, 12, 288, 14877, 398, 1369, 275, 291, 423, 974, 63, 1733, 63, 1802, 8, 12022, 12, 849, 29, 403, 9, 267, 10062, 275, 291, 423, 974, 63, 1733, 63, 8311, 8, 288, 9248, 12, 849, 29, 403, 9, 503, 291, 423, 1733, 63, 3821, 8, 288, 26130, 63, 907, 450, 283, 20801, 297, 9248, 12, 283, 8311, 297, 14294, 29, 797, 9, 267, 4913, 275, 25344, 63, 3954, 8, 277, 423, 1360, 63, 1733, 63, 2024, 8, 288, 283, 6934, 26, 8987, 63, 521, 297, 9248, 12, 283, 3954, 297, 14294, 29, 797, 430, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 2918, 63, 344, 356, 2929, 63, 344, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 1802, 356, 1369, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 3954 ]
[ 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 6705, 63, 832, 12, 272, 25344, 63, 3954, 12, 199, 9, 421, 199, 533, 820, 9154, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 6558, 86, 4537, 374, 32576, 29637, 6653, 262, 78, 15, 26285, 92, 932, 2447, 2229, 48, 28, 344, 26906, 5169, 6307, 68, 19544, 3171, 272, 485, 7569, 275, 8910, 267, 327, 333, 19, 85, 24, 267, 283, 633, 356, 283, 1014, 921, 6558, 86, 14, 374, 15, 29637, 6653, 262, 78, 15, 6558, 86, 13, 65, 3210, 285, 305, 15, 12853, 13, 637, 300, 15, 10680, 1717, 975, 297, 267, 283, 1064, 21, 356, 283, 1272, 1082, 2114, 2528, 70, 20, 69, 969, 69, 30003, 10997, 1196, 7759, 5470, 1196, 1194, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 845, 18078, 1020, 297, 288, 283, 2918, 63, 344, 356, 283, 12853, 13, 637, 300, 15, 10680, 1717, 975, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 32259, 446, 26263, 300, 297, 288, 283, 1802, 356, 283, 3655, 262, 13333, 119, 84, 24450, 9513, 11302, 650, 14, 1026, 3258, 481, 40, 312, 71, 812, 2551, 13333, 256, 13333, 119, 2393, 1051, 453, 593, 76, 13676, 83, 271, 668, 285, 1022, 285, 416, 13333, 256, 4926, 23484, 502, 3130, 288, 283, 3954, 356, 28528, 18105, 11035, 12, 288, 283, 5064, 63, 602, 356, 283, 10680, 1717, 975, 297, 267, 1660, 272, 1660, 469, 267, 327, 6118, 19, 267, 283, 633, 356, 283, 1014, 921, 6558, 86, 14, 374, 15, 29637, 6653, 262, 78, 15, 6360, 13, 18, 15, 77, 1308, 324, 337, 1391, 3150, 15, 10680, 1690, 1167, 297, 267, 283, 1064, 21, 356, 283, 14099, 4489, 7991, 67, 24, 65, 969, 69, 21, 29636, 1355, 68, 16226, 16, 2829, 2426, 12046, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 7680, 1344, 1216, 297, 288, 283, 2918, 63, 344, 356, 283, 77, 1308, 324, 337, 1391, 3150, 15, 10680, 1690, 1167, 297, 288, 283, 832, 356, 283, 311, 19, 297, 288, 283, 1213, 356, 283, 45, 1308, 324, 24602, 84, 1391, 1038, 29769, 297, 288, 283, 1802, 356, 283, 1064, 21, 26, 65, 20, 2177, 713, 996, 67, 16, 65, 8982, 21, 696, 9211, 66, 21254, 11990, 10478, 1085, 297, 288, 283, 3954, 356, 28528, 2277, 1229, 1493, 12, 288, 283, 5064, 63, 602, 356, 283, 10680, 1690, 1167, 297, 267, 1660, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 6558, 86, 14, 374, 15, 29637, 6653, 262, 78, 15, 6558, 86, 15, 70, 3292, 280, 82, 15, 10680, 1690, 1079, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 6558, 86, 14, 374, 15, 932, 15, 7680, 1085, 1477, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 6558, 86, 14, 374, 15, 29637, 6653, 262, 78, 15, 75, 3587, 387, 15, 4731, 13, 7873, 3548, 13, 426, 15624, 13, 65, 13, 77, 1308, 324, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 6558, 86, 14, 374, 15, 29637, 6653, 262, 78, 15, 6360, 13, 17, 15, 77, 1308, 324, 86, 1151, 1346, 15, 10680, 1690, 1167, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 14877, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 2929, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 398, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 2929, 63, 344, 9, 398, 2538, 275, 291, 423, 974, 63, 1733, 63, 1213, 8, 12022, 9, 398, 26130, 63, 907, 275, 519, 7, 3722, 60, 4111, 83, 60, 83, 23440, 83, 10, 779, 3212, 1105, 2229, 48, 28, 633, 30, 5169, 2229, 12525, 17, 680, 6393, 2862, 17, 7, 398, 5898, 63, 633, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 26130, 63, 907, 450, 283, 2164, 297, 9248, 12, 283, 3722, 2851, 297, 1572, 534, 633, 358, 398, 3991, 63, 344, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 7601, 1073, 60, 66, 17478, 24621, 66, 6399, 6270, 26889, 2859, 14144, 1544, 4537, 6558, 86, 4537, 374, 15, 932, 15, 2961, 68, 14705, 288, 9248, 12, 283, 3722, 1305, 297, 849, 29, 2918, 63, 344, 9, 398, 1599, 275, 6705, 63, 832, 8, 4603, 63, 633, 9, 398, 340, 1599, 508, 283, 77, 19, 85, 24, 356, 288, 6752, 275, 291, 423, 5005, 63, 77, 19, 85, 24, 63, 6321, 8, 355, 5898, 63, 633, 12, 3991, 63, 344, 12, 283, 311, 20, 297, 2397, 63, 3922, 534, 77, 19, 85, 24, 63, 6106, 297, 355, 333, 19, 85, 24, 63, 344, 534, 30252, 358, 267, 916, 1599, 508, 283, 311, 19, 356, 288, 6752, 275, 8910, 355, 283, 908, 63, 344, 356, 283, 311, 19, 297, 355, 283, 633, 356, 5898, 63, 633, 12, 355, 283, 86, 9276, 356, 283, 3592, 297, 288, 14877, 267, 587, 26, 288, 6752, 275, 8910, 355, 283, 633, 356, 5898, 63, 633, 12, 288, 14877, 398, 1369, 275, 291, 423, 974, 63, 1733, 63, 1802, 8, 12022, 12, 849, 29, 403, 9, 267, 10062, 275, 291, 423, 974, 63, 1733, 63, 8311, 8, 288, 9248, 12, 849, 29, 403, 9, 503, 291, 423, 1733, 63, 3821, 8, 288, 26130, 63, 907, 450, 283, 20801, 297, 9248, 12, 283, 8311, 297, 14294, 29, 797, 9, 267, 4913, 275, 25344, 63, 3954, 8, 277, 423, 1360, 63, 1733, 63, 2024, 8, 288, 283, 6934, 26, 8987, 63, 521, 297, 9248, 12, 283, 3954, 297, 14294, 29, 797, 430, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 2918, 63, 344, 356, 2929, 63, 344, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 1802, 356, 1369, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 3954, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
stonegithubs/odoo
addons/stock/wizard/orderpoint_procurement.py
326
2844
# -*- 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/>. # ############################################################################## # # Order Point Method: # - Order if the virtual stock of today is bellow the min of the defined order point # import threading from openerp.osv import fields,osv from openerp.api import Environment class procurement_compute(osv.osv_memory): _name = 'procurement.orderpoint.compute' _description = 'Compute Minimum Stock Rules' def _procure_calculation_orderpoint(self, cr, uid, ids, context=None): """ @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: List of IDs selected @param context: A standard dictionary """ with Environment.manage(): proc_obj = self.pool.get('procurement.order') #As this function is in a new thread, I need to open a new cursor, because the old one may be closed new_cr = self.pool.cursor() user_obj = self.pool.get('res.users') company_id = user_obj.browse(new_cr, uid, uid, context=context).company_id.id proc_obj._procure_orderpoint_confirm(new_cr, uid, use_new_cursor=new_cr.dbname, company_id = company_id, context=context) #close the new cursor new_cr.close() return {} def procure_calculation(self, cr, uid, ids, context=None): """ @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: List of IDs selected @param context: A standard dictionary """ threaded_calculation = threading.Thread(target=self._procure_calculation_orderpoint, args=(cr, uid, ids, context)) threaded_calculation.start() return {'type': 'ir.actions.act_window_close'} # 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, 3, 199, 3, 9240, 7584, 9075, 26, 199, 3, 259, 446, 9240, 340, 314, 5791, 10952, 402, 11168, 365, 8959, 674, 314, 1748, 402, 314, 3247, 1865, 2376, 199, 3, 199, 199, 646, 5796, 199, 504, 5166, 14, 4795, 492, 1504, 12, 4795, 199, 504, 5166, 14, 1246, 492, 9711, 199, 199, 533, 16214, 63, 3357, 8, 4795, 14, 4795, 63, 4844, 304, 272, 485, 354, 275, 283, 18546, 14, 1648, 1403, 14, 3357, 7, 272, 485, 1802, 275, 283, 8564, 22466, 28406, 24259, 7, 2378, 347, 485, 4687, 608, 63, 31458, 63, 1648, 1403, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 408, 267, 768, 635, 291, 26, 710, 909, 7849, 14, 267, 768, 635, 2467, 26, 437, 3050, 3920, 267, 768, 635, 1747, 26, 2870, 402, 314, 922, 5544, 10367, 315, 267, 768, 635, 2762, 26, 3820, 402, 11449, 4895, 267, 768, 635, 1067, 26, 437, 4465, 2600, 267, 408, 267, 543, 9711, 14, 9053, 837, 288, 6499, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 18546, 14, 1648, 358, 288, 327, 2822, 642, 805, 365, 315, 282, 892, 2462, 12, 473, 1929, 370, 1551, 282, 892, 3920, 12, 2952, 314, 2269, 1373, 1443, 506, 6876, 288, 892, 63, 1556, 275, 291, 14, 2293, 14, 3937, 342, 288, 922, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 470, 14, 3707, 358, 288, 7233, 63, 344, 275, 922, 63, 1113, 14, 4570, 8, 1222, 63, 1556, 12, 1747, 12, 1747, 12, 1067, 29, 1100, 680, 4627, 63, 344, 14, 344, 288, 6499, 63, 1113, 423, 4687, 608, 63, 1648, 1403, 63, 9548, 8, 1222, 63, 1556, 12, 1747, 12, 675, 63, 1222, 63, 3937, 29, 1222, 63, 1556, 14, 13238, 12, 7233, 63, 344, 275, 7233, 63, 344, 12, 1067, 29, 1100, 9, 288, 327, 1600, 314, 892, 3920, 288, 892, 63, 1556, 14, 1600, 342, 288, 372, 1052, 339, 347, 6499, 608, 63, 31458, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 408, 267, 768, 635, 291, 26, 710, 909, 7849, 14, 267, 768, 635, 2467, 26, 437, 3050, 3920, 267, 768, 635, 1747, 26, 2870, 402, 314, 922, 5544, 10367, 315, 267, 768, 635, 2762, 26, 3820, 402, 11449, 4895, 267, 768, 635, 1067, 26, 437, 4465, 2600, 267, 408, 2728, 25396, 63, 31458, 275, 5796, 14, 4436, 8, 1375, 29, 277, 423, 4687, 608, 63, 31458, 63, 1648, 1403, 12, 1249, 2687, 1556, 12, 1747, 12, 2762, 12, 1067, 430, 267, 25396, 63, 31458, 14, 928, 342, 267, 372, 791, 466, 356, 283, 723, 14, 3723, 14, 2442, 63, 3806, 63, 1600, 936, 421, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 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, 3, 199, 3, 9240, 7584, 9075, 26, 199, 3, 259, 446, 9240, 340, 314, 5791, 10952, 402, 11168, 365, 8959, 674, 314, 1748, 402, 314, 3247, 1865, 2376, 199, 3, 199, 199, 646, 5796, 199, 504, 5166, 14, 4795, 492, 1504, 12, 4795, 199, 504, 5166, 14, 1246, 492, 9711, 199, 199, 533, 16214, 63, 3357, 8, 4795, 14, 4795, 63, 4844, 304, 272, 485, 354, 275, 283, 18546, 14, 1648, 1403, 14, 3357, 7, 272, 485, 1802, 275, 283, 8564, 22466, 28406, 24259, 7, 2378, 347, 485, 4687, 608, 63, 31458, 63, 1648, 1403, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 408, 267, 768, 635, 291, 26, 710, 909, 7849, 14, 267, 768, 635, 2467, 26, 437, 3050, 3920, 267, 768, 635, 1747, 26, 2870, 402, 314, 922, 5544, 10367, 315, 267, 768, 635, 2762, 26, 3820, 402, 11449, 4895, 267, 768, 635, 1067, 26, 437, 4465, 2600, 267, 408, 267, 543, 9711, 14, 9053, 837, 288, 6499, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 18546, 14, 1648, 358, 288, 327, 2822, 642, 805, 365, 315, 282, 892, 2462, 12, 473, 1929, 370, 1551, 282, 892, 3920, 12, 2952, 314, 2269, 1373, 1443, 506, 6876, 288, 892, 63, 1556, 275, 291, 14, 2293, 14, 3937, 342, 288, 922, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 470, 14, 3707, 358, 288, 7233, 63, 344, 275, 922, 63, 1113, 14, 4570, 8, 1222, 63, 1556, 12, 1747, 12, 1747, 12, 1067, 29, 1100, 680, 4627, 63, 344, 14, 344, 288, 6499, 63, 1113, 423, 4687, 608, 63, 1648, 1403, 63, 9548, 8, 1222, 63, 1556, 12, 1747, 12, 675, 63, 1222, 63, 3937, 29, 1222, 63, 1556, 14, 13238, 12, 7233, 63, 344, 275, 7233, 63, 344, 12, 1067, 29, 1100, 9, 288, 327, 1600, 314, 892, 3920, 288, 892, 63, 1556, 14, 1600, 342, 288, 372, 1052, 339, 347, 6499, 608, 63, 31458, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 408, 267, 768, 635, 291, 26, 710, 909, 7849, 14, 267, 768, 635, 2467, 26, 437, 3050, 3920, 267, 768, 635, 1747, 26, 2870, 402, 314, 922, 5544, 10367, 315, 267, 768, 635, 2762, 26, 3820, 402, 11449, 4895, 267, 768, 635, 1067, 26, 437, 4465, 2600, 267, 408, 2728, 25396, 63, 31458, 275, 5796, 14, 4436, 8, 1375, 29, 277, 423, 4687, 608, 63, 31458, 63, 1648, 1403, 12, 1249, 2687, 1556, 12, 1747, 12, 2762, 12, 1067, 430, 267, 25396, 63, 31458, 14, 928, 342, 267, 372, 791, 466, 356, 283, 723, 14, 3723, 14, 2442, 63, 3806, 63, 1600, 936, 421, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sameetb-cuelogic/edx-platform-test
lms/djangoapps/shoppingcart/migrations/0001_initial.py
182
12544
# -*- 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 'Order' db.create_table('shoppingcart_order', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), ('currency', self.gf('django.db.models.fields.CharField')(default='usd', max_length=8)), ('status', self.gf('django.db.models.fields.CharField')(default='cart', max_length=32)), ('purchase_time', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)), ('bill_to_first', self.gf('django.db.models.fields.CharField')(max_length=64, blank=True)), ('bill_to_last', self.gf('django.db.models.fields.CharField')(max_length=64, blank=True)), ('bill_to_street1', self.gf('django.db.models.fields.CharField')(max_length=128, blank=True)), ('bill_to_street2', self.gf('django.db.models.fields.CharField')(max_length=128, blank=True)), ('bill_to_city', self.gf('django.db.models.fields.CharField')(max_length=64, blank=True)), ('bill_to_state', self.gf('django.db.models.fields.CharField')(max_length=8, blank=True)), ('bill_to_postalcode', self.gf('django.db.models.fields.CharField')(max_length=16, blank=True)), ('bill_to_country', self.gf('django.db.models.fields.CharField')(max_length=64, blank=True)), ('bill_to_ccnum', self.gf('django.db.models.fields.CharField')(max_length=8, blank=True)), ('bill_to_cardtype', self.gf('django.db.models.fields.CharField')(max_length=32, blank=True)), ('processor_reply_dump', self.gf('django.db.models.fields.TextField')(blank=True)), )) db.send_create_signal('shoppingcart', ['Order']) # Adding model 'OrderItem' db.create_table('shoppingcart_orderitem', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('order', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['shoppingcart.Order'])), ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), ('status', self.gf('django.db.models.fields.CharField')(default='cart', max_length=32)), ('qty', self.gf('django.db.models.fields.IntegerField')(default=1)), ('unit_cost', self.gf('django.db.models.fields.DecimalField')(default=0.0, max_digits=30, decimal_places=2)), ('line_cost', self.gf('django.db.models.fields.DecimalField')(default=0.0, max_digits=30, decimal_places=2)), ('line_desc', self.gf('django.db.models.fields.CharField')(default='Misc. Item', max_length=1024)), ('currency', self.gf('django.db.models.fields.CharField')(default='usd', max_length=8)), )) db.send_create_signal('shoppingcart', ['OrderItem']) # Adding model 'PaidCourseRegistration' db.create_table('shoppingcart_paidcourseregistration', ( ('orderitem_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['shoppingcart.OrderItem'], unique=True, primary_key=True)), ('course_id', self.gf('django.db.models.fields.CharField')(max_length=128, db_index=True)), )) db.send_create_signal('shoppingcart', ['PaidCourseRegistration']) # Adding model 'CertificateItem' db.create_table('shoppingcart_certificateitem', ( ('orderitem_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['shoppingcart.OrderItem'], unique=True, primary_key=True)), ('course_id', self.gf('django.db.models.fields.CharField')(max_length=128, db_index=True)), ('course_enrollment', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['student.CourseEnrollment'])), ('mode', self.gf('django.db.models.fields.SlugField')(max_length=50)), )) db.send_create_signal('shoppingcart', ['CertificateItem']) def backwards(self, orm): # Deleting model 'Order' db.delete_table('shoppingcart_order') # Deleting model 'OrderItem' db.delete_table('shoppingcart_orderitem') # Deleting model 'PaidCourseRegistration' db.delete_table('shoppingcart_paidcourseregistration') # Deleting model 'CertificateItem' db.delete_table('shoppingcart_certificateitem') models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, 'auth.permission': { 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, 'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, 'shoppingcart.certificateitem': { 'Meta': {'object_name': 'CertificateItem', '_ormbases': ['shoppingcart.OrderItem']}, 'course_enrollment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['student.CourseEnrollment']"}), 'course_id': ('django.db.models.fields.CharField', [], {'max_length': '128', 'db_index': 'True'}), 'mode': ('django.db.models.fields.SlugField', [], {'max_length': '50'}), 'orderitem_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['shoppingcart.OrderItem']", 'unique': 'True', 'primary_key': 'True'}) }, 'shoppingcart.order': { 'Meta': {'object_name': 'Order'}, 'bill_to_cardtype': ('django.db.models.fields.CharField', [], {'max_length': '32', 'blank': 'True'}), 'bill_to_ccnum': ('django.db.models.fields.CharField', [], {'max_length': '8', 'blank': 'True'}), 'bill_to_city': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}), 'bill_to_country': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}), 'bill_to_first': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}), 'bill_to_last': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}), 'bill_to_postalcode': ('django.db.models.fields.CharField', [], {'max_length': '16', 'blank': 'True'}), 'bill_to_state': ('django.db.models.fields.CharField', [], {'max_length': '8', 'blank': 'True'}), 'bill_to_street1': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}), 'bill_to_street2': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}), 'currency': ('django.db.models.fields.CharField', [], {'default': "'usd'", 'max_length': '8'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'processor_reply_dump': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'purchase_time': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'status': ('django.db.models.fields.CharField', [], {'default': "'cart'", 'max_length': '32'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) }, 'shoppingcart.orderitem': { 'Meta': {'object_name': 'OrderItem'}, 'currency': ('django.db.models.fields.CharField', [], {'default': "'usd'", 'max_length': '8'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'line_cost': ('django.db.models.fields.DecimalField', [], {'default': '0.0', 'max_digits': '30', 'decimal_places': '2'}), 'line_desc': ('django.db.models.fields.CharField', [], {'default': "'Misc. Item'", 'max_length': '1024'}), 'order': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shoppingcart.Order']"}), 'qty': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'status': ('django.db.models.fields.CharField', [], {'default': "'cart'", 'max_length': '32'}), 'unit_cost': ('django.db.models.fields.DecimalField', [], {'default': '0.0', 'max_digits': '30', 'decimal_places': '2'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) }, 'shoppingcart.paidcourseregistration': { 'Meta': {'object_name': 'PaidCourseRegistration', '_ormbases': ['shoppingcart.OrderItem']}, 'course_id': ('django.db.models.fields.CharField', [], {'max_length': '128', 'db_index': 'True'}), 'orderitem_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['shoppingcart.OrderItem']", 'unique': 'True', 'primary_key': 'True'}) }, 'student.courseenrollment': { 'Meta': {'ordering': "('user', 'course_id')", 'unique_together': "(('user', 'course_id'),)", 'object_name': 'CourseEnrollment'}, 'course_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'null': 'True', 'db_index': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'mode': ('django.db.models.fields.CharField', [], {'default': "'honor'", 'max_length': '100'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) } } complete_apps = ['shoppingcart']
agpl-3.0
[ 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, 4738, 7, 267, 1592, 14, 981, 63, 1224, 360, 17788, 63, 1648, 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, 751, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1178, 14, 1899, 16607, 288, 661, 4968, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 534, 31597, 297, 1390, 63, 1267, 29, 24, 1826, 288, 661, 1205, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 534, 8153, 297, 1390, 63, 1267, 29, 708, 1826, 288, 661, 9533, 63, 521, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 19815, 63, 475, 63, 2246, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 772, 12, 4596, 29, 549, 1826, 288, 661, 19815, 63, 475, 63, 2019, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 772, 12, 4596, 29, 549, 1826, 288, 661, 19815, 63, 475, 63, 20451, 17, 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, 19815, 63, 475, 63, 20451, 18, 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, 19815, 63, 475, 63, 3690, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 772, 12, 4596, 29, 549, 1826, 288, 661, 19815, 63, 475, 63, 929, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 24, 12, 4596, 29, 549, 1826, 288, 661, 19815, 63, 475, 63, 31580, 600, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 975, 12, 4596, 29, 549, 1826, 288, 661, 19815, 63, 475, 63, 6063, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 772, 12, 4596, 29, 549, 1826, 288, 661, 19815, 63, 475, 63, 2055, 1507, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 24, 12, 4596, 29, 549, 1826, 288, 661, 19815, 63, 475, 63, 5841, 466, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 708, 12, 4596, 29, 549, 1826, 288, 661, 6459, 63, 8102, 63, 2724, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2500, 29, 549, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 17788, 297, 788, 4738, 1105, 398, 327, 12934, 1402, 283, 4738, 2081, 7, 267, 1592, 14, 981, 63, 1224, 360, 17788, 63, 269, 9910, 563, 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, 1648, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 17788, 14, 4738, 16607, 288, 661, 751, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1178, 14, 1899, 16607, 288, 661, 1205, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 534, 8153, 297, 1390, 63, 1267, 29, 708, 1826, 288, 661, 5643, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 7533, 885, 29, 17, 1826, 288, 661, 3248, 63, 6336, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 15975, 7533, 885, 29, 16, 14, 16, 12, 1390, 63, 7022, 29, 1216, 12, 6107, 63, 10696, 29, 18, 1826, 288, 661, 604, 63, 6336, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 15975, 7533, 885, 29, 16, 14, 16, 12, 1390, 63, 7022, 29, 1216, 12, 6107, 63, 10696, 29, 18, 1826, 288, 661, 604, 63, 3257, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 534, 29926, 14, 7020, 297, 1390, 63, 1267, 29, 7727, 1826, 288, 661, 4968, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 534, 31597, 297, 1390, 63, 1267, 29, 24, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 17788, 297, 788, 4738, 2081, 1105, 398, 327, 12934, 1402, 283, 4232, 344, 6979, 11757, 7, 267, 1592, 14, 981, 63, 1224, 360, 17788, 63, 16555, 1972, 8054, 297, 334, 288, 661, 269, 9910, 563, 63, 4695, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 7533, 475, 29, 1025, 459, 17788, 14, 4738, 2081, 995, 3747, 29, 549, 12, 5062, 63, 498, 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, 3933, 12, 1592, 63, 1080, 29, 549, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 17788, 297, 788, 4232, 344, 6979, 11757, 1105, 398, 327, 12934, 1402, 283, 11414, 2081, 7, 267, 1592, 14, 981, 63, 1224, 360, 17788, 63, 6999, 1053, 297, 334, 288, 661, 269, 9910, 563, 63, 4695, 297, 291, 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, 4738, 7, 267, 1592, 14, 981, 63, 1224, 360, 17788, 63, 1648, 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, 751, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1178, 14, 1899, 16607, 288, 661, 4968, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 534, 31597, 297, 1390, 63, 1267, 29, 24, 1826, 288, 661, 1205, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 534, 8153, 297, 1390, 63, 1267, 29, 708, 1826, 288, 661, 9533, 63, 521, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 19815, 63, 475, 63, 2246, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 772, 12, 4596, 29, 549, 1826, 288, 661, 19815, 63, 475, 63, 2019, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 772, 12, 4596, 29, 549, 1826, 288, 661, 19815, 63, 475, 63, 20451, 17, 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, 19815, 63, 475, 63, 20451, 18, 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, 19815, 63, 475, 63, 3690, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 772, 12, 4596, 29, 549, 1826, 288, 661, 19815, 63, 475, 63, 929, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 24, 12, 4596, 29, 549, 1826, 288, 661, 19815, 63, 475, 63, 31580, 600, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 975, 12, 4596, 29, 549, 1826, 288, 661, 19815, 63, 475, 63, 6063, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 772, 12, 4596, 29, 549, 1826, 288, 661, 19815, 63, 475, 63, 2055, 1507, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 24, 12, 4596, 29, 549, 1826, 288, 661, 19815, 63, 475, 63, 5841, 466, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 708, 12, 4596, 29, 549, 1826, 288, 661, 6459, 63, 8102, 63, 2724, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2500, 29, 549, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 17788, 297, 788, 4738, 1105, 398, 327, 12934, 1402, 283, 4738, 2081, 7, 267, 1592, 14, 981, 63, 1224, 360, 17788, 63, 269, 9910, 563, 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, 1648, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 17788, 14, 4738, 16607, 288, 661, 751, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1178, 14, 1899, 16607, 288, 661, 1205, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 534, 8153, 297, 1390, 63, 1267, 29, 708, 1826, 288, 661, 5643, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 7533, 885, 29, 17, 1826, 288, 661, 3248, 63, 6336, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 15975, 7533, 885, 29, 16, 14, 16, 12, 1390, 63, 7022, 29, 1216, 12, 6107, 63, 10696, 29, 18, 1826, 288, 661, 604, 63, 6336, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 15975, 7533, 885, 29, 16, 14, 16, 12, 1390, 63, 7022, 29, 1216, 12, 6107, 63, 10696, 29, 18, 1826, 288, 661, 604, 63, 3257, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 534, 29926, 14, 7020, 297, 1390, 63, 1267, 29, 7727, 1826, 288, 661, 4968, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 534, 31597, 297, 1390, 63, 1267, 29, 24, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 17788, 297, 788, 4738, 2081, 1105, 398, 327, 12934, 1402, 283, 4232, 344, 6979, 11757, 7, 267, 1592, 14, 981, 63, 1224, 360, 17788, 63, 16555, 1972, 8054, 297, 334, 288, 661, 269, 9910, 563, 63, 4695, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 7533, 475, 29, 1025, 459, 17788, 14, 4738, 2081, 995, 3747, 29, 549, 12, 5062, 63, 498, 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, 3933, 12, 1592, 63, 1080, 29, 549, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 17788, 297, 788, 4232, 344, 6979, 11757, 1105, 398, 327, 12934, 1402, 283, 11414, 2081, 7, 267, 1592, 14, 981, 63, 1224, 360, 17788, 63, 6999, 1053, 297, 334, 288, 661, 269, 9910, 563, 63, 4695, 297, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
OpenTrading/OpenTrader
setup.py
1
2533
#!/usr/bin/env python import codecs import os import sys import glob from setuptools import setup, find_packages try: # http://stackoverflow.com/questions/21698004/python-behave-integration-in-setuptools-setup-py from setuptools_behave import behave_test except ImportError: behave_test = None dirname = os.path.dirname(__file__) long_description = ( codecs.open(os.path.join(dirname, "README.creole"), encoding="utf-8").read() + "\n" ) # Dependencies are automatically detected, but it might need fine tuning. build_exe_options = {"packages": ["zmq"], "excludes": ["tkinter"]} setup( name="OpenTrader", description="OpenTrader", long_description=long_description, author="Open Trading", license="LGPL2 license", url="https://www.github.com/OpenTrading/OpenTrader", version='1.0', classifiers=[ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: LGPL2 License", "Operating System :: POSIX", "Operating System :: Microsoft :: Windows", "Operating System :: MacOS :: MacOS X", "Topic :: Office/Business :: Financial :: Investment", "Topic :: Software Development :: Libraries :: Python Modules", "Programming Language :: Python :: 2", ] + [("Programming Language :: Python :: %s" % x) for x in "2.6 2.7".split()], install_requires=[ "configobj", "pandas", "pyparsing", # we'll make zmq default now "zmq", ], extras_require={'plotting': ["matplotlib"], 'pybacktest': ["pybacktest"], 'rabbit': ["pyrabbit"], 'doc': ["python-creole", "invoke"], # we'll make zmq default now # 'zmq': ["zmq"], 'amqp': ["pika"], }, data_files=[('', ['README.creole']), ('OpenTrader', glob.glob('OpenTrader/*.ini')), ('OpenTrader/Omlettes', glob.glob('OpenTrader/Omlettes/*.ini'))], options = {"build_exe": build_exe_options}, entry_points={ "console_scripts": [ "OTCmd2 = OpenTrader.OTCmd2:iMain", "OTBackTest = OpenTrader.OTBackTest:iMain", "OTPpnAmgc = OpenTrader.OTPpnAmgc:iMain", ] }, tests_require=["behave>=1.2.5"], cmdclass=behave_test and {"behave_test": behave_test,} or {}, packages=find_packages(), include_package_data=True, zip_safe=False, )
lgpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 6010, 199, 646, 747, 199, 646, 984, 199, 646, 5739, 199, 199, 504, 9116, 492, 3272, 12, 2342, 63, 5154, 199, 893, 26, 199, 3, 1455, 921, 23153, 14, 957, 15, 16069, 15, 9669, 2905, 7979, 15, 1548, 13, 1235, 7804, 13, 15092, 13, 262, 13, 13623, 13, 2758, 13, 647, 272, 687, 9116, 63, 1235, 7804, 492, 24062, 63, 396, 199, 2590, 3545, 26, 272, 24062, 63, 396, 275, 488, 1362, 199, 3475, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 199, 199, 2809, 63, 1802, 275, 334, 272, 6010, 14, 1490, 8, 736, 14, 515, 14, 904, 8, 3475, 12, 298, 18195, 14, 1353, 16721, 1288, 2644, 628, 1624, 13, 24, 3471, 739, 342, 435, 1867, 78, 2, 272, 776, 199, 199, 3, 1487, 3209, 787, 5847, 10501, 12, 1325, 652, 5594, 1929, 15701, 15486, 316, 14, 199, 1506, 63, 5803, 63, 1419, 275, 2420, 5154, 582, 2097, 21290, 2255, 298, 26984, 582, 2097, 12223, 27635, 199, 199, 2758, 8, 272, 536, 628, 4299, 2437, 424, 401, 272, 1369, 628, 4299, 2437, 424, 401, 272, 1846, 63, 1802, 29, 2809, 63, 1802, 12, 272, 4132, 628, 4299, 12643, 1098, 401, 272, 4190, 628, 44, 12006, 18, 4190, 401, 272, 1166, 628, 2859, 921, 1544, 14, 5031, 14, 957, 15, 4299, 23210, 15, 4299, 2437, 424, 401, 272, 1015, 534, 17, 14, 16, 297, 272, 19137, 1524, 267, 298, 23753, 9795, 3800, 499, 446, 5543, 13, 16192, 401, 267, 298, 23910, 23975, 3800, 23493, 401, 267, 298, 3761, 3800, 25718, 26330, 3800, 32426, 18, 844, 401, 267, 298, 23699, 6187, 3800, 18169, 401, 267, 298, 23699, 6187, 3800, 15332, 3800, 5417, 401, 267, 298, 23699, 6187, 3800, 10444, 3100, 3800, 10444, 3100, 1323, 401, 267, 298, 12157, 3800, 593, 11286, 301, 15, 12106, 9585, 3800, 11711, 24409, 3800, 1010, 13981, 434, 401, 267, 298, 12157, 3800, 2290, 15290, 3800, 31454, 3800, 2018, 18167, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 499, 401, 272, 1622, 435, 10003, 11411, 8466, 3800, 2018, 3800, 450, 83, 2, 450, 671, 9, 367, 671, 315, 298, 18, 14, 22, 499, 14, 23, 1674, 1294, 15618, 272, 3907, 63, 6537, 1524, 267, 298, 888, 1113, 401, 267, 298, 15718, 401, 267, 298, 647, 11059, 401, 267, 327, 781, 7171, 1852, 26633, 849, 3063, 267, 298, 21290, 401, 267, 2156, 272, 13751, 63, 4365, 3713, 2798, 1337, 356, 2097, 16440, 2255, 490, 283, 647, 894, 396, 356, 2097, 647, 894, 396, 2255, 490, 283, 14411, 2075, 356, 2097, 647, 14411, 2075, 2255, 490, 283, 1301, 356, 2097, 1548, 13, 1353, 16721, 401, 298, 15195, 2255, 490, 327, 781, 7171, 1852, 26633, 849, 3063, 490, 327, 283, 21290, 356, 2097, 21290, 2255, 490, 283, 455, 15202, 356, 2097, 1038, 7351, 2255, 490, 1660, 272, 666, 63, 1725, 1524, 8594, 788, 18195, 14, 1353, 16721, 3815, 355, 661, 4299, 2437, 424, 297, 5739, 14, 6463, 360, 4299, 2437, 424, 20362, 2730, 3855, 355, 661, 4299, 2437, 424, 15, 29197, 2723, 744, 297, 5739, 14, 6463, 360, 4299, 2437, 424, 15, 29197, 2723, 744, 20362, 2730, 1333, 467, 339, 1511, 275, 2420, 1506, 63, 5803, 582, 1900, 63, 5803, 63, 1419, 1386, 272, 2397, 63, 3438, 3126, 267, 298, 6614, 63, 6429, 582, 359, 288, 298, 1387, 7874, 18, 275, 3232, 2437, 424, 14, 1387, 7874, 18, 26, 73, 6756, 401, 288, 298, 1387, 4540, 774, 275, 3232, 2437, 424, 14, 1387, 4540, 774, 26, 73, 6756, 401, 288, 298, 1387, 48, 4812, 33, 6649, 67, 275, 3232, 2437, 424, 14, 1387, 48, 4812, 33, 6649, 67, 26, 73, 6756, 401, 267, 1622, 272, 1660, 272, 2295, 63, 4365, 6270, 1235, 7804, 8119, 17, 14, 18, 14, 21, 2255, 272, 2088, 533, 29, 1235, 7804, 63, 396, 436, 2420, 1235, 7804, 63, 396, 582, 24062, 63, 396, 28209, 503, 5479, 272, 6117, 29, 1623, 63, 5154, 1062, 272, 2387, 63, 2491, 63, 576, 29, 549, 12, 272, 3482, 63, 3489, 29, 797, 12, 199, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 6010, 199, 646, 747, 199, 646, 984, 199, 646, 5739, 199, 199, 504, 9116, 492, 3272, 12, 2342, 63, 5154, 199, 893, 26, 199, 3, 1455, 921, 23153, 14, 957, 15, 16069, 15, 9669, 2905, 7979, 15, 1548, 13, 1235, 7804, 13, 15092, 13, 262, 13, 13623, 13, 2758, 13, 647, 272, 687, 9116, 63, 1235, 7804, 492, 24062, 63, 396, 199, 2590, 3545, 26, 272, 24062, 63, 396, 275, 488, 1362, 199, 3475, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 199, 199, 2809, 63, 1802, 275, 334, 272, 6010, 14, 1490, 8, 736, 14, 515, 14, 904, 8, 3475, 12, 298, 18195, 14, 1353, 16721, 1288, 2644, 628, 1624, 13, 24, 3471, 739, 342, 435, 1867, 78, 2, 272, 776, 199, 199, 3, 1487, 3209, 787, 5847, 10501, 12, 1325, 652, 5594, 1929, 15701, 15486, 316, 14, 199, 1506, 63, 5803, 63, 1419, 275, 2420, 5154, 582, 2097, 21290, 2255, 298, 26984, 582, 2097, 12223, 27635, 199, 199, 2758, 8, 272, 536, 628, 4299, 2437, 424, 401, 272, 1369, 628, 4299, 2437, 424, 401, 272, 1846, 63, 1802, 29, 2809, 63, 1802, 12, 272, 4132, 628, 4299, 12643, 1098, 401, 272, 4190, 628, 44, 12006, 18, 4190, 401, 272, 1166, 628, 2859, 921, 1544, 14, 5031, 14, 957, 15, 4299, 23210, 15, 4299, 2437, 424, 401, 272, 1015, 534, 17, 14, 16, 297, 272, 19137, 1524, 267, 298, 23753, 9795, 3800, 499, 446, 5543, 13, 16192, 401, 267, 298, 23910, 23975, 3800, 23493, 401, 267, 298, 3761, 3800, 25718, 26330, 3800, 32426, 18, 844, 401, 267, 298, 23699, 6187, 3800, 18169, 401, 267, 298, 23699, 6187, 3800, 15332, 3800, 5417, 401, 267, 298, 23699, 6187, 3800, 10444, 3100, 3800, 10444, 3100, 1323, 401, 267, 298, 12157, 3800, 593, 11286, 301, 15, 12106, 9585, 3800, 11711, 24409, 3800, 1010, 13981, 434, 401, 267, 298, 12157, 3800, 2290, 15290, 3800, 31454, 3800, 2018, 18167, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 499, 401, 272, 1622, 435, 10003, 11411, 8466, 3800, 2018, 3800, 450, 83, 2, 450, 671, 9, 367, 671, 315, 298, 18, 14, 22, 499, 14, 23, 1674, 1294, 15618, 272, 3907, 63, 6537, 1524, 267, 298, 888, 1113, 401, 267, 298, 15718, 401, 267, 298, 647, 11059, 401, 267, 327, 781, 7171, 1852, 26633, 849, 3063, 267, 298, 21290, 401, 267, 2156, 272, 13751, 63, 4365, 3713, 2798, 1337, 356, 2097, 16440, 2255, 490, 283, 647, 894, 396, 356, 2097, 647, 894, 396, 2255, 490, 283, 14411, 2075, 356, 2097, 647, 14411, 2075, 2255, 490, 283, 1301, 356, 2097, 1548, 13, 1353, 16721, 401, 298, 15195, 2255, 490, 327, 781, 7171, 1852, 26633, 849, 3063, 490, 327, 283, 21290, 356, 2097, 21290, 2255, 490, 283, 455, 15202, 356, 2097, 1038, 7351, 2255, 490, 1660, 272, 666, 63, 1725, 1524, 8594, 788, 18195, 14, 1353, 16721, 3815, 355, 661, 4299, 2437, 424, 297, 5739, 14, 6463, 360, 4299, 2437, 424, 20362, 2730, 3855, 355, 661, 4299, 2437, 424, 15, 29197, 2723, 744, 297, 5739, 14, 6463, 360, 4299, 2437, 424, 15, 29197, 2723, 744, 20362, 2730, 1333, 467, 339, 1511, 275, 2420, 1506, 63, 5803, 582, 1900, 63, 5803, 63, 1419, 1386, 272, 2397, 63, 3438, 3126, 267, 298, 6614, 63, 6429, 582, 359, 288, 298, 1387, 7874, 18, 275, 3232, 2437, 424, 14, 1387, 7874, 18, 26, 73, 6756, 401, 288, 298, 1387, 4540, 774, 275, 3232, 2437, 424, 14, 1387, 4540, 774, 26, 73, 6756, 401, 288, 298, 1387, 48, 4812, 33, 6649, 67, 275, 3232, 2437, 424, 14, 1387, 48, 4812, 33, 6649, 67, 26, 73, 6756, 401, 267, 1622, 272, 1660, 272, 2295, 63, 4365, 6270, 1235, 7804, 8119, 17, 14, 18, 14, 21, 2255, 272, 2088, 533, 29, 1235, 7804, 63, 396, 436, 2420, 1235, 7804, 63, 396, 582, 24062, 63, 396, 28209, 503, 5479, 272, 6117, 29, 1623, 63, 5154, 1062, 272, 2387, 63, 2491, 63, 576, 29, 549, 12, 272, 3482, 63, 3489, 29, 797, 12, 199, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mayankcu/Django-social
venv/Lib/site-packages/django/core/files/storage.py
78
10329
import os import errno import urlparse import itertools from datetime import datetime from django.conf import settings from django.core.exceptions import ImproperlyConfigured, SuspiciousOperation from django.core.files import locks, File from django.core.files.move import file_move_safe from django.utils.encoding import force_unicode, filepath_to_uri from django.utils.functional import LazyObject from django.utils.importlib import import_module from django.utils.text import get_valid_filename from django.utils._os import safe_join, abspathu __all__ = ('Storage', 'FileSystemStorage', 'DefaultStorage', 'default_storage') class Storage(object): """ A base storage class, providing some default behaviors that all other storage systems can inherit or override, as necessary. """ # The following methods represent a public interface to private methods. # These shouldn't be overridden by subclasses unless absolutely necessary. def open(self, name, mode='rb'): """ Retrieves the specified file from storage. """ return self._open(name, mode) def save(self, name, content): """ Saves new content to the file specified by name. The content should be a proper File object, ready to be read from the beginning. """ # Get the proper name for the file, as it will actually be saved. if name is None: name = content.name name = self.get_available_name(name) name = self._save(name, content) # Store filenames with forward slashes, even on Windows return force_unicode(name.replace('\\', '/')) # These methods are part of the public API, with default implementations. def get_valid_name(self, name): """ Returns a filename, based on the provided filename, that's suitable for use in the target storage system. """ return get_valid_filename(name) def get_available_name(self, name): """ Returns a filename that's free on the target storage system, and available for new content to be written to. """ dir_name, file_name = os.path.split(name) file_root, file_ext = os.path.splitext(file_name) # If the filename already exists, add an underscore and a number (before # the file extension, if one exists) to the filename until the generated # filename doesn't exist. count = itertools.count(1) while self.exists(name): # file_ext includes the dot. name = os.path.join(dir_name, "%s_%s%s" % (file_root, count.next(), file_ext)) return name def path(self, name): """ Returns a local filesystem path where the file can be retrieved using Python's built-in open() function. Storage systems that can't be accessed using open() should *not* implement this method. """ raise NotImplementedError("This backend doesn't support absolute paths.") # The following methods form the public API for storage systems, but with # no default implementations. Subclasses must implement *all* of these. def delete(self, name): """ Deletes the specified file from the storage system. """ raise NotImplementedError() def exists(self, name): """ Returns True if a file referened by the given name already exists in the storage system, or False if the name is available for a new file. """ raise NotImplementedError() def listdir(self, path): """ Lists the contents of the specified path, returning a 2-tuple of lists; the first item being directories, the second item being files. """ raise NotImplementedError() def size(self, name): """ Returns the total size, in bytes, of the file specified by name. """ raise NotImplementedError() def url(self, name): """ Returns an absolute URL where the file's contents can be accessed directly by a Web browser. """ raise NotImplementedError() def accessed_time(self, name): """ Returns the last accessed time (as datetime object) of the file specified by name. """ raise NotImplementedError() def created_time(self, name): """ Returns the creation time (as datetime object) of the file specified by name. """ raise NotImplementedError() def modified_time(self, name): """ Returns the last modified time (as datetime object) of the file specified by name. """ raise NotImplementedError() class FileSystemStorage(Storage): """ Standard filesystem storage """ def __init__(self, location=None, base_url=None): if location is None: location = settings.MEDIA_ROOT self.base_location = location self.location = abspathu(self.base_location) if base_url is None: base_url = settings.MEDIA_URL self.base_url = base_url def _open(self, name, mode='rb'): return File(open(self.path(name), mode)) def _save(self, name, content): full_path = self.path(name) # Create any intermediate directories that do not exist. # Note that there is a race between os.path.exists and os.makedirs: # if os.makedirs fails with EEXIST, the directory was created # concurrently, and we can continue normally. Refs #16082. directory = os.path.dirname(full_path) if not os.path.exists(directory): try: os.makedirs(directory) except OSError, e: if e.errno != errno.EEXIST: raise if not os.path.isdir(directory): raise IOError("%s exists and is not a directory." % directory) # There's a potential race condition between get_available_name and # saving the file; it's possible that two threads might return the # same name, at which point all sorts of fun happens. So we need to # try to create the file, but if it already exists we have to go back # to get_available_name() and try again. while True: try: # This file has a file path that we can move. if hasattr(content, 'temporary_file_path'): file_move_safe(content.temporary_file_path(), full_path) content.close() # This is a normal uploadedfile that we can stream. else: # This fun binary flag incantation makes os.open throw an # OSError if the file already exists before we open it. fd = os.open(full_path, os.O_WRONLY | os.O_CREAT | os.O_EXCL | getattr(os, 'O_BINARY', 0)) try: locks.lock(fd, locks.LOCK_EX) for chunk in content.chunks(): os.write(fd, chunk) finally: locks.unlock(fd) os.close(fd) except OSError, e: if e.errno == errno.EEXIST: # Ooops, the file exists. We need a new file name. name = self.get_available_name(name) full_path = self.path(name) else: raise else: # OK, the file save worked. Break out of the loop. break if settings.FILE_UPLOAD_PERMISSIONS is not None: os.chmod(full_path, settings.FILE_UPLOAD_PERMISSIONS) return name def delete(self, name): name = self.path(name) # If the file exists, delete it from the filesystem. # Note that there is a race between os.path.exists and os.remove: # if os.remove fails with ENOENT, the file was removed # concurrently, and we can continue normally. if os.path.exists(name): try: os.remove(name) except OSError, e: if e.errno != errno.ENOENT: raise def exists(self, name): return os.path.exists(self.path(name)) def listdir(self, path): path = self.path(path) directories, files = [], [] for entry in os.listdir(path): if os.path.isdir(os.path.join(path, entry)): directories.append(entry) else: files.append(entry) return directories, files def path(self, name): try: path = safe_join(self.location, name) except ValueError: raise SuspiciousOperation("Attempted access to '%s' denied." % name) return os.path.normpath(path) def size(self, name): return os.path.getsize(self.path(name)) def url(self, name): if self.base_url is None: raise ValueError("This file is not accessible via a URL.") return urlparse.urljoin(self.base_url, filepath_to_uri(name)) def accessed_time(self, name): return datetime.fromtimestamp(os.path.getatime(self.path(name))) def created_time(self, name): return datetime.fromtimestamp(os.path.getctime(self.path(name))) def modified_time(self, name): return datetime.fromtimestamp(os.path.getmtime(self.path(name))) def get_storage_class(import_path=None): if import_path is None: import_path = settings.DEFAULT_FILE_STORAGE try: dot = import_path.rindex('.') except ValueError: raise ImproperlyConfigured("%s isn't a storage module." % import_path) module, classname = import_path[:dot], import_path[dot+1:] try: mod = import_module(module) except ImportError, e: raise ImproperlyConfigured('Error importing storage module %s: "%s"' % (module, e)) try: return getattr(mod, classname) except AttributeError: raise ImproperlyConfigured('Storage module "%s" does not define a "%s" class.' % (module, classname)) class DefaultStorage(LazyObject): def _setup(self): self._wrapped = get_storage_class()() default_storage = DefaultStorage()
bsd-3-clause
[ 646, 747, 199, 646, 7554, 199, 646, 7097, 199, 646, 7975, 199, 504, 2197, 492, 2197, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 12, 428, 28651, 6044, 199, 504, 1639, 14, 1018, 14, 1725, 492, 23340, 12, 3814, 199, 504, 1639, 14, 1018, 14, 1725, 14, 1185, 492, 570, 63, 1185, 63, 3489, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2975, 12, 9911, 63, 475, 63, 2302, 199, 504, 1639, 14, 1208, 14, 15481, 492, 22373, 1692, 199, 504, 1639, 14, 1208, 14, 25893, 492, 492, 63, 578, 199, 504, 1639, 14, 1208, 14, 505, 492, 664, 63, 1078, 63, 1501, 199, 504, 1639, 14, 1208, 423, 736, 492, 5048, 63, 904, 12, 19529, 85, 421, 199, 363, 452, 363, 275, 661, 6408, 297, 283, 17521, 6408, 297, 283, 2698, 6408, 297, 283, 885, 63, 3494, 358, 199, 199, 533, 10533, 8, 785, 304, 272, 408, 272, 437, 1300, 4887, 1021, 12, 13070, 2005, 849, 5112, 1384, 626, 1006, 1163, 272, 4887, 10460, 883, 8287, 503, 4278, 12, 465, 5784, 14, 272, 408, 339, 327, 710, 2569, 3102, 2954, 282, 4575, 3217, 370, 5726, 3102, 14, 272, 327, 5723, 9296, 1133, 506, 10087, 701, 9180, 7444, 3679, 590, 5784, 14, 339, 347, 1551, 8, 277, 12, 536, 12, 818, 534, 4848, 735, 267, 408, 267, 27940, 314, 2013, 570, 687, 4887, 14, 267, 408, 267, 372, 291, 423, 1490, 8, 354, 12, 818, 9, 339, 347, 3354, 8, 277, 12, 536, 12, 1564, 304, 267, 408, 267, 428, 7047, 892, 1564, 370, 314, 570, 2013, 701, 536, 14, 710, 1564, 1077, 506, 282, 267, 5576, 3814, 909, 12, 10144, 370, 506, 1586, 687, 314, 9608, 14, 267, 408, 267, 327, 2372, 314, 5576, 536, 367, 314, 570, 12, 465, 652, 911, 5965, 506, 6290, 14, 267, 340, 536, 365, 488, 26, 288, 536, 275, 1564, 14, 354, 398, 536, 275, 291, 14, 362, 63, 4561, 63, 354, 8, 354, 9, 267, 536, 275, 291, 423, 2117, 8, 354, 12, 1564, 9, 398, 327, 13874, 6203, 543, 7568, 20275, 12, 2755, 641, 5417, 267, 372, 3542, 63, 2975, 8, 354, 14, 1814, 20786, 1994, 1333, 339, 327, 5723, 3102, 787, 1777, 402, 314, 4575, 3261, 12, 543, 849, 12591, 14, 339, 347, 664, 63, 1078, 63, 354, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 282, 1788, 12, 4079, 641, 314, 2741, 1788, 12, 626, 1159, 11233, 367, 267, 675, 315, 314, 1347, 4887, 2656, 14, 267, 408, 267, 372, 664, 63, 1078, 63, 1501, 8, 354, 9, 339, 347, 664, 63, 4561, 63, 354, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 282, 1788, 626, 1159, 2867, 641, 314, 1347, 4887, 2656, 12, 436, 267, 2808, 367, 892, 1564, 370, 506, 5313, 370, 14, 267, 408, 267, 2935, 63, 354, 12, 570, 63, 354, 275, 747, 14, 515, 14, 1294, 8, 354, 9, 267, 570, 63, 1231, 12, 570, 63, 832, 275, 747, 14, 515, 14, 7973, 8, 493, 63, 354, 9, 267, 327, 982, 314, 1788, 2575, 3495, 12, 1050, 376, 18888, 436, 282, 1329, 334, 5182, 267, 327, 314, 570, 3329, 12, 340, 1373, 3495, 9, 370, 314, 1788, 5133, 314, 4046, 267, 327, 1788, 3181, 1133, 2187, 14, 267, 2338, 275, 7975, 14, 835, 8, 17, 9, 267, 1830, 291, 14, 2444, 8, 354, 304, 288, 327, 570, 63, 832, 6952, 314, 6308, 14, 288, 536, 275, 747, 14, 515, 14, 904, 8, 694, 63, 354, 12, 2071, 83, 4970, 83, 5, 83, 2, 450, 334, 493, 63, 1231, 12, 2338, 14, 2184, 1062, 570, 63, 832, 430, 398, 372, 536, 339, 347, 931, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 282, 2257, 10036, 931, 2382, 314, 570, 883, 506, 12396, 1808, 267, 2018, 1159, 6137, 13, 262, 1551, 342, 805, 14, 10533, 10460, 626, 883, 1133, 506, 267, 13810, 1808, 1551, 342, 1077, 627, 1397, 10, 5669, 642, 1083, 14, 267, 408, 267, 746, 4279, 480, 2765, 4865, 3181, 1133, 2291, 3679, 3792, 2685, 339, 327, 710, 2569, 3102, 1824, 314, 4575, 3261, 367, 4887, 10460, 12, 1325, 543, 272, 327, 949, 849, 12591, 14, 20196, 1471, 5669, 627, 452, 10, 402, 3520, 14, 339, 347, 3145, 8, 277, 12, 536, 304, 267, 408, 267, 28382, 314, 2013, 570, 687, 314, 4887, 2656, 14, 267, 408, 267, 746, 4279, 342, 339, 347, 3495, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 715, 340, 282, 570, 295, 1485, 379, 701, 314, 1627, 536, 2575, 3495, 315, 314, 267, 4887, 2656, 12, 503, 756, 340, 314, 536, 365, 2808, 367, 282, 892, 570, 14, 267, 408, 267, 746, 4279, 342, 339, 347, 27483, 8, 277, 12, 931, 304, 267, 408, 267, 31289, 314, 4072, 402, 314, 2013, 931, 12, 8152, 282, 499, 13, 2960, 402, 5548, 27, 267, 314, 1642, 1242, 3769, 6602, 12, 314, 3499, 1242, 3769, 1584, 14, 267, 408, 267, 746, 4279, 342, 339, 347, 1568, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 314, 3141, 1568, 12, 315, 2783, 12, 402, 314, 570, 2013, 701, 536, 14, 267, 408, 267, 746, 4279, 342, 339, 347, 1166, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 376, 3679, 2851, 2382, 314, 570, 1159, 4072, 883, 506, 13810, 267, 5370, 701, 282, 6001, 7042, 14, 267, 408, 267, 746, 4279, 342, 339, 347, 13810, 63, 521, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 314, 2061, 13810, 900, 334, 305, 2197, 909, 9, 402, 314, 570, 267, 2013, 701, 536, 14, 267, 408, 267, 746, 4279, 342, 339, 347, 2737, 63, 521, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 314, 7143, 900, 334, 305, 2197, 909, 9, 402, 314, 570, 267, 2013, 701, 536, 14, 267, 408, 267, 746, 4279, 342, 339, 347, 6042, 63, 521, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 314, 2061, 6042, 900, 334, 305, 2197, 909, 9, 402, 314, 570, 267, 2013, 701, 536, 14, 267, 408, 267, 746, 4279, 342, 199, 199, 533, 23754, 6408, 8, 6408, 304, 272, 408, 272, 9739, 10036, 4887, 272, 408, 339, 347, 636, 826 ]
[ 747, 199, 646, 7554, 199, 646, 7097, 199, 646, 7975, 199, 504, 2197, 492, 2197, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 12, 428, 28651, 6044, 199, 504, 1639, 14, 1018, 14, 1725, 492, 23340, 12, 3814, 199, 504, 1639, 14, 1018, 14, 1725, 14, 1185, 492, 570, 63, 1185, 63, 3489, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2975, 12, 9911, 63, 475, 63, 2302, 199, 504, 1639, 14, 1208, 14, 15481, 492, 22373, 1692, 199, 504, 1639, 14, 1208, 14, 25893, 492, 492, 63, 578, 199, 504, 1639, 14, 1208, 14, 505, 492, 664, 63, 1078, 63, 1501, 199, 504, 1639, 14, 1208, 423, 736, 492, 5048, 63, 904, 12, 19529, 85, 421, 199, 363, 452, 363, 275, 661, 6408, 297, 283, 17521, 6408, 297, 283, 2698, 6408, 297, 283, 885, 63, 3494, 358, 199, 199, 533, 10533, 8, 785, 304, 272, 408, 272, 437, 1300, 4887, 1021, 12, 13070, 2005, 849, 5112, 1384, 626, 1006, 1163, 272, 4887, 10460, 883, 8287, 503, 4278, 12, 465, 5784, 14, 272, 408, 339, 327, 710, 2569, 3102, 2954, 282, 4575, 3217, 370, 5726, 3102, 14, 272, 327, 5723, 9296, 1133, 506, 10087, 701, 9180, 7444, 3679, 590, 5784, 14, 339, 347, 1551, 8, 277, 12, 536, 12, 818, 534, 4848, 735, 267, 408, 267, 27940, 314, 2013, 570, 687, 4887, 14, 267, 408, 267, 372, 291, 423, 1490, 8, 354, 12, 818, 9, 339, 347, 3354, 8, 277, 12, 536, 12, 1564, 304, 267, 408, 267, 428, 7047, 892, 1564, 370, 314, 570, 2013, 701, 536, 14, 710, 1564, 1077, 506, 282, 267, 5576, 3814, 909, 12, 10144, 370, 506, 1586, 687, 314, 9608, 14, 267, 408, 267, 327, 2372, 314, 5576, 536, 367, 314, 570, 12, 465, 652, 911, 5965, 506, 6290, 14, 267, 340, 536, 365, 488, 26, 288, 536, 275, 1564, 14, 354, 398, 536, 275, 291, 14, 362, 63, 4561, 63, 354, 8, 354, 9, 267, 536, 275, 291, 423, 2117, 8, 354, 12, 1564, 9, 398, 327, 13874, 6203, 543, 7568, 20275, 12, 2755, 641, 5417, 267, 372, 3542, 63, 2975, 8, 354, 14, 1814, 20786, 1994, 1333, 339, 327, 5723, 3102, 787, 1777, 402, 314, 4575, 3261, 12, 543, 849, 12591, 14, 339, 347, 664, 63, 1078, 63, 354, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 282, 1788, 12, 4079, 641, 314, 2741, 1788, 12, 626, 1159, 11233, 367, 267, 675, 315, 314, 1347, 4887, 2656, 14, 267, 408, 267, 372, 664, 63, 1078, 63, 1501, 8, 354, 9, 339, 347, 664, 63, 4561, 63, 354, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 282, 1788, 626, 1159, 2867, 641, 314, 1347, 4887, 2656, 12, 436, 267, 2808, 367, 892, 1564, 370, 506, 5313, 370, 14, 267, 408, 267, 2935, 63, 354, 12, 570, 63, 354, 275, 747, 14, 515, 14, 1294, 8, 354, 9, 267, 570, 63, 1231, 12, 570, 63, 832, 275, 747, 14, 515, 14, 7973, 8, 493, 63, 354, 9, 267, 327, 982, 314, 1788, 2575, 3495, 12, 1050, 376, 18888, 436, 282, 1329, 334, 5182, 267, 327, 314, 570, 3329, 12, 340, 1373, 3495, 9, 370, 314, 1788, 5133, 314, 4046, 267, 327, 1788, 3181, 1133, 2187, 14, 267, 2338, 275, 7975, 14, 835, 8, 17, 9, 267, 1830, 291, 14, 2444, 8, 354, 304, 288, 327, 570, 63, 832, 6952, 314, 6308, 14, 288, 536, 275, 747, 14, 515, 14, 904, 8, 694, 63, 354, 12, 2071, 83, 4970, 83, 5, 83, 2, 450, 334, 493, 63, 1231, 12, 2338, 14, 2184, 1062, 570, 63, 832, 430, 398, 372, 536, 339, 347, 931, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 282, 2257, 10036, 931, 2382, 314, 570, 883, 506, 12396, 1808, 267, 2018, 1159, 6137, 13, 262, 1551, 342, 805, 14, 10533, 10460, 626, 883, 1133, 506, 267, 13810, 1808, 1551, 342, 1077, 627, 1397, 10, 5669, 642, 1083, 14, 267, 408, 267, 746, 4279, 480, 2765, 4865, 3181, 1133, 2291, 3679, 3792, 2685, 339, 327, 710, 2569, 3102, 1824, 314, 4575, 3261, 367, 4887, 10460, 12, 1325, 543, 272, 327, 949, 849, 12591, 14, 20196, 1471, 5669, 627, 452, 10, 402, 3520, 14, 339, 347, 3145, 8, 277, 12, 536, 304, 267, 408, 267, 28382, 314, 2013, 570, 687, 314, 4887, 2656, 14, 267, 408, 267, 746, 4279, 342, 339, 347, 3495, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 715, 340, 282, 570, 295, 1485, 379, 701, 314, 1627, 536, 2575, 3495, 315, 314, 267, 4887, 2656, 12, 503, 756, 340, 314, 536, 365, 2808, 367, 282, 892, 570, 14, 267, 408, 267, 746, 4279, 342, 339, 347, 27483, 8, 277, 12, 931, 304, 267, 408, 267, 31289, 314, 4072, 402, 314, 2013, 931, 12, 8152, 282, 499, 13, 2960, 402, 5548, 27, 267, 314, 1642, 1242, 3769, 6602, 12, 314, 3499, 1242, 3769, 1584, 14, 267, 408, 267, 746, 4279, 342, 339, 347, 1568, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 314, 3141, 1568, 12, 315, 2783, 12, 402, 314, 570, 2013, 701, 536, 14, 267, 408, 267, 746, 4279, 342, 339, 347, 1166, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 376, 3679, 2851, 2382, 314, 570, 1159, 4072, 883, 506, 13810, 267, 5370, 701, 282, 6001, 7042, 14, 267, 408, 267, 746, 4279, 342, 339, 347, 13810, 63, 521, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 314, 2061, 13810, 900, 334, 305, 2197, 909, 9, 402, 314, 570, 267, 2013, 701, 536, 14, 267, 408, 267, 746, 4279, 342, 339, 347, 2737, 63, 521, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 314, 7143, 900, 334, 305, 2197, 909, 9, 402, 314, 570, 267, 2013, 701, 536, 14, 267, 408, 267, 746, 4279, 342, 339, 347, 6042, 63, 521, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 314, 2061, 6042, 900, 334, 305, 2197, 909, 9, 402, 314, 570, 267, 2013, 701, 536, 14, 267, 408, 267, 746, 4279, 342, 199, 199, 533, 23754, 6408, 8, 6408, 304, 272, 408, 272, 9739, 10036, 4887, 272, 408, 339, 347, 636, 826, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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project authors. 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. try: import hashlib md5er = hashlib.md5 except ImportError, e: import md5 md5er = md5.new import optparse import os from os.path import abspath, join, dirname, basename, exists import pickle import re import sys import subprocess import multiprocessing from subprocess import PIPE # Disabled LINT rules and reason. # build/include_what_you_use: Started giving false positives for variables # named "string" and "map" assuming that you needed to include STL headers. ENABLED_LINT_RULES = """ build/class build/deprecated build/endif_comment build/forward_decl build/include_alpha build/include_order build/printf_format build/storage_class legal/copyright readability/boost readability/braces readability/casting readability/constructors readability/fn_size readability/function readability/multiline_comment readability/multiline_string readability/streams readability/todo readability/utf8 runtime/arrays runtime/casting runtime/deprecated_fn runtime/explicit runtime/int runtime/memset runtime/mutex runtime/nonconf runtime/printf runtime/printf_format runtime/rtti runtime/sizeof runtime/string runtime/virtual runtime/vlog whitespace/blank_line whitespace/braces whitespace/comma whitespace/comments whitespace/ending_newline whitespace/indent whitespace/labels whitespace/line_length whitespace/newline whitespace/operators whitespace/parens whitespace/tab whitespace/todo """.split() # TODO(bmeurer): Fix and re-enable readability/check LINT_OUTPUT_PATTERN = re.compile(r'^.+[:(]\d+[:)]|^Done processing') def CppLintWorker(command): try: process = subprocess.Popen(command, stderr=subprocess.PIPE) process.wait() out_lines = "" error_count = -1 while True: out_line = process.stderr.readline() if out_line == '' and process.poll() != None: if error_count == -1: print "Failed to process %s" % command.pop() return 1 break m = LINT_OUTPUT_PATTERN.match(out_line) if m: out_lines += out_line error_count += 1 sys.stdout.write(out_lines) return error_count except KeyboardInterrupt: process.kill() except: print('Error running cpplint.py. Please make sure you have depot_tools' + ' in your $PATH. Lint check skipped.') process.kill() class FileContentsCache(object): def __init__(self, sums_file_name): self.sums = {} self.sums_file_name = sums_file_name def Load(self): try: sums_file = None try: sums_file = open(self.sums_file_name, 'r') self.sums = pickle.load(sums_file) except: # Cannot parse pickle for any reason. Not much we can do about it. pass finally: if sums_file: sums_file.close() def Save(self): try: sums_file = open(self.sums_file_name, 'w') pickle.dump(self.sums, sums_file) except: # Failed to write pickle. Try to clean-up behind us. if sums_file: sums_file.close() try: os.unlink(self.sums_file_name) except: pass finally: sums_file.close() def FilterUnchangedFiles(self, files): changed_or_new = [] for file in files: try: handle = open(file, "r") file_sum = md5er(handle.read()).digest() if not file in self.sums or self.sums[file] != file_sum: changed_or_new.append(file) self.sums[file] = file_sum finally: handle.close() return changed_or_new def RemoveFile(self, file): if file in self.sums: self.sums.pop(file) class SourceFileProcessor(object): """ Utility class that can run through a directory structure, find all relevant files and invoke a custom check on the files. """ def Run(self, path): all_files = [] for file in self.GetPathsToSearch(): all_files += self.FindFilesIn(join(path, file)) if not self.ProcessFiles(all_files, path): return False return True def IgnoreDir(self, name): return (name.startswith('.') or name in ('buildtools', 'data', 'gmock', 'gtest', 'kraken', 'octane', 'sunspider')) def IgnoreFile(self, name): return name.startswith('.') def FindFilesIn(self, path): result = [] for (root, dirs, files) in os.walk(path): for ignored in [x for x in dirs if self.IgnoreDir(x)]: dirs.remove(ignored) for file in files: if not self.IgnoreFile(file) and self.IsRelevant(file): result.append(join(root, file)) return result class CppLintProcessor(SourceFileProcessor): """ Lint files to check that they follow the google code style. """ def IsRelevant(self, name): return name.endswith('.cc') or name.endswith('.h') def IgnoreDir(self, name): return (super(CppLintProcessor, self).IgnoreDir(name) or (name == 'third_party')) IGNORE_LINT = ['flag-definitions.h'] def IgnoreFile(self, name): return (super(CppLintProcessor, self).IgnoreFile(name) or (name in CppLintProcessor.IGNORE_LINT)) def GetPathsToSearch(self): return ['src', 'include', 'samples', join('test', 'cctest'), join('test', 'unittests')] def GetCpplintScript(self, prio_path): for path in [prio_path] + os.environ["PATH"].split(os.pathsep): path = path.strip('"') cpplint = os.path.join(path, "cpplint.py") if os.path.isfile(cpplint): return cpplint return None def ProcessFiles(self, files, path): good_files_cache = FileContentsCache('.cpplint-cache') good_files_cache.Load() files = good_files_cache.FilterUnchangedFiles(files) if len(files) == 0: print 'No changes in files detected. Skipping cpplint check.' return True filt = '-,' + ",".join(['+' + n for n in ENABLED_LINT_RULES]) command = [sys.executable, 'cpplint.py', '--filter', filt] cpplint = self.GetCpplintScript(join(path, "tools")) if cpplint is None: print('Could not find cpplint.py. Make sure ' 'depot_tools is installed and in the path.') sys.exit(1) command = [sys.executable, cpplint, '--filter', filt] commands = join([command + [file] for file in files]) count = multiprocessing.cpu_count() pool = multiprocessing.Pool(count) try: results = pool.map_async(CppLintWorker, commands).get(999999) except KeyboardInterrupt: print "\nCaught KeyboardInterrupt, terminating workers." sys.exit(1) for i in range(len(files)): if results[i] > 0: good_files_cache.RemoveFile(files[i]) total_errors = sum(results) print "Total errors found: %d" % total_errors good_files_cache.Save() return total_errors == 0 COPYRIGHT_HEADER_PATTERN = re.compile( r'Copyright [\d-]*20[0-1][0-9] the V8 project authors. All rights reserved.') class SourceProcessor(SourceFileProcessor): """ Check that all files include a copyright notice and no trailing whitespaces. """ RELEVANT_EXTENSIONS = ['.js', '.cc', '.h', '.py', '.c', '.status', '.gyp', '.gypi'] # Overwriting the one in the parent class. def FindFilesIn(self, path): if os.path.exists(path+'/.git'): output = subprocess.Popen('git ls-files --full-name', stdout=PIPE, cwd=path, shell=True) result = [] for file in output.stdout.read().split(): for dir_part in os.path.dirname(file).replace(os.sep, '/').split('/'): if self.IgnoreDir(dir_part): break else: if (self.IsRelevant(file) and os.path.exists(file) and not self.IgnoreFile(file)): result.append(join(path, file)) if output.wait() == 0: return result return super(SourceProcessor, self).FindFilesIn(path) def IsRelevant(self, name): for ext in SourceProcessor.RELEVANT_EXTENSIONS: if name.endswith(ext): return True return False def GetPathsToSearch(self): return ['.'] def IgnoreDir(self, name): return (super(SourceProcessor, self).IgnoreDir(name) or name in ('third_party', 'gyp', 'out', 'obj', 'DerivedSources')) IGNORE_COPYRIGHTS = ['box2d.js', 'cpplint.py', 'copy.js', 'corrections.js', 'crypto.js', 'daemon.py', 'earley-boyer.js', 'fannkuch.js', 'fasta.js', 'jsmin.py', 'libraries.cc', 'libraries-empty.cc', 'lua_binarytrees.js', 'memops.js', 'primes.js', 'raytrace.js', 'regexp-pcre.js', 'gnuplot-4.6.3-emscripten.js', 'zlib.js'] IGNORE_TABS = IGNORE_COPYRIGHTS + ['unicode-test.js', 'html-comments.js'] def EndOfDeclaration(self, line): return line == "}" or line == "};" def StartOfDeclaration(self, line): return line.find("//") == 0 or \ line.find("/*") == 0 or \ line.find(") {") != -1 def ProcessContents(self, name, contents): result = True base = basename(name) if not base in SourceProcessor.IGNORE_TABS: if '\t' in contents: print "%s contains tabs" % name result = False if not base in SourceProcessor.IGNORE_COPYRIGHTS: if not COPYRIGHT_HEADER_PATTERN.search(contents): print "%s is missing a correct copyright header." % name result = False if ' \n' in contents or contents.endswith(' '): line = 0 lines = [] parts = contents.split(' \n') if not contents.endswith(' '): parts.pop() for part in parts: line += part.count('\n') + 1 lines.append(str(line)) linenumbers = ', '.join(lines) if len(lines) > 1: print "%s has trailing whitespaces in lines %s." % (name, linenumbers) else: print "%s has trailing whitespaces in line %s." % (name, linenumbers) result = False if not contents.endswith('\n') or contents.endswith('\n\n'): print "%s does not end with a single new line." % name result = False # Check two empty lines between declarations. if name.endswith(".cc"): line = 0 lines = [] parts = contents.split('\n') while line < len(parts) - 2: if self.EndOfDeclaration(parts[line]): if self.StartOfDeclaration(parts[line + 1]): lines.append(str(line + 1)) line += 1 elif parts[line + 1] == "" and \ self.StartOfDeclaration(parts[line + 2]): lines.append(str(line + 1)) line += 2 line += 1 if len(lines) >= 1: linenumbers = ', '.join(lines) if len(lines) > 1: print "%s does not have two empty lines between declarations " \ "in lines %s." % (name, linenumbers) else: print "%s does not have two empty lines between declarations " \ "in line %s." % (name, linenumbers) result = False return result def ProcessFiles(self, files, path): success = True violations = 0 for file in files: try: handle = open(file) contents = handle.read() if not self.ProcessContents(file, contents): success = False violations += 1 finally: handle.close() print "Total violating files: %s" % violations return success def CheckRuntimeVsNativesNameClashes(workspace): code = subprocess.call( [sys.executable, join(workspace, "tools", "check-name-clashes.py")]) return code == 0 def CheckExternalReferenceRegistration(workspace): code = subprocess.call( [sys.executable, join(workspace, "tools", "external-reference-check.py")]) return code == 0 def GetOptions(): result = optparse.OptionParser() result.add_option('--no-lint', help="Do not run cpplint", default=False, action="store_true") return result def Main(): workspace = abspath(join(dirname(sys.argv[0]), '..')) parser = GetOptions() (options, args) = parser.parse_args() success = True print "Running C++ lint check..." if not options.no_lint: success = CppLintProcessor().Run(workspace) and success print "Running copyright header, trailing whitespaces and " \ "two empty lines between declarations check..." success = SourceProcessor().Run(workspace) and success success = CheckRuntimeVsNativesNameClashes(workspace) and success success = CheckExternalReferenceRegistration(workspace) and success if success: return 0 else: return 1 if __name__ == '__main__': sys.exit(Main())
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 6029, 314, 812, 24, 2199, 11462, 14, 2900, 4481, 4644, 14, 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, 755, 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, 755, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 199, 3, 755, 6450, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 199, 3, 755, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 755, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 199, 3, 755, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 893, 26, 523, 492, 8337, 523, 6128, 21, 281, 275, 8337, 14, 1064, 21, 199, 2590, 3545, 12, 325, 26, 523, 492, 6128, 21, 523, 6128, 21, 281, 275, 6128, 21, 14, 1222, 421, 199, 646, 8691, 199, 646, 747, 199, 504, 747, 14, 515, 492, 19529, 12, 4263, 12, 9017, 12, 9593, 12, 3495, 199, 646, 5927, 199, 646, 295, 199, 646, 984, 199, 646, 3873, 199, 646, 12866, 199, 504, 3873, 492, 22773, 199, 199, 3, 5289, 1909, 491, 2919, 4713, 436, 4499, 14, 199, 3, 1900, 15, 2613, 63, 10058, 63, 13297, 63, 1180, 26, 1933, 5015, 15131, 3055, 27609, 367, 2860, 199, 3, 221, 4310, 298, 875, 2, 436, 298, 1130, 2, 18002, 626, 1265, 4346, 370, 2387, 4384, 44, 2323, 14, 199, 199, 15704, 63, 44, 2919, 63, 31490, 275, 408, 199, 1506, 15, 533, 199, 1506, 15, 6667, 199, 1506, 15, 13739, 63, 3349, 199, 1506, 15, 6688, 63, 9427, 199, 1506, 15, 2613, 63, 4468, 199, 1506, 15, 2613, 63, 1648, 199, 1506, 15, 19139, 63, 908, 199, 1506, 15, 3494, 63, 533, 199, 9666, 15, 7307, 199, 29814, 15, 15589, 199, 29814, 15, 7828, 823, 199, 29814, 15, 2931, 316, 199, 29814, 15, 1880, 83, 199, 29814, 15, 2324, 63, 890, 199, 29814, 15, 1593, 199, 29814, 15, 21108, 63, 3349, 199, 29814, 15, 21108, 63, 875, 199, 29814, 15, 11231, 199, 29814, 15, 11396, 199, 29814, 15, 1624, 24, 199, 7726, 15, 10095, 199, 7726, 15, 2931, 316, 199, 7726, 15, 6667, 63, 2324, 199, 7726, 15, 10306, 199, 7726, 15, 442, 199, 7726, 15, 5286, 409, 199, 7726, 15, 19078, 199, 7726, 15, 2865, 2190, 199, 7726, 15, 19139, 199, 7726, 15, 19139, 63, 908, 199, 7726, 15, 2591, 280, 199, 7726, 15, 12590, 199, 7726, 15, 875, 199, 7726, 15, 2065, 199, 7726, 15, 86, 793, 199, 8506, 15, 2500, 63, 604, 199, 8506, 15, 7828, 823, 199, 8506, 15, 13184, 199, 8506, 15, 6223, 199, 8506, 15, 3219, 63, 12210, 199, 8506, 15, 3724, 199, 8506, 15, 3512, 199, 8506, 15, 604, 63, 1267, 199, 8506, 15, 12210, 199, 8506, 15, 12688, 199, 8506, 15, 31910, 199, 8506, 15, 2902, 199, 8506, 15, 11396, 199, 23045, 1294, 342, 199, 199, 3, 3254, 8, 66, 278, 608, 82, 304, 14811, 436, 295, 13, 4296, 1586, 3616, 15, 1074, 199, 199, 44, 2919, 63, 8414, 63, 10764, 275, 295, 14, 2014, 8, 82, 4289, 6977, 1491, 8, 7272, 68, 11, 1491, 1874, 92, 62, 10759, 6661, 358, 421, 199, 318, 445, 802, 44, 442, 12678, 8, 1531, 304, 523, 862, 26, 272, 2112, 275, 3873, 14, 7942, 8, 1531, 12, 4635, 29, 5781, 14, 6089, 9, 272, 2112, 14, 2573, 342, 272, 734, 63, 1278, 275, 3087, 272, 1125, 63, 835, 275, 446, 17, 272, 1830, 715, 26, 489, 734, 63, 604, 275, 2112, 14, 3083, 14, 6407, 342, 489, 340, 734, 63, 604, 508, 2125, 436, 2112, 14, 6843, 342, 1137, 488, 26, 267, 340, 1125, 63, 835, 508, 446, 17, 26, 881, 870, 298, 4276, 370, 2112, 450, 83, 2, 450, 1414, 14, 1935, 342, 881, 372, 413, 267, 2059, 489, 333, 275, 491, 2919, 63, 8414, 63, 10764, 14, 1431, 8, 548, 63, 604, 9, 489, 340, 333, 26, 267, 734, 63, 1278, 847, 734, 63, 604, 267, 1125, 63, 835, 847, 413, 272, 984, 14, 2703, 14, 952, 8, 548, 63, 1278, 9, 272, 372, 1125, 63, 835, 523, 871, 13483, 26, 272, 2112, 14, 8997, 342, 523, 871, 26, 272, 870, 360, 547, 3879, 7246, 3854, 14, 647, 14, 7754, 1852, 3238, 1265, 1172, 32544, 63, 2537, 7, 435, 881, 283, 315, 2195, 2672, 3243, 14, 491, 442, 1104, 9645, 2659, 272, 2112, 14, 8997, 342, 421, 199, 533, 3814, 11383, 4437, 8, 785, 304, 819, 347, 636, 826, 721, 277, 12, 27690, 63, 493, 63, 354, 304, 272, 291, 14, 22178, 275, 1052, 272, 291, 14, 22178, 63, 493, 63, 354, 275, 27690, 63, 493, 63, 354, 819, 347, 7190, 8, 277, 304, 272, 862, 26, 489, 27690, 63, 493, 275, 488, 489, 862, 26, 267, 27690, 63, 493, 275, 1551, 8 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 6029, 314, 812, 24, 2199, 11462, 14, 2900, 4481, 4644, 14, 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, 755, 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, 755, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 199, 3, 755, 6450, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 199, 3, 755, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 755, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 199, 3, 755, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 893, 26, 523, 492, 8337, 523, 6128, 21, 281, 275, 8337, 14, 1064, 21, 199, 2590, 3545, 12, 325, 26, 523, 492, 6128, 21, 523, 6128, 21, 281, 275, 6128, 21, 14, 1222, 421, 199, 646, 8691, 199, 646, 747, 199, 504, 747, 14, 515, 492, 19529, 12, 4263, 12, 9017, 12, 9593, 12, 3495, 199, 646, 5927, 199, 646, 295, 199, 646, 984, 199, 646, 3873, 199, 646, 12866, 199, 504, 3873, 492, 22773, 199, 199, 3, 5289, 1909, 491, 2919, 4713, 436, 4499, 14, 199, 3, 1900, 15, 2613, 63, 10058, 63, 13297, 63, 1180, 26, 1933, 5015, 15131, 3055, 27609, 367, 2860, 199, 3, 221, 4310, 298, 875, 2, 436, 298, 1130, 2, 18002, 626, 1265, 4346, 370, 2387, 4384, 44, 2323, 14, 199, 199, 15704, 63, 44, 2919, 63, 31490, 275, 408, 199, 1506, 15, 533, 199, 1506, 15, 6667, 199, 1506, 15, 13739, 63, 3349, 199, 1506, 15, 6688, 63, 9427, 199, 1506, 15, 2613, 63, 4468, 199, 1506, 15, 2613, 63, 1648, 199, 1506, 15, 19139, 63, 908, 199, 1506, 15, 3494, 63, 533, 199, 9666, 15, 7307, 199, 29814, 15, 15589, 199, 29814, 15, 7828, 823, 199, 29814, 15, 2931, 316, 199, 29814, 15, 1880, 83, 199, 29814, 15, 2324, 63, 890, 199, 29814, 15, 1593, 199, 29814, 15, 21108, 63, 3349, 199, 29814, 15, 21108, 63, 875, 199, 29814, 15, 11231, 199, 29814, 15, 11396, 199, 29814, 15, 1624, 24, 199, 7726, 15, 10095, 199, 7726, 15, 2931, 316, 199, 7726, 15, 6667, 63, 2324, 199, 7726, 15, 10306, 199, 7726, 15, 442, 199, 7726, 15, 5286, 409, 199, 7726, 15, 19078, 199, 7726, 15, 2865, 2190, 199, 7726, 15, 19139, 199, 7726, 15, 19139, 63, 908, 199, 7726, 15, 2591, 280, 199, 7726, 15, 12590, 199, 7726, 15, 875, 199, 7726, 15, 2065, 199, 7726, 15, 86, 793, 199, 8506, 15, 2500, 63, 604, 199, 8506, 15, 7828, 823, 199, 8506, 15, 13184, 199, 8506, 15, 6223, 199, 8506, 15, 3219, 63, 12210, 199, 8506, 15, 3724, 199, 8506, 15, 3512, 199, 8506, 15, 604, 63, 1267, 199, 8506, 15, 12210, 199, 8506, 15, 12688, 199, 8506, 15, 31910, 199, 8506, 15, 2902, 199, 8506, 15, 11396, 199, 23045, 1294, 342, 199, 199, 3, 3254, 8, 66, 278, 608, 82, 304, 14811, 436, 295, 13, 4296, 1586, 3616, 15, 1074, 199, 199, 44, 2919, 63, 8414, 63, 10764, 275, 295, 14, 2014, 8, 82, 4289, 6977, 1491, 8, 7272, 68, 11, 1491, 1874, 92, 62, 10759, 6661, 358, 421, 199, 318, 445, 802, 44, 442, 12678, 8, 1531, 304, 523, 862, 26, 272, 2112, 275, 3873, 14, 7942, 8, 1531, 12, 4635, 29, 5781, 14, 6089, 9, 272, 2112, 14, 2573, 342, 272, 734, 63, 1278, 275, 3087, 272, 1125, 63, 835, 275, 446, 17, 272, 1830, 715, 26, 489, 734, 63, 604, 275, 2112, 14, 3083, 14, 6407, 342, 489, 340, 734, 63, 604, 508, 2125, 436, 2112, 14, 6843, 342, 1137, 488, 26, 267, 340, 1125, 63, 835, 508, 446, 17, 26, 881, 870, 298, 4276, 370, 2112, 450, 83, 2, 450, 1414, 14, 1935, 342, 881, 372, 413, 267, 2059, 489, 333, 275, 491, 2919, 63, 8414, 63, 10764, 14, 1431, 8, 548, 63, 604, 9, 489, 340, 333, 26, 267, 734, 63, 1278, 847, 734, 63, 604, 267, 1125, 63, 835, 847, 413, 272, 984, 14, 2703, 14, 952, 8, 548, 63, 1278, 9, 272, 372, 1125, 63, 835, 523, 871, 13483, 26, 272, 2112, 14, 8997, 342, 523, 871, 26, 272, 870, 360, 547, 3879, 7246, 3854, 14, 647, 14, 7754, 1852, 3238, 1265, 1172, 32544, 63, 2537, 7, 435, 881, 283, 315, 2195, 2672, 3243, 14, 491, 442, 1104, 9645, 2659, 272, 2112, 14, 8997, 342, 421, 199, 533, 3814, 11383, 4437, 8, 785, 304, 819, 347, 636, 826, 721, 277, 12, 27690, 63, 493, 63, 354, 304, 272, 291, 14, 22178, 275, 1052, 272, 291, 14, 22178, 63, 493, 63, 354, 275, 27690, 63, 493, 63, 354, 819, 347, 7190, 8, 277, 304, 272, 862, 26, 489, 27690, 63, 493, 275, 488, 489, 862, 26, 267, 27690, 63, 493, 275, 1551, 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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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 ]
fujunwei/chromium-crosswalk
native_client_sdk/src/build_tools/sdk_tools/command/list.py
152
1736
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. def List(remote_manifest, local_manifest, display_revisions): any_bundles_need_update = False print 'Bundles:' print ' I: installed\n *: update available\n' for bundle in remote_manifest.GetBundles(): local_bundle = local_manifest.GetBundle(bundle.name) needs_update = local_bundle and local_manifest.BundleNeedsUpdate(bundle) if needs_update: any_bundles_need_update = True _PrintBundle(local_bundle, bundle, needs_update, display_revisions) if not any_bundles_need_update: print '\nAll installed bundles are up-to-date.' local_only_bundles = set([b.name for b in local_manifest.GetBundles()]) local_only_bundles -= set([b.name for b in remote_manifest.GetBundles()]) if local_only_bundles: print '\nBundles installed locally that are not available remotely:' for bundle_name in local_only_bundles: local_bundle = local_manifest.GetBundle(bundle_name) _PrintBundle(local_bundle, None, False, display_revisions) def _PrintBundle(local_bundle, bundle, needs_update, display_revisions): installed = local_bundle is not None # If bundle is None, there is no longer a remote bundle with this name. if bundle is None: bundle = local_bundle if display_revisions: if needs_update: revision = ' (r%s -> r%s)' % (local_bundle.revision, bundle.revision) else: revision = ' (r%s)' % (bundle.revision,) else: revision = '' print (' %s%s %s (%s)%s' % ( 'I' if installed else ' ', '*' if needs_update else ' ', bundle.name, bundle.stability, revision))
bsd-3-clause
[ 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 318, 3820, 8, 3846, 63, 6418, 12, 2257, 63, 6418, 12, 2929, 63, 23449, 304, 523, 1263, 63, 66, 18793, 63, 9321, 63, 873, 275, 756, 523, 870, 283, 34, 18793, 4881, 523, 870, 283, 473, 26, 4903, 60, 78, 627, 26, 1678, 2808, 60, 78, 7, 523, 367, 8844, 315, 3982, 63, 6418, 14, 1002, 34, 18793, 837, 272, 2257, 63, 6469, 275, 2257, 63, 6418, 14, 1002, 12320, 8, 6469, 14, 354, 9, 272, 4839, 63, 873, 275, 2257, 63, 6469, 436, 2257, 63, 6418, 14, 12320, 28390, 4152, 8, 6469, 9, 272, 340, 4839, 63, 873, 26, 489, 1263, 63, 66, 18793, 63, 9321, 63, 873, 275, 715, 339, 485, 5375, 12320, 8, 1832, 63, 6469, 12, 8844, 12, 4839, 63, 873, 12, 2929, 63, 23449, 9, 819, 340, 440, 1263, 63, 66, 18793, 63, 9321, 63, 873, 26, 272, 870, 1557, 78, 2422, 4903, 27206, 787, 1536, 13, 475, 13, 602, 3530, 819, 2257, 63, 2118, 63, 66, 18793, 275, 663, 779, 66, 14, 354, 367, 330, 315, 2257, 63, 6418, 14, 1002, 34, 18793, 9383, 523, 2257, 63, 2118, 63, 66, 18793, 4862, 663, 779, 66, 14, 354, 367, 330, 315, 3982, 63, 6418, 14, 1002, 34, 18793, 9383, 523, 340, 2257, 63, 2118, 63, 66, 18793, 26, 272, 870, 1557, 78, 34, 18793, 4903, 17738, 626, 787, 440, 2808, 3982, 590, 4881, 272, 367, 8844, 63, 354, 315, 2257, 63, 2118, 63, 66, 18793, 26, 489, 2257, 63, 6469, 275, 2257, 63, 6418, 14, 1002, 12320, 8, 6469, 63, 354, 9, 489, 485, 5375, 12320, 8, 1832, 63, 6469, 12, 488, 12, 756, 12, 2929, 63, 23449, 9, 421, 199, 318, 485, 5375, 12320, 8, 1832, 63, 6469, 12, 8844, 12, 4839, 63, 873, 12, 2929, 63, 23449, 304, 523, 4903, 275, 2257, 63, 6469, 365, 440, 488, 523, 327, 982, 8844, 365, 488, 12, 2337, 365, 949, 8088, 282, 3982, 8844, 543, 642, 536, 14, 523, 340, 8844, 365, 488, 26, 272, 8844, 275, 2257, 63, 6469, 819, 340, 2929, 63, 23449, 26, 272, 340, 4839, 63, 873, 26, 489, 6974, 275, 283, 334, 82, 5, 83, 1035, 519, 5, 83, 3171, 450, 334, 1832, 63, 6469, 14, 5792, 12, 8844, 14, 5792, 9, 272, 587, 26, 489, 6974, 275, 283, 334, 82, 5, 83, 3171, 450, 334, 6469, 14, 5792, 4258, 523, 587, 26, 272, 6974, 275, 2125, 819, 870, 661, 221, 450, 83, 5, 83, 450, 83, 4366, 83, 19656, 83, 7, 450, 334, 272, 283, 41, 7, 340, 4903, 587, 283, 1656, 272, 13626, 340, 4839, 63, 873, 587, 283, 1656, 272, 8844, 14, 354, 12, 272, 8844, 14, 270, 3616, 12, 272, 6974, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 318, 3820, 8, 3846, 63, 6418, 12, 2257, 63, 6418, 12, 2929, 63, 23449, 304, 523, 1263, 63, 66, 18793, 63, 9321, 63, 873, 275, 756, 523, 870, 283, 34, 18793, 4881, 523, 870, 283, 473, 26, 4903, 60, 78, 627, 26, 1678, 2808, 60, 78, 7, 523, 367, 8844, 315, 3982, 63, 6418, 14, 1002, 34, 18793, 837, 272, 2257, 63, 6469, 275, 2257, 63, 6418, 14, 1002, 12320, 8, 6469, 14, 354, 9, 272, 4839, 63, 873, 275, 2257, 63, 6469, 436, 2257, 63, 6418, 14, 12320, 28390, 4152, 8, 6469, 9, 272, 340, 4839, 63, 873, 26, 489, 1263, 63, 66, 18793, 63, 9321, 63, 873, 275, 715, 339, 485, 5375, 12320, 8, 1832, 63, 6469, 12, 8844, 12, 4839, 63, 873, 12, 2929, 63, 23449, 9, 819, 340, 440, 1263, 63, 66, 18793, 63, 9321, 63, 873, 26, 272, 870, 1557, 78, 2422, 4903, 27206, 787, 1536, 13, 475, 13, 602, 3530, 819, 2257, 63, 2118, 63, 66, 18793, 275, 663, 779, 66, 14, 354, 367, 330, 315, 2257, 63, 6418, 14, 1002, 34, 18793, 9383, 523, 2257, 63, 2118, 63, 66, 18793, 4862, 663, 779, 66, 14, 354, 367, 330, 315, 3982, 63, 6418, 14, 1002, 34, 18793, 9383, 523, 340, 2257, 63, 2118, 63, 66, 18793, 26, 272, 870, 1557, 78, 34, 18793, 4903, 17738, 626, 787, 440, 2808, 3982, 590, 4881, 272, 367, 8844, 63, 354, 315, 2257, 63, 2118, 63, 66, 18793, 26, 489, 2257, 63, 6469, 275, 2257, 63, 6418, 14, 1002, 12320, 8, 6469, 63, 354, 9, 489, 485, 5375, 12320, 8, 1832, 63, 6469, 12, 488, 12, 756, 12, 2929, 63, 23449, 9, 421, 199, 318, 485, 5375, 12320, 8, 1832, 63, 6469, 12, 8844, 12, 4839, 63, 873, 12, 2929, 63, 23449, 304, 523, 4903, 275, 2257, 63, 6469, 365, 440, 488, 523, 327, 982, 8844, 365, 488, 12, 2337, 365, 949, 8088, 282, 3982, 8844, 543, 642, 536, 14, 523, 340, 8844, 365, 488, 26, 272, 8844, 275, 2257, 63, 6469, 819, 340, 2929, 63, 23449, 26, 272, 340, 4839, 63, 873, 26, 489, 6974, 275, 283, 334, 82, 5, 83, 1035, 519, 5, 83, 3171, 450, 334, 1832, 63, 6469, 14, 5792, 12, 8844, 14, 5792, 9, 272, 587, 26, 489, 6974, 275, 283, 334, 82, 5, 83, 3171, 450, 334, 6469, 14, 5792, 4258, 523, 587, 26, 272, 6974, 275, 2125, 819, 870, 661, 221, 450, 83, 5, 83, 450, 83, 4366, 83, 19656, 83, 7, 450, 334, 272, 283, 41, 7, 340, 4903, 587, 283, 1656, 272, 13626, 340, 4839, 63, 873, 587, 283, 1656, 272, 8844, 14, 354, 12, 272, 8844, 14, 270, 3616, 12, 272, 6974, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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: List[List[int]] """ # Non-recursive solution if not nums: return [] stack = [-1] permutation = [] permutations = [] while len(stack): index = stack.pop() index += 1 while index < len(nums): if nums[index] not in permutation: break index += 1 else: if len(permutation): permutation.pop() continue stack.append(index) stack.append(-1) permutation.append(nums[index]) if len(permutation) == len(nums): permutations.append(list(permutation)) return permutations # recursive solution # def dfs(bag,partitionList,result): # if bag == []: # result.append(partitionList) # else: # for i in range(len(bag)): # dfs(bag[:i] + bag[i+1:], partitionList + [bag[i]], result) # if not nums: # return [] # result = [] # dfs(nums,[],result) # return result
epl-1.0
[ 533, 9274, 8, 785, 304, 272, 347, 10869, 938, 8, 277, 12, 24047, 304, 267, 408, 267, 520, 466, 24047, 26, 3820, 59, 442, 61, 267, 520, 4500, 26, 3820, 59, 1296, 59, 442, 2677, 267, 408, 267, 327, 10172, 13, 9931, 8744, 267, 340, 440, 24047, 26, 288, 372, 942, 267, 3464, 275, 5243, 17, 61, 267, 22966, 275, 942, 267, 26899, 275, 942, 267, 1830, 822, 8, 2340, 304, 288, 1478, 275, 3464, 14, 1935, 342, 288, 1478, 847, 413, 288, 1830, 1478, 665, 822, 8, 16084, 304, 355, 340, 24047, 59, 1080, 61, 440, 315, 22966, 26, 490, 2059, 355, 1478, 847, 413, 288, 587, 26, 355, 340, 822, 8, 23832, 304, 490, 22966, 14, 1935, 342, 355, 1980, 953, 3464, 14, 740, 8, 1080, 9, 288, 3464, 14, 740, 2801, 17, 9, 288, 22966, 14, 740, 8, 16084, 59, 1080, 566, 288, 340, 822, 8, 23832, 9, 508, 822, 8, 16084, 304, 355, 26899, 14, 740, 8, 513, 8, 23832, 430, 398, 372, 26899, 421, 199, 3, 9133, 8744, 199, 3, 260, 347, 366, 2319, 8, 19430, 12, 5312, 1296, 12, 1099, 304, 199, 3, 3777, 340, 330, 643, 508, 18410, 199, 3, 463, 754, 14, 740, 8, 5312, 1296, 9, 199, 3, 3777, 587, 26, 199, 3, 463, 367, 284, 315, 1425, 8, 552, 8, 19430, 2298, 199, 3, 9326, 366, 2319, 8, 19430, 1491, 73, 61, 435, 330, 643, 59, 73, 11, 17, 8429, 6484, 1296, 435, 359, 19430, 59, 73, 2365, 754, 9, 199, 199, 3, 260, 340, 440, 24047, 26, 199, 3, 3777, 372, 942, 199, 3, 260, 754, 275, 942, 199, 3, 260, 366, 2319, 8, 16084, 14343, 467, 1099, 9, 199, 3, 260, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 9274, 8, 785, 304, 272, 347, 10869, 938, 8, 277, 12, 24047, 304, 267, 408, 267, 520, 466, 24047, 26, 3820, 59, 442, 61, 267, 520, 4500, 26, 3820, 59, 1296, 59, 442, 2677, 267, 408, 267, 327, 10172, 13, 9931, 8744, 267, 340, 440, 24047, 26, 288, 372, 942, 267, 3464, 275, 5243, 17, 61, 267, 22966, 275, 942, 267, 26899, 275, 942, 267, 1830, 822, 8, 2340, 304, 288, 1478, 275, 3464, 14, 1935, 342, 288, 1478, 847, 413, 288, 1830, 1478, 665, 822, 8, 16084, 304, 355, 340, 24047, 59, 1080, 61, 440, 315, 22966, 26, 490, 2059, 355, 1478, 847, 413, 288, 587, 26, 355, 340, 822, 8, 23832, 304, 490, 22966, 14, 1935, 342, 355, 1980, 953, 3464, 14, 740, 8, 1080, 9, 288, 3464, 14, 740, 2801, 17, 9, 288, 22966, 14, 740, 8, 16084, 59, 1080, 566, 288, 340, 822, 8, 23832, 9, 508, 822, 8, 16084, 304, 355, 26899, 14, 740, 8, 513, 8, 23832, 430, 398, 372, 26899, 421, 199, 3, 9133, 8744, 199, 3, 260, 347, 366, 2319, 8, 19430, 12, 5312, 1296, 12, 1099, 304, 199, 3, 3777, 340, 330, 643, 508, 18410, 199, 3, 463, 754, 14, 740, 8, 5312, 1296, 9, 199, 3, 3777, 587, 26, 199, 3, 463, 367, 284, 315, 1425, 8, 552, 8, 19430, 2298, 199, 3, 9326, 366, 2319, 8, 19430, 1491, 73, 61, 435, 330, 643, 59, 73, 11, 17, 8429, 6484, 1296, 435, 359, 19430, 59, 73, 2365, 754, 9, 199, 199, 3, 260, 340, 440, 24047, 26, 199, 3, 3777, 372, 942, 199, 3, 260, 754, 275, 942, 199, 3, 260, 366, 2319, 8, 16084, 14343, 467, 1099, 9, 199, 3, 260, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
aivarsk/scrapy
scrapy/downloadermiddlewares/retry.py
108
3570
""" An extension to retry failed requests that are potentially caused by temporary problems such as a connection timeout or HTTP 500 error. You can change the behaviour of this middleware by modifing the scraping settings: RETRY_TIMES - how many times to retry a failed page RETRY_HTTP_CODES - which HTTP response codes to retry Failed pages are collected on the scraping process and rescheduled at the end, once the spider has finished crawling all regular (non failed) pages. Once there is no more failed pages to retry this middleware sends a signal (retry_complete), so other extensions could connect to that signal. About HTTP errors to consider: - You may want to remove 400 from RETRY_HTTP_CODES, if you stick to the HTTP protocol. It's included by default because it's a common code used to indicate server overload, which would be something we want to retry """ import logging from twisted.internet import defer from twisted.internet.error import TimeoutError, DNSLookupError, \ ConnectionRefusedError, ConnectionDone, ConnectError, \ ConnectionLost, TCPTimedOutError from scrapy.exceptions import NotConfigured from scrapy.utils.response import response_status_message from scrapy.xlib.tx import ResponseFailed logger = logging.getLogger(__name__) class RetryMiddleware(object): # IOError is raised by the HttpCompression middleware when trying to # decompress an empty response EXCEPTIONS_TO_RETRY = (defer.TimeoutError, TimeoutError, DNSLookupError, ConnectionRefusedError, ConnectionDone, ConnectError, ConnectionLost, TCPTimedOutError, ResponseFailed, IOError) def __init__(self, settings): if not settings.getbool('RETRY_ENABLED'): raise NotConfigured self.max_retry_times = settings.getint('RETRY_TIMES') self.retry_http_codes = set(int(x) for x in settings.getlist('RETRY_HTTP_CODES')) self.priority_adjust = settings.getint('RETRY_PRIORITY_ADJUST') @classmethod def from_crawler(cls, crawler): return cls(crawler.settings) def process_response(self, request, response, spider): if request.meta.get('dont_retry', False): return response if response.status in self.retry_http_codes: reason = response_status_message(response.status) return self._retry(request, reason, spider) or response return response def process_exception(self, request, exception, spider): if isinstance(exception, self.EXCEPTIONS_TO_RETRY) \ and not request.meta.get('dont_retry', False): return self._retry(request, exception, spider) def _retry(self, request, reason, spider): retries = request.meta.get('retry_times', 0) + 1 if retries <= self.max_retry_times: logger.debug("Retrying %(request)s (failed %(retries)d times): %(reason)s", {'request': request, 'retries': retries, 'reason': reason}, extra={'spider': spider}) retryreq = request.copy() retryreq.meta['retry_times'] = retries retryreq.dont_filter = True retryreq.priority = request.priority + self.priority_adjust return retryreq else: logger.debug("Gave up retrying %(request)s (failed %(retries)d times): %(reason)s", {'request': request, 'retries': retries, 'reason': reason}, extra={'spider': spider})
bsd-3-clause
[ 624, 199, 2493, 3329, 370, 7269, 3405, 4145, 626, 787, 18994, 18104, 701, 7937, 199, 22959, 4066, 465, 282, 1950, 2653, 503, 3101, 6891, 1125, 14, 199, 199, 5556, 883, 1570, 314, 13942, 402, 642, 10816, 701, 1953, 70, 316, 314, 4061, 1330, 316, 2202, 26, 199, 27778, 63, 11342, 654, 446, 4212, 5002, 5431, 370, 7269, 282, 3405, 2034, 199, 27778, 63, 2856, 63, 15639, 446, 1314, 3101, 1177, 9479, 370, 7269, 199, 199, 4276, 6497, 787, 13736, 641, 314, 4061, 1330, 316, 2112, 436, 522, 3082, 68, 737, 314, 1284, 12, 199, 5089, 314, 18094, 965, 9158, 286, 1773, 2983, 1006, 5578, 334, 2865, 3405, 9, 6497, 14, 19468, 199, 16990, 365, 949, 1655, 3405, 6497, 370, 7269, 642, 10816, 16178, 282, 4673, 199, 8, 7154, 63, 4883, 395, 880, 1163, 5478, 4293, 4907, 370, 626, 4673, 14, 199, 199, 18816, 3101, 2552, 370, 11201, 26, 199, 199, 13, 2047, 1443, 2934, 370, 2813, 8290, 687, 17409, 5782, 63, 2856, 63, 15639, 12, 340, 1265, 29404, 370, 314, 3101, 523, 4113, 14, 2779, 1159, 5120, 701, 849, 2952, 652, 1159, 282, 2863, 1233, 1202, 370, 523, 6623, 1654, 1806, 912, 12, 1314, 3955, 506, 6020, 781, 2934, 370, 7269, 199, 624, 199, 646, 2050, 199, 199, 504, 7390, 14, 4901, 492, 10133, 199, 504, 7390, 14, 4901, 14, 705, 492, 31886, 12, 10237, 32060, 12, 971, 267, 8113, 2891, 2972, 547, 12, 8113, 10759, 12, 15175, 547, 12, 971, 267, 8113, 14074, 12, 13488, 28682, 2204, 547, 199, 199, 504, 18918, 14, 3924, 492, 2832, 9902, 199, 504, 18918, 14, 1208, 14, 1310, 492, 1177, 63, 1205, 63, 1188, 199, 504, 18918, 14, 88, 773, 14, 2347, 492, 7232, 4276, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 20506, 6608, 8, 785, 304, 339, 327, 5925, 365, 4915, 701, 314, 4760, 25551, 10816, 1380, 9936, 370, 272, 327, 24733, 376, 2701, 1177, 272, 3651, 7177, 2823, 63, 2566, 63, 27778, 275, 334, 11610, 14, 19382, 12, 31886, 12, 10237, 32060, 12, 2574, 8113, 2891, 2972, 547, 12, 8113, 10759, 12, 15175, 547, 12, 2574, 8113, 14074, 12, 13488, 28682, 2204, 547, 12, 7232, 4276, 12, 2574, 5925, 9, 339, 347, 636, 826, 721, 277, 12, 2202, 304, 267, 340, 440, 2202, 14, 362, 2245, 360, 27778, 63, 15704, 735, 288, 746, 2832, 9902, 267, 291, 14, 988, 63, 7154, 63, 4508, 275, 2202, 14, 26627, 360, 27778, 63, 11342, 654, 358, 267, 291, 14, 7154, 63, 1014, 63, 6021, 275, 663, 8, 442, 8, 88, 9, 367, 671, 315, 2202, 14, 21343, 360, 27778, 63, 2856, 63, 15639, 1333, 267, 291, 14, 6693, 63, 10917, 275, 2202, 14, 26627, 360, 27778, 63, 25144, 63, 1554, 42, 7698, 358, 339, 768, 3744, 272, 347, 687, 63, 23972, 8, 1886, 12, 29550, 304, 267, 372, 843, 8, 23972, 14, 1751, 9, 339, 347, 2112, 63, 1310, 8, 277, 12, 1056, 12, 1177, 12, 18094, 304, 267, 340, 1056, 14, 2024, 14, 362, 360, 18671, 63, 7154, 297, 756, 304, 288, 372, 1177, 267, 340, 1177, 14, 1205, 315, 291, 14, 7154, 63, 1014, 63, 6021, 26, 288, 4499, 275, 1177, 63, 1205, 63, 1188, 8, 1310, 14, 1205, 9, 288, 372, 291, 423, 7154, 8, 1069, 12, 4499, 12, 18094, 9, 503, 1177, 267, 372, 1177, 339, 347, 2112, 63, 1971, 8, 277, 12, 1056, 12, 1919, 12, 18094, 304, 267, 340, 1228, 8, 1971, 12, 291, 14, 25054, 63, 2566, 63, 27778, 9, 971, 355, 436, 440, 1056, 14, 2024, 14, 362, 360, 18671, 63, 7154, 297, 756, 304, 1467, 372, 291, 423, 7154, 8, 1069, 12, 1919, 12, 18094, 9, 339, 347, 485, 7154, 8, 277, 12, 1056, 12, 4499, 12, 18094, 304, 267, 10086, 275, 1056, 14, 2024, 14, 362, 360, 7154, 63, 4508, 297, 378, 9, 435, 413, 398, 340, 10086, 2695, 291, 14, 988, 63, 7154, 63, 4508, 26, 288, 2512, 14, 1757, 480, 12989, 316, 2818, 1069, 9, 83, 334, 4892, 2818, 10937, 9, 68, 5431, 304, 2818, 5764, 9, 83, 401, 586, 791, 1069, 356, 1056, 12, 283, 10937, 356, 10086, 12, 283, 5764, 356, 4499, 1386, 586, 2402, 3713, 12856, 356, 18094, 1552, 288, 7269, 2103, 275, 1056, 14, 1574, 342, 288, 7269, 2103, 14, 2024, 459, 7154, 63, 4508, 418, 275, 10086, 288, 7269, 2103, 14, 18671, 63, 1541, 275, 715, 288, 7269, 2103, 14, 6693, 275, 1056, 14, 6693, 435, 291, 14, 6693, 63, 10917, 288, 372, 7269, 2103, 267, 587, 26, 288, 2512, 14, 1757, 480, 39, 811, 1536, 7269, 316, 2818, 1069, 9, 83, 334, 4892, 2818, 10937, 9, 68, 5431, 304, 2818, 5764, 9, 83, 401, 586, 791, 1069, 356, 1056, 12, 283, 10937, 356, 10086, 12, 283, 5764, 356, 4499, 1386, 586, 2402, 3713, 12856, 356, 18094, 1552, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 2493, 3329, 370, 7269, 3405, 4145, 626, 787, 18994, 18104, 701, 7937, 199, 22959, 4066, 465, 282, 1950, 2653, 503, 3101, 6891, 1125, 14, 199, 199, 5556, 883, 1570, 314, 13942, 402, 642, 10816, 701, 1953, 70, 316, 314, 4061, 1330, 316, 2202, 26, 199, 27778, 63, 11342, 654, 446, 4212, 5002, 5431, 370, 7269, 282, 3405, 2034, 199, 27778, 63, 2856, 63, 15639, 446, 1314, 3101, 1177, 9479, 370, 7269, 199, 199, 4276, 6497, 787, 13736, 641, 314, 4061, 1330, 316, 2112, 436, 522, 3082, 68, 737, 314, 1284, 12, 199, 5089, 314, 18094, 965, 9158, 286, 1773, 2983, 1006, 5578, 334, 2865, 3405, 9, 6497, 14, 19468, 199, 16990, 365, 949, 1655, 3405, 6497, 370, 7269, 642, 10816, 16178, 282, 4673, 199, 8, 7154, 63, 4883, 395, 880, 1163, 5478, 4293, 4907, 370, 626, 4673, 14, 199, 199, 18816, 3101, 2552, 370, 11201, 26, 199, 199, 13, 2047, 1443, 2934, 370, 2813, 8290, 687, 17409, 5782, 63, 2856, 63, 15639, 12, 340, 1265, 29404, 370, 314, 3101, 523, 4113, 14, 2779, 1159, 5120, 701, 849, 2952, 652, 1159, 282, 2863, 1233, 1202, 370, 523, 6623, 1654, 1806, 912, 12, 1314, 3955, 506, 6020, 781, 2934, 370, 7269, 199, 624, 199, 646, 2050, 199, 199, 504, 7390, 14, 4901, 492, 10133, 199, 504, 7390, 14, 4901, 14, 705, 492, 31886, 12, 10237, 32060, 12, 971, 267, 8113, 2891, 2972, 547, 12, 8113, 10759, 12, 15175, 547, 12, 971, 267, 8113, 14074, 12, 13488, 28682, 2204, 547, 199, 199, 504, 18918, 14, 3924, 492, 2832, 9902, 199, 504, 18918, 14, 1208, 14, 1310, 492, 1177, 63, 1205, 63, 1188, 199, 504, 18918, 14, 88, 773, 14, 2347, 492, 7232, 4276, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 20506, 6608, 8, 785, 304, 339, 327, 5925, 365, 4915, 701, 314, 4760, 25551, 10816, 1380, 9936, 370, 272, 327, 24733, 376, 2701, 1177, 272, 3651, 7177, 2823, 63, 2566, 63, 27778, 275, 334, 11610, 14, 19382, 12, 31886, 12, 10237, 32060, 12, 2574, 8113, 2891, 2972, 547, 12, 8113, 10759, 12, 15175, 547, 12, 2574, 8113, 14074, 12, 13488, 28682, 2204, 547, 12, 7232, 4276, 12, 2574, 5925, 9, 339, 347, 636, 826, 721, 277, 12, 2202, 304, 267, 340, 440, 2202, 14, 362, 2245, 360, 27778, 63, 15704, 735, 288, 746, 2832, 9902, 267, 291, 14, 988, 63, 7154, 63, 4508, 275, 2202, 14, 26627, 360, 27778, 63, 11342, 654, 358, 267, 291, 14, 7154, 63, 1014, 63, 6021, 275, 663, 8, 442, 8, 88, 9, 367, 671, 315, 2202, 14, 21343, 360, 27778, 63, 2856, 63, 15639, 1333, 267, 291, 14, 6693, 63, 10917, 275, 2202, 14, 26627, 360, 27778, 63, 25144, 63, 1554, 42, 7698, 358, 339, 768, 3744, 272, 347, 687, 63, 23972, 8, 1886, 12, 29550, 304, 267, 372, 843, 8, 23972, 14, 1751, 9, 339, 347, 2112, 63, 1310, 8, 277, 12, 1056, 12, 1177, 12, 18094, 304, 267, 340, 1056, 14, 2024, 14, 362, 360, 18671, 63, 7154, 297, 756, 304, 288, 372, 1177, 267, 340, 1177, 14, 1205, 315, 291, 14, 7154, 63, 1014, 63, 6021, 26, 288, 4499, 275, 1177, 63, 1205, 63, 1188, 8, 1310, 14, 1205, 9, 288, 372, 291, 423, 7154, 8, 1069, 12, 4499, 12, 18094, 9, 503, 1177, 267, 372, 1177, 339, 347, 2112, 63, 1971, 8, 277, 12, 1056, 12, 1919, 12, 18094, 304, 267, 340, 1228, 8, 1971, 12, 291, 14, 25054, 63, 2566, 63, 27778, 9, 971, 355, 436, 440, 1056, 14, 2024, 14, 362, 360, 18671, 63, 7154, 297, 756, 304, 1467, 372, 291, 423, 7154, 8, 1069, 12, 1919, 12, 18094, 9, 339, 347, 485, 7154, 8, 277, 12, 1056, 12, 4499, 12, 18094, 304, 267, 10086, 275, 1056, 14, 2024, 14, 362, 360, 7154, 63, 4508, 297, 378, 9, 435, 413, 398, 340, 10086, 2695, 291, 14, 988, 63, 7154, 63, 4508, 26, 288, 2512, 14, 1757, 480, 12989, 316, 2818, 1069, 9, 83, 334, 4892, 2818, 10937, 9, 68, 5431, 304, 2818, 5764, 9, 83, 401, 586, 791, 1069, 356, 1056, 12, 283, 10937, 356, 10086, 12, 283, 5764, 356, 4499, 1386, 586, 2402, 3713, 12856, 356, 18094, 1552, 288, 7269, 2103, 275, 1056, 14, 1574, 342, 288, 7269, 2103, 14, 2024, 459, 7154, 63, 4508, 418, 275, 10086, 288, 7269, 2103, 14, 18671, 63, 1541, 275, 715, 288, 7269, 2103, 14, 6693, 275, 1056, 14, 6693, 435, 291, 14, 6693, 63, 10917, 288, 372, 7269, 2103, 267, 587, 26, 288, 2512, 14, 1757, 480, 39, 811, 1536, 7269, 316, 2818, 1069, 9, 83, 334, 4892, 2818, 10937, 9, 68, 5431, 304, 2818, 5764, 9, 83, 401, 586, 791, 1069, 356, 1056, 12, 283, 10937, 356, 10086, 12, 283, 5764, 356, 4499, 1386, 586, 2402, 3713, 12856, 356, 18094, 1552, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sarvex/tensorflow
tensorflow/lite/examples/python/label_image.py
6
3100
# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """label_image for tflite.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import argparse import time import numpy as np from PIL import Image import tensorflow as tf def load_labels(filename): with open(filename, 'r') as f: return [line.strip() for line in f.readlines()] if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument( '-i', '--image', default='/tmp/grace_hopper.bmp', help='image to be classified') parser.add_argument( '-m', '--model_file', default='/tmp/mobilenet_v1_1.0_224_quant.tflite', help='.tflite model to be executed') parser.add_argument( '-l', '--label_file', default='/tmp/labels.txt', help='name of file containing labels') parser.add_argument( '--input_mean', default=127.5, type=float, help='input_mean') parser.add_argument( '--input_std', default=127.5, type=float, help='input standard deviation') parser.add_argument( '--num_threads', default=None, type=int, help='number of threads') args = parser.parse_args() interpreter = tf.lite.Interpreter( model_path=args.model_file, num_threads=args.num_threads) interpreter.allocate_tensors() input_details = interpreter.get_input_details() output_details = interpreter.get_output_details() # check the type of the input tensor floating_model = input_details[0]['dtype'] == np.float32 # NxHxWxC, H:1, W:2 height = input_details[0]['shape'][1] width = input_details[0]['shape'][2] img = Image.open(args.image).resize((width, height)) # add N dim input_data = np.expand_dims(img, axis=0) if floating_model: input_data = (np.float32(input_data) - args.input_mean) / args.input_std interpreter.set_tensor(input_details[0]['index'], input_data) start_time = time.time() interpreter.invoke() stop_time = time.time() output_data = interpreter.get_tensor(output_details[0]['index']) results = np.squeeze(output_data) top_k = results.argsort()[-5:][::-1] labels = load_labels(args.label_file) for i in top_k: if floating_model: print('{:08.6f}: {}'.format(float(results[i]), labels[i])) else: print('{:08.6f}: {}'.format(float(results[i] / 255.0), labels[i])) print('time: {:.3f}ms'.format((stop_time - start_time) * 1000))
apache-2.0
[ 3, 1898, 14894, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 1302, 63, 1569, 367, 2833, 5333, 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, 7534, 199, 646, 900, 199, 199, 646, 2680, 465, 980, 199, 504, 14937, 492, 6047, 199, 646, 3228, 465, 2833, 421, 199, 318, 2248, 63, 3512, 8, 1501, 304, 523, 543, 1551, 8, 1501, 12, 283, 82, 358, 465, 289, 26, 272, 372, 359, 604, 14, 1913, 342, 367, 1004, 315, 289, 14, 9684, 5106, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 1798, 275, 7534, 14, 10730, 342, 523, 1798, 14, 525, 63, 2094, 8, 489, 2475, 73, 297, 489, 2850, 1569, 297, 489, 849, 8805, 2791, 15, 20631, 63, 13376, 529, 14, 22308, 297, 489, 1720, 534, 1569, 370, 506, 11534, 1290, 358, 523, 1798, 14, 525, 63, 2094, 8, 489, 2475, 77, 297, 489, 2850, 1238, 63, 493, 297, 489, 849, 8805, 2791, 15, 11375, 846, 63, 86, 17, 63, 17, 14, 16, 63, 8731, 63, 13603, 14, 3249, 5333, 297, 489, 1720, 15637, 3249, 5333, 1402, 370, 506, 7934, 358, 523, 1798, 14, 525, 63, 2094, 8, 489, 2475, 76, 297, 489, 2850, 1302, 63, 493, 297, 489, 849, 8805, 2791, 15, 3512, 14, 2424, 297, 489, 1720, 534, 354, 402, 570, 3035, 3628, 358, 523, 1798, 14, 525, 63, 2094, 8, 489, 2850, 1210, 63, 3670, 297, 489, 849, 29, 4195, 14, 21, 12, 730, 29, 1609, 12, 489, 1720, 534, 1210, 63, 3670, 358, 523, 1798, 14, 525, 63, 2094, 8, 489, 2850, 1210, 63, 1516, 297, 489, 849, 29, 4195, 14, 21, 12, 730, 29, 1609, 12, 489, 1720, 534, 1210, 4465, 18458, 358, 523, 1798, 14, 525, 63, 2094, 8, 489, 2850, 1507, 63, 6962, 297, 849, 29, 403, 12, 730, 29, 442, 12, 1720, 534, 1955, 402, 7183, 358, 523, 1249, 275, 1798, 14, 1122, 63, 589, 342, 819, 12693, 275, 2833, 14, 5333, 14, 2620, 26499, 8, 489, 1402, 63, 515, 29, 589, 14, 1238, 63, 493, 12, 1967, 63, 6962, 29, 589, 14, 1507, 63, 6962, 9, 523, 12693, 14, 12991, 63, 10206, 342, 819, 1324, 63, 5087, 275, 12693, 14, 362, 63, 1210, 63, 5087, 342, 523, 1072, 63, 5087, 275, 12693, 14, 362, 63, 1199, 63, 5087, 342, 819, 327, 1104, 314, 730, 402, 314, 1324, 2345, 523, 8402, 63, 1238, 275, 1324, 63, 5087, 59, 16, 2733, 2271, 418, 508, 980, 14, 1609, 708, 819, 327, 653, 88, 40, 88, 55, 8163, 12, 869, 26, 17, 12, 644, 26, 18, 523, 4569, 275, 1324, 63, 5087, 59, 16, 2733, 1392, 3488, 17, 61, 523, 3462, 275, 1324, 63, 5087, 59, 16, 2733, 1392, 3488, 18, 61, 523, 6050, 275, 6047, 14, 1490, 8, 589, 14, 1569, 680, 8709, 1332, 2063, 12, 4569, 430, 819, 327, 1050, 653, 8134, 523, 1324, 63, 576, 275, 980, 14, 4441, 63, 5380, 8, 4060, 12, 3114, 29, 16, 9, 819, 340, 8402, 63, 1238, 26, 272, 1324, 63, 576, 275, 334, 1590, 14, 1609, 708, 8, 1210, 63, 576, 9, 446, 1249, 14, 1210, 63, 3670, 9, 1182, 1249, 14, 1210, 63, 1516, 819, 12693, 14, 409, 63, 3128, 8, 1210, 63, 5087, 59, 16, 2733, 1080, 995, 1324, 63, 576, 9, 819, 1343, 63, 521, 275, 900, 14, 521, 342, 523, 12693, 14, 15195, 342, 523, 3631, 63, 521, 275, 900, 14, 521, 342, 819, 1072, 63, 576, 275, 12693, 14, 362, 63, 3128, 8, 1199, 63, 5087, 59, 16, 2733, 1080, 1105, 523, 2058, 275, 980, 14, 16597, 8, 1199, 63, 576, 9, 819, 2746, 63, 75, 275, 2058, 14, 20188, 19105, 21, 26, 1527, 21123, 17, 61, 523, 3628, 275, 2248, 63, 3512, 8, 589, 14, 1302, 63, 493, 9, 523, 367, 284, 315, 2746, 63, 75, 26, 272, 340, 8402, 63, 1238, 26, 489, 870, 11117, 26, 2036, 14, 22, 70, 9160, 9499, 908, 8, 1609, 8, 2604, 59, 73, 2522, 3628, 59, 73, 2459, 272, 587, 26, 489, 870, 11117, 26, 2036, 14, 22, 70, 9160, 9499, 908, 8, 1609, 8, 2604, 59, 73, 61, 1182, 5450, 14, 16, 395, 3628, 59, 73, 2459, 819, 870, 360, 521, 26, 469, 14010, 19, 70, 93, 706, 1370, 908, 1332, 2379, 63, 521, 446, 1343, 63, 521, 9, 627, 5198, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 14894, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 1302, 63, 1569, 367, 2833, 5333, 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, 7534, 199, 646, 900, 199, 199, 646, 2680, 465, 980, 199, 504, 14937, 492, 6047, 199, 646, 3228, 465, 2833, 421, 199, 318, 2248, 63, 3512, 8, 1501, 304, 523, 543, 1551, 8, 1501, 12, 283, 82, 358, 465, 289, 26, 272, 372, 359, 604, 14, 1913, 342, 367, 1004, 315, 289, 14, 9684, 5106, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 1798, 275, 7534, 14, 10730, 342, 523, 1798, 14, 525, 63, 2094, 8, 489, 2475, 73, 297, 489, 2850, 1569, 297, 489, 849, 8805, 2791, 15, 20631, 63, 13376, 529, 14, 22308, 297, 489, 1720, 534, 1569, 370, 506, 11534, 1290, 358, 523, 1798, 14, 525, 63, 2094, 8, 489, 2475, 77, 297, 489, 2850, 1238, 63, 493, 297, 489, 849, 8805, 2791, 15, 11375, 846, 63, 86, 17, 63, 17, 14, 16, 63, 8731, 63, 13603, 14, 3249, 5333, 297, 489, 1720, 15637, 3249, 5333, 1402, 370, 506, 7934, 358, 523, 1798, 14, 525, 63, 2094, 8, 489, 2475, 76, 297, 489, 2850, 1302, 63, 493, 297, 489, 849, 8805, 2791, 15, 3512, 14, 2424, 297, 489, 1720, 534, 354, 402, 570, 3035, 3628, 358, 523, 1798, 14, 525, 63, 2094, 8, 489, 2850, 1210, 63, 3670, 297, 489, 849, 29, 4195, 14, 21, 12, 730, 29, 1609, 12, 489, 1720, 534, 1210, 63, 3670, 358, 523, 1798, 14, 525, 63, 2094, 8, 489, 2850, 1210, 63, 1516, 297, 489, 849, 29, 4195, 14, 21, 12, 730, 29, 1609, 12, 489, 1720, 534, 1210, 4465, 18458, 358, 523, 1798, 14, 525, 63, 2094, 8, 489, 2850, 1507, 63, 6962, 297, 849, 29, 403, 12, 730, 29, 442, 12, 1720, 534, 1955, 402, 7183, 358, 523, 1249, 275, 1798, 14, 1122, 63, 589, 342, 819, 12693, 275, 2833, 14, 5333, 14, 2620, 26499, 8, 489, 1402, 63, 515, 29, 589, 14, 1238, 63, 493, 12, 1967, 63, 6962, 29, 589, 14, 1507, 63, 6962, 9, 523, 12693, 14, 12991, 63, 10206, 342, 819, 1324, 63, 5087, 275, 12693, 14, 362, 63, 1210, 63, 5087, 342, 523, 1072, 63, 5087, 275, 12693, 14, 362, 63, 1199, 63, 5087, 342, 819, 327, 1104, 314, 730, 402, 314, 1324, 2345, 523, 8402, 63, 1238, 275, 1324, 63, 5087, 59, 16, 2733, 2271, 418, 508, 980, 14, 1609, 708, 819, 327, 653, 88, 40, 88, 55, 8163, 12, 869, 26, 17, 12, 644, 26, 18, 523, 4569, 275, 1324, 63, 5087, 59, 16, 2733, 1392, 3488, 17, 61, 523, 3462, 275, 1324, 63, 5087, 59, 16, 2733, 1392, 3488, 18, 61, 523, 6050, 275, 6047, 14, 1490, 8, 589, 14, 1569, 680, 8709, 1332, 2063, 12, 4569, 430, 819, 327, 1050, 653, 8134, 523, 1324, 63, 576, 275, 980, 14, 4441, 63, 5380, 8, 4060, 12, 3114, 29, 16, 9, 819, 340, 8402, 63, 1238, 26, 272, 1324, 63, 576, 275, 334, 1590, 14, 1609, 708, 8, 1210, 63, 576, 9, 446, 1249, 14, 1210, 63, 3670, 9, 1182, 1249, 14, 1210, 63, 1516, 819, 12693, 14, 409, 63, 3128, 8, 1210, 63, 5087, 59, 16, 2733, 1080, 995, 1324, 63, 576, 9, 819, 1343, 63, 521, 275, 900, 14, 521, 342, 523, 12693, 14, 15195, 342, 523, 3631, 63, 521, 275, 900, 14, 521, 342, 819, 1072, 63, 576, 275, 12693, 14, 362, 63, 3128, 8, 1199, 63, 5087, 59, 16, 2733, 1080, 1105, 523, 2058, 275, 980, 14, 16597, 8, 1199, 63, 576, 9, 819, 2746, 63, 75, 275, 2058, 14, 20188, 19105, 21, 26, 1527, 21123, 17, 61, 523, 3628, 275, 2248, 63, 3512, 8, 589, 14, 1302, 63, 493, 9, 523, 367, 284, 315, 2746, 63, 75, 26, 272, 340, 8402, 63, 1238, 26, 489, 870, 11117, 26, 2036, 14, 22, 70, 9160, 9499, 908, 8, 1609, 8, 2604, 59, 73, 2522, 3628, 59, 73, 2459, 272, 587, 26, 489, 870, 11117, 26, 2036, 14, 22, 70, 9160, 9499, 908, 8, 1609, 8, 2604, 59, 73, 61, 1182, 5450, 14, 16, 395, 3628, 59, 73, 2459, 819, 870, 360, 521, 26, 469, 14010, 19, 70, 93, 706, 1370, 908, 1332, 2379, 63, 521, 446, 1343, 63, 521, 9, 627, 5198, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
yildizberkay/MongoApp
libs/PIL/ImageTk.py
39
9248
# # The Python Imaging Library. # $Id$ # # a Tk display interface # # History: # 96-04-08 fl Created # 96-09-06 fl Added getimage method # 96-11-01 fl Rewritten, removed image attribute and crop method # 97-05-09 fl Use PyImagingPaste method instead of image type # 97-05-12 fl Minor tweaks to match the IFUNC95 interface # 97-05-17 fl Support the "pilbitmap" booster patch # 97-06-05 fl Added file= and data= argument to image constructors # 98-03-09 fl Added width and height methods to Image classes # 98-07-02 fl Use default mode for "P" images without palette attribute # 98-07-02 fl Explicitly destroy Tkinter image objects # 99-07-24 fl Support multiple Tk interpreters (from Greg Couch) # 99-07-26 fl Automatically hook into Tkinter (if possible) # 99-08-15 fl Hook uses _imagingtk instead of _imaging # # Copyright (c) 1997-1999 by Secret Labs AB # Copyright (c) 1996-1997 by Fredrik Lundh # # See the README file for information on usage and redistribution. # import Tkinter, Image ## # The <b>ImageTk</b> module contains support to create and modify # Tkinter <b>BitmapImage</b> and <b>PhotoImage</b> objects. # <p> # For examples, see the demo programs in the <i>Scripts</i> # directory. ## # -------------------------------------------------------------------- # Check for Tkinter interface hooks _pilbitmap_ok = None def _pilbitmap_check(): global _pilbitmap_ok if _pilbitmap_ok is None: try: im = Image.new("1", (1,1)) Tkinter.BitmapImage(data="PIL:%d" % im.im.id) _pilbitmap_ok = 1 except Tkinter.TclError: _pilbitmap_ok = 0 return _pilbitmap_ok # -------------------------------------------------------------------- # PhotoImage ## # Creates a Tkinter-compatible photo image. This can be used # everywhere Tkinter expects an image object. If the image is an RGBA # image, pixels having alpha 0 are treated as transparent. class PhotoImage: ## # Create a photo image object. The constructor takes either # a PIL image, or a mode and a size. Alternatively, you can # use the <b>file</b> or <b>data</b> options to initialize # the photo image object. # <p> # @def __init__(image=None, size=None, **options) # @param image Either a PIL image, or a mode string. If a # mode string is used, a size must also be given. # @param size If the first argument is a mode string, this # defines the size of the image. # @keyparam file A filename to load the image from (using # Image.open(file)). # @keyparam data An 8-bit string containing image data (as # loaded from an image file). def __init__(self, image=None, size=None, **kw): # Tk compatibility: file or data if image is None: if kw.has_key("file"): image = Image.open(kw["file"]) del kw["file"] elif kw.has_key("data"): from StringIO import StringIO image = Image.open(StringIO(kw["data"])) del kw["data"] if hasattr(image, "mode") and hasattr(image, "size"): # got an image instead of a mode mode = image.mode if mode == "P": # palette mapped data image.load() try: mode = image.palette.mode except AttributeError: mode = "RGB" # default size = image.size kw["width"], kw["height"] = size else: mode = image image = None if mode not in ["1", "L", "RGB", "RGBA"]: mode = Image.getmodebase(mode) self.__mode = mode self.__size = size self.__photo = apply(Tkinter.PhotoImage, (), kw) self.tk = self.__photo.tk if image: self.paste(image) def __del__(self): name = self.__photo.name self.__photo.name = None try: self.__photo.tk.call("image", "delete", name) except: pass # ignore internal errors ## # Get the Tkinter photo image identifier. This method is # automatically called by Tkinter whenever a PhotoImage object is # passed to a Tkinter method. # # @return A Tkinter photo image identifier (a string). def __str__(self): return str(self.__photo) ## # Get the width of the image. # # @return The width, in pixels. def width(self): return self.__size[0] ## # Get the height of the image. # # @return The height, in pixels. def height(self): return self.__size[1] ## # Paste a PIL image into the photo image. Note that this can # be very slow if the photo image is displayed. # # @param im A PIL image. The size must match the target region. # If the mode does not match, the image is converted to the # mode of the bitmap image. # @param box A 4-tuple defining the left, upper, right, and # lower pixel coordinate. If None is given instead of a # tuple, all of the image is assumed. def paste(self, im, box=None): # convert to blittable im.load() image = im.im if image.isblock() and im.mode == self.__mode: block = image else: block = image.new_block(self.__mode, im.size) image.convert2(block, image) # convert directly between buffers tk = self.__photo.tk try: tk.call("PyImagingPhoto", self.__photo, block.id) except Tkinter.TclError, v: # activate Tkinter hook try: import _imagingtk try: _imagingtk.tkinit(tk.interpaddr(), 1) except AttributeError: _imagingtk.tkinit(id(tk), 0) tk.call("PyImagingPhoto", self.__photo, block.id) except (ImportError, AttributeError, Tkinter.TclError): raise # configuration problem; cannot attach to Tkinter # -------------------------------------------------------------------- # BitmapImage ## # Create a Tkinter-compatible bitmap image. This can be used # everywhere Tkinter expects an image object. class BitmapImage: ## # Create a Tkinter-compatible bitmap image. # <p> # The given image must have mode "1". Pixels having value 0 are # treated as transparent. Options, if any, are passed on to # Tkinter. The most commonly used option is <b>foreground</b>, # which is used to specify the colour for the non-transparent # parts. See the Tkinter documentation for information on how to # specify colours. # # @def __init__(image=None, **options) # @param image A PIL image. def __init__(self, image=None, **kw): # Tk compatibility: file or data if image is None: if kw.has_key("file"): image = Image.open(kw["file"]) del kw["file"] elif kw.has_key("data"): from StringIO import StringIO image = Image.open(StringIO(kw["data"])) del kw["data"] self.__mode = image.mode self.__size = image.size if _pilbitmap_check(): # fast way (requires the pilbitmap booster patch) image.load() kw["data"] = "PIL:%d" % image.im.id self.__im = image # must keep a reference else: # slow but safe way kw["data"] = image.tobitmap() self.__photo = apply(Tkinter.BitmapImage, (), kw) def __del__(self): name = self.__photo.name self.__photo.name = None try: self.__photo.tk.call("image", "delete", name) except: pass # ignore internal errors ## # Get the width of the image. # # @return The width, in pixels. def width(self): return self.__size[0] ## # Get the height of the image. # # @return The height, in pixels. def height(self): return self.__size[1] ## # Get the Tkinter bitmap image identifier. This method is # automatically called by Tkinter whenever a BitmapImage object # is passed to a Tkinter method. # # @return A Tkinter bitmap image identifier (a string). def __str__(self): return str(self.__photo) ## # Copies the contents of a PhotoImage to a PIL image memory. def getimage(photo): photo.tk.call("PyImagingPhotoGet", photo) # -------------------------------------------------------------------- # Helper for the Image.show method. def _show(image, title): class UI(Tkinter.Label): def __init__(self, master, im): if im.mode == "1": self.image = BitmapImage(im, foreground="white", master=master) else: self.image = PhotoImage(im, master=master) Tkinter.Label.__init__(self, master, image=self.image, bg="black", bd=0) if not Tkinter._default_root: raise IOError, "tkinter not initialized" top = Tkinter.Toplevel() if title: top.title(title) UI(top, image).pack()
apache-2.0
[ 3, 199, 3, 710, 2018, 473, 391, 1540, 11243, 14, 199, 3, 2672, 1304, 4, 199, 3, 199, 3, 282, 12435, 2929, 3217, 199, 3, 199, 3, 27829, 26, 199, 3, 15580, 13, 966, 13, 2036, 2717, 257, 18208, 199, 3, 15580, 13, 1643, 13, 1690, 2717, 257, 16230, 2312, 280, 960, 1083, 199, 3, 15580, 13, 845, 13, 614, 2717, 257, 799, 8938, 12, 4829, 1834, 2225, 436, 18366, 1083, 199, 3, 15997, 13, 1717, 13, 1643, 2717, 257, 3645, 1611, 32023, 1540, 48, 9209, 1083, 3140, 402, 1834, 730, 199, 3, 15997, 13, 1717, 13, 713, 2717, 257, 10195, 269, 32464, 83, 370, 1336, 314, 8036, 17192, 2720, 3217, 199, 3, 15997, 13, 1717, 13, 1196, 2717, 257, 12502, 314, 298, 80, 382, 20299, 2, 1234, 29895, 3371, 199, 3, 15997, 13, 1690, 13, 1717, 2717, 257, 16230, 570, 29, 436, 666, 29, 1423, 370, 1834, 31604, 199, 3, 16096, 13, 1644, 13, 1643, 2717, 257, 16230, 3462, 436, 4569, 3102, 370, 6047, 3992, 199, 3, 16096, 13, 1780, 13, 996, 2717, 257, 3645, 849, 818, 367, 298, 48, 2, 5935, 1928, 17986, 2225, 199, 3, 16096, 13, 1780, 13, 996, 2717, 257, 23872, 590, 11972, 16826, 1834, 2251, 199, 3, 8806, 13, 1780, 13, 1194, 2717, 257, 12502, 3663, 12435, 6421, 878, 334, 504, 29096, 445, 13087, 9, 199, 3, 8806, 13, 1780, 13, 1479, 2717, 257, 9195, 17174, 5759, 1901, 16826, 334, 692, 3962, 9, 199, 3, 8806, 13, 2036, 13, 1046, 2717, 257, 24837, 4440, 485, 11744, 1540, 2663, 3140, 402, 485, 11744, 1540, 199, 3, 199, 3, 1898, 334, 67, 9, 9013, 23, 13, 16278, 701, 23580, 491, 2101, 14840, 199, 3, 1898, 334, 67, 9, 31347, 13, 7155, 23, 701, 481, 581, 25844, 491, 725, 72, 199, 3, 199, 3, 1666, 314, 27781, 570, 367, 2556, 641, 4503, 436, 295, 4972, 14, 199, 3, 199, 199, 646, 16826, 12, 6047, 199, 199, 309, 199, 3, 710, 665, 66, 30, 3491, 15189, 1108, 66, 30, 859, 3509, 2291, 370, 1218, 436, 2811, 199, 3, 16826, 665, 66, 30, 16469, 3491, 1108, 66, 30, 436, 665, 66, 30, 21258, 3491, 1108, 66, 30, 2251, 14, 199, 3, 665, 80, 30, 199, 3, 2104, 7251, 12, 1937, 314, 14779, 18572, 315, 314, 665, 73, 30, 25681, 1108, 73, 30, 199, 3, 2082, 14, 199, 309, 199, 199, 3, 23567, 199, 3, 2670, 367, 16826, 3217, 12604, 199, 199, 63, 80, 382, 20299, 63, 745, 275, 488, 199, 199, 318, 485, 80, 382, 20299, 63, 1074, 837, 272, 2288, 485, 80, 382, 20299, 63, 745, 272, 340, 485, 80, 382, 20299, 63, 745, 365, 488, 26, 267, 862, 26, 288, 3416, 275, 6047, 14, 1222, 480, 17, 401, 334, 17, 12, 17, 430, 288, 16826, 14, 16469, 3491, 8, 576, 628, 48, 1193, 2689, 68, 2, 450, 3416, 14, 1017, 14, 344, 9, 288, 485, 80, 382, 20299, 63, 745, 275, 413, 267, 871, 16826, 14, 29175, 547, 26, 288, 485, 80, 382, 20299, 63, 745, 275, 378, 272, 372, 485, 80, 382, 20299, 63, 745, 199, 199, 3, 23567, 199, 3, 30808, 3491, 199, 199, 309, 199, 3, 10560, 282, 16826, 13, 6490, 19397, 1834, 14, 221, 961, 883, 506, 1202, 199, 3, 4036, 4509, 16826, 14292, 376, 1834, 909, 14, 221, 982, 314, 1834, 365, 376, 820, 39, 4134, 199, 3, 1834, 12, 11094, 9445, 5131, 378, 787, 10184, 465, 17265, 14, 199, 199, 533, 30808, 3491, 26, 339, 925, 272, 327, 2790, 282, 19397, 1834, 909, 14, 710, 3787, 6181, 1902, 272, 327, 282, 14937, 1834, 12, 503, 282, 818, 436, 282, 1568, 14, 221, 26776, 12, 1265, 883, 272, 327, 675, 314, 665, 66, 30, 493, 1108, 66, 30, 503, 665, 66, 30, 576, 1108, 66, 30, 1511, 370, 8265, 272, 327, 314, 19397, 1834, 909, 14, 272, 327, 665, 80, 30, 272, 327, 768, 318, 636, 826, 721, 1569, 29, 403, 12, 1568, 29, 403, 12, 1011, 1419, 9, 272, 327, 768, 635, 1834, 13083, 282, 14937, 1834, 12, 503, 282, 818, 1059, 14, 221, 982, 282, 272, 327, 259, 818, 1059, 365, 1202, 12, 282, 1568, 1471, 2597, 506, 1627, 14, 272, 327, 768, 635, 1568, 982, 314, 1642, 1423, 365, 282, 818, 1059, 12, 642, 272, 327, 259, 7890, 314, 1568, 402, 314, 1834, 14, 272, 327, 768, 498, 635, 570, 437, 1788, 370, 2248, 314, 1834, 687, 334, 4941, 272, 327, 259, 6047, 14, 1490, 8, 493, 4992, 272, 327, 768, 498, 635, 666, 1626, 1695, 13, 2075, 1059, 3035, 1834, 666, 334, 305, 272, 327, 259, 6511, 687, 376, 1834, 570, 680, 339, 347, 636, 826, 721, 277, 12, 1834, 29, 403, 12, 1568, 29, 403, 12, 1011, 829, 304, 398, 327, 12435, 7163, 26, 570, 503, 666, 267, 340, 1834, 365, 488, 26, 288, 340, 4775, 14, 1989, 63, 498, 480, 493, 2349, 355, 1834, 275, 6047, 14, 1490, 8, 829, 905, 493, 3135, 355, 2150, 4775, 905, 493, 937, 288, 916, 4775, 14, 1989, 63, 498, 480, 576, 2349, 355, 687, 5228, 492, 5228, 355, 1834, 275, 6047, 14, 1490, 8, 6424, 8, 829, 905, 576, 13045, 355, 2150, 4775, 905, 576, 937, 398, 340, 2688, 8, 1569, 12, 298, 632, 531, 436, 2688, 8, 1569, 12, 298, 890, 2349, 288, 327, 4788, 376, 1834, 3140, 402, 282, 818, 288, 818, 275, 1834, 14, 632, 288, 340, 818, 508, 298, 48, 582, 355, 327, 17986, 9994, 666, 355, 1834, 14, 912, 342, 355, 862, 26, 490, 818, 275, 1834, 14, 16506, 14, 632, 355, 871, 4281, 26, 490, 818, 275, 298, 12067, 2, 327, 849, 288, 1568, 275, 1834, 14, 890, 288, 4775, 905, 2063, 2255, 4775, 905, 3333, 937, 275, 1568, 267, 587, 26, 288, 818, 275, 1834, 288, 1834, 275, 488, 398, 340, 818, 440, 315, 2097, 17, 401, 298, 44, 401, 298, 12067, 401, 298, 21631, 6229, 288, 818, 275, 6047, 14, 362, 632, 1095, 8, 632, 9, 398, 291, 855, 632, 275, 818, 267, 291, 855, 890, 275, 1568, 267, 291, 855, 13834, 275, 4838, 8, 15189, 1058, 14, 21258, 3491, 12, 11969, 4775, 9, 267, 291, 14, 2663, 275, 291, 855, 13834, 14, 2663, 267 ]
[ 199, 3, 710, 2018, 473, 391, 1540, 11243, 14, 199, 3, 2672, 1304, 4, 199, 3, 199, 3, 282, 12435, 2929, 3217, 199, 3, 199, 3, 27829, 26, 199, 3, 15580, 13, 966, 13, 2036, 2717, 257, 18208, 199, 3, 15580, 13, 1643, 13, 1690, 2717, 257, 16230, 2312, 280, 960, 1083, 199, 3, 15580, 13, 845, 13, 614, 2717, 257, 799, 8938, 12, 4829, 1834, 2225, 436, 18366, 1083, 199, 3, 15997, 13, 1717, 13, 1643, 2717, 257, 3645, 1611, 32023, 1540, 48, 9209, 1083, 3140, 402, 1834, 730, 199, 3, 15997, 13, 1717, 13, 713, 2717, 257, 10195, 269, 32464, 83, 370, 1336, 314, 8036, 17192, 2720, 3217, 199, 3, 15997, 13, 1717, 13, 1196, 2717, 257, 12502, 314, 298, 80, 382, 20299, 2, 1234, 29895, 3371, 199, 3, 15997, 13, 1690, 13, 1717, 2717, 257, 16230, 570, 29, 436, 666, 29, 1423, 370, 1834, 31604, 199, 3, 16096, 13, 1644, 13, 1643, 2717, 257, 16230, 3462, 436, 4569, 3102, 370, 6047, 3992, 199, 3, 16096, 13, 1780, 13, 996, 2717, 257, 3645, 849, 818, 367, 298, 48, 2, 5935, 1928, 17986, 2225, 199, 3, 16096, 13, 1780, 13, 996, 2717, 257, 23872, 590, 11972, 16826, 1834, 2251, 199, 3, 8806, 13, 1780, 13, 1194, 2717, 257, 12502, 3663, 12435, 6421, 878, 334, 504, 29096, 445, 13087, 9, 199, 3, 8806, 13, 1780, 13, 1479, 2717, 257, 9195, 17174, 5759, 1901, 16826, 334, 692, 3962, 9, 199, 3, 8806, 13, 2036, 13, 1046, 2717, 257, 24837, 4440, 485, 11744, 1540, 2663, 3140, 402, 485, 11744, 1540, 199, 3, 199, 3, 1898, 334, 67, 9, 9013, 23, 13, 16278, 701, 23580, 491, 2101, 14840, 199, 3, 1898, 334, 67, 9, 31347, 13, 7155, 23, 701, 481, 581, 25844, 491, 725, 72, 199, 3, 199, 3, 1666, 314, 27781, 570, 367, 2556, 641, 4503, 436, 295, 4972, 14, 199, 3, 199, 199, 646, 16826, 12, 6047, 199, 199, 309, 199, 3, 710, 665, 66, 30, 3491, 15189, 1108, 66, 30, 859, 3509, 2291, 370, 1218, 436, 2811, 199, 3, 16826, 665, 66, 30, 16469, 3491, 1108, 66, 30, 436, 665, 66, 30, 21258, 3491, 1108, 66, 30, 2251, 14, 199, 3, 665, 80, 30, 199, 3, 2104, 7251, 12, 1937, 314, 14779, 18572, 315, 314, 665, 73, 30, 25681, 1108, 73, 30, 199, 3, 2082, 14, 199, 309, 199, 199, 3, 23567, 199, 3, 2670, 367, 16826, 3217, 12604, 199, 199, 63, 80, 382, 20299, 63, 745, 275, 488, 199, 199, 318, 485, 80, 382, 20299, 63, 1074, 837, 272, 2288, 485, 80, 382, 20299, 63, 745, 272, 340, 485, 80, 382, 20299, 63, 745, 365, 488, 26, 267, 862, 26, 288, 3416, 275, 6047, 14, 1222, 480, 17, 401, 334, 17, 12, 17, 430, 288, 16826, 14, 16469, 3491, 8, 576, 628, 48, 1193, 2689, 68, 2, 450, 3416, 14, 1017, 14, 344, 9, 288, 485, 80, 382, 20299, 63, 745, 275, 413, 267, 871, 16826, 14, 29175, 547, 26, 288, 485, 80, 382, 20299, 63, 745, 275, 378, 272, 372, 485, 80, 382, 20299, 63, 745, 199, 199, 3, 23567, 199, 3, 30808, 3491, 199, 199, 309, 199, 3, 10560, 282, 16826, 13, 6490, 19397, 1834, 14, 221, 961, 883, 506, 1202, 199, 3, 4036, 4509, 16826, 14292, 376, 1834, 909, 14, 221, 982, 314, 1834, 365, 376, 820, 39, 4134, 199, 3, 1834, 12, 11094, 9445, 5131, 378, 787, 10184, 465, 17265, 14, 199, 199, 533, 30808, 3491, 26, 339, 925, 272, 327, 2790, 282, 19397, 1834, 909, 14, 710, 3787, 6181, 1902, 272, 327, 282, 14937, 1834, 12, 503, 282, 818, 436, 282, 1568, 14, 221, 26776, 12, 1265, 883, 272, 327, 675, 314, 665, 66, 30, 493, 1108, 66, 30, 503, 665, 66, 30, 576, 1108, 66, 30, 1511, 370, 8265, 272, 327, 314, 19397, 1834, 909, 14, 272, 327, 665, 80, 30, 272, 327, 768, 318, 636, 826, 721, 1569, 29, 403, 12, 1568, 29, 403, 12, 1011, 1419, 9, 272, 327, 768, 635, 1834, 13083, 282, 14937, 1834, 12, 503, 282, 818, 1059, 14, 221, 982, 282, 272, 327, 259, 818, 1059, 365, 1202, 12, 282, 1568, 1471, 2597, 506, 1627, 14, 272, 327, 768, 635, 1568, 982, 314, 1642, 1423, 365, 282, 818, 1059, 12, 642, 272, 327, 259, 7890, 314, 1568, 402, 314, 1834, 14, 272, 327, 768, 498, 635, 570, 437, 1788, 370, 2248, 314, 1834, 687, 334, 4941, 272, 327, 259, 6047, 14, 1490, 8, 493, 4992, 272, 327, 768, 498, 635, 666, 1626, 1695, 13, 2075, 1059, 3035, 1834, 666, 334, 305, 272, 327, 259, 6511, 687, 376, 1834, 570, 680, 339, 347, 636, 826, 721, 277, 12, 1834, 29, 403, 12, 1568, 29, 403, 12, 1011, 829, 304, 398, 327, 12435, 7163, 26, 570, 503, 666, 267, 340, 1834, 365, 488, 26, 288, 340, 4775, 14, 1989, 63, 498, 480, 493, 2349, 355, 1834, 275, 6047, 14, 1490, 8, 829, 905, 493, 3135, 355, 2150, 4775, 905, 493, 937, 288, 916, 4775, 14, 1989, 63, 498, 480, 576, 2349, 355, 687, 5228, 492, 5228, 355, 1834, 275, 6047, 14, 1490, 8, 6424, 8, 829, 905, 576, 13045, 355, 2150, 4775, 905, 576, 937, 398, 340, 2688, 8, 1569, 12, 298, 632, 531, 436, 2688, 8, 1569, 12, 298, 890, 2349, 288, 327, 4788, 376, 1834, 3140, 402, 282, 818, 288, 818, 275, 1834, 14, 632, 288, 340, 818, 508, 298, 48, 582, 355, 327, 17986, 9994, 666, 355, 1834, 14, 912, 342, 355, 862, 26, 490, 818, 275, 1834, 14, 16506, 14, 632, 355, 871, 4281, 26, 490, 818, 275, 298, 12067, 2, 327, 849, 288, 1568, 275, 1834, 14, 890, 288, 4775, 905, 2063, 2255, 4775, 905, 3333, 937, 275, 1568, 267, 587, 26, 288, 818, 275, 1834, 288, 1834, 275, 488, 398, 340, 818, 440, 315, 2097, 17, 401, 298, 44, 401, 298, 12067, 401, 298, 21631, 6229, 288, 818, 275, 6047, 14, 362, 632, 1095, 8, 632, 9, 398, 291, 855, 632, 275, 818, 267, 291, 855, 890, 275, 1568, 267, 291, 855, 13834, 275, 4838, 8, 15189, 1058, 14, 21258, 3491, 12, 11969, 4775, 9, 267, 291, 14, 2663, 275, 291, 855, 13834, 14, 2663, 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,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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 ]
edmundgentle/schoolscript
SchoolScript/bin/Debug/pythonlib/Lib/encodings/zlib_codec.py
4
2319
"""Python 'zlib_codec' Codec - zlib compression encoding. This codec de/encodes from bytes to bytes and is therefore usable with bytes.transform() and bytes.untransform(). Written by Marc-Andre Lemburg (mal@lemburg.com). """ import codecs import zlib # this codec needs the optional zlib module ! ### Codec APIs def zlib_encode(input, errors='strict'): assert errors == 'strict' return (zlib.compress(input), len(input)) def zlib_decode(input, errors='strict'): assert errors == 'strict' return (zlib.decompress(input), len(input)) class Codec(codecs.Codec): def encode(self, input, errors='strict'): return zlib_encode(input, errors) def decode(self, input, errors='strict'): return zlib_decode(input, errors) class IncrementalEncoder(codecs.IncrementalEncoder): def __init__(self, errors='strict'): assert errors == 'strict' self.errors = errors self.compressobj = zlib.compressobj() def encode(self, input, final=False): if final: c = self.compressobj.compress(input) return c + self.compressobj.flush() else: return self.compressobj.compress(input) def reset(self): self.compressobj = zlib.compressobj() class IncrementalDecoder(codecs.IncrementalDecoder): def __init__(self, errors='strict'): assert errors == 'strict' self.errors = errors self.decompressobj = zlib.decompressobj() def decode(self, input, final=False): if final: c = self.decompressobj.decompress(input) return c + self.decompressobj.flush() else: return self.decompressobj.decompress(input) def reset(self): self.decompressobj = zlib.decompressobj() class StreamWriter(Codec, codecs.StreamWriter): charbuffertype = bytes class StreamReader(Codec, codecs.StreamReader): charbuffertype = bytes ### encodings module API def getregentry(): return codecs.CodecInfo( name='zlib', encode=zlib_encode, decode=zlib_decode, incrementalencoder=IncrementalEncoder, incrementaldecoder=IncrementalDecoder, streamreader=StreamReader, streamwriter=StreamWriter, )
gpl-2.0
[ 624, 4718, 283, 15371, 63, 9276, 7, 13732, 446, 12472, 10291, 2644, 14, 2999, 199, 2765, 9076, 477, 15, 2143, 83, 687, 2783, 370, 2783, 436, 365, 16119, 18025, 543, 202, 199, 2394, 14, 4711, 342, 436, 2783, 14, 324, 4711, 1252, 2999, 199, 32329, 701, 603, 9912, 13, 3325, 264, 7005, 32649, 334, 2174, 32, 274, 32649, 14, 957, 680, 202, 199, 624, 2999, 199, 646, 6010, 202, 199, 646, 12472, 327, 642, 9076, 4839, 314, 2716, 12472, 859, 8546, 2999, 199, 5680, 13732, 15913, 2999, 199, 318, 12472, 63, 2143, 8, 1210, 12, 2552, 534, 4768, 735, 1128, 702, 2552, 508, 283, 4768, 7, 1128, 372, 334, 15371, 14, 6447, 8, 1210, 395, 822, 8, 1210, 430, 2999, 199, 318, 12472, 63, 2708, 8, 1210, 12, 2552, 534, 4768, 735, 1128, 702, 2552, 508, 283, 4768, 7, 1128, 372, 334, 15371, 14, 14954, 8, 1210, 395, 822, 8, 1210, 430, 2999, 199, 533, 13732, 8, 8933, 14, 8818, 304, 1128, 347, 3752, 8, 277, 12, 1324, 12, 2552, 534, 4768, 735, 1039, 372, 12472, 63, 2143, 8, 1210, 12, 2552, 9, 1128, 347, 4849, 8, 277, 12, 1324, 12, 2552, 534, 4768, 735, 1039, 372, 12472, 63, 2708, 8, 1210, 12, 2552, 9, 2999, 199, 533, 24350, 8, 8933, 14, 17016, 304, 1128, 347, 636, 826, 721, 277, 12, 2552, 534, 4768, 735, 1039, 702, 2552, 508, 283, 4768, 7, 1039, 291, 14, 2550, 275, 2552, 1039, 291, 14, 6447, 1113, 275, 12472, 14, 6447, 1113, 342, 2958, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 1039, 340, 4242, 26, 1675, 286, 275, 291, 14, 6447, 1113, 14, 6447, 8, 1210, 9, 1675, 372, 286, 435, 291, 14, 6447, 1113, 14, 4939, 342, 1039, 587, 26, 1675, 372, 291, 14, 6447, 1113, 14, 6447, 8, 1210, 9, 2958, 347, 5305, 8, 277, 304, 1039, 291, 14, 6447, 1113, 275, 12472, 14, 6447, 1113, 342, 2999, 199, 533, 24385, 8, 8933, 14, 16703, 304, 1128, 347, 636, 826, 721, 277, 12, 2552, 534, 4768, 735, 1039, 702, 2552, 508, 283, 4768, 7, 1039, 291, 14, 2550, 275, 2552, 1039, 291, 14, 14954, 1113, 275, 12472, 14, 14954, 1113, 342, 2958, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 1039, 340, 4242, 26, 1675, 286, 275, 291, 14, 14954, 1113, 14, 14954, 8, 1210, 9, 1675, 372, 286, 435, 291, 14, 14954, 1113, 14, 4939, 342, 1039, 587, 26, 1675, 372, 291, 14, 14954, 1113, 14, 14954, 8, 1210, 9, 2958, 347, 5305, 8, 277, 304, 1039, 291, 14, 14954, 1113, 275, 12472, 14, 14954, 1113, 342, 2999, 199, 533, 24163, 8, 8818, 12, 6010, 14, 16551, 304, 1128, 1495, 2738, 466, 275, 2783, 2999, 199, 533, 22970, 8, 8818, 12, 6010, 14, 16132, 304, 1128, 1495, 2738, 466, 275, 2783, 2999, 199, 5680, 14134, 859, 3261, 2999, 199, 318, 26116, 837, 1128, 372, 6010, 14, 26375, 8, 1039, 536, 534, 15371, 297, 1039, 3752, 29, 15371, 63, 2143, 12, 1039, 4849, 29, 15371, 63, 2708, 12, 1039, 26329, 29, 17016, 12, 1039, 26317, 29, 16703, 12, 1039, 26101, 29, 16132, 12, 1039, 26112, 29, 16551, 12, 1128, 776, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4718, 283, 15371, 63, 9276, 7, 13732, 446, 12472, 10291, 2644, 14, 2999, 199, 2765, 9076, 477, 15, 2143, 83, 687, 2783, 370, 2783, 436, 365, 16119, 18025, 543, 202, 199, 2394, 14, 4711, 342, 436, 2783, 14, 324, 4711, 1252, 2999, 199, 32329, 701, 603, 9912, 13, 3325, 264, 7005, 32649, 334, 2174, 32, 274, 32649, 14, 957, 680, 202, 199, 624, 2999, 199, 646, 6010, 202, 199, 646, 12472, 327, 642, 9076, 4839, 314, 2716, 12472, 859, 8546, 2999, 199, 5680, 13732, 15913, 2999, 199, 318, 12472, 63, 2143, 8, 1210, 12, 2552, 534, 4768, 735, 1128, 702, 2552, 508, 283, 4768, 7, 1128, 372, 334, 15371, 14, 6447, 8, 1210, 395, 822, 8, 1210, 430, 2999, 199, 318, 12472, 63, 2708, 8, 1210, 12, 2552, 534, 4768, 735, 1128, 702, 2552, 508, 283, 4768, 7, 1128, 372, 334, 15371, 14, 14954, 8, 1210, 395, 822, 8, 1210, 430, 2999, 199, 533, 13732, 8, 8933, 14, 8818, 304, 1128, 347, 3752, 8, 277, 12, 1324, 12, 2552, 534, 4768, 735, 1039, 372, 12472, 63, 2143, 8, 1210, 12, 2552, 9, 1128, 347, 4849, 8, 277, 12, 1324, 12, 2552, 534, 4768, 735, 1039, 372, 12472, 63, 2708, 8, 1210, 12, 2552, 9, 2999, 199, 533, 24350, 8, 8933, 14, 17016, 304, 1128, 347, 636, 826, 721, 277, 12, 2552, 534, 4768, 735, 1039, 702, 2552, 508, 283, 4768, 7, 1039, 291, 14, 2550, 275, 2552, 1039, 291, 14, 6447, 1113, 275, 12472, 14, 6447, 1113, 342, 2958, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 1039, 340, 4242, 26, 1675, 286, 275, 291, 14, 6447, 1113, 14, 6447, 8, 1210, 9, 1675, 372, 286, 435, 291, 14, 6447, 1113, 14, 4939, 342, 1039, 587, 26, 1675, 372, 291, 14, 6447, 1113, 14, 6447, 8, 1210, 9, 2958, 347, 5305, 8, 277, 304, 1039, 291, 14, 6447, 1113, 275, 12472, 14, 6447, 1113, 342, 2999, 199, 533, 24385, 8, 8933, 14, 16703, 304, 1128, 347, 636, 826, 721, 277, 12, 2552, 534, 4768, 735, 1039, 702, 2552, 508, 283, 4768, 7, 1039, 291, 14, 2550, 275, 2552, 1039, 291, 14, 14954, 1113, 275, 12472, 14, 14954, 1113, 342, 2958, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 1039, 340, 4242, 26, 1675, 286, 275, 291, 14, 14954, 1113, 14, 14954, 8, 1210, 9, 1675, 372, 286, 435, 291, 14, 14954, 1113, 14, 4939, 342, 1039, 587, 26, 1675, 372, 291, 14, 14954, 1113, 14, 14954, 8, 1210, 9, 2958, 347, 5305, 8, 277, 304, 1039, 291, 14, 14954, 1113, 275, 12472, 14, 14954, 1113, 342, 2999, 199, 533, 24163, 8, 8818, 12, 6010, 14, 16551, 304, 1128, 1495, 2738, 466, 275, 2783, 2999, 199, 533, 22970, 8, 8818, 12, 6010, 14, 16132, 304, 1128, 1495, 2738, 466, 275, 2783, 2999, 199, 5680, 14134, 859, 3261, 2999, 199, 318, 26116, 837, 1128, 372, 6010, 14, 26375, 8, 1039, 536, 534, 15371, 297, 1039, 3752, 29, 15371, 63, 2143, 12, 1039, 4849, 29, 15371, 63, 2708, 12, 1039, 26329, 29, 17016, 12, 1039, 26317, 29, 16703, 12, 1039, 26101, 29, 16132, 12, 1039, 26112, 29, 16551, 12, 1128, 776, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
laurent-george/bokeh
bokeh/util/notebook.py
22
2701
""" Functions useful for loading Bokeh code and data in IPython notebooks. """ from __future__ import absolute_import _notebook_loaded = None def load_notebook(resources=None, verbose=False, hide_banner=False): """ Prepare the IPython notebook for displaying Bokeh plots. Args: resources (Resource, optional) : how and where to load BokehJS from verbose (bool, optional) : whether to report detailed settings (default: False) hide_banner (bool, optional): whether to hide the Bokeh banner (default: False) .. warning:: Clearing the output cell containing the published BokehJS resources HTML code may cause Bokeh CSS styling to be removed. Returns: None """ global _notebook_loaded from .. import __version__ from ..resources import INLINE from ..templates import NOTEBOOK_LOAD, RESOURCES if resources is None: resources = INLINE plot_resources = RESOURCES.render( js_raw = resources.js_raw, css_raw = resources.css_raw, js_files = resources.js_files, css_files = resources.css_files, ) if resources.mode == 'inline': js_info = 'inline' css_info = 'inline' else: js_info = resources.js_files[0] if len(resources.js_files) == 1 else resources.js_files css_info = resources.css_files[0] if len(resources.css_files) == 1 else resources.css_files warnings = ["Warning: " + msg['text'] for msg in resources.messages if msg['type'] == 'warn'] if _notebook_loaded: warnings.append('Warning: BokehJS previously loaded') _notebook_loaded = resources html = NOTEBOOK_LOAD.render( plot_resources = plot_resources, logo_url = resources.logo_url, verbose = verbose, js_info = js_info, css_info = css_info, bokeh_version = __version__, warnings = warnings, hide_banner = hide_banner, ) publish_display_data({'text/html': html}) def publish_display_data(data, source='bokeh'): """ Compatibility wrapper for IPython ``publish_display_data`` Later versions of IPython remove the ``source`` (first) argument. This function insulates Bokeh library code from this change. Args: source (str, optional) : the source arg for IPython (default: "bokeh") data (dict) : the data dict to pass to ``publish_display_data`` Typically has the form ``{'text/html': html}`` """ import IPython.core.displaypub as displaypub try: displaypub.publish_display_data(source, data) except TypeError: displaypub.publish_display_data(data)
bsd-3-clause
[ 624, 17471, 2997, 367, 8697, 5088, 16610, 1233, 436, 666, 315, 16243, 5317, 8858, 14, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 63, 19174, 63, 4591, 275, 488, 199, 199, 318, 2248, 63, 19174, 8, 4435, 29, 403, 12, 3376, 29, 797, 12, 13714, 63, 13066, 29, 797, 304, 272, 408, 17008, 314, 16243, 20751, 367, 20589, 5088, 16610, 19695, 14, 339, 3033, 26, 267, 5944, 334, 4031, 12, 2716, 9, 520, 288, 4212, 436, 2382, 370, 2248, 5088, 16610, 11378, 687, 398, 3376, 334, 2245, 12, 2716, 9, 520, 288, 3775, 370, 3622, 16212, 2202, 334, 885, 26, 756, 9, 398, 13714, 63, 13066, 334, 2245, 12, 2716, 304, 288, 3775, 370, 13714, 314, 5088, 16610, 20997, 334, 885, 26, 756, 9, 339, 2508, 5721, 447, 267, 14836, 316, 314, 1072, 4917, 3035, 314, 3267, 5088, 16610, 11378, 267, 5944, 4163, 1233, 1443, 7675, 5088, 16610, 15750, 32468, 2983, 370, 506, 4829, 14, 339, 1803, 26, 267, 488, 339, 408, 272, 2288, 485, 19174, 63, 4591, 339, 687, 2508, 492, 636, 1023, 363, 272, 687, 2508, 4435, 492, 1621, 6174, 272, 687, 2508, 5876, 492, 6944, 21155, 63, 7405, 12, 12565, 11237, 16734, 339, 340, 5944, 365, 488, 26, 267, 5944, 275, 1621, 6174, 339, 5137, 63, 4435, 275, 12565, 11237, 16734, 14, 3352, 8, 267, 8586, 63, 1773, 275, 5944, 14, 3596, 63, 1773, 12, 267, 11431, 63, 1773, 275, 5944, 14, 3919, 63, 1773, 12, 267, 8586, 63, 1725, 275, 5944, 14, 3596, 63, 1725, 12, 267, 11431, 63, 1725, 275, 5944, 14, 3919, 63, 1725, 12, 272, 776, 339, 340, 5944, 14, 632, 508, 283, 6460, 356, 267, 8586, 63, 815, 275, 283, 6460, 7, 267, 11431, 63, 815, 275, 283, 6460, 7, 272, 587, 26, 267, 8586, 63, 815, 275, 5944, 14, 3596, 63, 1725, 59, 16, 61, 340, 822, 8, 4435, 14, 3596, 63, 1725, 9, 508, 413, 587, 5944, 14, 3596, 63, 1725, 267, 11431, 63, 815, 275, 5944, 14, 3919, 63, 1725, 59, 16, 61, 340, 822, 8, 4435, 14, 3919, 63, 1725, 9, 508, 413, 587, 5944, 14, 3919, 63, 1725, 339, 3598, 275, 2097, 3849, 26, 298, 435, 1499, 459, 505, 418, 367, 1499, 315, 5944, 14, 3431, 340, 1499, 459, 466, 418, 508, 283, 4050, 418, 339, 340, 485, 19174, 63, 4591, 26, 267, 3598, 14, 740, 360, 3849, 26, 5088, 16610, 11378, 10889, 6511, 358, 339, 485, 19174, 63, 4591, 275, 5944, 339, 3517, 275, 6944, 21155, 63, 7405, 14, 3352, 8, 267, 5137, 63, 4435, 275, 5137, 63, 4435, 12, 267, 23623, 63, 633, 275, 5944, 14, 9733, 63, 633, 12, 267, 3376, 275, 3376, 12, 267, 8586, 63, 815, 275, 8586, 63, 815, 12, 267, 11431, 63, 815, 275, 11431, 63, 815, 12, 267, 25214, 63, 1023, 275, 636, 1023, 3108, 267, 3598, 275, 3598, 12, 267, 13714, 63, 13066, 275, 13714, 63, 13066, 12, 272, 776, 272, 2780, 63, 2918, 63, 576, 3252, 505, 15, 1360, 356, 3517, 1552, 421, 199, 318, 2780, 63, 2918, 63, 576, 8, 576, 12, 1350, 534, 656, 16610, 735, 272, 408, 3599, 5880, 4975, 367, 16243, 1124, 4763, 63, 2918, 63, 576, 1040, 339, 491, 6618, 5459, 402, 16243, 2813, 314, 1124, 1365, 1040, 334, 2246, 9, 1423, 14, 961, 272, 805, 5261, 15409, 5088, 16610, 3555, 1233, 687, 642, 1570, 14, 339, 3033, 26, 267, 1350, 334, 495, 12, 2716, 9, 520, 314, 1350, 1680, 367, 16243, 334, 885, 26, 298, 656, 16610, 531, 267, 666, 334, 807, 9, 520, 314, 666, 1211, 370, 986, 370, 1124, 4763, 63, 2918, 63, 576, 1040, 288, 26914, 965, 314, 1824, 1124, 1445, 505, 15, 1360, 356, 3517, 93, 1040, 339, 408, 272, 492, 16243, 14, 1018, 14, 2918, 5645, 465, 2929, 5645, 272, 862, 26, 267, 2929, 5645, 14, 4763, 63, 2918, 63, 576, 8, 1365, 12, 666, 9, 272, 871, 3146, 26, 267, 2929, 5645, 14, 4763, 63, 2918, 63, 576, 8, 576, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 17471, 2997, 367, 8697, 5088, 16610, 1233, 436, 666, 315, 16243, 5317, 8858, 14, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 63, 19174, 63, 4591, 275, 488, 199, 199, 318, 2248, 63, 19174, 8, 4435, 29, 403, 12, 3376, 29, 797, 12, 13714, 63, 13066, 29, 797, 304, 272, 408, 17008, 314, 16243, 20751, 367, 20589, 5088, 16610, 19695, 14, 339, 3033, 26, 267, 5944, 334, 4031, 12, 2716, 9, 520, 288, 4212, 436, 2382, 370, 2248, 5088, 16610, 11378, 687, 398, 3376, 334, 2245, 12, 2716, 9, 520, 288, 3775, 370, 3622, 16212, 2202, 334, 885, 26, 756, 9, 398, 13714, 63, 13066, 334, 2245, 12, 2716, 304, 288, 3775, 370, 13714, 314, 5088, 16610, 20997, 334, 885, 26, 756, 9, 339, 2508, 5721, 447, 267, 14836, 316, 314, 1072, 4917, 3035, 314, 3267, 5088, 16610, 11378, 267, 5944, 4163, 1233, 1443, 7675, 5088, 16610, 15750, 32468, 2983, 370, 506, 4829, 14, 339, 1803, 26, 267, 488, 339, 408, 272, 2288, 485, 19174, 63, 4591, 339, 687, 2508, 492, 636, 1023, 363, 272, 687, 2508, 4435, 492, 1621, 6174, 272, 687, 2508, 5876, 492, 6944, 21155, 63, 7405, 12, 12565, 11237, 16734, 339, 340, 5944, 365, 488, 26, 267, 5944, 275, 1621, 6174, 339, 5137, 63, 4435, 275, 12565, 11237, 16734, 14, 3352, 8, 267, 8586, 63, 1773, 275, 5944, 14, 3596, 63, 1773, 12, 267, 11431, 63, 1773, 275, 5944, 14, 3919, 63, 1773, 12, 267, 8586, 63, 1725, 275, 5944, 14, 3596, 63, 1725, 12, 267, 11431, 63, 1725, 275, 5944, 14, 3919, 63, 1725, 12, 272, 776, 339, 340, 5944, 14, 632, 508, 283, 6460, 356, 267, 8586, 63, 815, 275, 283, 6460, 7, 267, 11431, 63, 815, 275, 283, 6460, 7, 272, 587, 26, 267, 8586, 63, 815, 275, 5944, 14, 3596, 63, 1725, 59, 16, 61, 340, 822, 8, 4435, 14, 3596, 63, 1725, 9, 508, 413, 587, 5944, 14, 3596, 63, 1725, 267, 11431, 63, 815, 275, 5944, 14, 3919, 63, 1725, 59, 16, 61, 340, 822, 8, 4435, 14, 3919, 63, 1725, 9, 508, 413, 587, 5944, 14, 3919, 63, 1725, 339, 3598, 275, 2097, 3849, 26, 298, 435, 1499, 459, 505, 418, 367, 1499, 315, 5944, 14, 3431, 340, 1499, 459, 466, 418, 508, 283, 4050, 418, 339, 340, 485, 19174, 63, 4591, 26, 267, 3598, 14, 740, 360, 3849, 26, 5088, 16610, 11378, 10889, 6511, 358, 339, 485, 19174, 63, 4591, 275, 5944, 339, 3517, 275, 6944, 21155, 63, 7405, 14, 3352, 8, 267, 5137, 63, 4435, 275, 5137, 63, 4435, 12, 267, 23623, 63, 633, 275, 5944, 14, 9733, 63, 633, 12, 267, 3376, 275, 3376, 12, 267, 8586, 63, 815, 275, 8586, 63, 815, 12, 267, 11431, 63, 815, 275, 11431, 63, 815, 12, 267, 25214, 63, 1023, 275, 636, 1023, 3108, 267, 3598, 275, 3598, 12, 267, 13714, 63, 13066, 275, 13714, 63, 13066, 12, 272, 776, 272, 2780, 63, 2918, 63, 576, 3252, 505, 15, 1360, 356, 3517, 1552, 421, 199, 318, 2780, 63, 2918, 63, 576, 8, 576, 12, 1350, 534, 656, 16610, 735, 272, 408, 3599, 5880, 4975, 367, 16243, 1124, 4763, 63, 2918, 63, 576, 1040, 339, 491, 6618, 5459, 402, 16243, 2813, 314, 1124, 1365, 1040, 334, 2246, 9, 1423, 14, 961, 272, 805, 5261, 15409, 5088, 16610, 3555, 1233, 687, 642, 1570, 14, 339, 3033, 26, 267, 1350, 334, 495, 12, 2716, 9, 520, 314, 1350, 1680, 367, 16243, 334, 885, 26, 298, 656, 16610, 531, 267, 666, 334, 807, 9, 520, 314, 666, 1211, 370, 986, 370, 1124, 4763, 63, 2918, 63, 576, 1040, 288, 26914, 965, 314, 1824, 1124, 1445, 505, 15, 1360, 356, 3517, 93, 1040, 339, 408, 272, 492, 16243, 14, 1018, 14, 2918, 5645, 465, 2929, 5645, 272, 862, 26, 267, 2929, 5645, 14, 4763, 63, 2918, 63, 576, 8, 1365, 12, 666, 9, 272, 871, 3146, 26, 267, 2929, 5645, 14, 4763, 63, 2918, 63, 576, 8, 576, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
RabadanLab/MITKats
Modules/Biophotonics/python/iMC/regression/estimation.py
5
4129
""" The MultiSpectral Imaging Toolkit (MSITK) Copyright (c) German Cancer Research Center, Computer Assisted Interventions. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE for details """ ''' Created on Oct 21, 2015 @author: wirkert ''' import math import logging import time import tensorflow as tf import numpy as np import SimpleITK as sitk from regression.tensorflow_estimator import multilayer_perceptron, cnn import msi.imgmani as imgmani def SAMDistance(x, y): return math.acos(np.dot(x, y) / (np.linalg.norm(x) * np.linalg.norm(y))) def estimate_image(msi, regressor): """given an Msi and an regressor estimate the parmaeters for this image Paramters: msi: multi spectral image regressor: regressor, must implement the predict method""" # estimate parameters collapsed_msi = imgmani.collapse_image(msi.get_image()) # in case of nan values: set to 0 collapsed_msi[np.isnan(collapsed_msi)] = 0. collapsed_msi[np.isinf(collapsed_msi)] = 0. start = time.time() estimated_parameters = regressor.predict(collapsed_msi) end = time.time() estimation_time = end - start logging.info("time necessary for estimating image parameters: " + str(estimation_time) + "s") # restore shape feature_dimension = 1 if len(estimated_parameters.shape) > 1: feature_dimension = estimated_parameters.shape[-1] estimated_paramters_as_image = np.reshape( estimated_parameters, (msi.get_image().shape[0], msi.get_image().shape[1], feature_dimension)) # save as sitk nrrd. sitk_img = sitk.GetImageFromArray(estimated_paramters_as_image, isVector=True) return sitk_img, estimation_time def estimate_image_tensorflow(msi, model_checkpoint_dir): # estimate parameters collapsed_msi = imgmani.collapse_image(msi.get_image()) # in case of nan values: set to 0 collapsed_msi[np.isnan(collapsed_msi)] = 0. collapsed_msi[np.isinf(collapsed_msi)] = 0. tf.reset_default_graph() keep_prob = tf.placeholder("float") nr_wavelengths = len(msi.get_wavelengths()) x = tf.placeholder("float", [None, nr_wavelengths, 1, 1]) x_test_image = np.reshape(msi.get_image(), [-1, nr_wavelengths, 1, 1]) # Construct the desired model # pred, regularizers = multilayer_perceptron(x, nr_wavelengths, 100, 1, # keep_prob) pred = cnn(x, 1, keep_prob) # Initializing the variables init = tf.initialize_all_variables() saver = tf.train.Saver() with tf.Session() as sess: sess.run(tf.initialize_all_variables()) # restore model: ckpt = tf.train.get_checkpoint_state(model_checkpoint_dir) if ckpt and ckpt.model_checkpoint_path: saver.restore(sess, ckpt.model_checkpoint_path) start = time.time() estimated_parameters = pred.eval({x: x_test_image, keep_prob:1.0}) end = time.time() estimation_time = end - start logging.info("time necessary for estimating image parameters: " + str(estimation_time) + "s") # restore shape feature_dimension = 1 if len(estimated_parameters.shape) > 1: feature_dimension = estimated_parameters.shape[-1] estimated_paramters_as_image = np.reshape( estimated_parameters, (msi.get_image().shape[0], msi.get_image().shape[1], feature_dimension)) # save as sitk nrrd. sitk_img = sitk.GetImageFromArray(estimated_paramters_as_image, isVector=True) return sitk_img, estimation_time def standard_score(estimator, X, y): """our standard scoring method is the median absolute error""" return np.median(np.abs(estimator.predict(X) - y))
bsd-3-clause
[ 199, 199, 624, 199, 199, 1918, 6879, 51, 15832, 473, 391, 1540, 15650, 6065, 334, 3053, 649, 43, 9, 199, 199, 7384, 334, 67, 9, 22261, 1237, 6855, 2247, 26993, 24699, 12, 199, 2404, 2699, 3709, 24925, 6551, 1856, 852, 14, 199, 2422, 4481, 4644, 14, 199, 199, 2765, 2032, 365, 1854, 2428, 1821, 3408, 27, 1928, 199, 12056, 314, 2478, 3750, 402, 3169, 503, 3092, 2381, 199, 33, 3115, 3104, 14, 199, 199, 9295, 5113, 367, 2436, 199, 199, 624, 199, 2344, 199, 10502, 641, 18365, 7829, 12, 6900, 199, 199, 32, 2502, 26, 336, 723, 2570, 84, 199, 2344, 199, 199, 646, 3473, 199, 646, 2050, 199, 646, 900, 199, 199, 646, 3228, 465, 2833, 199, 646, 2680, 465, 980, 199, 646, 5870, 649, 43, 465, 13867, 75, 199, 199, 504, 10864, 14, 16008, 63, 8627, 492, 3510, 1897, 63, 529, 301, 4695, 265, 12, 286, 4411, 199, 646, 333, 338, 14, 4060, 1237, 73, 465, 6050, 1237, 73, 421, 199, 318, 428, 1156, 10076, 8, 88, 12, 612, 304, 272, 372, 3473, 14, 65, 5197, 8, 1590, 14, 3287, 8, 88, 12, 612, 9, 1182, 334, 1590, 14, 10096, 14, 4791, 8, 88, 9, 627, 980, 14, 10096, 14, 4791, 8, 89, 1724, 421, 199, 318, 14497, 63, 1569, 8, 77, 338, 12, 1295, 11686, 304, 272, 408, 11809, 376, 603, 338, 436, 376, 1295, 11686, 14497, 314, 623, 391, 69, 878, 367, 642, 1834, 339, 12608, 878, 26, 267, 333, 338, 26, 3510, 28397, 1834, 267, 1295, 11686, 26, 1295, 11686, 12, 1471, 5669, 314, 12610, 1083, 624, 339, 327, 14497, 2633, 272, 31219, 63, 77, 338, 275, 6050, 1237, 73, 14, 20681, 63, 1569, 8, 77, 338, 14, 362, 63, 1569, 1012, 272, 327, 315, 1930, 402, 12055, 1338, 26, 663, 370, 378, 272, 31219, 63, 77, 338, 59, 1590, 14, 12936, 8, 761, 9982, 63, 77, 338, 1874, 275, 378, 14, 272, 31219, 63, 77, 338, 59, 1590, 14, 29326, 8, 761, 9982, 63, 77, 338, 1874, 275, 378, 14, 339, 1343, 275, 900, 14, 521, 342, 272, 20077, 63, 3214, 275, 1295, 11686, 14, 6892, 8, 761, 9982, 63, 77, 338, 9, 272, 1284, 275, 900, 14, 521, 342, 272, 27156, 63, 521, 275, 1284, 446, 1343, 272, 2050, 14, 815, 480, 521, 5784, 367, 4347, 3969, 316, 1834, 2633, 26, 298, 435, 267, 620, 8, 597, 8182, 63, 521, 9, 435, 298, 83, 531, 272, 327, 9066, 2215, 272, 3878, 63, 7430, 275, 413, 272, 340, 822, 8, 597, 12754, 63, 3214, 14, 1392, 9, 690, 413, 26, 267, 3878, 63, 7430, 275, 20077, 63, 3214, 14, 1392, 1988, 17, 61, 339, 20077, 63, 635, 878, 63, 305, 63, 1569, 275, 980, 14, 5217, 8, 288, 20077, 63, 3214, 12, 334, 77, 338, 14, 362, 63, 1569, 1252, 1392, 59, 16, 467, 3521, 333, 338, 14, 362, 63, 1569, 1252, 1392, 59, 17, 467, 3521, 3878, 63, 7430, 430, 272, 327, 3354, 465, 13867, 75, 14762, 6883, 14, 272, 13867, 75, 63, 4060, 275, 13867, 75, 14, 1002, 3491, 2532, 3836, 8, 597, 12754, 63, 635, 878, 63, 305, 63, 1569, 12, 639, 365, 3646, 29, 549, 9, 272, 372, 13867, 75, 63, 4060, 12, 27156, 63, 521, 421, 199, 318, 14497, 63, 1569, 63, 16008, 8, 77, 338, 12, 1402, 63, 10109, 63, 694, 304, 272, 327, 14497, 2633, 272, 31219, 63, 77, 338, 275, 6050, 1237, 73, 14, 20681, 63, 1569, 8, 77, 338, 14, 362, 63, 1569, 1012, 272, 327, 315, 1930, 402, 12055, 1338, 26, 663, 370, 378, 272, 31219, 63, 77, 338, 59, 1590, 14, 12936, 8, 761, 9982, 63, 77, 338, 1874, 275, 378, 14, 272, 31219, 63, 77, 338, 59, 1590, 14, 29326, 8, 761, 9982, 63, 77, 338, 1874, 275, 378, 14, 2378, 2833, 14, 3958, 63, 885, 63, 2180, 342, 339, 4215, 63, 6101, 275, 2833, 14, 6199, 480, 1609, 531, 272, 14762, 63, 10024, 14563, 275, 822, 8, 77, 338, 14, 362, 63, 10024, 14563, 1012, 272, 671, 275, 2833, 14, 6199, 480, 1609, 401, 359, 403, 12, 14762, 63, 10024, 14563, 12, 413, 12, 413, 566, 339, 671, 63, 396, 63, 1569, 275, 980, 14, 5217, 8, 77, 338, 14, 362, 63, 1569, 1062, 5243, 17, 12, 14762, 63, 10024, 14563, 12, 413, 12, 413, 566, 339, 327, 9215, 314, 6387, 1402, 272, 327, 8869, 12, 5578, 6315, 275, 3510, 1897, 63, 529, 301, 4695, 265, 8, 88, 12, 14762, 63, 10024, 14563, 12, 2948, 12, 413, 12, 272, 327, 2476, 3322, 4215, 63, 6101, 9, 272, 8869, 275, 286, 4411, 8, 88, 12, 413, 12, 4215, 63, 6101, 9, 339, 327, 6026, 9147, 314, 2860, 272, 4205, 275, 2833, 14, 8489, 63, 452, 63, 3669, 342, 339, 17559, 275, 2833, 14, 2834, 14, 20829, 342, 339, 543, 2833, 14, 4434, 342, 465, 4043, 26, 267, 4043, 14, 1065, 8, 3249, 14, 8489, 63, 452, 63, 3669, 1012, 267, 327, 9066, 1402, 26, 267, 22030, 541, 275, 2833, 14, 2834, 14, 362, 63, 10109, 63, 929, 8, 1238, 63, 10109, 63, 694, 9, 398, 340, 22030, 541, 436, 22030, 541, 14, 1238, 63, 10109, 63, 515, 26, 288, 17559, 14, 8011, 8, 5480, 12, 22030, 541, 14, 1238, 63, 10109, 63, 515, 9, 953, 1343, 275, 900, 14, 521, 342, 288, 20077, 63, 3214, 275, 8869, 14, 2579, 2561, 88, 26, 671, 63, 396, 63, 1569, 12, 6343, 4215, 63, 6101, 26, 17, 14, 16, 1552, 288, 1284, 275, 900, 14, 521, 342, 288, 27156, 63, 521, 275, 1284, 446, 1343, 288, 2050, 14, 815, 480, 521, 5784, 367, 4347, 3969, 316, 1834, 2633, 26, 298, 435, 355, 620, 8, 597, 8182, 63, 521, 9, 435, 298, 83, 531, 272, 327, 9066, 2215, 272, 3878, 63, 7430, 275, 413, 272, 340, 822, 8, 597, 12754, 63, 3214, 14, 1392, 9, 690, 413, 26, 267, 3878, 63, 7430, 275, 20077, 63, 3214, 14, 1392, 1988, 17, 61, 339, 20077, 63, 635, 878, 63, 305, 63, 1569, 275, 980, 14, 5217, 8, 288, 20077, 63, 3214, 12, 334, 77, 338, 14, 362, 63, 1569, 1252, 1392, 59, 16, 467, 3521, 333, 338, 14, 362, 63, 1569, 1252 ]
[ 199, 624, 199, 199, 1918, 6879, 51, 15832, 473, 391, 1540, 15650, 6065, 334, 3053, 649, 43, 9, 199, 199, 7384, 334, 67, 9, 22261, 1237, 6855, 2247, 26993, 24699, 12, 199, 2404, 2699, 3709, 24925, 6551, 1856, 852, 14, 199, 2422, 4481, 4644, 14, 199, 199, 2765, 2032, 365, 1854, 2428, 1821, 3408, 27, 1928, 199, 12056, 314, 2478, 3750, 402, 3169, 503, 3092, 2381, 199, 33, 3115, 3104, 14, 199, 199, 9295, 5113, 367, 2436, 199, 199, 624, 199, 2344, 199, 10502, 641, 18365, 7829, 12, 6900, 199, 199, 32, 2502, 26, 336, 723, 2570, 84, 199, 2344, 199, 199, 646, 3473, 199, 646, 2050, 199, 646, 900, 199, 199, 646, 3228, 465, 2833, 199, 646, 2680, 465, 980, 199, 646, 5870, 649, 43, 465, 13867, 75, 199, 199, 504, 10864, 14, 16008, 63, 8627, 492, 3510, 1897, 63, 529, 301, 4695, 265, 12, 286, 4411, 199, 646, 333, 338, 14, 4060, 1237, 73, 465, 6050, 1237, 73, 421, 199, 318, 428, 1156, 10076, 8, 88, 12, 612, 304, 272, 372, 3473, 14, 65, 5197, 8, 1590, 14, 3287, 8, 88, 12, 612, 9, 1182, 334, 1590, 14, 10096, 14, 4791, 8, 88, 9, 627, 980, 14, 10096, 14, 4791, 8, 89, 1724, 421, 199, 318, 14497, 63, 1569, 8, 77, 338, 12, 1295, 11686, 304, 272, 408, 11809, 376, 603, 338, 436, 376, 1295, 11686, 14497, 314, 623, 391, 69, 878, 367, 642, 1834, 339, 12608, 878, 26, 267, 333, 338, 26, 3510, 28397, 1834, 267, 1295, 11686, 26, 1295, 11686, 12, 1471, 5669, 314, 12610, 1083, 624, 339, 327, 14497, 2633, 272, 31219, 63, 77, 338, 275, 6050, 1237, 73, 14, 20681, 63, 1569, 8, 77, 338, 14, 362, 63, 1569, 1012, 272, 327, 315, 1930, 402, 12055, 1338, 26, 663, 370, 378, 272, 31219, 63, 77, 338, 59, 1590, 14, 12936, 8, 761, 9982, 63, 77, 338, 1874, 275, 378, 14, 272, 31219, 63, 77, 338, 59, 1590, 14, 29326, 8, 761, 9982, 63, 77, 338, 1874, 275, 378, 14, 339, 1343, 275, 900, 14, 521, 342, 272, 20077, 63, 3214, 275, 1295, 11686, 14, 6892, 8, 761, 9982, 63, 77, 338, 9, 272, 1284, 275, 900, 14, 521, 342, 272, 27156, 63, 521, 275, 1284, 446, 1343, 272, 2050, 14, 815, 480, 521, 5784, 367, 4347, 3969, 316, 1834, 2633, 26, 298, 435, 267, 620, 8, 597, 8182, 63, 521, 9, 435, 298, 83, 531, 272, 327, 9066, 2215, 272, 3878, 63, 7430, 275, 413, 272, 340, 822, 8, 597, 12754, 63, 3214, 14, 1392, 9, 690, 413, 26, 267, 3878, 63, 7430, 275, 20077, 63, 3214, 14, 1392, 1988, 17, 61, 339, 20077, 63, 635, 878, 63, 305, 63, 1569, 275, 980, 14, 5217, 8, 288, 20077, 63, 3214, 12, 334, 77, 338, 14, 362, 63, 1569, 1252, 1392, 59, 16, 467, 3521, 333, 338, 14, 362, 63, 1569, 1252, 1392, 59, 17, 467, 3521, 3878, 63, 7430, 430, 272, 327, 3354, 465, 13867, 75, 14762, 6883, 14, 272, 13867, 75, 63, 4060, 275, 13867, 75, 14, 1002, 3491, 2532, 3836, 8, 597, 12754, 63, 635, 878, 63, 305, 63, 1569, 12, 639, 365, 3646, 29, 549, 9, 272, 372, 13867, 75, 63, 4060, 12, 27156, 63, 521, 421, 199, 318, 14497, 63, 1569, 63, 16008, 8, 77, 338, 12, 1402, 63, 10109, 63, 694, 304, 272, 327, 14497, 2633, 272, 31219, 63, 77, 338, 275, 6050, 1237, 73, 14, 20681, 63, 1569, 8, 77, 338, 14, 362, 63, 1569, 1012, 272, 327, 315, 1930, 402, 12055, 1338, 26, 663, 370, 378, 272, 31219, 63, 77, 338, 59, 1590, 14, 12936, 8, 761, 9982, 63, 77, 338, 1874, 275, 378, 14, 272, 31219, 63, 77, 338, 59, 1590, 14, 29326, 8, 761, 9982, 63, 77, 338, 1874, 275, 378, 14, 2378, 2833, 14, 3958, 63, 885, 63, 2180, 342, 339, 4215, 63, 6101, 275, 2833, 14, 6199, 480, 1609, 531, 272, 14762, 63, 10024, 14563, 275, 822, 8, 77, 338, 14, 362, 63, 10024, 14563, 1012, 272, 671, 275, 2833, 14, 6199, 480, 1609, 401, 359, 403, 12, 14762, 63, 10024, 14563, 12, 413, 12, 413, 566, 339, 671, 63, 396, 63, 1569, 275, 980, 14, 5217, 8, 77, 338, 14, 362, 63, 1569, 1062, 5243, 17, 12, 14762, 63, 10024, 14563, 12, 413, 12, 413, 566, 339, 327, 9215, 314, 6387, 1402, 272, 327, 8869, 12, 5578, 6315, 275, 3510, 1897, 63, 529, 301, 4695, 265, 8, 88, 12, 14762, 63, 10024, 14563, 12, 2948, 12, 413, 12, 272, 327, 2476, 3322, 4215, 63, 6101, 9, 272, 8869, 275, 286, 4411, 8, 88, 12, 413, 12, 4215, 63, 6101, 9, 339, 327, 6026, 9147, 314, 2860, 272, 4205, 275, 2833, 14, 8489, 63, 452, 63, 3669, 342, 339, 17559, 275, 2833, 14, 2834, 14, 20829, 342, 339, 543, 2833, 14, 4434, 342, 465, 4043, 26, 267, 4043, 14, 1065, 8, 3249, 14, 8489, 63, 452, 63, 3669, 1012, 267, 327, 9066, 1402, 26, 267, 22030, 541, 275, 2833, 14, 2834, 14, 362, 63, 10109, 63, 929, 8, 1238, 63, 10109, 63, 694, 9, 398, 340, 22030, 541, 436, 22030, 541, 14, 1238, 63, 10109, 63, 515, 26, 288, 17559, 14, 8011, 8, 5480, 12, 22030, 541, 14, 1238, 63, 10109, 63, 515, 9, 953, 1343, 275, 900, 14, 521, 342, 288, 20077, 63, 3214, 275, 8869, 14, 2579, 2561, 88, 26, 671, 63, 396, 63, 1569, 12, 6343, 4215, 63, 6101, 26, 17, 14, 16, 1552, 288, 1284, 275, 900, 14, 521, 342, 288, 27156, 63, 521, 275, 1284, 446, 1343, 288, 2050, 14, 815, 480, 521, 5784, 367, 4347, 3969, 316, 1834, 2633, 26, 298, 435, 355, 620, 8, 597, 8182, 63, 521, 9, 435, 298, 83, 531, 272, 327, 9066, 2215, 272, 3878, 63, 7430, 275, 413, 272, 340, 822, 8, 597, 12754, 63, 3214, 14, 1392, 9, 690, 413, 26, 267, 3878, 63, 7430, 275, 20077, 63, 3214, 14, 1392, 1988, 17, 61, 339, 20077, 63, 635, 878, 63, 305, 63, 1569, 275, 980, 14, 5217, 8, 288, 20077, 63, 3214, 12, 334, 77, 338, 14, 362, 63, 1569, 1252, 1392, 59, 16, 467, 3521, 333, 338, 14, 362, 63, 1569, 1252, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
shakamunyi/os-cloud-config
os_cloud_config/neutron.py
1
5961
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P. # # 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 logging from os_cloud_config.cmd.utils import _clients as clients LOG = logging.getLogger(__name__) def initialize_neutron(network_desc, neutron_client=None, keystone_client=None): if not neutron_client: LOG.warn('Creating neutron client inline is deprecated, please pass ' 'the client as parameter.') neutron_client = clients.get_neutron_client() if not keystone_client: LOG.warn('Creating keystone client inline is deprecated, please pass ' 'the client as parameter.') keystone_client = clients.get_keystone_client() admin_tenant = _get_admin_tenant_id(keystone_client) if 'physical' in network_desc: network_type = 'physical' if not admin_tenant: raise ValueError("No admin tenant registered in Keystone") if not network_desc['physical']['metadata_server']: raise ValueError("metadata_server is required for physical " "networks") elif 'float' in network_desc: network_type = 'float' else: raise ValueError("No float or physical network defined.") net = _create_net(neutron_client, network_desc, network_type, admin_tenant) subnet = _create_subnet(neutron_client, net, network_desc, network_type, admin_tenant) if 'external' in network_desc: router = _create_router(neutron_client, subnet) ext_net = _create_net(neutron_client, network_desc, 'external', None) _create_subnet(neutron_client, ext_net, network_desc, 'external', None) neutron_client.add_gateway_router( router['router']['id'], {'network_id': ext_net['network']['id']}) LOG.debug("Neutron configured.") def _get_admin_tenant_id(keystone): """Fetch the admin tenant id from Keystone. :param keystone: A keystone v2 client. """ LOG.debug("Discovering admin tenant.") tenant = keystone.tenants.find(name='admin') if tenant: return tenant.id def _create_net(neutron, network_desc, network_type, admin_tenant): """Create a new neutron net. :param neutron: A neutron v2 client. :param network_desc: A network description. :param network_type: The type of network to create. :param admin_tenant: The admin tenant id in Keystone. """ LOG.debug("Creating %s network." % network_type) network = {'admin_state_up': True, 'name': network_desc[network_type]['name']} if network_type == 'physical': network.update({'tenant_id': admin_tenant, 'provider:network_type': 'flat', 'provider:physical_network': network['name']}) elif network_type == 'float': network['shared'] = True elif network_type == 'external': network['router:external'] = True if network_desc[network_type].get('segmentation_id'): vlan_tag = network_desc[network_type]['segmentation_id'] network.update({'provider:network_type': 'vlan', 'provider:segmentation_id': vlan_tag, 'provider:physical_network': 'datacentre'}) return neutron.create_network({'network': network}) def _create_subnet(neutron, net, network_desc, network_type, admin_tenant): """Create a new neutron subnet. :param neutron: A neutron v2 client. :param network_desc: A network description. :param network_type: The type of network to create. :param admin_tenant: The admin tenant id in Keystone. """ cidr = network_desc[network_type]['cidr'] LOG.debug("Creating %s subnet, with CIDR %s." % (network_type, cidr)) subnet = {'ip_version': 4, 'network_id': net['network']['id'], 'cidr': cidr} if network_type == 'physical': metadata = network_desc['physical']['metadata_server'] subnet.update({'tenant_id': admin_tenant, 'host_routes': [{'destination': '169.254.169.254/32', 'nexthop': metadata}]}) elif network_type == 'external': subnet['enable_dhcp'] = False if network_desc[network_type].get('gateway'): subnet['gateway_ip'] = network_desc[network_type]['gateway'] if network_desc[network_type].get('nameserver'): subnet['dns_nameservers'] = [network_desc[network_type]['nameserver']] elif network_type == 'float': subnet['dns_nameservers'] = ['8.8.8.8'] if (network_desc[network_type].get('allocation_start') and network_desc[network_type].get('allocation_end')): allocation_start = network_desc[network_type]['allocation_start'] allocation_end = network_desc[network_type]['allocation_end'] subnet['allocation_pools'] = [{'start': allocation_start, 'end': allocation_end}] return neutron.create_subnet({'subnet': subnet}) def _create_router(neutron, subnet): """Create a new neutron router. :param neutron: A neutron v2 client. :param subnet: The subnet id to route for. """ LOG.debug("Creating router.") router = neutron.create_router({'router': {'name': 'default-router'}}) neutron.add_interface_router(router['router']['id'], {'subnet_id': subnet['subnet']['id']}) return router
apache-2.0
[ 3, 1898, 334, 67, 9, 6927, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 2050, 199, 199, 504, 747, 63, 4091, 63, 888, 14, 1760, 14, 1208, 492, 485, 14555, 465, 13431, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 8265, 63, 10271, 8, 1200, 63, 3257, 12, 8224, 63, 1258, 29, 403, 12, 2432, 19395, 63, 1258, 29, 403, 304, 272, 340, 440, 8224, 63, 1258, 26, 267, 5051, 14, 4050, 360, 14380, 8224, 1890, 8308, 365, 5906, 12, 8749, 986, 283, 326, 283, 1589, 1890, 465, 2725, 2659, 267, 8224, 63, 1258, 275, 13431, 14, 362, 63, 10271, 63, 1258, 342, 272, 340, 440, 19395, 63, 1258, 26, 267, 5051, 14, 4050, 360, 14380, 19395, 1890, 8308, 365, 5906, 12, 8749, 986, 283, 326, 283, 1589, 1890, 465, 2725, 2659, 267, 19395, 63, 1258, 275, 13431, 14, 362, 63, 19143, 63, 1258, 342, 339, 4628, 63, 4647, 275, 485, 362, 63, 2113, 63, 4647, 63, 344, 8, 19143, 63, 1258, 9, 272, 340, 283, 15020, 7, 315, 2784, 63, 3257, 26, 267, 2784, 63, 466, 275, 283, 15020, 7, 267, 340, 440, 4628, 63, 4647, 26, 288, 746, 1722, 480, 1944, 4628, 8261, 7264, 315, 2606, 8361, 531, 267, 340, 440, 2784, 63, 3257, 459, 15020, 2545, 2343, 63, 1000, 2565, 288, 746, 1722, 480, 2343, 63, 1000, 365, 1415, 367, 14095, 298, 2490, 298, 7642, 531, 272, 916, 283, 1609, 7, 315, 2784, 63, 3257, 26, 267, 2784, 63, 466, 275, 283, 1609, 7, 272, 587, 26, 267, 746, 1722, 480, 1944, 2069, 503, 14095, 2784, 3247, 2685, 272, 1851, 275, 485, 981, 63, 846, 8, 10271, 63, 1258, 12, 2784, 63, 3257, 12, 2784, 63, 466, 12, 4628, 63, 4647, 9, 272, 6303, 275, 485, 981, 63, 5327, 8, 10271, 63, 1258, 12, 1851, 12, 2784, 63, 3257, 12, 2784, 63, 466, 12, 1169, 4628, 63, 4647, 9, 272, 340, 283, 5159, 7, 315, 2784, 63, 3257, 26, 267, 6197, 275, 485, 981, 63, 4995, 8, 10271, 63, 1258, 12, 6303, 9, 267, 1599, 63, 846, 275, 485, 981, 63, 846, 8, 10271, 63, 1258, 12, 2784, 63, 3257, 12, 283, 5159, 297, 488, 9, 267, 485, 981, 63, 5327, 8, 10271, 63, 1258, 12, 1599, 63, 846, 12, 2784, 63, 3257, 12, 283, 5159, 297, 488, 9, 267, 8224, 63, 1258, 14, 525, 63, 7019, 63, 4995, 8, 288, 6197, 459, 4995, 2545, 344, 995, 791, 1200, 63, 344, 356, 1599, 63, 846, 459, 1200, 2545, 344, 13678, 272, 5051, 14, 1757, 480, 20915, 7526, 2685, 421, 199, 318, 485, 362, 63, 2113, 63, 4647, 63, 344, 8, 19143, 304, 272, 408, 11135, 314, 4628, 8261, 1305, 687, 2606, 8361, 14, 339, 520, 635, 19395, 26, 437, 19395, 373, 18, 1890, 14, 272, 408, 272, 5051, 14, 1757, 480, 2825, 5899, 316, 4628, 8261, 2685, 272, 8261, 275, 19395, 14, 25021, 14, 1623, 8, 354, 534, 2113, 358, 272, 340, 8261, 26, 267, 372, 8261, 14, 344, 421, 199, 318, 485, 981, 63, 846, 8, 10271, 12, 2784, 63, 3257, 12, 2784, 63, 466, 12, 4628, 63, 4647, 304, 272, 408, 2499, 282, 892, 8224, 1851, 14, 339, 520, 635, 8224, 26, 437, 8224, 373, 18, 1890, 14, 272, 520, 635, 2784, 63, 3257, 26, 437, 2784, 1369, 14, 272, 520, 635, 2784, 63, 466, 26, 710, 730, 402, 2784, 370, 1218, 14, 272, 520, 635, 4628, 63, 4647, 26, 710, 4628, 8261, 1305, 315, 2606, 8361, 14, 272, 408, 272, 5051, 14, 1757, 480, 14380, 450, 83, 2784, 2122, 450, 2784, 63, 466, 9, 272, 2784, 275, 791, 2113, 63, 929, 63, 384, 356, 715, 12, 2049, 283, 354, 356, 2784, 63, 3257, 59, 1200, 63, 466, 2733, 354, 12074, 272, 340, 2784, 63, 466, 508, 283, 15020, 356, 267, 2784, 14, 873, 3252, 4647, 63, 344, 356, 4628, 63, 4647, 12, 717, 283, 3780, 26, 1200, 63, 466, 356, 283, 7088, 297, 717, 283, 3780, 26, 15020, 63, 1200, 356, 2784, 459, 354, 13678, 272, 916, 2784, 63, 466, 508, 283, 1609, 356, 267, 2784, 459, 5555, 418, 275, 715, 272, 916, 2784, 63, 466, 508, 283, 5159, 356, 267, 2784, 459, 4995, 26, 5159, 418, 275, 715, 272, 340, 2784, 63, 3257, 59, 1200, 63, 466, 1055, 362, 360, 26926, 63, 344, 735, 267, 10119, 63, 1450, 275, 2784, 63, 3257, 59, 1200, 63, 466, 2733, 26926, 63, 344, 418, 267, 2784, 14, 873, 3252, 3780, 26, 1200, 63, 466, 356, 283, 7175, 297, 717, 283, 3780, 26, 26926, 63, 344, 356, 10119, 63, 1450, 12, 717, 283, 3780, 26, 15020, 63, 1200, 356, 283, 576, 31748, 3071, 272, 372, 8224, 14, 981, 63, 1200, 3252, 1200, 356, 2784, 1552, 421, 199, 318, 485, 981, 63, 5327, 8, 10271, 12, 1851, 12, 2784, 63, 3257, 12, 2784, 63, 466, 12, 4628, 63, 4647, 304, 272, 408, 2499, 282, 892, 8224, 6303, 14, 339, 520, 635, 8224, 26, 437, 8224, 373, 18, 1890, 14, 272, 520, 635, 2784, 63, 3257, 26, 437, 2784, 1369, 14, 272, 520, 635, 2784, 63, 466, 26, 710, 730, 402, 2784, 370, 1218, 14, 272, 520, 635, 4628, 63, 4647, 26, 710, 4628, 8261, 1305, 315, 2606, 8361, 14, 272, 408, 272, 16770, 275, 2784, 63, 3257, 59, 1200, 63, 466, 2733, 10509, 418, 272, 5051, 14, 1757, 480 ]
[ 1898, 334, 67, 9, 6927, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 2050, 199, 199, 504, 747, 63, 4091, 63, 888, 14, 1760, 14, 1208, 492, 485, 14555, 465, 13431, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 8265, 63, 10271, 8, 1200, 63, 3257, 12, 8224, 63, 1258, 29, 403, 12, 2432, 19395, 63, 1258, 29, 403, 304, 272, 340, 440, 8224, 63, 1258, 26, 267, 5051, 14, 4050, 360, 14380, 8224, 1890, 8308, 365, 5906, 12, 8749, 986, 283, 326, 283, 1589, 1890, 465, 2725, 2659, 267, 8224, 63, 1258, 275, 13431, 14, 362, 63, 10271, 63, 1258, 342, 272, 340, 440, 19395, 63, 1258, 26, 267, 5051, 14, 4050, 360, 14380, 19395, 1890, 8308, 365, 5906, 12, 8749, 986, 283, 326, 283, 1589, 1890, 465, 2725, 2659, 267, 19395, 63, 1258, 275, 13431, 14, 362, 63, 19143, 63, 1258, 342, 339, 4628, 63, 4647, 275, 485, 362, 63, 2113, 63, 4647, 63, 344, 8, 19143, 63, 1258, 9, 272, 340, 283, 15020, 7, 315, 2784, 63, 3257, 26, 267, 2784, 63, 466, 275, 283, 15020, 7, 267, 340, 440, 4628, 63, 4647, 26, 288, 746, 1722, 480, 1944, 4628, 8261, 7264, 315, 2606, 8361, 531, 267, 340, 440, 2784, 63, 3257, 459, 15020, 2545, 2343, 63, 1000, 2565, 288, 746, 1722, 480, 2343, 63, 1000, 365, 1415, 367, 14095, 298, 2490, 298, 7642, 531, 272, 916, 283, 1609, 7, 315, 2784, 63, 3257, 26, 267, 2784, 63, 466, 275, 283, 1609, 7, 272, 587, 26, 267, 746, 1722, 480, 1944, 2069, 503, 14095, 2784, 3247, 2685, 272, 1851, 275, 485, 981, 63, 846, 8, 10271, 63, 1258, 12, 2784, 63, 3257, 12, 2784, 63, 466, 12, 4628, 63, 4647, 9, 272, 6303, 275, 485, 981, 63, 5327, 8, 10271, 63, 1258, 12, 1851, 12, 2784, 63, 3257, 12, 2784, 63, 466, 12, 1169, 4628, 63, 4647, 9, 272, 340, 283, 5159, 7, 315, 2784, 63, 3257, 26, 267, 6197, 275, 485, 981, 63, 4995, 8, 10271, 63, 1258, 12, 6303, 9, 267, 1599, 63, 846, 275, 485, 981, 63, 846, 8, 10271, 63, 1258, 12, 2784, 63, 3257, 12, 283, 5159, 297, 488, 9, 267, 485, 981, 63, 5327, 8, 10271, 63, 1258, 12, 1599, 63, 846, 12, 2784, 63, 3257, 12, 283, 5159, 297, 488, 9, 267, 8224, 63, 1258, 14, 525, 63, 7019, 63, 4995, 8, 288, 6197, 459, 4995, 2545, 344, 995, 791, 1200, 63, 344, 356, 1599, 63, 846, 459, 1200, 2545, 344, 13678, 272, 5051, 14, 1757, 480, 20915, 7526, 2685, 421, 199, 318, 485, 362, 63, 2113, 63, 4647, 63, 344, 8, 19143, 304, 272, 408, 11135, 314, 4628, 8261, 1305, 687, 2606, 8361, 14, 339, 520, 635, 19395, 26, 437, 19395, 373, 18, 1890, 14, 272, 408, 272, 5051, 14, 1757, 480, 2825, 5899, 316, 4628, 8261, 2685, 272, 8261, 275, 19395, 14, 25021, 14, 1623, 8, 354, 534, 2113, 358, 272, 340, 8261, 26, 267, 372, 8261, 14, 344, 421, 199, 318, 485, 981, 63, 846, 8, 10271, 12, 2784, 63, 3257, 12, 2784, 63, 466, 12, 4628, 63, 4647, 304, 272, 408, 2499, 282, 892, 8224, 1851, 14, 339, 520, 635, 8224, 26, 437, 8224, 373, 18, 1890, 14, 272, 520, 635, 2784, 63, 3257, 26, 437, 2784, 1369, 14, 272, 520, 635, 2784, 63, 466, 26, 710, 730, 402, 2784, 370, 1218, 14, 272, 520, 635, 4628, 63, 4647, 26, 710, 4628, 8261, 1305, 315, 2606, 8361, 14, 272, 408, 272, 5051, 14, 1757, 480, 14380, 450, 83, 2784, 2122, 450, 2784, 63, 466, 9, 272, 2784, 275, 791, 2113, 63, 929, 63, 384, 356, 715, 12, 2049, 283, 354, 356, 2784, 63, 3257, 59, 1200, 63, 466, 2733, 354, 12074, 272, 340, 2784, 63, 466, 508, 283, 15020, 356, 267, 2784, 14, 873, 3252, 4647, 63, 344, 356, 4628, 63, 4647, 12, 717, 283, 3780, 26, 1200, 63, 466, 356, 283, 7088, 297, 717, 283, 3780, 26, 15020, 63, 1200, 356, 2784, 459, 354, 13678, 272, 916, 2784, 63, 466, 508, 283, 1609, 356, 267, 2784, 459, 5555, 418, 275, 715, 272, 916, 2784, 63, 466, 508, 283, 5159, 356, 267, 2784, 459, 4995, 26, 5159, 418, 275, 715, 272, 340, 2784, 63, 3257, 59, 1200, 63, 466, 1055, 362, 360, 26926, 63, 344, 735, 267, 10119, 63, 1450, 275, 2784, 63, 3257, 59, 1200, 63, 466, 2733, 26926, 63, 344, 418, 267, 2784, 14, 873, 3252, 3780, 26, 1200, 63, 466, 356, 283, 7175, 297, 717, 283, 3780, 26, 26926, 63, 344, 356, 10119, 63, 1450, 12, 717, 283, 3780, 26, 15020, 63, 1200, 356, 283, 576, 31748, 3071, 272, 372, 8224, 14, 981, 63, 1200, 3252, 1200, 356, 2784, 1552, 421, 199, 318, 485, 981, 63, 5327, 8, 10271, 12, 1851, 12, 2784, 63, 3257, 12, 2784, 63, 466, 12, 4628, 63, 4647, 304, 272, 408, 2499, 282, 892, 8224, 6303, 14, 339, 520, 635, 8224, 26, 437, 8224, 373, 18, 1890, 14, 272, 520, 635, 2784, 63, 3257, 26, 437, 2784, 1369, 14, 272, 520, 635, 2784, 63, 466, 26, 710, 730, 402, 2784, 370, 1218, 14, 272, 520, 635, 4628, 63, 4647, 26, 710, 4628, 8261, 1305, 315, 2606, 8361, 14, 272, 408, 272, 16770, 275, 2784, 63, 3257, 59, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
PriceChild/ansible
lib/ansible/modules/windows/win_say.py
6
4604
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2016, Jon Hawkesworth (@jhawkesworth) <figs@unity.demon.co.uk> # # 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/>. # this is a windows documentation stub. actual code lives in the .ps1 # file of the same name ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = r''' --- module: win_say version_added: "2.3" short_description: Text to speech module for Windows to speak messages and optionally play sounds description: - Uses .NET libraries to convert text to speech and optionally play .wav sounds. Audio Service needs to be running and some kind of speakers or headphones need to be attached to the windows target(s) for the speech to be audible. options: msg: description: - The text to be spoken. Use either msg or msg_file. Optional so that you can use this module just to play sounds. required: false default: none msg_file: description: - Full path to a windows format text file containing the text to be spokend. Use either msg or msg_file. Optional so that you can use this module just to play sounds. required: false default: none voice: description: - Which voice to use. See notes for how to discover installed voices. If the requested voice is not available the default voice will be used. Example voice names from Windows 10 are 'Microsoft Zira Desktop' and 'Microsoft Hazel Desktop'. required: false default: system default voice speech_speed: description: - How fast or slow to speak the text. Must be an integer value in the range -10 to 10. -10 is slowest, 10 is fastest. required: false default: 0 start_sound_path: description: - Full path to a C(.wav) file containing a sound to play before the text is spoken. Useful on conference calls to alert other speakers that ansible has something to say. required: false default: null end_sound_path: description: - Full path to a C(.wav) file containing a sound to play after the text has been spoken. Useful on conference calls to alert other speakers that ansible has finished speaking. required: false default: null author: "Jon Hawkesworth (@jhawkesworth)" notes: - Needs speakers or headphones to do anything useful. - To find which voices are installed, run the following powershell Add-Type -AssemblyName System.Speech $speech = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer $speech.GetInstalledVoices() | ForEach-Object { $_.VoiceInfo } $speech.Dispose() - Speech can be surprisingly slow, so its best to keep message text short. ''' EXAMPLES = r''' # Warn of impending deployment - win_say: msg: Warning, deployment commencing in 5 minutes, please log out. # Using a different voice and a start sound - win_say: start_sound_path: C:\Windows\Media\ding.wav msg: Warning, deployment commencing in 5 minutes, please log out. voice: Microsoft Hazel Desktop # example with start and end sound - win_say: start_sound_path: C:\Windows\Media\Windows Balloon.wav msg: New software installed end_sound_path: C:\Windows\Media\chimes.wav # text from file example - win_say: start_sound_path: C:\Windows\Media\Windows Balloon.wav msg_file: AppData\Local\Temp\morning_report.txt end_sound_path: C:\Windows\Media\chimes.wav ''' RETURN = r''' message_text: description: the text that the module attempted to speak returned: success type: string sample: "Warning, deployment commencing in 5 minutes." voice: description: the voice used to speak the text. returned: success type: string sample: Microsoft Hazel Desktop voice_info: description: the voice used to speak the text. returned: when requested voice could not be loaded type: string sample: Could not load voice TestVoice, using system default voice '''
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, 1603, 265, 869, 10084, 9246, 584, 273, 8593, 74, 2411, 87, 9246, 584, 273, 9, 665, 5513, 32, 6639, 14, 271, 2106, 14, 331, 14, 3210, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 642, 365, 282, 10061, 3794, 10098, 14, 221, 3503, 1233, 27576, 315, 314, 1275, 1190, 17, 199, 3, 570, 402, 314, 2011, 536, 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, 519, 2344, 199, 2595, 199, 578, 26, 4747, 63, 19787, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 3612, 63, 1802, 26, 4516, 370, 32093, 859, 367, 5417, 370, 308, 8556, 3788, 436, 14190, 5232, 20453, 83, 199, 1802, 26, 272, 446, 14911, 1275, 7278, 8363, 370, 3957, 1318, 370, 32093, 436, 14190, 5232, 1275, 19118, 20453, 83, 14, 221, 30885, 7591, 4839, 370, 506, 3879, 436, 2005, 4928, 402, 308, 8556, 1192, 503, 4854, 838, 4548, 1929, 370, 506, 10102, 370, 314, 10061, 1347, 8, 83, 9, 367, 314, 32093, 370, 506, 10576, 328, 830, 14, 199, 1419, 26, 523, 1499, 26, 272, 1369, 26, 489, 446, 710, 1318, 370, 506, 25664, 917, 14, 221, 3645, 1902, 1499, 503, 1499, 63, 493, 14, 221, 4879, 880, 626, 1265, 883, 675, 642, 859, 2951, 370, 5232, 20453, 83, 14, 272, 1415, 26, 3055, 272, 849, 26, 7179, 523, 1499, 63, 493, 26, 272, 1369, 26, 489, 446, 16579, 931, 370, 282, 10061, 1475, 1318, 570, 3035, 314, 1318, 370, 506, 25664, 75, 500, 14, 221, 3645, 1902, 1499, 503, 1499, 63, 493, 14, 221, 4879, 880, 626, 1265, 883, 675, 642, 859, 2951, 370, 5232, 20453, 83, 14, 272, 1415, 26, 3055, 272, 849, 26, 7179, 523, 26563, 26, 272, 1369, 26, 489, 446, 26058, 26563, 370, 675, 14, 1666, 12681, 367, 4212, 370, 20131, 4903, 14164, 2370, 14, 221, 982, 314, 5839, 26563, 365, 440, 2808, 314, 849, 26563, 911, 506, 1202, 14, 5679, 26563, 1561, 687, 5417, 1616, 787, 283, 12940, 3107, 20936, 8055, 17827, 7, 436, 283, 12940, 869, 4651, 352, 8055, 17827, 1370, 272, 1415, 26, 3055, 272, 849, 26, 2656, 849, 26563, 523, 32093, 63, 7625, 26, 272, 1369, 26, 489, 446, 7494, 7377, 503, 11999, 370, 308, 8556, 314, 1318, 14, 221, 9498, 506, 376, 3000, 574, 315, 314, 1425, 446, 709, 370, 1616, 14, 221, 446, 709, 365, 11999, 597, 12, 1616, 365, 289, 32645, 14, 272, 1415, 26, 3055, 272, 849, 26, 378, 523, 1343, 63, 14990, 63, 515, 26, 272, 1369, 26, 489, 446, 16579, 931, 370, 282, 445, 13417, 19118, 9, 570, 3035, 282, 20453, 370, 5232, 2544, 314, 1318, 365, 25664, 917, 14, 221, 18491, 641, 406, 1769, 4882, 370, 10459, 1163, 308, 8556, 1192, 626, 3242, 965, 6020, 370, 14722, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 1284, 63, 14990, 63, 515, 26, 272, 1369, 26, 489, 446, 16579, 931, 370, 282, 445, 13417, 19118, 9, 570, 3035, 282, 20453, 370, 5232, 2410, 314, 1318, 965, 2757, 25664, 917, 14, 221, 18491, 641, 406, 1769, 4882, 370, 10459, 1163, 308, 8556, 1192, 626, 3242, 965, 9158, 308, 8556, 316, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 199, 2502, 26, 298, 42, 265, 869, 10084, 9246, 584, 273, 8593, 74, 2411, 87, 9246, 584, 273, 2924, 199, 5983, 26, 2043, 446, 29613, 308, 8556, 1192, 503, 4854, 838, 4548, 370, 886, 7003, 2997, 14, 2043, 446, 4005, 2342, 1314, 14164, 2370, 787, 4903, 12, 1255, 314, 2569, 7074, 5641, 1362, 2654, 13, 804, 446, 16489, 985, 6187, 14, 27047, 12736, 1362, 2672, 23660, 275, 7053, 13, 1692, 446, 23059, 6187, 14, 27047, 12736, 14, 17746, 14925, 14, 27047, 12736, 17746, 1589, 19158, 1362, 2672, 23660, 14, 1002, 21268, 23956, 2370, 342, 1204, 2104, 22321, 13, 1692, 469, 2672, 3754, 23956, 1885, 2354, 789, 1362, 2672, 23660, 14, 15613, 342, 2043, 446, 428, 321, 12736, 883, 506, 6296, 1359, 1044, 590, 11999, 12, 880, 2399, 5526, 370, 4215, 1245, 1318, 3974, 14, 199, 2344, 199, 199, 8918, 275, 519, 2344, 523, 327, 644, 1060, 402, 1742, 3219, 14295, 199, 13, 4747, 63, 19787, 26, 272, 1499, 26, 15902, 12, 14295, 2414, 1410, 4477, 315, 959, 9395, 12, 8749, 943, 734, 14, 523, 327, 11719, 282, 3365, 26563, 436, 282, 1343, 20453, 199, 13, 4747, 63, 19787, 26, 272, 1343, 63, 14990, 63, 515, 26, 445, 3427, 8647, 60, 11398, 60, 1098, 14, 19118, 272, 1499, 26, 15902, 12, 14295, 2414, 1410, 4477, 315, 959, 9395, 12, 8749, 943, 734, 14, 272, 26563, 26, 15332, 869, 4651, 352, 8055, 17827, 523, 327, 2893, 543, 1343, 436, 1284, 20453, 199, 13, 4747, 63, 19787, 26, 272, 1343, 63, 14990, 63, 515, 26, 445, 3427, 8647, 60, 11398, 60, 8647, 23928, 27734, 14, 19118, 272, 1499, 26, 7053, 2032, 4903, 272, 1284, 63, 14990, 63, 515, 26, 445, 3427, 8647, 60, 11398, 60, 335, 29778, 14, 19118, 523, 327, 1318, 687, 570, 2893, 199, 13, 4747, 63, 19787, 26 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 7800, 12, 1603, 265, 869, 10084, 9246, 584, 273, 8593, 74, 2411, 87, 9246, 584, 273, 9, 665, 5513, 32, 6639, 14, 271, 2106, 14, 331, 14, 3210, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 642, 365, 282, 10061, 3794, 10098, 14, 221, 3503, 1233, 27576, 315, 314, 1275, 1190, 17, 199, 3, 570, 402, 314, 2011, 536, 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, 519, 2344, 199, 2595, 199, 578, 26, 4747, 63, 19787, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 3612, 63, 1802, 26, 4516, 370, 32093, 859, 367, 5417, 370, 308, 8556, 3788, 436, 14190, 5232, 20453, 83, 199, 1802, 26, 272, 446, 14911, 1275, 7278, 8363, 370, 3957, 1318, 370, 32093, 436, 14190, 5232, 1275, 19118, 20453, 83, 14, 221, 30885, 7591, 4839, 370, 506, 3879, 436, 2005, 4928, 402, 308, 8556, 1192, 503, 4854, 838, 4548, 1929, 370, 506, 10102, 370, 314, 10061, 1347, 8, 83, 9, 367, 314, 32093, 370, 506, 10576, 328, 830, 14, 199, 1419, 26, 523, 1499, 26, 272, 1369, 26, 489, 446, 710, 1318, 370, 506, 25664, 917, 14, 221, 3645, 1902, 1499, 503, 1499, 63, 493, 14, 221, 4879, 880, 626, 1265, 883, 675, 642, 859, 2951, 370, 5232, 20453, 83, 14, 272, 1415, 26, 3055, 272, 849, 26, 7179, 523, 1499, 63, 493, 26, 272, 1369, 26, 489, 446, 16579, 931, 370, 282, 10061, 1475, 1318, 570, 3035, 314, 1318, 370, 506, 25664, 75, 500, 14, 221, 3645, 1902, 1499, 503, 1499, 63, 493, 14, 221, 4879, 880, 626, 1265, 883, 675, 642, 859, 2951, 370, 5232, 20453, 83, 14, 272, 1415, 26, 3055, 272, 849, 26, 7179, 523, 26563, 26, 272, 1369, 26, 489, 446, 26058, 26563, 370, 675, 14, 1666, 12681, 367, 4212, 370, 20131, 4903, 14164, 2370, 14, 221, 982, 314, 5839, 26563, 365, 440, 2808, 314, 849, 26563, 911, 506, 1202, 14, 5679, 26563, 1561, 687, 5417, 1616, 787, 283, 12940, 3107, 20936, 8055, 17827, 7, 436, 283, 12940, 869, 4651, 352, 8055, 17827, 1370, 272, 1415, 26, 3055, 272, 849, 26, 2656, 849, 26563, 523, 32093, 63, 7625, 26, 272, 1369, 26, 489, 446, 7494, 7377, 503, 11999, 370, 308, 8556, 314, 1318, 14, 221, 9498, 506, 376, 3000, 574, 315, 314, 1425, 446, 709, 370, 1616, 14, 221, 446, 709, 365, 11999, 597, 12, 1616, 365, 289, 32645, 14, 272, 1415, 26, 3055, 272, 849, 26, 378, 523, 1343, 63, 14990, 63, 515, 26, 272, 1369, 26, 489, 446, 16579, 931, 370, 282, 445, 13417, 19118, 9, 570, 3035, 282, 20453, 370, 5232, 2544, 314, 1318, 365, 25664, 917, 14, 221, 18491, 641, 406, 1769, 4882, 370, 10459, 1163, 308, 8556, 1192, 626, 3242, 965, 6020, 370, 14722, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 1284, 63, 14990, 63, 515, 26, 272, 1369, 26, 489, 446, 16579, 931, 370, 282, 445, 13417, 19118, 9, 570, 3035, 282, 20453, 370, 5232, 2410, 314, 1318, 965, 2757, 25664, 917, 14, 221, 18491, 641, 406, 1769, 4882, 370, 10459, 1163, 308, 8556, 1192, 626, 3242, 965, 9158, 308, 8556, 316, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 199, 2502, 26, 298, 42, 265, 869, 10084, 9246, 584, 273, 8593, 74, 2411, 87, 9246, 584, 273, 2924, 199, 5983, 26, 2043, 446, 29613, 308, 8556, 1192, 503, 4854, 838, 4548, 370, 886, 7003, 2997, 14, 2043, 446, 4005, 2342, 1314, 14164, 2370, 787, 4903, 12, 1255, 314, 2569, 7074, 5641, 1362, 2654, 13, 804, 446, 16489, 985, 6187, 14, 27047, 12736, 1362, 2672, 23660, 275, 7053, 13, 1692, 446, 23059, 6187, 14, 27047, 12736, 14, 17746, 14925, 14, 27047, 12736, 17746, 1589, 19158, 1362, 2672, 23660, 14, 1002, 21268, 23956, 2370, 342, 1204, 2104, 22321, 13, 1692, 469, 2672, 3754, 23956, 1885, 2354, 789, 1362, 2672, 23660, 14, 15613, 342, 2043, 446, 428, 321, 12736, 883, 506, 6296, 1359, 1044, 590, 11999, 12, 880, 2399, 5526, 370, 4215, 1245, 1318, 3974, 14, 199, 2344, 199, 199, 8918, 275, 519, 2344, 523, 327, 644, 1060, 402, 1742, 3219, 14295, 199, 13, 4747, 63, 19787, 26, 272, 1499, 26, 15902, 12, 14295, 2414, 1410, 4477, 315, 959, 9395, 12, 8749, 943, 734, 14, 523, 327, 11719, 282, 3365, 26563, 436, 282, 1343, 20453, 199, 13, 4747, 63, 19787, 26, 272, 1343, 63, 14990, 63, 515, 26, 445, 3427, 8647, 60, 11398, 60, 1098, 14, 19118, 272, 1499, 26, 15902, 12, 14295, 2414, 1410, 4477, 315, 959, 9395, 12, 8749, 943, 734, 14, 272, 26563, 26, 15332, 869, 4651, 352, 8055, 17827, 523, 327, 2893, 543, 1343, 436, 1284, 20453, 199, 13, 4747, 63, 19787, 26, 272, 1343, 63, 14990, 63, 515, 26, 445, 3427, 8647, 60, 11398, 60, 8647, 23928, 27734, 14, 19118, 272, 1499, 26, 7053, 2032, 4903, 272, 1284, 63, 14990, 63, 515, 26, 445, 3427, 8647, 60, 11398, 60, 335, 29778, 14, 19118, 523, 327, 1318, 687, 570, 2893, 199, 13, 4747, 63, 19787, 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, 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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 ]
2ndQuadrant/ansible
lib/ansible/modules/network/fortios/fortios_router_setting.py
21
7279
#!/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/>. # # the lib use python logging can get it if the following is set in your # Ansible config. __metaclass__ = type ANSIBLE_METADATA = {'status': ['preview'], 'supported_by': 'community', 'metadata_version': '1.1'} DOCUMENTATION = ''' --- module: fortios_router_setting short_description: Configure router settings in Fortinet's FortiOS and FortiGate. description: - This module is able to configure a FortiGate or FortiOS by allowing the user to set and modify router feature and setting category. Examples include all parameters and values need to be adjusted to datasources before usage. Tested with FOS v6.0.2 version_added: "2.8" 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. required: true username: description: - FortiOS or FortiGate username. required: true password: description: - FortiOS or FortiGate password. 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. default: root https: description: - Indicates if the requests towards FortiGate must use HTTPS protocol type: bool default: true router_setting: description: - Configure router settings. default: null suboptions: hostname: description: - Hostname for this virtual domain router. show-filter: description: - Prefix-list as filter for showing routes. Source router.prefix-list.name. ''' EXAMPLES = ''' - hosts: localhost vars: host: "192.168.122.40" username: "admin" password: "" vdom: "root" tasks: - name: Configure router settings. fortios_router_setting: host: "{{ host }}" username: "{{ username }}" password: "{{ password }}" vdom: "{{ vdom }}" https: "False" router_setting: hostname: "myhostname" show-filter: "<your_own_value> (source router.prefix-list.name)" ''' 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 fos = None def login(data): host = data['host'] username = data['username'] password = data['password'] fos.debug('on') if 'https' in data and not data['https']: fos.https('off') else: fos.https('on') fos.login(host, username, password) def filter_router_setting_data(json): option_list = ['hostname', 'show-filter'] dictionary = {} for attribute in option_list: if attribute in json and json[attribute] is not None: dictionary[attribute] = json[attribute] return dictionary def flatten_multilists_attributes(data): multilist_attrs = [] for attr in multilist_attrs: try: path = "data['" + "']['".join(elem for elem in attr) + "']" current_val = eval(path) flattened_val = ' '.join(elem for elem in current_val) exec(path + '= flattened_val') except BaseException: pass return data def router_setting(data, fos): vdom = data['vdom'] router_setting_data = data['router_setting'] flattened_data = flatten_multilists_attributes(router_setting_data) filtered_data = filter_router_setting_data(flattened_data) return fos.set('router', 'setting', data=filtered_data, vdom=vdom) def fortios_router(data, fos): login(data) if data['router_setting']: resp = router_setting(data, fos) fos.logout() return not resp['status'] == "success", resp['status'] == "success", resp def main(): fields = { "host": {"required": True, "type": "str"}, "username": {"required": True, "type": "str"}, "password": {"required": False, "type": "str", "no_log": True}, "vdom": {"required": False, "type": "str", "default": "root"}, "https": {"required": False, "type": "bool", "default": True}, "router_setting": { "required": False, "type": "dict", "options": { "hostname": {"required": False, "type": "str"}, "show-filter": {"required": False, "type": "str"} } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") global fos fos = FortiOSAPI() is_error, has_changed, result = fortios_router(module.params, fos) 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, 3, 199, 3, 314, 1973, 675, 2366, 2050, 883, 664, 652, 340, 314, 2569, 365, 663, 315, 2195, 199, 3, 2622, 1101, 14, 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, 4995, 63, 6031, 199, 3612, 63, 1802, 26, 15453, 6197, 2202, 315, 30205, 10811, 1159, 22913, 436, 20306, 14, 199, 1802, 26, 272, 446, 961, 859, 365, 7688, 370, 7908, 282, 20306, 503, 22913, 701, 17266, 314, 489, 922, 370, 663, 436, 2811, 6197, 3878, 436, 4260, 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, 18, 199, 1023, 63, 3270, 26, 298, 18, 14, 24, 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, 2126, 1369, 26, 288, 446, 22913, 503, 20306, 3384, 2287, 14, 2126, 1415, 26, 2549, 272, 3434, 26, 267, 1369, 26, 288, 446, 22913, 503, 20306, 3434, 14, 267, 1415, 26, 2549, 272, 2505, 26, 267, 1369, 26, 288, 446, 22913, 503, 20306, 2505, 14, 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, 849, 26, 1738, 272, 4178, 26, 267, 1369, 26, 288, 446, 19334, 340, 314, 4145, 28354, 20306, 1471, 675, 14147, 1598, 4113, 267, 730, 26, 2155, 267, 849, 26, 2549, 272, 6197, 63, 6031, 26, 267, 1369, 26, 288, 446, 15453, 6197, 2202, 14, 267, 849, 26, 2973, 267, 26265, 26, 288, 6246, 26, 355, 1369, 26, 490, 446, 10891, 354, 367, 642, 5791, 2881, 6197, 14, 288, 2498, 13, 1541, 26, 355, 1369, 26, 490, 446, 25110, 13, 513, 465, 2457, 367, 21207, 15777, 14, 5800, 6197, 14, 1861, 13, 513, 14, 354, 14, 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, 523, 6527, 26, 523, 446, 536, 26, 15453, 6197, 2202, 14, 272, 19516, 63, 4995, 63, 6031, 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, 6197, 63, 6031, 26, 267, 6246, 26, 298, 1662, 4269, 2, 267, 2498, 13, 1541, 26, 3886, 12695, 63, 944, 63, 585, 30, 334, 1365, 6197, 14, 1861, 13, 513, 14, 354, 2924, 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, 523, 1369, 26, 15237, 1083, 1202, 370, 15408, 314, 1564, 1901, 20306, 523, 2138, 26, 3544, 523, 730, 26, 620, 523, 2690, 26, 283, 4013, 7, 199, 1014, 63, 1205, 26, 523, 1369, 26, 15237, 754, 1627, 701, 20306, 641, 2061, 3439, 6781, 523, 2138, 26, 3544, 523, 730, 26, 620, 523, 2690, 26, 298, 1840, 2, 199, 77, 498, 26, 523, 1369, 26, 26728, 790, 334, 344, 9, 1202, 315, 314, 2061, 1240, 370, 20306, 523, 2138, 26, 3182, 523, 730, 26, 620, 523, 2690, 26, 298, 344, 2, 199, 354, 26, 523, 1369, 26, 2812, 402, 314, 1817, 1202, 370, 15632, 22503, 314, 1056, 523, 2138, 26, 3544, 523, 730, 26, 620, 523, 2690, 26, 298, 300, 276, 3518, 2, 199, 515, 26, 523, 1369, 26, 6912, 402, 314, 1817, 1202, 370, 15632, 22503, 314, 1056, 523, 2138, 26, 3544, 523, 730, 26, 620, 523, 2690, 26, 298, 2520, 1541, 2, 199, 5792, 26, 523, 1369, 26, 12624, 6974, 1329, 523, 2138, 26, 3544, 523, 730, 26, 620, 523, 2690, 26, 298, 1196, 14, 16, 14, 18, 14, 7357, 2010, 2, 199, 2171, 26, 523, 1369, 26, 11973, 1329, 402, 314, 4137, 523, 2138, 26, 3544, 523, 730, 26, 620, 523, 2690, 26, 298, 38, 14876, 3635, 54, 7080, 19229, 19, 1217, 7920, 18, 2, 199, 1205, 26, 523, 1369, 26, 1010, 21171, 402, 314, 3439, 1159, 754, 523, 2138, 26, 3544, 523, 730, 26, 620, 523, 2690, 26, 298, 3742, 2, 199, 23779, 26, 523, 1369, 26, 13311 ]
[ 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, 3, 199, 3, 314, 1973, 675, 2366, 2050, 883, 664, 652, 340, 314, 2569, 365, 663, 315, 2195, 199, 3, 2622, 1101, 14, 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, 4995, 63, 6031, 199, 3612, 63, 1802, 26, 15453, 6197, 2202, 315, 30205, 10811, 1159, 22913, 436, 20306, 14, 199, 1802, 26, 272, 446, 961, 859, 365, 7688, 370, 7908, 282, 20306, 503, 22913, 701, 17266, 314, 489, 922, 370, 663, 436, 2811, 6197, 3878, 436, 4260, 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, 18, 199, 1023, 63, 3270, 26, 298, 18, 14, 24, 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, 2126, 1369, 26, 288, 446, 22913, 503, 20306, 3384, 2287, 14, 2126, 1415, 26, 2549, 272, 3434, 26, 267, 1369, 26, 288, 446, 22913, 503, 20306, 3434, 14, 267, 1415, 26, 2549, 272, 2505, 26, 267, 1369, 26, 288, 446, 22913, 503, 20306, 2505, 14, 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, 849, 26, 1738, 272, 4178, 26, 267, 1369, 26, 288, 446, 19334, 340, 314, 4145, 28354, 20306, 1471, 675, 14147, 1598, 4113, 267, 730, 26, 2155, 267, 849, 26, 2549, 272, 6197, 63, 6031, 26, 267, 1369, 26, 288, 446, 15453, 6197, 2202, 14, 267, 849, 26, 2973, 267, 26265, 26, 288, 6246, 26, 355, 1369, 26, 490, 446, 10891, 354, 367, 642, 5791, 2881, 6197, 14, 288, 2498, 13, 1541, 26, 355, 1369, 26, 490, 446, 25110, 13, 513, 465, 2457, 367, 21207, 15777, 14, 5800, 6197, 14, 1861, 13, 513, 14, 354, 14, 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, 523, 6527, 26, 523, 446, 536, 26, 15453, 6197, 2202, 14, 272, 19516, 63, 4995, 63, 6031, 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, 6197, 63, 6031, 26, 267, 6246, 26, 298, 1662, 4269, 2, 267, 2498, 13, 1541, 26, 3886, 12695, 63, 944, 63, 585, 30, 334, 1365, 6197, 14, 1861, 13, 513, 14, 354, 2924, 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, 523, 1369, 26, 15237, 1083, 1202, 370, 15408, 314, 1564, 1901, 20306, 523, 2138, 26, 3544, 523, 730, 26, 620, 523, 2690, 26, 283, 4013, 7, 199, 1014, 63, 1205, 26, 523, 1369, 26, 15237, 754, 1627, 701, 20306, 641, 2061, 3439, 6781, 523, 2138, 26, 3544, 523, 730, 26, 620, 523, 2690, 26, 298, 1840, 2, 199, 77, 498, 26, 523, 1369, 26, 26728, 790, 334, 344, 9, 1202, 315, 314, 2061, 1240, 370, 20306, 523, 2138, 26, 3182, 523, 730, 26, 620, 523, 2690, 26, 298, 344, 2, 199, 354, 26, 523, 1369, 26, 2812, 402, 314, 1817, 1202, 370, 15632, 22503, 314, 1056, 523, 2138, 26, 3544, 523, 730, 26, 620, 523, 2690, 26, 298, 300, 276, 3518, 2, 199, 515, 26, 523, 1369, 26, 6912, 402, 314, 1817, 1202, 370, 15632, 22503, 314, 1056, 523, 2138, 26, 3544, 523, 730, 26, 620, 523, 2690, 26, 298, 2520, 1541, 2, 199, 5792, 26, 523, 1369, 26, 12624, 6974, 1329, 523, 2138, 26, 3544, 523, 730, 26, 620, 523, 2690, 26, 298, 1196, 14, 16, 14, 18, 14, 7357, 2010, 2, 199, 2171, 26, 523, 1369, 26, 11973, 1329, 402, 314, 4137, 523, 2138, 26, 3544, 523, 730, 26, 620, 523, 2690, 26, 298, 38, 14876, 3635, 54, 7080, 19229, 19, 1217, 7920, 18, 2, 199, 1205, 26, 523, 1369, 26, 1010, 21171, 402, 314, 3439, 1159, 754, 523, 2138, 26, 3544, 523, 730, 26, 620, 523, 2690, 26, 298, 3742, 2, 199, 23779, 26, 523, 1369, 26, 13311, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ujjwalwahi/odoo
addons/account/wizard/__init__.py
362
2345
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import account_report_common import account_report_common_partner import account_report_common_journal import account_report_common_account import account_automatic_reconcile import account_move_line_reconcile_select import account_move_line_unreconcile_select import account_reconcile_partner_process import account_reconcile import account_unreconcile import account_invoice_refund import account_journal_select import account_move_bank_reconcile import account_subscription_generate import account_report_aged_partner_balance import account_report_partner_ledger import account_report_partner_balance import account_period_close import account_fiscalyear_close import account_fiscalyear_close_state import account_vat import account_open_closed_fiscalyear import account_invoice_state import account_chart import account_tax_chart import account_financial_report #TODO: remove this file no moe used # also remove related view fiel import account_validate_account_move import account_use_model import account_state_open import account_report_print_journal import account_report_central_journal import account_report_general_journal import account_report_general_ledger import account_report_account_balance import account_change_currency import pos_box import account_statement_from_invoice # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 2933, 63, 3070, 63, 2330, 199, 646, 2933, 63, 3070, 63, 2330, 63, 3899, 199, 646, 2933, 63, 3070, 63, 2330, 63, 7067, 199, 646, 2933, 63, 3070, 63, 2330, 63, 2048, 199, 199, 646, 2933, 63, 23292, 63, 18403, 199, 646, 2933, 63, 1185, 63, 604, 63, 18403, 63, 2416, 199, 646, 2933, 63, 1185, 63, 604, 63, 324, 18403, 63, 2416, 199, 646, 2933, 63, 18403, 63, 3899, 63, 1412, 199, 646, 2933, 63, 18403, 199, 646, 2933, 63, 324, 18403, 199, 646, 2933, 63, 5404, 63, 18440, 199, 646, 2933, 63, 7067, 63, 2416, 199, 646, 2933, 63, 1185, 63, 9860, 63, 18403, 199, 646, 2933, 63, 6645, 63, 4208, 199, 646, 2933, 63, 3070, 63, 6028, 63, 3899, 63, 7358, 199, 646, 2933, 63, 3070, 63, 3899, 63, 28771, 199, 646, 2933, 63, 3070, 63, 3899, 63, 7358, 199, 646, 2933, 63, 5191, 63, 1600, 199, 646, 2933, 63, 21260, 63, 1600, 199, 646, 2933, 63, 21260, 63, 1600, 63, 929, 199, 646, 2933, 63, 16305, 199, 646, 2933, 63, 1490, 63, 5938, 63, 21260, 199, 199, 646, 2933, 63, 5404, 63, 929, 199, 646, 2933, 63, 9019, 199, 646, 2933, 63, 5530, 63, 9019, 199, 646, 2933, 63, 2408, 24409, 63, 3070, 199, 3, 11768, 26, 2813, 642, 570, 949, 1303, 69, 1202, 199, 3, 2597, 2813, 4048, 2455, 5883, 352, 199, 199, 646, 2933, 63, 3502, 63, 2048, 63, 1185, 199, 646, 2933, 63, 1180, 63, 1238, 199, 199, 646, 2933, 63, 929, 63, 1490, 199, 199, 646, 2933, 63, 3070, 63, 1361, 63, 7067, 199, 646, 2933, 63, 3070, 63, 16067, 63, 7067, 199, 646, 2933, 63, 3070, 63, 10706, 63, 7067, 199, 646, 2933, 63, 3070, 63, 10706, 63, 28771, 199, 646, 2933, 63, 3070, 63, 2048, 63, 7358, 199, 199, 646, 2933, 63, 1461, 63, 4968, 199, 199, 646, 2086, 63, 1977, 199, 646, 2933, 63, 6242, 63, 504, 63, 5404, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 2933, 63, 3070, 63, 2330, 199, 646, 2933, 63, 3070, 63, 2330, 63, 3899, 199, 646, 2933, 63, 3070, 63, 2330, 63, 7067, 199, 646, 2933, 63, 3070, 63, 2330, 63, 2048, 199, 199, 646, 2933, 63, 23292, 63, 18403, 199, 646, 2933, 63, 1185, 63, 604, 63, 18403, 63, 2416, 199, 646, 2933, 63, 1185, 63, 604, 63, 324, 18403, 63, 2416, 199, 646, 2933, 63, 18403, 63, 3899, 63, 1412, 199, 646, 2933, 63, 18403, 199, 646, 2933, 63, 324, 18403, 199, 646, 2933, 63, 5404, 63, 18440, 199, 646, 2933, 63, 7067, 63, 2416, 199, 646, 2933, 63, 1185, 63, 9860, 63, 18403, 199, 646, 2933, 63, 6645, 63, 4208, 199, 646, 2933, 63, 3070, 63, 6028, 63, 3899, 63, 7358, 199, 646, 2933, 63, 3070, 63, 3899, 63, 28771, 199, 646, 2933, 63, 3070, 63, 3899, 63, 7358, 199, 646, 2933, 63, 5191, 63, 1600, 199, 646, 2933, 63, 21260, 63, 1600, 199, 646, 2933, 63, 21260, 63, 1600, 63, 929, 199, 646, 2933, 63, 16305, 199, 646, 2933, 63, 1490, 63, 5938, 63, 21260, 199, 199, 646, 2933, 63, 5404, 63, 929, 199, 646, 2933, 63, 9019, 199, 646, 2933, 63, 5530, 63, 9019, 199, 646, 2933, 63, 2408, 24409, 63, 3070, 199, 3, 11768, 26, 2813, 642, 570, 949, 1303, 69, 1202, 199, 3, 2597, 2813, 4048, 2455, 5883, 352, 199, 199, 646, 2933, 63, 3502, 63, 2048, 63, 1185, 199, 646, 2933, 63, 1180, 63, 1238, 199, 199, 646, 2933, 63, 929, 63, 1490, 199, 199, 646, 2933, 63, 3070, 63, 1361, 63, 7067, 199, 646, 2933, 63, 3070, 63, 16067, 63, 7067, 199, 646, 2933, 63, 3070, 63, 10706, 63, 7067, 199, 646, 2933, 63, 3070, 63, 10706, 63, 28771, 199, 646, 2933, 63, 3070, 63, 2048, 63, 7358, 199, 199, 646, 2933, 63, 1461, 63, 4968, 199, 199, 646, 2086, 63, 1977, 199, 646, 2933, 63, 6242, 63, 504, 63, 5404, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
redhat-openstack/trove
trove/tests/util/client.py
8
3744
# Copyright (c) 2011 OpenStack Foundation # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """ :mod:`tests` -- Utility methods for tests. =================================== .. automodule:: utils :platform: Unix :synopsis: Tests for Nova. """ from proboscis import asserts from trove.tests.config import CONFIG def add_report_event_to(home, name): """Takes a module, class, etc, and an attribute name to decorate.""" func = getattr(home, name) def __cb(*args, **kwargs): # While %s turns a var into a string but in some rare cases explicit # str() is less likely to raise an exception. arg_strs = [repr(arg) for arg in args] arg_strs += ['%s=%s' % (repr(key), repr(value)) for (key, value) in kwargs.items()] CONFIG.get_reporter().log("[RDC] Calling : %s(%s)..." % (name, ','.join(arg_strs))) value = func(*args, **kwargs) CONFIG.get_reporter.log("[RDC] returned %s." % str(value)) return value setattr(home, name, __cb) class TestClient(object): """Decorates the rich clients with some extra methods. These methods are filled with test asserts, meaning if you use this you get the tests for free. """ def __init__(self, real_client): """Accepts a normal client.""" self.real_client = real_client def assert_http_code(self, expected_http_code): resp, body = self.real_client.client.last_response asserts.assert_equal(resp.status, expected_http_code) @property def last_http_code(self): resp, body = self.real_client.client.last_response return resp.status @staticmethod def find_flavor_self_href(flavor): self_links = [link for link in flavor.links if link['rel'] == 'self'] asserts.assert_true(len(self_links) > 0, "Flavor had no self href!") flavor_href = self_links[0]['href'] asserts.assert_false(flavor_href is None, "Flavor link self href missing.") return flavor_href def find_flavors_by(self, condition, flavor_manager=None): flavor_manager = flavor_manager or self.flavors flavors = flavor_manager.list() return [flavor for flavor in flavors if condition(flavor)] def find_flavors_by_name(self, name, flavor_manager=None): return self.find_flavors_by(lambda flavor: flavor.name == name, flavor_manager) def find_flavors_by_ram(self, ram, flavor_manager=None): return self.find_flavors_by(lambda flavor: flavor.ram == ram, flavor_manager) def find_flavor_and_self_href(self, flavor_id, flavor_manager=None): """Given an ID, returns flavor and its self href.""" flavor_manager = flavor_manager or self.flavors asserts.assert_false(flavor_id is None) flavor = flavor_manager.get(flavor_id) asserts.assert_false(flavor is None) flavor_href = self.find_flavor_self_href(flavor) return flavor, flavor_href def __getattr__(self, item): return getattr(self.real_client, item)
apache-2.0
[ 3, 1898, 334, 67, 9, 7760, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 199, 26, 1494, 1705, 2219, 64, 1553, 20511, 3102, 367, 2295, 14, 199, 2486, 5918, 199, 199, 703, 2599, 578, 447, 3778, 2043, 520, 3246, 26, 13074, 2043, 520, 9466, 27573, 26, 6496, 367, 28184, 14, 199, 624, 421, 199, 504, 557, 656, 551, 374, 492, 702, 83, 199, 199, 504, 307, 11750, 14, 2219, 14, 888, 492, 15869, 421, 199, 318, 1050, 63, 3070, 63, 1430, 63, 475, 8, 4219, 12, 536, 304, 272, 408, 32488, 282, 859, 12, 1021, 12, 5423, 12, 436, 376, 2225, 536, 370, 24774, 1041, 272, 2562, 275, 2519, 8, 4219, 12, 536, 9, 339, 347, 636, 2894, 2031, 589, 12, 1011, 958, 304, 267, 327, 22117, 450, 83, 25449, 282, 2729, 1901, 282, 1059, 1325, 315, 2005, 24063, 5560, 5027, 267, 327, 620, 342, 365, 6656, 12060, 370, 746, 376, 1919, 14, 267, 1680, 63, 16144, 275, 359, 2722, 8, 1273, 9, 367, 1680, 315, 1249, 61, 267, 1680, 63, 16144, 847, 15926, 83, 2458, 83, 7, 450, 334, 2722, 8, 498, 395, 4700, 8, 585, 430, 2151, 367, 334, 498, 12, 574, 9, 315, 2074, 14, 1744, 5106, 267, 15869, 14, 362, 63, 12222, 1252, 793, 10994, 50, 5196, 61, 23892, 520, 450, 83, 4042, 83, 680, 703, 2, 3303, 450, 334, 354, 12, 12814, 904, 8, 1273, 63, 16144, 1724, 267, 574, 275, 2562, 2031, 589, 12, 1011, 958, 9, 267, 15869, 14, 362, 63, 12222, 14, 793, 10994, 50, 5196, 61, 258, 2138, 450, 83, 2122, 450, 620, 8, 585, 430, 267, 372, 574, 272, 5371, 8, 4219, 12, 536, 12, 636, 2894, 9, 421, 199, 533, 1379, 3041, 8, 785, 304, 272, 408, 8584, 269, 2335, 314, 30162, 13431, 543, 2005, 2402, 3102, 14, 339, 5723, 3102, 787, 13457, 543, 511, 702, 83, 12, 11150, 340, 1265, 675, 642, 1265, 272, 664, 314, 2295, 367, 2867, 14, 339, 408, 339, 347, 636, 826, 721, 277, 12, 3363, 63, 1258, 304, 267, 408, 8422, 83, 282, 3293, 1890, 1041, 267, 291, 14, 3093, 63, 1258, 275, 3363, 63, 1258, 339, 347, 702, 63, 1014, 63, 600, 8, 277, 12, 1420, 63, 1014, 63, 600, 304, 267, 3085, 12, 2396, 275, 291, 14, 3093, 63, 1258, 14, 1258, 14, 2019, 63, 1310, 267, 702, 83, 14, 479, 63, 1452, 8, 4518, 14, 1205, 12, 1420, 63, 1014, 63, 600, 9, 339, 768, 1829, 272, 347, 2061, 63, 1014, 63, 600, 8, 277, 304, 267, 3085, 12, 2396, 275, 291, 14, 3093, 63, 1258, 14, 1258, 14, 2019, 63, 1310, 267, 372, 3085, 14, 1205, 339, 768, 4639, 272, 347, 2342, 63, 6081, 63, 277, 63, 6399, 8, 6081, 304, 267, 291, 63, 4614, 275, 359, 1073, 367, 2142, 315, 8541, 14, 4614, 340, 2142, 459, 3369, 418, 508, 283, 277, 418, 267, 702, 83, 14, 479, 63, 2052, 8, 552, 8, 277, 63, 4614, 9, 690, 378, 12, 298, 16739, 10530, 949, 291, 4369, 9124, 267, 8541, 63, 6399, 275, 291, 63, 4614, 59, 16, 2733, 6399, 418, 267, 702, 83, 14, 479, 63, 3910, 8, 6081, 63, 6399, 365, 488, 12, 2490, 298, 16739, 2142, 291, 4369, 4124, 2685, 267, 372, 8541, 63, 6399, 339, 347, 2342, 63, 18664, 63, 991, 8, 277, 12, 5558, 12, 8541, 63, 2609, 29, 403, 304, 267, 8541, 63, 2609, 275, 8541, 63, 2609, 503, 291, 14, 18664, 267, 23547, 275, 8541, 63, 2609, 14, 513, 342, 267, 372, 359, 6081, 367, 8541, 315, 23547, 340, 5558, 8, 6081, 1874, 339, 347, 2342, 63, 18664, 63, 991, 63, 354, 8, 277, 12, 536, 12, 8541, 63, 2609, 29, 403, 304, 267, 372, 291, 14, 1623, 63, 18664, 63, 991, 8, 2734, 8541, 26, 8541, 14, 354, 508, 536, 12, 2511, 8541, 63, 2609, 9, 339, 347, 2342, 63, 18664, 63, 991, 63, 5975, 8, 277, 12, 21394, 12, 8541, 63, 2609, 29, 403, 304, 267, 372, 291, 14, 1623, 63, 18664, 63, 991, 8, 2734, 8541, 26, 8541, 14, 5975, 508, 21394, 12, 2511, 8541, 63, 2609, 9, 339, 347, 2342, 63, 6081, 63, 460, 63, 277, 63, 6399, 8, 277, 12, 8541, 63, 344, 12, 8541, 63, 2609, 29, 403, 304, 267, 408, 13735, 376, 2870, 12, 2529, 8541, 436, 2399, 291, 4369, 1041, 267, 8541, 63, 2609, 275, 8541, 63, 2609, 503, 291, 14, 18664, 267, 702, 83, 14, 479, 63, 3910, 8, 6081, 63, 344, 365, 488, 9, 267, 8541, 275, 8541, 63, 2609, 14, 362, 8, 6081, 63, 344, 9, 267, 702, 83, 14, 479, 63, 3910, 8, 6081, 365, 488, 9, 267, 8541, 63, 6399, 275, 291, 14, 1623, 63, 6081, 63, 277, 63, 6399, 8, 6081, 9, 267, 372, 8541, 12, 8541, 63, 6399, 339, 347, 636, 5675, 721, 277, 12, 1242, 304, 267, 372, 2519, 8, 277, 14, 3093, 63, 1258, 12, 1242, 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 ]
[ 1898, 334, 67, 9, 7760, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 199, 26, 1494, 1705, 2219, 64, 1553, 20511, 3102, 367, 2295, 14, 199, 2486, 5918, 199, 199, 703, 2599, 578, 447, 3778, 2043, 520, 3246, 26, 13074, 2043, 520, 9466, 27573, 26, 6496, 367, 28184, 14, 199, 624, 421, 199, 504, 557, 656, 551, 374, 492, 702, 83, 199, 199, 504, 307, 11750, 14, 2219, 14, 888, 492, 15869, 421, 199, 318, 1050, 63, 3070, 63, 1430, 63, 475, 8, 4219, 12, 536, 304, 272, 408, 32488, 282, 859, 12, 1021, 12, 5423, 12, 436, 376, 2225, 536, 370, 24774, 1041, 272, 2562, 275, 2519, 8, 4219, 12, 536, 9, 339, 347, 636, 2894, 2031, 589, 12, 1011, 958, 304, 267, 327, 22117, 450, 83, 25449, 282, 2729, 1901, 282, 1059, 1325, 315, 2005, 24063, 5560, 5027, 267, 327, 620, 342, 365, 6656, 12060, 370, 746, 376, 1919, 14, 267, 1680, 63, 16144, 275, 359, 2722, 8, 1273, 9, 367, 1680, 315, 1249, 61, 267, 1680, 63, 16144, 847, 15926, 83, 2458, 83, 7, 450, 334, 2722, 8, 498, 395, 4700, 8, 585, 430, 2151, 367, 334, 498, 12, 574, 9, 315, 2074, 14, 1744, 5106, 267, 15869, 14, 362, 63, 12222, 1252, 793, 10994, 50, 5196, 61, 23892, 520, 450, 83, 4042, 83, 680, 703, 2, 3303, 450, 334, 354, 12, 12814, 904, 8, 1273, 63, 16144, 1724, 267, 574, 275, 2562, 2031, 589, 12, 1011, 958, 9, 267, 15869, 14, 362, 63, 12222, 14, 793, 10994, 50, 5196, 61, 258, 2138, 450, 83, 2122, 450, 620, 8, 585, 430, 267, 372, 574, 272, 5371, 8, 4219, 12, 536, 12, 636, 2894, 9, 421, 199, 533, 1379, 3041, 8, 785, 304, 272, 408, 8584, 269, 2335, 314, 30162, 13431, 543, 2005, 2402, 3102, 14, 339, 5723, 3102, 787, 13457, 543, 511, 702, 83, 12, 11150, 340, 1265, 675, 642, 1265, 272, 664, 314, 2295, 367, 2867, 14, 339, 408, 339, 347, 636, 826, 721, 277, 12, 3363, 63, 1258, 304, 267, 408, 8422, 83, 282, 3293, 1890, 1041, 267, 291, 14, 3093, 63, 1258, 275, 3363, 63, 1258, 339, 347, 702, 63, 1014, 63, 600, 8, 277, 12, 1420, 63, 1014, 63, 600, 304, 267, 3085, 12, 2396, 275, 291, 14, 3093, 63, 1258, 14, 1258, 14, 2019, 63, 1310, 267, 702, 83, 14, 479, 63, 1452, 8, 4518, 14, 1205, 12, 1420, 63, 1014, 63, 600, 9, 339, 768, 1829, 272, 347, 2061, 63, 1014, 63, 600, 8, 277, 304, 267, 3085, 12, 2396, 275, 291, 14, 3093, 63, 1258, 14, 1258, 14, 2019, 63, 1310, 267, 372, 3085, 14, 1205, 339, 768, 4639, 272, 347, 2342, 63, 6081, 63, 277, 63, 6399, 8, 6081, 304, 267, 291, 63, 4614, 275, 359, 1073, 367, 2142, 315, 8541, 14, 4614, 340, 2142, 459, 3369, 418, 508, 283, 277, 418, 267, 702, 83, 14, 479, 63, 2052, 8, 552, 8, 277, 63, 4614, 9, 690, 378, 12, 298, 16739, 10530, 949, 291, 4369, 9124, 267, 8541, 63, 6399, 275, 291, 63, 4614, 59, 16, 2733, 6399, 418, 267, 702, 83, 14, 479, 63, 3910, 8, 6081, 63, 6399, 365, 488, 12, 2490, 298, 16739, 2142, 291, 4369, 4124, 2685, 267, 372, 8541, 63, 6399, 339, 347, 2342, 63, 18664, 63, 991, 8, 277, 12, 5558, 12, 8541, 63, 2609, 29, 403, 304, 267, 8541, 63, 2609, 275, 8541, 63, 2609, 503, 291, 14, 18664, 267, 23547, 275, 8541, 63, 2609, 14, 513, 342, 267, 372, 359, 6081, 367, 8541, 315, 23547, 340, 5558, 8, 6081, 1874, 339, 347, 2342, 63, 18664, 63, 991, 63, 354, 8, 277, 12, 536, 12, 8541, 63, 2609, 29, 403, 304, 267, 372, 291, 14, 1623, 63, 18664, 63, 991, 8, 2734, 8541, 26, 8541, 14, 354, 508, 536, 12, 2511, 8541, 63, 2609, 9, 339, 347, 2342, 63, 18664, 63, 991, 63, 5975, 8, 277, 12, 21394, 12, 8541, 63, 2609, 29, 403, 304, 267, 372, 291, 14, 1623, 63, 18664, 63, 991, 8, 2734, 8541, 26, 8541, 14, 5975, 508, 21394, 12, 2511, 8541, 63, 2609, 9, 339, 347, 2342, 63, 6081, 63, 460, 63, 277, 63, 6399, 8, 277, 12, 8541, 63, 344, 12, 8541, 63, 2609, 29, 403, 304, 267, 408, 13735, 376, 2870, 12, 2529, 8541, 436, 2399, 291, 4369, 1041, 267, 8541, 63, 2609, 275, 8541, 63, 2609, 503, 291, 14, 18664, 267, 702, 83, 14, 479, 63, 3910, 8, 6081, 63, 344, 365, 488, 9, 267, 8541, 275, 8541, 63, 2609, 14, 362, 8, 6081, 63, 344, 9, 267, 702, 83, 14, 479, 63, 3910, 8, 6081, 365, 488, 9, 267, 8541, 63, 6399, 275, 291, 14, 1623, 63, 6081, 63, 277, 63, 6399, 8, 6081, 9, 267, 372, 8541, 12, 8541, 63, 6399, 339, 347, 636, 5675, 721, 277, 12, 1242, 304, 267, 372, 2519, 8, 277, 14, 3093, 63, 1258, 12, 1242, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
soerendip42/rdkit
Contrib/LEF/ClusterFps.py
4
2857
# # Copyright (c) 2009, Novartis Institutes for BioMedical Research 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 Novartis Institutes for BioMedical Research 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. # # Created by Greg Landrum and Anna Vulpetti, March 2009 from __future__ import print_function from rdkit.ML.Cluster import Butina from rdkit import DataStructs import sys,cPickle # sims is the list of similarity thresholds used to generate clusters sims=[.9,.8,.7,.6] smis=[] uniq=[] uFps=[] for fileN in sys.argv[1:]: inF = file(sys.argv[1],'r') cols = cPickle.load(inF) fps = cPickle.load(inF) for row in fps: nm,smi,fp = row[:3] if smi not in smis: try: fpIdx = uFps.index(fp) except ValueError: fpIdx=len(uFps) uFps.append(fp) uniq.append([fp,nm,smi,'FP_%d'%fpIdx]+row[3:]) smis.append(smi) def distFunc(a,b): return 1.-DataStructs.DiceSimilarity(a[0],b[0]) for sim in sims: clusters=Butina.ClusterData(uniq,len(uniq),1.-sim,False,distFunc) print('Sim: %.2f, nClusters: %d'%(sim,len(clusters)), file=sys.stderr) for i,cluster in enumerate(clusters): for pt in cluster: uniq[pt].append(str(i+1)) cols.append('cluster_thresh_%d'%(int(100*sim))) print(' '.join(cols)) for row in uniq: print(' '.join(row[1:]))
bsd-3-clause
[ 3, 199, 3, 221, 1898, 334, 67, 9, 8937, 12, 3091, 1391, 16753, 1010, 6329, 3862, 367, 699, 2308, 1352, 328, 915, 26993, 3277, 14, 199, 3, 221, 2900, 4481, 4644, 14, 199, 3, 221, 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, 221, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 221, 199, 3, 755, 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, 755, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 221, 199, 3, 755, 6450, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 221, 199, 3, 755, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 3091, 1391, 16753, 1010, 6329, 3862, 367, 699, 2308, 1352, 328, 915, 26993, 3277, 14, 221, 199, 3, 755, 6590, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 221, 199, 3, 755, 7585, 7131, 687, 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, 18208, 701, 29096, 491, 460, 28430, 436, 1626, 3540, 812, 348, 8096, 280, 12, 603, 1047, 8937, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 11517, 6065, 14, 1698, 14, 9581, 492, 11017, 13765, 199, 504, 11517, 6065, 492, 3918, 4836, 83, 199, 646, 984, 12, 67, 12755, 199, 199, 3, 308, 11171, 365, 314, 769, 402, 22838, 22757, 1202, 370, 3550, 13865, 199, 338, 706, 1524, 14, 25, 18485, 24, 18485, 23, 18485, 22, 61, 199, 83, 1292, 9811, 199, 22484, 9811, 199, 19872, 1190, 9811, 9948, 199, 509, 570, 46, 315, 984, 14, 3020, 59, 17, 10688, 272, 315, 38, 275, 570, 8, 1274, 14, 3020, 59, 17, 26801, 82, 358, 272, 8850, 275, 17572, 14, 912, 8, 262, 38, 9, 272, 289, 1190, 275, 17572, 14, 912, 8, 262, 38, 9, 339, 367, 1962, 315, 289, 1190, 26, 267, 16751, 12, 83, 2664, 12, 3997, 275, 1962, 1491, 19, 61, 267, 340, 308, 2664, 440, 315, 308, 1292, 26, 288, 862, 26, 355, 4090, 12215, 275, 399, 38, 1190, 14, 1080, 8, 3997, 9, 288, 871, 1722, 26, 355, 4090, 12215, 29, 552, 8, 19872, 1190, 9, 355, 399, 38, 1190, 14, 740, 8, 3997, 9, 288, 625, 9962, 14, 740, 779, 3997, 12, 10756, 12, 83, 2664, 2584, 17095, 4970, 68, 5956, 3997, 12215, 2807, 1143, 59, 19, 5728, 288, 308, 1292, 14, 740, 8, 83, 2664, 9, 1467, 199, 199, 318, 2917, 7465, 8, 65, 12, 66, 304, 272, 372, 413, 23683, 1451, 4836, 83, 14, 1341, 301, 7467, 13093, 8, 65, 59, 16, 467, 66, 59, 16, 566, 199, 199, 509, 4389, 315, 308, 11171, 26, 272, 13865, 29, 28543, 13765, 14, 9581, 1451, 8, 22484, 12, 552, 8, 22484, 395, 17, 23683, 5206, 12, 797, 12, 2686, 7465, 9, 272, 870, 360, 7467, 26, 10536, 18, 70, 12, 302, 1968, 6811, 26, 450, 68, 13328, 5206, 12, 552, 8, 9170, 1826, 570, 29, 1274, 14, 3083, 9, 272, 367, 284, 12, 4201, 315, 3874, 8, 9170, 304, 267, 367, 10063, 315, 4350, 26, 288, 625, 9962, 59, 541, 1055, 740, 8, 495, 8, 73, 11, 17, 430, 272, 8850, 14, 740, 360, 4201, 63, 14898, 4970, 68, 13328, 442, 8, 1960, 10, 5206, 1724, 199, 1361, 360, 1987, 904, 8, 4574, 430, 199, 509, 1962, 315, 625, 9962, 26, 272, 870, 360, 1987, 904, 8, 1143, 59, 17, 16720, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 221, 1898, 334, 67, 9, 8937, 12, 3091, 1391, 16753, 1010, 6329, 3862, 367, 699, 2308, 1352, 328, 915, 26993, 3277, 14, 199, 3, 221, 2900, 4481, 4644, 14, 199, 3, 221, 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, 221, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 221, 199, 3, 755, 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, 755, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 221, 199, 3, 755, 6450, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 221, 199, 3, 755, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 3091, 1391, 16753, 1010, 6329, 3862, 367, 699, 2308, 1352, 328, 915, 26993, 3277, 14, 221, 199, 3, 755, 6590, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 221, 199, 3, 755, 7585, 7131, 687, 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, 18208, 701, 29096, 491, 460, 28430, 436, 1626, 3540, 812, 348, 8096, 280, 12, 603, 1047, 8937, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 11517, 6065, 14, 1698, 14, 9581, 492, 11017, 13765, 199, 504, 11517, 6065, 492, 3918, 4836, 83, 199, 646, 984, 12, 67, 12755, 199, 199, 3, 308, 11171, 365, 314, 769, 402, 22838, 22757, 1202, 370, 3550, 13865, 199, 338, 706, 1524, 14, 25, 18485, 24, 18485, 23, 18485, 22, 61, 199, 83, 1292, 9811, 199, 22484, 9811, 199, 19872, 1190, 9811, 9948, 199, 509, 570, 46, 315, 984, 14, 3020, 59, 17, 10688, 272, 315, 38, 275, 570, 8, 1274, 14, 3020, 59, 17, 26801, 82, 358, 272, 8850, 275, 17572, 14, 912, 8, 262, 38, 9, 272, 289, 1190, 275, 17572, 14, 912, 8, 262, 38, 9, 339, 367, 1962, 315, 289, 1190, 26, 267, 16751, 12, 83, 2664, 12, 3997, 275, 1962, 1491, 19, 61, 267, 340, 308, 2664, 440, 315, 308, 1292, 26, 288, 862, 26, 355, 4090, 12215, 275, 399, 38, 1190, 14, 1080, 8, 3997, 9, 288, 871, 1722, 26, 355, 4090, 12215, 29, 552, 8, 19872, 1190, 9, 355, 399, 38, 1190, 14, 740, 8, 3997, 9, 288, 625, 9962, 14, 740, 779, 3997, 12, 10756, 12, 83, 2664, 2584, 17095, 4970, 68, 5956, 3997, 12215, 2807, 1143, 59, 19, 5728, 288, 308, 1292, 14, 740, 8, 83, 2664, 9, 1467, 199, 199, 318, 2917, 7465, 8, 65, 12, 66, 304, 272, 372, 413, 23683, 1451, 4836, 83, 14, 1341, 301, 7467, 13093, 8, 65, 59, 16, 467, 66, 59, 16, 566, 199, 199, 509, 4389, 315, 308, 11171, 26, 272, 13865, 29, 28543, 13765, 14, 9581, 1451, 8, 22484, 12, 552, 8, 22484, 395, 17, 23683, 5206, 12, 797, 12, 2686, 7465, 9, 272, 870, 360, 7467, 26, 10536, 18, 70, 12, 302, 1968, 6811, 26, 450, 68, 13328, 5206, 12, 552, 8, 9170, 1826, 570, 29, 1274, 14, 3083, 9, 272, 367, 284, 12, 4201, 315, 3874, 8, 9170, 304, 267, 367, 10063, 315, 4350, 26, 288, 625, 9962, 59, 541, 1055, 740, 8, 495, 8, 73, 11, 17, 430, 272, 8850, 14, 740, 360, 4201, 63, 14898, 4970, 68, 13328, 442, 8, 1960, 10, 5206, 1724, 199, 1361, 360, 1987, 904, 8, 4574, 430, 199, 509, 1962, 315, 625, 9962, 26, 272, 870, 360, 1987, 904, 8, 1143, 59, 17, 16720, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
ericdill/bokeh
examples/glyphs/data_tables_server.py
38
6676
from __future__ import print_function from bokeh.browserlib import view from bokeh.models import ColumnDataSource, DataRange1d, Plot, LinearAxis, Grid, Circle, HoverTool, BoxSelectTool from bokeh.models.widgets import ( Select, DataTable, TableColumn, StringFormatter, NumberFormatter, StringEditor, IntEditor, NumberEditor, SelectEditor) from bokeh.io import vplot, hplot from bokeh.document import Document from bokeh.session import Session from bokeh.sampledata.autompg2 import autompg2 as mpg class DataTables(object): def __init__(self): self.document = Document() self.session = Session() self.session.use_doc('data_tables_server') self.session.load_document(self.document) self.manufacturer_filter = None self.model_filter = None self.transmission_filter = None self.drive_filter = None self.class_filter = None self.source = ColumnDataSource() self.update_data() self.document.add(self.create()) self.session.store_document(self.document) def create(self): manufacturers = sorted(mpg["manufacturer"].unique()) models = sorted(mpg["model"].unique()) transmissions = sorted(mpg["trans"].unique()) drives = sorted(mpg["drv"].unique()) classes = sorted(mpg["class"].unique()) manufacturer_select = Select(title="Manufacturer:", value="All", options=["All"] + manufacturers) manufacturer_select.on_change('value', self.on_manufacturer_change) model_select = Select(title="Model:", value="All", options=["All"] + models) model_select.on_change('value', self.on_model_change) transmission_select = Select(title="Transmission:", value="All", options=["All"] + transmissions) transmission_select.on_change('value', self.on_transmission_change) drive_select = Select(title="Drive:", value="All", options=["All"] + drives) drive_select.on_change('value', self.on_drive_change) class_select = Select(title="Class:", value="All", options=["All"] + classes) class_select.on_change('value', self.on_class_change) columns = [ TableColumn(field="manufacturer", title="Manufacturer", editor=SelectEditor(options=manufacturers), formatter=StringFormatter(font_style="bold")), TableColumn(field="model", title="Model", editor=StringEditor(completions=models)), TableColumn(field="displ", title="Displacement", editor=NumberEditor(step=0.1), formatter=NumberFormatter(format="0.0")), TableColumn(field="year", title="Year", editor=IntEditor()), TableColumn(field="cyl", title="Cylinders", editor=IntEditor()), TableColumn(field="trans", title="Transmission", editor=SelectEditor(options=transmissions)), TableColumn(field="drv", title="Drive", editor=SelectEditor(options=drives)), TableColumn(field="class", title="Class", editor=SelectEditor(options=classes)), TableColumn(field="cty", title="City MPG", editor=IntEditor()), TableColumn(field="hwy", title="Highway MPG", editor=IntEditor()), ] data_table = DataTable(source=self.source, columns=columns, editable=True) plot = Plot(title=None, x_range= DataRange1d(), y_range=DataRange1d(), plot_width=1000, plot_height=300) # Set up x & y axis plot.add_layout(LinearAxis(), 'below') yaxis = LinearAxis() plot.add_layout(yaxis, 'left') plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker)) # Add Glyphs cty_glyph = Circle(x="index", y="cty", fill_color="#396285", size=8, fill_alpha=0.5, line_alpha=0.5) hwy_glyph = Circle(x="index", y="hwy", fill_color="#CE603D", size=8, fill_alpha=0.5, line_alpha=0.5) cty = plot.add_glyph(self.source, cty_glyph) hwy = plot.add_glyph(self.source, hwy_glyph) # Add the tools tooltips = [ ("Manufacturer", "@manufacturer"), ("Model", "@model"), ("Displacement", "@displ"), ("Year", "@year"), ("Cylinders", "@cyl"), ("Transmission", "@trans"), ("Drive", "@drv"), ("Class", "@class"), ] cty_hover_tool = HoverTool(renderers=[cty], tooltips=tooltips + [("City MPG", "@cty")]) hwy_hover_tool = HoverTool(renderers=[hwy], tooltips=tooltips + [("Highway MPG", "@hwy")]) select_tool = BoxSelectTool(renderers=[cty, hwy], dimensions=['width']) plot.add_tools(cty_hover_tool, hwy_hover_tool, select_tool) controls = vplot(manufacturer_select, model_select, transmission_select, drive_select, class_select) top_panel = hplot(controls, plot) layout = vplot(top_panel, data_table) return layout def on_manufacturer_change(self, obj, attr, _, value): self.manufacturer_filter = None if value == "All" else value self.update_data() def on_model_change(self, obj, attr, _, value): self.model_filter = None if value == "All" else value self.update_data() def on_transmission_change(self, obj, attr, _, value): self.transmission_filter = None if value == "All" else value self.update_data() def on_drive_change(self, obj, attr, _, value): self.drive_filter = None if value == "All" else value self.update_data() def on_class_change(self, obj, attr, _, value): self.class_filter = None if value == "All" else value self.update_data() def update_data(self): df = mpg if self.manufacturer_filter: df = df[df["manufacturer"] == self.manufacturer_filter] if self.model_filter: df = df[df["model"] == self.model_filter] if self.transmission_filter: df = df[df["trans"] == self.transmission_filter] if self.drive_filter: df = df[df["drv"] == self.drive_filter] if self.class_filter: df = df[df["class"] == self.class_filter] self.source.data = ColumnDataSource.from_df(df) self.session.store_document(self.document) def run(self, do_view=False, poll_interval=0.5): link = self.session.object_link(self.document.context) print("Please visit %s to see the plots" % link) if do_view: view(link) print("\npress ctrl-C to exit") self.session.poll_document(self.document) if __name__ == "__main__": data_tables = DataTables() data_tables.run(True)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 25214, 14, 5750, 773, 492, 2455, 199, 504, 25214, 14, 992, 492, 4996, 16693, 12, 3918, 4709, 17, 68, 12, 14794, 12, 12489, 11220, 12, 16386, 12, 445, 12571, 12, 869, 1883, 5157, 12, 20783, 5446, 5157, 199, 504, 25214, 14, 992, 14, 8583, 492, 334, 272, 9496, 12, 3918, 3186, 12, 6957, 4547, 12, 2624, 7772, 12, 272, 4860, 7772, 12, 2624, 10423, 12, 9805, 10423, 12, 4860, 10423, 12, 9496, 10423, 9, 199, 504, 25214, 14, 2308, 492, 373, 2798, 12, 394, 2798, 199, 504, 25214, 14, 3554, 492, 7543, 199, 504, 25214, 14, 1730, 492, 8596, 199, 504, 25214, 14, 3271, 576, 14, 2495, 311, 71, 18, 492, 2599, 311, 71, 18, 465, 6118, 71, 421, 199, 533, 3918, 18845, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 3554, 275, 7543, 342, 267, 291, 14, 1730, 275, 8596, 342, 267, 291, 14, 1730, 14, 1180, 63, 1301, 360, 576, 63, 5987, 63, 1000, 358, 267, 291, 14, 1730, 14, 912, 63, 3554, 8, 277, 14, 3554, 9, 398, 291, 14, 32214, 63, 1541, 275, 488, 267, 291, 14, 1238, 63, 1541, 275, 488, 267, 291, 14, 1515, 2250, 63, 1541, 275, 488, 267, 291, 14, 9541, 63, 1541, 275, 488, 267, 291, 14, 533, 63, 1541, 275, 488, 398, 291, 14, 1365, 275, 4996, 16693, 342, 267, 291, 14, 873, 63, 576, 342, 398, 291, 14, 3554, 14, 525, 8, 277, 14, 981, 1012, 267, 291, 14, 1730, 14, 1617, 63, 3554, 8, 277, 14, 3554, 9, 339, 347, 1218, 8, 277, 304, 267, 2169, 17391, 2393, 275, 3355, 8, 311, 71, 905, 32214, 4140, 3235, 1012, 267, 1709, 275, 3355, 8, 311, 71, 905, 1238, 4140, 3235, 1012, 267, 1752, 2554, 275, 3355, 8, 311, 71, 905, 1515, 4140, 3235, 1012, 267, 20921, 2310, 275, 3355, 8, 311, 71, 905, 24066, 4140, 3235, 1012, 267, 3992, 275, 3355, 8, 311, 71, 905, 533, 4140, 3235, 1012, 398, 2169, 21087, 63, 2416, 275, 9496, 8, 1213, 628, 2395, 21087, 6783, 574, 628, 2422, 401, 1511, 6270, 2422, 937, 435, 2169, 17391, 2393, 9, 267, 2169, 21087, 63, 2416, 14, 265, 63, 1461, 360, 585, 297, 291, 14, 265, 63, 32214, 63, 1461, 9, 267, 1402, 63, 2416, 275, 9496, 8, 1213, 628, 1685, 6783, 574, 628, 2422, 401, 1511, 6270, 2422, 937, 435, 1709, 9, 267, 1402, 63, 2416, 14, 265, 63, 1461, 360, 585, 297, 291, 14, 265, 63, 1238, 63, 1461, 9, 267, 1752, 2250, 63, 2416, 275, 9496, 8, 1213, 628, 24011, 6783, 574, 628, 2422, 401, 1511, 6270, 2422, 937, 435, 1752, 2554, 9, 267, 1752, 2250, 63, 2416, 14, 265, 63, 1461, 360, 585, 297, 291, 14, 265, 63, 1515, 2250, 63, 1461, 9, 267, 12912, 63, 2416, 275, 9496, 8, 1213, 628, 24276, 6783, 574, 628, 2422, 401, 1511, 6270, 2422, 937, 435, 20921, 2310, 9, 267, 12912, 63, 2416, 14, 265, 63, 1461, 360, 585, 297, 291, 14, 265, 63, 9541, 63, 1461, 9, 267, 1021, 63, 2416, 275, 9496, 8, 1213, 628, 2543, 6783, 574, 628, 2422, 401, 1511, 6270, 2422, 937, 435, 3992, 9, 267, 1021, 63, 2416, 14, 265, 63, 1461, 360, 585, 297, 291, 14, 265, 63, 533, 63, 1461, 9, 398, 4362, 275, 359, 288, 6957, 4547, 8, 698, 628, 32214, 401, 2538, 628, 2395, 21087, 401, 8823, 29, 5446, 10423, 8, 1419, 29, 1237, 17391, 2393, 395, 9698, 29, 1558, 7772, 8, 4246, 63, 2487, 628, 9771, 8150, 288, 6957, 4547, 8, 698, 628, 1238, 401, 263, 2538, 628, 1685, 401, 263, 8823, 29, 1558, 10423, 8, 28832, 29, 992, 1826, 288, 6957, 4547, 8, 698, 628, 13654, 76, 401, 263, 2538, 628, 32616, 401, 8823, 29, 3259, 10423, 8, 2926, 29, 16, 14, 17, 395, 4519, 9698, 29, 3259, 7772, 8, 908, 628, 16, 14, 16, 8150, 288, 6957, 4547, 8, 698, 628, 3403, 401, 260, 2538, 628, 15731, 401, 260, 8823, 29, 3241, 10423, 4000, 288, 6957, 4547, 8, 698, 628, 1480, 76, 401, 3515, 2538, 628, 9156, 472, 7735, 401, 259, 8823, 29, 3241, 10423, 4000, 288, 6957, 4547, 8, 698, 628, 1515, 401, 263, 2538, 628, 24011, 401, 8823, 29, 5446, 10423, 8, 1419, 29, 1515, 2554, 1826, 288, 6957, 4547, 8, 698, 628, 24066, 401, 3515, 2538, 628, 24276, 401, 263, 8823, 29, 5446, 10423, 8, 1419, 29, 17824, 2310, 1826, 288, 6957, 4547, 8, 698, 628, 533, 401, 263, 2538, 628, 2543, 401, 263, 8823, 29, 5446, 10423, 8, 1419, 29, 2888, 1826, 288, 6957, 4547, 8, 698, 628, 319, 89, 401, 3515, 2538, 628, 17024, 603, 11115, 401, 258, 8823, 29, 3241, 10423, 4000, 288, 6957, 4547, 8, 698, 628, 8090, 89, 401, 3515, 2538, 628, 11688, 3316, 603, 11115, 401, 221, 8823, 29, 3241, 10423, 4000, 267, 1622, 267, 666, 63, 1224, 275, 3918, 3186, 8, 1365, 29, 277, 14, 1365, 12, 4362, 29, 3406, 12, 14783, 29, 549, 9, 398, 5137, 275, 14794, 8, 1213, 29, 403, 12, 671, 63, 1842, 29, 3918, 4709, 17, 68, 1062, 612, 63, 1842, 29, 1451, 4709, 17, 68, 1062, 5137, 63, 2063, 29, 5279, 12, 5137, 63, 3333, 29, 5863, 9, 398, 327, 2494, 1536, 671, 1253, 612, 3114, 267, 5137, 14, 525, 63, 4209, 8, 10608, 11220, 1062, 283, 12843, 358, 267, 612, 3127, 275, 12489, 11220, 342, 267, 5137, 14, 525, 63, 4209, 8, 23876, 12, 283, 3039, 358, 267, 5137, 14, 525, 63, 4209, 8, 7900, 8, 7430, 29, 17, 12, 32721, 29, 23876, 14, 28572, 430, 398, 327, 2654, 598, 7234, 83, 267, 286, 369, 63, 13723, 275, 445, 12571, 8, 88, 628, 1080, 401, 612, 628, 319, 89, 401, 5554, 63, 2326, 13476, 13443, 14523, 401, 1568, 29, 24, 12, 5554, 63, 4468, 29, 16, 14, 21, 12, 1004, 63, 4468, 29, 16, 14, 21, 9, 267, 12073, 89, 63, 13723, 275, 445, 12571, 8, 88, 628, 1080, 401, 612, 628, 8090, 89, 401, 5554, 63, 2326, 13476, 2089, 30877, 36, 401, 1568, 29, 24, 12, 5554, 63, 4468, 29, 16, 14, 21, 12, 1004, 63, 4468, 29, 16, 14, 21 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 25214, 14, 5750, 773, 492, 2455, 199, 504, 25214, 14, 992, 492, 4996, 16693, 12, 3918, 4709, 17, 68, 12, 14794, 12, 12489, 11220, 12, 16386, 12, 445, 12571, 12, 869, 1883, 5157, 12, 20783, 5446, 5157, 199, 504, 25214, 14, 992, 14, 8583, 492, 334, 272, 9496, 12, 3918, 3186, 12, 6957, 4547, 12, 2624, 7772, 12, 272, 4860, 7772, 12, 2624, 10423, 12, 9805, 10423, 12, 4860, 10423, 12, 9496, 10423, 9, 199, 504, 25214, 14, 2308, 492, 373, 2798, 12, 394, 2798, 199, 504, 25214, 14, 3554, 492, 7543, 199, 504, 25214, 14, 1730, 492, 8596, 199, 504, 25214, 14, 3271, 576, 14, 2495, 311, 71, 18, 492, 2599, 311, 71, 18, 465, 6118, 71, 421, 199, 533, 3918, 18845, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 3554, 275, 7543, 342, 267, 291, 14, 1730, 275, 8596, 342, 267, 291, 14, 1730, 14, 1180, 63, 1301, 360, 576, 63, 5987, 63, 1000, 358, 267, 291, 14, 1730, 14, 912, 63, 3554, 8, 277, 14, 3554, 9, 398, 291, 14, 32214, 63, 1541, 275, 488, 267, 291, 14, 1238, 63, 1541, 275, 488, 267, 291, 14, 1515, 2250, 63, 1541, 275, 488, 267, 291, 14, 9541, 63, 1541, 275, 488, 267, 291, 14, 533, 63, 1541, 275, 488, 398, 291, 14, 1365, 275, 4996, 16693, 342, 267, 291, 14, 873, 63, 576, 342, 398, 291, 14, 3554, 14, 525, 8, 277, 14, 981, 1012, 267, 291, 14, 1730, 14, 1617, 63, 3554, 8, 277, 14, 3554, 9, 339, 347, 1218, 8, 277, 304, 267, 2169, 17391, 2393, 275, 3355, 8, 311, 71, 905, 32214, 4140, 3235, 1012, 267, 1709, 275, 3355, 8, 311, 71, 905, 1238, 4140, 3235, 1012, 267, 1752, 2554, 275, 3355, 8, 311, 71, 905, 1515, 4140, 3235, 1012, 267, 20921, 2310, 275, 3355, 8, 311, 71, 905, 24066, 4140, 3235, 1012, 267, 3992, 275, 3355, 8, 311, 71, 905, 533, 4140, 3235, 1012, 398, 2169, 21087, 63, 2416, 275, 9496, 8, 1213, 628, 2395, 21087, 6783, 574, 628, 2422, 401, 1511, 6270, 2422, 937, 435, 2169, 17391, 2393, 9, 267, 2169, 21087, 63, 2416, 14, 265, 63, 1461, 360, 585, 297, 291, 14, 265, 63, 32214, 63, 1461, 9, 267, 1402, 63, 2416, 275, 9496, 8, 1213, 628, 1685, 6783, 574, 628, 2422, 401, 1511, 6270, 2422, 937, 435, 1709, 9, 267, 1402, 63, 2416, 14, 265, 63, 1461, 360, 585, 297, 291, 14, 265, 63, 1238, 63, 1461, 9, 267, 1752, 2250, 63, 2416, 275, 9496, 8, 1213, 628, 24011, 6783, 574, 628, 2422, 401, 1511, 6270, 2422, 937, 435, 1752, 2554, 9, 267, 1752, 2250, 63, 2416, 14, 265, 63, 1461, 360, 585, 297, 291, 14, 265, 63, 1515, 2250, 63, 1461, 9, 267, 12912, 63, 2416, 275, 9496, 8, 1213, 628, 24276, 6783, 574, 628, 2422, 401, 1511, 6270, 2422, 937, 435, 20921, 2310, 9, 267, 12912, 63, 2416, 14, 265, 63, 1461, 360, 585, 297, 291, 14, 265, 63, 9541, 63, 1461, 9, 267, 1021, 63, 2416, 275, 9496, 8, 1213, 628, 2543, 6783, 574, 628, 2422, 401, 1511, 6270, 2422, 937, 435, 3992, 9, 267, 1021, 63, 2416, 14, 265, 63, 1461, 360, 585, 297, 291, 14, 265, 63, 533, 63, 1461, 9, 398, 4362, 275, 359, 288, 6957, 4547, 8, 698, 628, 32214, 401, 2538, 628, 2395, 21087, 401, 8823, 29, 5446, 10423, 8, 1419, 29, 1237, 17391, 2393, 395, 9698, 29, 1558, 7772, 8, 4246, 63, 2487, 628, 9771, 8150, 288, 6957, 4547, 8, 698, 628, 1238, 401, 263, 2538, 628, 1685, 401, 263, 8823, 29, 1558, 10423, 8, 28832, 29, 992, 1826, 288, 6957, 4547, 8, 698, 628, 13654, 76, 401, 263, 2538, 628, 32616, 401, 8823, 29, 3259, 10423, 8, 2926, 29, 16, 14, 17, 395, 4519, 9698, 29, 3259, 7772, 8, 908, 628, 16, 14, 16, 8150, 288, 6957, 4547, 8, 698, 628, 3403, 401, 260, 2538, 628, 15731, 401, 260, 8823, 29, 3241, 10423, 4000, 288, 6957, 4547, 8, 698, 628, 1480, 76, 401, 3515, 2538, 628, 9156, 472, 7735, 401, 259, 8823, 29, 3241, 10423, 4000, 288, 6957, 4547, 8, 698, 628, 1515, 401, 263, 2538, 628, 24011, 401, 8823, 29, 5446, 10423, 8, 1419, 29, 1515, 2554, 1826, 288, 6957, 4547, 8, 698, 628, 24066, 401, 3515, 2538, 628, 24276, 401, 263, 8823, 29, 5446, 10423, 8, 1419, 29, 17824, 2310, 1826, 288, 6957, 4547, 8, 698, 628, 533, 401, 263, 2538, 628, 2543, 401, 263, 8823, 29, 5446, 10423, 8, 1419, 29, 2888, 1826, 288, 6957, 4547, 8, 698, 628, 319, 89, 401, 3515, 2538, 628, 17024, 603, 11115, 401, 258, 8823, 29, 3241, 10423, 4000, 288, 6957, 4547, 8, 698, 628, 8090, 89, 401, 3515, 2538, 628, 11688, 3316, 603, 11115, 401, 221, 8823, 29, 3241, 10423, 4000, 267, 1622, 267, 666, 63, 1224, 275, 3918, 3186, 8, 1365, 29, 277, 14, 1365, 12, 4362, 29, 3406, 12, 14783, 29, 549, 9, 398, 5137, 275, 14794, 8, 1213, 29, 403, 12, 671, 63, 1842, 29, 3918, 4709, 17, 68, 1062, 612, 63, 1842, 29, 1451, 4709, 17, 68, 1062, 5137, 63, 2063, 29, 5279, 12, 5137, 63, 3333, 29, 5863, 9, 398, 327, 2494, 1536, 671, 1253, 612, 3114, 267, 5137, 14, 525, 63, 4209, 8, 10608, 11220, 1062, 283, 12843, 358, 267, 612, 3127, 275, 12489, 11220, 342, 267, 5137, 14, 525, 63, 4209, 8, 23876, 12, 283, 3039, 358, 267, 5137, 14, 525, 63, 4209, 8, 7900, 8, 7430, 29, 17, 12, 32721, 29, 23876, 14, 28572, 430, 398, 327, 2654, 598, 7234, 83, 267, 286, 369, 63, 13723, 275, 445, 12571, 8, 88, 628, 1080, 401, 612, 628, 319, 89, 401, 5554, 63, 2326, 13476, 13443, 14523, 401, 1568, 29, 24, 12, 5554, 63, 4468, 29, 16, 14, 21, 12, 1004, 63, 4468, 29, 16, 14, 21, 9, 267, 12073,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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 ]
dexterx17/nodoSocket
clients/Python-2.7.6/Lib/test/test_hotshot.py
122
4990
import os import pprint import unittest import tempfile import _hotshot import gc from test import test_support # Silence Py3k warning hotshot = test_support.import_module('hotshot', deprecated=True) from hotshot.log import ENTER, EXIT, LINE from hotshot import stats def shortfilename(fn): # We use a really shortened filename since an exact match is made, # and the source may be either a Python source file or a # pre-compiled bytecode file. if fn: return os.path.splitext(os.path.basename(fn))[0] else: return fn class UnlinkingLogReader(hotshot.log.LogReader): """Extend the LogReader so the log file is unlinked when we're done with it.""" def __init__(self, logfn): self.__logfn = logfn hotshot.log.LogReader.__init__(self, logfn) def next(self, index=None): try: return hotshot.log.LogReader.next(self) except StopIteration: self.close() os.unlink(self.__logfn) raise class HotShotTestCase(unittest.TestCase): def new_profiler(self, lineevents=0, linetimings=1): self.logfn = test_support.TESTFN return hotshot.Profile(self.logfn, lineevents, linetimings) def get_logreader(self): return UnlinkingLogReader(self.logfn) def get_events_wotime(self): L = [] for event in self.get_logreader(): what, (filename, lineno, funcname), tdelta = event L.append((what, (shortfilename(filename), lineno, funcname))) return L def check_events(self, expected): events = self.get_events_wotime() if events != expected: self.fail( "events did not match expectation; got:\n%s\nexpected:\n%s" % (pprint.pformat(events), pprint.pformat(expected))) def run_test(self, callable, events, profiler=None): if profiler is None: profiler = self.new_profiler() self.assertTrue(not profiler._prof.closed) profiler.runcall(callable) self.assertTrue(not profiler._prof.closed) profiler.close() self.assertTrue(profiler._prof.closed) self.check_events(events) def test_addinfo(self): def f(p): p.addinfo("test-key", "test-value") profiler = self.new_profiler() profiler.runcall(f, profiler) profiler.close() log = self.get_logreader() info = log._info list(log) self.assertTrue(info["test-key"] == ["test-value"]) def test_line_numbers(self): def f(): y = 2 x = 1 def g(): f() f_lineno = f.func_code.co_firstlineno g_lineno = g.func_code.co_firstlineno events = [(ENTER, ("test_hotshot", g_lineno, "g")), (LINE, ("test_hotshot", g_lineno+1, "g")), (ENTER, ("test_hotshot", f_lineno, "f")), (LINE, ("test_hotshot", f_lineno+1, "f")), (LINE, ("test_hotshot", f_lineno+2, "f")), (EXIT, ("test_hotshot", f_lineno, "f")), (EXIT, ("test_hotshot", g_lineno, "g")), ] self.run_test(g, events, self.new_profiler(lineevents=1)) def test_start_stop(self): # Make sure we don't return NULL in the start() and stop() # methods when there isn't an error. Bug in 2.2 noted by # Anthony Baxter. profiler = self.new_profiler() profiler.start() profiler.stop() profiler.close() os.unlink(self.logfn) def test_bad_sys_path(self): import sys import os orig_path = sys.path coverage = hotshot._hotshot.coverage try: # verify we require a list for sys.path sys.path = 'abc' self.assertRaises(RuntimeError, coverage, test_support.TESTFN) # verify that we require sys.path exists del sys.path self.assertRaises(RuntimeError, coverage, test_support.TESTFN) finally: sys.path = orig_path if os.path.exists(test_support.TESTFN): os.remove(test_support.TESTFN) def test_logreader_eof_error(self): emptyfile = tempfile.NamedTemporaryFile() try: self.assertRaises((IOError, EOFError), _hotshot.logreader, emptyfile.name) finally: emptyfile.close() gc.collect() def test_load_stats(self): def start(prof): prof.start() # Make sure stats can be loaded when start and stop of profiler # are not executed in the same stack frame. profiler = self.new_profiler() start(profiler) profiler.stop() profiler.close() stats.load(self.logfn) os.unlink(self.logfn) def test_main(): test_support.run_unittest(HotShotTestCase) if __name__ == "__main__": test_main()
mit
[ 646, 747, 199, 646, 10933, 199, 646, 2882, 199, 646, 5549, 199, 646, 485, 8885, 2782, 199, 646, 9486, 199, 199, 504, 511, 492, 511, 63, 4058, 199, 199, 3, 428, 441, 21225, 1611, 19, 75, 5721, 199, 8885, 2782, 275, 511, 63, 4058, 14, 646, 63, 578, 360, 8885, 2782, 297, 5906, 29, 549, 9, 199, 504, 18469, 2782, 14, 793, 492, 5070, 1157, 12, 3651, 649, 12, 13587, 199, 504, 18469, 2782, 492, 5020, 421, 199, 318, 3974, 1501, 8, 2324, 304, 272, 327, 2136, 675, 282, 7710, 25123, 379, 1788, 3967, 376, 5835, 1336, 365, 6326, 12, 272, 327, 436, 314, 1350, 1443, 506, 1902, 282, 2018, 1350, 570, 503, 282, 272, 327, 876, 13, 8427, 16855, 570, 14, 272, 340, 4325, 26, 267, 372, 747, 14, 515, 14, 7973, 8, 736, 14, 515, 14, 4846, 8, 2324, 11515, 16, 61, 272, 587, 26, 267, 372, 4325, 421, 199, 533, 1910, 1073, 316, 2445, 5929, 8, 8885, 2782, 14, 793, 14, 2445, 5929, 304, 272, 408, 30775, 314, 5297, 5929, 880, 314, 943, 570, 365, 625, 12751, 1380, 781, 3984, 272, 4224, 543, 652, 1041, 339, 347, 636, 826, 721, 277, 12, 943, 2324, 304, 267, 291, 855, 793, 2324, 275, 943, 2324, 267, 18469, 2782, 14, 793, 14, 2445, 5929, 855, 826, 721, 277, 12, 943, 2324, 9, 339, 347, 2163, 8, 277, 12, 1478, 29, 403, 304, 267, 862, 26, 288, 372, 18469, 2782, 14, 793, 14, 2445, 5929, 14, 2184, 8, 277, 9, 267, 871, 10852, 26, 288, 291, 14, 1600, 342, 288, 747, 14, 7162, 8, 277, 855, 793, 2324, 9, 288, 746, 421, 199, 533, 869, 357, 2662, 357, 1746, 8, 2796, 14, 1746, 304, 272, 347, 892, 63, 20132, 8, 277, 12, 1004, 4368, 29, 16, 12, 1004, 27337, 29, 17, 304, 267, 291, 14, 793, 2324, 275, 511, 63, 4058, 14, 10179, 267, 372, 18469, 2782, 14, 5736, 8, 277, 14, 793, 2324, 12, 1004, 4368, 12, 1004, 27337, 9, 339, 347, 664, 63, 793, 5503, 8, 277, 304, 267, 372, 1910, 1073, 316, 2445, 5929, 8, 277, 14, 793, 2324, 9, 339, 347, 664, 63, 4368, 63, 2027, 521, 8, 277, 304, 267, 491, 275, 942, 267, 367, 1566, 315, 291, 14, 362, 63, 793, 5503, 837, 288, 4052, 12, 334, 1501, 12, 5874, 12, 24092, 395, 307, 3136, 275, 1566, 288, 491, 14, 740, 1332, 10058, 12, 334, 3612, 1501, 8, 1501, 395, 5874, 12, 24092, 1724, 267, 372, 491, 339, 347, 1104, 63, 4368, 8, 277, 12, 1420, 304, 267, 4474, 275, 291, 14, 362, 63, 4368, 63, 2027, 521, 342, 267, 340, 4474, 1137, 1420, 26, 288, 291, 14, 1633, 8, 355, 298, 4368, 8103, 440, 1336, 17513, 27, 4788, 3427, 78, 5, 83, 60, 78, 2062, 3427, 78, 5, 83, 2, 355, 450, 334, 15380, 14, 24225, 8, 4368, 395, 10933, 14, 24225, 8, 2062, 1724, 339, 347, 1255, 63, 396, 8, 277, 12, 4550, 12, 4474, 12, 23173, 29, 403, 304, 267, 340, 23173, 365, 488, 26, 288, 23173, 275, 291, 14, 1222, 63, 20132, 342, 267, 291, 14, 1815, 8, 1397, 23173, 423, 14979, 14, 5938, 9, 267, 23173, 14, 1065, 1250, 8, 8296, 9, 267, 291, 14, 1815, 8, 1397, 23173, 423, 14979, 14, 5938, 9, 267, 23173, 14, 1600, 342, 267, 291, 14, 1815, 8, 20132, 423, 14979, 14, 5938, 9, 267, 291, 14, 1074, 63, 4368, 8, 4368, 9, 339, 347, 511, 63, 525, 815, 8, 277, 304, 267, 347, 289, 8, 80, 304, 288, 299, 14, 525, 815, 480, 396, 13, 498, 401, 298, 396, 13, 585, 531, 267, 23173, 275, 291, 14, 1222, 63, 20132, 342, 267, 23173, 14, 1065, 1250, 8, 70, 12, 23173, 9, 267, 23173, 14, 1600, 342, 267, 943, 275, 291, 14, 362, 63, 793, 5503, 342, 267, 2256, 275, 943, 423, 815, 267, 769, 8, 793, 9, 267, 291, 14, 1815, 8, 815, 905, 396, 13, 498, 937, 508, 2097, 396, 13, 585, 3135, 339, 347, 511, 63, 604, 63, 10548, 8, 277, 304, 267, 347, 289, 837, 288, 612, 275, 499, 288, 671, 275, 413, 267, 347, 486, 837, 288, 289, 342, 267, 289, 63, 3469, 275, 289, 14, 1532, 63, 600, 14, 331, 63, 30114, 267, 486, 63, 3469, 275, 486, 14, 1532, 63, 600, 14, 331, 63, 30114, 267, 4474, 275, 3842, 12533, 12, 1689, 396, 63, 8885, 2782, 401, 486, 63, 3469, 12, 298, 71, 8150, 2116, 334, 6174, 12, 221, 1689, 396, 63, 8885, 2782, 401, 486, 63, 3469, 11, 17, 12, 298, 71, 8150, 2116, 334, 12533, 12, 1689, 396, 63, 8885, 2782, 401, 289, 63, 3469, 12, 298, 70, 8150, 2116, 334, 6174, 12, 221, 1689, 396, 63, 8885, 2782, 401, 289, 63, 3469, 11, 17, 12, 298, 70, 8150, 2116, 334, 6174, 12, 221, 1689, 396, 63, 8885, 2782, 401, 289, 63, 3469, 11, 18, 12, 298, 70, 8150, 2116, 334, 17219, 12, 221, 1689, 396, 63, 8885, 2782, 401, 289, 63, 3469, 12, 298, 70, 8150, 2116, 334, 17219, 12, 221, 1689, 396, 63, 8885, 2782, 401, 486, 63, 3469, 12, 298, 71, 8150, 2116, 1622, 267, 291, 14, 1065, 63, 396, 8, 71, 12, 4474, 12, 291, 14, 1222, 63, 20132, 8, 604, 4368, 29, 17, 430, 339, 347, 511, 63, 928, 63, 2379, 8, 277, 304, 267, 327, 4155, 3238, 781, 2793, 1133, 372, 5962, 315, 314, 1343, 342, 436, 3631, 342, 267, 327, 3102, 1380, 2337, 5712, 1133, 376, 1125, 14, 221, 21605, 315, 499, 14, 18, 949, 471, 701, 267, 327, 1626, 898, 89, 699, 1219, 351, 14, 267, 23173, 275, 291, 14, 1222, 63, 20132, 342, 267, 23173, 14, 928, 342, 267, 23173, 14, 2379, 342, 267, 23173, 14, 1600, 342, 267, 747, 14, 7162, 8, 277, 14, 793, 2324, 9, 339, 347, 511, 63, 4087, 63, 1274, 63, 515, 8, 277, 304, 267, 492, 984, 267, 492, 747, 267, 2306, 63, 515, 275, 984, 14, 515, 267, 11745, 275, 18469, 2782, 423, 8885, 2782, 14, 10828, 267, 862, 26, 288, 327, 4911, 781, 4409, 282, 769, 367, 984, 14, 515, 288, 984, 14, 515, 275, 283, 3175, 7, 288, 291, 14, 1855 ]
[ 747, 199, 646, 10933, 199, 646, 2882, 199, 646, 5549, 199, 646, 485, 8885, 2782, 199, 646, 9486, 199, 199, 504, 511, 492, 511, 63, 4058, 199, 199, 3, 428, 441, 21225, 1611, 19, 75, 5721, 199, 8885, 2782, 275, 511, 63, 4058, 14, 646, 63, 578, 360, 8885, 2782, 297, 5906, 29, 549, 9, 199, 504, 18469, 2782, 14, 793, 492, 5070, 1157, 12, 3651, 649, 12, 13587, 199, 504, 18469, 2782, 492, 5020, 421, 199, 318, 3974, 1501, 8, 2324, 304, 272, 327, 2136, 675, 282, 7710, 25123, 379, 1788, 3967, 376, 5835, 1336, 365, 6326, 12, 272, 327, 436, 314, 1350, 1443, 506, 1902, 282, 2018, 1350, 570, 503, 282, 272, 327, 876, 13, 8427, 16855, 570, 14, 272, 340, 4325, 26, 267, 372, 747, 14, 515, 14, 7973, 8, 736, 14, 515, 14, 4846, 8, 2324, 11515, 16, 61, 272, 587, 26, 267, 372, 4325, 421, 199, 533, 1910, 1073, 316, 2445, 5929, 8, 8885, 2782, 14, 793, 14, 2445, 5929, 304, 272, 408, 30775, 314, 5297, 5929, 880, 314, 943, 570, 365, 625, 12751, 1380, 781, 3984, 272, 4224, 543, 652, 1041, 339, 347, 636, 826, 721, 277, 12, 943, 2324, 304, 267, 291, 855, 793, 2324, 275, 943, 2324, 267, 18469, 2782, 14, 793, 14, 2445, 5929, 855, 826, 721, 277, 12, 943, 2324, 9, 339, 347, 2163, 8, 277, 12, 1478, 29, 403, 304, 267, 862, 26, 288, 372, 18469, 2782, 14, 793, 14, 2445, 5929, 14, 2184, 8, 277, 9, 267, 871, 10852, 26, 288, 291, 14, 1600, 342, 288, 747, 14, 7162, 8, 277, 855, 793, 2324, 9, 288, 746, 421, 199, 533, 869, 357, 2662, 357, 1746, 8, 2796, 14, 1746, 304, 272, 347, 892, 63, 20132, 8, 277, 12, 1004, 4368, 29, 16, 12, 1004, 27337, 29, 17, 304, 267, 291, 14, 793, 2324, 275, 511, 63, 4058, 14, 10179, 267, 372, 18469, 2782, 14, 5736, 8, 277, 14, 793, 2324, 12, 1004, 4368, 12, 1004, 27337, 9, 339, 347, 664, 63, 793, 5503, 8, 277, 304, 267, 372, 1910, 1073, 316, 2445, 5929, 8, 277, 14, 793, 2324, 9, 339, 347, 664, 63, 4368, 63, 2027, 521, 8, 277, 304, 267, 491, 275, 942, 267, 367, 1566, 315, 291, 14, 362, 63, 793, 5503, 837, 288, 4052, 12, 334, 1501, 12, 5874, 12, 24092, 395, 307, 3136, 275, 1566, 288, 491, 14, 740, 1332, 10058, 12, 334, 3612, 1501, 8, 1501, 395, 5874, 12, 24092, 1724, 267, 372, 491, 339, 347, 1104, 63, 4368, 8, 277, 12, 1420, 304, 267, 4474, 275, 291, 14, 362, 63, 4368, 63, 2027, 521, 342, 267, 340, 4474, 1137, 1420, 26, 288, 291, 14, 1633, 8, 355, 298, 4368, 8103, 440, 1336, 17513, 27, 4788, 3427, 78, 5, 83, 60, 78, 2062, 3427, 78, 5, 83, 2, 355, 450, 334, 15380, 14, 24225, 8, 4368, 395, 10933, 14, 24225, 8, 2062, 1724, 339, 347, 1255, 63, 396, 8, 277, 12, 4550, 12, 4474, 12, 23173, 29, 403, 304, 267, 340, 23173, 365, 488, 26, 288, 23173, 275, 291, 14, 1222, 63, 20132, 342, 267, 291, 14, 1815, 8, 1397, 23173, 423, 14979, 14, 5938, 9, 267, 23173, 14, 1065, 1250, 8, 8296, 9, 267, 291, 14, 1815, 8, 1397, 23173, 423, 14979, 14, 5938, 9, 267, 23173, 14, 1600, 342, 267, 291, 14, 1815, 8, 20132, 423, 14979, 14, 5938, 9, 267, 291, 14, 1074, 63, 4368, 8, 4368, 9, 339, 347, 511, 63, 525, 815, 8, 277, 304, 267, 347, 289, 8, 80, 304, 288, 299, 14, 525, 815, 480, 396, 13, 498, 401, 298, 396, 13, 585, 531, 267, 23173, 275, 291, 14, 1222, 63, 20132, 342, 267, 23173, 14, 1065, 1250, 8, 70, 12, 23173, 9, 267, 23173, 14, 1600, 342, 267, 943, 275, 291, 14, 362, 63, 793, 5503, 342, 267, 2256, 275, 943, 423, 815, 267, 769, 8, 793, 9, 267, 291, 14, 1815, 8, 815, 905, 396, 13, 498, 937, 508, 2097, 396, 13, 585, 3135, 339, 347, 511, 63, 604, 63, 10548, 8, 277, 304, 267, 347, 289, 837, 288, 612, 275, 499, 288, 671, 275, 413, 267, 347, 486, 837, 288, 289, 342, 267, 289, 63, 3469, 275, 289, 14, 1532, 63, 600, 14, 331, 63, 30114, 267, 486, 63, 3469, 275, 486, 14, 1532, 63, 600, 14, 331, 63, 30114, 267, 4474, 275, 3842, 12533, 12, 1689, 396, 63, 8885, 2782, 401, 486, 63, 3469, 12, 298, 71, 8150, 2116, 334, 6174, 12, 221, 1689, 396, 63, 8885, 2782, 401, 486, 63, 3469, 11, 17, 12, 298, 71, 8150, 2116, 334, 12533, 12, 1689, 396, 63, 8885, 2782, 401, 289, 63, 3469, 12, 298, 70, 8150, 2116, 334, 6174, 12, 221, 1689, 396, 63, 8885, 2782, 401, 289, 63, 3469, 11, 17, 12, 298, 70, 8150, 2116, 334, 6174, 12, 221, 1689, 396, 63, 8885, 2782, 401, 289, 63, 3469, 11, 18, 12, 298, 70, 8150, 2116, 334, 17219, 12, 221, 1689, 396, 63, 8885, 2782, 401, 289, 63, 3469, 12, 298, 70, 8150, 2116, 334, 17219, 12, 221, 1689, 396, 63, 8885, 2782, 401, 486, 63, 3469, 12, 298, 71, 8150, 2116, 1622, 267, 291, 14, 1065, 63, 396, 8, 71, 12, 4474, 12, 291, 14, 1222, 63, 20132, 8, 604, 4368, 29, 17, 430, 339, 347, 511, 63, 928, 63, 2379, 8, 277, 304, 267, 327, 4155, 3238, 781, 2793, 1133, 372, 5962, 315, 314, 1343, 342, 436, 3631, 342, 267, 327, 3102, 1380, 2337, 5712, 1133, 376, 1125, 14, 221, 21605, 315, 499, 14, 18, 949, 471, 701, 267, 327, 1626, 898, 89, 699, 1219, 351, 14, 267, 23173, 275, 291, 14, 1222, 63, 20132, 342, 267, 23173, 14, 928, 342, 267, 23173, 14, 2379, 342, 267, 23173, 14, 1600, 342, 267, 747, 14, 7162, 8, 277, 14, 793, 2324, 9, 339, 347, 511, 63, 4087, 63, 1274, 63, 515, 8, 277, 304, 267, 492, 984, 267, 492, 747, 267, 2306, 63, 515, 275, 984, 14, 515, 267, 11745, 275, 18469, 2782, 423, 8885, 2782, 14, 10828, 267, 862, 26, 288, 327, 4911, 781, 4409, 282, 769, 367, 984, 14, 515, 288, 984, 14, 515, 275, 283, 3175, 7, 288, 291, 14, 1855, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
michaelmior/pylinks
pylinks/links/views.py
1
2010
from django.db.models import F from django.http import Http404, HttpResponseRedirect from django.shortcuts import get_object_or_404 from django.views.generic import ListView from pylinks.links.models import Category, Link class LinkListView(ListView): model = Link context_object_name = 'links' paginate_by = 20 class CategoryListView(LinkListView): template_name = 'links/category.htm' def get(self, request, *args, **kwargs): # We set the category here to be used later self.category = get_object_or_404(Category, slug=kwargs.get('slug')) return super().get(request, *args, **kwargs) def get_queryset(self): return self.category.links.all() def get_context_data(self, *args, **kwargs): # Just add the category to the context context = super() \ .get_context_data(*args, **kwargs) context['category'] = self.category context['page'] = context['page_obj'] del context['page_obj'] return context class AlphaListView(LinkListView): template_name = 'links/alpha.htm' def get(self, request, *args, **kwargs): self.letter = kwargs.get('letter') return super().get(request, *args, **kwargs) def get_queryset(self): return Link.objects.filter(title__istartswith=self.letter) class RecentListView(LinkListView): template_name = 'links/recent.htm' def get_queryset(self): return Link.objects.all().order_by('-created_time') class PopularListView(LinkListView): template_name = 'links/popular.htm' def get_queryset(self): return Link.objects.all().order_by('-visits', 'title') def track_link(request, link_id): link = Link.objects.select_for_update().filter(pk=link_id) if not link.exists(): raise Http404 link.update(visits=F('visits') + 1) link = link[0] if link.file: url = link.file.cdn_url else: url = link.url return HttpResponseRedirect(url)
mit
[ 504, 1639, 14, 697, 14, 992, 492, 481, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 12, 14935, 199, 504, 1639, 14, 17469, 492, 664, 63, 785, 63, 269, 63, 5188, 199, 504, 1639, 14, 4196, 14, 6767, 492, 3820, 2768, 199, 199, 504, 1134, 4614, 14, 4614, 14, 992, 492, 13573, 12, 10967, 421, 199, 533, 10967, 23239, 8, 23239, 304, 272, 1402, 275, 10967, 272, 1067, 63, 785, 63, 354, 275, 283, 4614, 7, 272, 9881, 23043, 63, 991, 275, 3388, 421, 199, 533, 13573, 23239, 8, 3834, 23239, 304, 272, 1978, 63, 354, 275, 283, 4614, 15, 3710, 14, 15575, 7, 339, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 2136, 663, 314, 4637, 2348, 370, 506, 1202, 2945, 267, 291, 14, 3710, 275, 664, 63, 785, 63, 269, 63, 5188, 8, 7841, 12, 8889, 29, 958, 14, 362, 360, 5464, 1333, 267, 372, 1613, 1252, 362, 8, 1069, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 291, 14, 3710, 14, 4614, 14, 452, 342, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 13870, 1050, 314, 4637, 370, 314, 1067, 267, 1067, 275, 1613, 342, 971, 490, 1275, 362, 63, 1100, 63, 576, 2031, 589, 12, 1011, 958, 9, 398, 1067, 459, 3710, 418, 275, 291, 14, 3710, 267, 1067, 459, 1606, 418, 275, 1067, 459, 1606, 63, 1113, 418, 267, 2150, 1067, 459, 1606, 63, 1113, 418, 398, 372, 1067, 199, 199, 533, 32657, 23239, 8, 3834, 23239, 304, 272, 1978, 63, 354, 275, 283, 4614, 15, 4468, 14, 15575, 7, 339, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 9269, 275, 2074, 14, 362, 360, 9269, 358, 267, 372, 1613, 1252, 362, 8, 1069, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 10967, 14, 1462, 14, 1541, 8, 1213, 363, 631, 580, 1908, 29, 277, 14, 9269, 9, 421, 199, 533, 799, 2946, 23239, 8, 3834, 23239, 304, 272, 1978, 63, 354, 275, 283, 4614, 15, 14951, 14, 15575, 7, 339, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 10967, 14, 1462, 14, 452, 1252, 1648, 63, 991, 3654, 3966, 63, 521, 358, 421, 199, 533, 13244, 2238, 23239, 8, 3834, 23239, 304, 272, 1978, 63, 354, 275, 283, 4614, 15, 1935, 2238, 14, 15575, 7, 339, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 10967, 14, 1462, 14, 452, 1252, 1648, 63, 991, 3654, 433, 30066, 297, 283, 1213, 358, 421, 199, 318, 4426, 63, 1073, 8, 1069, 12, 2142, 63, 344, 304, 272, 2142, 275, 10967, 14, 1462, 14, 2416, 63, 509, 63, 873, 1252, 1541, 8, 2051, 29, 1073, 63, 344, 9, 272, 340, 440, 2142, 14, 2444, 837, 267, 746, 4760, 5188, 339, 2142, 14, 873, 8, 433, 30066, 29, 38, 360, 433, 30066, 358, 435, 413, 9, 339, 2142, 275, 2142, 59, 16, 61, 272, 340, 2142, 14, 493, 26, 267, 1166, 275, 2142, 14, 493, 14, 23982, 63, 633, 272, 587, 26, 267, 1166, 275, 2142, 14, 633, 272, 372, 14935, 8, 633, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 14, 697, 14, 992, 492, 481, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 12, 14935, 199, 504, 1639, 14, 17469, 492, 664, 63, 785, 63, 269, 63, 5188, 199, 504, 1639, 14, 4196, 14, 6767, 492, 3820, 2768, 199, 199, 504, 1134, 4614, 14, 4614, 14, 992, 492, 13573, 12, 10967, 421, 199, 533, 10967, 23239, 8, 23239, 304, 272, 1402, 275, 10967, 272, 1067, 63, 785, 63, 354, 275, 283, 4614, 7, 272, 9881, 23043, 63, 991, 275, 3388, 421, 199, 533, 13573, 23239, 8, 3834, 23239, 304, 272, 1978, 63, 354, 275, 283, 4614, 15, 3710, 14, 15575, 7, 339, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 2136, 663, 314, 4637, 2348, 370, 506, 1202, 2945, 267, 291, 14, 3710, 275, 664, 63, 785, 63, 269, 63, 5188, 8, 7841, 12, 8889, 29, 958, 14, 362, 360, 5464, 1333, 267, 372, 1613, 1252, 362, 8, 1069, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 291, 14, 3710, 14, 4614, 14, 452, 342, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 13870, 1050, 314, 4637, 370, 314, 1067, 267, 1067, 275, 1613, 342, 971, 490, 1275, 362, 63, 1100, 63, 576, 2031, 589, 12, 1011, 958, 9, 398, 1067, 459, 3710, 418, 275, 291, 14, 3710, 267, 1067, 459, 1606, 418, 275, 1067, 459, 1606, 63, 1113, 418, 267, 2150, 1067, 459, 1606, 63, 1113, 418, 398, 372, 1067, 199, 199, 533, 32657, 23239, 8, 3834, 23239, 304, 272, 1978, 63, 354, 275, 283, 4614, 15, 4468, 14, 15575, 7, 339, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 9269, 275, 2074, 14, 362, 360, 9269, 358, 267, 372, 1613, 1252, 362, 8, 1069, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 10967, 14, 1462, 14, 1541, 8, 1213, 363, 631, 580, 1908, 29, 277, 14, 9269, 9, 421, 199, 533, 799, 2946, 23239, 8, 3834, 23239, 304, 272, 1978, 63, 354, 275, 283, 4614, 15, 14951, 14, 15575, 7, 339, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 10967, 14, 1462, 14, 452, 1252, 1648, 63, 991, 3654, 3966, 63, 521, 358, 421, 199, 533, 13244, 2238, 23239, 8, 3834, 23239, 304, 272, 1978, 63, 354, 275, 283, 4614, 15, 1935, 2238, 14, 15575, 7, 339, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 10967, 14, 1462, 14, 452, 1252, 1648, 63, 991, 3654, 433, 30066, 297, 283, 1213, 358, 421, 199, 318, 4426, 63, 1073, 8, 1069, 12, 2142, 63, 344, 304, 272, 2142, 275, 10967, 14, 1462, 14, 2416, 63, 509, 63, 873, 1252, 1541, 8, 2051, 29, 1073, 63, 344, 9, 272, 340, 440, 2142, 14, 2444, 837, 267, 746, 4760, 5188, 339, 2142, 14, 873, 8, 433, 30066, 29, 38, 360, 433, 30066, 358, 435, 413, 9, 339, 2142, 275, 2142, 59, 16, 61, 272, 340, 2142, 14, 493, 26, 267, 1166, 275, 2142, 14, 493, 14, 23982, 63, 633, 272, 587, 26, 267, 1166, 275, 2142, 14, 633, 272, 372, 14935, 8, 633, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
juanyaw/python
cpython/Lib/tkinter/tix.py
89
77022
# -*-mode: python; fill-column: 75; tab-width: 8 -*- # # $Id$ # # Tix.py -- Tix widget wrappers. # # For Tix, see http://tix.sourceforge.net # # - Sudhir Shenoy (sshenoy@gol.com), Dec. 1995. # based on an idea of Jean-Marc Lugrin (lugrin@ms.com) # # NOTE: In order to minimize changes to Tkinter.py, some of the code here # (TixWidget.__init__) has been taken from Tkinter (Widget.__init__) # and will break if there are major changes in Tkinter. # # The Tix widgets are represented by a class hierarchy in python with proper # inheritance of base classes. # # As a result after creating a 'w = StdButtonBox', I can write # w.ok['text'] = 'Who Cares' # or w.ok['bg'] = w['bg'] # or even w.ok.invoke() # etc. # # Compare the demo tixwidgets.py to the original Tcl program and you will # appreciate the advantages. # from tkinter import * from tkinter import _cnfmerge, _default_root # WARNING - TkVersion is a limited precision floating point number if TkVersion < 3.999: raise ImportError("This version of Tix.py requires Tk 4.0 or higher") import _tkinter # If this fails your Python may not be configured for Tk # Some more constants (for consistency with Tkinter) WINDOW = 'window' TEXT = 'text' STATUS = 'status' IMMEDIATE = 'immediate' IMAGE = 'image' IMAGETEXT = 'imagetext' BALLOON = 'balloon' AUTO = 'auto' ACROSSTOP = 'acrosstop' # A few useful constants for the Grid widget ASCII = 'ascii' CELL = 'cell' COLUMN = 'column' DECREASING = 'decreasing' INCREASING = 'increasing' INTEGER = 'integer' MAIN = 'main' MAX = 'max' REAL = 'real' ROW = 'row' S_REGION = 's-region' X_REGION = 'x-region' Y_REGION = 'y-region' # Some constants used by Tkinter dooneevent() TCL_DONT_WAIT = 1 << 1 TCL_WINDOW_EVENTS = 1 << 2 TCL_FILE_EVENTS = 1 << 3 TCL_TIMER_EVENTS = 1 << 4 TCL_IDLE_EVENTS = 1 << 5 TCL_ALL_EVENTS = 0 # BEWARE - this is implemented by copying some code from the Widget class # in Tkinter (to override Widget initialization) and is therefore # liable to break. import tkinter, os # Could probably add this to Tkinter.Misc class tixCommand: """The tix commands provide access to miscellaneous elements of Tix's internal state and the Tix application context. Most of the information manipulated by these commands pertains to the application as a whole, or to a screen or display, rather than to a particular window. This is a mixin class, assumed to be mixed to Tkinter.Tk that supports the self.tk.call method. """ def tix_addbitmapdir(self, directory): """Tix maintains a list of directories under which the tix_getimage and tix_getbitmap commands will search for image files. The standard bitmap directory is $TIX_LIBRARY/bitmaps. The addbitmapdir command adds directory into this list. By using this command, the image files of an applications can also be located using the tix_getimage or tix_getbitmap command. """ return self.tk.call('tix', 'addbitmapdir', directory) def tix_cget(self, option): """Returns the current value of the configuration option given by option. Option may be any of the options described in the CONFIGURATION OPTIONS section. """ return self.tk.call('tix', 'cget', option) def tix_configure(self, cnf=None, **kw): """Query or modify the configuration options of the Tix application context. If no option is specified, returns a dictionary all of the available options. If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given option(s) to have the given value(s); in this case the command returns an empty string. Option may be any of the configuration options. """ # Copied from Tkinter.py if kw: cnf = _cnfmerge((cnf, kw)) elif cnf: cnf = _cnfmerge(cnf) if cnf is None: return self._getconfigure('tix', 'configure') if isinstance(cnf, str): return self._getconfigure1('tix', 'configure', '-'+cnf) return self.tk.call(('tix', 'configure') + self._options(cnf)) def tix_filedialog(self, dlgclass=None): """Returns the file selection dialog that may be shared among different calls from this application. This command will create a file selection dialog widget when it is called the first time. This dialog will be returned by all subsequent calls to tix_filedialog. An optional dlgclass parameter can be passed to specified what type of file selection dialog widget is desired. Possible options are tix FileSelectDialog or tixExFileSelectDialog. """ if dlgclass is not None: return self.tk.call('tix', 'filedialog', dlgclass) else: return self.tk.call('tix', 'filedialog') def tix_getbitmap(self, name): """Locates a bitmap file of the name name.xpm or name in one of the bitmap directories (see the tix_addbitmapdir command above). By using tix_getbitmap, you can avoid hard coding the pathnames of the bitmap files in your application. When successful, it returns the complete pathname of the bitmap file, prefixed with the character '@'. The returned value can be used to configure the -bitmap option of the TK and Tix widgets. """ return self.tk.call('tix', 'getbitmap', name) def tix_getimage(self, name): """Locates an image file of the name name.xpm, name.xbm or name.ppm in one of the bitmap directories (see the addbitmapdir command above). If more than one file with the same name (but different extensions) exist, then the image type is chosen according to the depth of the X display: xbm images are chosen on monochrome displays and color images are chosen on color displays. By using tix_ getimage, you can avoid hard coding the pathnames of the image files in your application. When successful, this command returns the name of the newly created image, which can be used to configure the -image option of the Tk and Tix widgets. """ return self.tk.call('tix', 'getimage', name) def tix_option_get(self, name): """Gets the options maintained by the Tix scheme mechanism. Available options include: active_bg active_fg bg bold_font dark1_bg dark1_fg dark2_bg dark2_fg disabled_fg fg fixed_font font inactive_bg inactive_fg input1_bg input2_bg italic_font light1_bg light1_fg light2_bg light2_fg menu_font output1_bg output2_bg select_bg select_fg selector """ # could use self.tk.globalgetvar('tixOption', name) return self.tk.call('tix', 'option', 'get', name) def tix_resetoptions(self, newScheme, newFontSet, newScmPrio=None): """Resets the scheme and fontset of the Tix application to newScheme and newFontSet, respectively. This affects only those widgets created after this call. Therefore, it is best to call the resetoptions command before the creation of any widgets in a Tix application. The optional parameter newScmPrio can be given to reset the priority level of the Tk options set by the Tix schemes. Because of the way Tk handles the X option database, after Tix has been has imported and inited, it is not possible to reset the color schemes and font sets using the tix config command. Instead, the tix_resetoptions command must be used. """ if newScmPrio is not None: return self.tk.call('tix', 'resetoptions', newScheme, newFontSet, newScmPrio) else: return self.tk.call('tix', 'resetoptions', newScheme, newFontSet) class Tk(tkinter.Tk, tixCommand): """Toplevel widget of Tix which represents mostly the main window of an application. It has an associated Tcl interpreter.""" def __init__(self, screenName=None, baseName=None, className='Tix'): tkinter.Tk.__init__(self, screenName, baseName, className) tixlib = os.environ.get('TIX_LIBRARY') self.tk.eval('global auto_path; lappend auto_path [file dir [info nameof]]') if tixlib is not None: self.tk.eval('global auto_path; lappend auto_path {%s}' % tixlib) self.tk.eval('global tcl_pkgPath; lappend tcl_pkgPath {%s}' % tixlib) # Load Tix - this should work dynamically or statically # If it's static, tcl/tix8.1/pkgIndex.tcl should have # 'load {} Tix' # If it's dynamic under Unix, tcl/tix8.1/pkgIndex.tcl should have # 'load libtix8.1.8.3.so Tix' self.tk.eval('package require Tix') def destroy(self): # For safety, remove an delete_window binding before destroy self.protocol("WM_DELETE_WINDOW", "") tkinter.Tk.destroy(self) # The Tix 'tixForm' geometry manager class Form: """The Tix Form geometry manager Widgets can be arranged by specifying attachments to other widgets. See Tix documentation for complete details""" def config(self, cnf={}, **kw): self.tk.call('tixForm', self._w, *self._options(cnf, kw)) form = config def __setitem__(self, key, value): Form.form(self, {key: value}) def check(self): return self.tk.call('tixForm', 'check', self._w) def forget(self): self.tk.call('tixForm', 'forget', self._w) def grid(self, xsize=0, ysize=0): if (not xsize) and (not ysize): x = self.tk.call('tixForm', 'grid', self._w) y = self.tk.splitlist(x) z = () for x in y: z = z + (self.tk.getint(x),) return z return self.tk.call('tixForm', 'grid', self._w, xsize, ysize) def info(self, option=None): if not option: return self.tk.call('tixForm', 'info', self._w) if option[0] != '-': option = '-' + option return self.tk.call('tixForm', 'info', self._w, option) def slaves(self): return [self._nametowidget(x) for x in self.tk.splitlist( self.tk.call( 'tixForm', 'slaves', self._w))] tkinter.Widget.__bases__ = tkinter.Widget.__bases__ + (Form,) class TixWidget(tkinter.Widget): """A TixWidget class is used to package all (or most) Tix widgets. Widget initialization is extended in two ways: 1) It is possible to give a list of options which must be part of the creation command (so called Tix 'static' options). These cannot be given as a 'config' command later. 2) It is possible to give the name of an existing TK widget. These are child widgets created automatically by a Tix mega-widget. The Tk call to create these widgets is therefore bypassed in TixWidget.__init__ Both options are for use by subclasses only. """ def __init__ (self, master=None, widgetName=None, static_options=None, cnf={}, kw={}): # Merge keywords and dictionary arguments if kw: cnf = _cnfmerge((cnf, kw)) else: cnf = _cnfmerge(cnf) # Move static options into extra. static_options must be # a list of keywords (or None). extra=() # 'options' is always a static option if static_options: static_options.append('options') else: static_options = ['options'] for k,v in list(cnf.items()): if k in static_options: extra = extra + ('-' + k, v) del cnf[k] self.widgetName = widgetName Widget._setup(self, master, cnf) # If widgetName is None, this is a dummy creation call where the # corresponding Tk widget has already been created by Tix if widgetName: self.tk.call(widgetName, self._w, *extra) # Non-static options - to be done via a 'config' command if cnf: Widget.config(self, cnf) # Dictionary to hold subwidget names for easier access. We can't # use the children list because the public Tix names may not be the # same as the pathname component self.subwidget_list = {} # We set up an attribute access function so that it is possible to # do w.ok['text'] = 'Hello' rather than w.subwidget('ok')['text'] = 'Hello' # when w is a StdButtonBox. # We can even do w.ok.invoke() because w.ok is subclassed from the # Button class if you go through the proper constructors def __getattr__(self, name): if name in self.subwidget_list: return self.subwidget_list[name] raise AttributeError(name) def set_silent(self, value): """Set a variable without calling its action routine""" self.tk.call('tixSetSilent', self._w, value) def subwidget(self, name): """Return the named subwidget (which must have been created by the sub-class).""" n = self._subwidget_name(name) if not n: raise TclError("Subwidget " + name + " not child of " + self._name) # Remove header of name and leading dot n = n[len(self._w)+1:] return self._nametowidget(n) def subwidgets_all(self): """Return all subwidgets.""" names = self._subwidget_names() if not names: return [] retlist = [] for name in names: name = name[len(self._w)+1:] try: retlist.append(self._nametowidget(name)) except: # some of the widgets are unknown e.g. border in LabelFrame pass return retlist def _subwidget_name(self,name): """Get a subwidget name (returns a String, not a Widget !)""" try: return self.tk.call(self._w, 'subwidget', name) except TclError: return None def _subwidget_names(self): """Return the name of all subwidgets.""" try: x = self.tk.call(self._w, 'subwidgets', '-all') return self.tk.splitlist(x) except TclError: return None def config_all(self, option, value): """Set configuration options for all subwidgets (and self).""" if option == '': return elif not isinstance(option, str): option = repr(option) if not isinstance(value, str): value = repr(value) names = self._subwidget_names() for name in names: self.tk.call(name, 'configure', '-' + option, value) # These are missing from Tkinter def image_create(self, imgtype, cnf={}, master=None, **kw): if not master: master = tkinter._default_root if not master: raise RuntimeError('Too early to create image') if kw and cnf: cnf = _cnfmerge((cnf, kw)) elif kw: cnf = kw options = () for k, v in cnf.items(): if callable(v): v = self._register(v) options = options + ('-'+k, v) return master.tk.call(('image', 'create', imgtype,) + options) def image_delete(self, imgname): try: self.tk.call('image', 'delete', imgname) except TclError: # May happen if the root was destroyed pass # Subwidgets are child widgets created automatically by mega-widgets. # In python, we have to create these subwidgets manually to mirror their # existence in Tk/Tix. class TixSubWidget(TixWidget): """Subwidget class. This is used to mirror child widgets automatically created by Tix/Tk as part of a mega-widget in Python (which is not informed of this)""" def __init__(self, master, name, destroy_physically=1, check_intermediate=1): if check_intermediate: path = master._subwidget_name(name) try: path = path[len(master._w)+1:] plist = path.split('.') except: plist = [] if not check_intermediate: # immediate descendant TixWidget.__init__(self, master, None, None, {'name' : name}) else: # Ensure that the intermediate widgets exist parent = master for i in range(len(plist) - 1): n = '.'.join(plist[:i+1]) try: w = master._nametowidget(n) parent = w except KeyError: # Create the intermediate widget parent = TixSubWidget(parent, plist[i], destroy_physically=0, check_intermediate=0) # The Tk widget name is in plist, not in name if plist: name = plist[-1] TixWidget.__init__(self, parent, None, None, {'name' : name}) self.destroy_physically = destroy_physically def destroy(self): # For some widgets e.g., a NoteBook, when we call destructors, # we must be careful not to destroy the frame widget since this # also destroys the parent NoteBook thus leading to an exception # in Tkinter when it finally calls Tcl to destroy the NoteBook for c in list(self.children.values()): c.destroy() if self._name in self.master.children: del self.master.children[self._name] if self._name in self.master.subwidget_list: del self.master.subwidget_list[self._name] if self.destroy_physically: # This is bypassed only for a few widgets self.tk.call('destroy', self._w) # Useful class to create a display style - later shared by many items. # Contributed by Steffen Kremser class DisplayStyle: """DisplayStyle - handle configuration options shared by (multiple) Display Items""" def __init__(self, itemtype, cnf={}, **kw): master = _default_root # global from Tkinter if not master and 'refwindow' in cnf: master=cnf['refwindow'] elif not master and 'refwindow' in kw: master= kw['refwindow'] elif not master: raise RuntimeError("Too early to create display style: no root window") self.tk = master.tk self.stylename = self.tk.call('tixDisplayStyle', itemtype, *self._options(cnf,kw) ) def __str__(self): return self.stylename def _options(self, cnf, kw): if kw and cnf: cnf = _cnfmerge((cnf, kw)) elif kw: cnf = kw opts = () for k, v in cnf.items(): opts = opts + ('-'+k, v) return opts def delete(self): self.tk.call(self.stylename, 'delete') def __setitem__(self,key,value): self.tk.call(self.stylename, 'configure', '-%s'%key, value) def config(self, cnf={}, **kw): return self._getconfigure( self.stylename, 'configure', *self._options(cnf,kw)) def __getitem__(self,key): return self.tk.call(self.stylename, 'cget', '-%s'%key) ###################################################### ### The Tix Widget classes - in alphabetical order ### ###################################################### class Balloon(TixWidget): """Balloon help widget. Subwidget Class --------- ----- label Label message Message""" # FIXME: It should inherit -superclass tixShell def __init__(self, master=None, cnf={}, **kw): # static seem to be -installcolormap -initwait -statusbar -cursor static = ['options', 'installcolormap', 'initwait', 'statusbar', 'cursor'] TixWidget.__init__(self, master, 'tixBalloon', static, cnf, kw) self.subwidget_list['label'] = _dummyLabel(self, 'label', destroy_physically=0) self.subwidget_list['message'] = _dummyLabel(self, 'message', destroy_physically=0) def bind_widget(self, widget, cnf={}, **kw): """Bind balloon widget to another. One balloon widget may be bound to several widgets at the same time""" self.tk.call(self._w, 'bind', widget._w, *self._options(cnf, kw)) def unbind_widget(self, widget): self.tk.call(self._w, 'unbind', widget._w) class ButtonBox(TixWidget): """ButtonBox - A container for pushbuttons. Subwidgets are the buttons added with the add method. """ def __init__(self, master=None, cnf={}, **kw): TixWidget.__init__(self, master, 'tixButtonBox', ['orientation', 'options'], cnf, kw) def add(self, name, cnf={}, **kw): """Add a button with given name to box.""" btn = self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) self.subwidget_list[name] = _dummyButton(self, name) return btn def invoke(self, name): if name in self.subwidget_list: self.tk.call(self._w, 'invoke', name) class ComboBox(TixWidget): """ComboBox - an Entry field with a dropdown menu. The user can select a choice by either typing in the entry subwidget or selecting from the listbox subwidget. Subwidget Class --------- ----- entry Entry arrow Button slistbox ScrolledListBox tick Button cross Button : present if created with the fancy option""" # FIXME: It should inherit -superclass tixLabelWidget def __init__ (self, master=None, cnf={}, **kw): TixWidget.__init__(self, master, 'tixComboBox', ['editable', 'dropdown', 'fancy', 'options'], cnf, kw) self.subwidget_list['label'] = _dummyLabel(self, 'label') self.subwidget_list['entry'] = _dummyEntry(self, 'entry') self.subwidget_list['arrow'] = _dummyButton(self, 'arrow') self.subwidget_list['slistbox'] = _dummyScrolledListBox(self, 'slistbox') try: self.subwidget_list['tick'] = _dummyButton(self, 'tick') self.subwidget_list['cross'] = _dummyButton(self, 'cross') except TypeError: # unavailable when -fancy not specified pass # align def add_history(self, str): self.tk.call(self._w, 'addhistory', str) def append_history(self, str): self.tk.call(self._w, 'appendhistory', str) def insert(self, index, str): self.tk.call(self._w, 'insert', index, str) def pick(self, index): self.tk.call(self._w, 'pick', index) class Control(TixWidget): """Control - An entry field with value change arrows. The user can adjust the value by pressing the two arrow buttons or by entering the value directly into the entry. The new value will be checked against the user-defined upper and lower limits. Subwidget Class --------- ----- incr Button decr Button entry Entry label Label""" # FIXME: It should inherit -superclass tixLabelWidget def __init__ (self, master=None, cnf={}, **kw): TixWidget.__init__(self, master, 'tixControl', ['options'], cnf, kw) self.subwidget_list['incr'] = _dummyButton(self, 'incr') self.subwidget_list['decr'] = _dummyButton(self, 'decr') self.subwidget_list['label'] = _dummyLabel(self, 'label') self.subwidget_list['entry'] = _dummyEntry(self, 'entry') def decrement(self): self.tk.call(self._w, 'decr') def increment(self): self.tk.call(self._w, 'incr') def invoke(self): self.tk.call(self._w, 'invoke') def update(self): self.tk.call(self._w, 'update') class DirList(TixWidget): """DirList - displays a list view of a directory, its previous directories and its sub-directories. The user can choose one of the directories displayed in the list or change to another directory. Subwidget Class --------- ----- hlist HList hsb Scrollbar vsb Scrollbar""" # FIXME: It should inherit -superclass tixScrolledHList def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixDirList', ['options'], cnf, kw) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') def chdir(self, dir): self.tk.call(self._w, 'chdir', dir) class DirTree(TixWidget): """DirTree - Directory Listing in a hierarchical view. Displays a tree view of a directory, its previous directories and its sub-directories. The user can choose one of the directories displayed in the list or change to another directory. Subwidget Class --------- ----- hlist HList hsb Scrollbar vsb Scrollbar""" # FIXME: It should inherit -superclass tixScrolledHList def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixDirTree', ['options'], cnf, kw) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') def chdir(self, dir): self.tk.call(self._w, 'chdir', dir) class DirSelectBox(TixWidget): """DirSelectBox - Motif style file select box. It is generally used for the user to choose a file. FileSelectBox stores the files mostly recently selected into a ComboBox widget so that they can be quickly selected again. Subwidget Class --------- ----- selection ComboBox filter ComboBox dirlist ScrolledListBox filelist ScrolledListBox""" def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixDirSelectBox', ['options'], cnf, kw) self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist') self.subwidget_list['dircbx'] = _dummyFileComboBox(self, 'dircbx') class ExFileSelectBox(TixWidget): """ExFileSelectBox - MS Windows style file select box. It provides an convenient method for the user to select files. Subwidget Class --------- ----- cancel Button ok Button hidden Checkbutton types ComboBox dir ComboBox file ComboBox dirlist ScrolledListBox filelist ScrolledListBox""" def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixExFileSelectBox', ['options'], cnf, kw) self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') self.subwidget_list['ok'] = _dummyButton(self, 'ok') self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden') self.subwidget_list['types'] = _dummyComboBox(self, 'types') self.subwidget_list['dir'] = _dummyComboBox(self, 'dir') self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist') self.subwidget_list['file'] = _dummyComboBox(self, 'file') self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') def filter(self): self.tk.call(self._w, 'filter') def invoke(self): self.tk.call(self._w, 'invoke') # Should inherit from a Dialog class class DirSelectDialog(TixWidget): """The DirSelectDialog widget presents the directories in the file system in a dialog window. The user can use this dialog window to navigate through the file system to select the desired directory. Subwidgets Class ---------- ----- dirbox DirSelectDialog""" # FIXME: It should inherit -superclass tixDialogShell def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixDirSelectDialog', ['options'], cnf, kw) self.subwidget_list['dirbox'] = _dummyDirSelectBox(self, 'dirbox') # cancel and ok buttons are missing def popup(self): self.tk.call(self._w, 'popup') def popdown(self): self.tk.call(self._w, 'popdown') # Should inherit from a Dialog class class ExFileSelectDialog(TixWidget): """ExFileSelectDialog - MS Windows style file select dialog. It provides an convenient method for the user to select files. Subwidgets Class ---------- ----- fsbox ExFileSelectBox""" # FIXME: It should inherit -superclass tixDialogShell def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixExFileSelectDialog', ['options'], cnf, kw) self.subwidget_list['fsbox'] = _dummyExFileSelectBox(self, 'fsbox') def popup(self): self.tk.call(self._w, 'popup') def popdown(self): self.tk.call(self._w, 'popdown') class FileSelectBox(TixWidget): """ExFileSelectBox - Motif style file select box. It is generally used for the user to choose a file. FileSelectBox stores the files mostly recently selected into a ComboBox widget so that they can be quickly selected again. Subwidget Class --------- ----- selection ComboBox filter ComboBox dirlist ScrolledListBox filelist ScrolledListBox""" def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixFileSelectBox', ['options'], cnf, kw) self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist') self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') self.subwidget_list['filter'] = _dummyComboBox(self, 'filter') self.subwidget_list['selection'] = _dummyComboBox(self, 'selection') def apply_filter(self): # name of subwidget is same as command self.tk.call(self._w, 'filter') def invoke(self): self.tk.call(self._w, 'invoke') # Should inherit from a Dialog class class FileSelectDialog(TixWidget): """FileSelectDialog - Motif style file select dialog. Subwidgets Class ---------- ----- btns StdButtonBox fsbox FileSelectBox""" # FIXME: It should inherit -superclass tixStdDialogShell def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixFileSelectDialog', ['options'], cnf, kw) self.subwidget_list['btns'] = _dummyStdButtonBox(self, 'btns') self.subwidget_list['fsbox'] = _dummyFileSelectBox(self, 'fsbox') def popup(self): self.tk.call(self._w, 'popup') def popdown(self): self.tk.call(self._w, 'popdown') class FileEntry(TixWidget): """FileEntry - Entry field with button that invokes a FileSelectDialog. The user can type in the filename manually. Alternatively, the user can press the button widget that sits next to the entry, which will bring up a file selection dialog. Subwidgets Class ---------- ----- button Button entry Entry""" # FIXME: It should inherit -superclass tixLabelWidget def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixFileEntry', ['dialogtype', 'options'], cnf, kw) self.subwidget_list['button'] = _dummyButton(self, 'button') self.subwidget_list['entry'] = _dummyEntry(self, 'entry') def invoke(self): self.tk.call(self._w, 'invoke') def file_dialog(self): # FIXME: return python object pass class HList(TixWidget, XView, YView): """HList - Hierarchy display widget can be used to display any data that have a hierarchical structure, for example, file system directory trees. The list entries are indented and connected by branch lines according to their places in the hierarchy. Subwidgets - None""" def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixHList', ['columns', 'options'], cnf, kw) def add(self, entry, cnf={}, **kw): return self.tk.call(self._w, 'add', entry, *self._options(cnf, kw)) def add_child(self, parent=None, cnf={}, **kw): if not parent: parent = '' return self.tk.call( self._w, 'addchild', parent, *self._options(cnf, kw)) def anchor_set(self, entry): self.tk.call(self._w, 'anchor', 'set', entry) def anchor_clear(self): self.tk.call(self._w, 'anchor', 'clear') def column_width(self, col=0, width=None, chars=None): if not chars: return self.tk.call(self._w, 'column', 'width', col, width) else: return self.tk.call(self._w, 'column', 'width', col, '-char', chars) def delete_all(self): self.tk.call(self._w, 'delete', 'all') def delete_entry(self, entry): self.tk.call(self._w, 'delete', 'entry', entry) def delete_offsprings(self, entry): self.tk.call(self._w, 'delete', 'offsprings', entry) def delete_siblings(self, entry): self.tk.call(self._w, 'delete', 'siblings', entry) def dragsite_set(self, index): self.tk.call(self._w, 'dragsite', 'set', index) def dragsite_clear(self): self.tk.call(self._w, 'dragsite', 'clear') def dropsite_set(self, index): self.tk.call(self._w, 'dropsite', 'set', index) def dropsite_clear(self): self.tk.call(self._w, 'dropsite', 'clear') def header_create(self, col, cnf={}, **kw): self.tk.call(self._w, 'header', 'create', col, *self._options(cnf, kw)) def header_configure(self, col, cnf={}, **kw): if cnf is None: return self._getconfigure(self._w, 'header', 'configure', col) self.tk.call(self._w, 'header', 'configure', col, *self._options(cnf, kw)) def header_cget(self, col, opt): return self.tk.call(self._w, 'header', 'cget', col, opt) def header_exists(self, col): return self.tk.call(self._w, 'header', 'exists', col) def header_delete(self, col): self.tk.call(self._w, 'header', 'delete', col) def header_size(self, col): return self.tk.call(self._w, 'header', 'size', col) def hide_entry(self, entry): self.tk.call(self._w, 'hide', 'entry', entry) def indicator_create(self, entry, cnf={}, **kw): self.tk.call( self._w, 'indicator', 'create', entry, *self._options(cnf, kw)) def indicator_configure(self, entry, cnf={}, **kw): if cnf is None: return self._getconfigure( self._w, 'indicator', 'configure', entry) self.tk.call( self._w, 'indicator', 'configure', entry, *self._options(cnf, kw)) def indicator_cget(self, entry, opt): return self.tk.call(self._w, 'indicator', 'cget', entry, opt) def indicator_exists(self, entry): return self.tk.call (self._w, 'indicator', 'exists', entry) def indicator_delete(self, entry): self.tk.call(self._w, 'indicator', 'delete', entry) def indicator_size(self, entry): return self.tk.call(self._w, 'indicator', 'size', entry) def info_anchor(self): return self.tk.call(self._w, 'info', 'anchor') def info_bbox(self, entry): return self._getints( self.tk.call(self._w, 'info', 'bbox', entry)) or None def info_children(self, entry=None): c = self.tk.call(self._w, 'info', 'children', entry) return self.tk.splitlist(c) def info_data(self, entry): return self.tk.call(self._w, 'info', 'data', entry) def info_dragsite(self): return self.tk.call(self._w, 'info', 'dragsite') def info_dropsite(self): return self.tk.call(self._w, 'info', 'dropsite') def info_exists(self, entry): return self.tk.call(self._w, 'info', 'exists', entry) def info_hidden(self, entry): return self.tk.call(self._w, 'info', 'hidden', entry) def info_next(self, entry): return self.tk.call(self._w, 'info', 'next', entry) def info_parent(self, entry): return self.tk.call(self._w, 'info', 'parent', entry) def info_prev(self, entry): return self.tk.call(self._w, 'info', 'prev', entry) def info_selection(self): c = self.tk.call(self._w, 'info', 'selection') return self.tk.splitlist(c) def item_cget(self, entry, col, opt): return self.tk.call(self._w, 'item', 'cget', entry, col, opt) def item_configure(self, entry, col, cnf={}, **kw): if cnf is None: return self._getconfigure(self._w, 'item', 'configure', entry, col) self.tk.call(self._w, 'item', 'configure', entry, col, *self._options(cnf, kw)) def item_create(self, entry, col, cnf={}, **kw): self.tk.call( self._w, 'item', 'create', entry, col, *self._options(cnf, kw)) def item_exists(self, entry, col): return self.tk.call(self._w, 'item', 'exists', entry, col) def item_delete(self, entry, col): self.tk.call(self._w, 'item', 'delete', entry, col) def entrycget(self, entry, opt): return self.tk.call(self._w, 'entrycget', entry, opt) def entryconfigure(self, entry, cnf={}, **kw): if cnf is None: return self._getconfigure(self._w, 'entryconfigure', entry) self.tk.call(self._w, 'entryconfigure', entry, *self._options(cnf, kw)) def nearest(self, y): return self.tk.call(self._w, 'nearest', y) def see(self, entry): self.tk.call(self._w, 'see', entry) def selection_clear(self, cnf={}, **kw): self.tk.call(self._w, 'selection', 'clear', *self._options(cnf, kw)) def selection_includes(self, entry): return self.tk.call(self._w, 'selection', 'includes', entry) def selection_set(self, first, last=None): self.tk.call(self._w, 'selection', 'set', first, last) def show_entry(self, entry): return self.tk.call(self._w, 'show', 'entry', entry) class InputOnly(TixWidget): """InputOnly - Invisible widget. Unix only. Subwidgets - None""" def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixInputOnly', None, cnf, kw) class LabelEntry(TixWidget): """LabelEntry - Entry field with label. Packages an entry widget and a label into one mega widget. It can beused be used to simplify the creation of ``entry-form'' type of interface. Subwidgets Class ---------- ----- label Label entry Entry""" def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixLabelEntry', ['labelside','options'], cnf, kw) self.subwidget_list['label'] = _dummyLabel(self, 'label') self.subwidget_list['entry'] = _dummyEntry(self, 'entry') class LabelFrame(TixWidget): """LabelFrame - Labelled Frame container. Packages a frame widget and a label into one mega widget. To create widgets inside a LabelFrame widget, one creates the new widgets relative to the frame subwidget and manage them inside the frame subwidget. Subwidgets Class ---------- ----- label Label frame Frame""" def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixLabelFrame', ['labelside','options'], cnf, kw) self.subwidget_list['label'] = _dummyLabel(self, 'label') self.subwidget_list['frame'] = _dummyFrame(self, 'frame') class ListNoteBook(TixWidget): """A ListNoteBook widget is very similar to the TixNoteBook widget: it can be used to display many windows in a limited space using a notebook metaphor. The notebook is divided into a stack of pages (windows). At one time only one of these pages can be shown. The user can navigate through these pages by choosing the name of the desired page in the hlist subwidget.""" def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixListNoteBook', ['options'], cnf, kw) # Is this necessary? It's not an exposed subwidget in Tix. self.subwidget_list['pane'] = _dummyPanedWindow(self, 'pane', destroy_physically=0) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['shlist'] = _dummyScrolledHList(self, 'shlist') def add(self, name, cnf={}, **kw): self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) self.subwidget_list[name] = TixSubWidget(self, name) return self.subwidget_list[name] def page(self, name): return self.subwidget(name) def pages(self): # Can't call subwidgets_all directly because we don't want .nbframe names = self.tk.split(self.tk.call(self._w, 'pages')) ret = [] for x in names: ret.append(self.subwidget(x)) return ret def raise_page(self, name): # raise is a python keyword self.tk.call(self._w, 'raise', name) class Meter(TixWidget): """The Meter widget can be used to show the progress of a background job which may take a long time to execute. """ def __init__(self, master=None, cnf={}, **kw): TixWidget.__init__(self, master, 'tixMeter', ['options'], cnf, kw) class NoteBook(TixWidget): """NoteBook - Multi-page container widget (tabbed notebook metaphor). Subwidgets Class ---------- ----- nbframe NoteBookFrame <pages> page widgets added dynamically with the add method""" def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self,master,'tixNoteBook', ['options'], cnf, kw) self.subwidget_list['nbframe'] = TixSubWidget(self, 'nbframe', destroy_physically=0) def add(self, name, cnf={}, **kw): self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) self.subwidget_list[name] = TixSubWidget(self, name) return self.subwidget_list[name] def delete(self, name): self.tk.call(self._w, 'delete', name) self.subwidget_list[name].destroy() del self.subwidget_list[name] def page(self, name): return self.subwidget(name) def pages(self): # Can't call subwidgets_all directly because we don't want .nbframe names = self.tk.split(self.tk.call(self._w, 'pages')) ret = [] for x in names: ret.append(self.subwidget(x)) return ret def raise_page(self, name): # raise is a python keyword self.tk.call(self._w, 'raise', name) def raised(self): return self.tk.call(self._w, 'raised') class NoteBookFrame(TixWidget): # FIXME: This is dangerous to expose to be called on its own. pass class OptionMenu(TixWidget): """OptionMenu - creates a menu button of options. Subwidget Class --------- ----- menubutton Menubutton menu Menu""" def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixOptionMenu', ['options'], cnf, kw) self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton') self.subwidget_list['menu'] = _dummyMenu(self, 'menu') def add_command(self, name, cnf={}, **kw): self.tk.call(self._w, 'add', 'command', name, *self._options(cnf, kw)) def add_separator(self, name, cnf={}, **kw): self.tk.call(self._w, 'add', 'separator', name, *self._options(cnf, kw)) def delete(self, name): self.tk.call(self._w, 'delete', name) def disable(self, name): self.tk.call(self._w, 'disable', name) def enable(self, name): self.tk.call(self._w, 'enable', name) class PanedWindow(TixWidget): """PanedWindow - Multi-pane container widget allows the user to interactively manipulate the sizes of several panes. The panes can be arranged either vertically or horizontally.The user changes the sizes of the panes by dragging the resize handle between two panes. Subwidgets Class ---------- ----- <panes> g/p widgets added dynamically with the add method.""" def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixPanedWindow', ['orientation', 'options'], cnf, kw) # add delete forget panecget paneconfigure panes setsize def add(self, name, cnf={}, **kw): self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) self.subwidget_list[name] = TixSubWidget(self, name, check_intermediate=0) return self.subwidget_list[name] def delete(self, name): self.tk.call(self._w, 'delete', name) self.subwidget_list[name].destroy() del self.subwidget_list[name] def forget(self, name): self.tk.call(self._w, 'forget', name) def panecget(self, entry, opt): return self.tk.call(self._w, 'panecget', entry, opt) def paneconfigure(self, entry, cnf={}, **kw): if cnf is None: return self._getconfigure(self._w, 'paneconfigure', entry) self.tk.call(self._w, 'paneconfigure', entry, *self._options(cnf, kw)) def panes(self): names = self.tk.splitlist(self.tk.call(self._w, 'panes')) return [self.subwidget(x) for x in names] class PopupMenu(TixWidget): """PopupMenu widget can be used as a replacement of the tk_popup command. The advantage of the Tix PopupMenu widget is it requires less application code to manipulate. Subwidgets Class ---------- ----- menubutton Menubutton menu Menu""" # FIXME: It should inherit -superclass tixShell def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixPopupMenu', ['options'], cnf, kw) self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton') self.subwidget_list['menu'] = _dummyMenu(self, 'menu') def bind_widget(self, widget): self.tk.call(self._w, 'bind', widget._w) def unbind_widget(self, widget): self.tk.call(self._w, 'unbind', widget._w) def post_widget(self, widget, x, y): self.tk.call(self._w, 'post', widget._w, x, y) class ResizeHandle(TixWidget): """Internal widget to draw resize handles on Scrolled widgets.""" def __init__(self, master, cnf={}, **kw): # There seems to be a Tix bug rejecting the configure method # Let's try making the flags -static flags = ['options', 'command', 'cursorfg', 'cursorbg', 'handlesize', 'hintcolor', 'hintwidth', 'x', 'y'] # In fact, x y height width are configurable TixWidget.__init__(self, master, 'tixResizeHandle', flags, cnf, kw) def attach_widget(self, widget): self.tk.call(self._w, 'attachwidget', widget._w) def detach_widget(self, widget): self.tk.call(self._w, 'detachwidget', widget._w) def hide(self, widget): self.tk.call(self._w, 'hide', widget._w) def show(self, widget): self.tk.call(self._w, 'show', widget._w) class ScrolledHList(TixWidget): """ScrolledHList - HList with automatic scrollbars.""" # FIXME: It should inherit -superclass tixScrolledWidget def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledHList', ['options'], cnf, kw) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') class ScrolledListBox(TixWidget): """ScrolledListBox - Listbox with automatic scrollbars.""" # FIXME: It should inherit -superclass tixScrolledWidget def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledListBox', ['options'], cnf, kw) self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') class ScrolledText(TixWidget): """ScrolledText - Text with automatic scrollbars.""" # FIXME: It should inherit -superclass tixScrolledWidget def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledText', ['options'], cnf, kw) self.subwidget_list['text'] = _dummyText(self, 'text') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') class ScrolledTList(TixWidget): """ScrolledTList - TList with automatic scrollbars.""" # FIXME: It should inherit -superclass tixScrolledWidget def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledTList', ['options'], cnf, kw) self.subwidget_list['tlist'] = _dummyTList(self, 'tlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') class ScrolledWindow(TixWidget): """ScrolledWindow - Window with automatic scrollbars.""" # FIXME: It should inherit -superclass tixScrolledWidget def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledWindow', ['options'], cnf, kw) self.subwidget_list['window'] = _dummyFrame(self, 'window') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') class Select(TixWidget): """Select - Container of button subwidgets. It can be used to provide radio-box or check-box style of selection options for the user. Subwidgets are buttons added dynamically using the add method.""" # FIXME: It should inherit -superclass tixLabelWidget def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixSelect', ['allowzero', 'radio', 'orientation', 'labelside', 'options'], cnf, kw) self.subwidget_list['label'] = _dummyLabel(self, 'label') def add(self, name, cnf={}, **kw): self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) self.subwidget_list[name] = _dummyButton(self, name) return self.subwidget_list[name] def invoke(self, name): self.tk.call(self._w, 'invoke', name) class Shell(TixWidget): """Toplevel window. Subwidgets - None""" def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixShell', ['options', 'title'], cnf, kw) class DialogShell(TixWidget): """Toplevel window, with popup popdown and center methods. It tells the window manager that it is a dialog window and should be treated specially. The exact treatment depends on the treatment of the window manager. Subwidgets - None""" # FIXME: It should inherit from Shell def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixDialogShell', ['options', 'title', 'mapped', 'minheight', 'minwidth', 'parent', 'transient'], cnf, kw) def popdown(self): self.tk.call(self._w, 'popdown') def popup(self): self.tk.call(self._w, 'popup') def center(self): self.tk.call(self._w, 'center') class StdButtonBox(TixWidget): """StdButtonBox - Standard Button Box (OK, Apply, Cancel and Help) """ def __init__(self, master=None, cnf={}, **kw): TixWidget.__init__(self, master, 'tixStdButtonBox', ['orientation', 'options'], cnf, kw) self.subwidget_list['ok'] = _dummyButton(self, 'ok') self.subwidget_list['apply'] = _dummyButton(self, 'apply') self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') self.subwidget_list['help'] = _dummyButton(self, 'help') def invoke(self, name): if name in self.subwidget_list: self.tk.call(self._w, 'invoke', name) class TList(TixWidget, XView, YView): """TList - Hierarchy display widget which can be used to display data in a tabular format. The list entries of a TList widget are similar to the entries in the Tk listbox widget. The main differences are (1) the TList widget can display the list entries in a two dimensional format and (2) you can use graphical images as well as multiple colors and fonts for the list entries. Subwidgets - None""" def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixTList', ['options'], cnf, kw) def active_set(self, index): self.tk.call(self._w, 'active', 'set', index) def active_clear(self): self.tk.call(self._w, 'active', 'clear') def anchor_set(self, index): self.tk.call(self._w, 'anchor', 'set', index) def anchor_clear(self): self.tk.call(self._w, 'anchor', 'clear') def delete(self, from_, to=None): self.tk.call(self._w, 'delete', from_, to) def dragsite_set(self, index): self.tk.call(self._w, 'dragsite', 'set', index) def dragsite_clear(self): self.tk.call(self._w, 'dragsite', 'clear') def dropsite_set(self, index): self.tk.call(self._w, 'dropsite', 'set', index) def dropsite_clear(self): self.tk.call(self._w, 'dropsite', 'clear') def insert(self, index, cnf={}, **kw): self.tk.call(self._w, 'insert', index, *self._options(cnf, kw)) def info_active(self): return self.tk.call(self._w, 'info', 'active') def info_anchor(self): return self.tk.call(self._w, 'info', 'anchor') def info_down(self, index): return self.tk.call(self._w, 'info', 'down', index) def info_left(self, index): return self.tk.call(self._w, 'info', 'left', index) def info_right(self, index): return self.tk.call(self._w, 'info', 'right', index) def info_selection(self): c = self.tk.call(self._w, 'info', 'selection') return self.tk.splitlist(c) def info_size(self): return self.tk.call(self._w, 'info', 'size') def info_up(self, index): return self.tk.call(self._w, 'info', 'up', index) def nearest(self, x, y): return self.tk.call(self._w, 'nearest', x, y) def see(self, index): self.tk.call(self._w, 'see', index) def selection_clear(self, cnf={}, **kw): self.tk.call(self._w, 'selection', 'clear', *self._options(cnf, kw)) def selection_includes(self, index): return self.tk.call(self._w, 'selection', 'includes', index) def selection_set(self, first, last=None): self.tk.call(self._w, 'selection', 'set', first, last) class Tree(TixWidget): """Tree - The tixTree widget can be used to display hierarchical data in a tree form. The user can adjust the view of the tree by opening or closing parts of the tree.""" # FIXME: It should inherit -superclass tixScrolledWidget def __init__(self, master=None, cnf={}, **kw): TixWidget.__init__(self, master, 'tixTree', ['options'], cnf, kw) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') def autosetmode(self): '''This command calls the setmode method for all the entries in this Tree widget: if an entry has no child entries, its mode is set to none. Otherwise, if the entry has any hidden child entries, its mode is set to open; otherwise its mode is set to close.''' self.tk.call(self._w, 'autosetmode') def close(self, entrypath): '''Close the entry given by entryPath if its mode is close.''' self.tk.call(self._w, 'close', entrypath) def getmode(self, entrypath): '''Returns the current mode of the entry given by entryPath.''' return self.tk.call(self._w, 'getmode', entrypath) def open(self, entrypath): '''Open the entry given by entryPath if its mode is open.''' self.tk.call(self._w, 'open', entrypath) def setmode(self, entrypath, mode='none'): '''This command is used to indicate whether the entry given by entryPath has children entries and whether the children are visible. mode must be one of open, close or none. If mode is set to open, a (+) indicator is drawn next the entry. If mode is set to close, a (-) indicator is drawn next the entry. If mode is set to none, no indicators will be drawn for this entry. The default mode is none. The open mode indicates the entry has hidden children and this entry can be opened by the user. The close mode indicates that all the children of the entry are now visible and the entry can be closed by the user.''' self.tk.call(self._w, 'setmode', entrypath, mode) # Could try subclassing Tree for CheckList - would need another arg to init class CheckList(TixWidget): """The CheckList widget displays a list of items to be selected by the user. CheckList acts similarly to the Tk checkbutton or radiobutton widgets, except it is capable of handling many more items than checkbuttons or radiobuttons. """ # FIXME: It should inherit -superclass tixTree def __init__(self, master=None, cnf={}, **kw): TixWidget.__init__(self, master, 'tixCheckList', ['options', 'radio'], cnf, kw) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') def autosetmode(self): '''This command calls the setmode method for all the entries in this Tree widget: if an entry has no child entries, its mode is set to none. Otherwise, if the entry has any hidden child entries, its mode is set to open; otherwise its mode is set to close.''' self.tk.call(self._w, 'autosetmode') def close(self, entrypath): '''Close the entry given by entryPath if its mode is close.''' self.tk.call(self._w, 'close', entrypath) def getmode(self, entrypath): '''Returns the current mode of the entry given by entryPath.''' return self.tk.call(self._w, 'getmode', entrypath) def open(self, entrypath): '''Open the entry given by entryPath if its mode is open.''' self.tk.call(self._w, 'open', entrypath) def getselection(self, mode='on'): '''Returns a list of items whose status matches status. If status is not specified, the list of items in the "on" status will be returned. Mode can be on, off, default''' c = self.tk.split(self.tk.call(self._w, 'getselection', mode)) return self.tk.splitlist(c) def getstatus(self, entrypath): '''Returns the current status of entryPath.''' return self.tk.call(self._w, 'getstatus', entrypath) def setstatus(self, entrypath, mode='on'): '''Sets the status of entryPath to be status. A bitmap will be displayed next to the entry its status is on, off or default.''' self.tk.call(self._w, 'setstatus', entrypath, mode) ########################################################################### ### The subclassing below is used to instantiate the subwidgets in each ### ### mega widget. This allows us to access their methods directly. ### ########################################################################### class _dummyButton(Button, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyCheckbutton(Checkbutton, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyEntry(Entry, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyFrame(Frame, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyLabel(Label, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyListbox(Listbox, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyMenu(Menu, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyMenubutton(Menubutton, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyScrollbar(Scrollbar, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyText(Text, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyScrolledListBox(ScrolledListBox, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') class _dummyHList(HList, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyScrolledHList(ScrolledHList, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') class _dummyTList(TList, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyComboBox(ComboBox, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, ['fancy',destroy_physically]) self.subwidget_list['label'] = _dummyLabel(self, 'label') self.subwidget_list['entry'] = _dummyEntry(self, 'entry') self.subwidget_list['arrow'] = _dummyButton(self, 'arrow') self.subwidget_list['slistbox'] = _dummyScrolledListBox(self, 'slistbox') try: self.subwidget_list['tick'] = _dummyButton(self, 'tick') #cross Button : present if created with the fancy option self.subwidget_list['cross'] = _dummyButton(self, 'cross') except TypeError: # unavailable when -fancy not specified pass class _dummyDirList(DirList, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') class _dummyDirSelectBox(DirSelectBox, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist') self.subwidget_list['dircbx'] = _dummyFileComboBox(self, 'dircbx') class _dummyExFileSelectBox(ExFileSelectBox, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') self.subwidget_list['ok'] = _dummyButton(self, 'ok') self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden') self.subwidget_list['types'] = _dummyComboBox(self, 'types') self.subwidget_list['dir'] = _dummyComboBox(self, 'dir') self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist') self.subwidget_list['file'] = _dummyComboBox(self, 'file') self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') class _dummyFileSelectBox(FileSelectBox, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist') self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') self.subwidget_list['filter'] = _dummyComboBox(self, 'filter') self.subwidget_list['selection'] = _dummyComboBox(self, 'selection') class _dummyFileComboBox(ComboBox, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) self.subwidget_list['dircbx'] = _dummyComboBox(self, 'dircbx') class _dummyStdButtonBox(StdButtonBox, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) self.subwidget_list['ok'] = _dummyButton(self, 'ok') self.subwidget_list['apply'] = _dummyButton(self, 'apply') self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') self.subwidget_list['help'] = _dummyButton(self, 'help') class _dummyNoteBookFrame(NoteBookFrame, TixSubWidget): def __init__(self, master, name, destroy_physically=0): TixSubWidget.__init__(self, master, name, destroy_physically) class _dummyPanedWindow(PanedWindow, TixSubWidget): def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically) ######################## ### Utility Routines ### ######################## #mike Should tixDestroy be exposed as a wrapper? - but not for widgets. def OptionName(widget): '''Returns the qualified path name for the widget. Normally used to set default options for subwidgets. See tixwidgets.py''' return widget.tk.call('tixOptionName', widget._w) # Called with a dictionary argument of the form # {'*.c':'C source files', '*.txt':'Text Files', '*':'All files'} # returns a string which can be used to configure the fsbox file types # in an ExFileSelectBox. i.e., # '{{*} {* - All files}} {{*.c} {*.c - C source files}} {{*.txt} {*.txt - Text Files}}' def FileTypeList(dict): s = '' for type in dict.keys(): s = s + '{{' + type + '} {' + type + ' - ' + dict[type] + '}} ' return s # Still to be done: # tixIconView class CObjView(TixWidget): """This file implements the Canvas Object View widget. This is a base class of IconView. It implements automatic placement/adjustment of the scrollbars according to the canvas objects inside the canvas subwidget. The scrollbars are adjusted so that the canvas is just large enough to see all the objects. """ # FIXME: It should inherit -superclass tixScrolledWidget pass class Grid(TixWidget, XView, YView): '''The Tix Grid command creates a new window and makes it into a tixGrid widget. Additional options, may be specified on the command line or in the option database to configure aspects such as its cursor and relief. A Grid widget displays its contents in a two dimensional grid of cells. Each cell may contain one Tix display item, which may be in text, graphics or other formats. See the DisplayStyle class for more information about Tix display items. Individual cells, or groups of cells, can be formatted with a wide range of attributes, such as its color, relief and border. Subwidgets - None''' # valid specific resources as of Tk 8.4 # editdonecmd, editnotifycmd, floatingcols, floatingrows, formatcmd, # highlightbackground, highlightcolor, leftmargin, itemtype, selectmode, # selectunit, topmargin, def __init__(self, master=None, cnf={}, **kw): static= [] self.cnf= cnf TixWidget.__init__(self, master, 'tixGrid', static, cnf, kw) # valid options as of Tk 8.4 # anchor, bdtype, cget, configure, delete, dragsite, dropsite, entrycget, # edit, entryconfigure, format, geometryinfo, info, index, move, nearest, # selection, set, size, unset, xview, yview def anchor_clear(self): """Removes the selection anchor.""" self.tk.call(self, 'anchor', 'clear') def anchor_get(self): "Get the (x,y) coordinate of the current anchor cell" return self._getints(self.tk.call(self, 'anchor', 'get')) def anchor_set(self, x, y): """Set the selection anchor to the cell at (x, y).""" self.tk.call(self, 'anchor', 'set', x, y) def delete_row(self, from_, to=None): """Delete rows between from_ and to inclusive. If to is not provided, delete only row at from_""" if to is None: self.tk.call(self, 'delete', 'row', from_) else: self.tk.call(self, 'delete', 'row', from_, to) def delete_column(self, from_, to=None): """Delete columns between from_ and to inclusive. If to is not provided, delete only column at from_""" if to is None: self.tk.call(self, 'delete', 'column', from_) else: self.tk.call(self, 'delete', 'column', from_, to) def edit_apply(self): """If any cell is being edited, de-highlight the cell and applies the changes.""" self.tk.call(self, 'edit', 'apply') def edit_set(self, x, y): """Highlights the cell at (x, y) for editing, if the -editnotify command returns True for this cell.""" self.tk.call(self, 'edit', 'set', x, y) def entrycget(self, x, y, option): "Get the option value for cell at (x,y)" if option and option[0] != '-': option = '-' + option return self.tk.call(self, 'entrycget', x, y, option) def entryconfigure(self, x, y, cnf=None, **kw): return self._configure(('entryconfigure', x, y), cnf, kw) # def format # def index def info_exists(self, x, y): "Return True if display item exists at (x,y)" return self._getboolean(self.tk.call(self, 'info', 'exists', x, y)) def info_bbox(self, x, y): # This seems to always return '', at least for 'text' displayitems return self.tk.call(self, 'info', 'bbox', x, y) def move_column(self, from_, to, offset): """Moves the range of columns from position FROM through TO by the distance indicated by OFFSET. For example, move_column(2, 4, 1) moves the columns 2,3,4 to columns 3,4,5.""" self.tk.call(self, 'move', 'column', from_, to, offset) def move_row(self, from_, to, offset): """Moves the range of rows from position FROM through TO by the distance indicated by OFFSET. For example, move_row(2, 4, 1) moves the rows 2,3,4 to rows 3,4,5.""" self.tk.call(self, 'move', 'row', from_, to, offset) def nearest(self, x, y): "Return coordinate of cell nearest pixel coordinate (x,y)" return self._getints(self.tk.call(self, 'nearest', x, y)) # def selection adjust # def selection clear # def selection includes # def selection set # def selection toggle def set(self, x, y, itemtype=None, **kw): args= self._options(self.cnf, kw) if itemtype is not None: args= ('-itemtype', itemtype) + args self.tk.call(self, 'set', x, y, *args) def size_column(self, index, **kw): """Queries or sets the size of the column given by INDEX. INDEX may be any non-negative integer that gives the position of a given column. INDEX can also be the string "default"; in this case, this command queries or sets the default size of all columns. When no option-value pair is given, this command returns a tuple containing the current size setting of the given column. When option-value pairs are given, the corresponding options of the size setting of the given column are changed. Options may be one of the follwing: pad0 pixels Specifies the paddings to the left of a column. pad1 pixels Specifies the paddings to the right of a column. size val Specifies the width of a column. Val may be: "auto" -- the width of the column is set to the width of the widest cell in the column; a valid Tk screen distance unit; or a real number following by the word chars (e.g. 3.4chars) that sets the width of the column to the given number of characters.""" return self.tk.split(self.tk.call(self._w, 'size', 'column', index, *self._options({}, kw))) def size_row(self, index, **kw): """Queries or sets the size of the row given by INDEX. INDEX may be any non-negative integer that gives the position of a given row . INDEX can also be the string "default"; in this case, this command queries or sets the default size of all rows. When no option-value pair is given, this command returns a list con- taining the current size setting of the given row . When option-value pairs are given, the corresponding options of the size setting of the given row are changed. Options may be one of the follwing: pad0 pixels Specifies the paddings to the top of a row. pad1 pixels Specifies the paddings to the bottom of a row. size val Specifies the height of a row. Val may be: "auto" -- the height of the row is set to the height of the highest cell in the row; a valid Tk screen distance unit; or a real number following by the word chars (e.g. 3.4chars) that sets the height of the row to the given number of characters.""" return self.tk.split(self.tk.call( self, 'size', 'row', index, *self._options({}, kw))) def unset(self, x, y): """Clears the cell at (x, y) by removing its display item.""" self.tk.call(self._w, 'unset', x, y) class ScrolledGrid(Grid): '''Scrolled Grid widgets''' # FIXME: It should inherit -superclass tixScrolledWidget def __init__(self, master=None, cnf={}, **kw): static= [] self.cnf= cnf TixWidget.__init__(self, master, 'tixScrolledGrid', static, cnf, kw)
bsd-3-clause
[ 3, 1882, 632, 26, 2366, 27, 5554, 13, 2301, 26, 13098, 27, 5174, 13, 2063, 26, 1695, 1882, 199, 3, 199, 3, 2672, 1304, 4, 199, 3, 199, 3, 25984, 14, 647, 1553, 25984, 3938, 17995, 14, 199, 3, 199, 3, 755, 2104, 25984, 12, 1937, 1455, 921, 31625, 14, 22943, 14, 846, 199, 3, 199, 3, 755, 446, 428, 1181, 72, 723, 5244, 287, 79, 89, 334, 5510, 287, 79, 89, 32, 71, 393, 14, 957, 395, 13966, 14, 9013, 21, 14, 199, 3, 260, 4079, 641, 376, 16819, 402, 1603, 69, 290, 13, 45, 9912, 491, 1518, 24667, 334, 32047, 24667, 32, 706, 14, 957, 9, 199, 3, 199, 3, 6944, 26, 1010, 1865, 370, 24720, 4493, 370, 16826, 14, 647, 12, 2005, 402, 314, 1233, 2348, 199, 3, 755, 334, 30167, 3339, 855, 826, 3368, 965, 2757, 9394, 687, 16826, 334, 3339, 855, 826, 3368, 199, 3, 755, 436, 911, 2059, 340, 2337, 787, 12160, 4493, 315, 16826, 14, 199, 3, 199, 3, 710, 25984, 11114, 787, 11159, 701, 282, 1021, 14446, 315, 2366, 543, 5576, 199, 3, 15433, 402, 1300, 3992, 14, 199, 3, 199, 3, 3709, 282, 754, 2410, 6425, 282, 283, 87, 275, 20992, 4259, 3532, 297, 473, 883, 2218, 199, 3, 4519, 336, 14, 745, 459, 505, 418, 275, 283, 55, 526, 8790, 470, 7, 199, 3, 259, 503, 4519, 336, 14, 745, 459, 6856, 418, 275, 336, 459, 6856, 418, 199, 3, 503, 2755, 755, 336, 14, 745, 14, 15195, 342, 199, 3, 5423, 14, 199, 3, 199, 3, 18955, 314, 14779, 3367, 88, 8583, 14, 647, 370, 314, 3379, 29251, 2240, 436, 1265, 911, 199, 3, 2771, 20940, 323, 314, 19396, 867, 7441, 14, 199, 3, 199, 199, 504, 22171, 492, 627, 199, 504, 22171, 492, 485, 23600, 5628, 12, 485, 885, 63, 1231, 199, 199, 3, 14750, 446, 12435, 3353, 365, 282, 13988, 7151, 8402, 2376, 1329, 199, 692, 12435, 3353, 665, 650, 14, 5637, 26, 272, 746, 3545, 480, 2765, 1015, 402, 25984, 14, 647, 5074, 12435, 841, 14, 16, 503, 10948, 531, 199, 199, 646, 485, 12223, 327, 982, 642, 6918, 2195, 2018, 1443, 440, 506, 7526, 367, 12435, 199, 199, 3, 6601, 1655, 5262, 334, 509, 17754, 543, 16826, 9, 199, 15480, 275, 283, 3806, 7, 199, 3876, 275, 283, 505, 7, 199, 6305, 275, 283, 1205, 7, 199, 1469, 19464, 275, 283, 20250, 7, 199, 9438, 275, 283, 1569, 7, 199, 1469, 1254, 775, 2472, 275, 283, 1569, 505, 7, 199, 31232, 1484, 615, 275, 283, 4982, 27734, 7, 199, 13883, 275, 283, 2495, 7, 199, 1348, 1092, 51, 11632, 275, 283, 645, 4796, 2379, 7, 199, 199, 3, 437, 9284, 2997, 5262, 367, 314, 16386, 3938, 199, 12292, 275, 283, 4371, 7, 199, 26474, 275, 283, 3890, 7, 199, 21436, 275, 283, 2301, 7, 199, 1093, 5798, 1179, 1206, 275, 283, 271, 19877, 7, 199, 568, 5798, 1179, 1206, 275, 283, 262, 19877, 7, 199, 9596, 275, 283, 4115, 7, 199, 5848, 275, 283, 973, 7, 199, 4283, 275, 283, 988, 7, 199, 15508, 275, 283, 3093, 7, 199, 11415, 275, 283, 1143, 7, 199, 51, 63, 23030, 275, 283, 83, 13, 4551, 7, 199, 56, 63, 23030, 275, 283, 88, 13, 4551, 7, 199, 57, 63, 23030, 275, 283, 89, 13, 4551, 7, 199, 199, 3, 6601, 5262, 1202, 701, 16826, 886, 368, 1430, 342, 199, 52, 1981, 63, 31874, 63, 12458, 258, 275, 413, 5213, 413, 199, 52, 1981, 63, 15480, 63, 8193, 51, 275, 413, 5213, 499, 199, 52, 1981, 63, 3817, 63, 8193, 51, 257, 275, 413, 5213, 650, 199, 52, 1981, 63, 29108, 63, 8193, 51, 221, 275, 413, 5213, 841, 199, 52, 1981, 63, 23715, 63, 8193, 51, 257, 275, 413, 5213, 959, 199, 52, 1981, 63, 1761, 63, 8193, 51, 259, 275, 378, 199, 199, 3, 6262, 3695, 446, 642, 365, 6366, 701, 16743, 2005, 1233, 687, 314, 16905, 1021, 199, 3, 3515, 315, 16826, 334, 475, 4278, 16905, 11097, 9, 436, 365, 16119, 199, 3, 3515, 1212, 461, 370, 2059, 14, 199, 646, 22171, 12, 747, 199, 199, 3, 18615, 8646, 1050, 642, 370, 16826, 14, 29926, 199, 533, 3367, 88, 3110, 26, 272, 408, 1918, 3367, 88, 3718, 5647, 2879, 370, 3201, 19549, 221, 4008, 272, 402, 221, 25984, 1159, 221, 5007, 1174, 436, 314, 25984, 4223, 1067, 14, 272, 17536, 402, 314, 2556, 13335, 8097, 701, 3520, 221, 3718, 1126, 3953, 272, 370, 221, 314, 221, 4223, 221, 465, 282, 8852, 12, 503, 370, 282, 6426, 503, 272, 2929, 12, 7830, 2419, 370, 282, 6770, 4353, 14, 339, 961, 365, 282, 20048, 1021, 12, 10826, 370, 506, 13492, 370, 16826, 14, 15189, 272, 626, 5171, 314, 291, 14, 2663, 14, 1250, 1083, 14, 272, 408, 339, 347, 3367, 88, 63, 525, 20299, 694, 8, 277, 12, 2082, 304, 267, 408, 30167, 11075, 83, 282, 769, 402, 6602, 1334, 1314, 267, 314, 221, 3367, 88, 63, 303, 280, 960, 221, 436, 3367, 88, 63, 362, 20299, 3718, 911, 267, 2754, 367, 1834, 1584, 14, 710, 4465, 20810, 221, 2082, 267, 365, 2672, 52, 3867, 63, 16983, 15, 2075, 8919, 14, 710, 1050, 20299, 694, 1414, 267, 9584, 2082, 1901, 642, 769, 14, 4885, 221, 1808, 221, 642, 267, 1414, 12, 314, 221, 1834, 221, 1584, 221, 402, 376, 13103, 883, 267, 2597, 506, 16180, 1808, 314, 3367, 88, 63, 303, 280, 960, 503, 3367, 88, 63, 362, 20299, 267, 1414, 14, 267, 408, 267, 372, 291, 14, 2663, 14, 1250, 360, 31625, 297, 283, 525, 20299, 694, 297, 2082, 9, 339, 347, 3367, 88, 63, 67, 362, 8, 277, 12, 945, 304, 267, 408, 3407, 221, 314, 221, 1453, 221, 574, 221, 402, 314, 2897, 267, 945, 1627, 701, 945, 14, 3207, 1443, 506, 221, 1263, 221, 402, 221, 314, 267, 1511, 11736, 315, 314, 15869, 15301, 23860, 3420, 14, 267, 408, 267, 372, 291, 14, 2663, 14, 1250, 360, 31625, 297, 283, 67, 362, 297, 945, 9, 339, 347, 3367, 88, 63, 6472, 8, 277, 12, 19062, 29, 403, 12, 1011, 829, 304, 267, 408, 3227, 503, 2811, 314, 2897, 1511, 402, 314, 25984, 4223, 267, 1067, 14, 982 ]
[ 1882, 632, 26, 2366, 27, 5554, 13, 2301, 26, 13098, 27, 5174, 13, 2063, 26, 1695, 1882, 199, 3, 199, 3, 2672, 1304, 4, 199, 3, 199, 3, 25984, 14, 647, 1553, 25984, 3938, 17995, 14, 199, 3, 199, 3, 755, 2104, 25984, 12, 1937, 1455, 921, 31625, 14, 22943, 14, 846, 199, 3, 199, 3, 755, 446, 428, 1181, 72, 723, 5244, 287, 79, 89, 334, 5510, 287, 79, 89, 32, 71, 393, 14, 957, 395, 13966, 14, 9013, 21, 14, 199, 3, 260, 4079, 641, 376, 16819, 402, 1603, 69, 290, 13, 45, 9912, 491, 1518, 24667, 334, 32047, 24667, 32, 706, 14, 957, 9, 199, 3, 199, 3, 6944, 26, 1010, 1865, 370, 24720, 4493, 370, 16826, 14, 647, 12, 2005, 402, 314, 1233, 2348, 199, 3, 755, 334, 30167, 3339, 855, 826, 3368, 965, 2757, 9394, 687, 16826, 334, 3339, 855, 826, 3368, 199, 3, 755, 436, 911, 2059, 340, 2337, 787, 12160, 4493, 315, 16826, 14, 199, 3, 199, 3, 710, 25984, 11114, 787, 11159, 701, 282, 1021, 14446, 315, 2366, 543, 5576, 199, 3, 15433, 402, 1300, 3992, 14, 199, 3, 199, 3, 3709, 282, 754, 2410, 6425, 282, 283, 87, 275, 20992, 4259, 3532, 297, 473, 883, 2218, 199, 3, 4519, 336, 14, 745, 459, 505, 418, 275, 283, 55, 526, 8790, 470, 7, 199, 3, 259, 503, 4519, 336, 14, 745, 459, 6856, 418, 275, 336, 459, 6856, 418, 199, 3, 503, 2755, 755, 336, 14, 745, 14, 15195, 342, 199, 3, 5423, 14, 199, 3, 199, 3, 18955, 314, 14779, 3367, 88, 8583, 14, 647, 370, 314, 3379, 29251, 2240, 436, 1265, 911, 199, 3, 2771, 20940, 323, 314, 19396, 867, 7441, 14, 199, 3, 199, 199, 504, 22171, 492, 627, 199, 504, 22171, 492, 485, 23600, 5628, 12, 485, 885, 63, 1231, 199, 199, 3, 14750, 446, 12435, 3353, 365, 282, 13988, 7151, 8402, 2376, 1329, 199, 692, 12435, 3353, 665, 650, 14, 5637, 26, 272, 746, 3545, 480, 2765, 1015, 402, 25984, 14, 647, 5074, 12435, 841, 14, 16, 503, 10948, 531, 199, 199, 646, 485, 12223, 327, 982, 642, 6918, 2195, 2018, 1443, 440, 506, 7526, 367, 12435, 199, 199, 3, 6601, 1655, 5262, 334, 509, 17754, 543, 16826, 9, 199, 15480, 275, 283, 3806, 7, 199, 3876, 275, 283, 505, 7, 199, 6305, 275, 283, 1205, 7, 199, 1469, 19464, 275, 283, 20250, 7, 199, 9438, 275, 283, 1569, 7, 199, 1469, 1254, 775, 2472, 275, 283, 1569, 505, 7, 199, 31232, 1484, 615, 275, 283, 4982, 27734, 7, 199, 13883, 275, 283, 2495, 7, 199, 1348, 1092, 51, 11632, 275, 283, 645, 4796, 2379, 7, 199, 199, 3, 437, 9284, 2997, 5262, 367, 314, 16386, 3938, 199, 12292, 275, 283, 4371, 7, 199, 26474, 275, 283, 3890, 7, 199, 21436, 275, 283, 2301, 7, 199, 1093, 5798, 1179, 1206, 275, 283, 271, 19877, 7, 199, 568, 5798, 1179, 1206, 275, 283, 262, 19877, 7, 199, 9596, 275, 283, 4115, 7, 199, 5848, 275, 283, 973, 7, 199, 4283, 275, 283, 988, 7, 199, 15508, 275, 283, 3093, 7, 199, 11415, 275, 283, 1143, 7, 199, 51, 63, 23030, 275, 283, 83, 13, 4551, 7, 199, 56, 63, 23030, 275, 283, 88, 13, 4551, 7, 199, 57, 63, 23030, 275, 283, 89, 13, 4551, 7, 199, 199, 3, 6601, 5262, 1202, 701, 16826, 886, 368, 1430, 342, 199, 52, 1981, 63, 31874, 63, 12458, 258, 275, 413, 5213, 413, 199, 52, 1981, 63, 15480, 63, 8193, 51, 275, 413, 5213, 499, 199, 52, 1981, 63, 3817, 63, 8193, 51, 257, 275, 413, 5213, 650, 199, 52, 1981, 63, 29108, 63, 8193, 51, 221, 275, 413, 5213, 841, 199, 52, 1981, 63, 23715, 63, 8193, 51, 257, 275, 413, 5213, 959, 199, 52, 1981, 63, 1761, 63, 8193, 51, 259, 275, 378, 199, 199, 3, 6262, 3695, 446, 642, 365, 6366, 701, 16743, 2005, 1233, 687, 314, 16905, 1021, 199, 3, 3515, 315, 16826, 334, 475, 4278, 16905, 11097, 9, 436, 365, 16119, 199, 3, 3515, 1212, 461, 370, 2059, 14, 199, 646, 22171, 12, 747, 199, 199, 3, 18615, 8646, 1050, 642, 370, 16826, 14, 29926, 199, 533, 3367, 88, 3110, 26, 272, 408, 1918, 3367, 88, 3718, 5647, 2879, 370, 3201, 19549, 221, 4008, 272, 402, 221, 25984, 1159, 221, 5007, 1174, 436, 314, 25984, 4223, 1067, 14, 272, 17536, 402, 314, 2556, 13335, 8097, 701, 3520, 221, 3718, 1126, 3953, 272, 370, 221, 314, 221, 4223, 221, 465, 282, 8852, 12, 503, 370, 282, 6426, 503, 272, 2929, 12, 7830, 2419, 370, 282, 6770, 4353, 14, 339, 961, 365, 282, 20048, 1021, 12, 10826, 370, 506, 13492, 370, 16826, 14, 15189, 272, 626, 5171, 314, 291, 14, 2663, 14, 1250, 1083, 14, 272, 408, 339, 347, 3367, 88, 63, 525, 20299, 694, 8, 277, 12, 2082, 304, 267, 408, 30167, 11075, 83, 282, 769, 402, 6602, 1334, 1314, 267, 314, 221, 3367, 88, 63, 303, 280, 960, 221, 436, 3367, 88, 63, 362, 20299, 3718, 911, 267, 2754, 367, 1834, 1584, 14, 710, 4465, 20810, 221, 2082, 267, 365, 2672, 52, 3867, 63, 16983, 15, 2075, 8919, 14, 710, 1050, 20299, 694, 1414, 267, 9584, 2082, 1901, 642, 769, 14, 4885, 221, 1808, 221, 642, 267, 1414, 12, 314, 221, 1834, 221, 1584, 221, 402, 376, 13103, 883, 267, 2597, 506, 16180, 1808, 314, 3367, 88, 63, 303, 280, 960, 503, 3367, 88, 63, 362, 20299, 267, 1414, 14, 267, 408, 267, 372, 291, 14, 2663, 14, 1250, 360, 31625, 297, 283, 525, 20299, 694, 297, 2082, 9, 339, 347, 3367, 88, 63, 67, 362, 8, 277, 12, 945, 304, 267, 408, 3407, 221, 314, 221, 1453, 221, 574, 221, 402, 314, 2897, 267, 945, 1627, 701, 945, 14, 3207, 1443, 506, 221, 1263, 221, 402, 221, 314, 267, 1511, 11736, 315, 314, 15869, 15301, 23860, 3420, 14, 267, 408, 267, 372, 291, 14, 2663, 14, 1250, 360, 31625, 297, 283, 67, 362, 297, 945, 9, 339, 347, 3367, 88, 63, 6472, 8, 277, 12, 19062, 29, 403, 12, 1011, 829, 304,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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 ]
zutshi/S3CAMR
src/nonlinprog/pyfmincon.py
1
3601
from __future__ import absolute_import from __future__ import division from __future__ import unicode_literals import numpy as np import sympy as sym import functools as ft import atexit from pymatopt.optimmatlab import init, deinit, fmincon from utils import print import nonlinprog.spec as spec import settings init() atexit.register(deinit) def nlinprog(obj, cons, Vars, mode='cons'): """nlinprog Parameters ---------- obj : cons : Returns ------- Notes ------ """ if mode == 'cons': return cons_opt(obj, cons, Vars) elif mode == 'uncons': return uncons_opt(obj, cons, Vars) else: raise NotImplementedError def uncons_opt(obj, cons, Vars): assert(obj == 0) # else can't tell if the opt was successfull for c in cons: assert(isinstance(c, sym.LessThan)) assert(c.rhs == 0) obj += c.lhs**2 x0 = np.zeros(len(Vars)) retcode, res_x, res_f = call_fmincon(Vars, obj, [], x0) print('res_f:', res_f) print('retcode:', retcode) success = res_f <= 0 return spec.OPTRES(res_f, res_x, 'OK', success) def cons_opt(obj, cons, Vars): # def debugf(f, e, x): # y = f(*x) # print(x, ':', e.args[0] <= 0, ':', f(*x)) # print(e.args[0] <= 0, ':', f(*x)) # return y # Must pass l as an arguement, else late binding will make sure # that all functions are the same: the last one #cons_f = tuple(lambda x, l=l: l(*x) for l in lambdafied) #cons_f = tuple(ft.partial(debugf, l, e) for l, e in zip(lambdafied, cons)) x0 = np.zeros(len(Vars)) #retcode, res_x, res_f = fmincon(obj_f, x0, A=[], B=[], C=cons_f) retcode, res_x, res_f = call_fmincon(Vars, obj, cons, x0) print('retcode:', retcode) return spec.OPTRES(res_f, res_x, 'OK', retcode == 0) def call_fmincon(Vars, obj, cons, x0): cons = list(cons) # The below constraint encoding assumes all cons # (constraint exprs) are of the form f(x) <= 0 for c in cons: assert(isinstance(c, sym.LessThan)) assert(c.rhs == 0) def eval_expr(f, x): y = f(*x) #print(x, ':', e.args[0] <= 0, ':', f(*x)) #print(e.args[0] <= 0, ':', f(*x)) return y obj_f = ft.partial(eval_expr, sym.lambdify(Vars, obj, str('numpy'))) cons_f = tuple(ft.partial(eval_expr, sym.lambdify(Vars, c.args[0], str('numpy'))) for c in cons) return fmincon(obj_f, x0, A=[], B=[], C=cons_f) def example(): import time # simple test function def banana(x): term1 = 100.0 * (x[1] - x[0]**2.0) ** 2.0 term2 = (1.0 - x[0])**2.0 return term1 + term2 # example non linear constraint def nonlincon(x): return x[0]**2 - x[1]**2 ti = time.time() init() print('init time: {}'.format(time.time() - ti)) ti = time.time() x, fval = fmincon(banana, [1.99, 1.55], A=[1.99, 1.55], B=[1.5], C=[nonlincon]) print('1st solve time: {}'.format(time.time() - ti)) ti = time.time() x, fval = fmincon(banana, [1.99, 1.55], A=[1.99, 1.55], B=[1.5], C=[nonlincon]) print('2nd solve time: {}'.format(time.time() - ti)) ti = time.time() x, fval = fmincon(banana, [1.99, 1.55], A=[1.99, 1.55], B=[1.5], C=[nonlincon]) print('3rd solve time: {}'.format(time.time() - ti)) ti = time.time() x, fval = fmincon(banana, [1.99, 1.55], A=[1.99, 1.55], B=[1.5], C=[nonlincon]) print('4th solve time: {}'.format(time.time() - ti)) ti = time.time() deinit() print('de-init time: {}'.format(time.time() - ti))
bsd-2-clause
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2680, 465, 980, 199, 646, 5840, 465, 4678, 199, 646, 9143, 465, 18133, 199, 646, 19840, 199, 199, 504, 1134, 569, 2992, 14, 6433, 569, 5561, 492, 4205, 12, 477, 826, 12, 289, 827, 388, 199, 504, 3778, 492, 870, 199, 199, 646, 2222, 472, 6595, 14, 1650, 465, 3158, 199, 646, 2202, 421, 199, 826, 342, 199, 24026, 390, 14, 2683, 8, 271, 826, 9, 421, 199, 318, 302, 472, 6595, 8, 1113, 12, 13447, 12, 812, 4291, 12, 818, 534, 8704, 735, 272, 408, 78, 472, 6595, 339, 3897, 272, 4143, 272, 1559, 520, 272, 13447, 520, 339, 1803, 272, 5514, 339, 8144, 272, 21397, 272, 408, 272, 340, 818, 508, 283, 8704, 356, 267, 372, 13447, 63, 2992, 8, 1113, 12, 13447, 12, 812, 4291, 9, 272, 916, 818, 508, 283, 324, 8704, 356, 267, 372, 625, 8704, 63, 2992, 8, 1113, 12, 13447, 12, 812, 4291, 9, 272, 587, 26, 267, 746, 4279, 421, 199, 318, 625, 8704, 63, 2992, 8, 1113, 12, 13447, 12, 812, 4291, 304, 272, 702, 8, 1113, 508, 378, 9, 327, 587, 883, 1133, 11480, 340, 314, 2450, 1990, 3182, 2861, 272, 367, 286, 315, 13447, 26, 267, 702, 8, 6074, 8, 67, 12, 4678, 14, 32693, 430, 267, 702, 8, 67, 14, 12071, 508, 378, 9, 267, 1559, 847, 286, 14, 12697, 538, 18, 339, 671, 16, 275, 980, 14, 4250, 8, 552, 8, 16270, 430, 339, 17375, 12, 522, 63, 88, 12, 522, 63, 70, 275, 1240, 63, 70, 827, 388, 8, 16270, 12, 1559, 12, 990, 671, 16, 9, 272, 870, 360, 470, 63, 70, 6536, 522, 63, 70, 9, 272, 870, 360, 27523, 6536, 17375, 9, 339, 3182, 275, 522, 63, 70, 2695, 378, 339, 372, 3158, 14, 1938, 1766, 654, 8, 470, 63, 70, 12, 522, 63, 88, 12, 283, 3593, 297, 3182, 9, 421, 199, 318, 13447, 63, 2992, 8, 1113, 12, 13447, 12, 812, 4291, 304, 199, 199, 3, 258, 347, 3105, 70, 8, 70, 12, 325, 12, 671, 304, 199, 3, 260, 612, 275, 289, 2031, 88, 9, 199, 3, 260, 870, 8, 88, 12, 25475, 325, 14, 589, 59, 16, 61, 2695, 378, 12, 25475, 289, 2031, 88, 430, 199, 3, 260, 870, 8, 69, 14, 589, 59, 16, 61, 2695, 378, 12, 25475, 289, 2031, 88, 430, 199, 3, 260, 372, 612, 339, 327, 9498, 986, 634, 465, 376, 1680, 310, 434, 12, 587, 2465, 11696, 911, 1852, 3238, 272, 327, 626, 1006, 3423, 787, 314, 2011, 26, 314, 2061, 1373, 272, 327, 8704, 63, 70, 275, 2008, 8, 2734, 671, 12, 634, 29, 76, 26, 634, 2031, 88, 9, 367, 634, 315, 2400, 1290, 9, 272, 327, 8704, 63, 70, 275, 2008, 8, 856, 14, 6672, 8, 1757, 70, 12, 634, 12, 325, 9, 367, 634, 12, 325, 315, 3482, 8, 2734, 1290, 12, 13447, 430, 339, 671, 16, 275, 980, 14, 4250, 8, 552, 8, 16270, 430, 339, 327, 27523, 12, 522, 63, 88, 12, 522, 63, 70, 275, 289, 827, 388, 8, 1113, 63, 70, 12, 671, 16, 12, 437, 6034, 699, 6034, 445, 29, 8704, 63, 70, 9, 272, 17375, 12, 522, 63, 88, 12, 522, 63, 70, 275, 1240, 63, 70, 827, 388, 8, 16270, 12, 1559, 12, 13447, 12, 671, 16, 9, 272, 870, 360, 27523, 6536, 17375, 9, 339, 372, 3158, 14, 1938, 1766, 654, 8, 470, 63, 70, 12, 522, 63, 88, 12, 283, 3593, 297, 17375, 508, 378, 9, 421, 199, 318, 1240, 63, 70, 827, 388, 8, 16270, 12, 1559, 12, 13447, 12, 671, 16, 304, 339, 13447, 275, 769, 8, 8704, 9, 339, 327, 710, 5084, 5828, 2644, 15194, 1006, 13447, 272, 327, 334, 5631, 23770, 9, 787, 402, 314, 1824, 289, 8, 88, 9, 2695, 378, 272, 367, 286, 315, 13447, 26, 267, 702, 8, 6074, 8, 67, 12, 4678, 14, 32693, 430, 267, 702, 8, 67, 14, 12071, 508, 378, 9, 339, 347, 3468, 63, 3684, 8, 70, 12, 671, 304, 267, 612, 275, 289, 2031, 88, 9, 267, 327, 1361, 8, 88, 12, 25475, 325, 14, 589, 59, 16, 61, 2695, 378, 12, 25475, 289, 2031, 88, 430, 267, 327, 1361, 8, 69, 14, 589, 59, 16, 61, 2695, 378, 12, 25475, 289, 2031, 88, 430, 267, 372, 612, 339, 1559, 63, 70, 275, 18133, 14, 6672, 8, 2579, 63, 3684, 12, 4678, 14, 416, 887, 29552, 8, 16270, 12, 1559, 12, 620, 360, 4714, 7058, 272, 13447, 63, 70, 275, 2008, 8, 856, 14, 6672, 8, 2579, 63, 3684, 12, 4678, 14, 416, 887, 29552, 8, 16270, 12, 286, 14, 589, 59, 16, 467, 620, 360, 4714, 7058, 367, 286, 315, 13447, 9, 272, 372, 289, 827, 388, 8, 1113, 63, 70, 12, 671, 16, 12, 437, 6034, 699, 6034, 445, 29, 8704, 63, 70, 9, 421, 199, 318, 2893, 837, 272, 492, 900, 339, 327, 3486, 511, 805, 272, 347, 30354, 6738, 8, 88, 304, 267, 6707, 17, 275, 2948, 14, 16, 627, 334, 88, 59, 17, 61, 446, 671, 59, 16, 24186, 18, 14, 16, 9, 1011, 499, 14, 16, 267, 6707, 18, 275, 334, 17, 14, 16, 446, 671, 59, 16, 566, 538, 18, 14, 16, 267, 372, 6707, 17, 435, 6707, 18, 339, 327, 2893, 2222, 7798, 5828, 272, 347, 2222, 472, 388, 8, 88, 304, 267, 372, 671, 59, 16, 24186, 18, 446, 671, 59, 17, 24186, 18, 339, 3367, 275, 900, 14, 521, 342, 272, 4205, 342, 272, 870, 360, 826, 900, 26, 9499, 908, 8, 521, 14, 521, 342, 446, 3367, 430, 339, 3367, 275, 900, 14, 521, 342, 272, 671, 12, 289, 637, 275, 289, 827, 388, 8, 13206, 6738, 12, 359, 17, 14, 1020, 12, 413, 14, 1229, 467, 437, 1524, 17, 14, 1020, 12, 413, 14, 1229, 467, 699, 1524, 17, 14, 21, 467, 445, 1524, 2865, 472, 388, 566, 272, 870, 360, 17, 270, 14241, 900, 26, 9499, 908, 8, 521, 14, 521, 342, 446, 3367, 430, 339, 3367, 275, 900, 14 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2680, 465, 980, 199, 646, 5840, 465, 4678, 199, 646, 9143, 465, 18133, 199, 646, 19840, 199, 199, 504, 1134, 569, 2992, 14, 6433, 569, 5561, 492, 4205, 12, 477, 826, 12, 289, 827, 388, 199, 504, 3778, 492, 870, 199, 199, 646, 2222, 472, 6595, 14, 1650, 465, 3158, 199, 646, 2202, 421, 199, 826, 342, 199, 24026, 390, 14, 2683, 8, 271, 826, 9, 421, 199, 318, 302, 472, 6595, 8, 1113, 12, 13447, 12, 812, 4291, 12, 818, 534, 8704, 735, 272, 408, 78, 472, 6595, 339, 3897, 272, 4143, 272, 1559, 520, 272, 13447, 520, 339, 1803, 272, 5514, 339, 8144, 272, 21397, 272, 408, 272, 340, 818, 508, 283, 8704, 356, 267, 372, 13447, 63, 2992, 8, 1113, 12, 13447, 12, 812, 4291, 9, 272, 916, 818, 508, 283, 324, 8704, 356, 267, 372, 625, 8704, 63, 2992, 8, 1113, 12, 13447, 12, 812, 4291, 9, 272, 587, 26, 267, 746, 4279, 421, 199, 318, 625, 8704, 63, 2992, 8, 1113, 12, 13447, 12, 812, 4291, 304, 272, 702, 8, 1113, 508, 378, 9, 327, 587, 883, 1133, 11480, 340, 314, 2450, 1990, 3182, 2861, 272, 367, 286, 315, 13447, 26, 267, 702, 8, 6074, 8, 67, 12, 4678, 14, 32693, 430, 267, 702, 8, 67, 14, 12071, 508, 378, 9, 267, 1559, 847, 286, 14, 12697, 538, 18, 339, 671, 16, 275, 980, 14, 4250, 8, 552, 8, 16270, 430, 339, 17375, 12, 522, 63, 88, 12, 522, 63, 70, 275, 1240, 63, 70, 827, 388, 8, 16270, 12, 1559, 12, 990, 671, 16, 9, 272, 870, 360, 470, 63, 70, 6536, 522, 63, 70, 9, 272, 870, 360, 27523, 6536, 17375, 9, 339, 3182, 275, 522, 63, 70, 2695, 378, 339, 372, 3158, 14, 1938, 1766, 654, 8, 470, 63, 70, 12, 522, 63, 88, 12, 283, 3593, 297, 3182, 9, 421, 199, 318, 13447, 63, 2992, 8, 1113, 12, 13447, 12, 812, 4291, 304, 199, 199, 3, 258, 347, 3105, 70, 8, 70, 12, 325, 12, 671, 304, 199, 3, 260, 612, 275, 289, 2031, 88, 9, 199, 3, 260, 870, 8, 88, 12, 25475, 325, 14, 589, 59, 16, 61, 2695, 378, 12, 25475, 289, 2031, 88, 430, 199, 3, 260, 870, 8, 69, 14, 589, 59, 16, 61, 2695, 378, 12, 25475, 289, 2031, 88, 430, 199, 3, 260, 372, 612, 339, 327, 9498, 986, 634, 465, 376, 1680, 310, 434, 12, 587, 2465, 11696, 911, 1852, 3238, 272, 327, 626, 1006, 3423, 787, 314, 2011, 26, 314, 2061, 1373, 272, 327, 8704, 63, 70, 275, 2008, 8, 2734, 671, 12, 634, 29, 76, 26, 634, 2031, 88, 9, 367, 634, 315, 2400, 1290, 9, 272, 327, 8704, 63, 70, 275, 2008, 8, 856, 14, 6672, 8, 1757, 70, 12, 634, 12, 325, 9, 367, 634, 12, 325, 315, 3482, 8, 2734, 1290, 12, 13447, 430, 339, 671, 16, 275, 980, 14, 4250, 8, 552, 8, 16270, 430, 339, 327, 27523, 12, 522, 63, 88, 12, 522, 63, 70, 275, 289, 827, 388, 8, 1113, 63, 70, 12, 671, 16, 12, 437, 6034, 699, 6034, 445, 29, 8704, 63, 70, 9, 272, 17375, 12, 522, 63, 88, 12, 522, 63, 70, 275, 1240, 63, 70, 827, 388, 8, 16270, 12, 1559, 12, 13447, 12, 671, 16, 9, 272, 870, 360, 27523, 6536, 17375, 9, 339, 372, 3158, 14, 1938, 1766, 654, 8, 470, 63, 70, 12, 522, 63, 88, 12, 283, 3593, 297, 17375, 508, 378, 9, 421, 199, 318, 1240, 63, 70, 827, 388, 8, 16270, 12, 1559, 12, 13447, 12, 671, 16, 304, 339, 13447, 275, 769, 8, 8704, 9, 339, 327, 710, 5084, 5828, 2644, 15194, 1006, 13447, 272, 327, 334, 5631, 23770, 9, 787, 402, 314, 1824, 289, 8, 88, 9, 2695, 378, 272, 367, 286, 315, 13447, 26, 267, 702, 8, 6074, 8, 67, 12, 4678, 14, 32693, 430, 267, 702, 8, 67, 14, 12071, 508, 378, 9, 339, 347, 3468, 63, 3684, 8, 70, 12, 671, 304, 267, 612, 275, 289, 2031, 88, 9, 267, 327, 1361, 8, 88, 12, 25475, 325, 14, 589, 59, 16, 61, 2695, 378, 12, 25475, 289, 2031, 88, 430, 267, 327, 1361, 8, 69, 14, 589, 59, 16, 61, 2695, 378, 12, 25475, 289, 2031, 88, 430, 267, 372, 612, 339, 1559, 63, 70, 275, 18133, 14, 6672, 8, 2579, 63, 3684, 12, 4678, 14, 416, 887, 29552, 8, 16270, 12, 1559, 12, 620, 360, 4714, 7058, 272, 13447, 63, 70, 275, 2008, 8, 856, 14, 6672, 8, 2579, 63, 3684, 12, 4678, 14, 416, 887, 29552, 8, 16270, 12, 286, 14, 589, 59, 16, 467, 620, 360, 4714, 7058, 367, 286, 315, 13447, 9, 272, 372, 289, 827, 388, 8, 1113, 63, 70, 12, 671, 16, 12, 437, 6034, 699, 6034, 445, 29, 8704, 63, 70, 9, 421, 199, 318, 2893, 837, 272, 492, 900, 339, 327, 3486, 511, 805, 272, 347, 30354, 6738, 8, 88, 304, 267, 6707, 17, 275, 2948, 14, 16, 627, 334, 88, 59, 17, 61, 446, 671, 59, 16, 24186, 18, 14, 16, 9, 1011, 499, 14, 16, 267, 6707, 18, 275, 334, 17, 14, 16, 446, 671, 59, 16, 566, 538, 18, 14, 16, 267, 372, 6707, 17, 435, 6707, 18, 339, 327, 2893, 2222, 7798, 5828, 272, 347, 2222, 472, 388, 8, 88, 304, 267, 372, 671, 59, 16, 24186, 18, 446, 671, 59, 17, 24186, 18, 339, 3367, 275, 900, 14, 521, 342, 272, 4205, 342, 272, 870, 360, 826, 900, 26, 9499, 908, 8, 521, 14, 521, 342, 446, 3367, 430, 339, 3367, 275, 900, 14, 521, 342, 272, 671, 12, 289, 637, 275, 289, 827, 388, 8, 13206, 6738, 12, 359, 17, 14, 1020, 12, 413, 14, 1229, 467, 437, 1524, 17, 14, 1020, 12, 413, 14, 1229, 467, 699, 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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 ]
jemekite/p2pool-deepcoin
SOAPpy/SOAPBuilder.py
289
22852
""" ################################################################################ # Copyright (c) 2003, Pfizer # Copyright (c) 2001, Cayce Ullman. # Copyright (c) 2001, Brian Matthews. # # 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 actzero, 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 REGENTS 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. # ################################################################################ """ ident = '$Id: SOAPBuilder.py 1498 2010-03-12 02:13:19Z pooryorick $' from version import __version__ import cgi from wstools.XMLname import toXMLname, fromXMLname import fpconst # SOAPpy modules from Config import Config from NS import NS from Types import * # Test whether this Python version has Types.BooleanType # If it doesn't have it, then False and True are serialized as integers try: BooleanType pythonHasBooleanType = 1 except NameError: pythonHasBooleanType = 0 ################################################################################ # SOAP Builder ################################################################################ class SOAPBuilder: _xml_top = '<?xml version="1.0"?>\n' _xml_enc_top = '<?xml version="1.0" encoding="%s"?>\n' _env_top = ( '%(ENV_T)s:Envelope\n' + \ ' %(ENV_T)s:encodingStyle="%(ENC)s"\n' ) % \ NS.__dict__ _env_bot = '</%(ENV_T)s:Envelope>\n' % NS.__dict__ # Namespaces potentially defined in the Envelope tag. _env_ns = {NS.ENC: NS.ENC_T, NS.ENV: NS.ENV_T, NS.XSD: NS.XSD_T, NS.XSD2: NS.XSD2_T, NS.XSD3: NS.XSD3_T, NS.XSI: NS.XSI_T, NS.XSI2: NS.XSI2_T, NS.XSI3: NS.XSI3_T} def __init__(self, args = (), kw = {}, method = None, namespace = None, header = None, methodattrs = None, envelope = 1, encoding = 'UTF-8', use_refs = 0, config = Config, noroot = 0): # Test the encoding, raising an exception if it's not known if encoding != None: ''.encode(encoding) self.args = args self.kw = kw self.envelope = envelope self.encoding = encoding self.method = method self.namespace = namespace self.header = header self.methodattrs= methodattrs self.use_refs = use_refs self.config = config self.out = [] self.tcounter = 0 self.ncounter = 1 self.icounter = 1 self.envns = {} self.ids = {} self.depth = 0 self.multirefs = [] self.multis = 0 self.body = not isinstance(args, bodyType) self.noroot = noroot def build(self): if Config.debug: print "In build." ns_map = {} # Cache whether typing is on or not typed = self.config.typed if self.header: # Create a header. self.dump(self.header, "Header", typed = typed) #self.header = None # Wipe it out so no one is using it. if self.body: # Call genns to record that we've used SOAP-ENV. self.depth += 1 body_ns = self.genns(ns_map, NS.ENV)[0] self.out.append("<%sBody>\n" % body_ns) if self.method: # Save the NS map so that it can be restored when we # fall out of the scope of the method definition save_ns_map = ns_map.copy() self.depth += 1 a = '' if self.methodattrs: for (k, v) in self.methodattrs.items(): a += ' %s="%s"' % (k, v) if self.namespace: # Use the namespace info handed to us methodns, n = self.genns(ns_map, self.namespace) else: methodns, n = '', '' self.out.append('<%s%s%s%s%s>\n' % ( methodns, self.method, n, a, self.genroot(ns_map))) try: if type(self.args) != TupleType: args = (self.args,) else: args = self.args for i in args: self.dump(i, typed = typed, ns_map = ns_map) if hasattr(self.config, "argsOrdering") and self.config.argsOrdering.has_key(self.method): for k in self.config.argsOrdering.get(self.method): self.dump(self.kw.get(k), k, typed = typed, ns_map = ns_map) else: for (k, v) in self.kw.items(): self.dump(v, k, typed = typed, ns_map = ns_map) except RecursionError: if self.use_refs == 0: # restart b = SOAPBuilder(args = self.args, kw = self.kw, method = self.method, namespace = self.namespace, header = self.header, methodattrs = self.methodattrs, envelope = self.envelope, encoding = self.encoding, use_refs = 1, config = self.config) return b.build() raise if self.method: self.out.append("</%s%s>\n" % (methodns, self.method)) # End of the method definition; drop any local namespaces ns_map = save_ns_map self.depth -= 1 if self.body: # dump may add to self.multirefs, but the for loop will keep # going until it has used all of self.multirefs, even those # entries added while in the loop. self.multis = 1 for obj, tag in self.multirefs: self.dump(obj, tag, typed = typed, ns_map = ns_map) self.out.append("</%sBody>\n" % body_ns) self.depth -= 1 if self.envelope: e = map (lambda ns: ' xmlns:%s="%s"\n' % (ns[1], ns[0]), self.envns.items()) self.out = ['<', self._env_top] + e + ['>\n'] + \ self.out + \ [self._env_bot] if self.encoding != None: self.out.insert(0, self._xml_enc_top % self.encoding) return ''.join(self.out).encode(self.encoding) self.out.insert(0, self._xml_top) return ''.join(self.out) def gentag(self): if Config.debug: print "In gentag." self.tcounter += 1 return "v%d" % self.tcounter def genns(self, ns_map, nsURI): if nsURI == None: return ('', '') if type(nsURI) == TupleType: # already a tuple if len(nsURI) == 2: ns, nsURI = nsURI else: ns, nsURI = None, nsURI[0] else: ns = None if ns_map.has_key(nsURI): return (ns_map[nsURI] + ':', '') if self._env_ns.has_key(nsURI): ns = self.envns[nsURI] = ns_map[nsURI] = self._env_ns[nsURI] return (ns + ':', '') if not ns: ns = "ns%d" % self.ncounter self.ncounter += 1 ns_map[nsURI] = ns if self.config.buildWithNamespacePrefix: return (ns + ':', ' xmlns:%s="%s"' % (ns, nsURI)) else: return ('', ' xmlns="%s"' % (nsURI)) def genroot(self, ns_map): if self.noroot: return '' if self.depth != 2: return '' ns, n = self.genns(ns_map, NS.ENC) return ' %sroot="%d"%s' % (ns, not self.multis, n) # checkref checks an element to see if it needs to be encoded as a # multi-reference element or not. If it returns None, the element has # been handled and the caller can continue with subsequent elements. # If it returns a string, the string should be included in the opening # tag of the marshaled element. def checkref(self, obj, tag, ns_map): if self.depth < 2: return '' if not self.ids.has_key(id(obj)): n = self.ids[id(obj)] = self.icounter self.icounter = n + 1 if self.use_refs == 0: return '' if self.depth == 2: return ' id="i%d"' % n self.multirefs.append((obj, tag)) else: if self.use_refs == 0: raise RecursionError, "Cannot serialize recursive object" n = self.ids[id(obj)] if self.multis and self.depth == 2: return ' id="i%d"' % n self.out.append('<%s href="#i%d"%s/>\n' % (tag, n, self.genroot(ns_map))) return None # dumpers def dump(self, obj, tag = None, typed = 1, ns_map = {}): if Config.debug: print "In dump.", "obj=", obj ns_map = ns_map.copy() self.depth += 1 if type(tag) not in (NoneType, StringType, UnicodeType): raise KeyError, "tag must be a string or None" self.dump_dispatch(obj, tag, typed, ns_map) self.depth -= 1 # generic dumper def dumper(self, nsURI, obj_type, obj, tag, typed = 1, ns_map = {}, rootattr = '', id = '', xml = '<%(tag)s%(type)s%(id)s%(attrs)s%(root)s>%(data)s</%(tag)s>\n'): if Config.debug: print "In dumper." if nsURI == None: nsURI = self.config.typesNamespaceURI tag = tag or self.gentag() tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding a = n = t = '' if typed and obj_type: ns, n = self.genns(ns_map, nsURI) ins = self.genns(ns_map, self.config.schemaNamespaceURI)[0] t = ' %stype="%s%s"%s' % (ins, ns, obj_type, n) try: a = obj._marshalAttrs(ns_map, self) except: pass try: data = obj._marshalData() except: if (obj_type != "string"): # strings are already encoded data = cgi.escape(str(obj)) else: data = obj return xml % {"tag": tag, "type": t, "data": data, "root": rootattr, "id": id, "attrs": a} def dump_float(self, obj, tag, typed = 1, ns_map = {}): if Config.debug: print "In dump_float." tag = tag or self.gentag() tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding if Config.strict_range: doubleType(obj) if fpconst.isPosInf(obj): obj = "INF" elif fpconst.isNegInf(obj): obj = "-INF" elif fpconst.isNaN(obj): obj = "NaN" else: obj = repr(obj) # Note: python 'float' is actually a SOAP 'double'. self.out.append(self.dumper( None, "double", obj, tag, typed, ns_map, self.genroot(ns_map))) def dump_int(self, obj, tag, typed = 1, ns_map = {}): if Config.debug: print "In dump_int." self.out.append(self.dumper(None, 'integer', obj, tag, typed, ns_map, self.genroot(ns_map))) def dump_bool(self, obj, tag, typed = 1, ns_map = {}): if Config.debug: print "In dump_bool." self.out.append(self.dumper(None, 'boolean', obj, tag, typed, ns_map, self.genroot(ns_map))) def dump_string(self, obj, tag, typed = 0, ns_map = {}): if Config.debug: print "In dump_string." tag = tag or self.gentag() tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding id = self.checkref(obj, tag, ns_map) if id == None: return try: data = obj._marshalData() except: data = obj self.out.append(self.dumper(None, "string", cgi.escape(data), tag, typed, ns_map, self.genroot(ns_map), id)) dump_str = dump_string # For Python 2.2+ dump_unicode = dump_string def dump_None(self, obj, tag, typed = 0, ns_map = {}): if Config.debug: print "In dump_None." tag = tag or self.gentag() tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding ns = self.genns(ns_map, self.config.schemaNamespaceURI)[0] self.out.append('<%s %snull="1"%s/>\n' % (tag, ns, self.genroot(ns_map))) dump_NoneType = dump_None # For Python 2.2+ def dump_list(self, obj, tag, typed = 1, ns_map = {}): if Config.debug: print "In dump_list.", "obj=", obj tag = tag or self.gentag() tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding if type(obj) == InstanceType: data = obj.data else: data = obj if typed: id = self.checkref(obj, tag, ns_map) if id == None: return try: sample = data[0] empty = 0 except: # preserve type if present if getattr(obj,"_typed",None) and getattr(obj,"_type",None): if getattr(obj, "_complexType", None): sample = typedArrayType(typed=obj._type, complexType = obj._complexType) sample._typename = obj._type if not getattr(obj,"_ns",None): obj._ns = NS.URN else: sample = typedArrayType(typed=obj._type) else: sample = structType() empty = 1 # First scan list to see if all are the same type same_type = 1 if not empty: for i in data[1:]: if type(sample) != type(i) or \ (type(sample) == InstanceType and \ sample.__class__ != i.__class__): same_type = 0 break ndecl = '' if same_type: if (isinstance(sample, structType)) or \ type(sample) == DictType or \ (isinstance(sample, anyType) and \ (getattr(sample, "_complexType", None) and \ sample._complexType)): # force to urn struct try: tns = obj._ns or NS.URN except: tns = NS.URN ns, ndecl = self.genns(ns_map, tns) try: typename = sample._typename except: typename = "SOAPStruct" t = ns + typename elif isinstance(sample, anyType): ns = sample._validNamespaceURI(self.config.typesNamespaceURI, self.config.strictNamespaces) if ns: ns, ndecl = self.genns(ns_map, ns) t = ns + str(sample._type) else: t = 'ur-type' else: typename = type(sample).__name__ # For Python 2.2+ if type(sample) == StringType: typename = 'string' # HACK: unicode is a SOAP string if type(sample) == UnicodeType: typename = 'string' # HACK: python 'float' is actually a SOAP 'double'. if typename=="float": typename="double" t = self.genns( ns_map, self.config.typesNamespaceURI)[0] + typename else: t = self.genns(ns_map, self.config.typesNamespaceURI)[0] + \ "ur-type" try: a = obj._marshalAttrs(ns_map, self) except: a = '' ens, edecl = self.genns(ns_map, NS.ENC) ins, idecl = self.genns(ns_map, self.config.schemaNamespaceURI) if typed: self.out.append( '<%s %sarrayType="%s[%d]" %stype="%sArray"%s%s%s%s%s%s>\n' % (tag, ens, t, len(data), ins, ens, ndecl, edecl, idecl, self.genroot(ns_map), id, a)) if typed: try: elemsname = obj._elemsname except: elemsname = "item" else: elemsname = tag if isinstance(data, (list, tuple, arrayType)): should_drill = True else: should_drill = not same_type for i in data: self.dump(i, elemsname, should_drill, ns_map) if typed: self.out.append('</%s>\n' % tag) dump_tuple = dump_list def dump_exception(self, obj, tag, typed = 0, ns_map = {}): if isinstance(obj, faultType): # Fault cns, cdecl = self.genns(ns_map, NS.ENC) vns, vdecl = self.genns(ns_map, NS.ENV) self.out.append('<%sFault %sroot="1"%s%s>' % (vns, cns, vdecl, cdecl)) self.dump(obj.faultcode, "faultcode", typed, ns_map) self.dump(obj.faultstring, "faultstring", typed, ns_map) if hasattr(obj, "detail"): self.dump(obj.detail, "detail", typed, ns_map) self.out.append("</%sFault>\n" % vns) def dump_dictionary(self, obj, tag, typed = 1, ns_map = {}): if Config.debug: print "In dump_dictionary." tag = tag or self.gentag() tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding id = self.checkref(obj, tag, ns_map) if id == None: return try: a = obj._marshalAttrs(ns_map, self) except: a = '' self.out.append('<%s%s%s%s>\n' % (tag, id, a, self.genroot(ns_map))) for (k, v) in obj.items(): if k[0] != "_": self.dump(v, k, 1, ns_map) self.out.append('</%s>\n' % tag) dump_dict = dump_dictionary # For Python 2.2+ def dump_dispatch(self, obj, tag, typed = 1, ns_map = {}): if not tag: # If it has a name use it. if isinstance(obj, anyType) and obj._name: tag = obj._name else: tag = self.gentag() # watch out for order! dumpmap = ( (Exception, self.dump_exception), (arrayType, self.dump_list), (basestring, self.dump_string), (NoneType, self.dump_None), (bool, self.dump_bool), (int, self.dump_int), (long, self.dump_int), (list, self.dump_list), (tuple, self.dump_list), (dict, self.dump_dictionary), (float, self.dump_float), ) for dtype, func in dumpmap: if isinstance(obj, dtype): func(obj, tag, typed, ns_map) return r = self.genroot(ns_map) try: a = obj._marshalAttrs(ns_map, self) except: a = '' if isinstance(obj, voidType): # void self.out.append("<%s%s%s></%s>\n" % (tag, a, r, tag)) else: id = self.checkref(obj, tag, ns_map) if id == None: return if isinstance(obj, structType): # Check for namespace ndecl = '' ns = obj._validNamespaceURI(self.config.typesNamespaceURI, self.config.strictNamespaces) if ns: ns, ndecl = self.genns(ns_map, ns) tag = ns + tag self.out.append("<%s%s%s%s%s>\n" % (tag, ndecl, id, a, r)) keylist = obj.__dict__.keys() # first write out items with order information if hasattr(obj, '_keyord'): for i in range(len(obj._keyord)): self.dump(obj._aslist(i), obj._keyord[i], 1, ns_map) keylist.remove(obj._keyord[i]) # now write out the rest for k in keylist: if (k[0] != "_"): self.dump(getattr(obj,k), k, 1, ns_map) if isinstance(obj, bodyType): self.multis = 1 for v, k in self.multirefs: self.dump(v, k, typed = typed, ns_map = ns_map) self.out.append('</%s>\n' % tag) elif isinstance(obj, anyType): t = '' if typed: ns = obj._validNamespaceURI(self.config.typesNamespaceURI, self.config.strictNamespaces) if ns: ons, ondecl = self.genns(ns_map, ns) ins, indecl = self.genns(ns_map, self.config.schemaNamespaceURI) t = ' %stype="%s%s"%s%s' % \ (ins, ons, obj._type, ondecl, indecl) self.out.append('<%s%s%s%s%s>%s</%s>\n' % (tag, t, id, a, r, obj._marshalData(), tag)) else: # Some Class self.out.append('<%s%s%s>\n' % (tag, id, r)) d1 = getattr(obj, '__dict__', None) if d1 is not None: for (k, v) in d1: if k[0] != "_": self.dump(v, k, 1, ns_map) self.out.append('</%s>\n' % tag) ################################################################################ # SOAPBuilder's more public interface ################################################################################ def buildSOAP(args=(), kw={}, method=None, namespace=None, header=None, methodattrs=None, envelope=1, encoding='UTF-8', config=Config, noroot = 0): t = SOAPBuilder(args=args, kw=kw, method=method, namespace=namespace, header=header, methodattrs=methodattrs,envelope=envelope, encoding=encoding, config=config,noroot=noroot) return t.build()
gpl-3.0
[ 624, 199, 13289, 199, 3, 1898, 334, 67, 9, 13004, 12, 510, 329, 2282, 199, 3, 1898, 334, 67, 9, 12521, 12, 445, 1187, 301, 738, 914, 1237, 14, 199, 3, 1898, 334, 67, 9, 12521, 12, 699, 18429, 18619, 29640, 83, 14, 199, 3, 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, 7647, 26, 199, 3, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 199, 3, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 199, 3, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 11443, 314, 536, 402, 2454, 4262, 12, 12864, 14, 6590, 314, 1561, 402, 2399, 8417, 1443, 199, 3, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 2032, 1928, 199, 3, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 199, 3, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 14142, 1309, 51, 1549, 6483, 6262, 7024, 2381, 199, 3, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 199, 3, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 199, 3, 5258, 1821, 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, 1634, 5749, 199, 3, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 13289, 199, 624, 199, 199, 5425, 275, 4505, 1304, 26, 26805, 6437, 14, 647, 413, 20537, 7129, 13, 1644, 13, 713, 12497, 26, 969, 26, 1167, 58, 1115, 1089, 269, 2000, 2672, 7, 199, 504, 1015, 492, 636, 1023, 363, 199, 199, 646, 16004, 199, 504, 336, 270, 5998, 14, 4317, 354, 492, 370, 4317, 354, 12, 687, 4317, 354, 199, 646, 4090, 1297, 199, 199, 3, 26805, 647, 4621, 199, 504, 4094, 492, 4094, 199, 504, 9380, 258, 492, 9380, 199, 504, 18851, 221, 492, 627, 199, 199, 3, 1379, 3775, 642, 2018, 1015, 965, 18851, 14, 4082, 804, 199, 3, 982, 652, 3181, 1133, 1172, 652, 12, 2066, 756, 436, 715, 787, 6380, 465, 9446, 199, 893, 26, 272, 9411, 804, 272, 2366, 6362, 4082, 804, 275, 413, 199, 2590, 12746, 26, 272, 2366, 6362, 4082, 804, 275, 378, 199, 199, 13289, 199, 3, 26805, 19286, 199, 13289, 199, 533, 26805, 6437, 26, 272, 485, 1652, 63, 2119, 275, 2650, 31, 1652, 1015, 628, 17, 14, 16, 14863, 3072, 78, 7, 272, 485, 1652, 63, 10945, 63, 2119, 275, 2650, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 5961, 83, 14863, 3072, 78, 7, 272, 485, 1813, 63, 2119, 275, 334, 9487, 9984, 63, 52, 9, 83, 26, 28278, 60, 78, 7, 435, 971, 326, 283, 221, 2818, 9984, 63, 52, 9, 83, 26, 2991, 6609, 17662, 9415, 9, 83, 3212, 78, 7, 776, 450, 971, 326, 9380, 855, 807, 363, 272, 485, 1813, 63, 3018, 275, 11936, 2840, 9984, 63, 52, 9, 83, 26, 28278, 3072, 78, 7, 450, 9380, 855, 807, 363, 339, 327, 2812, 10749, 18994, 3247, 315, 314, 29143, 1947, 14, 339, 485, 1813, 63, 561, 275, 469, 2709, 14, 9415, 26, 9380, 14, 9415, 63, 52, 12, 9380, 14, 9984, 26, 9380, 14, 9984, 63, 52, 12, 267, 9380, 14, 56, 3693, 26, 9380, 14, 56, 3693, 63, 52, 12, 9380, 14, 56, 3693, 18, 26, 9380, 14, 56, 3693, 18, 63, 52, 12, 9380, 14, 56, 3693, 19, 26, 9380, 14, 56, 3693, 19, 63, 52, 12, 267, 9380, 14, 56, 2684, 26, 9380, 14, 56, 2684, 63, 52, 12, 9380, 14, 56, 2684, 18, 26, 9380, 14, 56, 2684, 18, 63, 52, 12, 9380, 14, 56, 2684, 19, 26, 9380, 14, 56, 2684, 19, 63, 52, 93, 339, 347, 636, 826, 721, 277, 12, 1249, 275, 11969, 4775, 275, 5479, 1083, 275, 488, 12, 3231, 275, 488, 12, 267, 1406, 275, 488, 12, 1083, 3288, 275, 488, 12, 24631, 275, 413, 12, 2644, 275, 283, 6610, 13, 24, 297, 267, 675, 63, 7655, 275, 378, 12, 1101, 275, 4094, 12, 6590, 26974, 275, 378, 304, 398, 327, 1379, 314, 2644, 12, 17026, 376, 1919, 340, 652, 1159, 440, 6040, 267, 340, 2644, 1137, 488, 26, 288, 6522, 2143, 8, 2991, 9, 398, 291, 14, 589, 755, 275, 1249, 267, 291, 14, 829, 260, 275, 4775, 267, 291, 14, 19707, 257, 275, 24631, 267, 291, 14, 2991, 257, 275, 2644, 267, 291, 14, 765, 258, 275, 1083, 267, 291, 14, 3251, 221, 275, 3231, 267, 291, 14, 1291, 258, 275, 1406, 267, 291, 14, 765, 3288, 29, 1083, 3288, 267, 291, 14, 1180, 63, 7655, 257, 275, 675, 63, 7655, 267, 291, 14, 888, 258, 275, 1101, 267, 291, 14, 548, 263, 275, 942, 267, 291, 14, 84, 5337, 257, 275, 378, 267, 291, 14, 78, 5337, 257, 275, 413, 267, 291, 14, 73, 5337, 257, 275, 413, 267, 291, 14, 1813, 561, 420, 275, 1052, 267, 291, 14, 1580, 263, 275, 1052, 267, 291, 14, 4631, 420, 275, 378, 267, 291, 14, 3029, 7655, 221, 275, 942, 267, 291, 14, 3029, 83, 258, 275, 378, 267, 291, 14, 2030, 755, 275, 440, 1228, 8, 589, 12, 2396, 804, 9, 267, 291, 14, 6505, 26974, 258, 275, 6590, 26974, 339, 347, 1900, 8, 277, 304, 267, 340, 4094, 14, 1757, 26, 870, 298, 607, 1900, 2122, 267, 700, 63, 1130, 275, 1052, 398, 327, 11977, 3775, 14090, 365, 641, 503, 440 ]
[ 199, 13289, 199, 3, 1898, 334, 67, 9, 13004, 12, 510, 329, 2282, 199, 3, 1898, 334, 67, 9, 12521, 12, 445, 1187, 301, 738, 914, 1237, 14, 199, 3, 1898, 334, 67, 9, 12521, 12, 699, 18429, 18619, 29640, 83, 14, 199, 3, 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, 7647, 26, 199, 3, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 199, 3, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 199, 3, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 11443, 314, 536, 402, 2454, 4262, 12, 12864, 14, 6590, 314, 1561, 402, 2399, 8417, 1443, 199, 3, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 2032, 1928, 199, 3, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 199, 3, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 14142, 1309, 51, 1549, 6483, 6262, 7024, 2381, 199, 3, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 199, 3, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 199, 3, 5258, 1821, 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, 1634, 5749, 199, 3, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 13289, 199, 624, 199, 199, 5425, 275, 4505, 1304, 26, 26805, 6437, 14, 647, 413, 20537, 7129, 13, 1644, 13, 713, 12497, 26, 969, 26, 1167, 58, 1115, 1089, 269, 2000, 2672, 7, 199, 504, 1015, 492, 636, 1023, 363, 199, 199, 646, 16004, 199, 504, 336, 270, 5998, 14, 4317, 354, 492, 370, 4317, 354, 12, 687, 4317, 354, 199, 646, 4090, 1297, 199, 199, 3, 26805, 647, 4621, 199, 504, 4094, 492, 4094, 199, 504, 9380, 258, 492, 9380, 199, 504, 18851, 221, 492, 627, 199, 199, 3, 1379, 3775, 642, 2018, 1015, 965, 18851, 14, 4082, 804, 199, 3, 982, 652, 3181, 1133, 1172, 652, 12, 2066, 756, 436, 715, 787, 6380, 465, 9446, 199, 893, 26, 272, 9411, 804, 272, 2366, 6362, 4082, 804, 275, 413, 199, 2590, 12746, 26, 272, 2366, 6362, 4082, 804, 275, 378, 199, 199, 13289, 199, 3, 26805, 19286, 199, 13289, 199, 533, 26805, 6437, 26, 272, 485, 1652, 63, 2119, 275, 2650, 31, 1652, 1015, 628, 17, 14, 16, 14863, 3072, 78, 7, 272, 485, 1652, 63, 10945, 63, 2119, 275, 2650, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 5961, 83, 14863, 3072, 78, 7, 272, 485, 1813, 63, 2119, 275, 334, 9487, 9984, 63, 52, 9, 83, 26, 28278, 60, 78, 7, 435, 971, 326, 283, 221, 2818, 9984, 63, 52, 9, 83, 26, 2991, 6609, 17662, 9415, 9, 83, 3212, 78, 7, 776, 450, 971, 326, 9380, 855, 807, 363, 272, 485, 1813, 63, 3018, 275, 11936, 2840, 9984, 63, 52, 9, 83, 26, 28278, 3072, 78, 7, 450, 9380, 855, 807, 363, 339, 327, 2812, 10749, 18994, 3247, 315, 314, 29143, 1947, 14, 339, 485, 1813, 63, 561, 275, 469, 2709, 14, 9415, 26, 9380, 14, 9415, 63, 52, 12, 9380, 14, 9984, 26, 9380, 14, 9984, 63, 52, 12, 267, 9380, 14, 56, 3693, 26, 9380, 14, 56, 3693, 63, 52, 12, 9380, 14, 56, 3693, 18, 26, 9380, 14, 56, 3693, 18, 63, 52, 12, 9380, 14, 56, 3693, 19, 26, 9380, 14, 56, 3693, 19, 63, 52, 12, 267, 9380, 14, 56, 2684, 26, 9380, 14, 56, 2684, 63, 52, 12, 9380, 14, 56, 2684, 18, 26, 9380, 14, 56, 2684, 18, 63, 52, 12, 9380, 14, 56, 2684, 19, 26, 9380, 14, 56, 2684, 19, 63, 52, 93, 339, 347, 636, 826, 721, 277, 12, 1249, 275, 11969, 4775, 275, 5479, 1083, 275, 488, 12, 3231, 275, 488, 12, 267, 1406, 275, 488, 12, 1083, 3288, 275, 488, 12, 24631, 275, 413, 12, 2644, 275, 283, 6610, 13, 24, 297, 267, 675, 63, 7655, 275, 378, 12, 1101, 275, 4094, 12, 6590, 26974, 275, 378, 304, 398, 327, 1379, 314, 2644, 12, 17026, 376, 1919, 340, 652, 1159, 440, 6040, 267, 340, 2644, 1137, 488, 26, 288, 6522, 2143, 8, 2991, 9, 398, 291, 14, 589, 755, 275, 1249, 267, 291, 14, 829, 260, 275, 4775, 267, 291, 14, 19707, 257, 275, 24631, 267, 291, 14, 2991, 257, 275, 2644, 267, 291, 14, 765, 258, 275, 1083, 267, 291, 14, 3251, 221, 275, 3231, 267, 291, 14, 1291, 258, 275, 1406, 267, 291, 14, 765, 3288, 29, 1083, 3288, 267, 291, 14, 1180, 63, 7655, 257, 275, 675, 63, 7655, 267, 291, 14, 888, 258, 275, 1101, 267, 291, 14, 548, 263, 275, 942, 267, 291, 14, 84, 5337, 257, 275, 378, 267, 291, 14, 78, 5337, 257, 275, 413, 267, 291, 14, 73, 5337, 257, 275, 413, 267, 291, 14, 1813, 561, 420, 275, 1052, 267, 291, 14, 1580, 263, 275, 1052, 267, 291, 14, 4631, 420, 275, 378, 267, 291, 14, 3029, 7655, 221, 275, 942, 267, 291, 14, 3029, 83, 258, 275, 378, 267, 291, 14, 2030, 755, 275, 440, 1228, 8, 589, 12, 2396, 804, 9, 267, 291, 14, 6505, 26974, 258, 275, 6590, 26974, 339, 347, 1900, 8, 277, 304, 267, 340, 4094, 14, 1757, 26, 870, 298, 607, 1900, 2122, 267, 700, 63, 1130, 275, 1052, 398, 327, 11977, 3775, 14090, 365, 641, 503, 440, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
GalaxyTab4/android_kernel_samsung_matissewifi
tools/perf/scripts/python/syscall-counts-by-pid.py
11180
1927
# system call counts, by pid # (c) 2010, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # Displays system-wide system call totals, broken down by syscall. # If a [comm] arg is specified, only syscalls called by [comm] are displayed. import os, sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * from Util import syscall_name usage = "perf script -s syscall-counts-by-pid.py [comm]\n"; for_comm = None for_pid = None if len(sys.argv) > 2: sys.exit(usage) if len(sys.argv) > 1: try: for_pid = int(sys.argv[1]) except: for_comm = sys.argv[1] syscalls = autodict() def trace_begin(): print "Press control+C to stop and show the summary" def trace_end(): print_syscall_totals() def raw_syscalls__sys_enter(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, id, args): if (for_comm and common_comm != for_comm) or \ (for_pid and common_pid != for_pid ): return try: syscalls[common_comm][common_pid][id] += 1 except TypeError: syscalls[common_comm][common_pid][id] = 1 def print_syscall_totals(): if for_comm is not None: print "\nsyscall events for %s:\n\n" % (for_comm), else: print "\nsyscall events by comm/pid:\n\n", print "%-40s %10s\n" % ("comm [pid]/syscalls", "count"), print "%-40s %10s\n" % ("----------------------------------------", \ "----------"), comm_keys = syscalls.keys() for comm in comm_keys: pid_keys = syscalls[comm].keys() for pid in pid_keys: print "\n%s [%d]\n" % (comm, pid), id_keys = syscalls[comm][pid].keys() for id, val in sorted(syscalls[comm][pid].iteritems(), \ key = lambda(k, v): (v, k), reverse = True): print " %-38s %10d\n" % (syscall_name(id), val),
gpl-2.0
[ 3, 2656, 1240, 8242, 12, 701, 4422, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 28750, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 18901, 14, 199, 3, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 359, 1404, 61, 787, 9080, 14, 199, 199, 646, 747, 12, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 18901, 63, 354, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 13, 991, 13, 3150, 14, 647, 359, 1404, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 509, 63, 3150, 275, 488, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 509, 63, 3150, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 63, 19444, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 421, 198, 692, 334, 509, 63, 1404, 436, 2863, 63, 1404, 1137, 367, 63, 1404, 9, 503, 971, 21979, 334, 509, 63, 3150, 221, 436, 2863, 63, 3150, 221, 1137, 367, 63, 3150, 3461, 507, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 4474, 701, 1923, 15, 3150, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1404, 359, 3150, 12978, 14507, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 9460, 1288, 339, 1923, 63, 1612, 275, 19473, 14, 1612, 342, 272, 367, 1923, 315, 1923, 63, 1612, 26, 6722, 4422, 63, 1612, 275, 19473, 59, 1404, 1055, 1612, 342, 6722, 367, 4422, 315, 4422, 63, 1612, 26, 15075, 870, 1867, 78, 5, 83, 8978, 68, 7272, 78, 2, 450, 334, 1404, 12, 4422, 395, 15075, 1305, 63, 1612, 275, 19473, 59, 1404, 1527, 3150, 1055, 1612, 342, 15075, 367, 1305, 12, 1139, 315, 3355, 8, 14507, 59, 1404, 1527, 3150, 1055, 4611, 1062, 971, 1871, 221, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 221, 3837, 275, 715, 304, 24449, 870, 298, 221, 19752, 1703, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2656, 1240, 8242, 12, 701, 4422, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 28750, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 18901, 14, 199, 3, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 359, 1404, 61, 787, 9080, 14, 199, 199, 646, 747, 12, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 18901, 63, 354, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 13, 991, 13, 3150, 14, 647, 359, 1404, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 509, 63, 3150, 275, 488, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 509, 63, 3150, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 63, 19444, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 421, 198, 692, 334, 509, 63, 1404, 436, 2863, 63, 1404, 1137, 367, 63, 1404, 9, 503, 971, 21979, 334, 509, 63, 3150, 221, 436, 2863, 63, 3150, 221, 1137, 367, 63, 3150, 3461, 507, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 4474, 701, 1923, 15, 3150, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1404, 359, 3150, 12978, 14507, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 9460, 1288, 339, 1923, 63, 1612, 275, 19473, 14, 1612, 342, 272, 367, 1923, 315, 1923, 63, 1612, 26, 6722, 4422, 63, 1612, 275, 19473, 59, 1404, 1055, 1612, 342, 6722, 367, 4422, 315, 4422, 63, 1612, 26, 15075, 870, 1867, 78, 5, 83, 8978, 68, 7272, 78, 2, 450, 334, 1404, 12, 4422, 395, 15075, 1305, 63, 1612, 275, 19473, 59, 1404, 1527, 3150, 1055, 1612, 342, 15075, 367, 1305, 12, 1139, 315, 3355, 8, 14507, 59, 1404, 1527, 3150, 1055, 4611, 1062, 971, 1871, 221, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 221, 3837, 275, 715, 304, 24449, 870, 298, 221, 19752, 1703, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
clarencecastillo/dose
examples/17_no_migration_proportionate_selection.py
2
6760
''' Example 13: Examining the effects of natural selection on a population's genetic pool by implementing a fitness scheme that counts a specific sequence within the chromosome along with a goal to be reached from an evenly deployed population. In this simulation, - 1 population of 100 organisms - each organism will have 1 chromosome of only 2 bases (1 and 0) - Deployed on just one eco-cell - 1% background point mutation on chromosome of 50 bases - no organism movement throughout the simulation - no Ragaraja interpretation of genome - 300 generations to be simulated ''' # needed to run this example without prior # installation of DOSE into Python site-packages try: import run_examples_without_installation except ImportError: pass # Example codes starts from here import dose, random from collections import Counter from copy import deepcopy parameters = { "simulation_name": "example_13", "population_names": ['pop_01'], "population_locations": [[(0,0,0)]], "initial_chromosome": ['1','0'] * 250, "deployment_code": 1, "chromosome_bases": ['0','1'], "background_mutation": 0.01, "additional_mutation": 0.00, "mutation_type": 'point', "chromosome_size": 500, "genome_size": 1, "max_tape_length": 50, "clean_cell": True, "interpret_chromosome": False, "max_codon": 2000, "population_size": 100, "eco_cell_capacity": 0, "world_x": 1, "world_y": 1, "world_z": 1, "goal": 50, "maximum_generations": 200, "fossilized_ratio": 0.01, "fossilized_frequency": 50, "print_frequency": 1, "ragaraja_version": 0, "ragaraja_instructions": ['000', '001', '010', '011', '100', '101'], "eco_buried_frequency": 200, "database_file": "sim13_no_migration.db", "database_logging_frequency": 1 } class simulation_functions(dose.dose_functions): def organism_movement(self, Populations, pop_name, World): pass def organism_location(self, Populations, pop_name, World): pass def ecoregulate(self, World): pass def update_ecology(self, World, x, y, z): pass def update_local(self, World, x, y, z): pass def report(self, World): pass def fitness(self, Populations, pop_name): for organism in Populations[pop_name].agents: final_fitness = [] chromosome = organism.genome[0].sequence zero_count = [] for base_index in range(parameters["chromosome_size"] - 1): if int(chromosome[base_index]) == 0 and int(chromosome[base_index - 1]) != 0: next_index = 1 while int(chromosome[next_index + base_index]) == 0: next_index += 1 if (next_index + base_index) == parameters["chromosome_size"]: break zero_count.append(next_index - 1) for sequence in range(len(zero_count)): if len(final_fitness) == 10: break seq_score = sorted(zero_count, reverse = True)[sequence] if seq_score > (parameters["goal"]/10): seq_score = (parameters["goal"]/10) final_fitness.append(seq_score) organism.status['fitness'] = sum(final_fitness) def mutation_scheme(self, organism): organism.genome[0].rmutate(parameters["mutation_type"], parameters["additional_mutation"]) def prepopulation_control(self, Populations, pop_name): pass def mating(self, Populations, pop_name): group = deepcopy(Populations[pop_name].agents) for organism in group: organism.generate_name() Populations[pop_name].agents.append(organism) def postpopulation_control(self, Populations, pop_name): group = deepcopy(Populations[pop_name].agents) fitness_dict = {} for organism in group: fitness_dict[organism.status['identity']] = float(organism.status['fitness']) sorted_fitness = sorted(list(fitness_dict.items()), key=lambda x: x[1]) sorted_fitness = [list(item) for item in sorted_fitness] total_fitness = sum(fitness_dict.values()) cumulated_fitness = 0 for i in range(len(sorted_fitness)): sorted_fitness[i][1] = cumulated_fitness + (sorted_fitness[i][1] / total_fitness) cumulated_fitness = cumulated_fitness + (sorted_fitness[i][1] / total_fitness) filter_list = [] while len(filter_list) != 100: random_val = random.uniform(min([fitness[1] for fitness in sorted_fitness]), sum([fitness[1] for fitness in sorted_fitness])) for fitness_list in sorted_fitness: if fitness_list[1] > random_val and fitness_list[0] not in filter_list: filter_list.append(fitness_list[0]) break new_population = [organism for organism in Populations[pop_name].agents if organism.status['identity'] in filter_list] Populations[pop_name].agents = new_population def generation_events(self, Populations, pop_name): pass def population_report(self, Populations, pop_name): report_list = [] for organism in Populations[pop_name].agents: chromosome = organism.status['identity'] fitness = str(organism.status['fitness']) report_list.append(chromosome + ' ' + fitness) return '\n'.join(report_list) def database_report(self, con, cur, start_time, Populations, World, generation_count): try: dose.database_report_populations(con, cur, start_time, Populations, generation_count) except: pass try: dose.database_report_world(con, cur, start_time, World, generation_count) except: pass def deployment_scheme(self, Populations, pop_name, World): pass for trial in range(1, 26): for goal in [50, 70, 90, 110]: zero_base = goal/10 parameters["goal"] = goal parameters["simulation_name"] = "T" + str(trial) + "_fps_" + str(zero_base) + "x0_gain1" parameters["database_file"] = "T" + str(trial) + "_fps_" + str(zero_base) + "x0_gain1.db" dose.simulate(parameters, simulation_functions)
gpl-3.0
[ 2344, 199, 9846, 4944, 26, 1316, 455, 7969, 314, 22414, 402, 19981, 7267, 641, 282, 221, 199, 16003, 1159, 15599, 764, 4203, 701, 18234, 282, 5542, 4171, 5687, 626, 8242, 199, 65, 2488, 3414, 4453, 314, 20074, 26803, 3180, 543, 282, 14850, 370, 506, 13075, 221, 199, 504, 376, 2755, 590, 26181, 16423, 14, 199, 199, 607, 642, 17625, 12, 272, 446, 413, 16423, 402, 2948, 5981, 7199, 706, 272, 446, 1924, 5981, 7199, 77, 911, 1172, 413, 20074, 26803, 402, 1454, 499, 9768, 334, 17, 436, 378, 9, 272, 446, 21588, 3374, 379, 641, 2951, 1373, 325, 331, 13, 3890, 272, 446, 413, 5, 8020, 2376, 31083, 641, 20074, 26803, 402, 5238, 9768, 272, 446, 949, 5981, 7199, 77, 4057, 434, 23088, 314, 17625, 272, 446, 949, 820, 643, 17956, 3387, 28426, 402, 29924, 272, 446, 9601, 1519, 1298, 370, 506, 4389, 8097, 199, 2344, 199, 199, 3, 4346, 370, 1255, 642, 2893, 1928, 6791, 199, 3, 12096, 402, 3506, 899, 1901, 2018, 4770, 13, 5154, 199, 893, 26, 9948, 198, 646, 1255, 63, 8589, 63, 7395, 63, 23048, 199, 2590, 3545, 26, 986, 199, 199, 3, 5679, 9479, 9174, 687, 2348, 199, 646, 886, 261, 12, 2196, 199, 504, 5055, 492, 14427, 199, 504, 1331, 492, 14800, 199, 199, 3214, 275, 469, 1598, 298, 22930, 63, 354, 582, 298, 2694, 63, 969, 401, 1598, 298, 16003, 63, 1247, 582, 788, 1935, 63, 614, 995, 1598, 298, 16003, 63, 8022, 582, 3474, 8, 16, 12, 16, 12, 16, 18037, 1598, 298, 2747, 63, 23473, 26803, 582, 788, 17, 1673, 16, 418, 627, 16074, 12, 1598, 298, 13605, 63, 600, 582, 413, 12, 1598, 298, 23473, 26803, 63, 12087, 582, 788, 16, 1673, 17, 995, 1598, 298, 7451, 63, 11627, 582, 378, 14, 614, 12, 1598, 298, 8460, 63, 11627, 582, 378, 14, 383, 12, 1598, 298, 11627, 63, 466, 582, 283, 1403, 297, 1598, 298, 23473, 26803, 63, 890, 582, 6891, 12, 1598, 298, 27776, 63, 890, 582, 413, 12, 1598, 298, 988, 63, 502, 321, 63, 1267, 582, 5238, 12, 1598, 298, 3118, 63, 3890, 582, 715, 12, 1598, 298, 21533, 63, 23473, 26803, 582, 756, 12, 1598, 298, 988, 63, 7889, 265, 582, 12293, 12, 1598, 298, 16003, 63, 890, 582, 2948, 12, 1598, 298, 69, 331, 63, 3890, 63, 10457, 582, 378, 12, 1598, 298, 7617, 63, 88, 582, 413, 12, 1598, 298, 7617, 63, 89, 582, 413, 12, 1598, 298, 7617, 63, 90, 582, 413, 12, 1598, 298, 16117, 582, 5238, 12, 1598, 298, 11555, 63, 2038, 1298, 582, 1926, 12, 1598, 298, 545, 83, 338, 317, 7068, 63, 6884, 582, 378, 14, 614, 12, 1598, 298, 545, 83, 338, 317, 7068, 63, 11132, 582, 5238, 12, 1598, 298, 1361, 63, 11132, 582, 413, 12, 1598, 298, 2527, 17956, 3387, 63, 1023, 582, 378, 12, 1598, 298, 2527, 17956, 3387, 63, 20718, 582, 788, 1493, 297, 283, 4587, 297, 283, 9523, 297, 221, 3147, 283, 13059, 297, 283, 1960, 297, 283, 4893, 995, 1598, 298, 69, 331, 63, 66, 2302, 379, 63, 11132, 582, 1926, 12, 1598, 298, 4659, 63, 493, 582, 298, 5206, 969, 63, 889, 63, 8998, 14, 697, 401, 1598, 298, 4659, 63, 4806, 63, 11132, 582, 413, 1467, 789, 199, 199, 533, 17625, 63, 5777, 8, 1117, 261, 14, 1117, 261, 63, 5777, 304, 339, 347, 5981, 7199, 77, 63, 1185, 434, 8, 277, 12, 13244, 21429, 12, 4560, 63, 354, 12, 13064, 304, 986, 339, 347, 5981, 7199, 77, 63, 1985, 8, 277, 12, 13244, 21429, 12, 4560, 63, 354, 12, 13064, 304, 986, 339, 347, 325, 1018, 71, 5434, 8, 277, 12, 13064, 304, 986, 339, 347, 1678, 63, 69, 331, 4956, 8, 277, 12, 13064, 12, 671, 12, 612, 12, 1315, 304, 986, 339, 347, 1678, 63, 1832, 8, 277, 12, 13064, 12, 671, 12, 612, 12, 1315, 304, 986, 339, 347, 3622, 8, 277, 12, 13064, 304, 986, 339, 347, 5542, 4171, 8, 277, 12, 13244, 21429, 12, 4560, 63, 354, 304, 267, 367, 5981, 7199, 77, 315, 13244, 21429, 59, 1935, 63, 354, 1055, 14250, 26, 288, 4242, 63, 3269, 4171, 275, 942, 288, 20074, 26803, 275, 5981, 7199, 77, 14, 27776, 59, 16, 1055, 4041, 288, 4697, 63, 835, 275, 942, 288, 367, 1300, 63, 1080, 315, 1425, 8, 3214, 905, 23473, 26803, 63, 890, 937, 446, 413, 304, 355, 340, 1109, 8, 23473, 26803, 59, 1095, 63, 1080, 566, 508, 378, 436, 1109, 8, 23473, 26803, 59, 1095, 63, 1080, 446, 413, 566, 1137, 378, 26, 490, 2163, 63, 1080, 275, 413, 490, 1830, 1109, 8, 23473, 26803, 59, 2184, 63, 1080, 435, 1300, 63, 1080, 566, 508, 378, 26, 717, 2163, 63, 1080, 847, 413, 717, 340, 334, 2184, 63, 1080, 435, 1300, 63, 1080, 9, 508, 2633, 905, 23473, 26803, 63, 890, 6229, 2059, 490, 4697, 63, 835, 14, 740, 8, 2184, 63, 1080, 446, 413, 9, 288, 367, 3414, 315, 1425, 8, 552, 8, 4262, 63, 835, 2298, 355, 340, 822, 8, 5094, 63, 3269, 4171, 9, 508, 1616, 26, 2059, 355, 5412, 63, 3397, 275, 3355, 8, 4262, 63, 835, 12, 3837, 275, 715, 2788, 4041, 61, 355, 340, 5412, 63, 3397, 690, 334, 3214, 905, 16117, 937, 15, 709, 304, 490, 5412, 63, 3397, 275, 334, 3214, 905, 16117, 937, 15, 709, 9, 355, 4242, 63, 3269, 4171, 14, 740, 8, 3610, 63, 3397, 9, 288, 5981, 7199, 77, 14, 1205, 459, 3269, 4171, 418, 275, 3089, 8, 5094, 63, 3269, 4171, 9, 339, 347, 31083, 63, 5512, 8, 277, 12, 5981, 7199, 77, 304, 267, 5981, 7199, 77, 14, 27776, 59, 16, 1055, 5682, 337, 323, 8, 3214, 905, 11627, 63, 466, 2255, 3521, 2633, 905, 8460, 63, 11627, 3135, 339, 347, 876, 16003, 63, 2785, 8, 277, 12, 13244, 21429, 12, 4560, 63, 354, 304, 986, 339, 347, 333, 1958, 8, 277, 12, 13244, 21429, 12, 4560, 63, 354, 304, 4960, 1572, 275, 14800, 8, 9606, 21429, 59, 1935, 63, 354, 1055, 14250, 9, 267, 367, 5981, 7199, 77, 315, 1572, 26, 288, 5981, 7199, 77, 14, 4208, 63, 354, 342, 288, 13244, 21429, 59, 1935, 63, 354, 1055, 14250, 14 ]
[ 199, 9846, 4944, 26, 1316, 455, 7969, 314, 22414, 402, 19981, 7267, 641, 282, 221, 199, 16003, 1159, 15599, 764, 4203, 701, 18234, 282, 5542, 4171, 5687, 626, 8242, 199, 65, 2488, 3414, 4453, 314, 20074, 26803, 3180, 543, 282, 14850, 370, 506, 13075, 221, 199, 504, 376, 2755, 590, 26181, 16423, 14, 199, 199, 607, 642, 17625, 12, 272, 446, 413, 16423, 402, 2948, 5981, 7199, 706, 272, 446, 1924, 5981, 7199, 77, 911, 1172, 413, 20074, 26803, 402, 1454, 499, 9768, 334, 17, 436, 378, 9, 272, 446, 21588, 3374, 379, 641, 2951, 1373, 325, 331, 13, 3890, 272, 446, 413, 5, 8020, 2376, 31083, 641, 20074, 26803, 402, 5238, 9768, 272, 446, 949, 5981, 7199, 77, 4057, 434, 23088, 314, 17625, 272, 446, 949, 820, 643, 17956, 3387, 28426, 402, 29924, 272, 446, 9601, 1519, 1298, 370, 506, 4389, 8097, 199, 2344, 199, 199, 3, 4346, 370, 1255, 642, 2893, 1928, 6791, 199, 3, 12096, 402, 3506, 899, 1901, 2018, 4770, 13, 5154, 199, 893, 26, 9948, 198, 646, 1255, 63, 8589, 63, 7395, 63, 23048, 199, 2590, 3545, 26, 986, 199, 199, 3, 5679, 9479, 9174, 687, 2348, 199, 646, 886, 261, 12, 2196, 199, 504, 5055, 492, 14427, 199, 504, 1331, 492, 14800, 199, 199, 3214, 275, 469, 1598, 298, 22930, 63, 354, 582, 298, 2694, 63, 969, 401, 1598, 298, 16003, 63, 1247, 582, 788, 1935, 63, 614, 995, 1598, 298, 16003, 63, 8022, 582, 3474, 8, 16, 12, 16, 12, 16, 18037, 1598, 298, 2747, 63, 23473, 26803, 582, 788, 17, 1673, 16, 418, 627, 16074, 12, 1598, 298, 13605, 63, 600, 582, 413, 12, 1598, 298, 23473, 26803, 63, 12087, 582, 788, 16, 1673, 17, 995, 1598, 298, 7451, 63, 11627, 582, 378, 14, 614, 12, 1598, 298, 8460, 63, 11627, 582, 378, 14, 383, 12, 1598, 298, 11627, 63, 466, 582, 283, 1403, 297, 1598, 298, 23473, 26803, 63, 890, 582, 6891, 12, 1598, 298, 27776, 63, 890, 582, 413, 12, 1598, 298, 988, 63, 502, 321, 63, 1267, 582, 5238, 12, 1598, 298, 3118, 63, 3890, 582, 715, 12, 1598, 298, 21533, 63, 23473, 26803, 582, 756, 12, 1598, 298, 988, 63, 7889, 265, 582, 12293, 12, 1598, 298, 16003, 63, 890, 582, 2948, 12, 1598, 298, 69, 331, 63, 3890, 63, 10457, 582, 378, 12, 1598, 298, 7617, 63, 88, 582, 413, 12, 1598, 298, 7617, 63, 89, 582, 413, 12, 1598, 298, 7617, 63, 90, 582, 413, 12, 1598, 298, 16117, 582, 5238, 12, 1598, 298, 11555, 63, 2038, 1298, 582, 1926, 12, 1598, 298, 545, 83, 338, 317, 7068, 63, 6884, 582, 378, 14, 614, 12, 1598, 298, 545, 83, 338, 317, 7068, 63, 11132, 582, 5238, 12, 1598, 298, 1361, 63, 11132, 582, 413, 12, 1598, 298, 2527, 17956, 3387, 63, 1023, 582, 378, 12, 1598, 298, 2527, 17956, 3387, 63, 20718, 582, 788, 1493, 297, 283, 4587, 297, 283, 9523, 297, 221, 3147, 283, 13059, 297, 283, 1960, 297, 283, 4893, 995, 1598, 298, 69, 331, 63, 66, 2302, 379, 63, 11132, 582, 1926, 12, 1598, 298, 4659, 63, 493, 582, 298, 5206, 969, 63, 889, 63, 8998, 14, 697, 401, 1598, 298, 4659, 63, 4806, 63, 11132, 582, 413, 1467, 789, 199, 199, 533, 17625, 63, 5777, 8, 1117, 261, 14, 1117, 261, 63, 5777, 304, 339, 347, 5981, 7199, 77, 63, 1185, 434, 8, 277, 12, 13244, 21429, 12, 4560, 63, 354, 12, 13064, 304, 986, 339, 347, 5981, 7199, 77, 63, 1985, 8, 277, 12, 13244, 21429, 12, 4560, 63, 354, 12, 13064, 304, 986, 339, 347, 325, 1018, 71, 5434, 8, 277, 12, 13064, 304, 986, 339, 347, 1678, 63, 69, 331, 4956, 8, 277, 12, 13064, 12, 671, 12, 612, 12, 1315, 304, 986, 339, 347, 1678, 63, 1832, 8, 277, 12, 13064, 12, 671, 12, 612, 12, 1315, 304, 986, 339, 347, 3622, 8, 277, 12, 13064, 304, 986, 339, 347, 5542, 4171, 8, 277, 12, 13244, 21429, 12, 4560, 63, 354, 304, 267, 367, 5981, 7199, 77, 315, 13244, 21429, 59, 1935, 63, 354, 1055, 14250, 26, 288, 4242, 63, 3269, 4171, 275, 942, 288, 20074, 26803, 275, 5981, 7199, 77, 14, 27776, 59, 16, 1055, 4041, 288, 4697, 63, 835, 275, 942, 288, 367, 1300, 63, 1080, 315, 1425, 8, 3214, 905, 23473, 26803, 63, 890, 937, 446, 413, 304, 355, 340, 1109, 8, 23473, 26803, 59, 1095, 63, 1080, 566, 508, 378, 436, 1109, 8, 23473, 26803, 59, 1095, 63, 1080, 446, 413, 566, 1137, 378, 26, 490, 2163, 63, 1080, 275, 413, 490, 1830, 1109, 8, 23473, 26803, 59, 2184, 63, 1080, 435, 1300, 63, 1080, 566, 508, 378, 26, 717, 2163, 63, 1080, 847, 413, 717, 340, 334, 2184, 63, 1080, 435, 1300, 63, 1080, 9, 508, 2633, 905, 23473, 26803, 63, 890, 6229, 2059, 490, 4697, 63, 835, 14, 740, 8, 2184, 63, 1080, 446, 413, 9, 288, 367, 3414, 315, 1425, 8, 552, 8, 4262, 63, 835, 2298, 355, 340, 822, 8, 5094, 63, 3269, 4171, 9, 508, 1616, 26, 2059, 355, 5412, 63, 3397, 275, 3355, 8, 4262, 63, 835, 12, 3837, 275, 715, 2788, 4041, 61, 355, 340, 5412, 63, 3397, 690, 334, 3214, 905, 16117, 937, 15, 709, 304, 490, 5412, 63, 3397, 275, 334, 3214, 905, 16117, 937, 15, 709, 9, 355, 4242, 63, 3269, 4171, 14, 740, 8, 3610, 63, 3397, 9, 288, 5981, 7199, 77, 14, 1205, 459, 3269, 4171, 418, 275, 3089, 8, 5094, 63, 3269, 4171, 9, 339, 347, 31083, 63, 5512, 8, 277, 12, 5981, 7199, 77, 304, 267, 5981, 7199, 77, 14, 27776, 59, 16, 1055, 5682, 337, 323, 8, 3214, 905, 11627, 63, 466, 2255, 3521, 2633, 905, 8460, 63, 11627, 3135, 339, 347, 876, 16003, 63, 2785, 8, 277, 12, 13244, 21429, 12, 4560, 63, 354, 304, 986, 339, 347, 333, 1958, 8, 277, 12, 13244, 21429, 12, 4560, 63, 354, 304, 4960, 1572, 275, 14800, 8, 9606, 21429, 59, 1935, 63, 354, 1055, 14250, 9, 267, 367, 5981, 7199, 77, 315, 1572, 26, 288, 5981, 7199, 77, 14, 4208, 63, 354, 342, 288, 13244, 21429, 59, 1935, 63, 354, 1055, 14250, 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, 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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 ]
GrinningFerret/android_kernel_lge_w7
tools/perf/scripts/python/syscall-counts-by-pid.py
11180
1927
# system call counts, by pid # (c) 2010, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # Displays system-wide system call totals, broken down by syscall. # If a [comm] arg is specified, only syscalls called by [comm] are displayed. import os, sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * from Util import syscall_name usage = "perf script -s syscall-counts-by-pid.py [comm]\n"; for_comm = None for_pid = None if len(sys.argv) > 2: sys.exit(usage) if len(sys.argv) > 1: try: for_pid = int(sys.argv[1]) except: for_comm = sys.argv[1] syscalls = autodict() def trace_begin(): print "Press control+C to stop and show the summary" def trace_end(): print_syscall_totals() def raw_syscalls__sys_enter(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, id, args): if (for_comm and common_comm != for_comm) or \ (for_pid and common_pid != for_pid ): return try: syscalls[common_comm][common_pid][id] += 1 except TypeError: syscalls[common_comm][common_pid][id] = 1 def print_syscall_totals(): if for_comm is not None: print "\nsyscall events for %s:\n\n" % (for_comm), else: print "\nsyscall events by comm/pid:\n\n", print "%-40s %10s\n" % ("comm [pid]/syscalls", "count"), print "%-40s %10s\n" % ("----------------------------------------", \ "----------"), comm_keys = syscalls.keys() for comm in comm_keys: pid_keys = syscalls[comm].keys() for pid in pid_keys: print "\n%s [%d]\n" % (comm, pid), id_keys = syscalls[comm][pid].keys() for id, val in sorted(syscalls[comm][pid].iteritems(), \ key = lambda(k, v): (v, k), reverse = True): print " %-38s %10d\n" % (syscall_name(id), val),
gpl-2.0
[ 3, 2656, 1240, 8242, 12, 701, 4422, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 28750, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 18901, 14, 199, 3, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 359, 1404, 61, 787, 9080, 14, 199, 199, 646, 747, 12, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 18901, 63, 354, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 13, 991, 13, 3150, 14, 647, 359, 1404, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 509, 63, 3150, 275, 488, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 509, 63, 3150, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 63, 19444, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 421, 198, 692, 334, 509, 63, 1404, 436, 2863, 63, 1404, 1137, 367, 63, 1404, 9, 503, 971, 21979, 334, 509, 63, 3150, 221, 436, 2863, 63, 3150, 221, 1137, 367, 63, 3150, 3461, 507, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 4474, 701, 1923, 15, 3150, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1404, 359, 3150, 12978, 14507, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 9460, 1288, 339, 1923, 63, 1612, 275, 19473, 14, 1612, 342, 272, 367, 1923, 315, 1923, 63, 1612, 26, 6722, 4422, 63, 1612, 275, 19473, 59, 1404, 1055, 1612, 342, 6722, 367, 4422, 315, 4422, 63, 1612, 26, 15075, 870, 1867, 78, 5, 83, 8978, 68, 7272, 78, 2, 450, 334, 1404, 12, 4422, 395, 15075, 1305, 63, 1612, 275, 19473, 59, 1404, 1527, 3150, 1055, 1612, 342, 15075, 367, 1305, 12, 1139, 315, 3355, 8, 14507, 59, 1404, 1527, 3150, 1055, 4611, 1062, 971, 1871, 221, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 221, 3837, 275, 715, 304, 24449, 870, 298, 221, 19752, 1703, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2656, 1240, 8242, 12, 701, 4422, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 28750, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 18901, 14, 199, 3, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 359, 1404, 61, 787, 9080, 14, 199, 199, 646, 747, 12, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 18901, 63, 354, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 13, 991, 13, 3150, 14, 647, 359, 1404, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 509, 63, 3150, 275, 488, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 509, 63, 3150, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 63, 19444, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 421, 198, 692, 334, 509, 63, 1404, 436, 2863, 63, 1404, 1137, 367, 63, 1404, 9, 503, 971, 21979, 334, 509, 63, 3150, 221, 436, 2863, 63, 3150, 221, 1137, 367, 63, 3150, 3461, 507, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 4474, 701, 1923, 15, 3150, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1404, 359, 3150, 12978, 14507, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 9460, 1288, 339, 1923, 63, 1612, 275, 19473, 14, 1612, 342, 272, 367, 1923, 315, 1923, 63, 1612, 26, 6722, 4422, 63, 1612, 275, 19473, 59, 1404, 1055, 1612, 342, 6722, 367, 4422, 315, 4422, 63, 1612, 26, 15075, 870, 1867, 78, 5, 83, 8978, 68, 7272, 78, 2, 450, 334, 1404, 12, 4422, 395, 15075, 1305, 63, 1612, 275, 19473, 59, 1404, 1527, 3150, 1055, 1612, 342, 15075, 367, 1305, 12, 1139, 315, 3355, 8, 14507, 59, 1404, 1527, 3150, 1055, 4611, 1062, 971, 1871, 221, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 221, 3837, 275, 715, 304, 24449, 870, 298, 221, 19752, 1703, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
samchrisinger/osf.io
website/addons/figshare/views/hgrid.py
11
1201
# -*- coding: utf-8 -*- from website.util import rubeus from ..api import Figshare def figshare_hgrid_data(node_settings, auth, parent=None, **kwargs): node = node_settings.owner if node_settings.figshare_type == 'project': item = Figshare.from_settings(node_settings.user_settings).project(node_settings, node_settings.figshare_id) else: item = Figshare.from_settings(node_settings.user_settings).article(node_settings, node_settings.figshare_id) if not node_settings.figshare_id or not node_settings.has_auth or not item: return #TODO Test me #Throw error if neither node_settings.figshare_title = item.get('title') or item['items'][0]['title'] node_settings.save() return [ rubeus.build_addon_root( node_settings, u'{0}:{1}'.format(node_settings.figshare_title or 'Unnamed {0}'.format(node_settings.figshare_type or ''), node_settings.figshare_id), permissions=auth, nodeUrl=node.url, nodeApiUrl=node.api_url, extra={ 'status': (item.get('articles') or item['items'])[0]['status'].lower() }, private_key=kwargs.get('view_only', None), ) ]
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 10691, 14, 1974, 492, 519, 3375, 527, 199, 199, 504, 2508, 1246, 492, 31574, 458, 31527, 199, 199, 318, 5883, 458, 31527, 63, 72, 3825, 63, 576, 8, 932, 63, 1751, 12, 1790, 12, 1676, 29, 403, 12, 1011, 958, 304, 272, 1031, 275, 1031, 63, 1751, 14, 4597, 272, 340, 1031, 63, 1751, 14, 5513, 31527, 63, 466, 508, 283, 1715, 356, 267, 1242, 275, 31574, 458, 31527, 14, 504, 63, 1751, 8, 932, 63, 1751, 14, 751, 63, 1751, 680, 1715, 8, 932, 63, 1751, 12, 1031, 63, 1751, 14, 5513, 31527, 63, 344, 9, 272, 587, 26, 267, 1242, 275, 31574, 458, 31527, 14, 504, 63, 1751, 8, 932, 63, 1751, 14, 751, 63, 1751, 680, 6934, 8, 932, 63, 1751, 12, 1031, 63, 1751, 14, 5513, 31527, 63, 344, 9, 272, 340, 440, 1031, 63, 1751, 14, 5513, 31527, 63, 344, 503, 440, 1031, 63, 1751, 14, 1989, 63, 1178, 503, 440, 1242, 26, 267, 372, 272, 327, 11768, 1379, 562, 272, 327, 2719, 1143, 1125, 340, 15564, 272, 1031, 63, 1751, 14, 5513, 31527, 63, 1213, 275, 1242, 14, 362, 360, 1213, 358, 503, 1242, 459, 1744, 3488, 16, 2733, 1213, 418, 272, 1031, 63, 1751, 14, 2117, 342, 272, 372, 359, 267, 519, 3375, 527, 14, 1506, 63, 9291, 63, 1231, 8, 288, 1031, 63, 1751, 12, 399, 16019, 16, 16495, 17, 5285, 908, 8, 932, 63, 1751, 14, 5513, 31527, 63, 1213, 503, 283, 1358, 4579, 469, 16, 5285, 908, 8, 932, 63, 1751, 14, 5513, 31527, 63, 466, 503, 9929, 1031, 63, 1751, 14, 5513, 31527, 63, 344, 395, 3443, 29, 1178, 12, 288, 1031, 6417, 29, 932, 14, 633, 12, 1031, 7394, 6417, 29, 932, 14, 1246, 63, 633, 12, 288, 2402, 3126, 355, 283, 1205, 356, 334, 1053, 14, 362, 360, 19813, 358, 503, 1242, 459, 1744, 25945, 16, 2733, 1205, 2278, 2325, 342, 288, 1660, 288, 5726, 63, 498, 29, 958, 14, 362, 360, 1345, 63, 2118, 297, 488, 395, 267, 776, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 10691, 14, 1974, 492, 519, 3375, 527, 199, 199, 504, 2508, 1246, 492, 31574, 458, 31527, 199, 199, 318, 5883, 458, 31527, 63, 72, 3825, 63, 576, 8, 932, 63, 1751, 12, 1790, 12, 1676, 29, 403, 12, 1011, 958, 304, 272, 1031, 275, 1031, 63, 1751, 14, 4597, 272, 340, 1031, 63, 1751, 14, 5513, 31527, 63, 466, 508, 283, 1715, 356, 267, 1242, 275, 31574, 458, 31527, 14, 504, 63, 1751, 8, 932, 63, 1751, 14, 751, 63, 1751, 680, 1715, 8, 932, 63, 1751, 12, 1031, 63, 1751, 14, 5513, 31527, 63, 344, 9, 272, 587, 26, 267, 1242, 275, 31574, 458, 31527, 14, 504, 63, 1751, 8, 932, 63, 1751, 14, 751, 63, 1751, 680, 6934, 8, 932, 63, 1751, 12, 1031, 63, 1751, 14, 5513, 31527, 63, 344, 9, 272, 340, 440, 1031, 63, 1751, 14, 5513, 31527, 63, 344, 503, 440, 1031, 63, 1751, 14, 1989, 63, 1178, 503, 440, 1242, 26, 267, 372, 272, 327, 11768, 1379, 562, 272, 327, 2719, 1143, 1125, 340, 15564, 272, 1031, 63, 1751, 14, 5513, 31527, 63, 1213, 275, 1242, 14, 362, 360, 1213, 358, 503, 1242, 459, 1744, 3488, 16, 2733, 1213, 418, 272, 1031, 63, 1751, 14, 2117, 342, 272, 372, 359, 267, 519, 3375, 527, 14, 1506, 63, 9291, 63, 1231, 8, 288, 1031, 63, 1751, 12, 399, 16019, 16, 16495, 17, 5285, 908, 8, 932, 63, 1751, 14, 5513, 31527, 63, 1213, 503, 283, 1358, 4579, 469, 16, 5285, 908, 8, 932, 63, 1751, 14, 5513, 31527, 63, 466, 503, 9929, 1031, 63, 1751, 14, 5513, 31527, 63, 344, 395, 3443, 29, 1178, 12, 288, 1031, 6417, 29, 932, 14, 633, 12, 1031, 7394, 6417, 29, 932, 14, 1246, 63, 633, 12, 288, 2402, 3126, 355, 283, 1205, 356, 334, 1053, 14, 362, 360, 19813, 358, 503, 1242, 459, 1744, 25945, 16, 2733, 1205, 2278, 2325, 342, 288, 1660, 288, 5726, 63, 498, 29, 958, 14, 362, 360, 1345, 63, 2118, 297, 488, 395, 267, 776, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
kangbiao/tornado
tornado/ioloop.py
44
40479
#!/usr/bin/env python # # Copyright 2009 Facebook # # 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. """An I/O event loop for non-blocking sockets. Typical applications will use a single `IOLoop` object, in the `IOLoop.instance` singleton. The `IOLoop.start` method should usually be called at the end of the ``main()`` function. Atypical applications may use more than one `IOLoop`, such as one `IOLoop` per thread, or per `unittest` case. In addition to I/O events, the `IOLoop` can also schedule time-based events. `IOLoop.add_timeout` is a non-blocking alternative to `time.sleep`. """ from __future__ import absolute_import, division, print_function, with_statement import datetime import errno import functools import heapq import itertools import logging import numbers import os import select import sys import threading import time import traceback import math from tornado.concurrent import TracebackFuture, is_future from tornado.log import app_log, gen_log from tornado import stack_context from tornado.util import Configurable, errno_from_exception, timedelta_to_seconds try: import signal except ImportError: signal = None try: import thread # py2 except ImportError: import _thread as thread # py3 from tornado.platform.auto import set_close_exec, Waker _POLL_TIMEOUT = 3600.0 class TimeoutError(Exception): pass class IOLoop(Configurable): """A level-triggered I/O loop. We use ``epoll`` (Linux) or ``kqueue`` (BSD and Mac OS X) if they are available, or else we fall back on select(). If you are implementing a system that needs to handle thousands of simultaneous connections, you should use a system that supports either ``epoll`` or ``kqueue``. Example usage for a simple TCP server: .. testcode:: import errno import functools import tornado.ioloop import socket def connection_ready(sock, fd, events): while True: try: connection, address = sock.accept() except socket.error as e: if e.args[0] not in (errno.EWOULDBLOCK, errno.EAGAIN): raise return connection.setblocking(0) handle_connection(connection, address) if __name__ == '__main__': sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.setblocking(0) sock.bind(("", port)) sock.listen(128) io_loop = tornado.ioloop.IOLoop.current() callback = functools.partial(connection_ready, sock) io_loop.add_handler(sock.fileno(), callback, io_loop.READ) io_loop.start() .. testoutput:: :hide: By default, a newly-constructed `IOLoop` becomes the thread's current `IOLoop`, unless there already is a current `IOLoop`. This behavior can be controlled with the ``make_current`` argument to the `IOLoop` constructor: if ``make_current=True``, the new `IOLoop` will always try to become current and it raises an error if there is already a current instance. If ``make_current=False``, the new `IOLoop` will not try to become current. .. versionchanged:: 4.2 Added the ``make_current`` keyword argument to the `IOLoop` constructor. """ # Constants from the epoll module _EPOLLIN = 0x001 _EPOLLPRI = 0x002 _EPOLLOUT = 0x004 _EPOLLERR = 0x008 _EPOLLHUP = 0x010 _EPOLLRDHUP = 0x2000 _EPOLLONESHOT = (1 << 30) _EPOLLET = (1 << 31) # Our events map exactly to the epoll events NONE = 0 READ = _EPOLLIN WRITE = _EPOLLOUT ERROR = _EPOLLERR | _EPOLLHUP # Global lock for creating global IOLoop instance _instance_lock = threading.Lock() _current = threading.local() @staticmethod def instance(): """Returns a global `IOLoop` instance. Most applications have a single, global `IOLoop` running on the main thread. Use this method to get this instance from another thread. In most other cases, it is better to use `current()` to get the current thread's `IOLoop`. """ if not hasattr(IOLoop, "_instance"): with IOLoop._instance_lock: if not hasattr(IOLoop, "_instance"): # New instance after double check IOLoop._instance = IOLoop() return IOLoop._instance @staticmethod def initialized(): """Returns true if the singleton instance has been created.""" return hasattr(IOLoop, "_instance") def install(self): """Installs this `IOLoop` object as the singleton instance. This is normally not necessary as `instance()` will create an `IOLoop` on demand, but you may want to call `install` to use a custom subclass of `IOLoop`. """ assert not IOLoop.initialized() IOLoop._instance = self @staticmethod def clear_instance(): """Clear the global `IOLoop` instance. .. versionadded:: 4.0 """ if hasattr(IOLoop, "_instance"): del IOLoop._instance @staticmethod def current(instance=True): """Returns the current thread's `IOLoop`. If an `IOLoop` is currently running or has been marked as current by `make_current`, returns that instance. If there is no current `IOLoop`, returns `IOLoop.instance()` (i.e. the main thread's `IOLoop`, creating one if necessary) if ``instance`` is true. In general you should use `IOLoop.current` as the default when constructing an asynchronous object, and use `IOLoop.instance` when you mean to communicate to the main thread from a different one. .. versionchanged:: 4.1 Added ``instance`` argument to control the fallback to `IOLoop.instance()`. """ current = getattr(IOLoop._current, "instance", None) if current is None and instance: return IOLoop.instance() return current def make_current(self): """Makes this the `IOLoop` for the current thread. An `IOLoop` automatically becomes current for its thread when it is started, but it is sometimes useful to call `make_current` explicitly before starting the `IOLoop`, so that code run at startup time can find the right instance. .. versionchanged:: 4.1 An `IOLoop` created while there is no current `IOLoop` will automatically become current. """ IOLoop._current.instance = self @staticmethod def clear_current(): IOLoop._current.instance = None @classmethod def configurable_base(cls): return IOLoop @classmethod def configurable_default(cls): if hasattr(select, "epoll"): from tornado.platform.epoll import EPollIOLoop return EPollIOLoop if hasattr(select, "kqueue"): # Python 2.6+ on BSD or Mac from tornado.platform.kqueue import KQueueIOLoop return KQueueIOLoop from tornado.platform.select import SelectIOLoop return SelectIOLoop def initialize(self, make_current=None): if make_current is None: if IOLoop.current(instance=False) is None: self.make_current() elif make_current: if IOLoop.current(instance=False) is None: raise RuntimeError("current IOLoop already exists") self.make_current() def close(self, all_fds=False): """Closes the `IOLoop`, freeing any resources used. If ``all_fds`` is true, all file descriptors registered on the IOLoop will be closed (not just the ones created by the `IOLoop` itself). Many applications will only use a single `IOLoop` that runs for the entire lifetime of the process. In that case closing the `IOLoop` is not necessary since everything will be cleaned up when the process exits. `IOLoop.close` is provided mainly for scenarios such as unit tests, which create and destroy a large number of ``IOLoops``. An `IOLoop` must be completely stopped before it can be closed. This means that `IOLoop.stop()` must be called *and* `IOLoop.start()` must be allowed to return before attempting to call `IOLoop.close()`. Therefore the call to `close` will usually appear just after the call to `start` rather than near the call to `stop`. .. versionchanged:: 3.1 If the `IOLoop` implementation supports non-integer objects for "file descriptors", those objects will have their ``close`` method when ``all_fds`` is true. """ raise NotImplementedError() def add_handler(self, fd, handler, events): """Registers the given handler to receive the given events for ``fd``. The ``fd`` argument may either be an integer file descriptor or a file-like object with a ``fileno()`` method (and optionally a ``close()`` method, which may be called when the `IOLoop` is shut down). The ``events`` argument is a bitwise or of the constants ``IOLoop.READ``, ``IOLoop.WRITE``, and ``IOLoop.ERROR``. When an event occurs, ``handler(fd, events)`` will be run. .. versionchanged:: 4.0 Added the ability to pass file-like objects in addition to raw file descriptors. """ raise NotImplementedError() def update_handler(self, fd, events): """Changes the events we listen for ``fd``. .. versionchanged:: 4.0 Added the ability to pass file-like objects in addition to raw file descriptors. """ raise NotImplementedError() def remove_handler(self, fd): """Stop listening for events on ``fd``. .. versionchanged:: 4.0 Added the ability to pass file-like objects in addition to raw file descriptors. """ raise NotImplementedError() def set_blocking_signal_threshold(self, seconds, action): """Sends a signal if the `IOLoop` is blocked for more than ``s`` seconds. Pass ``seconds=None`` to disable. Requires Python 2.6 on a unixy platform. The action parameter is a Python signal handler. Read the documentation for the `signal` module for more information. If ``action`` is None, the process will be killed if it is blocked for too long. """ raise NotImplementedError() def set_blocking_log_threshold(self, seconds): """Logs a stack trace if the `IOLoop` is blocked for more than ``s`` seconds. Equivalent to ``set_blocking_signal_threshold(seconds, self.log_stack)`` """ self.set_blocking_signal_threshold(seconds, self.log_stack) def log_stack(self, signal, frame): """Signal handler to log the stack trace of the current thread. For use with `set_blocking_signal_threshold`. """ gen_log.warning('IOLoop blocked for %f seconds in\n%s', self._blocking_signal_threshold, ''.join(traceback.format_stack(frame))) def start(self): """Starts the I/O loop. The loop will run until one of the callbacks calls `stop()`, which will make the loop stop after the current event iteration completes. """ raise NotImplementedError() def _setup_logging(self): """The IOLoop catches and logs exceptions, so it's important that log output be visible. However, python's default behavior for non-root loggers (prior to python 3.2) is to print an unhelpful "no handlers could be found" message rather than the actual log entry, so we must explicitly configure logging if we've made it this far without anything. This method should be called from start() in subclasses. """ if not any([logging.getLogger().handlers, logging.getLogger('tornado').handlers, logging.getLogger('tornado.application').handlers]): logging.basicConfig() def stop(self): """Stop the I/O loop. If the event loop is not currently running, the next call to `start()` will return immediately. To use asynchronous methods from otherwise-synchronous code (such as unit tests), you can start and stop the event loop like this:: ioloop = IOLoop() async_method(ioloop=ioloop, callback=ioloop.stop) ioloop.start() ``ioloop.start()`` will return after ``async_method`` has run its callback, whether that callback was invoked before or after ``ioloop.start``. Note that even after `stop` has been called, the `IOLoop` is not completely stopped until `IOLoop.start` has also returned. Some work that was scheduled before the call to `stop` may still be run before the `IOLoop` shuts down. """ raise NotImplementedError() def run_sync(self, func, timeout=None): """Starts the `IOLoop`, runs the given function, and stops the loop. If the function returns a `.Future`, the `IOLoop` will run until the future is resolved. If it raises an exception, the `IOLoop` will stop and the exception will be re-raised to the caller. The keyword-only argument ``timeout`` may be used to set a maximum duration for the function. If the timeout expires, a `TimeoutError` is raised. This method is useful in conjunction with `tornado.gen.coroutine` to allow asynchronous calls in a ``main()`` function:: @gen.coroutine def main(): # do stuff... if __name__ == '__main__': IOLoop.current().run_sync(main) """ future_cell = [None] def run(): try: result = func() except Exception: future_cell[0] = TracebackFuture() future_cell[0].set_exc_info(sys.exc_info()) else: if is_future(result): future_cell[0] = result else: future_cell[0] = TracebackFuture() future_cell[0].set_result(result) self.add_future(future_cell[0], lambda future: self.stop()) self.add_callback(run) if timeout is not None: timeout_handle = self.add_timeout(self.time() + timeout, self.stop) self.start() if timeout is not None: self.remove_timeout(timeout_handle) if not future_cell[0].done(): raise TimeoutError('Operation timed out after %s seconds' % timeout) return future_cell[0].result() def time(self): """Returns the current time according to the `IOLoop`'s clock. The return value is a floating-point number relative to an unspecified time in the past. By default, the `IOLoop`'s time function is `time.time`. However, it may be configured to use e.g. `time.monotonic` instead. Calls to `add_timeout` that pass a number instead of a `datetime.timedelta` should use this function to compute the appropriate time, so they can work no matter what time function is chosen. """ return time.time() def add_timeout(self, deadline, callback, *args, **kwargs): """Runs the ``callback`` at the time ``deadline`` from the I/O loop. Returns an opaque handle that may be passed to `remove_timeout` to cancel. ``deadline`` may be a number denoting a time (on the same scale as `IOLoop.time`, normally `time.time`), or a `datetime.timedelta` object for a deadline relative to the current time. Since Tornado 4.0, `call_later` is a more convenient alternative for the relative case since it does not require a timedelta object. Note that it is not safe to call `add_timeout` from other threads. Instead, you must use `add_callback` to transfer control to the `IOLoop`'s thread, and then call `add_timeout` from there. Subclasses of IOLoop must implement either `add_timeout` or `call_at`; the default implementations of each will call the other. `call_at` is usually easier to implement, but subclasses that wish to maintain compatibility with Tornado versions prior to 4.0 must use `add_timeout` instead. .. versionchanged:: 4.0 Now passes through ``*args`` and ``**kwargs`` to the callback. """ if isinstance(deadline, numbers.Real): return self.call_at(deadline, callback, *args, **kwargs) elif isinstance(deadline, datetime.timedelta): return self.call_at(self.time() + timedelta_to_seconds(deadline), callback, *args, **kwargs) else: raise TypeError("Unsupported deadline %r" % deadline) def call_later(self, delay, callback, *args, **kwargs): """Runs the ``callback`` after ``delay`` seconds have passed. Returns an opaque handle that may be passed to `remove_timeout` to cancel. Note that unlike the `asyncio` method of the same name, the returned object does not have a ``cancel()`` method. See `add_timeout` for comments on thread-safety and subclassing. .. versionadded:: 4.0 """ return self.call_at(self.time() + delay, callback, *args, **kwargs) def call_at(self, when, callback, *args, **kwargs): """Runs the ``callback`` at the absolute time designated by ``when``. ``when`` must be a number using the same reference point as `IOLoop.time`. Returns an opaque handle that may be passed to `remove_timeout` to cancel. Note that unlike the `asyncio` method of the same name, the returned object does not have a ``cancel()`` method. See `add_timeout` for comments on thread-safety and subclassing. .. versionadded:: 4.0 """ return self.add_timeout(when, callback, *args, **kwargs) def remove_timeout(self, timeout): """Cancels a pending timeout. The argument is a handle as returned by `add_timeout`. It is safe to call `remove_timeout` even if the callback has already been run. """ raise NotImplementedError() def add_callback(self, callback, *args, **kwargs): """Calls the given callback on the next I/O loop iteration. It is safe to call this method from any thread at any time, except from a signal handler. Note that this is the **only** method in `IOLoop` that makes this thread-safety guarantee; all other interaction with the `IOLoop` must be done from that `IOLoop`'s thread. `add_callback()` may be used to transfer control from other threads to the `IOLoop`'s thread. To add a callback from a signal handler, see `add_callback_from_signal`. """ raise NotImplementedError() def add_callback_from_signal(self, callback, *args, **kwargs): """Calls the given callback on the next I/O loop iteration. Safe for use from a Python signal handler; should not be used otherwise. Callbacks added with this method will be run without any `.stack_context`, to avoid picking up the context of the function that was interrupted by the signal. """ raise NotImplementedError() def spawn_callback(self, callback, *args, **kwargs): """Calls the given callback on the next IOLoop iteration. Unlike all other callback-related methods on IOLoop, ``spawn_callback`` does not associate the callback with its caller's ``stack_context``, so it is suitable for fire-and-forget callbacks that should not interfere with the caller. .. versionadded:: 4.0 """ with stack_context.NullContext(): self.add_callback(callback, *args, **kwargs) def add_future(self, future, callback): """Schedules a callback on the ``IOLoop`` when the given `.Future` is finished. The callback is invoked with one argument, the `.Future`. """ assert is_future(future) callback = stack_context.wrap(callback) future.add_done_callback( lambda future: self.add_callback(callback, future)) def _run_callback(self, callback): """Runs a callback with error handling. For use in subclasses. """ try: ret = callback() if ret is not None and is_future(ret): # Functions that return Futures typically swallow all # exceptions and store them in the Future. If a Future # makes it out to the IOLoop, ensure its exception (if any) # gets logged too. self.add_future(ret, lambda f: f.result()) except Exception: self.handle_callback_exception(callback) def handle_callback_exception(self, callback): """This method is called whenever a callback run by the `IOLoop` throws an exception. By default simply logs the exception as an error. Subclasses may override this method to customize reporting of exceptions. The exception itself is not passed explicitly, but is available in `sys.exc_info`. """ app_log.error("Exception in callback %r", callback, exc_info=True) def split_fd(self, fd): """Returns an (fd, obj) pair from an ``fd`` parameter. We accept both raw file descriptors and file-like objects as input to `add_handler` and related methods. When a file-like object is passed, we must retain the object itself so we can close it correctly when the `IOLoop` shuts down, but the poller interfaces favor file descriptors (they will accept file-like objects and call ``fileno()`` for you, but they always return the descriptor itself). This method is provided for use by `IOLoop` subclasses and should not generally be used by application code. .. versionadded:: 4.0 """ try: return fd.fileno(), fd except AttributeError: return fd, fd def close_fd(self, fd): """Utility method to close an ``fd``. If ``fd`` is a file-like object, we close it directly; otherwise we use `os.close`. This method is provided for use by `IOLoop` subclasses (in implementations of ``IOLoop.close(all_fds=True)`` and should not generally be used by application code. .. versionadded:: 4.0 """ try: try: fd.close() except AttributeError: os.close(fd) except OSError: pass class PollIOLoop(IOLoop): """Base class for IOLoops built around a select-like function. For concrete implementations, see `tornado.platform.epoll.EPollIOLoop` (Linux), `tornado.platform.kqueue.KQueueIOLoop` (BSD and Mac), or `tornado.platform.select.SelectIOLoop` (all platforms). """ def initialize(self, impl, time_func=None, **kwargs): super(PollIOLoop, self).initialize(**kwargs) self._impl = impl if hasattr(self._impl, 'fileno'): set_close_exec(self._impl.fileno()) self.time_func = time_func or time.time self._handlers = {} self._events = {} self._callbacks = [] self._callback_lock = threading.Lock() self._timeouts = [] self._cancellations = 0 self._running = False self._stopped = False self._closing = False self._thread_ident = None self._blocking_signal_threshold = None self._timeout_counter = itertools.count() # Create a pipe that we send bogus data to when we want to wake # the I/O loop when it is idle self._waker = Waker() self.add_handler(self._waker.fileno(), lambda fd, events: self._waker.consume(), self.READ) def close(self, all_fds=False): with self._callback_lock: self._closing = True self.remove_handler(self._waker.fileno()) if all_fds: for fd, handler in self._handlers.values(): self.close_fd(fd) self._waker.close() self._impl.close() self._callbacks = None self._timeouts = None def add_handler(self, fd, handler, events): fd, obj = self.split_fd(fd) self._handlers[fd] = (obj, stack_context.wrap(handler)) self._impl.register(fd, events | self.ERROR) def update_handler(self, fd, events): fd, obj = self.split_fd(fd) self._impl.modify(fd, events | self.ERROR) def remove_handler(self, fd): fd, obj = self.split_fd(fd) self._handlers.pop(fd, None) self._events.pop(fd, None) try: self._impl.unregister(fd) except Exception: gen_log.debug("Error deleting fd from IOLoop", exc_info=True) def set_blocking_signal_threshold(self, seconds, action): if not hasattr(signal, "setitimer"): gen_log.error("set_blocking_signal_threshold requires a signal module " "with the setitimer method") return self._blocking_signal_threshold = seconds if seconds is not None: signal.signal(signal.SIGALRM, action if action is not None else signal.SIG_DFL) def start(self): if self._running: raise RuntimeError("IOLoop is already running") self._setup_logging() if self._stopped: self._stopped = False return old_current = getattr(IOLoop._current, "instance", None) IOLoop._current.instance = self self._thread_ident = thread.get_ident() self._running = True # signal.set_wakeup_fd closes a race condition in event loops: # a signal may arrive at the beginning of select/poll/etc # before it goes into its interruptible sleep, so the signal # will be consumed without waking the select. The solution is # for the (C, synchronous) signal handler to write to a pipe, # which will then be seen by select. # # In python's signal handling semantics, this only matters on the # main thread (fortunately, set_wakeup_fd only works on the main # thread and will raise a ValueError otherwise). # # If someone has already set a wakeup fd, we don't want to # disturb it. This is an issue for twisted, which does its # SIGCHLD processing in response to its own wakeup fd being # written to. As long as the wakeup fd is registered on the IOLoop, # the loop will still wake up and everything should work. old_wakeup_fd = None if hasattr(signal, 'set_wakeup_fd') and os.name == 'posix': # requires python 2.6+, unix. set_wakeup_fd exists but crashes # the python process on windows. try: old_wakeup_fd = signal.set_wakeup_fd(self._waker.write_fileno()) if old_wakeup_fd != -1: # Already set, restore previous value. This is a little racy, # but there's no clean get_wakeup_fd and in real use the # IOLoop is just started once at the beginning. signal.set_wakeup_fd(old_wakeup_fd) old_wakeup_fd = None except ValueError: # Non-main thread, or the previous value of wakeup_fd # is no longer valid. old_wakeup_fd = None try: while True: # Prevent IO event starvation by delaying new callbacks # to the next iteration of the event loop. with self._callback_lock: callbacks = self._callbacks self._callbacks = [] # Add any timeouts that have come due to the callback list. # Do not run anything until we have determined which ones # are ready, so timeouts that call add_timeout cannot # schedule anything in this iteration. due_timeouts = [] if self._timeouts: now = self.time() while self._timeouts: if self._timeouts[0].callback is None: # The timeout was cancelled. Note that the # cancellation check is repeated below for timeouts # that are cancelled by another timeout or callback. heapq.heappop(self._timeouts) self._cancellations -= 1 elif self._timeouts[0].deadline <= now: due_timeouts.append(heapq.heappop(self._timeouts)) else: break if (self._cancellations > 512 and self._cancellations > (len(self._timeouts) >> 1)): # Clean up the timeout queue when it gets large and it's # more than half cancellations. self._cancellations = 0 self._timeouts = [x for x in self._timeouts if x.callback is not None] heapq.heapify(self._timeouts) for callback in callbacks: self._run_callback(callback) for timeout in due_timeouts: if timeout.callback is not None: self._run_callback(timeout.callback) # Closures may be holding on to a lot of memory, so allow # them to be freed before we go into our poll wait. callbacks = callback = due_timeouts = timeout = None if self._callbacks: # If any callbacks or timeouts called add_callback, # we don't want to wait in poll() before we run them. poll_timeout = 0.0 elif self._timeouts: # If there are any timeouts, schedule the first one. # Use self.time() instead of 'now' to account for time # spent running callbacks. poll_timeout = self._timeouts[0].deadline - self.time() poll_timeout = max(0, min(poll_timeout, _POLL_TIMEOUT)) else: # No timeouts and no callbacks, so use the default. poll_timeout = _POLL_TIMEOUT if not self._running: break if self._blocking_signal_threshold is not None: # clear alarm so it doesn't fire while poll is waiting for # events. signal.setitimer(signal.ITIMER_REAL, 0, 0) try: event_pairs = self._impl.poll(poll_timeout) except Exception as e: # Depending on python version and IOLoop implementation, # different exception types may be thrown and there are # two ways EINTR might be signaled: # * e.errno == errno.EINTR # * e.args is like (errno.EINTR, 'Interrupted system call') if errno_from_exception(e) == errno.EINTR: continue else: raise if self._blocking_signal_threshold is not None: signal.setitimer(signal.ITIMER_REAL, self._blocking_signal_threshold, 0) # Pop one fd at a time from the set of pending fds and run # its handler. Since that handler may perform actions on # other file descriptors, there may be reentrant calls to # this IOLoop that update self._events self._events.update(event_pairs) while self._events: fd, events = self._events.popitem() try: fd_obj, handler_func = self._handlers[fd] handler_func(fd_obj, events) except (OSError, IOError) as e: if errno_from_exception(e) == errno.EPIPE: # Happens when the client closes the connection pass else: self.handle_callback_exception(self._handlers.get(fd)) except Exception: self.handle_callback_exception(self._handlers.get(fd)) fd_obj = handler_func = None finally: # reset the stopped flag so another start/stop pair can be issued self._stopped = False if self._blocking_signal_threshold is not None: signal.setitimer(signal.ITIMER_REAL, 0, 0) IOLoop._current.instance = old_current if old_wakeup_fd is not None: signal.set_wakeup_fd(old_wakeup_fd) def stop(self): self._running = False self._stopped = True self._waker.wake() def time(self): return self.time_func() def call_at(self, deadline, callback, *args, **kwargs): timeout = _Timeout( deadline, functools.partial(stack_context.wrap(callback), *args, **kwargs), self) heapq.heappush(self._timeouts, timeout) return timeout def remove_timeout(self, timeout): # Removing from a heap is complicated, so just leave the defunct # timeout object in the queue (see discussion in # http://docs.python.org/library/heapq.html). # If this turns out to be a problem, we could add a garbage # collection pass whenever there are too many dead timeouts. timeout.callback = None self._cancellations += 1 def add_callback(self, callback, *args, **kwargs): with self._callback_lock: if self._closing: raise RuntimeError("IOLoop is closing") list_empty = not self._callbacks self._callbacks.append(functools.partial( stack_context.wrap(callback), *args, **kwargs)) if list_empty and thread.get_ident() != self._thread_ident: # If we're in the IOLoop's thread, we know it's not currently # polling. If we're not, and we added the first callback to an # empty list, we may need to wake it up (it may wake up on its # own, but an occasional extra wake is harmless). Waking # up a polling IOLoop is relatively expensive, so we try to # avoid it when we can. self._waker.wake() def add_callback_from_signal(self, callback, *args, **kwargs): with stack_context.NullContext(): if thread.get_ident() != self._thread_ident: # if the signal is handled on another thread, we can add # it normally (modulo the NullContext) self.add_callback(callback, *args, **kwargs) else: # If we're on the IOLoop's thread, we cannot use # the regular add_callback because it may deadlock on # _callback_lock. Blindly insert into self._callbacks. # This is safe because the GIL makes list.append atomic. # One subtlety is that if the signal interrupted the # _callback_lock block in IOLoop.start, we may modify # either the old or new version of self._callbacks, # but either way will work. self._callbacks.append(functools.partial( stack_context.wrap(callback), *args, **kwargs)) class _Timeout(object): """An IOLoop timeout, a UNIX timestamp and a callback""" # Reduce memory overhead when there are lots of pending callbacks __slots__ = ['deadline', 'callback', 'tiebreaker'] def __init__(self, deadline, callback, io_loop): if not isinstance(deadline, numbers.Real): raise TypeError("Unsupported deadline %r" % deadline) self.deadline = deadline self.callback = callback self.tiebreaker = next(io_loop._timeout_counter) # Comparison methods to sort by deadline, with object id as a tiebreaker # to guarantee a consistent ordering. The heapq module uses __le__ # in python2.5, and __lt__ in 2.6+ (sort() and most other comparisons # use __lt__). def __lt__(self, other): return ((self.deadline, self.tiebreaker) < (other.deadline, other.tiebreaker)) def __le__(self, other): return ((self.deadline, self.tiebreaker) <= (other.deadline, other.tiebreaker)) class PeriodicCallback(object): """Schedules the given callback to be called periodically. The callback is called every ``callback_time`` milliseconds. Note that the timeout is given in milliseconds, while most other time-related functions in Tornado use seconds. If the callback runs for longer than ``callback_time`` milliseconds, subsequent invocations will be skipped to get back on schedule. `start` must be called after the `PeriodicCallback` is created. .. versionchanged:: 4.1 The ``io_loop`` argument is deprecated. """ def __init__(self, callback, callback_time, io_loop=None): self.callback = callback if callback_time <= 0: raise ValueError("Periodic callback must have a positive callback_time") self.callback_time = callback_time self.io_loop = io_loop or IOLoop.current() self._running = False self._timeout = None def start(self): """Starts the timer.""" self._running = True self._next_timeout = self.io_loop.time() self._schedule_next() def stop(self): """Stops the timer.""" self._running = False if self._timeout is not None: self.io_loop.remove_timeout(self._timeout) self._timeout = None def is_running(self): """Return True if this `.PeriodicCallback` has been started. .. versionadded:: 4.1 """ return self._running def _run(self): if not self._running: return try: return self.callback() except Exception: self.io_loop.handle_callback_exception(self.callback) finally: self._schedule_next() def _schedule_next(self): if self._running: current_time = self.io_loop.time() if self._next_timeout <= current_time: callback_time_sec = self.callback_time / 1000.0 self._next_timeout += (math.floor((current_time - self._next_timeout) / callback_time_sec) + 1) * callback_time_sec self._timeout = self.io_loop.add_timeout(self._next_timeout, self._run)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 8937, 27107, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 624, 2493, 473, 15, 47, 1566, 4438, 367, 2222, 13, 13091, 18772, 14, 199, 199, 26876, 13103, 911, 675, 282, 2849, 658, 23152, 64, 909, 12, 315, 314, 199, 64, 23152, 14, 842, 64, 19768, 14, 221, 710, 658, 23152, 14, 928, 64, 1083, 1077, 9987, 199, 1235, 2797, 737, 314, 1284, 402, 314, 1124, 973, 8497, 805, 14, 221, 437, 9749, 2652, 13103, 1443, 199, 1180, 1655, 2419, 1373, 658, 23152, 3559, 4066, 465, 1373, 658, 23152, 64, 1126, 2462, 12, 503, 1126, 658, 2796, 64, 199, 2546, 14, 199, 199, 607, 10234, 370, 473, 15, 47, 4474, 12, 314, 658, 23152, 64, 883, 2597, 8732, 900, 13, 6788, 4474, 14, 199, 64, 23152, 14, 525, 63, 2593, 64, 365, 282, 2222, 13, 13091, 13943, 370, 658, 521, 14, 4532, 2313, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 543, 63, 6242, 199, 199, 646, 2197, 199, 646, 7554, 199, 646, 9143, 199, 646, 13295, 81, 199, 646, 7975, 199, 646, 2050, 199, 646, 5579, 199, 646, 747, 199, 646, 3504, 199, 646, 984, 199, 646, 5796, 199, 646, 900, 199, 646, 5190, 199, 646, 3473, 199, 199, 504, 12148, 14, 27237, 492, 15273, 14224, 12, 365, 63, 2443, 199, 504, 12148, 14, 793, 492, 1145, 63, 793, 12, 3805, 63, 793, 199, 504, 12148, 492, 3464, 63, 1100, 199, 504, 12148, 14, 1974, 492, 4094, 15684, 12, 7554, 63, 504, 63, 1971, 12, 6871, 63, 475, 63, 4515, 199, 199, 893, 26, 272, 492, 4673, 199, 2590, 3545, 26, 272, 4673, 275, 488, 199, 199, 893, 26, 272, 492, 2462, 221, 327, 1134, 18, 199, 2590, 3545, 26, 272, 492, 485, 2671, 465, 2462, 221, 327, 1134, 19, 199, 199, 504, 12148, 14, 3246, 14, 2495, 492, 663, 63, 1600, 63, 1628, 12, 644, 12630, 421, 199, 63, 16428, 63, 8899, 275, 15751, 14, 16, 421, 199, 533, 31886, 8, 1726, 304, 272, 986, 421, 199, 533, 25584, 8, 2028, 15684, 304, 272, 408, 33, 2166, 13, 21142, 473, 15, 47, 4438, 14, 339, 2136, 675, 1124, 1545, 14385, 1040, 334, 14091, 9, 503, 1124, 75, 1825, 1040, 334, 15400, 436, 10444, 4403, 1323, 9, 340, 2985, 272, 787, 2808, 12, 503, 587, 781, 11264, 1771, 641, 3504, 1252, 982, 1265, 787, 272, 18234, 282, 2656, 626, 4839, 370, 2429, 294, 29737, 402, 272, 27008, 6947, 12, 1265, 1077, 675, 282, 2656, 626, 5171, 272, 1902, 1124, 1545, 14385, 1040, 503, 1124, 75, 1825, 4345, 339, 5679, 4503, 367, 282, 3486, 13488, 1654, 26, 339, 2508, 511, 600, 447, 398, 492, 7554, 267, 492, 9143, 267, 492, 12148, 14, 27212, 267, 492, 2838, 398, 347, 1950, 63, 2179, 8, 5096, 12, 6111, 12, 4474, 304, 288, 1830, 715, 26, 355, 862, 26, 490, 1950, 12, 2287, 275, 6771, 14, 5694, 342, 355, 871, 2838, 14, 705, 465, 325, 26, 490, 340, 325, 14, 589, 59, 16, 61, 440, 315, 334, 7931, 14, 37, 11325, 1293, 2846, 4406, 12, 7554, 14, 37, 1254, 9021, 304, 717, 746, 490, 372, 355, 1950, 14, 409, 13091, 8, 16, 9, 355, 2429, 63, 2105, 8, 2105, 12, 2287, 9, 398, 340, 636, 354, 363, 508, 2560, 973, 3706, 288, 6771, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 12, 378, 9, 288, 6771, 14, 27689, 8, 3450, 14, 15096, 63, 17462, 12, 2838, 14, 4118, 63, 907, 4701, 7803, 12, 413, 9, 288, 6771, 14, 409, 13091, 8, 16, 9, 288, 6771, 14, 3409, 1332, 5151, 1844, 430, 288, 6771, 14, 5859, 8, 3933, 9, 953, 5890, 63, 3813, 275, 12148, 14, 27212, 14, 23152, 14, 1818, 342, 288, 3233, 275, 9143, 14, 6672, 8, 2105, 63, 2179, 12, 6771, 9, 288, 5890, 63, 3813, 14, 525, 63, 2232, 8, 5096, 14, 9843, 1062, 3233, 12, 5890, 63, 3813, 14, 5670, 9, 288, 5890, 63, 3813, 14, 928, 342, 339, 2508, 511, 1199, 447, 2126, 520, 8191, 26, 339, 4885, 849, 12, 282, 13903, 13, 388, 11614, 658, 23152, 64, 15410, 314, 2462, 1159, 1453, 272, 658, 23152, 3559, 7444, 2337, 2575, 365, 282, 1453, 658, 23152, 2313, 961, 5953, 272, 883, 506, 22284, 543, 314, 1124, 1875, 63, 1818, 1040, 1423, 370, 314, 658, 23152, 64, 272, 3787, 26, 340, 1124, 1875, 63, 1818, 29, 549, 4542, 314, 892, 658, 23152, 64, 911, 3544, 272, 862, 370, 8649, 1453, 436, 652, 6534, 376, 1125, 340, 2337, 365, 2575, 282, 272, 1453, 1256, 14, 982, 1124, 1875, 63, 1818, 29, 797, 4542, 314, 892, 658, 23152, 64, 911, 272, 440, 862, 370, 8649, 1453, 14, 339, 2508, 16434, 447, 841, 14, 18, 2126, 16230, 314, 1124, 1875, 63, 1818, 1040, 4252, 1423, 370, 314, 658, 23152, 64, 2126, 3787, 14, 272, 408, 272, 327, 22296, 687, 314, 325, 6843, 859, 272, 485, 37, 16428, 568, 275, 378, 88, 4587, 272, 485, 37, 16428, 20076, 275, 378, 88, 7432, 272, 485, 37, 32713, 1484, 934, 275, 378, 88, 7979, 272, 485, 37, 16428, 2666, 275, 378, 88, 8662, 272, 485, 37, 16428, 40, 2160, 275, 378, 88, 9523, 272, 485, 37, 16428, 50, 13860, 2160, 275, 378, 88, 8269, 272, 485, 37, 16428, 615, 654, 40, 1387, 275, 334, 17, 5213 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 8937, 27107, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 624, 2493, 473, 15, 47, 1566, 4438, 367, 2222, 13, 13091, 18772, 14, 199, 199, 26876, 13103, 911, 675, 282, 2849, 658, 23152, 64, 909, 12, 315, 314, 199, 64, 23152, 14, 842, 64, 19768, 14, 221, 710, 658, 23152, 14, 928, 64, 1083, 1077, 9987, 199, 1235, 2797, 737, 314, 1284, 402, 314, 1124, 973, 8497, 805, 14, 221, 437, 9749, 2652, 13103, 1443, 199, 1180, 1655, 2419, 1373, 658, 23152, 3559, 4066, 465, 1373, 658, 23152, 64, 1126, 2462, 12, 503, 1126, 658, 2796, 64, 199, 2546, 14, 199, 199, 607, 10234, 370, 473, 15, 47, 4474, 12, 314, 658, 23152, 64, 883, 2597, 8732, 900, 13, 6788, 4474, 14, 199, 64, 23152, 14, 525, 63, 2593, 64, 365, 282, 2222, 13, 13091, 13943, 370, 658, 521, 14, 4532, 2313, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 543, 63, 6242, 199, 199, 646, 2197, 199, 646, 7554, 199, 646, 9143, 199, 646, 13295, 81, 199, 646, 7975, 199, 646, 2050, 199, 646, 5579, 199, 646, 747, 199, 646, 3504, 199, 646, 984, 199, 646, 5796, 199, 646, 900, 199, 646, 5190, 199, 646, 3473, 199, 199, 504, 12148, 14, 27237, 492, 15273, 14224, 12, 365, 63, 2443, 199, 504, 12148, 14, 793, 492, 1145, 63, 793, 12, 3805, 63, 793, 199, 504, 12148, 492, 3464, 63, 1100, 199, 504, 12148, 14, 1974, 492, 4094, 15684, 12, 7554, 63, 504, 63, 1971, 12, 6871, 63, 475, 63, 4515, 199, 199, 893, 26, 272, 492, 4673, 199, 2590, 3545, 26, 272, 4673, 275, 488, 199, 199, 893, 26, 272, 492, 2462, 221, 327, 1134, 18, 199, 2590, 3545, 26, 272, 492, 485, 2671, 465, 2462, 221, 327, 1134, 19, 199, 199, 504, 12148, 14, 3246, 14, 2495, 492, 663, 63, 1600, 63, 1628, 12, 644, 12630, 421, 199, 63, 16428, 63, 8899, 275, 15751, 14, 16, 421, 199, 533, 31886, 8, 1726, 304, 272, 986, 421, 199, 533, 25584, 8, 2028, 15684, 304, 272, 408, 33, 2166, 13, 21142, 473, 15, 47, 4438, 14, 339, 2136, 675, 1124, 1545, 14385, 1040, 334, 14091, 9, 503, 1124, 75, 1825, 1040, 334, 15400, 436, 10444, 4403, 1323, 9, 340, 2985, 272, 787, 2808, 12, 503, 587, 781, 11264, 1771, 641, 3504, 1252, 982, 1265, 787, 272, 18234, 282, 2656, 626, 4839, 370, 2429, 294, 29737, 402, 272, 27008, 6947, 12, 1265, 1077, 675, 282, 2656, 626, 5171, 272, 1902, 1124, 1545, 14385, 1040, 503, 1124, 75, 1825, 4345, 339, 5679, 4503, 367, 282, 3486, 13488, 1654, 26, 339, 2508, 511, 600, 447, 398, 492, 7554, 267, 492, 9143, 267, 492, 12148, 14, 27212, 267, 492, 2838, 398, 347, 1950, 63, 2179, 8, 5096, 12, 6111, 12, 4474, 304, 288, 1830, 715, 26, 355, 862, 26, 490, 1950, 12, 2287, 275, 6771, 14, 5694, 342, 355, 871, 2838, 14, 705, 465, 325, 26, 490, 340, 325, 14, 589, 59, 16, 61, 440, 315, 334, 7931, 14, 37, 11325, 1293, 2846, 4406, 12, 7554, 14, 37, 1254, 9021, 304, 717, 746, 490, 372, 355, 1950, 14, 409, 13091, 8, 16, 9, 355, 2429, 63, 2105, 8, 2105, 12, 2287, 9, 398, 340, 636, 354, 363, 508, 2560, 973, 3706, 288, 6771, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 12, 378, 9, 288, 6771, 14, 27689, 8, 3450, 14, 15096, 63, 17462, 12, 2838, 14, 4118, 63, 907, 4701, 7803, 12, 413, 9, 288, 6771, 14, 409, 13091, 8, 16, 9, 288, 6771, 14, 3409, 1332, 5151, 1844, 430, 288, 6771, 14, 5859, 8, 3933, 9, 953, 5890, 63, 3813, 275, 12148, 14, 27212, 14, 23152, 14, 1818, 342, 288, 3233, 275, 9143, 14, 6672, 8, 2105, 63, 2179, 12, 6771, 9, 288, 5890, 63, 3813, 14, 525, 63, 2232, 8, 5096, 14, 9843, 1062, 3233, 12, 5890, 63, 3813, 14, 5670, 9, 288, 5890, 63, 3813, 14, 928, 342, 339, 2508, 511, 1199, 447, 2126, 520, 8191, 26, 339, 4885, 849, 12, 282, 13903, 13, 388, 11614, 658, 23152, 64, 15410, 314, 2462, 1159, 1453, 272, 658, 23152, 3559, 7444, 2337, 2575, 365, 282, 1453, 658, 23152, 2313, 961, 5953, 272, 883, 506, 22284, 543, 314, 1124, 1875, 63, 1818, 1040, 1423, 370, 314, 658, 23152, 64, 272, 3787, 26, 340, 1124, 1875, 63, 1818, 29, 549, 4542, 314, 892, 658, 23152, 64, 911, 3544, 272, 862, 370, 8649, 1453, 436, 652, 6534, 376, 1125, 340, 2337, 365, 2575, 282, 272, 1453, 1256, 14, 982, 1124, 1875, 63, 1818, 29, 797, 4542, 314, 892, 658, 23152, 64, 911, 272, 440, 862, 370, 8649, 1453, 14, 339, 2508, 16434, 447, 841, 14, 18, 2126, 16230, 314, 1124, 1875, 63, 1818, 1040, 4252, 1423, 370, 314, 658, 23152, 64, 2126, 3787, 14, 272, 408, 272, 327, 22296, 687, 314, 325, 6843, 859, 272, 485, 37, 16428, 568, 275, 378, 88, 4587, 272, 485, 37, 16428, 20076, 275, 378, 88, 7432, 272, 485, 37, 32713, 1484, 934, 275, 378, 88, 7979, 272, 485, 37, 16428, 2666, 275, 378, 88, 8662, 272, 485, 37, 16428, 40, 2160, 275, 378, 88, 9523, 272, 485, 37, 16428, 50, 13860, 2160, 275, 378, 88, 8269, 272, 485, 37, 16428, 615, 654, 40, 1387, 275, 334, 17, 5213, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1,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ablib-develop/test_tablib.py
6
19930
#!/usr/bin/env python # -*- coding: utf-8 -*- """Tests for Tablib.""" import unittest import sys import os import tablib from tablib.compat import markup, unicode class TablibTestCase(unittest.TestCase): """Tablib test cases.""" def setUp(self): """Create simple data set with headers.""" global data, book data = tablib.Dataset() book = tablib.Databook() self.headers = ('first_name', 'last_name', 'gpa') self.john = ('John', 'Adams', 90) self.george = ('George', 'Washington', 67) self.tom = ('Thomas', 'Jefferson', 50) self.founders = tablib.Dataset(headers=self.headers, title='Founders') self.founders.append(self.john) self.founders.append(self.george) self.founders.append(self.tom) def tearDown(self): """Teardown.""" pass def test_empty_append(self): """Verify append() correctly adds tuple with no headers.""" new_row = (1, 2, 3) data.append(new_row) # Verify width/data self.assertTrue(data.width == len(new_row)) self.assertTrue(data[0] == new_row) def test_empty_append_with_headers(self): """Verify append() correctly detects mismatch of number of headers and data. """ data.headers = ['first', 'second'] new_row = (1, 2, 3, 4) self.assertRaises(tablib.InvalidDimensions, data.append, new_row) def test_set_headers_with_incorrect_dimension(self): """Verify headers correctly detects mismatch of number of headers and data. """ data.append(self.john) def set_header_callable(): data.headers = ['first_name'] self.assertRaises(tablib.InvalidDimensions, set_header_callable) def test_add_column(self): """Verify adding column works with/without headers.""" data.append(['kenneth']) data.append(['bessie']) new_col = ['reitz', 'monke'] data.append_col(new_col) self.assertEqual(data[0], ('kenneth', 'reitz')) self.assertEqual(data.width, 2) # With Headers data.headers = ('fname', 'lname') new_col = [21, 22] data.append_col(new_col, header='age') self.assertEqual(data['age'], new_col) def test_add_column_no_data_no_headers(self): """Verify adding new column with no headers.""" new_col = ('reitz', 'monke') data.append_col(new_col) self.assertEqual(data[0], tuple([new_col[0]])) self.assertEqual(data.width, 1) self.assertEqual(data.height, len(new_col)) def test_add_column_with_header_ignored(self): """Verify append_col() ignores the header if data.headers has not previously been set """ new_col = ('reitz', 'monke') data.append_col(new_col, header='first_name') self.assertEqual(data[0], tuple([new_col[0]])) self.assertEqual(data.width, 1) self.assertEqual(data.height, len(new_col)) self.assertEqual(data.headers, None) def test_add_column_with_header_and_headers_only_exist(self): """Verify append_col() with header correctly detects mismatch when headers exist but there is no existing row data """ data.headers = ['first_name'] #no data new_col = ('allen') def append_col_callable(): data.append_col(new_col, header='middle_name') self.assertRaises(tablib.InvalidDimensions, append_col_callable) def test_add_column_with_header_and_data_exists(self): """Verify append_col() works when headers and rows exists""" data.headers = self.headers data.append(self.john) new_col = [10]; data.append_col(new_col, header='age') self.assertEqual(data.height, 1) self.assertEqual(data.width, len(self.john) + 1) self.assertEqual(data['age'], new_col) self.assertEqual(len(data.headers), len(self.headers) + 1) def test_add_callable_column(self): """Verify adding column with values specified as callable.""" new_col = lambda x: x[0] self.founders.append_col(new_col, header='first_again') def test_header_slicing(self): """Verify slicing by headers.""" self.assertEqual(self.founders['first_name'], [self.john[0], self.george[0], self.tom[0]]) self.assertEqual(self.founders['last_name'], [self.john[1], self.george[1], self.tom[1]]) self.assertEqual(self.founders['gpa'], [self.john[2], self.george[2], self.tom[2]]) def test_get_col(self): """Verify getting columns by index""" self.assertEqual( self.founders.get_col(list(self.headers).index('first_name')), [self.john[0], self.george[0], self.tom[0]]) self.assertEqual( self.founders.get_col(list(self.headers).index('last_name')), [self.john[1], self.george[1], self.tom[1]]) self.assertEqual( self.founders.get_col(list(self.headers).index('gpa')), [self.john[2], self.george[2], self.tom[2]]) def test_data_slicing(self): """Verify slicing by data.""" # Slice individual rows self.assertEqual(self.founders[0], self.john) self.assertEqual(self.founders[:1], [self.john]) self.assertEqual(self.founders[1:2], [self.george]) self.assertEqual(self.founders[-1], self.tom) self.assertEqual(self.founders[3:], []) # Slice multiple rows self.assertEqual(self.founders[:], [self.john, self.george, self.tom]) self.assertEqual(self.founders[0:2], [self.john, self.george]) self.assertEqual(self.founders[1:3], [self.george, self.tom]) self.assertEqual(self.founders[2:], [self.tom]) def test_delete(self): """Verify deleting from dataset works.""" # Delete from front of object del self.founders[0] self.assertEqual(self.founders[:], [self.george, self.tom]) # Verify dimensions, width should NOT change self.assertEqual(self.founders.height, 2) self.assertEqual(self.founders.width, 3) # Delete from back of object del self.founders[1] self.assertEqual(self.founders[:], [self.george]) # Verify dimensions, width should NOT change self.assertEqual(self.founders.height, 1) self.assertEqual(self.founders.width, 3) # Delete from invalid index self.assertRaises(IndexError, self.founders.__delitem__, 3) def test_csv_export(self): """Verify exporting dataset object as CSV.""" # Build up the csv string with headers first, followed by each row csv = '' for col in self.headers: csv += col + ',' csv = csv.strip(',') + '\r\n' for founder in self.founders: for col in founder: csv += str(col) + ',' csv = csv.strip(',') + '\r\n' self.assertEqual(csv, self.founders.csv) def test_tsv_export(self): """Verify exporting dataset object as TSV.""" # Build up the tsv string with headers first, followed by each row tsv = '' for col in self.headers: tsv += col + '\t' tsv = tsv.strip('\t') + '\r\n' for founder in self.founders: for col in founder: tsv += str(col) + '\t' tsv = tsv.strip('\t') + '\r\n' self.assertEqual(tsv, self.founders.tsv) def test_html_export(self): """HTML export""" html = markup.page() html.table.open() html.thead.open() html.tr(markup.oneliner.th(self.founders.headers)) html.thead.close() for founder in self.founders: html.tr(markup.oneliner.td(founder)) html.table.close() html = str(html) self.assertEqual(html, self.founders.html) def test_html_export_none_value(self): """HTML export""" html = markup.page() html.table.open() html.thead.open() html.tr(markup.oneliner.th(['foo','', 'bar'])) html.thead.close() html.tr(markup.oneliner.td(['foo','', 'bar'])) html.table.close() html = str(html) headers = ['foo', None, 'bar']; d = tablib.Dataset(['foo', None, 'bar'], headers=headers) self.assertEqual(html, d.html) def test_unicode_append(self): """Passes in a single unicode character and exports.""" new_row = (u'å', u'é') data.append(new_row) data.json data.yaml data.csv data.tsv data.xls data.xlsx data.ods data.html def test_book_export_no_exceptions(self): """Test that various exports don't error out.""" book = tablib.Databook() book.add_sheet(data) book.json book.yaml book.xls book.xlsx book.ods def test_json_import_set(self): """Generate and import JSON set serialization.""" data.append(self.john) data.append(self.george) data.headers = self.headers _json = data.json data.json = _json self.assertEqual(_json, data.json) def test_json_import_book(self): """Generate and import JSON book serialization.""" data.append(self.john) data.append(self.george) data.headers = self.headers book.add_sheet(data) _json = book.json book.json = _json self.assertEqual(_json, book.json) def test_yaml_import_set(self): """Generate and import YAML set serialization.""" data.append(self.john) data.append(self.george) data.headers = self.headers _yaml = data.yaml data.yaml = _yaml self.assertEqual(_yaml, data.yaml) def test_yaml_import_book(self): """Generate and import YAML book serialization.""" data.append(self.john) data.append(self.george) data.headers = self.headers book.add_sheet(data) _yaml = book.yaml book.yaml = _yaml self.assertEqual(_yaml, book.yaml) def test_csv_import_set(self): """Generate and import CSV set serialization.""" data.append(self.john) data.append(self.george) data.headers = self.headers _csv = data.csv data.csv = _csv self.assertEqual(_csv, data.csv) def test_csv_import_set_with_spaces(self): """Generate and import CSV set serialization when row values have spaces.""" data.append(('Bill Gates', 'Microsoft')) data.append(('Steve Jobs', 'Apple')) data.headers = ('Name', 'Company') _csv = data.csv data.csv = _csv self.assertEqual(_csv, data.csv) def test_tsv_import_set(self): """Generate and import TSV set serialization.""" data.append(self.john) data.append(self.george) data.headers = self.headers _tsv = data.tsv data.tsv = _tsv self.assertEqual(_tsv, data.tsv) def test_csv_format_detect(self): """Test CSV format detection.""" _csv = ( '1,2,3\n' '4,5,6\n' '7,8,9\n' ) _bunk = ( '¡¡¡¡¡¡¡¡£™∞¢£§∞§¶•¶ª∞¶•ªº••ª–º§•†•§º¶•†¥ª–º•§ƒø¥¨©πƒø†ˆ¥ç©¨√øˆ¥≈†ƒ¥ç©ø¨çˆ¥ƒçø¶' ) self.assertTrue(tablib.formats.csv.detect(_csv)) self.assertFalse(tablib.formats.csv.detect(_bunk)) def test_tsv_format_detect(self): """Test TSV format detection.""" _tsv = ( '1\t2\t3\n' '4\t5\t6\n' '7\t8\t9\n' ) _bunk = ( '¡¡¡¡¡¡¡¡£™∞¢£§∞§¶•¶ª∞¶•ªº••ª–º§•†•§º¶•†¥ª–º•§ƒø¥¨©πƒø†ˆ¥ç©¨√øˆ¥≈†ƒ¥ç©ø¨çˆ¥ƒçø¶' ) self.assertTrue(tablib.formats.tsv.detect(_tsv)) self.assertFalse(tablib.formats.tsv.detect(_bunk)) def test_json_format_detect(self): """Test JSON format detection.""" _json = '[{"last_name": "Adams","age": 90,"first_name": "John"}]' _bunk = ( '¡¡¡¡¡¡¡¡£™∞¢£§∞§¶•¶ª∞¶•ªº••ª–º§•†•§º¶•†¥ª–º•§ƒø¥¨©πƒø†ˆ¥ç©¨√øˆ¥≈†ƒ¥ç©ø¨çˆ¥ƒçø¶' ) self.assertTrue(tablib.formats.json.detect(_json)) self.assertFalse(tablib.formats.json.detect(_bunk)) def test_yaml_format_detect(self): """Test YAML format detection.""" _yaml = '- {age: 90, first_name: John, last_name: Adams}' _tsv = 'foo\tbar' _bunk = ( '¡¡¡¡¡¡---///\n\n\n¡¡£™∞¢£§∞§¶•¶ª∞¶•ªº••ª–º§•†•§º¶•†¥ª–º•§ƒø¥¨©πƒø†ˆ¥ç©¨√øˆ¥≈†ƒ¥ç©ø¨çˆ¥ƒçø¶' ) self.assertTrue(tablib.formats.yaml.detect(_yaml)) self.assertFalse(tablib.formats.yaml.detect(_bunk)) self.assertFalse(tablib.formats.yaml.detect(_tsv)) def test_auto_format_detect(self): """Test auto format detection.""" _yaml = '- {age: 90, first_name: John, last_name: Adams}' _json = '[{"last_name": "Adams","age": 90,"first_name": "John"}]' _csv = '1,2,3\n4,5,6\n7,8,9\n' _tsv = '1\t2\t3\n4\t5\t6\n7\t8\t9\n' _bunk = '¡¡¡¡¡¡---///\n\n\n¡¡£™∞¢£§∞§¶•¶ª∞¶•ªº••ª–º§•†•§º¶•†¥ª–º•§ƒø¥¨©πƒø†ˆ¥ç©¨√øˆ¥≈†ƒ¥ç©ø¨çˆ¥ƒçø¶' self.assertEqual(tablib.detect(_yaml)[0], tablib.formats.yaml) self.assertEqual(tablib.detect(_csv)[0], tablib.formats.csv) self.assertEqual(tablib.detect(_tsv)[0], tablib.formats.tsv) self.assertEqual(tablib.detect(_json)[0], tablib.formats.json) self.assertEqual(tablib.detect(_bunk)[0], None) def test_transpose(self): """Transpose a dataset.""" transposed_founders = self.founders.transpose() first_row = transposed_founders[0] second_row = transposed_founders[1] self.assertEqual(transposed_founders.headers, ["first_name","John", "George", "Thomas"]) self.assertEqual(first_row, ("last_name","Adams", "Washington", "Jefferson")) self.assertEqual(second_row, ("gpa",90, 67, 50)) def test_row_stacking(self): """Row stacking.""" to_join = tablib.Dataset(headers=self.founders.headers) for row in self.founders: to_join.append(row=row) row_stacked = self.founders.stack(to_join) for column in row_stacked.headers: original_data = self.founders[column] expected_data = original_data + original_data self.assertEqual(row_stacked[column], expected_data) def test_column_stacking(self): """Column stacking""" to_join = tablib.Dataset(headers=self.founders.headers) for row in self.founders: to_join.append(row=row) column_stacked = self.founders.stack_cols(to_join) for index, row in enumerate(column_stacked): original_data = self.founders[index] expected_data = original_data + original_data self.assertEqual(row, expected_data) self.assertEqual(column_stacked[0], ("John", "Adams", 90, "John", "Adams", 90)) def test_sorting(self): """Sort columns.""" sorted_data = self.founders.sort(col="first_name") self.assertEqual(sorted_data.title, 'Founders') first_row = sorted_data[0] second_row = sorted_data[2] third_row = sorted_data[1] expected_first = self.founders[1] expected_second = self.founders[2] expected_third = self.founders[0] self.assertEqual(first_row, expected_first) self.assertEqual(second_row, expected_second) self.assertEqual(third_row, expected_third) def test_wipe(self): """Purge a dataset.""" new_row = (1, 2, 3) data.append(new_row) # Verify width/data self.assertTrue(data.width == len(new_row)) self.assertTrue(data[0] == new_row) data.wipe() new_row = (1, 2, 3, 4) data.append(new_row) self.assertTrue(data.width == len(new_row)) self.assertTrue(data[0] == new_row) def test_formatters(self): """Confirm formatters are being triggered.""" def _formatter(cell_value): return str(cell_value).upper() self.founders.add_formatter('last_name', _formatter) for name in [r['last_name'] for r in self.founders.dict]: self.assertTrue(name.isupper()) def test_unicode_csv(self): """Check if unicode in csv export doesn't raise.""" data = tablib.Dataset() if sys.version_info[0] > 2: data.append(['\xfc', '\xfd']) else: exec("data.append([u'\xfc', u'\xfd'])") data.csv def test_csv_column_select(self): """Build up a CSV and test selecting a column""" data = tablib.Dataset() data.csv = self.founders.csv headers = data.headers self.assertTrue(isinstance(headers[0], unicode)) orig_first_name = self.founders[self.headers[0]] csv_first_name = data[headers[0]] self.assertEquals(orig_first_name, csv_first_name) def test_csv_column_delete(self): """Build up a CSV and test deleting a column""" data = tablib.Dataset() data.csv = self.founders.csv target_header = data.headers[0] self.assertTrue(isinstance(target_header, unicode)) del data[target_header] self.assertTrue(target_header not in data.headers) def test_csv_column_sort(self): """Build up a CSV and test sorting a column by name""" data = tablib.Dataset() data.csv = self.founders.csv orig_target_header = self.founders.headers[1] target_header = data.headers[1] self.founders.sort(orig_target_header) data.sort(target_header) self.assertEquals(self.founders[orig_target_header], data[target_header]) def test_unicode_renders_markdown_table(self): # add another entry to test right field width for # integer self.founders.append(('Old', 'Man', 100500)) self.assertEquals( """ first_name|last_name |gpa ----------|----------|------ John |Adams |90 George |Washington|67 Thomas |Jefferson |50 Old |Man |100500 """.strip(), unicode(self.founders) ) def test_databook_add_sheet_accepts_only_dataset_instances(self): class NotDataset(object): def append(self, item): pass dataset = NotDataset() dataset.append(self.john) self.assertRaises(tablib.InvalidDatasetType, book.add_sheet, dataset) def test_databook_add_sheet_accepts_dataset_subclasses(self): class DatasetSubclass(tablib.Dataset): pass # just checking if subclass of tablib.Dataset can be added to Databook dataset = DatasetSubclass() dataset.append(self.john) dataset.append(self.tom) try: book.add_sheet(dataset) except tablib.InvalidDatasetType: self.fail("Subclass of tablib.Dataset should be accepted by Databook.add_sheet") if __name__ == '__main__': unittest.main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 2925, 367, 23159, 773, 1041, 199, 199, 646, 2882, 199, 646, 984, 199, 646, 747, 199, 646, 5174, 773, 199, 504, 5174, 773, 14, 5819, 492, 9189, 12, 2649, 28154, 199, 533, 23159, 773, 1746, 8, 2796, 14, 1746, 304, 272, 408, 7690, 773, 511, 5560, 1041, 339, 347, 3613, 8, 277, 304, 267, 408, 2499, 3486, 666, 663, 543, 2323, 1041, 398, 2288, 666, 12, 6719, 398, 666, 275, 5174, 773, 14, 9271, 342, 267, 6719, 275, 5174, 773, 14, 36, 1936, 6992, 342, 398, 291, 14, 2139, 275, 661, 2246, 63, 354, 297, 283, 2019, 63, 354, 297, 283, 71, 387, 358, 267, 291, 14, 20216, 275, 661, 12923, 297, 283, 2767, 19470, 297, 9137, 9, 267, 291, 14, 303, 24591, 275, 661, 4240, 24591, 297, 283, 55, 1119, 31673, 297, 13296, 9, 267, 291, 14, 3151, 275, 661, 52, 526, 5892, 297, 283, 27888, 1260, 834, 297, 5238, 9, 398, 291, 14, 545, 7138, 83, 275, 5174, 773, 14, 9271, 8, 2139, 29, 277, 14, 2139, 12, 2538, 534, 15563, 7138, 83, 358, 267, 291, 14, 545, 7138, 83, 14, 740, 8, 277, 14, 20216, 9, 267, 291, 14, 545, 7138, 83, 14, 740, 8, 277, 14, 303, 24591, 9, 267, 291, 14, 545, 7138, 83, 14, 740, 8, 277, 14, 3151, 9, 2378, 347, 6766, 8, 277, 304, 267, 408, 6301, 10549, 1041, 267, 986, 2378, 347, 511, 63, 1667, 63, 740, 8, 277, 304, 267, 408, 7496, 5666, 342, 6657, 9584, 2008, 543, 949, 2323, 1041, 267, 892, 63, 1143, 275, 334, 17, 12, 499, 12, 650, 9, 267, 666, 14, 740, 8, 1222, 63, 1143, 9, 398, 327, 7635, 3462, 15, 576, 267, 291, 14, 1815, 8, 576, 14, 2063, 508, 822, 8, 1222, 63, 1143, 430, 267, 291, 14, 1815, 8, 576, 59, 16, 61, 508, 892, 63, 1143, 9, 2378, 347, 511, 63, 1667, 63, 740, 63, 1045, 63, 2139, 8, 277, 304, 267, 408, 7496, 5666, 342, 6657, 477, 28853, 15015, 402, 1329, 402, 267, 2323, 436, 666, 14, 267, 408, 267, 666, 14, 2139, 275, 788, 2246, 297, 283, 4375, 418, 267, 892, 63, 1143, 275, 334, 17, 12, 499, 12, 650, 12, 841, 9, 398, 291, 14, 1855, 8, 2902, 773, 14, 3364, 23370, 12, 666, 14, 740, 12, 892, 63, 1143, 9, 339, 347, 511, 63, 409, 63, 2139, 63, 1045, 63, 15448, 63, 7430, 8, 277, 304, 267, 408, 7496, 2323, 6657, 477, 28853, 15015, 402, 1329, 402, 267, 2323, 436, 666, 14, 267, 408, 398, 666, 14, 740, 8, 277, 14, 20216, 9, 398, 347, 663, 63, 1291, 63, 8296, 837, 288, 666, 14, 2139, 275, 788, 2246, 63, 354, 418, 398, 291, 14, 1855, 8, 2902, 773, 14, 3364, 23370, 12, 663, 63, 1291, 63, 8296, 9, 2378, 347, 511, 63, 525, 63, 2301, 8, 277, 304, 267, 408, 7496, 7791, 2763, 5419, 543, 15, 7395, 2323, 1041, 398, 666, 14, 740, 2941, 917, 685, 273, 1105, 267, 666, 14, 740, 2941, 11562, 23994, 1105, 398, 892, 63, 761, 275, 788, 264, 23751, 297, 283, 2106, 415, 418, 398, 666, 14, 740, 63, 761, 8, 1222, 63, 761, 9, 398, 291, 14, 629, 8, 576, 59, 16, 467, 661, 917, 685, 273, 297, 283, 264, 23751, 1333, 267, 291, 14, 629, 8, 576, 14, 2063, 12, 499, 9, 398, 327, 8777, 21391, 267, 666, 14, 2139, 275, 661, 5252, 297, 283, 76, 354, 358, 267, 892, 63, 761, 275, 359, 2025, 12, 6928, 61, 267, 666, 14, 740, 63, 761, 8, 1222, 63, 761, 12, 1406, 534, 474, 358, 398, 291, 14, 629, 8, 576, 459, 474, 995, 892, 63, 761, 9, 2378, 347, 511, 63, 525, 63, 2301, 63, 889, 63, 576, 63, 889, 63, 2139, 8, 277, 304, 267, 408, 7496, 7791, 892, 2763, 543, 949, 2323, 1041, 398, 892, 63, 761, 275, 661, 264, 23751, 297, 283, 2106, 415, 358, 398, 666, 14, 740, 63, 761, 8, 1222, 63, 761, 9, 398, 291, 14, 629, 8, 576, 59, 16, 467, 2008, 779, 1222, 63, 761, 59, 16, 17723, 267, 291, 14, 629, 8, 576, 14, 2063, 12, 413, 9, 267, 291, 14, 629, 8, 576, 14, 3333, 12, 822, 8, 1222, 63, 761, 430, 2378, 347, 511, 63, 525, 63, 2301, 63, 1045, 63, 1291, 63, 11996, 8, 277, 304, 267, 408, 7496, 5666, 63, 761, 342, 24010, 314, 1406, 340, 666, 14, 2139, 965, 267, 440, 10889, 2757, 663, 267, 408, 398, 892, 63, 761, 275, 661, 264, 23751, 297, 283, 2106, 415, 358, 398, 666, 14, 740, 63, 761, 8, 1222, 63, 761, 12, 1406, 534, 2246, 63, 354, 358, 398, 291, 14, 629, 8, 576, 59, 16, 467, 2008, 779, 1222, 63, 761, 59, 16, 17723, 267, 291, 14, 629, 8, 576, 14, 2063, 12, 413, 9, 267, 291, 14, 629, 8, 576, 14, 3333, 12, 822, 8, 1222, 63, 761, 430, 267, 291, 14, 629, 8, 576, 14, 2139, 12, 488, 9, 2378, 347, 511, 63, 525, 63, 2301, 63, 1045, 63, 1291, 63, 460, 63, 2139, 63, 2118, 63, 4494, 8, 277, 304, 267, 408, 7496, 5666, 63, 761, 342, 543, 1406, 6657, 477, 28853, 15015, 1380, 267, 2323, 2187, 1325, 2337, 365, 949, 3411, 1962, 666, 267, 408, 398, 666, 14, 2139, 275, 788, 2246, 63, 354, 418, 267, 327, 889, 666, 398, 892, 63, 761, 275, 661, 7670, 358, 398, 347, 5666, 63, 761, 63, 8296, 837, 288, 666, 14, 740, 63, 761, 8, 1222, 63, 761, 12, 1406, 534, 14885, 63, 354, 358, 398, 291, 14, 1855, 8, 2902, 773, 14, 3364, 23370, 12, 5666, 63, 761, 63, 8296, 9, 2378, 347, 511, 63, 525, 63, 2301, 63, 1045, 63, 1291, 63, 460, 63, 576, 63, 2444, 8, 277, 304, 267, 408, 7496, 5666, 63, 761, 342, 5419, 1380, 2323, 436, 4730, 3495, 624, 398, 666, 14, 2139, 275, 291, 14, 2139, 267, 666, 14, 740, 8, 277, 14, 20216, 9, 398, 892, 63, 761, 275, 359, 709, 11566, 398, 666, 14, 740, 63, 761, 8, 1222, 63, 761 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 2925, 367, 23159, 773, 1041, 199, 199, 646, 2882, 199, 646, 984, 199, 646, 747, 199, 646, 5174, 773, 199, 504, 5174, 773, 14, 5819, 492, 9189, 12, 2649, 28154, 199, 533, 23159, 773, 1746, 8, 2796, 14, 1746, 304, 272, 408, 7690, 773, 511, 5560, 1041, 339, 347, 3613, 8, 277, 304, 267, 408, 2499, 3486, 666, 663, 543, 2323, 1041, 398, 2288, 666, 12, 6719, 398, 666, 275, 5174, 773, 14, 9271, 342, 267, 6719, 275, 5174, 773, 14, 36, 1936, 6992, 342, 398, 291, 14, 2139, 275, 661, 2246, 63, 354, 297, 283, 2019, 63, 354, 297, 283, 71, 387, 358, 267, 291, 14, 20216, 275, 661, 12923, 297, 283, 2767, 19470, 297, 9137, 9, 267, 291, 14, 303, 24591, 275, 661, 4240, 24591, 297, 283, 55, 1119, 31673, 297, 13296, 9, 267, 291, 14, 3151, 275, 661, 52, 526, 5892, 297, 283, 27888, 1260, 834, 297, 5238, 9, 398, 291, 14, 545, 7138, 83, 275, 5174, 773, 14, 9271, 8, 2139, 29, 277, 14, 2139, 12, 2538, 534, 15563, 7138, 83, 358, 267, 291, 14, 545, 7138, 83, 14, 740, 8, 277, 14, 20216, 9, 267, 291, 14, 545, 7138, 83, 14, 740, 8, 277, 14, 303, 24591, 9, 267, 291, 14, 545, 7138, 83, 14, 740, 8, 277, 14, 3151, 9, 2378, 347, 6766, 8, 277, 304, 267, 408, 6301, 10549, 1041, 267, 986, 2378, 347, 511, 63, 1667, 63, 740, 8, 277, 304, 267, 408, 7496, 5666, 342, 6657, 9584, 2008, 543, 949, 2323, 1041, 267, 892, 63, 1143, 275, 334, 17, 12, 499, 12, 650, 9, 267, 666, 14, 740, 8, 1222, 63, 1143, 9, 398, 327, 7635, 3462, 15, 576, 267, 291, 14, 1815, 8, 576, 14, 2063, 508, 822, 8, 1222, 63, 1143, 430, 267, 291, 14, 1815, 8, 576, 59, 16, 61, 508, 892, 63, 1143, 9, 2378, 347, 511, 63, 1667, 63, 740, 63, 1045, 63, 2139, 8, 277, 304, 267, 408, 7496, 5666, 342, 6657, 477, 28853, 15015, 402, 1329, 402, 267, 2323, 436, 666, 14, 267, 408, 267, 666, 14, 2139, 275, 788, 2246, 297, 283, 4375, 418, 267, 892, 63, 1143, 275, 334, 17, 12, 499, 12, 650, 12, 841, 9, 398, 291, 14, 1855, 8, 2902, 773, 14, 3364, 23370, 12, 666, 14, 740, 12, 892, 63, 1143, 9, 339, 347, 511, 63, 409, 63, 2139, 63, 1045, 63, 15448, 63, 7430, 8, 277, 304, 267, 408, 7496, 2323, 6657, 477, 28853, 15015, 402, 1329, 402, 267, 2323, 436, 666, 14, 267, 408, 398, 666, 14, 740, 8, 277, 14, 20216, 9, 398, 347, 663, 63, 1291, 63, 8296, 837, 288, 666, 14, 2139, 275, 788, 2246, 63, 354, 418, 398, 291, 14, 1855, 8, 2902, 773, 14, 3364, 23370, 12, 663, 63, 1291, 63, 8296, 9, 2378, 347, 511, 63, 525, 63, 2301, 8, 277, 304, 267, 408, 7496, 7791, 2763, 5419, 543, 15, 7395, 2323, 1041, 398, 666, 14, 740, 2941, 917, 685, 273, 1105, 267, 666, 14, 740, 2941, 11562, 23994, 1105, 398, 892, 63, 761, 275, 788, 264, 23751, 297, 283, 2106, 415, 418, 398, 666, 14, 740, 63, 761, 8, 1222, 63, 761, 9, 398, 291, 14, 629, 8, 576, 59, 16, 467, 661, 917, 685, 273, 297, 283, 264, 23751, 1333, 267, 291, 14, 629, 8, 576, 14, 2063, 12, 499, 9, 398, 327, 8777, 21391, 267, 666, 14, 2139, 275, 661, 5252, 297, 283, 76, 354, 358, 267, 892, 63, 761, 275, 359, 2025, 12, 6928, 61, 267, 666, 14, 740, 63, 761, 8, 1222, 63, 761, 12, 1406, 534, 474, 358, 398, 291, 14, 629, 8, 576, 459, 474, 995, 892, 63, 761, 9, 2378, 347, 511, 63, 525, 63, 2301, 63, 889, 63, 576, 63, 889, 63, 2139, 8, 277, 304, 267, 408, 7496, 7791, 892, 2763, 543, 949, 2323, 1041, 398, 892, 63, 761, 275, 661, 264, 23751, 297, 283, 2106, 415, 358, 398, 666, 14, 740, 63, 761, 8, 1222, 63, 761, 9, 398, 291, 14, 629, 8, 576, 59, 16, 467, 2008, 779, 1222, 63, 761, 59, 16, 17723, 267, 291, 14, 629, 8, 576, 14, 2063, 12, 413, 9, 267, 291, 14, 629, 8, 576, 14, 3333, 12, 822, 8, 1222, 63, 761, 430, 2378, 347, 511, 63, 525, 63, 2301, 63, 1045, 63, 1291, 63, 11996, 8, 277, 304, 267, 408, 7496, 5666, 63, 761, 342, 24010, 314, 1406, 340, 666, 14, 2139, 965, 267, 440, 10889, 2757, 663, 267, 408, 398, 892, 63, 761, 275, 661, 264, 23751, 297, 283, 2106, 415, 358, 398, 666, 14, 740, 63, 761, 8, 1222, 63, 761, 12, 1406, 534, 2246, 63, 354, 358, 398, 291, 14, 629, 8, 576, 59, 16, 467, 2008, 779, 1222, 63, 761, 59, 16, 17723, 267, 291, 14, 629, 8, 576, 14, 2063, 12, 413, 9, 267, 291, 14, 629, 8, 576, 14, 3333, 12, 822, 8, 1222, 63, 761, 430, 267, 291, 14, 629, 8, 576, 14, 2139, 12, 488, 9, 2378, 347, 511, 63, 525, 63, 2301, 63, 1045, 63, 1291, 63, 460, 63, 2139, 63, 2118, 63, 4494, 8, 277, 304, 267, 408, 7496, 5666, 63, 761, 342, 543, 1406, 6657, 477, 28853, 15015, 1380, 267, 2323, 2187, 1325, 2337, 365, 949, 3411, 1962, 666, 267, 408, 398, 666, 14, 2139, 275, 788, 2246, 63, 354, 418, 267, 327, 889, 666, 398, 892, 63, 761, 275, 661, 7670, 358, 398, 347, 5666, 63, 761, 63, 8296, 837, 288, 666, 14, 740, 63, 761, 8, 1222, 63, 761, 12, 1406, 534, 14885, 63, 354, 358, 398, 291, 14, 1855, 8, 2902, 773, 14, 3364, 23370, 12, 5666, 63, 761, 63, 8296, 9, 2378, 347, 511, 63, 525, 63, 2301, 63, 1045, 63, 1291, 63, 460, 63, 576, 63, 2444, 8, 277, 304, 267, 408, 7496, 5666, 63, 761, 342, 5419, 1380, 2323, 436, 4730, 3495, 624, 398, 666, 14, 2139, 275, 291, 14, 2139, 267, 666, 14, 740, 8, 277, 14, 20216, 9, 398, 892, 63, 761, 275, 359, 709, 11566, 398, 666, 14, 740, 63, 761, 8, 1222, 63, 761, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
michalliu/OpenWrt-Firefly-Libraries
staging_dir/target-mipsel_1004kc+dsp_uClibc-0.9.33.2/usr/lib/python3.4/platform.py
75
49015
#!/usr/bin/env python3 """ This module tries to retrieve as much platform-identifying data as possible. It makes this information available via function APIs. If called from the command line, it prints the platform information concatenated as single string to stdout. The output format is useable as part of a filename. """ # This module is maintained by Marc-Andre Lemburg <mal@egenix.com>. # If you find problems, please submit bug reports/patches via the # Python bug tracker (http://bugs.python.org) and assign them to "lemburg". # # Still needed: # * more support for WinCE # * support for MS-DOS (PythonDX ?) # * support for Amiga and other still unsupported platforms running Python # * support for additional Linux distributions # # Many thanks to all those who helped adding platform-specific # checks (in no particular order): # # Charles G Waldman, David Arnold, Gordon McMillan, Ben Darnell, # Jeff Bauer, Cliff Crawford, Ivan Van Laningham, Josef # Betancourt, Randall Hopper, Karl Putland, John Farrell, Greg # Andruk, Just van Rossum, Thomas Heller, Mark R. Levinson, Mark # Hammond, Bill Tutt, Hans Nowak, Uwe Zessin (OpenVMS support), # Colin Kong, Trent Mick, Guido van Rossum, Anthony Baxter # # History: # # <see CVS and SVN checkin messages for history> # # 1.0.7 - added DEV_NULL # 1.0.6 - added linux_distribution() # 1.0.5 - fixed Java support to allow running the module on Jython # 1.0.4 - added IronPython support # 1.0.3 - added normalization of Windows system name # 1.0.2 - added more Windows support # 1.0.1 - reformatted to make doc.py happy # 1.0.0 - reformatted a bit and checked into Python CVS # 0.8.0 - added sys.version parser and various new access # APIs (python_version(), python_compiler(), etc.) # 0.7.2 - fixed architecture() to use sizeof(pointer) where available # 0.7.1 - added support for Caldera OpenLinux # 0.7.0 - some fixes for WinCE; untabified the source file # 0.6.2 - support for OpenVMS - requires version 1.5.2-V006 or higher and # vms_lib.getsyi() configured # 0.6.1 - added code to prevent 'uname -p' on platforms which are # known not to support it # 0.6.0 - fixed win32_ver() to hopefully work on Win95,98,NT and Win2k; # did some cleanup of the interfaces - some APIs have changed # 0.5.5 - fixed another type in the MacOS code... should have # used more coffee today ;-) # 0.5.4 - fixed a few typos in the MacOS code # 0.5.3 - added experimental MacOS support; added better popen() # workarounds in _syscmd_ver() -- still not 100% elegant # though # 0.5.2 - fixed uname() to return '' instead of 'unknown' in all # return values (the system uname command tends to return # 'unknown' instead of just leaving the field emtpy) # 0.5.1 - included code for slackware dist; added exception handlers # to cover up situations where platforms don't have os.popen # (e.g. Mac) or fail on socket.gethostname(); fixed libc # detection RE # 0.5.0 - changed the API names referring to system commands to *syscmd*; # added java_ver(); made syscmd_ver() a private # API (was system_ver() in previous versions) -- use uname() # instead; extended the win32_ver() to also return processor # type information # 0.4.0 - added win32_ver() and modified the platform() output for WinXX # 0.3.4 - fixed a bug in _follow_symlinks() # 0.3.3 - fixed popen() and "file" command invokation bugs # 0.3.2 - added architecture() API and support for it in platform() # 0.3.1 - fixed syscmd_ver() RE to support Windows NT # 0.3.0 - added system alias support # 0.2.3 - removed 'wince' again... oh well. # 0.2.2 - added 'wince' to syscmd_ver() supported platforms # 0.2.1 - added cache logic and changed the platform string format # 0.2.0 - changed the API to use functions instead of module globals # since some action take too long to be run on module import # 0.1.0 - first release # # You can always get the latest version of this module at: # # http://www.egenix.com/files/python/platform.py # # If that URL should fail, try contacting the author. __copyright__ = """ Copyright (c) 1999-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com Copyright (c) 2000-2010, eGenix.com Software GmbH; mailto:info@egenix.com Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee or royalty is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation or portions thereof, including modifications, that you make. EGENIX.COM SOFTWARE GMBH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE ! """ __version__ = '1.0.7' import collections import sys, os, re, subprocess ### Globals & Constants # Determine the platform's /dev/null device try: DEV_NULL = os.devnull except AttributeError: # os.devnull was added in Python 2.4, so emulate it for earlier # Python versions if sys.platform in ('dos', 'win32', 'win16'): # Use the old CP/M NUL as device name DEV_NULL = 'NUL' else: # Standard Unix uses /dev/null DEV_NULL = '/dev/null' # Directory to search for configuration information on Unix. # Constant used by test_platform to test linux_distribution(). _UNIXCONFDIR = '/etc' ### Platform specific APIs _libc_search = re.compile(b'(__libc_init)' b'|' b'(GLIBC_([0-9.]+))' b'|' br'(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)', re.ASCII) def libc_ver(executable=sys.executable, lib='', version='', chunksize=16384): """ Tries to determine the libc version that the file executable (which defaults to the Python interpreter) is linked against. Returns a tuple of strings (lib,version) which default to the given parameters in case the lookup fails. Note that the function has intimate knowledge of how different libc versions add symbols to the executable and thus is probably only useable for executables compiled using gcc. The file is read and scanned in chunks of chunksize bytes. """ if hasattr(os.path, 'realpath'): # Python 2.2 introduced os.path.realpath(); it is used # here to work around problems with Cygwin not being # able to open symlinks for reading executable = os.path.realpath(executable) f = open(executable, 'rb') binary = f.read(chunksize) pos = 0 while 1: if b'libc' in binary or b'GLIBC' in binary: m = _libc_search.search(binary, pos) else: m = None if not m: binary = f.read(chunksize) if not binary: break pos = 0 continue libcinit, glibc, glibcversion, so, threads, soversion = [ s.decode('latin1') if s is not None else s for s in m.groups()] if libcinit and not lib: lib = 'libc' elif glibc: if lib != 'glibc': lib = 'glibc' version = glibcversion elif glibcversion > version: version = glibcversion elif so: if lib != 'glibc': lib = 'libc' if soversion and soversion > version: version = soversion if threads and version[-len(threads):] != threads: version = version + threads pos = m.end() f.close() return lib, version def _dist_try_harder(distname, version, id): """ Tries some special tricks to get the distribution information in case the default method fails. Currently supports older SuSE Linux, Caldera OpenLinux and Slackware Linux distributions. """ if os.path.exists('/var/adm/inst-log/info'): # SuSE Linux stores distribution information in that file distname = 'SuSE' for line in open('/var/adm/inst-log/info'): tv = line.split() if len(tv) == 2: tag, value = tv else: continue if tag == 'MIN_DIST_VERSION': version = value.strip() elif tag == 'DIST_IDENT': values = value.split('-') id = values[2] return distname, version, id if os.path.exists('/etc/.installed'): # Caldera OpenLinux has some infos in that file (thanks to Colin Kong) for line in open('/etc/.installed'): pkg = line.split('-') if len(pkg) >= 2 and pkg[0] == 'OpenLinux': # XXX does Caldera support non Intel platforms ? If yes, # where can we find the needed id ? return 'OpenLinux', pkg[1], id if os.path.isdir('/usr/lib/setup'): # Check for slackware version tag file (thanks to Greg Andruk) verfiles = os.listdir('/usr/lib/setup') for n in range(len(verfiles)-1, -1, -1): if verfiles[n][:14] != 'slack-version-': del verfiles[n] if verfiles: verfiles.sort() distname = 'slackware' version = verfiles[-1][14:] return distname, version, id return distname, version, id _release_filename = re.compile(r'(\w+)[-_](release|version)', re.ASCII) _lsb_release_version = re.compile(r'(.+)' ' release ' '([\d.]+)' '[^(]*(?:\((.+)\))?', re.ASCII) _release_version = re.compile(r'([^0-9]+)' '(?: release )?' '([\d.]+)' '[^(]*(?:\((.+)\))?', re.ASCII) # See also http://www.novell.com/coolsolutions/feature/11251.html # and http://linuxmafia.com/faq/Admin/release-files.html # and http://data.linux-ntfs.org/rpm/whichrpm # and http://www.die.net/doc/linux/man/man1/lsb_release.1.html _supported_dists = ( 'SuSE', 'debian', 'fedora', 'redhat', 'centos', 'mandrake', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo', 'UnitedLinux', 'turbolinux', 'arch', 'mageia') def _parse_release_file(firstline): # Default to empty 'version' and 'id' strings. Both defaults are used # when 'firstline' is empty. 'id' defaults to empty when an id can not # be deduced. version = '' id = '' # Parse the first line m = _lsb_release_version.match(firstline) if m is not None: # LSB format: "distro release x.x (codename)" return tuple(m.groups()) # Pre-LSB format: "distro x.x (codename)" m = _release_version.match(firstline) if m is not None: return tuple(m.groups()) # Unknown format... take the first two words l = firstline.strip().split() if l: version = l[0] if len(l) > 1: id = l[1] return '', version, id def linux_distribution(distname='', version='', id='', supported_dists=_supported_dists, full_distribution_name=1): """ Tries to determine the name of the Linux OS distribution name. The function first looks for a distribution release file in /etc and then reverts to _dist_try_harder() in case no suitable files are found. supported_dists may be given to define the set of Linux distributions to look for. It defaults to a list of currently supported Linux distributions identified by their release file name. If full_distribution_name is true (default), the full distribution read from the OS is returned. Otherwise the short name taken from supported_dists is used. Returns a tuple (distname, version, id) which default to the args given as parameters. """ try: etc = os.listdir(_UNIXCONFDIR) except OSError: # Probably not a Unix system return distname, version, id etc.sort() for file in etc: m = _release_filename.match(file) if m is not None: _distname, dummy = m.groups() if _distname in supported_dists: distname = _distname break else: return _dist_try_harder(distname, version, id) # Read the first line with open(os.path.join(_UNIXCONFDIR, file), 'r', encoding='utf-8', errors='surrogateescape') as f: firstline = f.readline() _distname, _version, _id = _parse_release_file(firstline) if _distname and full_distribution_name: distname = _distname if _version: version = _version if _id: id = _id return distname, version, id # To maintain backwards compatibility: def dist(distname='', version='', id='', supported_dists=_supported_dists): """ Tries to determine the name of the Linux OS distribution name. The function first looks for a distribution release file in /etc and then reverts to _dist_try_harder() in case no suitable files are found. Returns a tuple (distname, version, id) which default to the args given as parameters. """ return linux_distribution(distname, version, id, supported_dists=supported_dists, full_distribution_name=0) def popen(cmd, mode='r', bufsize=-1): """ Portable popen() interface. """ import warnings warnings.warn('use os.popen instead', DeprecationWarning, stacklevel=2) return os.popen(cmd, mode, bufsize) def _norm_version(version, build=''): """ Normalize the version and build strings and return a single version string using the format major.minor.build (or patchlevel). """ l = version.split('.') if build: l.append(build) try: ints = map(int, l) except ValueError: strings = l else: strings = list(map(str, ints)) version = '.'.join(strings[:3]) return version _ver_output = re.compile(r'(?:([\w ]+) ([\w.]+) ' '.*' '\[.* ([\d.]+)\])') # Examples of VER command output: # # Windows 2000: Microsoft Windows 2000 [Version 5.00.2195] # Windows XP: Microsoft Windows XP [Version 5.1.2600] # Windows Vista: Microsoft Windows [Version 6.0.6002] # # Note that the "Version" string gets localized on different # Windows versions. def _syscmd_ver(system='', release='', version='', supported_platforms=('win32', 'win16', 'dos')): """ Tries to figure out the OS version used and returns a tuple (system, release, version). It uses the "ver" shell command for this which is known to exists on Windows, DOS. XXX Others too ? In case this fails, the given parameters are used as defaults. """ if sys.platform not in supported_platforms: return system, release, version # Try some common cmd strings for cmd in ('ver', 'command /c ver', 'cmd /c ver'): try: pipe = popen(cmd) info = pipe.read() if pipe.close(): raise OSError('command failed') # XXX How can I suppress shell errors from being written # to stderr ? except OSError as why: #print 'Command %s failed: %s' % (cmd, why) continue else: break else: return system, release, version # Parse the output info = info.strip() m = _ver_output.match(info) if m is not None: system, release, version = m.groups() # Strip trailing dots from version and release if release[-1] == '.': release = release[:-1] if version[-1] == '.': version = version[:-1] # Normalize the version and build strings (eliminating additional # zeros) version = _norm_version(version) return system, release, version def _win32_getvalue(key, name, default=''): """ Read a value for name from the registry key. In case this fails, default is returned. """ try: # Use win32api if available from win32api import RegQueryValueEx except ImportError: # On Python 2.0 and later, emulate using winreg import winreg RegQueryValueEx = winreg.QueryValueEx try: return RegQueryValueEx(key, name) except: return default def win32_ver(release='', version='', csd='', ptype=''): """ Get additional version information from the Windows Registry and return a tuple (version, csd, ptype) referring to version number, CSD level (service pack), and OS type (multi/single processor). As a hint: ptype returns 'Uniprocessor Free' on single processor NT machines and 'Multiprocessor Free' on multi processor machines. The 'Free' refers to the OS version being free of debugging code. It could also state 'Checked' which means the OS version uses debugging code, i.e. code that checks arguments, ranges, etc. (Thomas Heller). Note: this function works best with Mark Hammond's win32 package installed, but also on Python 2.3 and later. It obviously only runs on Win32 compatible platforms. """ # XXX Is there any way to find out the processor type on WinXX ? # XXX Is win32 available on Windows CE ? # # Adapted from code posted by Karl Putland to comp.lang.python. # # The mappings between reg. values and release names can be found # here: http://msdn.microsoft.com/library/en-us/sysinfo/base/osversioninfo_str.asp # Import the needed APIs try: from win32api import RegQueryValueEx, RegOpenKeyEx, \ RegCloseKey, GetVersionEx from win32con import HKEY_LOCAL_MACHINE, VER_PLATFORM_WIN32_NT, \ VER_PLATFORM_WIN32_WINDOWS, VER_NT_WORKSTATION except ImportError: # Emulate the win32api module using Python APIs try: sys.getwindowsversion except AttributeError: # No emulation possible, so return the defaults... return release, version, csd, ptype else: # Emulation using winreg (added in Python 2.0) and # sys.getwindowsversion() (added in Python 2.3) import winreg GetVersionEx = sys.getwindowsversion RegQueryValueEx = winreg.QueryValueEx RegOpenKeyEx = winreg.OpenKeyEx RegCloseKey = winreg.CloseKey HKEY_LOCAL_MACHINE = winreg.HKEY_LOCAL_MACHINE VER_PLATFORM_WIN32_WINDOWS = 1 VER_PLATFORM_WIN32_NT = 2 VER_NT_WORKSTATION = 1 VER_NT_SERVER = 3 REG_SZ = 1 # Find out the registry key and some general version infos winver = GetVersionEx() maj, min, buildno, plat, csd = winver version = '%i.%i.%i' % (maj, min, buildno & 0xFFFF) if hasattr(winver, "service_pack"): if winver.service_pack != "": csd = 'SP%s' % winver.service_pack_major else: if csd[:13] == 'Service Pack ': csd = 'SP' + csd[13:] if plat == VER_PLATFORM_WIN32_WINDOWS: regkey = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion' # Try to guess the release name if maj == 4: if min == 0: release = '95' elif min == 10: release = '98' elif min == 90: release = 'Me' else: release = 'postMe' elif maj == 5: release = '2000' elif plat == VER_PLATFORM_WIN32_NT: regkey = 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion' if maj <= 4: release = 'NT' elif maj == 5: if min == 0: release = '2000' elif min == 1: release = 'XP' elif min == 2: release = '2003Server' else: release = 'post2003' elif maj == 6: if hasattr(winver, "product_type"): product_type = winver.product_type else: product_type = VER_NT_WORKSTATION # Without an OSVERSIONINFOEX capable sys.getwindowsversion(), # or help from the registry, we cannot properly identify # non-workstation versions. try: key = RegOpenKeyEx(HKEY_LOCAL_MACHINE, regkey) name, type = RegQueryValueEx(key, "ProductName") # Discard any type that isn't REG_SZ if type == REG_SZ and name.find("Server") != -1: product_type = VER_NT_SERVER except OSError: # Use default of VER_NT_WORKSTATION pass if min == 0: if product_type == VER_NT_WORKSTATION: release = 'Vista' else: release = '2008Server' elif min == 1: if product_type == VER_NT_WORKSTATION: release = '7' else: release = '2008ServerR2' elif min == 2: if product_type == VER_NT_WORKSTATION: release = '8' else: release = '2012Server' else: release = 'post2012Server' else: if not release: # E.g. Win3.1 with win32s release = '%i.%i' % (maj, min) return release, version, csd, ptype # Open the registry key try: keyCurVer = RegOpenKeyEx(HKEY_LOCAL_MACHINE, regkey) # Get a value to make sure the key exists... RegQueryValueEx(keyCurVer, 'SystemRoot') except: return release, version, csd, ptype # Parse values #subversion = _win32_getvalue(keyCurVer, # 'SubVersionNumber', # ('',1))[0] #if subversion: # release = release + subversion # 95a, 95b, etc. build = _win32_getvalue(keyCurVer, 'CurrentBuildNumber', ('', 1))[0] ptype = _win32_getvalue(keyCurVer, 'CurrentType', (ptype, 1))[0] # Normalize version version = _norm_version(version, build) # Close key RegCloseKey(keyCurVer) return release, version, csd, ptype def _mac_ver_xml(): fn = '/System/Library/CoreServices/SystemVersion.plist' if not os.path.exists(fn): return None try: import plistlib except ImportError: return None with open(fn, 'rb') as f: pl = plistlib.load(f) release = pl['ProductVersion'] versioninfo = ('', '', '') machine = os.uname().machine if machine in ('ppc', 'Power Macintosh'): # Canonical name machine = 'PowerPC' return release, versioninfo, machine def mac_ver(release='', versioninfo=('', '', ''), machine=''): """ Get MacOS version information and return it as tuple (release, versioninfo, machine) with versioninfo being a tuple (version, dev_stage, non_release_version). Entries which cannot be determined are set to the parameter values which default to ''. All tuple entries are strings. """ # First try reading the information from an XML file which should # always be present info = _mac_ver_xml() if info is not None: return info # If that also doesn't work return the default values return release, versioninfo, machine def _java_getprop(name, default): from java.lang import System try: value = System.getProperty(name) if value is None: return default return value except AttributeError: return default def java_ver(release='', vendor='', vminfo=('', '', ''), osinfo=('', '', '')): """ Version interface for Jython. Returns a tuple (release, vendor, vminfo, osinfo) with vminfo being a tuple (vm_name, vm_release, vm_vendor) and osinfo being a tuple (os_name, os_version, os_arch). Values which cannot be determined are set to the defaults given as parameters (which all default to ''). """ # Import the needed APIs try: import java.lang except ImportError: return release, vendor, vminfo, osinfo vendor = _java_getprop('java.vendor', vendor) release = _java_getprop('java.version', release) vm_name, vm_release, vm_vendor = vminfo vm_name = _java_getprop('java.vm.name', vm_name) vm_vendor = _java_getprop('java.vm.vendor', vm_vendor) vm_release = _java_getprop('java.vm.version', vm_release) vminfo = vm_name, vm_release, vm_vendor os_name, os_version, os_arch = osinfo os_arch = _java_getprop('java.os.arch', os_arch) os_name = _java_getprop('java.os.name', os_name) os_version = _java_getprop('java.os.version', os_version) osinfo = os_name, os_version, os_arch return release, vendor, vminfo, osinfo ### System name aliasing def system_alias(system, release, version): """ Returns (system, release, version) aliased to common marketing names used for some systems. It also does some reordering of the information in some cases where it would otherwise cause confusion. """ if system == 'Rhapsody': # Apple's BSD derivative # XXX How can we determine the marketing release number ? return 'MacOS X Server', system+release, version elif system == 'SunOS': # Sun's OS if release < '5': # These releases use the old name SunOS return system, release, version # Modify release (marketing release = SunOS release - 3) l = release.split('.') if l: try: major = int(l[0]) except ValueError: pass else: major = major - 3 l[0] = str(major) release = '.'.join(l) if release < '6': system = 'Solaris' else: # XXX Whatever the new SunOS marketing name is... system = 'Solaris' elif system == 'IRIX64': # IRIX reports IRIX64 on platforms with 64-bit support; yet it # is really a version and not a different platform, since 32-bit # apps are also supported.. system = 'IRIX' if version: version = version + ' (64bit)' else: version = '64bit' elif system in ('win32', 'win16'): # In case one of the other tricks system = 'Windows' return system, release, version ### Various internal helpers def _platform(*args): """ Helper to format the platform string in a filename compatible format e.g. "system-version-machine". """ # Format the platform string platform = '-'.join(x.strip() for x in filter(len, args)) # Cleanup some possible filename obstacles... platform = platform.replace(' ', '_') platform = platform.replace('/', '-') platform = platform.replace('\\', '-') platform = platform.replace(':', '-') platform = platform.replace(';', '-') platform = platform.replace('"', '-') platform = platform.replace('(', '-') platform = platform.replace(')', '-') # No need to report 'unknown' information... platform = platform.replace('unknown', '') # Fold '--'s and remove trailing '-' while 1: cleaned = platform.replace('--', '-') if cleaned == platform: break platform = cleaned while platform[-1] == '-': platform = platform[:-1] return platform def _node(default=''): """ Helper to determine the node name of this machine. """ try: import socket except ImportError: # No sockets... return default try: return socket.gethostname() except OSError: # Still not working... return default def _follow_symlinks(filepath): """ In case filepath is a symlink, follow it until a real file is reached. """ filepath = os.path.abspath(filepath) while os.path.islink(filepath): filepath = os.path.normpath( os.path.join(os.path.dirname(filepath), os.readlink(filepath))) return filepath def _syscmd_uname(option, default=''): """ Interface to the system's uname command. """ if sys.platform in ('dos', 'win32', 'win16'): # XXX Others too ? return default try: f = os.popen('uname %s 2> %s' % (option, DEV_NULL)) except (AttributeError, OSError): return default output = f.read().strip() rc = f.close() if not output or rc: return default else: return output def _syscmd_file(target, default=''): """ Interface to the system's file command. The function uses the -b option of the file command to have it omit the filename in its output. Follow the symlinks. It returns default in case the command should fail. """ if sys.platform in ('dos', 'win32', 'win16'): # XXX Others too ? return default target = _follow_symlinks(target) try: proc = subprocess.Popen(['file', target], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) except (AttributeError, OSError): return default output = proc.communicate()[0].decode('latin-1') rc = proc.wait() if not output or rc: return default else: return output ### Information about the used architecture # Default values for architecture; non-empty strings override the # defaults given as parameters _default_architecture = { 'win32': ('', 'WindowsPE'), 'win16': ('', 'Windows'), 'dos': ('', 'MSDOS'), } def architecture(executable=sys.executable, bits='', linkage=''): """ Queries the given executable (defaults to the Python interpreter binary) for various architecture information. Returns a tuple (bits, linkage) which contains information about the bit architecture and the linkage format used for the executable. Both values are returned as strings. Values that cannot be determined are returned as given by the parameter presets. If bits is given as '', the sizeof(pointer) (or sizeof(long) on Python version < 1.5.2) is used as indicator for the supported pointer size. The function relies on the system's "file" command to do the actual work. This is available on most if not all Unix platforms. On some non-Unix platforms where the "file" command does not exist and the executable is set to the Python interpreter binary defaults from _default_architecture are used. """ # Use the sizeof(pointer) as default number of bits if nothing # else is given as default. if not bits: import struct try: size = struct.calcsize('P') except struct.error: # Older installations can only query longs size = struct.calcsize('l') bits = str(size*8) + 'bit' # Get data from the 'file' system command if executable: fileout = _syscmd_file(executable, '') else: fileout = '' if not fileout and \ executable == sys.executable: # "file" command did not return anything; we'll try to provide # some sensible defaults then... if sys.platform in _default_architecture: b, l = _default_architecture[sys.platform] if b: bits = b if l: linkage = l return bits, linkage if 'executable' not in fileout: # Format not supported return bits, linkage # Bits if '32-bit' in fileout: bits = '32bit' elif 'N32' in fileout: # On Irix only bits = 'n32bit' elif '64-bit' in fileout: bits = '64bit' # Linkage if 'ELF' in fileout: linkage = 'ELF' elif 'PE' in fileout: # E.g. Windows uses this format if 'Windows' in fileout: linkage = 'WindowsPE' else: linkage = 'PE' elif 'COFF' in fileout: linkage = 'COFF' elif 'MS-DOS' in fileout: linkage = 'MSDOS' else: # XXX the A.OUT format also falls under this class... pass return bits, linkage ### Portable uname() interface uname_result = collections.namedtuple("uname_result", "system node release version machine processor") _uname_cache = None def uname(): """ Fairly portable uname interface. Returns a tuple of strings (system, node, release, version, machine, processor) identifying the underlying platform. Note that unlike the os.uname function this also returns possible processor information as an additional tuple entry. Entries which cannot be determined are set to ''. """ global _uname_cache no_os_uname = 0 if _uname_cache is not None: return _uname_cache processor = '' # Get some infos from the builtin os.uname API... try: system, node, release, version, machine = os.uname() except AttributeError: no_os_uname = 1 if no_os_uname or not list(filter(None, (system, node, release, version, machine))): # Hmm, no there is either no uname or uname has returned #'unknowns'... we'll have to poke around the system then. if no_os_uname: system = sys.platform release = '' version = '' node = _node() machine = '' use_syscmd_ver = 1 # Try win32_ver() on win32 platforms if system == 'win32': release, version, csd, ptype = win32_ver() if release and version: use_syscmd_ver = 0 # Try to use the PROCESSOR_* environment variables # available on Win XP and later; see # http://support.microsoft.com/kb/888731 and # http://www.geocities.com/rick_lively/MANUALS/ENV/MSWIN/PROCESSI.HTM if not machine: # WOW64 processes mask the native architecture if "PROCESSOR_ARCHITEW6432" in os.environ: machine = os.environ.get("PROCESSOR_ARCHITEW6432", '') else: machine = os.environ.get('PROCESSOR_ARCHITECTURE', '') if not processor: processor = os.environ.get('PROCESSOR_IDENTIFIER', machine) # Try the 'ver' system command available on some # platforms if use_syscmd_ver: system, release, version = _syscmd_ver(system) # Normalize system to what win32_ver() normally returns # (_syscmd_ver() tends to return the vendor name as well) if system == 'Microsoft Windows': system = 'Windows' elif system == 'Microsoft' and release == 'Windows': # Under Windows Vista and Windows Server 2008, # Microsoft changed the output of the ver command. The # release is no longer printed. This causes the # system and release to be misidentified. system = 'Windows' if '6.0' == version[:3]: release = 'Vista' else: release = '' # In case we still don't know anything useful, we'll try to # help ourselves if system in ('win32', 'win16'): if not version: if system == 'win32': version = '32bit' else: version = '16bit' system = 'Windows' elif system[:4] == 'java': release, vendor, vminfo, osinfo = java_ver() system = 'Java' version = ', '.join(vminfo) if not version: version = vendor # System specific extensions if system == 'OpenVMS': # OpenVMS seems to have release and version mixed up if not release or release == '0': release = version version = '' # Get processor information try: import vms_lib except ImportError: pass else: csid, cpu_number = vms_lib.getsyi('SYI$_CPU', 0) if (cpu_number >= 128): processor = 'Alpha' else: processor = 'VAX' if not processor: # Get processor information from the uname system command processor = _syscmd_uname('-p', '') #If any unknowns still exist, replace them with ''s, which are more portable if system == 'unknown': system = '' if node == 'unknown': node = '' if release == 'unknown': release = '' if version == 'unknown': version = '' if machine == 'unknown': machine = '' if processor == 'unknown': processor = '' # normalize name if system == 'Microsoft' and release == 'Windows': system = 'Windows' release = 'Vista' _uname_cache = uname_result(system, node, release, version, machine, processor) return _uname_cache ### Direct interfaces to some of the uname() return values def system(): """ Returns the system/OS name, e.g. 'Linux', 'Windows' or 'Java'. An empty string is returned if the value cannot be determined. """ return uname().system def node(): """ Returns the computer's network name (which may not be fully qualified) An empty string is returned if the value cannot be determined. """ return uname().node def release(): """ Returns the system's release, e.g. '2.2.0' or 'NT' An empty string is returned if the value cannot be determined. """ return uname().release def version(): """ Returns the system's release version, e.g. '#3 on degas' An empty string is returned if the value cannot be determined. """ return uname().version def machine(): """ Returns the machine type, e.g. 'i386' An empty string is returned if the value cannot be determined. """ return uname().machine def processor(): """ Returns the (true) processor name, e.g. 'amdk6' An empty string is returned if the value cannot be determined. Note that many platforms do not provide this information or simply return the same value as for machine(), e.g. NetBSD does this. """ return uname().processor ### Various APIs for extracting information from sys.version _sys_version_parser = re.compile( r'([\w.+]+)\s*' '\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*' '\[([^\]]+)\]?', re.ASCII) _ironpython_sys_version_parser = re.compile( r'IronPython\s*' '([\d\.]+)' '(?: \(([\d\.]+)\))?' ' on (.NET [\d\.]+)', re.ASCII) # IronPython covering 2.6 and 2.7 _ironpython26_sys_version_parser = re.compile( r'([\d.]+)\s*' '\(IronPython\s*' '[\d.]+\s*' '\(([\d.]+)\) on ([\w.]+ [\d.]+(?: \(\d+-bit\))?)\)' ) _pypy_sys_version_parser = re.compile( r'([\w.+]+)\s*' '\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*' '\[PyPy [^\]]+\]?') _sys_version_cache = {} def _sys_version(sys_version=None): """ Returns a parsed version of Python's sys.version as tuple (name, version, branch, revision, buildno, builddate, compiler) referring to the Python implementation name, version, branch, revision, build number, build date/time as string and the compiler identification string. Note that unlike the Python sys.version, the returned value for the Python version will always include the patchlevel (it defaults to '.0'). The function returns empty strings for tuple entries that cannot be determined. sys_version may be given to parse an alternative version string, e.g. if the version was read from a different Python interpreter. """ # Get the Python version if sys_version is None: sys_version = sys.version # Try the cache first result = _sys_version_cache.get(sys_version, None) if result is not None: return result # Parse it if 'IronPython' in sys_version: # IronPython name = 'IronPython' if sys_version.startswith('IronPython'): match = _ironpython_sys_version_parser.match(sys_version) else: match = _ironpython26_sys_version_parser.match(sys_version) if match is None: raise ValueError( 'failed to parse IronPython sys.version: %s' % repr(sys_version)) version, alt_version, compiler = match.groups() buildno = '' builddate = '' elif sys.platform.startswith('java'): # Jython name = 'Jython' match = _sys_version_parser.match(sys_version) if match is None: raise ValueError( 'failed to parse Jython sys.version: %s' % repr(sys_version)) version, buildno, builddate, buildtime, _ = match.groups() compiler = sys.platform elif "PyPy" in sys_version: # PyPy name = "PyPy" match = _pypy_sys_version_parser.match(sys_version) if match is None: raise ValueError("failed to parse PyPy sys.version: %s" % repr(sys_version)) version, buildno, builddate, buildtime = match.groups() compiler = "" else: # CPython match = _sys_version_parser.match(sys_version) if match is None: raise ValueError( 'failed to parse CPython sys.version: %s' % repr(sys_version)) version, buildno, builddate, buildtime, compiler = \ match.groups() name = 'CPython' builddate = builddate + ' ' + buildtime if hasattr(sys, '_mercurial'): _, branch, revision = sys._mercurial elif hasattr(sys, 'subversion'): # sys.subversion was added in Python 2.5 _, branch, revision = sys.subversion else: branch = '' revision = '' # Add the patchlevel version if missing l = version.split('.') if len(l) == 2: l.append('0') version = '.'.join(l) # Build and cache the result result = (name, version, branch, revision, buildno, builddate, compiler) _sys_version_cache[sys_version] = result return result def python_implementation(): """ Returns a string identifying the Python implementation. Currently, the following implementations are identified: 'CPython' (C implementation of Python), 'IronPython' (.NET implementation of Python), 'Jython' (Java implementation of Python), 'PyPy' (Python implementation of Python). """ return _sys_version()[0] def python_version(): """ Returns the Python version as string 'major.minor.patchlevel' Note that unlike the Python sys.version, the returned value will always include the patchlevel (it defaults to 0). """ return _sys_version()[1] def python_version_tuple(): """ Returns the Python version as tuple (major, minor, patchlevel) of strings. Note that unlike the Python sys.version, the returned value will always include the patchlevel (it defaults to 0). """ return tuple(_sys_version()[1].split('.')) def python_branch(): """ Returns a string identifying the Python implementation branch. For CPython this is the Subversion branch from which the Python binary was built. If not available, an empty string is returned. """ return _sys_version()[2] def python_revision(): """ Returns a string identifying the Python implementation revision. For CPython this is the Subversion revision from which the Python binary was built. If not available, an empty string is returned. """ return _sys_version()[3] def python_build(): """ Returns a tuple (buildno, builddate) stating the Python build number and date as strings. """ return _sys_version()[4:6] def python_compiler(): """ Returns a string identifying the compiler used for compiling Python. """ return _sys_version()[6] ### The Opus Magnum of platform strings :-) _platform_cache = {} def platform(aliased=0, terse=0): """ Returns a single string identifying the underlying platform with as much useful information as possible (but no more :). The output is intended to be human readable rather than machine parseable. It may look different on different platforms and this is intended. If "aliased" is true, the function will use aliases for various platforms that report system names which differ from their common names, e.g. SunOS will be reported as Solaris. The system_alias() function is used to implement this. Setting terse to true causes the function to return only the absolute minimum information needed to identify the platform. """ result = _platform_cache.get((aliased, terse), None) if result is not None: return result # Get uname information and then apply platform specific cosmetics # to it... system, node, release, version, machine, processor = uname() if machine == processor: processor = '' if aliased: system, release, version = system_alias(system, release, version) if system == 'Windows': # MS platforms rel, vers, csd, ptype = win32_ver(version) if terse: platform = _platform(system, release) else: platform = _platform(system, release, version, csd) elif system in ('Linux',): # Linux based systems distname, distversion, distid = dist('') if distname and not terse: platform = _platform(system, release, machine, processor, 'with', distname, distversion, distid) else: # If the distribution name is unknown check for libc vs. glibc libcname, libcversion = libc_ver(sys.executable) platform = _platform(system, release, machine, processor, 'with', libcname+libcversion) elif system == 'Java': # Java platforms r, v, vminfo, (os_name, os_version, os_arch) = java_ver() if terse or not os_name: platform = _platform(system, release, version) else: platform = _platform(system, release, version, 'on', os_name, os_version, os_arch) elif system == 'MacOS': # MacOS platforms if terse: platform = _platform(system, release) else: platform = _platform(system, release, machine) else: # Generic handler if terse: platform = _platform(system, release) else: bits, linkage = architecture(sys.executable) platform = _platform(system, release, machine, processor, bits, linkage) _platform_cache[(aliased, terse)] = platform return platform ### Command line interface if __name__ == '__main__': # Default is to print the aliased verbose platform string terse = ('terse' in sys.argv or '--terse' in sys.argv) aliased = (not 'nonaliased' in sys.argv and not '--nonaliased' in sys.argv) print(platform(aliased, terse)) sys.exit(0)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 624, 961, 859, 11275, 370, 8044, 465, 8298, 4298, 13, 22232, 316, 666, 465, 272, 3962, 14, 2779, 7704, 642, 2556, 2808, 4799, 805, 15913, 14, 339, 982, 2797, 687, 314, 1414, 1004, 12, 652, 14767, 314, 4298, 272, 2556, 26271, 465, 2849, 1059, 370, 3839, 14, 710, 1072, 272, 1475, 365, 675, 461, 465, 1777, 402, 282, 1788, 14, 199, 199, 624, 199, 3, 259, 961, 859, 365, 26391, 701, 603, 9912, 13, 3325, 264, 7005, 32649, 665, 2174, 32, 69, 2268, 1148, 14, 957, 10827, 199, 3, 259, 982, 1265, 2342, 8826, 12, 8749, 11482, 6519, 13924, 15, 11350, 4799, 314, 199, 3, 259, 2018, 6519, 15271, 334, 1014, 921, 13017, 14, 1548, 14, 1308, 9, 436, 5090, 3062, 370, 298, 274, 32649, 1674, 199, 3, 199, 3, 259, 428, 12587, 4346, 26, 199, 3, 259, 627, 1655, 2291, 367, 13036, 2089, 199, 3, 259, 627, 2291, 367, 14282, 13, 32735, 334, 4718, 19596, 5805, 9, 199, 3, 259, 627, 2291, 367, 437, 4071, 65, 436, 1163, 5139, 16313, 10677, 3879, 2018, 199, 3, 259, 627, 2291, 367, 4722, 10130, 10208, 199, 3, 199, 3, 259, 15517, 2419, 6080, 370, 1006, 5204, 3963, 20181, 1915, 7791, 4298, 13, 6100, 199, 3, 259, 5920, 334, 262, 949, 6770, 1865, 304, 199, 3, 199, 3, 420, 6659, 2978, 598, 644, 27075, 1237, 12, 20232, 1952, 78, 1753, 12, 598, 2181, 265, 22895, 45, 778, 290, 12, 26844, 577, 1060, 1697, 12, 199, 3, 420, 1603, 3609, 699, 3844, 281, 12, 445, 317, 556, 445, 1773, 18090, 12, 473, 20662, 812, 290, 491, 290, 316, 10670, 12, 1603, 3362, 70, 199, 3, 420, 31535, 290, 331, 20471, 12, 820, 460, 452, 869, 411, 529, 12, 1804, 285, 76, 16280, 9688, 12, 17815, 481, 285, 264, 914, 12, 29096, 199, 3, 420, 6061, 82, 3210, 12, 13870, 20744, 6848, 385, 453, 12, 27864, 869, 352, 1435, 12, 7173, 820, 14, 491, 6857, 262, 834, 12, 7173, 199, 3, 420, 869, 455, 2106, 68, 12, 699, 778, 377, 337, 84, 12, 869, 796, 7356, 1151, 12, 738, 1129, 3107, 16709, 262, 334, 4299, 54, 3053, 2291, 395, 199, 3, 420, 3626, 262, 1804, 951, 12, 377, 640, 603, 2000, 12, 598, 1535, 79, 20744, 6848, 385, 453, 12, 1626, 898, 89, 699, 1219, 351, 199, 3, 199, 3, 259, 27829, 26, 199, 3, 199, 3, 259, 665, 3239, 445, 7428, 436, 24639, 1104, 262, 3788, 367, 7994, 30, 199, 3, 199, 3, 259, 413, 14, 16, 14, 23, 446, 3483, 3265, 54, 63, 8084, 199, 3, 259, 413, 14, 16, 14, 22, 446, 3483, 18369, 63, 4972, 342, 199, 3, 259, 413, 14, 16, 14, 21, 446, 6317, 9586, 2291, 370, 2040, 3879, 314, 859, 641, 25333, 199, 3, 259, 413, 14, 16, 14, 20, 446, 3483, 473, 2641, 4718, 2291, 199, 3, 259, 413, 14, 16, 14, 19, 446, 3483, 16973, 402, 5417, 2656, 536, 199, 3, 259, 413, 14, 16, 14, 18, 446, 3483, 1655, 5417, 2291, 199, 3, 259, 413, 14, 16, 14, 17, 446, 295, 15317, 370, 1852, 1382, 14, 647, 394, 18869, 199, 3, 259, 413, 14, 16, 14, 16, 446, 295, 15317, 282, 4546, 436, 7923, 1901, 2018, 445, 7428, 199, 3, 259, 378, 14, 24, 14, 16, 446, 3483, 984, 14, 1023, 1798, 436, 7750, 892, 2879, 199, 3, 3322, 15913, 334, 1548, 63, 1023, 1062, 2366, 63, 5772, 1062, 5423, 4959, 199, 3, 259, 378, 14, 23, 14, 18, 446, 6317, 15931, 342, 370, 675, 13855, 8, 3929, 9, 2382, 2808, 199, 3, 259, 378, 14, 23, 14, 17, 446, 3483, 2291, 367, 8256, 271, 345, 3232, 14091, 199, 3, 259, 378, 14, 23, 14, 16, 446, 2005, 25079, 367, 13036, 2089, 27, 625, 2902, 4541, 314, 1350, 570, 199, 3, 259, 378, 14, 22, 14, 18, 446, 2291, 367, 3232, 54, 3053, 446, 5074, 1015, 413, 14, 21, 14, 18, 13, 54, 8010, 503, 10948, 436, 199, 3, 3322, 22505, 63, 773, 14, 362, 1786, 73, 342, 7526, 199, 3, 259, 378, 14, 22, 14, 17, 446, 3483, 1233, 370, 7981, 283, 16040, 446, 80, 7, 641, 10677, 1314, 787, 199, 3, 3322, 6040, 440, 370, 2291, 652, 199, 3, 259, 378, 14, 22, 14, 16, 446, 6317, 4747, 708, 63, 422, 342, 370, 3661, 5836, 1736, 641, 13036, 2720, 12, 2905, 12, 12460, 436, 13036, 18, 75, 27, 199, 3, 3322, 8103, 2005, 9058, 402, 314, 8386, 446, 2005, 15913, 1172, 2896, 199, 3, 259, 378, 14, 21, 14, 21, 446, 6317, 4573, 730, 315, 314, 10444, 3100, 1233, 1396, 1077, 1172, 199, 3, 3322, 1202, 1655, 512, 24715, 11168, 8700, 13, 9, 199, 3, 259, 378, 14, 21, 14, 20, 446, 6317, 282, 9284, 10284, 1712, 315, 314, 10444, 3100, 1233, 199, 3, 259, 378, 14, 21, 14, 19, 446, 3483, 22820, 10444, 3100, 2291, 27, 3483, 8034, 17758, 342, 199, 3, 3322, 18092, 83, 315, 485, 1786, 551, 1064, 63, 422, 342, 1553, 5139, 440, 2948, 5, 325, 4170, 867, 199, 3, 3322, 10617, 199, 3, 259, 378, 14, 21, 14, 18, 446, 6317, 28179, 342, 370, 372, 2125, 3140, 402, 283, 5187, 7, 315, 1006, 199, 3, 3322, 372, 1338, 334, 1589, 2656, 28179, 1414, 16685, 795, 370, 372, 199, 3, 3322, 283, 5187, 7, 3140, 402, 2951, 23188, 314, 901, 325, 2037, 647, 9, 199, 3, 259, 378, 14, 21, 14, 17, 446, 5120, 1233, 367, 29877, 1068, 2917, 27, 3483, 1919, 8297, 199, 3, 3322, 370, 8486, 1536, 24325, 2382, 10677, 2793, 1133, 1172, 747, 14, 12207, 199, 3, 3322, 334, 69, 14, 71, 14, 10444, 9, 503, 2449, 641, 2838, 14, 29789, 7303, 6317, 1973, 67, 199, 3, 3322, 15212, 5363, 199, 3, 259, 378, 14, 21, 14, 16, 446, 2896, 314, 3261, 1561, 21864, 370, 2656, 3718, 370, 627, 1786, 551, 1064, 10, 27, 199, 3, 3322, 3483, 12120, 63, 422, 7303, 6326, 1847, 551, 1064, 63, 422, 342, 282, 5726, 199, 3, 3322, 3261, 334, 10274, 2656, 63, 422, 342, 315, 4136, 5459, 9, 1553, 675, 28179, 342, 199, 3, 3322, 3140, 27, 9243, 314, 4747, 708, 63, 422 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 624, 961, 859, 11275, 370, 8044, 465, 8298, 4298, 13, 22232, 316, 666, 465, 272, 3962, 14, 2779, 7704, 642, 2556, 2808, 4799, 805, 15913, 14, 339, 982, 2797, 687, 314, 1414, 1004, 12, 652, 14767, 314, 4298, 272, 2556, 26271, 465, 2849, 1059, 370, 3839, 14, 710, 1072, 272, 1475, 365, 675, 461, 465, 1777, 402, 282, 1788, 14, 199, 199, 624, 199, 3, 259, 961, 859, 365, 26391, 701, 603, 9912, 13, 3325, 264, 7005, 32649, 665, 2174, 32, 69, 2268, 1148, 14, 957, 10827, 199, 3, 259, 982, 1265, 2342, 8826, 12, 8749, 11482, 6519, 13924, 15, 11350, 4799, 314, 199, 3, 259, 2018, 6519, 15271, 334, 1014, 921, 13017, 14, 1548, 14, 1308, 9, 436, 5090, 3062, 370, 298, 274, 32649, 1674, 199, 3, 199, 3, 259, 428, 12587, 4346, 26, 199, 3, 259, 627, 1655, 2291, 367, 13036, 2089, 199, 3, 259, 627, 2291, 367, 14282, 13, 32735, 334, 4718, 19596, 5805, 9, 199, 3, 259, 627, 2291, 367, 437, 4071, 65, 436, 1163, 5139, 16313, 10677, 3879, 2018, 199, 3, 259, 627, 2291, 367, 4722, 10130, 10208, 199, 3, 199, 3, 259, 15517, 2419, 6080, 370, 1006, 5204, 3963, 20181, 1915, 7791, 4298, 13, 6100, 199, 3, 259, 5920, 334, 262, 949, 6770, 1865, 304, 199, 3, 199, 3, 420, 6659, 2978, 598, 644, 27075, 1237, 12, 20232, 1952, 78, 1753, 12, 598, 2181, 265, 22895, 45, 778, 290, 12, 26844, 577, 1060, 1697, 12, 199, 3, 420, 1603, 3609, 699, 3844, 281, 12, 445, 317, 556, 445, 1773, 18090, 12, 473, 20662, 812, 290, 491, 290, 316, 10670, 12, 1603, 3362, 70, 199, 3, 420, 31535, 290, 331, 20471, 12, 820, 460, 452, 869, 411, 529, 12, 1804, 285, 76, 16280, 9688, 12, 17815, 481, 285, 264, 914, 12, 29096, 199, 3, 420, 6061, 82, 3210, 12, 13870, 20744, 6848, 385, 453, 12, 27864, 869, 352, 1435, 12, 7173, 820, 14, 491, 6857, 262, 834, 12, 7173, 199, 3, 420, 869, 455, 2106, 68, 12, 699, 778, 377, 337, 84, 12, 869, 796, 7356, 1151, 12, 738, 1129, 3107, 16709, 262, 334, 4299, 54, 3053, 2291, 395, 199, 3, 420, 3626, 262, 1804, 951, 12, 377, 640, 603, 2000, 12, 598, 1535, 79, 20744, 6848, 385, 453, 12, 1626, 898, 89, 699, 1219, 351, 199, 3, 199, 3, 259, 27829, 26, 199, 3, 199, 3, 259, 665, 3239, 445, 7428, 436, 24639, 1104, 262, 3788, 367, 7994, 30, 199, 3, 199, 3, 259, 413, 14, 16, 14, 23, 446, 3483, 3265, 54, 63, 8084, 199, 3, 259, 413, 14, 16, 14, 22, 446, 3483, 18369, 63, 4972, 342, 199, 3, 259, 413, 14, 16, 14, 21, 446, 6317, 9586, 2291, 370, 2040, 3879, 314, 859, 641, 25333, 199, 3, 259, 413, 14, 16, 14, 20, 446, 3483, 473, 2641, 4718, 2291, 199, 3, 259, 413, 14, 16, 14, 19, 446, 3483, 16973, 402, 5417, 2656, 536, 199, 3, 259, 413, 14, 16, 14, 18, 446, 3483, 1655, 5417, 2291, 199, 3, 259, 413, 14, 16, 14, 17, 446, 295, 15317, 370, 1852, 1382, 14, 647, 394, 18869, 199, 3, 259, 413, 14, 16, 14, 16, 446, 295, 15317, 282, 4546, 436, 7923, 1901, 2018, 445, 7428, 199, 3, 259, 378, 14, 24, 14, 16, 446, 3483, 984, 14, 1023, 1798, 436, 7750, 892, 2879, 199, 3, 3322, 15913, 334, 1548, 63, 1023, 1062, 2366, 63, 5772, 1062, 5423, 4959, 199, 3, 259, 378, 14, 23, 14, 18, 446, 6317, 15931, 342, 370, 675, 13855, 8, 3929, 9, 2382, 2808, 199, 3, 259, 378, 14, 23, 14, 17, 446, 3483, 2291, 367, 8256, 271, 345, 3232, 14091, 199, 3, 259, 378, 14, 23, 14, 16, 446, 2005, 25079, 367, 13036, 2089, 27, 625, 2902, 4541, 314, 1350, 570, 199, 3, 259, 378, 14, 22, 14, 18, 446, 2291, 367, 3232, 54, 3053, 446, 5074, 1015, 413, 14, 21, 14, 18, 13, 54, 8010, 503, 10948, 436, 199, 3, 3322, 22505, 63, 773, 14, 362, 1786, 73, 342, 7526, 199, 3, 259, 378, 14, 22, 14, 17, 446, 3483, 1233, 370, 7981, 283, 16040, 446, 80, 7, 641, 10677, 1314, 787, 199, 3, 3322, 6040, 440, 370, 2291, 652, 199, 3, 259, 378, 14, 22, 14, 16, 446, 6317, 4747, 708, 63, 422, 342, 370, 3661, 5836, 1736, 641, 13036, 2720, 12, 2905, 12, 12460, 436, 13036, 18, 75, 27, 199, 3, 3322, 8103, 2005, 9058, 402, 314, 8386, 446, 2005, 15913, 1172, 2896, 199, 3, 259, 378, 14, 21, 14, 21, 446, 6317, 4573, 730, 315, 314, 10444, 3100, 1233, 1396, 1077, 1172, 199, 3, 3322, 1202, 1655, 512, 24715, 11168, 8700, 13, 9, 199, 3, 259, 378, 14, 21, 14, 20, 446, 6317, 282, 9284, 10284, 1712, 315, 314, 10444, 3100, 1233, 199, 3, 259, 378, 14, 21, 14, 19, 446, 3483, 22820, 10444, 3100, 2291, 27, 3483, 8034, 17758, 342, 199, 3, 3322, 18092, 83, 315, 485, 1786, 551, 1064, 63, 422, 342, 1553, 5139, 440, 2948, 5, 325, 4170, 867, 199, 3, 3322, 10617, 199, 3, 259, 378, 14, 21, 14, 18, 446, 6317, 28179, 342, 370, 372, 2125, 3140, 402, 283, 5187, 7, 315, 1006, 199, 3, 3322, 372, 1338, 334, 1589, 2656, 28179, 1414, 16685, 795, 370, 372, 199, 3, 3322, 283, 5187, 7, 3140, 402, 2951, 23188, 314, 901, 325, 2037, 647, 9, 199, 3, 259, 378, 14, 21, 14, 17, 446, 5120, 1233, 367, 29877, 1068, 2917, 27, 3483, 1919, 8297, 199, 3, 3322, 370, 8486, 1536, 24325, 2382, 10677, 2793, 1133, 1172, 747, 14, 12207, 199, 3, 3322, 334, 69, 14, 71, 14, 10444, 9, 503, 2449, 641, 2838, 14, 29789, 7303, 6317, 1973, 67, 199, 3, 3322, 15212, 5363, 199, 3, 259, 378, 14, 21, 14, 16, 446, 2896, 314, 3261, 1561, 21864, 370, 2656, 3718, 370, 627, 1786, 551, 1064, 10, 27, 199, 3, 3322, 3483, 12120, 63, 422, 7303, 6326, 1847, 551, 1064, 63, 422, 342, 282, 5726, 199, 3, 3322, 3261, 334, 10274, 2656, 63, 422, 342, 315, 4136,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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 ]
openstack/python-magnumclient
magnumclient/tests/v1/test_mservices_shell.py
1
1265
# Copyright 2015 NEC Corporation. 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. from unittest import mock from magnumclient.tests.v1 import shell_test_base class ShellTest(shell_test_base.TestCommandLineArgument): @mock.patch('magnumclient.v1.mservices.MServiceManager.list') def test_magnum_service_list_success(self, mock_list): self._test_arg_success('service-list') mock_list.assert_called_once_with() @mock.patch('magnumclient.v1.mservices.MServiceManager.list') def test_magnum_service_list_failure(self, mock_list): self._test_arg_failure('service-list --wrong', self._unrecognized_arg_error) mock_list.assert_not_called()
apache-2.0
[ 3, 1898, 6900, 653, 4220, 11098, 14, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 2882, 492, 1683, 199, 199, 504, 15916, 453, 1258, 14, 2219, 14, 86, 17, 492, 5218, 63, 396, 63, 1095, 421, 199, 533, 24599, 774, 8, 5641, 63, 396, 63, 1095, 14, 774, 16926, 5201, 304, 339, 768, 1805, 14, 2068, 360, 19902, 453, 1258, 14, 86, 17, 14, 77, 5950, 14, 45, 3167, 2988, 14, 513, 358, 272, 347, 511, 63, 19902, 453, 63, 1364, 63, 513, 63, 3742, 8, 277, 12, 1683, 63, 513, 304, 267, 291, 423, 396, 63, 1273, 63, 3742, 360, 1364, 13, 513, 358, 267, 1683, 63, 513, 14, 479, 63, 3527, 63, 5089, 63, 1045, 342, 339, 768, 1805, 14, 2068, 360, 19902, 453, 1258, 14, 86, 17, 14, 77, 5950, 14, 45, 3167, 2988, 14, 513, 358, 272, 347, 511, 63, 19902, 453, 63, 1364, 63, 513, 63, 5328, 8, 277, 12, 1683, 63, 513, 304, 267, 291, 423, 396, 63, 1273, 63, 5328, 360, 1364, 13, 513, 1553, 10603, 297, 3044, 291, 423, 324, 13221, 63, 1273, 63, 705, 9, 267, 1683, 63, 513, 14, 479, 63, 1397, 63, 3527, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6900, 653, 4220, 11098, 14, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 2882, 492, 1683, 199, 199, 504, 15916, 453, 1258, 14, 2219, 14, 86, 17, 492, 5218, 63, 396, 63, 1095, 421, 199, 533, 24599, 774, 8, 5641, 63, 396, 63, 1095, 14, 774, 16926, 5201, 304, 339, 768, 1805, 14, 2068, 360, 19902, 453, 1258, 14, 86, 17, 14, 77, 5950, 14, 45, 3167, 2988, 14, 513, 358, 272, 347, 511, 63, 19902, 453, 63, 1364, 63, 513, 63, 3742, 8, 277, 12, 1683, 63, 513, 304, 267, 291, 423, 396, 63, 1273, 63, 3742, 360, 1364, 13, 513, 358, 267, 1683, 63, 513, 14, 479, 63, 3527, 63, 5089, 63, 1045, 342, 339, 768, 1805, 14, 2068, 360, 19902, 453, 1258, 14, 86, 17, 14, 77, 5950, 14, 45, 3167, 2988, 14, 513, 358, 272, 347, 511, 63, 19902, 453, 63, 1364, 63, 513, 63, 5328, 8, 277, 12, 1683, 63, 513, 304, 267, 291, 423, 396, 63, 1273, 63, 5328, 360, 1364, 13, 513, 1553, 10603, 297, 3044, 291, 423, 324, 13221, 63, 1273, 63, 705, 9, 267, 1683, 63, 513, 14, 479, 63, 1397, 63, 3527, 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,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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 ]
filias/django
django/conf/locale/hr/formats.py
504
2106
# -*- encoding: utf-8 -*- # This file is distributed under the same license as the Django package. # from __future__ import unicode_literals # The *_FORMAT strings use the Django date format syntax, # see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date DATE_FORMAT = 'j. E Y.' TIME_FORMAT = 'H:i' DATETIME_FORMAT = 'j. E Y. H:i' YEAR_MONTH_FORMAT = 'F Y.' MONTH_DAY_FORMAT = 'j. F' SHORT_DATE_FORMAT = 'j.m.Y.' SHORT_DATETIME_FORMAT = 'j.m.Y. H:i' FIRST_DAY_OF_WEEK = 1 # The *_INPUT_FORMATS strings use the Python strftime format syntax, # see http://docs.python.org/library/datetime.html#strftime-strptime-behavior # Kept ISO formats as they are in first position DATE_INPUT_FORMATS = [ '%Y-%m-%d', # '2006-10-25' '%d.%m.%Y.', '%d.%m.%y.', # '25.10.2006.', '25.10.06.' '%d. %m. %Y.', '%d. %m. %y.', # '25. 10. 2006.', '25. 10. 06.' ] DATETIME_INPUT_FORMATS = [ '%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59' '%Y-%m-%d %H:%M:%S.%f', # '2006-10-25 14:30:59.000200' '%Y-%m-%d %H:%M', # '2006-10-25 14:30' '%Y-%m-%d', # '2006-10-25' '%d.%m.%Y. %H:%M:%S', # '25.10.2006. 14:30:59' '%d.%m.%Y. %H:%M:%S.%f', # '25.10.2006. 14:30:59.000200' '%d.%m.%Y. %H:%M', # '25.10.2006. 14:30' '%d.%m.%Y.', # '25.10.2006.' '%d.%m.%y. %H:%M:%S', # '25.10.06. 14:30:59' '%d.%m.%y. %H:%M:%S.%f', # '25.10.06. 14:30:59.000200' '%d.%m.%y. %H:%M', # '25.10.06. 14:30' '%d.%m.%y.', # '25.10.06.' '%d. %m. %Y. %H:%M:%S', # '25. 10. 2006. 14:30:59' '%d. %m. %Y. %H:%M:%S.%f', # '25. 10. 2006. 14:30:59.000200' '%d. %m. %Y. %H:%M', # '25. 10. 2006. 14:30' '%d. %m. %Y.', # '25. 10. 2006.' '%d. %m. %y. %H:%M:%S', # '25. 10. 06. 14:30:59' '%d. %m. %y. %H:%M:%S.%f', # '25. 10. 06. 14:30:59.000200' '%d. %m. %y. %H:%M', # '25. 10. 06. 14:30' '%d. %m. %y.', # '25. 10. 06.' ] DECIMAL_SEPARATOR = ',' THOUSAND_SEPARATOR = '.' NUMBER_GROUPING = 3
bsd-3-clause
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 283, 74, 14, 662, 1488, 3530, 199, 4961, 63, 4807, 275, 283, 40, 26, 73, 7, 199, 12488, 63, 4807, 275, 283, 74, 14, 662, 1488, 14, 869, 26, 73, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 3530, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 14, 481, 7, 199, 13003, 63, 5390, 63, 4807, 275, 283, 74, 14, 77, 14, 57, 3530, 199, 13003, 63, 12488, 63, 4807, 275, 283, 74, 14, 77, 14, 57, 14, 869, 26, 73, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 3, 25645, 541, 9055, 6752, 465, 2985, 787, 315, 1642, 3421, 199, 5390, 63, 7321, 63, 14019, 275, 359, 272, 1543, 57, 3295, 77, 3295, 68, 297, 9326, 327, 283, 7968, 13, 709, 13, 821, 7, 272, 1543, 68, 4111, 77, 4111, 57, 3130, 1543, 68, 4111, 77, 4111, 89, 3130, 755, 327, 283, 821, 14, 709, 14, 7968, 3130, 283, 821, 14, 709, 14, 1690, 3530, 272, 1543, 68, 14, 450, 77, 14, 450, 57, 3130, 1543, 68, 14, 450, 77, 14, 450, 89, 3130, 257, 327, 283, 821, 14, 1616, 14, 8315, 3130, 283, 821, 14, 1616, 14, 24293, 3530, 199, 61, 199, 12488, 63, 7321, 63, 14019, 275, 359, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 297, 263, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 258, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 297, 3698, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 7, 272, 1543, 57, 3295, 77, 3295, 68, 297, 463, 327, 283, 7968, 13, 709, 13, 821, 7, 272, 1543, 68, 4111, 77, 4111, 57, 14, 450, 40, 2689, 45, 2689, 51, 297, 755, 327, 283, 821, 14, 709, 14, 7968, 14, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 14, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 259, 327, 283, 821, 14, 709, 14, 7968, 14, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 57, 14, 450, 40, 2689, 45, 297, 3515, 327, 283, 821, 14, 709, 14, 7968, 14, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 3130, 4483, 327, 283, 821, 14, 709, 14, 7968, 3530, 272, 1543, 68, 4111, 77, 4111, 89, 14, 450, 40, 2689, 45, 2689, 51, 297, 755, 327, 283, 821, 14, 709, 14, 1690, 14, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 14, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 259, 327, 283, 821, 14, 709, 14, 1690, 14, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 89, 14, 450, 40, 2689, 45, 297, 3515, 327, 283, 821, 14, 709, 14, 1690, 14, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 3130, 4483, 327, 283, 821, 14, 709, 14, 1690, 3530, 272, 1543, 68, 14, 450, 77, 14, 450, 57, 14, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 1616, 14, 8315, 14, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 57, 14, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 1616, 14, 8315, 14, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 57, 14, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 1616, 14, 8315, 14, 4329, 26, 1216, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 57, 3130, 4519, 327, 283, 821, 14, 1616, 14, 8315, 3530, 272, 1543, 68, 14, 450, 77, 14, 450, 89, 14, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 1616, 14, 24293, 14, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 89, 14, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 1616, 14, 24293, 14, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 89, 14, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 1616, 14, 24293, 14, 4329, 26, 1216, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 89, 3130, 4519, 327, 283, 821, 14, 1616, 14, 24293, 3530, 199, 61, 199, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 7815, 199, 9190, 63, 7823, 1206, 275, 650, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 283, 74, 14, 662, 1488, 3530, 199, 4961, 63, 4807, 275, 283, 40, 26, 73, 7, 199, 12488, 63, 4807, 275, 283, 74, 14, 662, 1488, 14, 869, 26, 73, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 3530, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 14, 481, 7, 199, 13003, 63, 5390, 63, 4807, 275, 283, 74, 14, 77, 14, 57, 3530, 199, 13003, 63, 12488, 63, 4807, 275, 283, 74, 14, 77, 14, 57, 14, 869, 26, 73, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 3, 25645, 541, 9055, 6752, 465, 2985, 787, 315, 1642, 3421, 199, 5390, 63, 7321, 63, 14019, 275, 359, 272, 1543, 57, 3295, 77, 3295, 68, 297, 9326, 327, 283, 7968, 13, 709, 13, 821, 7, 272, 1543, 68, 4111, 77, 4111, 57, 3130, 1543, 68, 4111, 77, 4111, 89, 3130, 755, 327, 283, 821, 14, 709, 14, 7968, 3130, 283, 821, 14, 709, 14, 1690, 3530, 272, 1543, 68, 14, 450, 77, 14, 450, 57, 3130, 1543, 68, 14, 450, 77, 14, 450, 89, 3130, 257, 327, 283, 821, 14, 1616, 14, 8315, 3130, 283, 821, 14, 1616, 14, 24293, 3530, 199, 61, 199, 12488, 63, 7321, 63, 14019, 275, 359, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 297, 263, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 258, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 297, 3698, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 7, 272, 1543, 57, 3295, 77, 3295, 68, 297, 463, 327, 283, 7968, 13, 709, 13, 821, 7, 272, 1543, 68, 4111, 77, 4111, 57, 14, 450, 40, 2689, 45, 2689, 51, 297, 755, 327, 283, 821, 14, 709, 14, 7968, 14, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 14, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 259, 327, 283, 821, 14, 709, 14, 7968, 14, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 57, 14, 450, 40, 2689, 45, 297, 3515, 327, 283, 821, 14, 709, 14, 7968, 14, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 3130, 4483, 327, 283, 821, 14, 709, 14, 7968, 3530, 272, 1543, 68, 4111, 77, 4111, 89, 14, 450, 40, 2689, 45, 2689, 51, 297, 755, 327, 283, 821, 14, 709, 14, 1690, 14, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 14, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 259, 327, 283, 821, 14, 709, 14, 1690, 14, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 89, 14, 450, 40, 2689, 45, 297, 3515, 327, 283, 821, 14, 709, 14, 1690, 14, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 3130, 4483, 327, 283, 821, 14, 709, 14, 1690, 3530, 272, 1543, 68, 14, 450, 77, 14, 450, 57, 14, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 1616, 14, 8315, 14, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 57, 14, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 1616, 14, 8315, 14, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 57, 14, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 1616, 14, 8315, 14, 4329, 26, 1216, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 57, 3130, 4519, 327, 283, 821, 14, 1616, 14, 8315, 3530, 272, 1543, 68, 14, 450, 77, 14, 450, 89, 14, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 1616, 14, 24293, 14, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 89, 14, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 1616, 14, 24293, 14, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 89, 14, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 1616, 14, 24293, 14, 4329, 26, 1216, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 89, 3130, 4519, 327, 283, 821, 14, 1616, 14, 24293, 3530, 199, 61, 199, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 7815, 199, 9190, 63, 7823, 1206, 275, 650, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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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 ]
kvar/ansible
lib/ansible/modules/cloud/rackspace/rax_queue.py
102
3457
#!/usr/bin/python # Copyright: Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: rax_queue short_description: create / delete a queue in Rackspace Public Cloud description: - creates / deletes a Rackspace Public Cloud queue. version_added: "1.5" options: name: description: - Name to give the queue state: description: - Indicate desired state of the resource choices: - present - absent default: present author: - "Christopher H. Laco (@claco)" - "Matt Martz (@sivel)" extends_documentation_fragment: - rackspace - rackspace.openstack ''' EXAMPLES = ''' - name: Build a Queue gather_facts: False hosts: local connection: local tasks: - name: Queue create request local_action: module: rax_queue credentials: ~/.raxpub name: my-queue region: DFW state: present register: my_queue ''' try: import pyrax HAS_PYRAX = True except ImportError: HAS_PYRAX = False from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.rax import rax_argument_spec, rax_required_together, setup_rax_module def cloud_queue(module, state, name): for arg in (state, name): if not arg: module.fail_json(msg='%s is required for rax_queue' % arg) changed = False queues = [] instance = {} cq = pyrax.queues if not cq: module.fail_json(msg='Failed to instantiate client. This ' 'typically indicates an invalid region or an ' 'incorrectly capitalized region name.') for queue in cq.list(): if name != queue.name: continue queues.append(queue) if len(queues) > 1: module.fail_json(msg='Multiple Queues were matched by name') if state == 'present': if not queues: try: queue = cq.create(name) changed = True except Exception as e: module.fail_json(msg='%s' % e.message) else: queue = queues[0] instance = dict(name=queue.name) result = dict(changed=changed, queue=instance) module.exit_json(**result) elif state == 'absent': if queues: queue = queues[0] try: queue.delete() changed = True except Exception as e: module.fail_json(msg='%s' % e.message) module.exit_json(changed=changed, queue=instance) def main(): argument_spec = rax_argument_spec() argument_spec.update( dict( name=dict(), state=dict(default='present', choices=['present', 'absent']), ) ) module = AnsibleModule( argument_spec=argument_spec, required_together=rax_required_together() ) if not HAS_PYRAX: module.fail_json(msg='pyrax is required for this module') name = module.params.get('name') state = module.params.get('state') setup_rax_module(module, pyrax) cloud_queue(module, state, name) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1898, 26, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 16937, 63, 1825, 199, 3612, 63, 1802, 26, 1218, 1182, 3145, 282, 4126, 315, 32679, 1684, 8142, 199, 1802, 26, 1362, 446, 8491, 1182, 21812, 282, 32679, 1684, 8142, 4126, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 21, 2, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 2812, 370, 8120, 314, 4126, 523, 1174, 26, 272, 1369, 26, 489, 446, 1010, 10188, 6387, 1174, 402, 314, 2073, 272, 3415, 26, 489, 446, 3451, 489, 446, 9552, 272, 849, 26, 3451, 199, 2502, 26, 272, 446, 298, 1049, 322, 2379, 2523, 869, 14, 7964, 331, 8593, 3995, 331, 2924, 272, 446, 298, 45, 6796, 603, 28124, 8593, 338, 1090, 2924, 199, 11036, 63, 9970, 63, 7677, 26, 523, 446, 660, 346, 2638, 523, 446, 660, 346, 2638, 14, 8512, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 6516, 282, 10703, 523, 13082, 63, 5047, 26, 756, 523, 7057, 26, 2257, 523, 1950, 26, 2257, 523, 6527, 26, 272, 446, 536, 26, 10703, 1218, 1056, 489, 2257, 63, 1287, 26, 267, 859, 26, 16937, 63, 1825, 267, 6235, 26, 25975, 14495, 5645, 267, 536, 26, 3002, 13, 1825, 267, 4897, 26, 577, 19445, 267, 1174, 26, 3451, 489, 2274, 26, 3002, 63, 1825, 199, 2344, 199, 199, 893, 26, 272, 492, 23944, 272, 7509, 63, 4521, 2847, 56, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 4521, 2847, 56, 275, 756, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 14495, 492, 16937, 63, 2094, 63, 1650, 12, 16937, 63, 2427, 63, 6314, 12, 3272, 63, 14495, 63, 578, 421, 199, 318, 8002, 63, 1825, 8, 578, 12, 1174, 12, 536, 304, 272, 367, 1680, 315, 334, 929, 12, 536, 304, 267, 340, 440, 1680, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 9569, 83, 365, 1415, 367, 16937, 63, 1825, 7, 450, 1680, 9, 339, 2896, 275, 756, 272, 21366, 275, 942, 272, 1256, 275, 1052, 339, 286, 81, 275, 23944, 14, 18849, 272, 340, 440, 286, 81, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 4276, 370, 17321, 1890, 14, 961, 283, 2490, 283, 32251, 9126, 376, 3866, 4897, 503, 376, 283, 2490, 283, 15448, 590, 17094, 1759, 4897, 536, 2659, 339, 367, 4126, 315, 286, 81, 14, 513, 837, 267, 340, 536, 1137, 4126, 14, 354, 26, 288, 1980, 398, 21366, 14, 740, 8, 1825, 9, 339, 340, 822, 8, 18849, 9, 690, 413, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 8433, 10703, 83, 4898, 7838, 701, 536, 358, 339, 340, 1174, 508, 283, 1881, 356, 267, 340, 440, 21366, 26, 288, 862, 26, 355, 4126, 275, 286, 81, 14, 981, 8, 354, 9, 355, 2896, 275, 715, 288, 871, 2186, 465, 325, 26, 355, 859, 14, 1633, 63, 1001, 8, 1328, 9569, 83, 7, 450, 325, 14, 1188, 9, 267, 587, 26, 288, 4126, 275, 21366, 59, 16, 61, 398, 1256, 275, 1211, 8, 354, 29, 1825, 14, 354, 9, 267, 754, 275, 1211, 8, 2489, 29, 2489, 12, 4126, 29, 842, 9, 267, 859, 14, 2224, 63, 1001, 3682, 1099, 9, 339, 916, 1174, 508, 283, 5575, 356, 267, 340, 21366, 26, 288, 4126, 275, 21366, 59, 16, 61, 288, 862, 26, 355, 4126, 14, 1807, 342, 355, 2896, 275, 715, 288, 871, 2186, 465, 325, 26, 355, 859, 14, 1633, 63, 1001, 8, 1328, 9569, 83, 7, 450, 325, 14, 1188, 9, 339, 859, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 12, 4126, 29, 842, 9, 421, 199, 318, 2446, 837, 272, 1423, 63, 1650, 275, 16937, 63, 2094, 63, 1650, 342, 272, 1423, 63, 1650, 14, 873, 8, 267, 1211, 8, 288, 536, 29, 807, 1062, 288, 1174, 29, 807, 8, 885, 534, 1881, 297, 3415, 2968, 1881, 297, 283, 5575, 3815, 267, 776, 272, 776, 339, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 2094, 63, 1650, 12, 267, 1415, 63, 6314, 29, 14495, 63, 2427, 63, 6314, 342, 272, 776, 339, 340, 440, 7509, 63, 4521, 2847, 56, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 647, 14495, 365, 1415, 367, 642, 859, 358, 339, 536, 275, 859, 14, 1162, 14, 362, 360, 354, 358, 272, 1174, 275, 859, 14, 1162, 14, 362, 360, 929, 358, 339, 3272, 63, 14495, 63, 578, 8, 578, 12, 23944, 9, 339, 8002, 63, 1825, 8, 578, 12, 1174, 12, 536, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1898, 26, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 16937, 63, 1825, 199, 3612, 63, 1802, 26, 1218, 1182, 3145, 282, 4126, 315, 32679, 1684, 8142, 199, 1802, 26, 1362, 446, 8491, 1182, 21812, 282, 32679, 1684, 8142, 4126, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 21, 2, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 2812, 370, 8120, 314, 4126, 523, 1174, 26, 272, 1369, 26, 489, 446, 1010, 10188, 6387, 1174, 402, 314, 2073, 272, 3415, 26, 489, 446, 3451, 489, 446, 9552, 272, 849, 26, 3451, 199, 2502, 26, 272, 446, 298, 1049, 322, 2379, 2523, 869, 14, 7964, 331, 8593, 3995, 331, 2924, 272, 446, 298, 45, 6796, 603, 28124, 8593, 338, 1090, 2924, 199, 11036, 63, 9970, 63, 7677, 26, 523, 446, 660, 346, 2638, 523, 446, 660, 346, 2638, 14, 8512, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 6516, 282, 10703, 523, 13082, 63, 5047, 26, 756, 523, 7057, 26, 2257, 523, 1950, 26, 2257, 523, 6527, 26, 272, 446, 536, 26, 10703, 1218, 1056, 489, 2257, 63, 1287, 26, 267, 859, 26, 16937, 63, 1825, 267, 6235, 26, 25975, 14495, 5645, 267, 536, 26, 3002, 13, 1825, 267, 4897, 26, 577, 19445, 267, 1174, 26, 3451, 489, 2274, 26, 3002, 63, 1825, 199, 2344, 199, 199, 893, 26, 272, 492, 23944, 272, 7509, 63, 4521, 2847, 56, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 4521, 2847, 56, 275, 756, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 14495, 492, 16937, 63, 2094, 63, 1650, 12, 16937, 63, 2427, 63, 6314, 12, 3272, 63, 14495, 63, 578, 421, 199, 318, 8002, 63, 1825, 8, 578, 12, 1174, 12, 536, 304, 272, 367, 1680, 315, 334, 929, 12, 536, 304, 267, 340, 440, 1680, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 9569, 83, 365, 1415, 367, 16937, 63, 1825, 7, 450, 1680, 9, 339, 2896, 275, 756, 272, 21366, 275, 942, 272, 1256, 275, 1052, 339, 286, 81, 275, 23944, 14, 18849, 272, 340, 440, 286, 81, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 4276, 370, 17321, 1890, 14, 961, 283, 2490, 283, 32251, 9126, 376, 3866, 4897, 503, 376, 283, 2490, 283, 15448, 590, 17094, 1759, 4897, 536, 2659, 339, 367, 4126, 315, 286, 81, 14, 513, 837, 267, 340, 536, 1137, 4126, 14, 354, 26, 288, 1980, 398, 21366, 14, 740, 8, 1825, 9, 339, 340, 822, 8, 18849, 9, 690, 413, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 8433, 10703, 83, 4898, 7838, 701, 536, 358, 339, 340, 1174, 508, 283, 1881, 356, 267, 340, 440, 21366, 26, 288, 862, 26, 355, 4126, 275, 286, 81, 14, 981, 8, 354, 9, 355, 2896, 275, 715, 288, 871, 2186, 465, 325, 26, 355, 859, 14, 1633, 63, 1001, 8, 1328, 9569, 83, 7, 450, 325, 14, 1188, 9, 267, 587, 26, 288, 4126, 275, 21366, 59, 16, 61, 398, 1256, 275, 1211, 8, 354, 29, 1825, 14, 354, 9, 267, 754, 275, 1211, 8, 2489, 29, 2489, 12, 4126, 29, 842, 9, 267, 859, 14, 2224, 63, 1001, 3682, 1099, 9, 339, 916, 1174, 508, 283, 5575, 356, 267, 340, 21366, 26, 288, 4126, 275, 21366, 59, 16, 61, 288, 862, 26, 355, 4126, 14, 1807, 342, 355, 2896, 275, 715, 288, 871, 2186, 465, 325, 26, 355, 859, 14, 1633, 63, 1001, 8, 1328, 9569, 83, 7, 450, 325, 14, 1188, 9, 339, 859, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 12, 4126, 29, 842, 9, 421, 199, 318, 2446, 837, 272, 1423, 63, 1650, 275, 16937, 63, 2094, 63, 1650, 342, 272, 1423, 63, 1650, 14, 873, 8, 267, 1211, 8, 288, 536, 29, 807, 1062, 288, 1174, 29, 807, 8, 885, 534, 1881, 297, 3415, 2968, 1881, 297, 283, 5575, 3815, 267, 776, 272, 776, 339, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 2094, 63, 1650, 12, 267, 1415, 63, 6314, 29, 14495, 63, 2427, 63, 6314, 342, 272, 776, 339, 340, 440, 7509, 63, 4521, 2847, 56, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 647, 14495, 365, 1415, 367, 642, 859, 358, 339, 536, 275, 859, 14, 1162, 14, 362, 360, 354, 358, 272, 1174, 275, 859, 14, 1162, 14, 362, 360, 929, 358, 339, 3272, 63, 14495, 63, 578, 8, 578, 12, 23944, 9, 339, 8002, 63, 1825, 8, 578, 12, 1174, 12, 536, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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 ]
tysonholub/twilio-python
tests/integration/ip_messaging/v2/service/test_binding.py
1
6696
# coding=utf-8 r""" This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class BindingTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \ .bindings.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Bindings', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "next_page_url": null, "key": "bindings" }, "bindings": [ { "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-10-21T11:37:03Z", "date_updated": "2016-10-21T11:37:03Z", "endpoint": "TestUser-endpoint", "identity": "TestUser", "binding_type": "gcm", "credential_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "message_types": [ "removed_from_channel", "new_message", "added_to_channel", "invited_to_channel" ], "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "user": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/TestUser" } } ] } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \ .bindings.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "next_page_url": null, "key": "bindings" }, "bindings": [] } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \ .bindings.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \ .bindings(sid="BSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Bindings/BSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-10-21T11:37:03Z", "date_updated": "2016-10-21T11:37:03Z", "endpoint": "TestUser-endpoint", "identity": "TestUser", "binding_type": "gcm", "credential_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "message_types": [ "removed_from_channel", "new_message", "added_to_channel", "invited_to_channel" ], "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "user": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/TestUser" } } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \ .bindings(sid="BSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \ .bindings(sid="BSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Bindings/BSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.ip_messaging.v2.services(sid="ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \ .bindings(sid="BSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").delete() self.assertTrue(actual)
mit
[ 3, 2803, 29, 1624, 13, 24, 199, 82, 624, 199, 2765, 1233, 1990, 4046, 701, 199, 60, 1182, 485, 259, 485, 221, 485, 92, 257, 485, 221, 485, 199, 1204, 6110, 2862, 15, 1547, 9, 1547, 6113, 15, 92, 1204, 8, 15607, 221, 373, 17, 14, 16, 14, 16, 489, 1182, 755, 1182, 199, 624, 199, 199, 504, 2295, 492, 27561, 1746, 199, 504, 2295, 14, 526, 320, 31919, 492, 4784, 199, 504, 8900, 23533, 14, 1095, 14, 3924, 492, 377, 87, 23533, 1726, 199, 504, 8900, 23533, 14, 1014, 14, 1310, 492, 7232, 421, 199, 533, 22630, 316, 1746, 8, 20405, 1746, 304, 339, 347, 511, 63, 513, 63, 1069, 8, 277, 304, 267, 291, 14, 526, 320, 31919, 14, 1805, 8, 2364, 8, 5783, 12, 12381, 398, 543, 291, 14, 1855, 8, 22879, 23533, 1726, 304, 288, 291, 14, 1258, 14, 711, 63, 27782, 14, 86, 18, 14, 5950, 8, 4148, 628, 1311, 25837, 25837, 531, 971, 4318, 1275, 10880, 14, 513, 342, 398, 291, 14, 526, 320, 31919, 14, 479, 63, 1989, 63, 1069, 8, 2017, 8, 288, 283, 362, 297, 288, 283, 2859, 921, 10289, 14, 8122, 23533, 14, 957, 15, 86, 18, 15, 15803, 15, 1311, 25837, 25837, 15, 8198, 780, 297, 267, 5082, 339, 347, 511, 63, 739, 63, 2861, 63, 1310, 8, 277, 304, 267, 291, 14, 526, 320, 31919, 14, 1805, 8, 2364, 8, 288, 1926, 12, 288, 1449, 288, 469, 355, 298, 2024, 582, 469, 490, 298, 1606, 582, 378, 12, 490, 298, 1606, 63, 890, 582, 5238, 12, 490, 298, 2246, 63, 1606, 63, 633, 582, 298, 2859, 921, 10289, 14, 8122, 23533, 14, 957, 15, 86, 18, 15, 15803, 15, 1311, 20002, 20002, 15, 8198, 780, 31, 3276, 2320, 29, 1400, 6, 3276, 29, 16, 401, 490, 298, 6352, 63, 1606, 63, 633, 582, 2973, 12, 490, 298, 633, 582, 298, 2859, 921, 10289, 14, 8122, 23533, 14, 957, 15, 86, 18, 15, 15803, 15, 1311, 20002, 20002, 15, 8198, 780, 31, 3276, 2320, 29, 1400, 6, 3276, 29, 16, 401, 490, 298, 2184, 63, 1606, 63, 633, 582, 2973, 12, 490, 298, 498, 582, 298, 10880, 2, 355, 1660, 355, 298, 10880, 582, 359, 490, 469, 717, 298, 4148, 582, 298, 11087, 20002, 20002, 401, 717, 298, 2048, 63, 4148, 582, 298, 1348, 20002, 20002, 401, 717, 298, 1364, 63, 4148, 582, 298, 1311, 20002, 20002, 401, 717, 298, 602, 63, 3966, 582, 298, 9261, 13, 709, 13, 2025, 52, 845, 26, 1401, 26, 1644, 58, 401, 717, 298, 602, 63, 5334, 582, 298, 9261, 13, 709, 13, 2025, 52, 845, 26, 1401, 26, 1644, 58, 401, 717, 298, 6520, 582, 298, 774, 1899, 13, 6520, 401, 717, 298, 5582, 582, 298, 774, 1899, 401, 717, 298, 9140, 63, 466, 582, 298, 71, 4400, 401, 717, 298, 15591, 63, 4148, 582, 298, 35, 1537, 20002, 10980, 6000, 11629, 401, 717, 298, 1188, 63, 1313, 582, 359, 1169, 298, 10649, 63, 504, 63, 2775, 401, 1169, 298, 1222, 63, 1188, 401, 1169, 298, 3270, 63, 475, 63, 2775, 401, 1169, 298, 262, 433, 471, 63, 475, 63, 2775, 2, 717, 2156, 717, 298, 633, 582, 298, 2859, 921, 10289, 14, 8122, 23533, 14, 957, 15, 86, 18, 15, 15803, 15, 1311, 20002, 20002, 15, 8198, 780, 15, 11087, 20002, 20002, 401, 717, 298, 4614, 582, 469, 1169, 298, 751, 582, 298, 2859, 921, 10289, 14, 8122, 23533, 14, 957, 15, 86, 18, 15, 15803, 15, 1311, 20002, 20002, 15, 12117, 15, 774, 1899, 2, 717, 789, 490, 789, 355, 1622, 288, 789, 288, 1449, 267, 5082, 398, 3503, 275, 291, 14, 1258, 14, 711, 63, 27782, 14, 86, 18, 14, 5950, 8, 4148, 628, 1311, 25837, 25837, 531, 971, 4490, 1275, 10880, 14, 513, 342, 398, 291, 14, 10389, 8, 6514, 9, 339, 347, 511, 63, 739, 63, 1667, 63, 1310, 8, 277, 304, 267, 291, 14, 526, 320, 31919, 14, 1805, 8, 2364, 8, 288, 1926, 12, 288, 1449, 288, 469, 355, 298, 2024, 582, 469, 490, 298, 1606, 582, 378, 12, 490, 298, 1606, 63, 890, 582, 5238, 12, 490, 298, 2246, 63, 1606, 63, 633, 582, 298, 2859, 921, 10289, 14, 8122, 23533, 14, 957, 15, 86, 18, 15, 15803, 15, 1311, 20002, 20002, 15, 8198, 780, 31, 3276, 2320, 29, 1400, 6, 3276, 29, 16, 401, 490, 298, 6352, 63, 1606, 63, 633, 582, 2973, 12, 490, 298, 633, 582, 298, 2859, 921, 10289, 14, 8122, 23533, 14, 957, 15, 86, 18, 15, 15803, 15, 1311, 20002, 20002, 15, 8198, 780, 31, 3276, 2320, 29, 1400, 6, 3276, 29, 16, 401, 490, 298, 2184, 63, 1606, 63, 633, 582, 2973, 12, 490, 298, 498, 582, 298, 10880, 2, 355, 1660, 355, 298, 10880, 582, 942, 288, 789, 288, 1449, 267, 5082, 398, 3503, 275, 291, 14, 1258, 14, 711, 63, 27782, 14, 86, 18, 14, 5950, 8, 4148, 628, 1311, 25837, 25837, 531, 971, 4490, 1275, 10880, 14, 513, 342, 398, 291, 14, 10389, 8, 6514, 9, 339, 347, 511, 63, 3535, 63, 1069, 8, 277, 304, 267, 291, 14, 526, 320, 31919, 14, 1805, 8, 2364, 8, 5783, 12, 12381, 398, 543, 291, 14, 1855, 8, 22879, 23533, 1726, 304, 288, 291, 14, 1258, 14, 711, 63, 27782, 14, 86, 18, 14, 5950, 8, 4148, 628, 1311, 25837, 25837, 531, 971, 4318, 1275, 10880, 8, 4148, 628, 11087, 25837, 25837, 3471, 3535, 342, 398, 291, 14, 526, 320, 31919, 14, 479, 63, 1989, 63, 1069, 8, 2017, 8, 288, 283, 362, 297, 288, 283, 2859, 921, 10289, 14, 8122, 23533, 14, 957, 15, 86, 18, 15, 15803, 15, 1311, 25837, 25837, 15, 8198, 780, 15, 11087, 25837, 25837, 297, 267, 5082, 339, 347, 511, 63, 3535, 63, 1310, 8, 277, 304, 267, 291, 14, 526, 320, 31919, 14, 1805, 8, 2364, 8, 288, 1926, 12, 288, 1449, 288, 469, 355, 298, 4148, 582, 298, 11087, 20002, 20002, 401, 355, 298, 2048, 63, 4148, 582, 298, 1348, 20002, 20002, 401, 355, 298, 1364, 63, 4148, 582, 298, 1311, 20002, 20002, 401, 355, 298, 602, 63, 3966, 582, 298, 9261, 13, 709, 13, 2025, 52, 845, 26, 1401, 26, 1644 ]
[ 2803, 29, 1624, 13, 24, 199, 82, 624, 199, 2765, 1233, 1990, 4046, 701, 199, 60, 1182, 485, 259, 485, 221, 485, 92, 257, 485, 221, 485, 199, 1204, 6110, 2862, 15, 1547, 9, 1547, 6113, 15, 92, 1204, 8, 15607, 221, 373, 17, 14, 16, 14, 16, 489, 1182, 755, 1182, 199, 624, 199, 199, 504, 2295, 492, 27561, 1746, 199, 504, 2295, 14, 526, 320, 31919, 492, 4784, 199, 504, 8900, 23533, 14, 1095, 14, 3924, 492, 377, 87, 23533, 1726, 199, 504, 8900, 23533, 14, 1014, 14, 1310, 492, 7232, 421, 199, 533, 22630, 316, 1746, 8, 20405, 1746, 304, 339, 347, 511, 63, 513, 63, 1069, 8, 277, 304, 267, 291, 14, 526, 320, 31919, 14, 1805, 8, 2364, 8, 5783, 12, 12381, 398, 543, 291, 14, 1855, 8, 22879, 23533, 1726, 304, 288, 291, 14, 1258, 14, 711, 63, 27782, 14, 86, 18, 14, 5950, 8, 4148, 628, 1311, 25837, 25837, 531, 971, 4318, 1275, 10880, 14, 513, 342, 398, 291, 14, 526, 320, 31919, 14, 479, 63, 1989, 63, 1069, 8, 2017, 8, 288, 283, 362, 297, 288, 283, 2859, 921, 10289, 14, 8122, 23533, 14, 957, 15, 86, 18, 15, 15803, 15, 1311, 25837, 25837, 15, 8198, 780, 297, 267, 5082, 339, 347, 511, 63, 739, 63, 2861, 63, 1310, 8, 277, 304, 267, 291, 14, 526, 320, 31919, 14, 1805, 8, 2364, 8, 288, 1926, 12, 288, 1449, 288, 469, 355, 298, 2024, 582, 469, 490, 298, 1606, 582, 378, 12, 490, 298, 1606, 63, 890, 582, 5238, 12, 490, 298, 2246, 63, 1606, 63, 633, 582, 298, 2859, 921, 10289, 14, 8122, 23533, 14, 957, 15, 86, 18, 15, 15803, 15, 1311, 20002, 20002, 15, 8198, 780, 31, 3276, 2320, 29, 1400, 6, 3276, 29, 16, 401, 490, 298, 6352, 63, 1606, 63, 633, 582, 2973, 12, 490, 298, 633, 582, 298, 2859, 921, 10289, 14, 8122, 23533, 14, 957, 15, 86, 18, 15, 15803, 15, 1311, 20002, 20002, 15, 8198, 780, 31, 3276, 2320, 29, 1400, 6, 3276, 29, 16, 401, 490, 298, 2184, 63, 1606, 63, 633, 582, 2973, 12, 490, 298, 498, 582, 298, 10880, 2, 355, 1660, 355, 298, 10880, 582, 359, 490, 469, 717, 298, 4148, 582, 298, 11087, 20002, 20002, 401, 717, 298, 2048, 63, 4148, 582, 298, 1348, 20002, 20002, 401, 717, 298, 1364, 63, 4148, 582, 298, 1311, 20002, 20002, 401, 717, 298, 602, 63, 3966, 582, 298, 9261, 13, 709, 13, 2025, 52, 845, 26, 1401, 26, 1644, 58, 401, 717, 298, 602, 63, 5334, 582, 298, 9261, 13, 709, 13, 2025, 52, 845, 26, 1401, 26, 1644, 58, 401, 717, 298, 6520, 582, 298, 774, 1899, 13, 6520, 401, 717, 298, 5582, 582, 298, 774, 1899, 401, 717, 298, 9140, 63, 466, 582, 298, 71, 4400, 401, 717, 298, 15591, 63, 4148, 582, 298, 35, 1537, 20002, 10980, 6000, 11629, 401, 717, 298, 1188, 63, 1313, 582, 359, 1169, 298, 10649, 63, 504, 63, 2775, 401, 1169, 298, 1222, 63, 1188, 401, 1169, 298, 3270, 63, 475, 63, 2775, 401, 1169, 298, 262, 433, 471, 63, 475, 63, 2775, 2, 717, 2156, 717, 298, 633, 582, 298, 2859, 921, 10289, 14, 8122, 23533, 14, 957, 15, 86, 18, 15, 15803, 15, 1311, 20002, 20002, 15, 8198, 780, 15, 11087, 20002, 20002, 401, 717, 298, 4614, 582, 469, 1169, 298, 751, 582, 298, 2859, 921, 10289, 14, 8122, 23533, 14, 957, 15, 86, 18, 15, 15803, 15, 1311, 20002, 20002, 15, 12117, 15, 774, 1899, 2, 717, 789, 490, 789, 355, 1622, 288, 789, 288, 1449, 267, 5082, 398, 3503, 275, 291, 14, 1258, 14, 711, 63, 27782, 14, 86, 18, 14, 5950, 8, 4148, 628, 1311, 25837, 25837, 531, 971, 4490, 1275, 10880, 14, 513, 342, 398, 291, 14, 10389, 8, 6514, 9, 339, 347, 511, 63, 739, 63, 1667, 63, 1310, 8, 277, 304, 267, 291, 14, 526, 320, 31919, 14, 1805, 8, 2364, 8, 288, 1926, 12, 288, 1449, 288, 469, 355, 298, 2024, 582, 469, 490, 298, 1606, 582, 378, 12, 490, 298, 1606, 63, 890, 582, 5238, 12, 490, 298, 2246, 63, 1606, 63, 633, 582, 298, 2859, 921, 10289, 14, 8122, 23533, 14, 957, 15, 86, 18, 15, 15803, 15, 1311, 20002, 20002, 15, 8198, 780, 31, 3276, 2320, 29, 1400, 6, 3276, 29, 16, 401, 490, 298, 6352, 63, 1606, 63, 633, 582, 2973, 12, 490, 298, 633, 582, 298, 2859, 921, 10289, 14, 8122, 23533, 14, 957, 15, 86, 18, 15, 15803, 15, 1311, 20002, 20002, 15, 8198, 780, 31, 3276, 2320, 29, 1400, 6, 3276, 29, 16, 401, 490, 298, 2184, 63, 1606, 63, 633, 582, 2973, 12, 490, 298, 498, 582, 298, 10880, 2, 355, 1660, 355, 298, 10880, 582, 942, 288, 789, 288, 1449, 267, 5082, 398, 3503, 275, 291, 14, 1258, 14, 711, 63, 27782, 14, 86, 18, 14, 5950, 8, 4148, 628, 1311, 25837, 25837, 531, 971, 4490, 1275, 10880, 14, 513, 342, 398, 291, 14, 10389, 8, 6514, 9, 339, 347, 511, 63, 3535, 63, 1069, 8, 277, 304, 267, 291, 14, 526, 320, 31919, 14, 1805, 8, 2364, 8, 5783, 12, 12381, 398, 543, 291, 14, 1855, 8, 22879, 23533, 1726, 304, 288, 291, 14, 1258, 14, 711, 63, 27782, 14, 86, 18, 14, 5950, 8, 4148, 628, 1311, 25837, 25837, 531, 971, 4318, 1275, 10880, 8, 4148, 628, 11087, 25837, 25837, 3471, 3535, 342, 398, 291, 14, 526, 320, 31919, 14, 479, 63, 1989, 63, 1069, 8, 2017, 8, 288, 283, 362, 297, 288, 283, 2859, 921, 10289, 14, 8122, 23533, 14, 957, 15, 86, 18, 15, 15803, 15, 1311, 25837, 25837, 15, 8198, 780, 15, 11087, 25837, 25837, 297, 267, 5082, 339, 347, 511, 63, 3535, 63, 1310, 8, 277, 304, 267, 291, 14, 526, 320, 31919, 14, 1805, 8, 2364, 8, 288, 1926, 12, 288, 1449, 288, 469, 355, 298, 4148, 582, 298, 11087, 20002, 20002, 401, 355, 298, 2048, 63, 4148, 582, 298, 1348, 20002, 20002, 401, 355, 298, 1364, 63, 4148, 582, 298, 1311, 20002, 20002, 401, 355, 298, 602, 63, 3966, 582, 298, 9261, 13, 709, 13, 2025, 52, 845, 26, 1401, 26, 1644, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
darkleons/lama
addons/project_timesheet/__init__.py
441
1084
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import project_timesheet import report # 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, 646, 2199, 63, 17739, 199, 646, 3622, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 646, 2199, 63, 17739, 199, 646, 3622, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Sidney84/pa-chromium
chrome/test/functional/devtools_instrumented_objects_check.py
15
2829
#!/usr/bin/env python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import logging import os import tempfile import devtools_test_base import pyauto_functional # Must be imported before pyauto import pyauto import pyauto_utils class DevToolsInstrumentedObjectsCheck(devtools_test_base.DevToolsTestBase): """Test for checking that all instrumented objects are allocated by tcmalloc. This test navigates the browser to a test page, then takes native memory snapshot over remote debugging protocol and prints the number of objects that were counted by the DevTools memory instrumentation and how many of them have not been allocated by tcmalloc. Ideally the latter number should be 0. The test starts browser with HEAPPROFILE environment variable to enable tcmalloc heap profiler which is required by the memory instrumentation to check which of the instrumented objects have actually been allocated on the heap. The test uses Web Page Replay server as a proxy that allows to replay the same state of the test pages and avoid heavy network traffic on the real web sites. See webpagereplay.ReplayServer documentation to learn how to record new page archives. """ def setUp(self): # Make sure Chrome is started with tcmalloc heap profiler enabled. Dump # profiles into a temporary directory that will be destroyed when the test # completes. self._tempdir = tempfile.mkdtemp(prefix='devtools-test') os.environ['HEAPPROFILE'] = os.path.join(self._tempdir, 'heap-profile.') super(DevToolsInstrumentedObjectsCheck, self).setUp() def tearDown(self): super(DevToolsInstrumentedObjectsCheck, self).tearDown() del os.environ['HEAPPROFILE'] if self._tempdir: pyauto_utils.RemovePath(self._tempdir) def testNytimes(self): self.RunTestWithUrl('http://www.nytimes.com/') def testCnn(self): self.RunTestWithUrl('http://www.cnn.com/') def testGoogle(self): self.RunTestWithUrl('http://www.google.com/') def PrintTestResult(self, hostname, snapshot): total = snapshot.GetProcessPrivateMemorySize() counted_objects = snapshot.GetInstrumentedObjectsCount() counted_unknown_objects = snapshot.GetNumberOfInstrumentedObjectsNotInHeap() if counted_objects is None or counted_unknown_objects is None: logging.info('No information about number of instrumented objects.') return logging.info('Got data for: %s, objects count = %d (unknown = %d) ' % (hostname, counted_objects, counted_unknown_objects)) pyauto_utils.PrintPerfResult('DevTools Unknown Instrumented Objects', hostname, counted_unknown_objects, 'objects') if __name__ == '__main__': pyauto_functional.Main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 2050, 199, 646, 747, 199, 646, 5549, 199, 199, 646, 4866, 2537, 63, 396, 63, 1095, 199, 646, 1134, 2495, 63, 15481, 221, 327, 9498, 506, 8439, 2544, 1134, 2495, 199, 646, 1134, 2495, 199, 646, 1134, 2495, 63, 1208, 421, 199, 533, 29314, 11654, 607, 495, 12546, 11188, 1799, 8, 32355, 63, 396, 63, 1095, 14, 12680, 11654, 14440, 304, 523, 408, 774, 367, 7907, 626, 1006, 18885, 12546, 2251, 787, 17659, 701, 14415, 23981, 14, 819, 961, 511, 12670, 71, 2335, 314, 7042, 370, 282, 511, 2034, 12, 2066, 6181, 5438, 4402, 523, 5740, 1806, 3982, 10201, 4113, 436, 14767, 314, 1329, 402, 2251, 523, 626, 4898, 31662, 701, 314, 29314, 11654, 4402, 14498, 425, 436, 4212, 5002, 402, 523, 3062, 1172, 440, 2757, 17659, 701, 14415, 23981, 14, 473, 271, 1183, 314, 19045, 1329, 1077, 523, 506, 378, 14, 819, 710, 511, 9174, 7042, 543, 8378, 1282, 16632, 3734, 1750, 370, 4756, 523, 14415, 23981, 13295, 23173, 1314, 365, 1415, 701, 314, 4402, 14498, 425, 370, 523, 1104, 1314, 402, 314, 18885, 12546, 2251, 1172, 5965, 2757, 17659, 641, 314, 523, 13295, 14, 819, 710, 511, 4440, 6001, 10331, 799, 2802, 1654, 465, 282, 4566, 626, 6127, 370, 24331, 523, 314, 2011, 1174, 402, 314, 511, 6497, 436, 5126, 946, 22421, 2784, 15602, 641, 314, 523, 3363, 3330, 15424, 14, 1666, 9248, 19540, 14, 11657, 3120, 3794, 370, 12537, 4212, 523, 370, 2777, 892, 2034, 25993, 14, 523, 408, 819, 347, 3613, 8, 277, 304, 272, 327, 4155, 3238, 16776, 365, 8239, 543, 14415, 23981, 13295, 23173, 5223, 14, 19460, 272, 327, 17390, 1901, 282, 7937, 2082, 626, 911, 506, 28924, 1380, 314, 511, 272, 327, 29672, 14, 272, 291, 423, 11567, 275, 5549, 14, 11983, 8, 1861, 534, 32355, 13, 396, 358, 272, 747, 14, 2314, 459, 23707, 16632, 418, 275, 747, 14, 515, 14, 904, 8, 277, 423, 11567, 12, 283, 12492, 13, 2913, 2659, 272, 1613, 8, 12680, 11654, 607, 495, 12546, 11188, 1799, 12, 291, 680, 5996, 342, 819, 347, 6766, 8, 277, 304, 272, 1613, 8, 12680, 11654, 607, 495, 12546, 11188, 1799, 12, 291, 680, 12336, 342, 272, 2150, 747, 14, 2314, 459, 23707, 16632, 418, 272, 340, 291, 423, 11567, 26, 489, 1134, 2495, 63, 1208, 14, 5587, 2042, 8, 277, 423, 11567, 9, 819, 347, 511, 22781, 4508, 8, 277, 304, 272, 291, 14, 2540, 774, 3007, 6417, 360, 1014, 921, 1544, 14, 9745, 4508, 14, 957, 6217, 819, 347, 511, 35, 4411, 8, 277, 304, 272, 291, 14, 2540, 774, 3007, 6417, 360, 1014, 921, 1544, 14, 67, 4411, 14, 957, 6217, 819, 347, 511, 13266, 8, 277, 304, 272, 291, 14, 2540, 774, 3007, 6417, 360, 1014, 921, 1544, 14, 3098, 14, 957, 6217, 819, 347, 9101, 13120, 8, 277, 12, 6246, 12, 5740, 304, 272, 3141, 275, 5740, 14, 1002, 3498, 12185, 8628, 2320, 342, 272, 31662, 63, 1462, 275, 5740, 14, 1002, 607, 495, 12546, 11188, 2353, 342, 272, 31662, 63, 5187, 63, 1462, 275, 5740, 14, 1002, 16030, 607, 495, 12546, 11188, 1763, 607, 19777, 342, 272, 340, 31662, 63, 1462, 365, 488, 503, 31662, 63, 5187, 63, 1462, 365, 488, 26, 489, 2050, 14, 815, 360, 1944, 2556, 3595, 1329, 402, 18885, 12546, 2251, 2659, 489, 372, 272, 2050, 14, 815, 360, 13662, 666, 367, 26, 450, 83, 12, 2251, 2338, 275, 450, 68, 334, 5187, 275, 450, 68, 9, 283, 450, 267, 334, 4269, 12, 31662, 63, 1462, 12, 31662, 63, 5187, 63, 1462, 430, 272, 1134, 2495, 63, 1208, 14, 5375, 12387, 2889, 360, 12680, 11654, 14831, 1010, 495, 12546, 26794, 297, 267, 6246, 12, 31662, 63, 5187, 63, 1462, 12, 283, 1462, 358, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 1134, 2495, 63, 15481, 14, 6756, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 2050, 199, 646, 747, 199, 646, 5549, 199, 199, 646, 4866, 2537, 63, 396, 63, 1095, 199, 646, 1134, 2495, 63, 15481, 221, 327, 9498, 506, 8439, 2544, 1134, 2495, 199, 646, 1134, 2495, 199, 646, 1134, 2495, 63, 1208, 421, 199, 533, 29314, 11654, 607, 495, 12546, 11188, 1799, 8, 32355, 63, 396, 63, 1095, 14, 12680, 11654, 14440, 304, 523, 408, 774, 367, 7907, 626, 1006, 18885, 12546, 2251, 787, 17659, 701, 14415, 23981, 14, 819, 961, 511, 12670, 71, 2335, 314, 7042, 370, 282, 511, 2034, 12, 2066, 6181, 5438, 4402, 523, 5740, 1806, 3982, 10201, 4113, 436, 14767, 314, 1329, 402, 2251, 523, 626, 4898, 31662, 701, 314, 29314, 11654, 4402, 14498, 425, 436, 4212, 5002, 402, 523, 3062, 1172, 440, 2757, 17659, 701, 14415, 23981, 14, 473, 271, 1183, 314, 19045, 1329, 1077, 523, 506, 378, 14, 819, 710, 511, 9174, 7042, 543, 8378, 1282, 16632, 3734, 1750, 370, 4756, 523, 14415, 23981, 13295, 23173, 1314, 365, 1415, 701, 314, 4402, 14498, 425, 370, 523, 1104, 1314, 402, 314, 18885, 12546, 2251, 1172, 5965, 2757, 17659, 641, 314, 523, 13295, 14, 819, 710, 511, 4440, 6001, 10331, 799, 2802, 1654, 465, 282, 4566, 626, 6127, 370, 24331, 523, 314, 2011, 1174, 402, 314, 511, 6497, 436, 5126, 946, 22421, 2784, 15602, 641, 314, 523, 3363, 3330, 15424, 14, 1666, 9248, 19540, 14, 11657, 3120, 3794, 370, 12537, 4212, 523, 370, 2777, 892, 2034, 25993, 14, 523, 408, 819, 347, 3613, 8, 277, 304, 272, 327, 4155, 3238, 16776, 365, 8239, 543, 14415, 23981, 13295, 23173, 5223, 14, 19460, 272, 327, 17390, 1901, 282, 7937, 2082, 626, 911, 506, 28924, 1380, 314, 511, 272, 327, 29672, 14, 272, 291, 423, 11567, 275, 5549, 14, 11983, 8, 1861, 534, 32355, 13, 396, 358, 272, 747, 14, 2314, 459, 23707, 16632, 418, 275, 747, 14, 515, 14, 904, 8, 277, 423, 11567, 12, 283, 12492, 13, 2913, 2659, 272, 1613, 8, 12680, 11654, 607, 495, 12546, 11188, 1799, 12, 291, 680, 5996, 342, 819, 347, 6766, 8, 277, 304, 272, 1613, 8, 12680, 11654, 607, 495, 12546, 11188, 1799, 12, 291, 680, 12336, 342, 272, 2150, 747, 14, 2314, 459, 23707, 16632, 418, 272, 340, 291, 423, 11567, 26, 489, 1134, 2495, 63, 1208, 14, 5587, 2042, 8, 277, 423, 11567, 9, 819, 347, 511, 22781, 4508, 8, 277, 304, 272, 291, 14, 2540, 774, 3007, 6417, 360, 1014, 921, 1544, 14, 9745, 4508, 14, 957, 6217, 819, 347, 511, 35, 4411, 8, 277, 304, 272, 291, 14, 2540, 774, 3007, 6417, 360, 1014, 921, 1544, 14, 67, 4411, 14, 957, 6217, 819, 347, 511, 13266, 8, 277, 304, 272, 291, 14, 2540, 774, 3007, 6417, 360, 1014, 921, 1544, 14, 3098, 14, 957, 6217, 819, 347, 9101, 13120, 8, 277, 12, 6246, 12, 5740, 304, 272, 3141, 275, 5740, 14, 1002, 3498, 12185, 8628, 2320, 342, 272, 31662, 63, 1462, 275, 5740, 14, 1002, 607, 495, 12546, 11188, 2353, 342, 272, 31662, 63, 5187, 63, 1462, 275, 5740, 14, 1002, 16030, 607, 495, 12546, 11188, 1763, 607, 19777, 342, 272, 340, 31662, 63, 1462, 365, 488, 503, 31662, 63, 5187, 63, 1462, 365, 488, 26, 489, 2050, 14, 815, 360, 1944, 2556, 3595, 1329, 402, 18885, 12546, 2251, 2659, 489, 372, 272, 2050, 14, 815, 360, 13662, 666, 367, 26, 450, 83, 12, 2251, 2338, 275, 450, 68, 334, 5187, 275, 450, 68, 9, 283, 450, 267, 334, 4269, 12, 31662, 63, 1462, 12, 31662, 63, 5187, 63, 1462, 430, 272, 1134, 2495, 63, 1208, 14, 5375, 12387, 2889, 360, 12680, 11654, 14831, 1010, 495, 12546, 26794, 297, 267, 6246, 12, 31662, 63, 5187, 63, 1462, 12, 283, 1462, 358, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 1134, 2495, 63, 15481, 14, 6756, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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which specifies the type of each field in the item. This module contains FieldProcessor implementations, which are the classes responsible for custom processing of these types. We keep the types of scrapers supported flexible and allow different methods for each. In the future, we expect many different types, for example one might be a mechanical turk scraper and the fields would have to do user validation and provide error messages. """ from .text import ( RawFieldTypeProcessor, TextFieldTypeProcessor, SafeHtmlFieldTypeProcessor ) from .images import ImagesFieldTypeProcessor from .url import UrlFieldTypeProcessor from .number import NumberTypeProcessor from .point import GeoPointFieldTypeProcessor from .price import PriceTypeProcessor from .date import DateTimeFieldTypeProcessor class FieldTypeManager(object): _TYPEMAP = dict((c.name, c) for c in ( RawFieldTypeProcessor, TextFieldTypeProcessor, ImagesFieldTypeProcessor, NumberTypeProcessor, UrlFieldTypeProcessor, SafeHtmlFieldTypeProcessor, GeoPointFieldTypeProcessor, PriceTypeProcessor, DateTimeFieldTypeProcessor )) _names = sorted(_TYPEMAP.keys()) def available_type_names(self): """Find the names of all field types available. """ return self._names def type_processor_class(self, name): """Retrieve the class for the given extractor This can be useful to introspect on the constructor arguments. If no suitable type is found, it will default to the RawFieldTypeProcessor (no processing of extracted data is done). """ return self._TYPEMAP.get(name, RawFieldTypeProcessor) def all_processor_classes(self): """Retrieve all processor classes registered""" return list(self._TYPEMAP.values())
bsd-3-clause
[ 624, 199, 792, 18851, 199, 199, 51, 1038, 7735, 5536, 83, 2974, 402, 282, 1627, 730, 14, 5723, 1242, 2943, 787, 3247, 701, 282, 199, 3629, 12, 1314, 9314, 314, 730, 402, 1924, 901, 315, 314, 1242, 14, 961, 859, 199, 6134, 5024, 10438, 12591, 12, 1314, 787, 314, 3992, 17845, 367, 199, 4229, 6661, 402, 3520, 2943, 14, 199, 199, 6004, 4215, 314, 2943, 402, 21435, 83, 3748, 26841, 436, 2040, 3365, 3102, 199, 509, 1924, 14, 1010, 314, 6466, 12, 781, 4282, 5002, 3365, 2943, 12, 367, 2893, 1373, 5594, 199, 1235, 282, 562, 11984, 2652, 307, 300, 75, 21435, 436, 314, 1504, 3955, 1172, 370, 886, 922, 6411, 199, 460, 5647, 1125, 3788, 14, 199, 624, 199, 504, 1275, 505, 492, 334, 272, 13480, 792, 804, 10438, 12, 272, 4516, 792, 804, 10438, 12, 272, 14969, 12957, 792, 804, 10438, 199, 9, 199, 504, 1275, 4782, 492, 32658, 792, 804, 10438, 199, 504, 1275, 633, 492, 20503, 792, 804, 10438, 199, 504, 1275, 1955, 492, 4860, 804, 10438, 199, 504, 1275, 1403, 492, 8875, 3428, 792, 804, 10438, 199, 504, 1275, 4777, 492, 20276, 804, 10438, 199, 504, 1275, 602, 492, 31637, 804, 10438, 421, 199, 533, 5024, 804, 2988, 8, 785, 304, 272, 485, 2711, 5443, 275, 1211, 1332, 67, 14, 354, 12, 286, 9, 367, 286, 315, 334, 267, 13480, 792, 804, 10438, 12, 4516, 792, 804, 10438, 12, 267, 32658, 792, 804, 10438, 12, 4860, 804, 10438, 12, 267, 20503, 792, 804, 10438, 12, 14969, 12957, 792, 804, 10438, 12, 267, 8875, 3428, 792, 804, 10438, 12, 20276, 804, 10438, 12, 267, 31637, 804, 10438, 272, 5082, 272, 485, 1247, 275, 3355, 1547, 2711, 5443, 14, 1612, 1012, 339, 347, 2808, 63, 466, 63, 1247, 8, 277, 304, 267, 408, 6591, 314, 1561, 402, 1006, 901, 2943, 2808, 14, 408, 267, 372, 291, 423, 1247, 339, 347, 730, 63, 6459, 63, 533, 8, 277, 12, 536, 304, 267, 408, 15310, 314, 1021, 367, 314, 1627, 31295, 398, 961, 883, 506, 2997, 370, 1109, 21302, 641, 314, 3787, 2368, 14, 982, 949, 267, 11233, 730, 365, 1911, 12, 652, 911, 849, 370, 314, 13480, 792, 804, 10438, 267, 334, 889, 6661, 402, 12509, 666, 365, 4224, 680, 267, 408, 267, 372, 291, 423, 2711, 5443, 14, 362, 8, 354, 12, 13480, 792, 804, 10438, 9, 339, 347, 1006, 63, 6459, 63, 2888, 8, 277, 304, 267, 408, 15310, 1006, 12495, 3992, 7264, 624, 267, 372, 769, 8, 277, 423, 2711, 5443, 14, 1459, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 792, 18851, 199, 199, 51, 1038, 7735, 5536, 83, 2974, 402, 282, 1627, 730, 14, 5723, 1242, 2943, 787, 3247, 701, 282, 199, 3629, 12, 1314, 9314, 314, 730, 402, 1924, 901, 315, 314, 1242, 14, 961, 859, 199, 6134, 5024, 10438, 12591, 12, 1314, 787, 314, 3992, 17845, 367, 199, 4229, 6661, 402, 3520, 2943, 14, 199, 199, 6004, 4215, 314, 2943, 402, 21435, 83, 3748, 26841, 436, 2040, 3365, 3102, 199, 509, 1924, 14, 1010, 314, 6466, 12, 781, 4282, 5002, 3365, 2943, 12, 367, 2893, 1373, 5594, 199, 1235, 282, 562, 11984, 2652, 307, 300, 75, 21435, 436, 314, 1504, 3955, 1172, 370, 886, 922, 6411, 199, 460, 5647, 1125, 3788, 14, 199, 624, 199, 504, 1275, 505, 492, 334, 272, 13480, 792, 804, 10438, 12, 272, 4516, 792, 804, 10438, 12, 272, 14969, 12957, 792, 804, 10438, 199, 9, 199, 504, 1275, 4782, 492, 32658, 792, 804, 10438, 199, 504, 1275, 633, 492, 20503, 792, 804, 10438, 199, 504, 1275, 1955, 492, 4860, 804, 10438, 199, 504, 1275, 1403, 492, 8875, 3428, 792, 804, 10438, 199, 504, 1275, 4777, 492, 20276, 804, 10438, 199, 504, 1275, 602, 492, 31637, 804, 10438, 421, 199, 533, 5024, 804, 2988, 8, 785, 304, 272, 485, 2711, 5443, 275, 1211, 1332, 67, 14, 354, 12, 286, 9, 367, 286, 315, 334, 267, 13480, 792, 804, 10438, 12, 4516, 792, 804, 10438, 12, 267, 32658, 792, 804, 10438, 12, 4860, 804, 10438, 12, 267, 20503, 792, 804, 10438, 12, 14969, 12957, 792, 804, 10438, 12, 267, 8875, 3428, 792, 804, 10438, 12, 20276, 804, 10438, 12, 267, 31637, 804, 10438, 272, 5082, 272, 485, 1247, 275, 3355, 1547, 2711, 5443, 14, 1612, 1012, 339, 347, 2808, 63, 466, 63, 1247, 8, 277, 304, 267, 408, 6591, 314, 1561, 402, 1006, 901, 2943, 2808, 14, 408, 267, 372, 291, 423, 1247, 339, 347, 730, 63, 6459, 63, 533, 8, 277, 12, 536, 304, 267, 408, 15310, 314, 1021, 367, 314, 1627, 31295, 398, 961, 883, 506, 2997, 370, 1109, 21302, 641, 314, 3787, 2368, 14, 982, 949, 267, 11233, 730, 365, 1911, 12, 652, 911, 849, 370, 314, 13480, 792, 804, 10438, 267, 334, 889, 6661, 402, 12509, 666, 365, 4224, 680, 267, 408, 267, 372, 291, 423, 2711, 5443, 14, 362, 8, 354, 12, 13480, 792, 804, 10438, 9, 339, 347, 1006, 63, 6459, 63, 2888, 8, 277, 304, 267, 408, 15310, 1006, 12495, 3992, 7264, 624, 267, 372, 769, 8, 277, 423, 2711, 5443, 14, 1459, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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 ]
wrouesnel/ansible
lib/ansible/modules/cloud/vmware/vmware_vsan_cluster.py
47
3753
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2015, Russell Teague <rteague2 () csc.com> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: vmware_vsan_cluster short_description: Configure VSAN clustering on an ESXi host description: - This module can be used to configure VSAN clustering on an ESXi host version_added: 2.0 author: "Russell Teague (@mtnbikenc)" notes: - Tested on vSphere 5.5 requirements: - "python >= 2.6" - PyVmomi options: cluster_uuid: description: - Desired cluster UUID required: False extends_documentation_fragment: vmware.documentation ''' EXAMPLES = ''' # Example command from Ansible Playbook - name: Configure VMware VSAN Cluster hosts: deploy_node gather_facts: False tags: - vsan tasks: - name: Configure VSAN on first host vmware_vsan_cluster: hostname: "{{ groups['esxi'][0] }}" username: "{{ esxi_username }}" password: "{{ site_password }}" register: vsan_cluster - name: Configure VSAN on remaining hosts vmware_vsan_cluster: hostname: "{{ item }}" username: "{{ esxi_username }}" password: "{{ site_password }}" cluster_uuid: "{{ vsan_cluster.cluster_uuid }}" with_items: "{{ groups['esxi'][1:] }}" ''' try: from pyVmomi import vim, vmodl HAS_PYVMOMI = True except ImportError: HAS_PYVMOMI = False from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.vmware import (HAS_PYVMOMI, connect_to_api, get_all_objs, vmware_argument_spec, wait_for_task) def create_vsan_cluster(host_system, new_cluster_uuid): host_config_manager = host_system.configManager vsan_system = host_config_manager.vsanSystem vsan_config = vim.vsan.host.ConfigInfo() vsan_config.enabled = True if new_cluster_uuid is not None: vsan_config.clusterInfo = vim.vsan.host.ConfigInfo.ClusterInfo() vsan_config.clusterInfo.uuid = new_cluster_uuid vsan_config.storageInfo = vim.vsan.host.ConfigInfo.StorageInfo() vsan_config.storageInfo.autoClaimStorage = True task = vsan_system.UpdateVsan_Task(vsan_config) changed, result = wait_for_task(task) host_status = vsan_system.QueryHostStatus() cluster_uuid = host_status.uuid return changed, result, cluster_uuid def main(): argument_spec = vmware_argument_spec() argument_spec.update(dict(cluster_uuid=dict(required=False, type='str'))) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False) if not HAS_PYVMOMI: module.fail_json(msg='pyvmomi is required for this module') new_cluster_uuid = module.params['cluster_uuid'] try: content = connect_to_api(module, False) host = get_all_objs(content, [vim.HostSystem]) if not host: module.fail_json(msg="Unable to locate Physical Host.") host_system = host.keys()[0] changed, result, cluster_uuid = create_vsan_cluster(host_system, new_cluster_uuid) module.exit_json(changed=changed, result=result, cluster_uuid=cluster_uuid) except vmodl.RuntimeFault as runtime_fault: module.fail_json(msg=runtime_fault.msg) except vmodl.MethodFault as method_fault: module.fail_json(msg=method_fault.msg) except Exception as e: module.fail_json(msg=str(e)) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6900, 12, 820, 527, 23235, 5773, 30904, 665, 82, 266, 30904, 18, 6248, 28308, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 19365, 63, 3122, 290, 63, 4201, 199, 3612, 63, 1802, 26, 15453, 21685, 879, 19454, 641, 376, 10427, 14828, 1591, 199, 1802, 26, 272, 446, 961, 859, 883, 506, 1202, 370, 7908, 21685, 879, 19454, 641, 376, 10427, 14828, 1591, 199, 1023, 63, 3270, 26, 499, 14, 16, 199, 2502, 26, 298, 50, 527, 23235, 5773, 30904, 8593, 2037, 78, 4492, 917, 67, 2924, 199, 5983, 26, 272, 446, 30568, 641, 373, 22385, 959, 14, 21, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 22, 2, 272, 446, 1611, 54, 28603, 199, 1419, 26, 272, 4350, 63, 2580, 26, 267, 1369, 26, 288, 446, 1487, 5381, 4350, 11134, 267, 1415, 26, 756, 199, 11036, 63, 9970, 63, 7677, 26, 19365, 14, 9970, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 5679, 1414, 687, 2622, 16527, 2706, 199, 199, 13, 536, 26, 15453, 27391, 21685, 879, 16454, 523, 7057, 26, 12287, 63, 932, 523, 13082, 63, 5047, 26, 756, 523, 3762, 26, 272, 446, 8118, 290, 523, 6527, 26, 272, 446, 536, 26, 15453, 21685, 879, 641, 1642, 1591, 489, 19365, 63, 3122, 290, 63, 4201, 26, 268, 6246, 26, 7370, 4652, 459, 397, 6865, 3488, 16, 61, 7820, 268, 3434, 26, 7370, 9455, 6865, 63, 2473, 7820, 268, 2505, 26, 7370, 4770, 63, 2060, 7820, 489, 2274, 26, 8118, 290, 63, 4201, 339, 446, 536, 26, 15453, 21685, 879, 641, 7971, 7057, 489, 19365, 63, 3122, 290, 63, 4201, 26, 268, 6246, 26, 7370, 1242, 7820, 268, 3434, 26, 7370, 9455, 6865, 63, 2473, 7820, 268, 2505, 26, 7370, 4770, 63, 2060, 7820, 268, 4350, 63, 2580, 26, 7370, 8118, 290, 63, 4201, 14, 4201, 63, 2580, 7820, 489, 543, 63, 1744, 26, 7370, 4652, 459, 397, 6865, 3488, 17, 2938, 7820, 199, 199, 2344, 199, 199, 893, 26, 272, 687, 1134, 54, 28603, 492, 6695, 12, 373, 1494, 76, 272, 7509, 63, 4521, 54, 2679, 10709, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 4521, 54, 2679, 10709, 275, 756, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 18970, 492, 334, 13533, 63, 4521, 54, 2679, 10709, 12, 4907, 63, 475, 63, 1246, 12, 664, 63, 452, 63, 8718, 12, 19365, 63, 2094, 63, 1650, 12, 1460, 3618, 63, 509, 63, 1765, 9, 421, 199, 318, 1218, 63, 3122, 290, 63, 4201, 8, 1102, 63, 2253, 12, 892, 63, 4201, 63, 2580, 304, 272, 1591, 63, 888, 63, 2609, 275, 1591, 63, 2253, 14, 888, 2988, 272, 8118, 290, 63, 2253, 275, 1591, 63, 888, 63, 2609, 14, 3122, 290, 3989, 339, 8118, 290, 63, 888, 275, 6695, 14, 3122, 290, 14, 1102, 14, 2028, 2354, 342, 272, 8118, 290, 63, 888, 14, 3827, 275, 715, 339, 340, 892, 63, 4201, 63, 2580, 365, 440, 488, 26, 267, 8118, 290, 63, 888, 14, 4201, 2354, 275, 6695, 14, 3122, 290, 14, 1102, 14, 2028, 2354, 14, 9581, 2354, 342, 267, 8118, 290, 63, 888, 14, 4201, 2354, 14, 2580, 275, 892, 63, 4201, 63, 2580, 339, 8118, 290, 63, 888, 14, 3494, 2354, 275, 6695, 14, 3122, 290, 14, 1102, 14, 2028, 2354, 14, 6408, 2354, 342, 272, 8118, 290, 63, 888, 14, 3494, 2354, 14, 2495, 12086, 1017, 6408, 275, 715, 339, 2120, 275, 8118, 290, 63, 2253, 14, 4152, 54, 18904, 63, 4476, 8, 3122, 290, 63, 888, 9, 272, 2896, 12, 754, 275, 3618, 63, 509, 63, 1765, 8, 1765, 9, 339, 1591, 63, 1205, 275, 8118, 290, 63, 2253, 14, 3227, 4965, 3694, 342, 272, 4350, 63, 2580, 275, 1591, 63, 1205, 14, 2580, 339, 372, 2896, 12, 754, 12, 4350, 63, 2580, 421, 199, 318, 2446, 837, 339, 1423, 63, 1650, 275, 19365, 63, 2094, 63, 1650, 342, 272, 1423, 63, 1650, 14, 873, 8, 807, 8, 4201, 63, 2580, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 7058, 339, 859, 275, 6953, 8, 2094, 63, 1650, 29, 2094, 63, 1650, 12, 5171, 63, 1074, 63, 632, 29, 797, 9, 339, 340, 440, 7509, 63, 4521, 54, 2679, 10709, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 647, 86, 28603, 365, 1415, 367, 642, 859, 358, 339, 892, 63, 4201, 63, 2580, 275, 859, 14, 1162, 459, 4201, 63, 2580, 418, 339, 862, 26, 267, 1564, 275, 4907, 63, 475, 63, 1246, 8, 578, 12, 756, 9, 267, 1591, 275, 664, 63, 452, 63, 8718, 8, 1317, 12, 359, 16361, 14, 4965, 3989, 566, 267, 340, 440, 1591, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 628, 6005, 370, 16592, 24309, 7476, 10891, 2685, 267, 1591, 63, 2253, 275, 1591, 14, 1612, 3430, 16, 61, 267, 2896, 12, 754, 12, 4350, 63, 2580, 275, 1218, 63, 3122, 290, 63, 4201, 8, 1102, 63, 2253, 12, 892, 63, 4201, 63, 2580, 9, 267, 859, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 12, 754, 29, 1099, 12, 4350, 63, 2580, 29, 4201, 63, 2580, 9, 339, 871, 373, 1494, 76, 14, 14357, 16665, 465, 8836, 63, 1879, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 29, 7726, 63, 1879, 14, 1328, 9, 272, 871, 373, 1494, 76, 14, 3767, 16665, 465, 1083, 63, 1879, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 29, 765, 63, 1879, 14, 1328, 9, 272, 871 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6900, 12, 820, 527, 23235, 5773, 30904, 665, 82, 266, 30904, 18, 6248, 28308, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 19365, 63, 3122, 290, 63, 4201, 199, 3612, 63, 1802, 26, 15453, 21685, 879, 19454, 641, 376, 10427, 14828, 1591, 199, 1802, 26, 272, 446, 961, 859, 883, 506, 1202, 370, 7908, 21685, 879, 19454, 641, 376, 10427, 14828, 1591, 199, 1023, 63, 3270, 26, 499, 14, 16, 199, 2502, 26, 298, 50, 527, 23235, 5773, 30904, 8593, 2037, 78, 4492, 917, 67, 2924, 199, 5983, 26, 272, 446, 30568, 641, 373, 22385, 959, 14, 21, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 22, 2, 272, 446, 1611, 54, 28603, 199, 1419, 26, 272, 4350, 63, 2580, 26, 267, 1369, 26, 288, 446, 1487, 5381, 4350, 11134, 267, 1415, 26, 756, 199, 11036, 63, 9970, 63, 7677, 26, 19365, 14, 9970, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 5679, 1414, 687, 2622, 16527, 2706, 199, 199, 13, 536, 26, 15453, 27391, 21685, 879, 16454, 523, 7057, 26, 12287, 63, 932, 523, 13082, 63, 5047, 26, 756, 523, 3762, 26, 272, 446, 8118, 290, 523, 6527, 26, 272, 446, 536, 26, 15453, 21685, 879, 641, 1642, 1591, 489, 19365, 63, 3122, 290, 63, 4201, 26, 268, 6246, 26, 7370, 4652, 459, 397, 6865, 3488, 16, 61, 7820, 268, 3434, 26, 7370, 9455, 6865, 63, 2473, 7820, 268, 2505, 26, 7370, 4770, 63, 2060, 7820, 489, 2274, 26, 8118, 290, 63, 4201, 339, 446, 536, 26, 15453, 21685, 879, 641, 7971, 7057, 489, 19365, 63, 3122, 290, 63, 4201, 26, 268, 6246, 26, 7370, 1242, 7820, 268, 3434, 26, 7370, 9455, 6865, 63, 2473, 7820, 268, 2505, 26, 7370, 4770, 63, 2060, 7820, 268, 4350, 63, 2580, 26, 7370, 8118, 290, 63, 4201, 14, 4201, 63, 2580, 7820, 489, 543, 63, 1744, 26, 7370, 4652, 459, 397, 6865, 3488, 17, 2938, 7820, 199, 199, 2344, 199, 199, 893, 26, 272, 687, 1134, 54, 28603, 492, 6695, 12, 373, 1494, 76, 272, 7509, 63, 4521, 54, 2679, 10709, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 4521, 54, 2679, 10709, 275, 756, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 18970, 492, 334, 13533, 63, 4521, 54, 2679, 10709, 12, 4907, 63, 475, 63, 1246, 12, 664, 63, 452, 63, 8718, 12, 19365, 63, 2094, 63, 1650, 12, 1460, 3618, 63, 509, 63, 1765, 9, 421, 199, 318, 1218, 63, 3122, 290, 63, 4201, 8, 1102, 63, 2253, 12, 892, 63, 4201, 63, 2580, 304, 272, 1591, 63, 888, 63, 2609, 275, 1591, 63, 2253, 14, 888, 2988, 272, 8118, 290, 63, 2253, 275, 1591, 63, 888, 63, 2609, 14, 3122, 290, 3989, 339, 8118, 290, 63, 888, 275, 6695, 14, 3122, 290, 14, 1102, 14, 2028, 2354, 342, 272, 8118, 290, 63, 888, 14, 3827, 275, 715, 339, 340, 892, 63, 4201, 63, 2580, 365, 440, 488, 26, 267, 8118, 290, 63, 888, 14, 4201, 2354, 275, 6695, 14, 3122, 290, 14, 1102, 14, 2028, 2354, 14, 9581, 2354, 342, 267, 8118, 290, 63, 888, 14, 4201, 2354, 14, 2580, 275, 892, 63, 4201, 63, 2580, 339, 8118, 290, 63, 888, 14, 3494, 2354, 275, 6695, 14, 3122, 290, 14, 1102, 14, 2028, 2354, 14, 6408, 2354, 342, 272, 8118, 290, 63, 888, 14, 3494, 2354, 14, 2495, 12086, 1017, 6408, 275, 715, 339, 2120, 275, 8118, 290, 63, 2253, 14, 4152, 54, 18904, 63, 4476, 8, 3122, 290, 63, 888, 9, 272, 2896, 12, 754, 275, 3618, 63, 509, 63, 1765, 8, 1765, 9, 339, 1591, 63, 1205, 275, 8118, 290, 63, 2253, 14, 3227, 4965, 3694, 342, 272, 4350, 63, 2580, 275, 1591, 63, 1205, 14, 2580, 339, 372, 2896, 12, 754, 12, 4350, 63, 2580, 421, 199, 318, 2446, 837, 339, 1423, 63, 1650, 275, 19365, 63, 2094, 63, 1650, 342, 272, 1423, 63, 1650, 14, 873, 8, 807, 8, 4201, 63, 2580, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 7058, 339, 859, 275, 6953, 8, 2094, 63, 1650, 29, 2094, 63, 1650, 12, 5171, 63, 1074, 63, 632, 29, 797, 9, 339, 340, 440, 7509, 63, 4521, 54, 2679, 10709, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 647, 86, 28603, 365, 1415, 367, 642, 859, 358, 339, 892, 63, 4201, 63, 2580, 275, 859, 14, 1162, 459, 4201, 63, 2580, 418, 339, 862, 26, 267, 1564, 275, 4907, 63, 475, 63, 1246, 8, 578, 12, 756, 9, 267, 1591, 275, 664, 63, 452, 63, 8718, 8, 1317, 12, 359, 16361, 14, 4965, 3989, 566, 267, 340, 440, 1591, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 628, 6005, 370, 16592, 24309, 7476, 10891, 2685, 267, 1591, 63, 2253, 275, 1591, 14, 1612, 3430, 16, 61, 267, 2896, 12, 754, 12, 4350, 63, 2580, 275, 1218, 63, 3122, 290, 63, 4201, 8, 1102, 63, 2253, 12, 892, 63, 4201, 63, 2580, 9, 267, 859, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 12, 754, 29, 1099, 12, 4350, 63, 2580, 29, 4201, 63, 2580, 9, 339, 871, 373, 1494, 76, 14, 14357, 16665, 465, 8836, 63, 1879, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 29, 7726, 63, 1879, 14, 1328, 9, 272, 871, 373, 1494, 76, 14, 3767, 16665, 465, 1083, 63, 1879, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 29, 765, 63, 1879, 14, 1328, 9, 272, 871, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
fraenkel-lab/pcst_fast
external/googletest/googletest/test/gtest_catch_exceptions_test.py
2139
9901
#!/usr/bin/env python # # Copyright 2010 Google Inc. All Rights Reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Tests Google Test's exception catching behavior. This script invokes gtest_catch_exceptions_test_ and gtest_catch_exceptions_ex_test_ (programs written with Google Test) and verifies their output. """ __author__ = 'vladl@google.com (Vlad Losev)' import os import gtest_test_utils # Constants. FLAG_PREFIX = '--gtest_' LIST_TESTS_FLAG = FLAG_PREFIX + 'list_tests' NO_CATCH_EXCEPTIONS_FLAG = FLAG_PREFIX + 'catch_exceptions=0' FILTER_FLAG = FLAG_PREFIX + 'filter' # Path to the gtest_catch_exceptions_ex_test_ binary, compiled with # exceptions enabled. EX_EXE_PATH = gtest_test_utils.GetTestExecutablePath( 'gtest_catch_exceptions_ex_test_') # Path to the gtest_catch_exceptions_test_ binary, compiled with # exceptions disabled. EXE_PATH = gtest_test_utils.GetTestExecutablePath( 'gtest_catch_exceptions_no_ex_test_') environ = gtest_test_utils.environ SetEnvVar = gtest_test_utils.SetEnvVar # Tests in this file run a Google-Test-based test program and expect it # to terminate prematurely. Therefore they are incompatible with # the premature-exit-file protocol by design. Unset the # premature-exit filepath to prevent Google Test from creating # the file. SetEnvVar(gtest_test_utils.PREMATURE_EXIT_FILE_ENV_VAR, None) TEST_LIST = gtest_test_utils.Subprocess( [EXE_PATH, LIST_TESTS_FLAG], env=environ).output SUPPORTS_SEH_EXCEPTIONS = 'ThrowsSehException' in TEST_LIST if SUPPORTS_SEH_EXCEPTIONS: BINARY_OUTPUT = gtest_test_utils.Subprocess([EXE_PATH], env=environ).output EX_BINARY_OUTPUT = gtest_test_utils.Subprocess( [EX_EXE_PATH], env=environ).output # The tests. if SUPPORTS_SEH_EXCEPTIONS: # pylint:disable-msg=C6302 class CatchSehExceptionsTest(gtest_test_utils.TestCase): """Tests exception-catching behavior.""" def TestSehExceptions(self, test_output): self.assert_('SEH exception with code 0x2a thrown ' 'in the test fixture\'s constructor' in test_output) self.assert_('SEH exception with code 0x2a thrown ' 'in the test fixture\'s destructor' in test_output) self.assert_('SEH exception with code 0x2a thrown in SetUpTestCase()' in test_output) self.assert_('SEH exception with code 0x2a thrown in TearDownTestCase()' in test_output) self.assert_('SEH exception with code 0x2a thrown in SetUp()' in test_output) self.assert_('SEH exception with code 0x2a thrown in TearDown()' in test_output) self.assert_('SEH exception with code 0x2a thrown in the test body' in test_output) def testCatchesSehExceptionsWithCxxExceptionsEnabled(self): self.TestSehExceptions(EX_BINARY_OUTPUT) def testCatchesSehExceptionsWithCxxExceptionsDisabled(self): self.TestSehExceptions(BINARY_OUTPUT) class CatchCxxExceptionsTest(gtest_test_utils.TestCase): """Tests C++ exception-catching behavior. Tests in this test case verify that: * C++ exceptions are caught and logged as C++ (not SEH) exceptions * Exception thrown affect the remainder of the test work flow in the expected manner. """ def testCatchesCxxExceptionsInFixtureConstructor(self): self.assert_('C++ exception with description ' '"Standard C++ exception" thrown ' 'in the test fixture\'s constructor' in EX_BINARY_OUTPUT) self.assert_('unexpected' not in EX_BINARY_OUTPUT, 'This failure belongs in this test only if ' '"CxxExceptionInConstructorTest" (no quotes) ' 'appears on the same line as words "called unexpectedly"') if ('CxxExceptionInDestructorTest.ThrowsExceptionInDestructor' in EX_BINARY_OUTPUT): def testCatchesCxxExceptionsInFixtureDestructor(self): self.assert_('C++ exception with description ' '"Standard C++ exception" thrown ' 'in the test fixture\'s destructor' in EX_BINARY_OUTPUT) self.assert_('CxxExceptionInDestructorTest::TearDownTestCase() ' 'called as expected.' in EX_BINARY_OUTPUT) def testCatchesCxxExceptionsInSetUpTestCase(self): self.assert_('C++ exception with description "Standard C++ exception"' ' thrown in SetUpTestCase()' in EX_BINARY_OUTPUT) self.assert_('CxxExceptionInConstructorTest::TearDownTestCase() ' 'called as expected.' in EX_BINARY_OUTPUT) self.assert_('CxxExceptionInSetUpTestCaseTest constructor ' 'called as expected.' in EX_BINARY_OUTPUT) self.assert_('CxxExceptionInSetUpTestCaseTest destructor ' 'called as expected.' in EX_BINARY_OUTPUT) self.assert_('CxxExceptionInSetUpTestCaseTest::SetUp() ' 'called as expected.' in EX_BINARY_OUTPUT) self.assert_('CxxExceptionInSetUpTestCaseTest::TearDown() ' 'called as expected.' in EX_BINARY_OUTPUT) self.assert_('CxxExceptionInSetUpTestCaseTest test body ' 'called as expected.' in EX_BINARY_OUTPUT) def testCatchesCxxExceptionsInTearDownTestCase(self): self.assert_('C++ exception with description "Standard C++ exception"' ' thrown in TearDownTestCase()' in EX_BINARY_OUTPUT) def testCatchesCxxExceptionsInSetUp(self): self.assert_('C++ exception with description "Standard C++ exception"' ' thrown in SetUp()' in EX_BINARY_OUTPUT) self.assert_('CxxExceptionInSetUpTest::TearDownTestCase() ' 'called as expected.' in EX_BINARY_OUTPUT) self.assert_('CxxExceptionInSetUpTest destructor ' 'called as expected.' in EX_BINARY_OUTPUT) self.assert_('CxxExceptionInSetUpTest::TearDown() ' 'called as expected.' in EX_BINARY_OUTPUT) self.assert_('unexpected' not in EX_BINARY_OUTPUT, 'This failure belongs in this test only if ' '"CxxExceptionInSetUpTest" (no quotes) ' 'appears on the same line as words "called unexpectedly"') def testCatchesCxxExceptionsInTearDown(self): self.assert_('C++ exception with description "Standard C++ exception"' ' thrown in TearDown()' in EX_BINARY_OUTPUT) self.assert_('CxxExceptionInTearDownTest::TearDownTestCase() ' 'called as expected.' in EX_BINARY_OUTPUT) self.assert_('CxxExceptionInTearDownTest destructor ' 'called as expected.' in EX_BINARY_OUTPUT) def testCatchesCxxExceptionsInTestBody(self): self.assert_('C++ exception with description "Standard C++ exception"' ' thrown in the test body' in EX_BINARY_OUTPUT) self.assert_('CxxExceptionInTestBodyTest::TearDownTestCase() ' 'called as expected.' in EX_BINARY_OUTPUT) self.assert_('CxxExceptionInTestBodyTest destructor ' 'called as expected.' in EX_BINARY_OUTPUT) self.assert_('CxxExceptionInTestBodyTest::TearDown() ' 'called as expected.' in EX_BINARY_OUTPUT) def testCatchesNonStdCxxExceptions(self): self.assert_('Unknown C++ exception thrown in the test body' in EX_BINARY_OUTPUT) def testUnhandledCxxExceptionsAbortTheProgram(self): # Filters out SEH exception tests on Windows. Unhandled SEH exceptions # cause tests to show pop-up windows there. FITLER_OUT_SEH_TESTS_FLAG = FILTER_FLAG + '=-*Seh*' # By default, Google Test doesn't catch the exceptions. uncaught_exceptions_ex_binary_output = gtest_test_utils.Subprocess( [EX_EXE_PATH, NO_CATCH_EXCEPTIONS_FLAG, FITLER_OUT_SEH_TESTS_FLAG], env=environ).output self.assert_('Unhandled C++ exception terminating the program' in uncaught_exceptions_ex_binary_output) self.assert_('unexpected' not in uncaught_exceptions_ex_binary_output) if __name__ == '__main__': gtest_test_utils.Main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 7129, 4475, 3277, 14, 221, 2900, 5924, 5702, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 2925, 4475, 1379, 1159, 1919, 8579, 316, 5953, 14, 199, 199, 2765, 2884, 29761, 9088, 63, 9341, 63, 3924, 63, 396, 63, 436, 199, 8385, 63, 9341, 63, 3924, 63, 476, 63, 396, 63, 334, 28464, 5313, 543, 199, 13266, 1379, 9, 436, 22694, 3932, 1072, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 7300, 350, 76, 32, 3098, 14, 957, 334, 54, 76, 350, 491, 3362, 86, 3171, 199, 199, 646, 747, 199, 199, 646, 9088, 63, 396, 63, 1208, 199, 199, 3, 22296, 14, 199, 3719, 63, 6351, 275, 2850, 8385, 8650, 199, 4924, 63, 7569, 63, 3719, 275, 11031, 63, 6351, 435, 283, 513, 63, 2219, 7, 199, 2826, 63, 35, 8078, 63, 25054, 63, 3719, 275, 11031, 63, 6351, 435, 283, 9341, 63, 3924, 29, 16, 7, 199, 9905, 63, 3719, 275, 11031, 63, 6351, 435, 283, 1541, 7, 199, 199, 3, 6912, 370, 314, 9088, 63, 9341, 63, 3924, 63, 476, 63, 396, 63, 3366, 12, 10311, 543, 199, 3, 4967, 5223, 14, 199, 1438, 63, 23017, 63, 3243, 275, 9088, 63, 396, 63, 1208, 14, 28967, 27602, 8, 272, 283, 8385, 63, 9341, 63, 3924, 63, 476, 63, 396, 15452, 199, 199, 3, 6912, 370, 314, 9088, 63, 9341, 63, 3924, 63, 396, 63, 3366, 12, 10311, 543, 199, 3, 4967, 6980, 14, 199, 23017, 63, 3243, 275, 9088, 63, 396, 63, 1208, 14, 28967, 27602, 8, 272, 283, 8385, 63, 9341, 63, 3924, 63, 889, 63, 476, 63, 396, 15452, 199, 199, 2314, 275, 9088, 63, 396, 63, 1208, 14, 2314, 199, 1084, 19342, 275, 9088, 63, 396, 63, 1208, 14, 1084, 19342, 199, 199, 3, 6496, 315, 642, 570, 1255, 282, 4475, 13, 774, 13, 6788, 511, 2240, 436, 4282, 652, 199, 3, 370, 15095, 876, 19925, 590, 14, 221, 21039, 2985, 787, 18457, 543, 199, 3, 314, 876, 19925, 13, 2224, 13, 493, 4113, 701, 12899, 14, 221, 1910, 409, 314, 199, 3, 876, 19925, 13, 2224, 9911, 370, 7981, 4475, 1379, 687, 6425, 199, 3, 314, 570, 14, 199, 1084, 19342, 8, 8385, 63, 396, 63, 1208, 14, 4225, 45, 13214, 63, 17219, 63, 3817, 63, 9984, 63, 5568, 12, 488, 9, 199, 199, 2864, 63, 4924, 275, 9088, 63, 396, 63, 1208, 14, 22299, 8, 272, 359, 23017, 63, 3243, 12, 21716, 63, 7569, 63, 3719, 467, 2589, 29, 2314, 680, 1199, 199, 199, 10640, 51, 63, 899, 40, 63, 25054, 275, 283, 2719, 3838, 1513, 72, 1726, 7, 315, 7393, 63, 4924, 199, 199, 692, 13756, 51, 63, 899, 40, 63, 25054, 26, 523, 32698, 63, 8414, 275, 9088, 63, 396, 63, 1208, 14, 22299, 779, 23017, 63, 3243, 467, 2589, 29, 2314, 680, 1199, 199, 199, 1438, 63, 13246, 63, 8414, 275, 9088, 63, 396, 63, 1208, 14, 22299, 8, 272, 359, 1438, 63, 23017, 63, 3243, 467, 2589, 29, 2314, 680, 1199, 421, 199, 3, 710, 2295, 14, 199, 692, 13756, 51, 63, 899, 40, 63, 25054, 26, 523, 327, 4287, 26, 5993, 13, 1328, 29, 35, 2766, 996, 523, 1021, 32754, 1513, 72, 16836, 774, 8, 8385, 63, 396, 63, 1208, 14, 1746, 304, 272, 408, 2925, 1919, 13, 9341, 316, 5953, 1041, 2378, 347, 1379, 1513, 72, 16836, 8, 277, 12, 511, 63, 1199, 304, 489, 291, 14, 479, 11252, 899, 40, 1919, 543, 1233, 378, 88, 18, 65, 14031, 283, 673, 283, 262, 314, 511, 10949, 3985, 83, 3787, 7, 673, 315, 511, 63, 1199, 9, 489, 291, 14, 479, 11252, 899, 40, 1919, 543, 1233, 378, 88, 18, 65, 14031, 283, 673, 283, 262, 314, 511, 10949, 3985, 83, 32133, 7, 673, 315, 511, 63, 1199, 9, 489, 291, 14, 479, 11252, 899, 40, 1919, 543, 1233, 378, 88, 18, 65, 14031, 315, 2494, 1721, 1746, 11716, 673, 315, 511, 63, 1199, 9, 489, 291, 14, 479, 11252, 899, 40, 1919, 543, 1233, 378, 88, 18, 65, 14031, 315, 377, 25236, 1746, 11716, 673, 315, 511, 63, 1199, 9, 489, 291, 14, 479, 11252, 899, 40, 1919, 543, 1233, 378, 88, 18, 65, 14031, 315, 2494, 1721, 11716, 673, 315, 511, 63, 1199, 9, 489, 291, 14, 479, 11252, 899, 40, 1919, 543 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 7129, 4475, 3277, 14, 221, 2900, 5924, 5702, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 2925, 4475, 1379, 1159, 1919, 8579, 316, 5953, 14, 199, 199, 2765, 2884, 29761, 9088, 63, 9341, 63, 3924, 63, 396, 63, 436, 199, 8385, 63, 9341, 63, 3924, 63, 476, 63, 396, 63, 334, 28464, 5313, 543, 199, 13266, 1379, 9, 436, 22694, 3932, 1072, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 7300, 350, 76, 32, 3098, 14, 957, 334, 54, 76, 350, 491, 3362, 86, 3171, 199, 199, 646, 747, 199, 199, 646, 9088, 63, 396, 63, 1208, 199, 199, 3, 22296, 14, 199, 3719, 63, 6351, 275, 2850, 8385, 8650, 199, 4924, 63, 7569, 63, 3719, 275, 11031, 63, 6351, 435, 283, 513, 63, 2219, 7, 199, 2826, 63, 35, 8078, 63, 25054, 63, 3719, 275, 11031, 63, 6351, 435, 283, 9341, 63, 3924, 29, 16, 7, 199, 9905, 63, 3719, 275, 11031, 63, 6351, 435, 283, 1541, 7, 199, 199, 3, 6912, 370, 314, 9088, 63, 9341, 63, 3924, 63, 476, 63, 396, 63, 3366, 12, 10311, 543, 199, 3, 4967, 5223, 14, 199, 1438, 63, 23017, 63, 3243, 275, 9088, 63, 396, 63, 1208, 14, 28967, 27602, 8, 272, 283, 8385, 63, 9341, 63, 3924, 63, 476, 63, 396, 15452, 199, 199, 3, 6912, 370, 314, 9088, 63, 9341, 63, 3924, 63, 396, 63, 3366, 12, 10311, 543, 199, 3, 4967, 6980, 14, 199, 23017, 63, 3243, 275, 9088, 63, 396, 63, 1208, 14, 28967, 27602, 8, 272, 283, 8385, 63, 9341, 63, 3924, 63, 889, 63, 476, 63, 396, 15452, 199, 199, 2314, 275, 9088, 63, 396, 63, 1208, 14, 2314, 199, 1084, 19342, 275, 9088, 63, 396, 63, 1208, 14, 1084, 19342, 199, 199, 3, 6496, 315, 642, 570, 1255, 282, 4475, 13, 774, 13, 6788, 511, 2240, 436, 4282, 652, 199, 3, 370, 15095, 876, 19925, 590, 14, 221, 21039, 2985, 787, 18457, 543, 199, 3, 314, 876, 19925, 13, 2224, 13, 493, 4113, 701, 12899, 14, 221, 1910, 409, 314, 199, 3, 876, 19925, 13, 2224, 9911, 370, 7981, 4475, 1379, 687, 6425, 199, 3, 314, 570, 14, 199, 1084, 19342, 8, 8385, 63, 396, 63, 1208, 14, 4225, 45, 13214, 63, 17219, 63, 3817, 63, 9984, 63, 5568, 12, 488, 9, 199, 199, 2864, 63, 4924, 275, 9088, 63, 396, 63, 1208, 14, 22299, 8, 272, 359, 23017, 63, 3243, 12, 21716, 63, 7569, 63, 3719, 467, 2589, 29, 2314, 680, 1199, 199, 199, 10640, 51, 63, 899, 40, 63, 25054, 275, 283, 2719, 3838, 1513, 72, 1726, 7, 315, 7393, 63, 4924, 199, 199, 692, 13756, 51, 63, 899, 40, 63, 25054, 26, 523, 32698, 63, 8414, 275, 9088, 63, 396, 63, 1208, 14, 22299, 779, 23017, 63, 3243, 467, 2589, 29, 2314, 680, 1199, 199, 199, 1438, 63, 13246, 63, 8414, 275, 9088, 63, 396, 63, 1208, 14, 22299, 8, 272, 359, 1438, 63, 23017, 63, 3243, 467, 2589, 29, 2314, 680, 1199, 421, 199, 3, 710, 2295, 14, 199, 692, 13756, 51, 63, 899, 40, 63, 25054, 26, 523, 327, 4287, 26, 5993, 13, 1328, 29, 35, 2766, 996, 523, 1021, 32754, 1513, 72, 16836, 774, 8, 8385, 63, 396, 63, 1208, 14, 1746, 304, 272, 408, 2925, 1919, 13, 9341, 316, 5953, 1041, 2378, 347, 1379, 1513, 72, 16836, 8, 277, 12, 511, 63, 1199, 304, 489, 291, 14, 479, 11252, 899, 40, 1919, 543, 1233, 378, 88, 18, 65, 14031, 283, 673, 283, 262, 314, 511, 10949, 3985, 83, 3787, 7, 673, 315, 511, 63, 1199, 9, 489, 291, 14, 479, 11252, 899, 40, 1919, 543, 1233, 378, 88, 18, 65, 14031, 283, 673, 283, 262, 314, 511, 10949, 3985, 83, 32133, 7, 673, 315, 511, 63, 1199, 9, 489, 291, 14, 479, 11252, 899, 40, 1919, 543, 1233, 378, 88, 18, 65, 14031, 315, 2494, 1721, 1746, 11716, 673, 315, 511, 63, 1199, 9, 489, 291, 14, 479, 11252, 899, 40, 1919, 543, 1233, 378, 88, 18, 65, 14031, 315, 377, 25236, 1746, 11716, 673, 315, 511, 63, 1199, 9, 489, 291, 14, 479, 11252, 899, 40, 1919, 543, 1233, 378, 88, 18, 65, 14031, 315, 2494, 1721, 11716, 673, 315, 511, 63, 1199, 9, 489, 291, 14, 479, 11252, 899, 40, 1919, 543, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
inflrscns/django-wiki
wiki/plugins/attachments/south_migrations/0001_initial.py
16
12492
# -*- coding: utf-8 -*- from south.utils import datetime_utils as 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 'Attachment' db.create_table(u'wiki_attachments_attachment', ( (u'reusableplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['wiki.ReusablePlugin'], unique=True, primary_key=True)), ('current_revision', self.gf('django.db.models.fields.related.OneToOneField')(blank=True, related_name=u'current_set', unique=True, null=True, to=orm['attachments.AttachmentRevision'])), ('original_filename', self.gf('django.db.models.fields.CharField')(max_length=256, null=True, blank=True)), )) db.send_create_signal(u'attachments', ['Attachment']) # Adding model 'AttachmentRevision' db.create_table(u'wiki_attachments_attachmentrevision', ( (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('revision_number', self.gf('django.db.models.fields.IntegerField')()), ('user_message', self.gf('django.db.models.fields.TextField')(blank=True)), ('automatic_log', self.gf('django.db.models.fields.TextField')(blank=True)), ('ip_address', self.gf('django.db.models.fields.IPAddressField')(max_length=15, null=True, blank=True)), ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True, on_delete=models.SET_NULL, blank=True)), ('modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)), ('created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), ('previous_revision', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['attachments.AttachmentRevision'], null=True, on_delete=models.SET_NULL, blank=True)), ('deleted', self.gf('django.db.models.fields.BooleanField')(default=False)), ('locked', self.gf('django.db.models.fields.BooleanField')(default=False)), ('attachment', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['attachments.Attachment'])), ('file', self.gf('django.db.models.fields.files.FileField')(max_length=255)), ('description', self.gf('django.db.models.fields.TextField')(blank=True)), )) db.send_create_signal(u'attachments', ['AttachmentRevision']) def backwards(self, orm): # Deleting model 'Attachment' db.delete_table(u'wiki_attachments_attachment') # Deleting model 'AttachmentRevision' db.delete_table(u'wiki_attachments_attachmentrevision') models = { u'attachments.attachment': { 'Meta': {'object_name': 'Attachment', 'db_table': "u'wiki_attachments_attachment'", '_ormbases': [u'wiki.ReusablePlugin']}, 'current_revision': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "u'current_set'", 'unique': 'True', 'null': 'True', 'to': u"orm['attachments.AttachmentRevision']"}), 'original_filename': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}), u'reusableplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['wiki.ReusablePlugin']", 'unique': 'True', 'primary_key': 'True'}) }, u'attachments.attachmentrevision': { 'Meta': {'ordering': "(u'created',)", 'object_name': 'AttachmentRevision', 'db_table': "u'wiki_attachments_attachmentrevision'"}, 'attachment': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['attachments.Attachment']"}), 'automatic_log': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ip_address': ('django.db.models.fields.IPAddressField', [], {'max_length': '15', 'null': 'True', 'blank': 'True'}), 'locked': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'previous_revision': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['attachments.AttachmentRevision']", 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': 'True'}), 'revision_number': ('django.db.models.fields.IntegerField', [], {}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': 'True'}), 'user_message': ('django.db.models.fields.TextField', [], {'blank': 'True'}) }, u'auth.group': { 'Meta': {'object_name': 'Group'}, u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, u'auth.permission': { 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, u'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', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}), u'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', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, u'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'}), u'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'}) }, u'wiki.article': { 'Meta': {'object_name': 'Article'}, 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'current_revision': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "u'current_set'", 'unique': 'True', 'null': 'True', 'to': u"orm['wiki.ArticleRevision']"}), 'group': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.Group']", 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': 'True'}), 'group_read': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'group_write': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'other_read': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'other_write': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "u'owned_articles'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': u"orm['auth.User']"}) }, u'wiki.articleplugin': { 'Meta': {'object_name': 'ArticlePlugin'}, 'article': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['wiki.Article']"}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) }, u'wiki.articlerevision': { 'Meta': {'ordering': "(u'created',)", 'unique_together': "((u'article', u'revision_number'),)", 'object_name': 'ArticleRevision'}, 'article': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['wiki.Article']"}), 'automatic_log': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'content': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ip_address': ('django.db.models.fields.IPAddressField', [], {'max_length': '15', 'null': 'True', 'blank': 'True'}), 'locked': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'previous_revision': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['wiki.ArticleRevision']", 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': 'True'}), 'revision_number': ('django.db.models.fields.IntegerField', [], {}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '512'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': 'True'}), 'user_message': ('django.db.models.fields.TextField', [], {'blank': 'True'}) }, u'wiki.reusableplugin': { 'Meta': {'object_name': 'ReusablePlugin', '_ormbases': [u'wiki.ArticlePlugin']}, u'articleplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['wiki.ArticlePlugin']", 'unique': 'True', 'primary_key': 'True'}), 'articles': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "u'shared_plugins_set'", 'symmetrical': 'False', 'to': u"orm['wiki.Article']"}) } } complete_apps = ['attachments']
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 12919, 14, 1208, 492, 2197, 63, 1208, 465, 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, 22662, 7, 267, 1592, 14, 981, 63, 1224, 8, 85, 7, 6797, 63, 15855, 63, 8905, 297, 334, 288, 334, 85, 3984, 14418, 2718, 63, 4695, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 7533, 475, 29, 1025, 459, 6797, 14, 497, 14418, 5061, 995, 3747, 29, 549, 12, 5062, 63, 498, 29, 549, 1826, 288, 661, 1818, 63, 5792, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 7533, 2500, 29, 549, 12, 4048, 63, 354, 29, 85, 7, 1818, 63, 409, 297, 3747, 29, 549, 12, 2973, 29, 549, 12, 370, 29, 1025, 459, 15855, 14, 22662, 12714, 16607, 288, 661, 5043, 63, 1501, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 3912, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 8, 85, 7, 15855, 297, 788, 22662, 1105, 398, 327, 12934, 1402, 283, 22662, 12714, 7, 267, 1592, 14, 981, 63, 1224, 8, 85, 7, 6797, 63, 15855, 63, 8905, 5792, 297, 334, 288, 334, 85, 7, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 5792, 63, 1955, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 358, 4000, 288, 661, 751, 63, 1188, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2500, 29, 549, 1826, 288, 661, 23292, 63, 793, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2500, 29, 549, 1826, 288, 661, 711, 63, 1562, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 26969, 7533, 988, 63, 1267, 29, 1046, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 751, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1178, 14, 1899, 995, 2973, 29, 549, 12, 641, 63, 1807, 29, 992, 14, 3597, 63, 8084, 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, 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, 6352, 63, 5792, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 15855, 14, 22662, 12714, 995, 2973, 29, 549, 12, 641, 63, 1807, 29, 992, 14, 3597, 63, 8084, 12, 4596, 29, 549, 1826, 288, 661, 6062, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 7533, 885, 29, 797, 1826, 288, 661, 9325, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 7533, 885, 29, 797, 1826, 288, 661, 8905, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 15855, 14, 22662, 16607, 288, 661, 493, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 1725, 14, 23252, 7533, 988, 63, 1267, 29, 2299, 1826, 288, 661, 1802, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2500, 29, 549, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 8, 85, 7, 15855, 297, 788, 22662, 12714, 1105, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 1402, 283, 22662, 7, 267, 1592, 14, 1807, 63, 1224, 8, 85, 7, 6797, 63, 15855, 63, 8905, 358, 398, 327, 15920, 1402, 283, 22662, 12714, 7, 267, 1592, 14, 1807, 63, 1224, 8, 85, 7, 6797, 63, 15855, 63, 8905, 5792, 358, 2378, 1709, 275, 469, 267, 399, 7, 15855, 14, 8905, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 22662, 297, 283, 697, 63, 1224, 356, 298, 85, 7, 6797, 63, 15855, 63, 8905, 4662, 2513, 31525, 356, 359, 85, 7, 6797, 14, 497, 14418, 5061, 14949, 288, 283, 1818, 63, 5792, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 297, 990, 791, 2500, 356, 283, 549, 297, 283, 2407, 63, 354, 356, 298, 85, 7, 1818, 63, 409, 4662, 283, 3235, 356, 283, 549, 297, 283, 2307, 356, 283, 549, 297, 283, 475, 356, 399, 2, 1025, 459, 15855, 14, 22662, 12714, 6097, 288, 283, 5043, 63, 1501, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3912, 297, 283, 2307, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 399, 3984, 14418, 2718, 63, 4695, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 6797, 14, 497, 14418, 5061, 6256, 283, 3235, 356, 283, 549, 297, 283, 3327, 63, 498, 356, 283, 549, 3071, 267, 1660, 267, 399, 7, 15855, 14, 8905, 5792, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 7340, 85, 7, 3966, 21099, 283, 785, 63, 354, 356, 283, 22662, 12714, 297, 283, 697, 63, 1224, 356, 298, 85, 7, 6797, 63, 15855, 63, 8905, 5792, 15208, 288, 283, 8905, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 15855, 14, 22662, 6097, 288, 283, 23292, 63, 793, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2500 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 12919, 14, 1208, 492, 2197, 63, 1208, 465, 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, 22662, 7, 267, 1592, 14, 981, 63, 1224, 8, 85, 7, 6797, 63, 15855, 63, 8905, 297, 334, 288, 334, 85, 3984, 14418, 2718, 63, 4695, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 7533, 475, 29, 1025, 459, 6797, 14, 497, 14418, 5061, 995, 3747, 29, 549, 12, 5062, 63, 498, 29, 549, 1826, 288, 661, 1818, 63, 5792, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 7533, 2500, 29, 549, 12, 4048, 63, 354, 29, 85, 7, 1818, 63, 409, 297, 3747, 29, 549, 12, 2973, 29, 549, 12, 370, 29, 1025, 459, 15855, 14, 22662, 12714, 16607, 288, 661, 5043, 63, 1501, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 3912, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 8, 85, 7, 15855, 297, 788, 22662, 1105, 398, 327, 12934, 1402, 283, 22662, 12714, 7, 267, 1592, 14, 981, 63, 1224, 8, 85, 7, 6797, 63, 15855, 63, 8905, 5792, 297, 334, 288, 334, 85, 7, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 5792, 63, 1955, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 358, 4000, 288, 661, 751, 63, 1188, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2500, 29, 549, 1826, 288, 661, 23292, 63, 793, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2500, 29, 549, 1826, 288, 661, 711, 63, 1562, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 26969, 7533, 988, 63, 1267, 29, 1046, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 751, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1178, 14, 1899, 995, 2973, 29, 549, 12, 641, 63, 1807, 29, 992, 14, 3597, 63, 8084, 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, 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, 6352, 63, 5792, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 15855, 14, 22662, 12714, 995, 2973, 29, 549, 12, 641, 63, 1807, 29, 992, 14, 3597, 63, 8084, 12, 4596, 29, 549, 1826, 288, 661, 6062, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 7533, 885, 29, 797, 1826, 288, 661, 9325, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 7533, 885, 29, 797, 1826, 288, 661, 8905, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 15855, 14, 22662, 16607, 288, 661, 493, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 1725, 14, 23252, 7533, 988, 63, 1267, 29, 2299, 1826, 288, 661, 1802, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2500, 29, 549, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 8, 85, 7, 15855, 297, 788, 22662, 12714, 1105, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 1402, 283, 22662, 7, 267, 1592, 14, 1807, 63, 1224, 8, 85, 7, 6797, 63, 15855, 63, 8905, 358, 398, 327, 15920, 1402, 283, 22662, 12714, 7, 267, 1592, 14, 1807, 63, 1224, 8, 85, 7, 6797, 63, 15855, 63, 8905, 5792, 358, 2378, 1709, 275, 469, 267, 399, 7, 15855, 14, 8905, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 22662, 297, 283, 697, 63, 1224, 356, 298, 85, 7, 6797, 63, 15855, 63, 8905, 4662, 2513, 31525, 356, 359, 85, 7, 6797, 14, 497, 14418, 5061, 14949, 288, 283, 1818, 63, 5792, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 297, 990, 791, 2500, 356, 283, 549, 297, 283, 2407, 63, 354, 356, 298, 85, 7, 1818, 63, 409, 4662, 283, 3235, 356, 283, 549, 297, 283, 2307, 356, 283, 549, 297, 283, 475, 356, 399, 2, 1025, 459, 15855, 14, 22662, 12714, 6097, 288, 283, 5043, 63, 1501, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3912, 297, 283, 2307, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 399, 3984, 14418, 2718, 63, 4695, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 6797, 14, 497, 14418, 5061, 6256, 283, 3235, 356, 283, 549, 297, 283, 3327, 63, 498, 356, 283, 549, 3071, 267, 1660, 267, 399, 7, 15855, 14, 8905, 5792, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 7340, 85, 7, 3966, 21099, 283, 785, 63, 354, 356, 283, 22662, 12714, 297, 283, 697, 63, 1224, 356, 298, 85, 7, 6797, 63, 15855, 63, 8905, 5792, 15208, 288, 283, 8905, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 15855, 14, 22662, 6097, 288, 283, 23292, 63, 793, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2500, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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
""" Copyright 2011 Jeff Garzik AuthServiceProxy has the following improvements over python-jsonrpc's ServiceProxy class: - HTTP connections persist for the life of the AuthServiceProxy object (if server supports HTTP/1.1) - sends protocol 'version', per JSON-RPC 1.1 - sends proper, incrementing 'id' - sends Basic HTTP authentication headers - parses all JSON numbers that look like floats as Decimal - uses standard Python json lib Previous copyright, from python-jsonrpc/jsonrpc/proxy.py: Copyright (c) 2007 Jan-Klaas Kollhof This file is part of jsonrpc. jsonrpc 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 software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this software; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ try: import http.client as httplib except ImportError: import httplib import base64 import decimal import json import logging try: import urllib.parse as urlparse except ImportError: import urlparse USER_AGENT = "AuthServiceProxy/0.1" HTTP_TIMEOUT = 30 log = logging.getLogger("BitcoinRPC") class JSONRPCException(Exception): def __init__(self, rpc_error): Exception.__init__(self) self.error = rpc_error def EncodeDecimal(o): if isinstance(o, decimal.Decimal): return round(o, 8) raise TypeError(repr(o) + " is not JSON serializable") class AuthServiceProxy(object): __id_count = 0 def __init__(self, service_url, service_name=None, timeout=HTTP_TIMEOUT, connection=None): self.__service_url = service_url self.__service_name = service_name self.__url = urlparse.urlparse(service_url) if self.__url.port is None: port = 80 else: port = self.__url.port (user, passwd) = (self.__url.username, self.__url.password) try: user = user.encode('utf8') except AttributeError: pass try: passwd = passwd.encode('utf8') except AttributeError: pass authpair = user + b':' + passwd self.__auth_header = b'Basic ' + base64.b64encode(authpair) if connection: # Callables re-use the connection of the original proxy self.__conn = connection elif self.__url.scheme == 'https': self.__conn = httplib.HTTPSConnection(self.__url.hostname, port, None, None, False, timeout) else: self.__conn = httplib.HTTPConnection(self.__url.hostname, port, False, timeout) def __getattr__(self, name): if name.startswith('__') and name.endswith('__'): # Python internal stuff raise AttributeError if self.__service_name is not None: name = "%s.%s" % (self.__service_name, name) return AuthServiceProxy(self.__service_url, name, connection=self.__conn) def __call__(self, *args): AuthServiceProxy.__id_count += 1 log.debug("-%s-> %s %s"%(AuthServiceProxy.__id_count, self.__service_name, json.dumps(args, default=EncodeDecimal))) postdata = json.dumps({'version': '1.1', 'method': self.__service_name, 'params': args, 'id': AuthServiceProxy.__id_count}, default=EncodeDecimal) self.__conn.request('POST', self.__url.path, postdata, {'Host': self.__url.hostname, 'User-Agent': USER_AGENT, 'Authorization': self.__auth_header, 'Content-type': 'application/json'}) response = self._get_response() if response['error'] is not None: raise JSONRPCException(response['error']) elif 'result' not in response: raise JSONRPCException({ 'code': -343, 'message': 'missing JSON-RPC result'}) else: return response['result'] def _batch(self, rpc_call_list): postdata = json.dumps(list(rpc_call_list), default=EncodeDecimal) log.debug("--> "+postdata) self.__conn.request('POST', self.__url.path, postdata, {'Host': self.__url.hostname, 'User-Agent': USER_AGENT, 'Authorization': self.__auth_header, 'Content-type': 'application/json'}) return self._get_response() def _get_response(self): http_response = self.__conn.getresponse() if http_response is None: raise JSONRPCException({ 'code': -342, 'message': 'missing HTTP response from server'}) responsedata = http_response.read().decode('utf8') response = json.loads(responsedata, parse_float=decimal.Decimal) if "error" in response and response["error"] is None: log.debug("<-%s- %s"%(response["id"], json.dumps(response["result"], default=EncodeDecimal))) else: log.debug("<-- "+responsedata) return response
mit
[ 199, 624, 523, 1898, 7760, 1603, 3609, 598, 285, 90, 3258, 819, 3590, 3167, 4936, 965, 314, 2569, 19053, 1470, 1806, 2366, 13, 31395, 1159, 523, 7591, 4936, 1021, 26, 819, 446, 3101, 6947, 22400, 367, 314, 15451, 402, 314, 3590, 3167, 4936, 909, 272, 334, 692, 1654, 5171, 3101, 15, 17, 14, 17, 9, 523, 446, 16178, 4113, 283, 1023, 297, 1126, 4840, 13, 8171, 413, 14, 17, 523, 446, 16178, 5576, 12, 11609, 316, 283, 344, 7, 523, 446, 16178, 10082, 3101, 6299, 2323, 523, 446, 19953, 1006, 4840, 5579, 626, 3648, 2839, 15657, 465, 6345, 523, 446, 4440, 4465, 2018, 2022, 1973, 819, 26902, 4248, 12, 687, 2366, 13, 31395, 15, 31395, 15, 3280, 14, 647, 26, 819, 1898, 334, 67, 9, 10219, 17474, 13, 43, 416, 305, 1804, 14385, 526, 70, 819, 961, 570, 365, 1777, 402, 2022, 4354, 14, 819, 2022, 4354, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 523, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 523, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 523, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 819, 961, 2032, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 523, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 523, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 523, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 819, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 523, 3180, 543, 642, 2032, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 523, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 8217, 199, 624, 199, 199, 893, 26, 272, 492, 1455, 14, 1258, 465, 8809, 199, 2590, 3545, 26, 272, 492, 8809, 199, 646, 1300, 772, 199, 646, 6107, 199, 646, 2022, 199, 646, 2050, 199, 893, 26, 272, 492, 4011, 14, 1122, 465, 7097, 199, 2590, 3545, 26, 272, 492, 7097, 199, 199, 3791, 63, 14565, 275, 298, 2817, 3167, 4936, 15, 16, 14, 17, 2, 199, 199, 2856, 63, 8899, 275, 4233, 199, 199, 793, 275, 2050, 14, 5572, 480, 4734, 9061, 8171, 531, 199, 199, 533, 4840, 8171, 1726, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 8985, 63, 705, 304, 267, 2186, 855, 826, 721, 277, 9, 267, 291, 14, 705, 275, 8985, 63, 705, 421, 199, 318, 19244, 6745, 8, 79, 304, 272, 340, 1228, 8, 79, 12, 6107, 14, 6745, 304, 267, 372, 6168, 8, 79, 12, 1695, 9, 272, 746, 3146, 8, 2722, 8, 79, 9, 435, 298, 365, 440, 4840, 31244, 531, 199, 199, 533, 3590, 3167, 4936, 8, 785, 304, 272, 636, 344, 63, 835, 275, 378, 339, 347, 636, 826, 721, 277, 12, 2435, 63, 633, 12, 2435, 63, 354, 29, 403, 12, 2653, 29, 2856, 63, 8899, 12, 1950, 29, 403, 304, 267, 291, 855, 1364, 63, 633, 275, 2435, 63, 633, 267, 291, 855, 1364, 63, 354, 275, 2435, 63, 354, 267, 291, 855, 633, 275, 7097, 14, 10290, 8, 1364, 63, 633, 9, 267, 340, 291, 855, 633, 14, 719, 365, 488, 26, 288, 1844, 275, 5939, 267, 587, 26, 288, 1844, 275, 291, 855, 633, 14, 719, 267, 334, 751, 12, 15081, 9, 275, 334, 277, 855, 633, 14, 2473, 12, 291, 855, 633, 14, 2060, 9, 267, 862, 26, 288, 922, 275, 922, 14, 2143, 360, 1624, 24, 358, 267, 871, 4281, 26, 288, 986, 267, 862, 26, 288, 15081, 275, 15081, 14, 2143, 360, 1624, 24, 358, 267, 871, 4281, 26, 288, 986, 267, 1790, 3852, 275, 922, 435, 330, 5242, 435, 15081, 267, 291, 855, 1178, 63, 1291, 275, 330, 7, 6845, 283, 435, 1300, 772, 14, 66, 772, 2143, 8, 1178, 3852, 9, 398, 340, 1950, 26, 288, 327, 6523, 5921, 295, 13, 1180, 314, 1950, 402, 314, 3379, 4566, 288, 291, 855, 1631, 275, 1950, 267, 916, 291, 855, 633, 14, 5512, 508, 283, 2859, 356, 288, 291, 855, 1631, 275, 8809, 14, 27945, 8, 277, 855, 633, 14, 4269, 12, 1844, 12, 8179, 488, 12, 488, 12, 756, 12, 8179, 2653, 9, 267, 587, 26, 288, 291, 855, 1631, 275, 8809, 14, 19114, 8, 277, 855, 633, 14, 4269, 12, 1844, 12, 1740, 756, 12, 2653, 9, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 340, 536, 14, 2460, 10714, 358, 436, 536, 14, 4130, 10714, 735, 288, 327, 2018, 5007, 8292, 288, 746, 4281, 267, 340, 291, 855, 1364, 63, 354, 365, 440, 488, 26, 288, 536, 275, 2071, 83, 4111, 83, 2, 450, 334, 277, 855, 1364, 63, 354, 12, 536, 9, 267, 372, 3590, 3167, 4936, 8, 277, 855, 1364, 63, 633, 12, 536, 12, 1950, 29, 277, 855, 1631, 9, 339, 347, 636, 1250, 721, 277, 12, 627, 589, 304, 267, 3590, 3167, 4936, 855, 344, 63, 835, 847, 413, 398, 943, 14, 1757, 480, 3295, 83, 5118, 450, 83, 450, 83, 14007, 2817, 3167, 4936, 855, 344, 63, 835, 12, 291, 855, 1364, 63, 354, 12, 639, 2022, 14, 4180, 8, 589, 12, 849, 29, 9686, 6745, 1724, 267, 2963, 576, 275, 2022, 14, 4180, 3252, 1023, 356, 283, 17, 14, 17, 297, 3044, 283, 765, 356, 291, 855, 1364, 63, 354, 12, 3044, 283, 1162, 356, 1249, 12, 3044, 283, 344, 356, 3590, 3167, 4936, 855, 344, 63, 835, 1386, 849, 29, 9686, 6745, 9, 267, 291, 855, 1631, 14, 1069, 360, 4030, 297, 291, 855, 633, 14, 515, 12, 2963, 576, 12, 1169, 791, 4965, 356, 291, 855, 633, 14, 4269, 12, 2490, 283, 1899, 13, 7788, 356, 13044, 63, 14565, 12, 2490, 283, 11626, 356, 291, 855, 1178, 63, 1291, 12, 2490, 283, 2714, 13, 466, 356, 283, 3578, 15, 1001, 3071, 398, 1177, 275, 291, 423, 362, 63, 1310, 342, 267, 340, 1177, 459, 705, 418, 365, 440, 488, 26, 288, 746, 4840, 8171, 1726, 8, 1310, 459, 705, 1105, 267, 916, 283, 1099, 7, 440, 315, 1177, 26, 288, 746, 4840, 8171, 1726, 2561, 355 ]
[ 624, 523, 1898, 7760, 1603, 3609, 598, 285, 90, 3258, 819, 3590, 3167, 4936, 965, 314, 2569, 19053, 1470, 1806, 2366, 13, 31395, 1159, 523, 7591, 4936, 1021, 26, 819, 446, 3101, 6947, 22400, 367, 314, 15451, 402, 314, 3590, 3167, 4936, 909, 272, 334, 692, 1654, 5171, 3101, 15, 17, 14, 17, 9, 523, 446, 16178, 4113, 283, 1023, 297, 1126, 4840, 13, 8171, 413, 14, 17, 523, 446, 16178, 5576, 12, 11609, 316, 283, 344, 7, 523, 446, 16178, 10082, 3101, 6299, 2323, 523, 446, 19953, 1006, 4840, 5579, 626, 3648, 2839, 15657, 465, 6345, 523, 446, 4440, 4465, 2018, 2022, 1973, 819, 26902, 4248, 12, 687, 2366, 13, 31395, 15, 31395, 15, 3280, 14, 647, 26, 819, 1898, 334, 67, 9, 10219, 17474, 13, 43, 416, 305, 1804, 14385, 526, 70, 819, 961, 570, 365, 1777, 402, 2022, 4354, 14, 819, 2022, 4354, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 523, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 523, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 523, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 819, 961, 2032, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 523, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 523, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 523, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 819, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 523, 3180, 543, 642, 2032, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 523, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 8217, 199, 624, 199, 199, 893, 26, 272, 492, 1455, 14, 1258, 465, 8809, 199, 2590, 3545, 26, 272, 492, 8809, 199, 646, 1300, 772, 199, 646, 6107, 199, 646, 2022, 199, 646, 2050, 199, 893, 26, 272, 492, 4011, 14, 1122, 465, 7097, 199, 2590, 3545, 26, 272, 492, 7097, 199, 199, 3791, 63, 14565, 275, 298, 2817, 3167, 4936, 15, 16, 14, 17, 2, 199, 199, 2856, 63, 8899, 275, 4233, 199, 199, 793, 275, 2050, 14, 5572, 480, 4734, 9061, 8171, 531, 199, 199, 533, 4840, 8171, 1726, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 8985, 63, 705, 304, 267, 2186, 855, 826, 721, 277, 9, 267, 291, 14, 705, 275, 8985, 63, 705, 421, 199, 318, 19244, 6745, 8, 79, 304, 272, 340, 1228, 8, 79, 12, 6107, 14, 6745, 304, 267, 372, 6168, 8, 79, 12, 1695, 9, 272, 746, 3146, 8, 2722, 8, 79, 9, 435, 298, 365, 440, 4840, 31244, 531, 199, 199, 533, 3590, 3167, 4936, 8, 785, 304, 272, 636, 344, 63, 835, 275, 378, 339, 347, 636, 826, 721, 277, 12, 2435, 63, 633, 12, 2435, 63, 354, 29, 403, 12, 2653, 29, 2856, 63, 8899, 12, 1950, 29, 403, 304, 267, 291, 855, 1364, 63, 633, 275, 2435, 63, 633, 267, 291, 855, 1364, 63, 354, 275, 2435, 63, 354, 267, 291, 855, 633, 275, 7097, 14, 10290, 8, 1364, 63, 633, 9, 267, 340, 291, 855, 633, 14, 719, 365, 488, 26, 288, 1844, 275, 5939, 267, 587, 26, 288, 1844, 275, 291, 855, 633, 14, 719, 267, 334, 751, 12, 15081, 9, 275, 334, 277, 855, 633, 14, 2473, 12, 291, 855, 633, 14, 2060, 9, 267, 862, 26, 288, 922, 275, 922, 14, 2143, 360, 1624, 24, 358, 267, 871, 4281, 26, 288, 986, 267, 862, 26, 288, 15081, 275, 15081, 14, 2143, 360, 1624, 24, 358, 267, 871, 4281, 26, 288, 986, 267, 1790, 3852, 275, 922, 435, 330, 5242, 435, 15081, 267, 291, 855, 1178, 63, 1291, 275, 330, 7, 6845, 283, 435, 1300, 772, 14, 66, 772, 2143, 8, 1178, 3852, 9, 398, 340, 1950, 26, 288, 327, 6523, 5921, 295, 13, 1180, 314, 1950, 402, 314, 3379, 4566, 288, 291, 855, 1631, 275, 1950, 267, 916, 291, 855, 633, 14, 5512, 508, 283, 2859, 356, 288, 291, 855, 1631, 275, 8809, 14, 27945, 8, 277, 855, 633, 14, 4269, 12, 1844, 12, 8179, 488, 12, 488, 12, 756, 12, 8179, 2653, 9, 267, 587, 26, 288, 291, 855, 1631, 275, 8809, 14, 19114, 8, 277, 855, 633, 14, 4269, 12, 1844, 12, 1740, 756, 12, 2653, 9, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 340, 536, 14, 2460, 10714, 358, 436, 536, 14, 4130, 10714, 735, 288, 327, 2018, 5007, 8292, 288, 746, 4281, 267, 340, 291, 855, 1364, 63, 354, 365, 440, 488, 26, 288, 536, 275, 2071, 83, 4111, 83, 2, 450, 334, 277, 855, 1364, 63, 354, 12, 536, 9, 267, 372, 3590, 3167, 4936, 8, 277, 855, 1364, 63, 633, 12, 536, 12, 1950, 29, 277, 855, 1631, 9, 339, 347, 636, 1250, 721, 277, 12, 627, 589, 304, 267, 3590, 3167, 4936, 855, 344, 63, 835, 847, 413, 398, 943, 14, 1757, 480, 3295, 83, 5118, 450, 83, 450, 83, 14007, 2817, 3167, 4936, 855, 344, 63, 835, 12, 291, 855, 1364, 63, 354, 12, 639, 2022, 14, 4180, 8, 589, 12, 849, 29, 9686, 6745, 1724, 267, 2963, 576, 275, 2022, 14, 4180, 3252, 1023, 356, 283, 17, 14, 17, 297, 3044, 283, 765, 356, 291, 855, 1364, 63, 354, 12, 3044, 283, 1162, 356, 1249, 12, 3044, 283, 344, 356, 3590, 3167, 4936, 855, 344, 63, 835, 1386, 849, 29, 9686, 6745, 9, 267, 291, 855, 1631, 14, 1069, 360, 4030, 297, 291, 855, 633, 14, 515, 12, 2963, 576, 12, 1169, 791, 4965, 356, 291, 855, 633, 14, 4269, 12, 2490, 283, 1899, 13, 7788, 356, 13044, 63, 14565, 12, 2490, 283, 11626, 356, 291, 855, 1178, 63, 1291, 12, 2490, 283, 2714, 13, 466, 356, 283, 3578, 15, 1001, 3071, 398, 1177, 275, 291, 423, 362, 63, 1310, 342, 267, 340, 1177, 459, 705, 418, 365, 440, 488, 26, 288, 746, 4840, 8171, 1726, 8, 1310, 459, 705, 1105, 267, 916, 283, 1099, 7, 440, 315, 1177, 26, 288, 746, 4840, 8171, 1726, 2561, 355, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
bobrock/eden
modules/templates/ARC/layouts.py
20
10184
# -*- coding: utf-8 -*- from gluon import * from s3 import * # ============================================================================= class S3MainMenuLayout(S3NavigationItem): """ Application Main Menu Layout """ @staticmethod def layout(item): """ Custom Layout Method """ # Manage flags: hide any disabled/unauthorized items if not item.authorized: item.enabled = False item.visible = False elif item.enabled is None or item.enabled: item.enabled = True item.visible = True if item.enabled and item.visible: if item.parent is None: # The main menu items = item.render_components() return UL(items, _id="nav") else: if item.components: # A submenu items = item.render_components() _class = item.selected and "highlight" or "" return LI(A(item.label, _href=item.url(), _id=item.attr._id, _class=_class), UL(items, _class="sub-menu")) else: # A menu item return LI(A(item.label, _href=item.url(), _id=item.attr._id)) else: return None # ============================================================================= class S3OptionsMenuLayout(S3NavigationItem): """ Controller Options Menu Layout """ @staticmethod def layout(item): """ Custom Layout Method """ # Manage flags: hide any disabled/unauthorized items if not item.authorized: enabled = False visible = False elif item.enabled is None or item.enabled: enabled = True visible = True if enabled and visible: if item.parent is not None: if item.enabled and item.authorized: if item.components: # Submenu _class = "" if item.parent.parent is None and item.selected: _class = "highlight" items = item.render_components() if items: items = LI(UL(items, _class="menu-extention")) return [LI(A(item.label, _href=item.url(), _id=item.attr._id, _class=_class)), items] else: # Submenu item if item.parent.parent is None: _class = item.selected and "highlight" or "" else: _class = " " return LI(A(item.label, _href=item.url(), _id=item.attr._id, _class=_class)) else: # Main menu items = item.render_components() return UL(items, _id="main-sub-menu", _class="sub-menu") else: return None # ============================================================================= class S3LanguageMenuLayout(S3NavigationItem): @staticmethod def layout(item): """ Language menu layout options for each entry: - lang_code: the language code - lang_name: the language name option for the menu - current_language: code of the current language """ if item.enabled: if item.components: # The language menu itself current_language = current.T.accepted_language items = item.render_components() select = SELECT(items, value=current_language, _name="_language", # @ToDo T: _title="Language Selection", _onchange="S3.reloadWithQueryStringVars({'_language':$(this).val()});") form = FORM(select, _id="language_selector", _name="_language", _action="", _method="get") return form else: # A language entry return OPTION(item.opts.lang_name, _value=item.opts.lang_code) else: return None # ------------------------------------------------------------------------- def check_enabled(self): """ Check whether the language menu is enabled """ if current.deployment_settings.get_L10n_display_toolbar(): return True else: return False # ----------------------------------------------------------------------------- # Shortcut ML = S3LanguageMenuLayout # ============================================================================= class S3PersonalMenuLayout(S3NavigationItem): @staticmethod def layout(item): if item.parent is None: # The menu items = item.render_components() if items: return DIV(UL(items), _class="pmenu-wrapper") else: return "" # menu is empty else: # A menu item if item.enabled and item.authorized: return LI(A(item.label, _href=item.url())) else: return None # ----------------------------------------------------------------------------- # Shortcut MP = S3PersonalMenuLayout # ============================================================================= class S3DashBoardMenuLayout(S3NavigationItem): """ Layout for the bottom-menu (dashboard menu) """ @staticmethod def layout(item): T = current.T if item.components: items = item.render_components() else: items = None if item.parent is None: #return items #elif item.parent.parent is None: if items: if item.attr._id is not None: _id = item.attr._id else: _id = "sub-dashboard" return UL(items, _id=_id) else: return "" else: if item.components: return LI(A(H2(item.label), UL(items), IMG(_src=URL(c="static", f="themes", args=["IFRC", "img", item.opts.image]), _alt=T(item.opts.title)), _href=item.url())) elif item.opts.text: return LI(A(H2(item.label), P(T(item.opts.text)), IMG(_src=URL(c="static", f="themes", args=["IFRC", "img", item.opts.image]), _alt=item.opts.image), _href=item.url())) else: return LI(A(item.label, _href=item.url())) # ----------------------------------------------------------------------------- # Shortcut DB = S3DashBoardMenuLayout # ============================================================================= class S3OrgMenuLayout(S3NavigationItem): """ Layout for the organisation-specific menu """ @staticmethod def layout(item): name = "IFRC" logo = None # Lookup Root Organisation name & Logo root_org = current.auth.root_org() if root_org: s3db = current.s3db table = s3db.org_organisation record = current.db(table.id == root_org).select(table.name, table.acronym, table.logo, limitby = (0, 1), cache = s3db.cache, ).first() if record: if record.acronym: name = _name = record.acronym else: _name = record.name names = _name.split(" ") names_with_breaks = [] nappend = names_with_breaks.append for name in names: nappend(name) nappend(BR()) # Remove last BR() names_with_breaks.pop() name = TAG[""](*names_with_breaks) if record.logo: size = (60, None) image = s3db.pr_image_represent(record.logo, size=size) url_small = URL(c="default", f="download", args=image) alt = "%s logo" % _name logo = IMG(_src=url_small, _alt=alt, _width=60, ) if not logo: # Default to generic IFRC logo = IMG(_src="/%s/static/themes/IFRC/img/dummy_flag.png" % current.request.application, _alt=current.T("Red Cross/Red Crescent"), _width=60, ) # Note: render using current.menu.org.render()[0] + current.menu.org.render()[1] return (name, logo) # ----------------------------------------------------------------------------- # Shortcut OM = S3OrgMenuLayout # END =========================================================================
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 26752, 492, 627, 199, 504, 308, 19, 492, 627, 199, 199, 3, 26237, 199, 533, 428, 19, 6756, 5977, 4798, 8, 51, 19, 19617, 5360, 2081, 304, 272, 408, 267, 13515, 11298, 18281, 25604, 272, 408, 339, 768, 4639, 272, 347, 7054, 8, 1053, 304, 267, 408, 8388, 25604, 9075, 408, 398, 327, 14944, 3285, 26, 13714, 1263, 6980, 15, 324, 11497, 2974, 267, 340, 440, 1242, 14, 11497, 26, 288, 1242, 14, 3827, 275, 756, 288, 1242, 14, 6604, 275, 756, 267, 916, 1242, 14, 3827, 365, 488, 503, 1242, 14, 3827, 26, 288, 1242, 14, 3827, 275, 715, 288, 1242, 14, 6604, 275, 715, 398, 340, 1242, 14, 3827, 436, 1242, 14, 6604, 26, 288, 340, 1242, 14, 1708, 365, 488, 26, 355, 327, 710, 2446, 6269, 355, 2974, 275, 1242, 14, 3352, 63, 4608, 342, 355, 372, 738, 44, 8, 1744, 12, 485, 344, 628, 10927, 531, 288, 587, 26, 355, 340, 1242, 14, 4608, 26, 490, 327, 437, 1007, 4470, 490, 2974, 275, 1242, 14, 3352, 63, 4608, 342, 490, 485, 533, 275, 1242, 14, 5511, 436, 298, 14337, 2, 503, 3087, 490, 372, 3782, 8, 33, 8, 1053, 14, 1302, 12, 1816, 485, 6399, 29, 1053, 14, 633, 1062, 1816, 485, 344, 29, 1053, 14, 962, 423, 344, 12, 1816, 485, 533, 3699, 533, 395, 2892, 738, 44, 8, 1744, 12, 485, 533, 628, 954, 13, 4470, 2237, 355, 587, 26, 490, 327, 437, 6269, 1242, 490, 372, 3782, 8, 33, 8, 1053, 14, 1302, 12, 1816, 485, 6399, 29, 1053, 14, 633, 1062, 1816, 485, 344, 29, 1053, 14, 962, 423, 344, 430, 267, 587, 26, 288, 372, 488, 199, 199, 3, 26237, 199, 533, 428, 19, 4558, 5977, 4798, 8, 51, 19, 19617, 5360, 2081, 304, 272, 408, 267, 16282, 8394, 18281, 25604, 272, 408, 339, 768, 4639, 272, 347, 7054, 8, 1053, 304, 267, 408, 8388, 25604, 9075, 408, 398, 327, 14944, 3285, 26, 13714, 1263, 6980, 15, 324, 11497, 2974, 267, 340, 440, 1242, 14, 11497, 26, 288, 5223, 275, 756, 288, 8917, 275, 756, 267, 916, 1242, 14, 3827, 365, 488, 503, 1242, 14, 3827, 26, 288, 5223, 275, 715, 288, 8917, 275, 715, 398, 340, 5223, 436, 8917, 26, 288, 340, 1242, 14, 1708, 365, 440, 488, 26, 355, 340, 1242, 14, 3827, 436, 1242, 14, 11497, 26, 490, 340, 1242, 14, 4608, 26, 717, 327, 4804, 4470, 717, 485, 533, 275, 3087, 717, 340, 1242, 14, 1708, 14, 1708, 365, 488, 436, 1242, 14, 5511, 26, 1169, 485, 533, 275, 298, 14337, 2, 717, 2974, 275, 1242, 14, 3352, 63, 4608, 342, 717, 340, 2974, 26, 1169, 2974, 275, 3782, 8, 1293, 8, 1744, 12, 485, 533, 628, 4470, 13, 1614, 296, 2237, 9453, 372, 359, 2673, 8, 33, 8, 1053, 14, 1302, 12, 3660, 485, 6399, 29, 1053, 14, 633, 1062, 3660, 485, 344, 29, 1053, 14, 962, 423, 344, 12, 3660, 485, 533, 3699, 533, 1826, 2974, 61, 4951, 587, 26, 717, 327, 4804, 4470, 1242, 717, 340, 1242, 14, 1708, 14, 1708, 365, 488, 26, 1169, 485, 533, 275, 1242, 14, 5511, 436, 298, 14337, 2, 503, 3087, 717, 587, 26, 1169, 485, 533, 275, 298, 298, 9453, 372, 3782, 8, 33, 8, 1053, 14, 1302, 12, 2511, 485, 6399, 29, 1053, 14, 633, 1062, 2511, 485, 344, 29, 1053, 14, 962, 423, 344, 12, 2511, 485, 533, 3699, 533, 430, 288, 587, 26, 355, 327, 11298, 6269, 355, 2974, 275, 1242, 14, 3352, 63, 4608, 342, 355, 372, 738, 44, 8, 1744, 12, 485, 344, 628, 973, 13, 954, 13, 4470, 401, 485, 533, 628, 954, 13, 4470, 531, 398, 587, 26, 288, 372, 488, 199, 199, 3, 26237, 199, 533, 428, 19, 8493, 5977, 4798, 8, 51, 19, 19617, 5360, 2081, 304, 339, 768, 4639, 272, 347, 7054, 8, 1053, 304, 267, 408, 8466, 6269, 7054, 953, 1511, 367, 1924, 2397, 26, 355, 446, 6339, 63, 600, 26, 314, 2637, 1233, 355, 446, 6339, 63, 354, 26, 314, 2637, 536, 288, 945, 367, 314, 6269, 355, 446, 1453, 63, 3671, 26, 1233, 402, 314, 1453, 2637, 267, 408, 398, 340, 1242, 14, 3827, 26, 288, 340, 1242, 14, 4608, 26, 355, 327, 710, 2637, 6269, 6337, 355, 1453, 63, 3671, 275, 1453, 14, 52, 14, 16121, 63, 3671, 355, 2974, 275, 1242, 14, 3352, 63, 4608, 342, 355, 3504, 275, 10468, 8, 1744, 12, 574, 29, 1818, 63, 3671, 12, 2511, 485, 354, 19667, 3671, 401, 2511, 327, 768, 1378, 2585, 377, 26, 2511, 485, 1213, 628, 8493, 3240, 1486, 401, 2511, 485, 18128, 628, 51, 19, 14, 9233, 3007, 3227, 1558, 16270, 3252, 63, 3671, 356, 6629, 3749, 680, 637, 22804, 15027, 355, 1824, 275, 11295, 8, 2416, 12, 485, 344, 628, 3671, 63, 6662, 401, 2511, 485, 354, 19667, 3671, 401, 2511, 485, 1287, 8772, 2511, 485, 765, 628, 362, 531, 355, 372, 1824, 288, 587, 26, 355, 327, 437, 2637, 2397, 355, 372, 11662, 1075, 8, 1053, 14, 3291, 14, 4159, 63, 354, 12, 2892, 485, 585, 29, 1053, 14, 3291, 14, 4159, 63, 600, 9, 267, 587, 26, 288, 372, 488, 339, 327, 18852, 272, 347, 1104, 63, 3827, 8, 277, 304, 267, 408, 2670, 3775, 314, 2637, 6269, 365, 5223, 408, 398, 340, 1453, 14, 13605, 63, 1751, 14, 362, 63, 44, 709, 78, 63, 2918, 63, 13951, 837, 288, 372, 715, 267, 587, 26, 288, 372, 756, 199, 199, 3, 13722, 199, 3, 20124, 5919, 199, 1698, 275, 428, 19, 8493, 5977, 4798, 199, 199, 3, 26237, 199, 533, 428, 19, 7344, 279, 5977, 4798, 8, 51, 19, 19617, 5360, 2081, 304, 339, 768, 4639, 272, 347, 7054, 8, 1053, 304, 398, 340, 1242, 14, 1708, 365, 488, 26, 288, 327, 710, 6269, 288, 2974, 275, 1242, 14, 3352, 63, 4608, 342, 288, 340, 2974, 26, 355, 372, 5266, 54, 8, 1293, 8, 1744, 395, 485, 533, 628, 80, 4470, 13, 5029, 531, 288, 587, 26, 355, 372, 3087, 327, 6269, 365, 2701, 267, 587, 26, 288, 327, 437, 6269, 1242, 288, 340, 1242, 14, 3827, 436, 1242, 14, 11497 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 26752, 492, 627, 199, 504, 308, 19, 492, 627, 199, 199, 3, 26237, 199, 533, 428, 19, 6756, 5977, 4798, 8, 51, 19, 19617, 5360, 2081, 304, 272, 408, 267, 13515, 11298, 18281, 25604, 272, 408, 339, 768, 4639, 272, 347, 7054, 8, 1053, 304, 267, 408, 8388, 25604, 9075, 408, 398, 327, 14944, 3285, 26, 13714, 1263, 6980, 15, 324, 11497, 2974, 267, 340, 440, 1242, 14, 11497, 26, 288, 1242, 14, 3827, 275, 756, 288, 1242, 14, 6604, 275, 756, 267, 916, 1242, 14, 3827, 365, 488, 503, 1242, 14, 3827, 26, 288, 1242, 14, 3827, 275, 715, 288, 1242, 14, 6604, 275, 715, 398, 340, 1242, 14, 3827, 436, 1242, 14, 6604, 26, 288, 340, 1242, 14, 1708, 365, 488, 26, 355, 327, 710, 2446, 6269, 355, 2974, 275, 1242, 14, 3352, 63, 4608, 342, 355, 372, 738, 44, 8, 1744, 12, 485, 344, 628, 10927, 531, 288, 587, 26, 355, 340, 1242, 14, 4608, 26, 490, 327, 437, 1007, 4470, 490, 2974, 275, 1242, 14, 3352, 63, 4608, 342, 490, 485, 533, 275, 1242, 14, 5511, 436, 298, 14337, 2, 503, 3087, 490, 372, 3782, 8, 33, 8, 1053, 14, 1302, 12, 1816, 485, 6399, 29, 1053, 14, 633, 1062, 1816, 485, 344, 29, 1053, 14, 962, 423, 344, 12, 1816, 485, 533, 3699, 533, 395, 2892, 738, 44, 8, 1744, 12, 485, 533, 628, 954, 13, 4470, 2237, 355, 587, 26, 490, 327, 437, 6269, 1242, 490, 372, 3782, 8, 33, 8, 1053, 14, 1302, 12, 1816, 485, 6399, 29, 1053, 14, 633, 1062, 1816, 485, 344, 29, 1053, 14, 962, 423, 344, 430, 267, 587, 26, 288, 372, 488, 199, 199, 3, 26237, 199, 533, 428, 19, 4558, 5977, 4798, 8, 51, 19, 19617, 5360, 2081, 304, 272, 408, 267, 16282, 8394, 18281, 25604, 272, 408, 339, 768, 4639, 272, 347, 7054, 8, 1053, 304, 267, 408, 8388, 25604, 9075, 408, 398, 327, 14944, 3285, 26, 13714, 1263, 6980, 15, 324, 11497, 2974, 267, 340, 440, 1242, 14, 11497, 26, 288, 5223, 275, 756, 288, 8917, 275, 756, 267, 916, 1242, 14, 3827, 365, 488, 503, 1242, 14, 3827, 26, 288, 5223, 275, 715, 288, 8917, 275, 715, 398, 340, 5223, 436, 8917, 26, 288, 340, 1242, 14, 1708, 365, 440, 488, 26, 355, 340, 1242, 14, 3827, 436, 1242, 14, 11497, 26, 490, 340, 1242, 14, 4608, 26, 717, 327, 4804, 4470, 717, 485, 533, 275, 3087, 717, 340, 1242, 14, 1708, 14, 1708, 365, 488, 436, 1242, 14, 5511, 26, 1169, 485, 533, 275, 298, 14337, 2, 717, 2974, 275, 1242, 14, 3352, 63, 4608, 342, 717, 340, 2974, 26, 1169, 2974, 275, 3782, 8, 1293, 8, 1744, 12, 485, 533, 628, 4470, 13, 1614, 296, 2237, 9453, 372, 359, 2673, 8, 33, 8, 1053, 14, 1302, 12, 3660, 485, 6399, 29, 1053, 14, 633, 1062, 3660, 485, 344, 29, 1053, 14, 962, 423, 344, 12, 3660, 485, 533, 3699, 533, 1826, 2974, 61, 4951, 587, 26, 717, 327, 4804, 4470, 1242, 717, 340, 1242, 14, 1708, 14, 1708, 365, 488, 26, 1169, 485, 533, 275, 1242, 14, 5511, 436, 298, 14337, 2, 503, 3087, 717, 587, 26, 1169, 485, 533, 275, 298, 298, 9453, 372, 3782, 8, 33, 8, 1053, 14, 1302, 12, 2511, 485, 6399, 29, 1053, 14, 633, 1062, 2511, 485, 344, 29, 1053, 14, 962, 423, 344, 12, 2511, 485, 533, 3699, 533, 430, 288, 587, 26, 355, 327, 11298, 6269, 355, 2974, 275, 1242, 14, 3352, 63, 4608, 342, 355, 372, 738, 44, 8, 1744, 12, 485, 344, 628, 973, 13, 954, 13, 4470, 401, 485, 533, 628, 954, 13, 4470, 531, 398, 587, 26, 288, 372, 488, 199, 199, 3, 26237, 199, 533, 428, 19, 8493, 5977, 4798, 8, 51, 19, 19617, 5360, 2081, 304, 339, 768, 4639, 272, 347, 7054, 8, 1053, 304, 267, 408, 8466, 6269, 7054, 953, 1511, 367, 1924, 2397, 26, 355, 446, 6339, 63, 600, 26, 314, 2637, 1233, 355, 446, 6339, 63, 354, 26, 314, 2637, 536, 288, 945, 367, 314, 6269, 355, 446, 1453, 63, 3671, 26, 1233, 402, 314, 1453, 2637, 267, 408, 398, 340, 1242, 14, 3827, 26, 288, 340, 1242, 14, 4608, 26, 355, 327, 710, 2637, 6269, 6337, 355, 1453, 63, 3671, 275, 1453, 14, 52, 14, 16121, 63, 3671, 355, 2974, 275, 1242, 14, 3352, 63, 4608, 342, 355, 3504, 275, 10468, 8, 1744, 12, 574, 29, 1818, 63, 3671, 12, 2511, 485, 354, 19667, 3671, 401, 2511, 327, 768, 1378, 2585, 377, 26, 2511, 485, 1213, 628, 8493, 3240, 1486, 401, 2511, 485, 18128, 628, 51, 19, 14, 9233, 3007, 3227, 1558, 16270, 3252, 63, 3671, 356, 6629, 3749, 680, 637, 22804, 15027, 355, 1824, 275, 11295, 8, 2416, 12, 485, 344, 628, 3671, 63, 6662, 401, 2511, 485, 354, 19667, 3671, 401, 2511, 485, 1287, 8772, 2511, 485, 765, 628, 362, 531, 355, 372, 1824, 288, 587, 26, 355, 327, 437, 2637, 2397, 355, 372, 11662, 1075, 8, 1053, 14, 3291, 14, 4159, 63, 354, 12, 2892, 485, 585, 29, 1053, 14, 3291, 14, 4159, 63, 600, 9, 267, 587, 26, 288, 372, 488, 339, 327, 18852, 272, 347, 1104, 63, 3827, 8, 277, 304, 267, 408, 2670, 3775, 314, 2637, 6269, 365, 5223, 408, 398, 340, 1453, 14, 13605, 63, 1751, 14, 362, 63, 44, 709, 78, 63, 2918, 63, 13951, 837, 288, 372, 715, 267, 587, 26, 288, 372, 756, 199, 199, 3, 13722, 199, 3, 20124, 5919, 199, 1698, 275, 428, 19, 8493, 5977, 4798, 199, 199, 3, 26237, 199, 533, 428, 19, 7344, 279, 5977, 4798, 8, 51, 19, 19617, 5360, 2081, 304, 339, 768, 4639, 272, 347, 7054, 8, 1053, 304, 398, 340, 1242, 14, 1708, 365, 488, 26, 288, 327, 710, 6269, 288, 2974, 275, 1242, 14, 3352, 63, 4608, 342, 288, 340, 2974, 26, 355, 372, 5266, 54, 8, 1293, 8, 1744, 395, 485, 533, 628, 80, 4470, 13, 5029, 531, 288, 587, 26, 355, 372, 3087, 327, 6269, 365, 2701, 267, 587, 26, 288, 327, 437, 6269, 1242, 288, 340, 1242, 14, 3827, 436, 1242, 14, 11497, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
yasoob/PythonRSSReader
venv/lib/python2.7/dist-packages/twisted/internet/win32eventreactor.py
41
15157
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ A win32event based implementation of the Twisted main loop. This requires pywin32 (formerly win32all) or ActivePython to be installed. To install the event loop (and you should do this before any connections, listeners or connectors are added):: from twisted.internet import win32eventreactor win32eventreactor.install() LIMITATIONS: 1. WaitForMultipleObjects and thus the event loop can only handle 64 objects. 2. Process running has some problems (see L{Process} docstring). TODO: 1. Event loop handling of writes is *very* problematic (this is causing failed tests). Switch to doing it the correct way, whatever that means (see below). 2. Replace icky socket loopback waker with event based waker (use dummyEvent object) 3. Switch everyone to using Free Software so we don't have to deal with proprietary APIs. ALTERNATIVE SOLUTIONS: - IIRC, sockets can only be registered once. So we switch to a structure like the poll() reactor, thus allowing us to deal with write events in a decent fashion. This should allow us to pass tests, but we're still limited to 64 events. Or: - Instead of doing a reactor, we make this an addon to the select reactor. The WFMO event loop runs in a separate thread. This means no need to maintain separate code for networking, 64 event limit doesn't apply to sockets, we can run processes and other win32 stuff in default event loop. The only problem is that we're stuck with the icky socket based waker. Another benefit is that this could be extended to support >64 events in a simpler manner than the previous solution. The 2nd solution is probably what will get implemented. """ # System imports import time import sys from threading import Thread from weakref import WeakKeyDictionary from zope.interface import implements # Win32 imports from win32file import FD_READ, FD_CLOSE, FD_ACCEPT, FD_CONNECT, WSAEventSelect try: # WSAEnumNetworkEvents was added in pywin32 215 from win32file import WSAEnumNetworkEvents except ImportError: import warnings warnings.warn( 'Reliable disconnection notification requires pywin32 215 or later', category=UserWarning) def WSAEnumNetworkEvents(fd, event): return set([FD_READ]) from win32event import CreateEvent, MsgWaitForMultipleObjects from win32event import WAIT_OBJECT_0, WAIT_TIMEOUT, QS_ALLINPUT, QS_ALLEVENTS import win32gui # Twisted imports from twisted.internet import posixbase from twisted.python import log, threadable, failure from twisted.internet.interfaces import IReactorFDSet from twisted.internet.interfaces import IReactorWin32Events from twisted.internet.threads import blockingCallFromThread class Win32Reactor(posixbase.PosixReactorBase): """ Reactor that uses Win32 event APIs. @ivar _reads: A dictionary mapping L{FileDescriptor} instances to a win32 event object used to check for read events for that descriptor. @ivar _writes: A dictionary mapping L{FileDescriptor} instances to a arbitrary value. Keys in this dictionary will be given a chance to write out their data. @ivar _events: A dictionary mapping win32 event object to tuples of L{FileDescriptor} instances and event masks. @ivar _closedAndReading: Along with C{_closedAndNotReading}, keeps track of descriptors which have had close notification delivered from the OS but which we have not finished reading data from. MsgWaitForMultipleObjects will only deliver close notification to us once, so we remember it in these two dictionaries until we're ready to act on it. The OS has delivered close notification for each descriptor in this dictionary, and the descriptors are marked as allowed to handle read events in the reactor, so they can be processed. When a descriptor is marked as not allowed to handle read events in the reactor (ie, it is passed to L{IReactorFDSet.removeReader}), it is moved out of this dictionary and into C{_closedAndNotReading}. The descriptors are keys in this dictionary. The values are arbitrary. @type _closedAndReading: C{dict} @ivar _closedAndNotReading: These descriptors have had close notification delivered from the OS, but are not marked as allowed to handle read events in the reactor. They are saved here to record their closed state, but not processed at all. When one of these descriptors is passed to L{IReactorFDSet.addReader}, it is moved out of this dictionary and into C{_closedAndReading}. The descriptors are keys in this dictionary. The values are arbitrary. This is a weak key dictionary so that if an application tells the reactor to stop reading from a descriptor and then forgets about that descriptor itself, the reactor will also forget about it. @type _closedAndNotReading: C{WeakKeyDictionary} """ implements(IReactorFDSet, IReactorWin32Events) dummyEvent = CreateEvent(None, 0, 0, None) def __init__(self): self._reads = {} self._writes = {} self._events = {} self._closedAndReading = {} self._closedAndNotReading = WeakKeyDictionary() posixbase.PosixReactorBase.__init__(self) def _makeSocketEvent(self, fd, action, why): """ Make a win32 event object for a socket. """ event = CreateEvent(None, 0, 0, None) WSAEventSelect(fd, event, why) self._events[event] = (fd, action) return event def addEvent(self, event, fd, action): """ Add a new win32 event to the event loop. """ self._events[event] = (fd, action) def removeEvent(self, event): """ Remove an event. """ del self._events[event] def addReader(self, reader): """ Add a socket FileDescriptor for notification of data available to read. """ if reader not in self._reads: self._reads[reader] = self._makeSocketEvent( reader, 'doRead', FD_READ | FD_ACCEPT | FD_CONNECT | FD_CLOSE) # If the reader is closed, move it over to the dictionary of reading # descriptors. if reader in self._closedAndNotReading: self._closedAndReading[reader] = True del self._closedAndNotReading[reader] def addWriter(self, writer): """ Add a socket FileDescriptor for notification of data available to write. """ if writer not in self._writes: self._writes[writer] = 1 def removeReader(self, reader): """Remove a Selectable for notification of data available to read. """ if reader in self._reads: del self._events[self._reads[reader]] del self._reads[reader] # If the descriptor is closed, move it out of the dictionary of # reading descriptors into the dictionary of waiting descriptors. if reader in self._closedAndReading: self._closedAndNotReading[reader] = True del self._closedAndReading[reader] def removeWriter(self, writer): """Remove a Selectable for notification of data available to write. """ if writer in self._writes: del self._writes[writer] def removeAll(self): """ Remove all selectables, and return a list of them. """ return self._removeAll(self._reads, self._writes) def getReaders(self): return self._reads.keys() def getWriters(self): return self._writes.keys() def doWaitForMultipleEvents(self, timeout): log.msg(channel='system', event='iteration', reactor=self) if timeout is None: timeout = 100 # Keep track of whether we run any application code before we get to the # MsgWaitForMultipleObjects. If so, there's a chance it will schedule a # new timed call or stop the reactor or do something else that means we # shouldn't block in MsgWaitForMultipleObjects for the full timeout. ranUserCode = False # If any descriptors are trying to close, try to get them out of the way # first. for reader in self._closedAndReading.keys(): ranUserCode = True self._runAction('doRead', reader) for fd in self._writes.keys(): ranUserCode = True log.callWithLogger(fd, self._runWrite, fd) if ranUserCode: # If application code *might* have scheduled an event, assume it # did. If we're wrong, we'll get back here shortly anyway. If # we're right, we'll be sure to handle the event (including reactor # shutdown) in a timely manner. timeout = 0 if not (self._events or self._writes): # sleep so we don't suck up CPU time time.sleep(timeout) return handles = self._events.keys() or [self.dummyEvent] timeout = int(timeout * 1000) val = MsgWaitForMultipleObjects(handles, 0, timeout, QS_ALLINPUT) if val == WAIT_TIMEOUT: return elif val == WAIT_OBJECT_0 + len(handles): exit = win32gui.PumpWaitingMessages() if exit: self.callLater(0, self.stop) return elif val >= WAIT_OBJECT_0 and val < WAIT_OBJECT_0 + len(handles): event = handles[val - WAIT_OBJECT_0] fd, action = self._events[event] if fd in self._reads: # Before anything, make sure it's still a valid file descriptor. fileno = fd.fileno() if fileno == -1: self._disconnectSelectable(fd, posixbase._NO_FILEDESC, False) return # Since it's a socket (not another arbitrary event added via # addEvent) and we asked for FD_READ | FD_CLOSE, check to see if # we actually got FD_CLOSE. This needs a special check because # it only gets delivered once. If we miss it, it's gone forever # and we'll never know that the connection is closed. events = WSAEnumNetworkEvents(fileno, event) if FD_CLOSE in events: self._closedAndReading[fd] = True log.callWithLogger(fd, self._runAction, action, fd) def _runWrite(self, fd): closed = 0 try: closed = fd.doWrite() except: closed = sys.exc_info()[1] log.deferr() if closed: self.removeReader(fd) self.removeWriter(fd) try: fd.connectionLost(failure.Failure(closed)) except: log.deferr() elif closed is None: return 1 def _runAction(self, action, fd): try: closed = getattr(fd, action)() except: closed = sys.exc_info()[1] log.deferr() if closed: self._disconnectSelectable(fd, closed, action == 'doRead') doIteration = doWaitForMultipleEvents class _ThreadFDWrapper(object): """ This wraps an event handler and translates notification in the helper L{Win32Reactor} thread into a notification in the primary reactor thread. @ivar _reactor: The primary reactor, the one to which event notification will be sent. @ivar _fd: The L{FileDescriptor} to which the event will be dispatched. @ivar _action: A C{str} giving the method of C{_fd} which handles the event. @ivar _logPrefix: The pre-fetched log prefix string for C{_fd}, so that C{_fd.logPrefix} does not need to be called in a non-main thread. """ def __init__(self, reactor, fd, action, logPrefix): self._reactor = reactor self._fd = fd self._action = action self._logPrefix = logPrefix def logPrefix(self): """ Return the original handler's log prefix, as it was given to C{__init__}. """ return self._logPrefix def _execute(self): """ Callback fired when the associated event is set. Run the C{action} callback on the wrapped descriptor in the main reactor thread and raise or return whatever it raises or returns to cause this event handler to be removed from C{self._reactor} if appropriate. """ return blockingCallFromThread( self._reactor, lambda: getattr(self._fd, self._action)()) def connectionLost(self, reason): """ Pass through to the wrapped descriptor, but in the main reactor thread instead of the helper C{Win32Reactor} thread. """ self._reactor.callFromThread(self._fd.connectionLost, reason) class _ThreadedWin32EventsMixin(object): """ This mixin implements L{IReactorWin32Events} for another reactor by running a L{Win32Reactor} in a separate thread and dispatching work to it. @ivar _reactor: The L{Win32Reactor} running in the other thread. This is C{None} until it is actually needed. @ivar _reactorThread: The L{threading.Thread} which is running the L{Win32Reactor}. This is C{None} until it is actually needed. """ implements(IReactorWin32Events) _reactor = None _reactorThread = None def _unmakeHelperReactor(self): """ Stop and discard the reactor started by C{_makeHelperReactor}. """ self._reactor.callFromThread(self._reactor.stop) self._reactor = None def _makeHelperReactor(self): """ Create and (in a new thread) start a L{Win32Reactor} instance to use for the implementation of L{IReactorWin32Events}. """ self._reactor = Win32Reactor() # This is a helper reactor, it is not the global reactor and its thread # is not "the" I/O thread. Prevent it from registering it as such. self._reactor._registerAsIOThread = False self._reactorThread = Thread( target=self._reactor.run, args=(False,)) self.addSystemEventTrigger( 'after', 'shutdown', self._unmakeHelperReactor) self._reactorThread.start() def addEvent(self, event, fd, action): """ @see: L{IReactorWin32Events} """ if self._reactor is None: self._makeHelperReactor() self._reactor.callFromThread( self._reactor.addEvent, event, _ThreadFDWrapper(self, fd, action, fd.logPrefix()), "_execute") def removeEvent(self, event): """ @see: L{IReactorWin32Events} """ self._reactor.callFromThread(self._reactor.removeEvent, event) def install(): threadable.init(1) r = Win32Reactor() import main main.installReactor(r) __all__ = ["Win32Reactor", "install"]
mit
[ 3, 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 421, 199, 624, 199, 33, 4747, 708, 1430, 4079, 4514, 402, 314, 17078, 2446, 4438, 14, 199, 199, 2765, 5074, 1134, 2676, 708, 334, 8907, 590, 4747, 708, 452, 9, 503, 23241, 4718, 370, 506, 4903, 14, 199, 199, 1378, 3907, 314, 1566, 4438, 334, 460, 1265, 1077, 886, 642, 2544, 1263, 6947, 12, 199, 17301, 503, 4907, 1384, 787, 3483, 304, 26, 339, 687, 7390, 14, 4901, 492, 4747, 708, 1430, 13544, 272, 4747, 708, 1430, 13544, 14, 3174, 342, 199, 199, 13387, 12969, 26, 199, 413, 14, 13144, 1858, 8433, 11188, 436, 12850, 314, 1566, 4438, 883, 1454, 2429, 5049, 2251, 14, 199, 499, 14, 7132, 3879, 965, 2005, 8826, 334, 3239, 491, 91, 3498, 93, 9214, 680, 421, 199, 11768, 26, 199, 413, 14, 6763, 4438, 7252, 402, 14511, 365, 627, 2588, 10, 557, 31197, 334, 3749, 365, 25498, 3405, 2295, 680, 272, 17711, 370, 9689, 652, 314, 3211, 4340, 12, 15685, 626, 4910, 334, 3239, 5084, 680, 199, 499, 14, 14402, 284, 346, 89, 2838, 4438, 894, 336, 12630, 543, 1566, 4079, 336, 12630, 334, 1180, 7283, 2390, 909, 9, 199, 650, 14, 17711, 4036, 368, 370, 1808, 2868, 2290, 880, 781, 2793, 1133, 1172, 370, 7962, 543, 557, 1359, 386, 695, 15913, 14, 421, 199, 748, 7689, 14277, 17524, 934, 2823, 26, 199, 446, 473, 3927, 35, 12, 18772, 883, 1454, 506, 7264, 5403, 14, 2002, 781, 6258, 370, 282, 5523, 2043, 2839, 314, 11271, 342, 9655, 12, 12850, 17266, 2739, 370, 7962, 543, 2218, 4474, 315, 2043, 282, 477, 2946, 32285, 14, 961, 1077, 2040, 2739, 370, 986, 2295, 12, 1325, 781, 3984, 5139, 2043, 13988, 370, 5049, 4474, 14, 199, 199, 2844, 26, 421, 446, 15345, 402, 9689, 282, 9655, 12, 781, 1852, 642, 376, 13553, 370, 314, 3504, 9655, 14, 2043, 710, 644, 38, 2679, 1566, 4438, 7858, 315, 282, 7396, 2462, 14, 961, 4910, 949, 1929, 370, 11075, 2043, 7396, 1233, 367, 2784, 316, 12, 5049, 1566, 2304, 3181, 1133, 4838, 370, 18772, 12, 2043, 781, 883, 1255, 10358, 436, 1163, 4747, 708, 8292, 315, 849, 1566, 4438, 14, 710, 2043, 1454, 5160, 365, 626, 781, 3984, 410, 10112, 543, 314, 284, 346, 89, 2838, 4079, 336, 12630, 14, 2043, 22604, 22477, 3269, 365, 626, 642, 4293, 506, 9243, 370, 2291, 690, 772, 4474, 2043, 315, 282, 28293, 30800, 2419, 314, 4136, 8744, 14, 199, 199, 1918, 499, 977, 8744, 365, 8646, 4052, 911, 664, 6366, 14, 199, 624, 199, 199, 3, 6187, 8925, 199, 646, 900, 199, 646, 984, 199, 504, 5796, 492, 11086, 199, 504, 13852, 492, 28224, 1197, 11728, 199, 199, 504, 20110, 14, 3266, 492, 9031, 199, 199, 3, 13036, 708, 8925, 199, 504, 4747, 708, 493, 492, 481, 36, 63, 5670, 12, 481, 36, 63, 18219, 12, 481, 36, 63, 13089, 12, 481, 36, 63, 14657, 12, 644, 4251, 2390, 5446, 199, 893, 26, 272, 327, 644, 4251, 5081, 4491, 11770, 1990, 3483, 315, 1134, 2676, 708, 28436, 272, 687, 4747, 708, 493, 492, 644, 4251, 5081, 4491, 11770, 199, 2590, 3545, 26, 272, 492, 3598, 272, 3598, 14, 4050, 8, 267, 283, 497, 317, 461, 2153, 2105, 6955, 5074, 1134, 2676, 708, 28436, 503, 2945, 297, 267, 4637, 29, 32114, 9, 272, 347, 644, 4251, 5081, 4491, 11770, 8, 2592, 12, 1566, 304, 267, 372, 663, 779, 7902, 63, 5670, 566, 199, 199, 504, 4747, 708, 1430, 492, 2790, 2390, 12, 603, 1226, 21433, 8433, 11188, 199, 504, 4747, 708, 1430, 492, 644, 33, 649, 63, 9868, 63, 16, 12, 644, 33, 649, 63, 8899, 12, 1413, 51, 63, 1761, 7321, 12, 1413, 51, 63, 748, 906, 4554, 51, 199, 199, 646, 4747, 708, 5885, 199, 199, 3, 17078, 8925, 199, 504, 7390, 14, 4901, 492, 10694, 1095, 199, 504, 7390, 14, 1548, 492, 943, 12, 2462, 461, 12, 5988, 199, 504, 7390, 14, 4901, 14, 7436, 492, 473, 15860, 7902, 1084, 199, 504, 7390, 14, 4901, 14, 7436, 492, 473, 15860, 8886, 708, 11770, 199, 504, 7390, 14, 4901, 14, 6962, 492, 14592, 2176, 2532, 4436, 421, 199, 533, 13036, 708, 15860, 8, 9228, 1095, 14, 1575, 4174, 15860, 1563, 304, 272, 408, 272, 799, 5021, 626, 4440, 13036, 708, 1566, 15913, 14, 339, 768, 7725, 485, 15656, 26, 437, 2600, 4412, 491, 91, 23859, 93, 4454, 370, 282, 267, 4747, 708, 1566, 909, 1202, 370, 1104, 367, 1586, 4474, 367, 626, 5872, 14, 339, 768, 7725, 485, 16334, 26, 437, 2600, 4412, 491, 91, 23859, 93, 4454, 370, 282, 267, 9697, 574, 14, 221, 17276, 315, 642, 2600, 911, 506, 1627, 282, 22044, 370, 267, 2218, 734, 3932, 666, 14, 339, 768, 7725, 485, 4368, 26, 437, 2600, 4412, 4747, 708, 1566, 909, 370, 6346, 402, 267, 491, 91, 23859, 93, 4454, 436, 1566, 27996, 14, 339, 768, 7725, 485, 5938, 3325, 20568, 26, 437, 2809, 543, 445, 26975, 5938, 3325, 1763, 20568, 1386, 18578, 4426, 402, 267, 15428, 1314, 1172, 10530, 4002, 6955, 28218, 687, 314, 4403, 1325, 267, 1314, 781, 1172, 440, 9158, 7664, 666, 687, 14, 221, 603, 1226, 21433, 8433, 11188, 267, 911, 1454, 28503, 4002, 6955, 370, 2739, 5403, 12, 880, 781, 21027, 652, 315, 267, 3520, 2877, 11196, 5133, 781, 3984, 10144, 370, 2454, 641, 652, 14, 221, 710, 4403, 965, 267, 28218, 4002, 6955, 367, 1924, 5872, 315, 642, 2600, 12, 436, 267, 314, 15428, 787, 11584, 465, 4370, 370, 2429, 1586, 4474, 315, 314, 267, 9655, 12, 880, 2985, 883, 506, 7686, 14, 221, 3979, 282, 5872, 365, 11584, 465, 440, 267, 4370, 370, 2429, 1586, 4474, 315, 314, 9655, 334, 1873, 12, 652, 365, 3032, 370, 267, 491, 91, 30861, 7902, 1084, 14, 2168, 5929, 8688, 652, 365, 12155, 734, 402, 642, 2600, 436, 267, 1901, 445, 26975, 5938, 3325, 1763, 20568, 5565, 221, 710, 15428, 787, 2883, 315, 642, 267, 2600, 14, 221, 710, 1338, 787, 9697, 14, 272, 768, 466, 485, 5938, 3325, 20568, 26, 445, 91, 807, 93, 339, 768, 7725, 485, 5938, 3325, 1763, 20568, 26, 5723, 15428, 1172, 10530, 4002, 6955, 267, 28218, 687, 314, 4403, 12 ]
[ 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 421, 199, 624, 199, 33, 4747, 708, 1430, 4079, 4514, 402, 314, 17078, 2446, 4438, 14, 199, 199, 2765, 5074, 1134, 2676, 708, 334, 8907, 590, 4747, 708, 452, 9, 503, 23241, 4718, 370, 506, 4903, 14, 199, 199, 1378, 3907, 314, 1566, 4438, 334, 460, 1265, 1077, 886, 642, 2544, 1263, 6947, 12, 199, 17301, 503, 4907, 1384, 787, 3483, 304, 26, 339, 687, 7390, 14, 4901, 492, 4747, 708, 1430, 13544, 272, 4747, 708, 1430, 13544, 14, 3174, 342, 199, 199, 13387, 12969, 26, 199, 413, 14, 13144, 1858, 8433, 11188, 436, 12850, 314, 1566, 4438, 883, 1454, 2429, 5049, 2251, 14, 199, 499, 14, 7132, 3879, 965, 2005, 8826, 334, 3239, 491, 91, 3498, 93, 9214, 680, 421, 199, 11768, 26, 199, 413, 14, 6763, 4438, 7252, 402, 14511, 365, 627, 2588, 10, 557, 31197, 334, 3749, 365, 25498, 3405, 2295, 680, 272, 17711, 370, 9689, 652, 314, 3211, 4340, 12, 15685, 626, 4910, 334, 3239, 5084, 680, 199, 499, 14, 14402, 284, 346, 89, 2838, 4438, 894, 336, 12630, 543, 1566, 4079, 336, 12630, 334, 1180, 7283, 2390, 909, 9, 199, 650, 14, 17711, 4036, 368, 370, 1808, 2868, 2290, 880, 781, 2793, 1133, 1172, 370, 7962, 543, 557, 1359, 386, 695, 15913, 14, 421, 199, 748, 7689, 14277, 17524, 934, 2823, 26, 199, 446, 473, 3927, 35, 12, 18772, 883, 1454, 506, 7264, 5403, 14, 2002, 781, 6258, 370, 282, 5523, 2043, 2839, 314, 11271, 342, 9655, 12, 12850, 17266, 2739, 370, 7962, 543, 2218, 4474, 315, 2043, 282, 477, 2946, 32285, 14, 961, 1077, 2040, 2739, 370, 986, 2295, 12, 1325, 781, 3984, 5139, 2043, 13988, 370, 5049, 4474, 14, 199, 199, 2844, 26, 421, 446, 15345, 402, 9689, 282, 9655, 12, 781, 1852, 642, 376, 13553, 370, 314, 3504, 9655, 14, 2043, 710, 644, 38, 2679, 1566, 4438, 7858, 315, 282, 7396, 2462, 14, 961, 4910, 949, 1929, 370, 11075, 2043, 7396, 1233, 367, 2784, 316, 12, 5049, 1566, 2304, 3181, 1133, 4838, 370, 18772, 12, 2043, 781, 883, 1255, 10358, 436, 1163, 4747, 708, 8292, 315, 849, 1566, 4438, 14, 710, 2043, 1454, 5160, 365, 626, 781, 3984, 410, 10112, 543, 314, 284, 346, 89, 2838, 4079, 336, 12630, 14, 2043, 22604, 22477, 3269, 365, 626, 642, 4293, 506, 9243, 370, 2291, 690, 772, 4474, 2043, 315, 282, 28293, 30800, 2419, 314, 4136, 8744, 14, 199, 199, 1918, 499, 977, 8744, 365, 8646, 4052, 911, 664, 6366, 14, 199, 624, 199, 199, 3, 6187, 8925, 199, 646, 900, 199, 646, 984, 199, 504, 5796, 492, 11086, 199, 504, 13852, 492, 28224, 1197, 11728, 199, 199, 504, 20110, 14, 3266, 492, 9031, 199, 199, 3, 13036, 708, 8925, 199, 504, 4747, 708, 493, 492, 481, 36, 63, 5670, 12, 481, 36, 63, 18219, 12, 481, 36, 63, 13089, 12, 481, 36, 63, 14657, 12, 644, 4251, 2390, 5446, 199, 893, 26, 272, 327, 644, 4251, 5081, 4491, 11770, 1990, 3483, 315, 1134, 2676, 708, 28436, 272, 687, 4747, 708, 493, 492, 644, 4251, 5081, 4491, 11770, 199, 2590, 3545, 26, 272, 492, 3598, 272, 3598, 14, 4050, 8, 267, 283, 497, 317, 461, 2153, 2105, 6955, 5074, 1134, 2676, 708, 28436, 503, 2945, 297, 267, 4637, 29, 32114, 9, 272, 347, 644, 4251, 5081, 4491, 11770, 8, 2592, 12, 1566, 304, 267, 372, 663, 779, 7902, 63, 5670, 566, 199, 199, 504, 4747, 708, 1430, 492, 2790, 2390, 12, 603, 1226, 21433, 8433, 11188, 199, 504, 4747, 708, 1430, 492, 644, 33, 649, 63, 9868, 63, 16, 12, 644, 33, 649, 63, 8899, 12, 1413, 51, 63, 1761, 7321, 12, 1413, 51, 63, 748, 906, 4554, 51, 199, 199, 646, 4747, 708, 5885, 199, 199, 3, 17078, 8925, 199, 504, 7390, 14, 4901, 492, 10694, 1095, 199, 504, 7390, 14, 1548, 492, 943, 12, 2462, 461, 12, 5988, 199, 504, 7390, 14, 4901, 14, 7436, 492, 473, 15860, 7902, 1084, 199, 504, 7390, 14, 4901, 14, 7436, 492, 473, 15860, 8886, 708, 11770, 199, 504, 7390, 14, 4901, 14, 6962, 492, 14592, 2176, 2532, 4436, 421, 199, 533, 13036, 708, 15860, 8, 9228, 1095, 14, 1575, 4174, 15860, 1563, 304, 272, 408, 272, 799, 5021, 626, 4440, 13036, 708, 1566, 15913, 14, 339, 768, 7725, 485, 15656, 26, 437, 2600, 4412, 491, 91, 23859, 93, 4454, 370, 282, 267, 4747, 708, 1566, 909, 1202, 370, 1104, 367, 1586, 4474, 367, 626, 5872, 14, 339, 768, 7725, 485, 16334, 26, 437, 2600, 4412, 491, 91, 23859, 93, 4454, 370, 282, 267, 9697, 574, 14, 221, 17276, 315, 642, 2600, 911, 506, 1627, 282, 22044, 370, 267, 2218, 734, 3932, 666, 14, 339, 768, 7725, 485, 4368, 26, 437, 2600, 4412, 4747, 708, 1566, 909, 370, 6346, 402, 267, 491, 91, 23859, 93, 4454, 436, 1566, 27996, 14, 339, 768, 7725, 485, 5938, 3325, 20568, 26, 437, 2809, 543, 445, 26975, 5938, 3325, 1763, 20568, 1386, 18578, 4426, 402, 267, 15428, 1314, 1172, 10530, 4002, 6955, 28218, 687, 314, 4403, 1325, 267, 1314, 781, 1172, 440, 9158, 7664, 666, 687, 14, 221, 603, 1226, 21433, 8433, 11188, 267, 911, 1454, 28503, 4002, 6955, 370, 2739, 5403, 12, 880, 781, 21027, 652, 315, 267, 3520, 2877, 11196, 5133, 781, 3984, 10144, 370, 2454, 641, 652, 14, 221, 710, 4403, 965, 267, 28218, 4002, 6955, 367, 1924, 5872, 315, 642, 2600, 12, 436, 267, 314, 15428, 787, 11584, 465, 4370, 370, 2429, 1586, 4474, 315, 314, 267, 9655, 12, 880, 2985, 883, 506, 7686, 14, 221, 3979, 282, 5872, 365, 11584, 465, 440, 267, 4370, 370, 2429, 1586, 4474, 315, 314, 9655, 334, 1873, 12, 652, 365, 3032, 370, 267, 491, 91, 30861, 7902, 1084, 14, 2168, 5929, 8688, 652, 365, 12155, 734, 402, 642, 2600, 436, 267, 1901, 445, 26975, 5938, 3325, 1763, 20568, 5565, 221, 710, 15428, 787, 2883, 315, 642, 267, 2600, 14, 221, 710, 1338, 787, 9697, 14, 272, 768, 466, 485, 5938, 3325, 20568, 26, 445, 91, 807, 93, 339, 768, 7725, 485, 5938, 3325,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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 ]
felipenaselva/felipe.repository
script.module.universalscrapers/lib/universalscrapers/dialogs.py
9
8391
from threading import Thread, RLock import xbmc import xbmcaddon import xbmcgui def select_ext(title, populator, tasks_count, sort_function = None): addonPath = xbmcaddon.Addon().getAddonInfo('path').decode('utf-8') dlg = SelectorDialog("DialogSelect.xml", addonPath, title=title, populator=populator, steps=tasks_count, sort_function=sort_function) with ExtendedDialogHacks(): dlg.doModal() selection = dlg.get_selection() items = dlg.items del dlg return (selection, items) class FanArtWindow(xbmcgui.WindowDialog): def __init__(self): control_background = xbmcgui.ControlImage(0, 0, 1280, 720, xbmcaddon.Addon().getAddonInfo('fanart')) self.addControl(control_background) fanart = xbmc.getInfoLabel('ListItem.Property(Fanart_Image)') if fanart and fanart != "Fanart_Image": control_fanart = xbmcgui.ControlImage(0, 0, 1280, 720, fanart) self.addControl(control_fanart) class ExtendedDialogHacks(object): def __init__(self): self.active = False self.hide_progress = False self.hide_info = False self.autohidedialogs = False if self.autohidedialogs: self.hide_progress = False self.hide_info = False if not self.hide_progress and not self.hide_info: self.autohidedialogs = False def __enter__(self): self.active = True # self.numeric_keyboard = None self.fanart_window = FanArtWindow() ## Keyboard hack # if plugin.get_setting(SETTING_ADVANCED_KEYBOARD_HACKS, converter=bool): # self.numeric_keyboard = xbmcgui.Window(10109) # Thread(target = lambda: self.numeric_keyboard.show()).start() # wait_for_dialog('numericinput', interval=50) # Show fanart background self.fanart_window.show() # Run background task if self.autohidedialogs: Thread(target=self.background_task).start() def background_task(self): xbmc.sleep(1000) while not xbmc.abortRequested and self.active: if self.hide_progress: active_window = xbmcgui.getCurrentWindowDialogId() if active_window in [10101, 10151]: xbmc.executebuiltin("Dialog.Close(%d, true)" % active_window) if self.hide_info: if xbmc.getCondVisibility("Window.IsActive(infodialog)"): xbmc.executebuiltin('Dialog.Close(infodialog, true)') xbmc.sleep(100) def __exit__(self, exc_type, exc_value, traceback): self.active = False # if self.numeric_keyboard is not None: # self.numeric_keyboard.close() # del self.numeric_keyboard # xbmc.executebuiltin("Dialog.Close(numericinput, true)") self.fanart_window.close() del self.fanart_window class SelectorDialog(xbmcgui.WindowXMLDialog): def __init__(self, *args, **kwargs): xbmcgui.WindowXMLDialog.__init__(self) self.title = kwargs['title'] self.populator = kwargs['populator'] self.steps = kwargs['steps'] self.sort_function = kwargs['sort_function'] self.items = [] self.selection = None self.insideIndex = -1 self.completed_steps = 0 self.thread = None self.lock = RLock() def get_selection(self): """ get final selection """ return self.selection def onInit(self): # set title self.label = self.getControl(1) self.label.setLabel(self.title) # Hide ok button self.getControl(5).setVisible(False) # Get active list try: self.list = self.getControl(6) self.list.controlLeft(self.list) self.list.controlRight(self.list) self.getControl(3).setVisible(False) except: self.list = self.getControl(3) self.setFocus(self.list) # populate list self.thread = Thread(target=self._populate) self.thread.start() def onAction(self, action): if action.getId() in (9, 10, 92, 216, 247, 257, 275, 61467, 61448,): if self.insideIndex == -1: self.close() else: self._inside_root(select=self.insideIndex) def onClick(self, controlID): if controlID == 6 or controlID == 3: num = self.list.getSelectedPosition() if num >= 0: if self.insideIndex == -1: self._inside(num) else: self.selection = self.items[self.insideIndex][1][num] self.close() def onFocus(self, controlID): if controlID in (3, 61): self.setFocus(self.list) def _inside_root(self, select=-1): with self.lock: self.list.reset() for source, links in self.items: if len(links) > 1: source += " >>" listitem = xbmcgui.ListItem(source) try: #icon = xbmcaddon.Addon(id=links[0]['path'].split("/")[2]).getAddonInfo('icon') icon = xbmcaddon.Addon().getAddonInfo('icon') listitem.setIconImage(icon) except: pass self.list.addItem(listitem) if select >= 0: self.list.selectItem(select) self.insideIndex = -1 def _inside(self, num): if num == -1: self._inside_root(select=self.insideIndex) return with self.lock: source, links = self.items[num] if len(links) == 1: self.selection = links[0] self.close() return self.list.reset() for item in links: listitem = xbmcgui.ListItem(item['label']) #listitem.setProperty("Path", item['path']) try: #pluginid = item['path'].split("/")[2] icon = xbmcaddon.Addon().getAddonInfo('icon') listitem.setIconImage(icon) except: pass self.list.addItem(listitem) self.insideIndex = num def step(self): self.completed_steps += 1 progress = self.completed_steps * 100 / self.steps self.label.setLabel(u"{0} - {1:d}% ({2}/{3})".format(self.title, progress, self.completed_steps, self.steps)) def _populate(self): xbmc.sleep(500) # Delay population to let ui settle self.label.setLabel(self.title) try: for result in self.populator(): self.step() if not result: continue with self.lock: # Remember selected item selectedItem = None if self.insideIndex == -1: selectedIndex = self.list.getSelectedPosition() else: selectedIndex = self.insideIndex if selectedIndex >= 0: selectedItem = self.items[selectedIndex] # Add new item self.items.extend(result) if self.sort_function: self.items = sorted(self.items, key = self.sort_function) #self.items.sort() # Retrived new selection-index if selectedItem is not None: selectedIndex = self.items.index(selectedItem) if self.insideIndex != -1: self.insideIndex = selectedIndex # Update only if in root if self.insideIndex == -1: self._inside_root(select=selectedIndex) self.setFocus(self.list) except: self.label.setLabel( u"{0} - {1:d}% ({2}/{3})".format(self.title, 100, self.steps, self.steps)) pass
gpl-2.0
[ 504, 5796, 492, 11086, 12, 820, 6432, 199, 199, 646, 11709, 199, 646, 11709, 9291, 199, 646, 26418, 421, 199, 318, 3504, 63, 832, 8, 1213, 12, 4560, 6109, 12, 6527, 63, 835, 12, 4069, 63, 1593, 275, 488, 304, 272, 13553, 2042, 275, 11709, 9291, 14, 19654, 1252, 362, 19654, 2354, 360, 515, 1959, 2708, 360, 1624, 13, 24, 358, 272, 19406, 275, 3240, 3283, 5619, 480, 5619, 5446, 14, 1652, 401, 13553, 2042, 12, 2538, 29, 1213, 12, 586, 4560, 6109, 29, 1935, 6109, 12, 7124, 29, 5054, 63, 835, 12, 4069, 63, 1593, 29, 3191, 63, 1593, 9, 339, 543, 13706, 5619, 40, 564, 83, 837, 267, 19406, 14, 1117, 23689, 342, 267, 7267, 275, 19406, 14, 362, 63, 5592, 342, 267, 2974, 275, 19406, 14, 1744, 267, 2150, 19406, 339, 372, 334, 5592, 12, 2974, 9, 421, 199, 533, 481, 290, 28922, 4301, 8, 21382, 5885, 14, 4301, 5619, 304, 272, 347, 636, 826, 721, 277, 304, 267, 3304, 63, 7451, 275, 26418, 14, 3717, 3491, 8, 16, 12, 378, 12, 3144, 1257, 12, 29692, 12, 11709, 9291, 14, 19654, 1252, 362, 19654, 2354, 360, 24138, 1333, 267, 291, 14, 525, 3717, 8, 2785, 63, 7451, 9, 398, 19892, 275, 11709, 14, 362, 2354, 4314, 360, 24229, 14, 3697, 8, 29745, 580, 63, 3491, 5942, 267, 340, 19892, 436, 19892, 1137, 298, 29745, 580, 63, 3491, 582, 288, 3304, 63, 24138, 275, 26418, 14, 3717, 3491, 8, 16, 12, 378, 12, 3144, 1257, 12, 29692, 12, 19892, 9, 288, 291, 14, 525, 3717, 8, 2785, 63, 24138, 9, 421, 199, 533, 13706, 5619, 40, 564, 83, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2682, 275, 756, 398, 291, 14, 8191, 63, 5734, 275, 756, 267, 291, 14, 8191, 63, 815, 275, 756, 398, 291, 14, 2495, 8191, 328, 18238, 275, 756, 267, 340, 291, 14, 2495, 8191, 328, 18238, 26, 288, 291, 14, 8191, 63, 5734, 275, 756, 288, 291, 14, 8191, 63, 815, 275, 756, 398, 340, 440, 291, 14, 8191, 63, 5734, 436, 440, 291, 14, 8191, 63, 815, 26, 288, 291, 14, 2495, 8191, 328, 18238, 275, 756, 339, 347, 636, 4200, 721, 277, 304, 267, 291, 14, 2682, 275, 715, 398, 327, 263, 291, 14, 6677, 63, 19553, 275, 488, 267, 291, 14, 24138, 63, 3806, 275, 481, 290, 28922, 4301, 342, 398, 925, 2606, 3576, 11176, 267, 327, 263, 340, 3589, 14, 362, 63, 6031, 8, 12490, 1206, 63, 1554, 54, 879, 25927, 63, 3078, 23368, 63, 40, 3099, 51, 12, 11109, 29, 2245, 304, 267, 327, 3322, 291, 14, 6677, 63, 19553, 275, 26418, 14, 4301, 8, 4893, 1643, 9, 267, 327, 3322, 11086, 8, 1375, 275, 2400, 26, 291, 14, 6677, 63, 19553, 14, 2384, 8801, 928, 342, 267, 327, 3322, 3618, 63, 509, 63, 7196, 360, 6677, 1210, 297, 6252, 29, 1400, 9, 398, 327, 12968, 19892, 8020, 267, 291, 14, 24138, 63, 3806, 14, 2384, 342, 398, 327, 3378, 8020, 2120, 267, 340, 291, 14, 2495, 8191, 328, 18238, 26, 288, 11086, 8, 1375, 29, 277, 14, 7451, 63, 1765, 680, 928, 342, 339, 347, 8020, 63, 1765, 8, 277, 304, 267, 11709, 14, 4532, 8, 5279, 9, 267, 1830, 440, 11709, 14, 13845, 17935, 436, 291, 14, 2682, 26, 288, 340, 291, 14, 8191, 63, 5734, 26, 355, 4702, 63, 3806, 275, 26418, 14, 16662, 4301, 5619, 1304, 342, 355, 340, 4702, 63, 3806, 315, 359, 4893, 614, 12, 14313, 2869, 2189, 490, 11709, 14, 2526, 5351, 480, 5619, 14, 4724, 4042, 68, 12, 2549, 2924, 450, 4702, 63, 3806, 9, 288, 340, 291, 14, 8191, 63, 815, 26, 355, 340, 11709, 14, 362, 23735, 24735, 480, 4301, 14, 1831, 7472, 8, 815, 7196, 9, 2349, 490, 11709, 14, 2526, 5351, 360, 5619, 14, 4724, 8, 815, 7196, 12, 2549, 5942, 288, 11709, 14, 4532, 8, 1960, 9, 339, 347, 636, 2224, 721, 277, 12, 3178, 63, 466, 12, 3178, 63, 585, 12, 5190, 304, 267, 291, 14, 2682, 275, 756, 398, 327, 263, 340, 291, 14, 6677, 63, 19553, 365, 440, 488, 26, 267, 327, 3322, 291, 14, 6677, 63, 19553, 14, 1600, 342, 267, 327, 3322, 2150, 291, 14, 6677, 63, 19553, 267, 327, 3322, 11709, 14, 2526, 5351, 480, 5619, 14, 4724, 8, 6677, 1210, 12, 2549, 6320, 398, 291, 14, 24138, 63, 3806, 14, 1600, 342, 267, 2150, 291, 14, 24138, 63, 3806, 421, 199, 533, 3240, 3283, 5619, 8, 21382, 5885, 14, 4301, 4317, 5619, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 26418, 14, 4301, 4317, 5619, 855, 826, 721, 277, 9, 267, 291, 14, 1213, 275, 2074, 459, 1213, 418, 267, 291, 14, 1935, 6109, 275, 2074, 459, 1935, 6109, 418, 267, 291, 14, 5895, 275, 2074, 459, 5895, 418, 267, 291, 14, 3191, 63, 1593, 275, 2074, 459, 3191, 63, 1593, 418, 398, 291, 14, 1744, 275, 942, 267, 291, 14, 5592, 275, 488, 267, 291, 14, 17183, 2681, 275, 446, 17, 267, 291, 14, 12634, 63, 5895, 275, 378, 398, 291, 14, 2671, 275, 488, 267, 291, 14, 831, 275, 820, 6432, 342, 339, 347, 664, 63, 5592, 8, 277, 304, 267, 408, 664, 4242, 7267, 408, 267, 372, 291, 14, 5592, 339, 347, 641, 9346, 8, 277, 304, 267, 327, 663, 2538, 267, 291, 14, 1302, 275, 291, 14, 25117, 8, 17, 9, 267, 291, 14, 1302, 14, 409, 4314, 8, 277, 14, 1213, 9, 398, 327, 869, 2655, 4112, 5528, 267, 291, 14, 25117, 8, 21, 680, 32232, 8, 797, 9, 398, 327, 2372, 4702, 769, 267, 862, 26, 288, 291, 14, 513, 275, 291, 14, 25117, 8, 22, 9, 288, 291, 14, 513, 14, 2785, 8185, 8, 277, 14, 513, 9, 288, 291, 14, 513, 14, 2785, 9121, 8, 277, 14, 513, 9, 288, 291, 14, 25117, 8, 19, 680, 32232, 8, 797, 9, 267, 871, 26, 288, 291, 14, 513, 275, 291, 14, 25117, 8, 19, 9, 267, 291, 14, 409, 17310, 8, 277, 14, 513, 9, 398, 327, 13904, 769, 267, 291, 14, 2671, 275, 11086, 8, 1375, 29, 277, 423, 13817, 9 ]
[ 5796, 492, 11086, 12, 820, 6432, 199, 199, 646, 11709, 199, 646, 11709, 9291, 199, 646, 26418, 421, 199, 318, 3504, 63, 832, 8, 1213, 12, 4560, 6109, 12, 6527, 63, 835, 12, 4069, 63, 1593, 275, 488, 304, 272, 13553, 2042, 275, 11709, 9291, 14, 19654, 1252, 362, 19654, 2354, 360, 515, 1959, 2708, 360, 1624, 13, 24, 358, 272, 19406, 275, 3240, 3283, 5619, 480, 5619, 5446, 14, 1652, 401, 13553, 2042, 12, 2538, 29, 1213, 12, 586, 4560, 6109, 29, 1935, 6109, 12, 7124, 29, 5054, 63, 835, 12, 4069, 63, 1593, 29, 3191, 63, 1593, 9, 339, 543, 13706, 5619, 40, 564, 83, 837, 267, 19406, 14, 1117, 23689, 342, 267, 7267, 275, 19406, 14, 362, 63, 5592, 342, 267, 2974, 275, 19406, 14, 1744, 267, 2150, 19406, 339, 372, 334, 5592, 12, 2974, 9, 421, 199, 533, 481, 290, 28922, 4301, 8, 21382, 5885, 14, 4301, 5619, 304, 272, 347, 636, 826, 721, 277, 304, 267, 3304, 63, 7451, 275, 26418, 14, 3717, 3491, 8, 16, 12, 378, 12, 3144, 1257, 12, 29692, 12, 11709, 9291, 14, 19654, 1252, 362, 19654, 2354, 360, 24138, 1333, 267, 291, 14, 525, 3717, 8, 2785, 63, 7451, 9, 398, 19892, 275, 11709, 14, 362, 2354, 4314, 360, 24229, 14, 3697, 8, 29745, 580, 63, 3491, 5942, 267, 340, 19892, 436, 19892, 1137, 298, 29745, 580, 63, 3491, 582, 288, 3304, 63, 24138, 275, 26418, 14, 3717, 3491, 8, 16, 12, 378, 12, 3144, 1257, 12, 29692, 12, 19892, 9, 288, 291, 14, 525, 3717, 8, 2785, 63, 24138, 9, 421, 199, 533, 13706, 5619, 40, 564, 83, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2682, 275, 756, 398, 291, 14, 8191, 63, 5734, 275, 756, 267, 291, 14, 8191, 63, 815, 275, 756, 398, 291, 14, 2495, 8191, 328, 18238, 275, 756, 267, 340, 291, 14, 2495, 8191, 328, 18238, 26, 288, 291, 14, 8191, 63, 5734, 275, 756, 288, 291, 14, 8191, 63, 815, 275, 756, 398, 340, 440, 291, 14, 8191, 63, 5734, 436, 440, 291, 14, 8191, 63, 815, 26, 288, 291, 14, 2495, 8191, 328, 18238, 275, 756, 339, 347, 636, 4200, 721, 277, 304, 267, 291, 14, 2682, 275, 715, 398, 327, 263, 291, 14, 6677, 63, 19553, 275, 488, 267, 291, 14, 24138, 63, 3806, 275, 481, 290, 28922, 4301, 342, 398, 925, 2606, 3576, 11176, 267, 327, 263, 340, 3589, 14, 362, 63, 6031, 8, 12490, 1206, 63, 1554, 54, 879, 25927, 63, 3078, 23368, 63, 40, 3099, 51, 12, 11109, 29, 2245, 304, 267, 327, 3322, 291, 14, 6677, 63, 19553, 275, 26418, 14, 4301, 8, 4893, 1643, 9, 267, 327, 3322, 11086, 8, 1375, 275, 2400, 26, 291, 14, 6677, 63, 19553, 14, 2384, 8801, 928, 342, 267, 327, 3322, 3618, 63, 509, 63, 7196, 360, 6677, 1210, 297, 6252, 29, 1400, 9, 398, 327, 12968, 19892, 8020, 267, 291, 14, 24138, 63, 3806, 14, 2384, 342, 398, 327, 3378, 8020, 2120, 267, 340, 291, 14, 2495, 8191, 328, 18238, 26, 288, 11086, 8, 1375, 29, 277, 14, 7451, 63, 1765, 680, 928, 342, 339, 347, 8020, 63, 1765, 8, 277, 304, 267, 11709, 14, 4532, 8, 5279, 9, 267, 1830, 440, 11709, 14, 13845, 17935, 436, 291, 14, 2682, 26, 288, 340, 291, 14, 8191, 63, 5734, 26, 355, 4702, 63, 3806, 275, 26418, 14, 16662, 4301, 5619, 1304, 342, 355, 340, 4702, 63, 3806, 315, 359, 4893, 614, 12, 14313, 2869, 2189, 490, 11709, 14, 2526, 5351, 480, 5619, 14, 4724, 4042, 68, 12, 2549, 2924, 450, 4702, 63, 3806, 9, 288, 340, 291, 14, 8191, 63, 815, 26, 355, 340, 11709, 14, 362, 23735, 24735, 480, 4301, 14, 1831, 7472, 8, 815, 7196, 9, 2349, 490, 11709, 14, 2526, 5351, 360, 5619, 14, 4724, 8, 815, 7196, 12, 2549, 5942, 288, 11709, 14, 4532, 8, 1960, 9, 339, 347, 636, 2224, 721, 277, 12, 3178, 63, 466, 12, 3178, 63, 585, 12, 5190, 304, 267, 291, 14, 2682, 275, 756, 398, 327, 263, 340, 291, 14, 6677, 63, 19553, 365, 440, 488, 26, 267, 327, 3322, 291, 14, 6677, 63, 19553, 14, 1600, 342, 267, 327, 3322, 2150, 291, 14, 6677, 63, 19553, 267, 327, 3322, 11709, 14, 2526, 5351, 480, 5619, 14, 4724, 8, 6677, 1210, 12, 2549, 6320, 398, 291, 14, 24138, 63, 3806, 14, 1600, 342, 267, 2150, 291, 14, 24138, 63, 3806, 421, 199, 533, 3240, 3283, 5619, 8, 21382, 5885, 14, 4301, 4317, 5619, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 26418, 14, 4301, 4317, 5619, 855, 826, 721, 277, 9, 267, 291, 14, 1213, 275, 2074, 459, 1213, 418, 267, 291, 14, 1935, 6109, 275, 2074, 459, 1935, 6109, 418, 267, 291, 14, 5895, 275, 2074, 459, 5895, 418, 267, 291, 14, 3191, 63, 1593, 275, 2074, 459, 3191, 63, 1593, 418, 398, 291, 14, 1744, 275, 942, 267, 291, 14, 5592, 275, 488, 267, 291, 14, 17183, 2681, 275, 446, 17, 267, 291, 14, 12634, 63, 5895, 275, 378, 398, 291, 14, 2671, 275, 488, 267, 291, 14, 831, 275, 820, 6432, 342, 339, 347, 664, 63, 5592, 8, 277, 304, 267, 408, 664, 4242, 7267, 408, 267, 372, 291, 14, 5592, 339, 347, 641, 9346, 8, 277, 304, 267, 327, 663, 2538, 267, 291, 14, 1302, 275, 291, 14, 25117, 8, 17, 9, 267, 291, 14, 1302, 14, 409, 4314, 8, 277, 14, 1213, 9, 398, 327, 869, 2655, 4112, 5528, 267, 291, 14, 25117, 8, 21, 680, 32232, 8, 797, 9, 398, 327, 2372, 4702, 769, 267, 862, 26, 288, 291, 14, 513, 275, 291, 14, 25117, 8, 22, 9, 288, 291, 14, 513, 14, 2785, 8185, 8, 277, 14, 513, 9, 288, 291, 14, 513, 14, 2785, 9121, 8, 277, 14, 513, 9, 288, 291, 14, 25117, 8, 19, 680, 32232, 8, 797, 9, 267, 871, 26, 288, 291, 14, 513, 275, 291, 14, 25117, 8, 19, 9, 267, 291, 14, 409, 17310, 8, 277, 14, 513, 9, 398, 327, 13904, 769, 267, 291, 14, 2671, 275, 11086, 8, 1375, 29, 277, 423, 13817, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
WangWenjun559/Weiss
summary/sumy/sklearn/feature_selection/rfe.py
1
17079
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr> # Vincent Michel <vincent.michel@inria.fr> # Gilles Louppe <g.louppe@gmail.com> # # License: BSD 3 clause """Recursive feature elimination for feature ranking""" import warnings import numpy as np from ..utils import check_X_y, safe_sqr from ..utils.metaestimators import if_delegate_has_method from ..base import BaseEstimator from ..base import MetaEstimatorMixin from ..base import clone from ..base import is_classifier from ..cross_validation import _check_cv as check_cv from ..cross_validation import _safe_split, _score from ..metrics.scorer import check_scoring from .base import SelectorMixin class RFE(BaseEstimator, MetaEstimatorMixin, SelectorMixin): """Feature ranking with recursive feature elimination. Given an external estimator that assigns weights to features (e.g., the coefficients of a linear model), the goal of recursive feature elimination (RFE) is to select features by recursively considering smaller and smaller sets of features. First, the estimator is trained on the initial set of features and weights are assigned to each one of them. Then, features whose absolute weights are the smallest are pruned from the current set features. That procedure is recursively repeated on the pruned set until the desired number of features to select is eventually reached. Read more in the :ref:`User Guide <rfe>`. Parameters ---------- estimator : object A supervised learning estimator with a `fit` method that updates a `coef_` attribute that holds the fitted parameters. Important features must correspond to high absolute values in the `coef_` array. For instance, this is the case for most supervised learning algorithms such as Support Vector Classifiers and Generalized Linear Models from the `svm` and `linear_model` modules. n_features_to_select : int or None (default=None) The number of features to select. If `None`, half of the features are selected. step : int or float, optional (default=1) If greater than or equal to 1, then `step` corresponds to the (integer) number of features to remove at each iteration. If within (0.0, 1.0), then `step` corresponds to the percentage (rounded down) of features to remove at each iteration. estimator_params : dict Parameters for the external estimator. This attribute is deprecated as of version 0.16 and will be removed in 0.18. Use estimator initialisation or set_params method instead. verbose : int, default=0 Controls verbosity of output. Attributes ---------- n_features_ : int The number of selected features. support_ : array of shape [n_features] The mask of selected features. ranking_ : array of shape [n_features] The feature ranking, such that ``ranking_[i]`` corresponds to the ranking position of the i-th feature. Selected (i.e., estimated best) features are assigned rank 1. estimator_ : object The external estimator fit on the reduced dataset. Examples -------- The following example shows how to retrieve the 5 right informative features in the Friedman #1 dataset. >>> from sklearn.datasets import make_friedman1 >>> from sklearn.feature_selection import RFE >>> from sklearn.svm import SVR >>> X, y = make_friedman1(n_samples=50, n_features=10, random_state=0) >>> estimator = SVR(kernel="linear") >>> selector = RFE(estimator, 5, step=1) >>> selector = selector.fit(X, y) >>> selector.support_ # doctest: +NORMALIZE_WHITESPACE array([ True, True, True, True, True, False, False, False, False, False], dtype=bool) >>> selector.ranking_ array([1, 1, 1, 1, 1, 6, 4, 3, 2, 5]) References ---------- .. [1] Guyon, I., Weston, J., Barnhill, S., & Vapnik, V., "Gene selection for cancer classification using support vector machines", Mach. Learn., 46(1-3), 389--422, 2002. """ def __init__(self, estimator, n_features_to_select=None, step=1, estimator_params=None, verbose=0): self.estimator = estimator self.n_features_to_select = n_features_to_select self.step = step self.estimator_params = estimator_params self.verbose = verbose @property def _estimator_type(self): return self.estimator._estimator_type def fit(self, X, y): """Fit the RFE model and then the underlying estimator on the selected features. Parameters ---------- X : {array-like, sparse matrix}, shape = [n_samples, n_features] The training input samples. y : array-like, shape = [n_samples] The target values. """ return self._fit(X, y) def _fit(self, X, y, step_score=None): X, y = check_X_y(X, y, "csc") # Initialization n_features = X.shape[1] if self.n_features_to_select is None: n_features_to_select = n_features / 2 else: n_features_to_select = self.n_features_to_select if 0.0 < self.step < 1.0: step = int(max(1, self.step * n_features)) else: step = int(self.step) if step <= 0: raise ValueError("Step must be >0") if self.estimator_params is not None: warnings.warn("The parameter 'estimator_params' is deprecated as " "of version 0.16 and will be removed in 0.18. The " "parameter is no longer necessary because the value " "is set via the estimator initialisation or " "set_params method.", DeprecationWarning) support_ = np.ones(n_features, dtype=np.bool) ranking_ = np.ones(n_features, dtype=np.int) if step_score: self.scores_ = [] # Elimination while np.sum(support_) > n_features_to_select: # Remaining features features = np.arange(n_features)[support_] # Rank the remaining features estimator = clone(self.estimator) if self.estimator_params: estimator.set_params(**self.estimator_params) if self.verbose > 0: print("Fitting estimator with %d features." % np.sum(support_)) estimator.fit(X[:, features], y) # Get coefs if hasattr(estimator, 'coef_'): coefs = estimator.coef_ elif hasattr(estimator, 'feature_importances_'): coefs = estimator.feature_importances_ else: raise RuntimeError('The classifier does not expose ' '"coef_" or "feature_importances_" ' 'attributes') # Get ranks if coefs.ndim > 1: ranks = np.argsort(safe_sqr(coefs).sum(axis=0)) else: ranks = np.argsort(safe_sqr(coefs)) # for sparse case ranks is matrix ranks = np.ravel(ranks) # Eliminate the worse features threshold = min(step, np.sum(support_) - n_features_to_select) # Compute step score on the previous selection iteration # because 'estimator' must use features # that have not been eliminated yet if step_score: self.scores_.append(step_score(estimator, features)) support_[features[ranks][:threshold]] = False ranking_[np.logical_not(support_)] += 1 # Set final attributes features = np.arange(n_features)[support_] self.estimator_ = clone(self.estimator) if self.estimator_params: self.estimator_.set_params(**self.estimator_params) self.estimator_.fit(X[:, features], y) # Compute step score when only n_features_to_select features left if step_score: self.scores_.append(step_score(self.estimator_, features)) self.n_features_ = support_.sum() self.support_ = support_ self.ranking_ = ranking_ return self @if_delegate_has_method(delegate='estimator') def predict(self, X): """Reduce X to the selected features and then predict using the underlying estimator. Parameters ---------- X : array of shape [n_samples, n_features] The input samples. Returns ------- y : array of shape [n_samples] The predicted target values. """ return self.estimator_.predict(self.transform(X)) @if_delegate_has_method(delegate='estimator') def score(self, X, y): """Reduce X to the selected features and then return the score of the underlying estimator. Parameters ---------- X : array of shape [n_samples, n_features] The input samples. y : array of shape [n_samples] The target values. """ return self.estimator_.score(self.transform(X), y) def _get_support_mask(self): return self.support_ @if_delegate_has_method(delegate='estimator') def decision_function(self, X): return self.estimator_.decision_function(self.transform(X)) @if_delegate_has_method(delegate='estimator') def predict_proba(self, X): return self.estimator_.predict_proba(self.transform(X)) @if_delegate_has_method(delegate='estimator') def predict_log_proba(self, X): return self.estimator_.predict_log_proba(self.transform(X)) class RFECV(RFE, MetaEstimatorMixin): """Feature ranking with recursive feature elimination and cross-validated selection of the best number of features. Read more in the :ref:`User Guide <rfe>`. Parameters ---------- estimator : object A supervised learning estimator with a `fit` method that updates a `coef_` attribute that holds the fitted parameters. Important features must correspond to high absolute values in the `coef_` array. For instance, this is the case for most supervised learning algorithms such as Support Vector Classifiers and Generalized Linear Models from the `svm` and `linear_model` modules. step : int or float, optional (default=1) If greater than or equal to 1, then `step` corresponds to the (integer) number of features to remove at each iteration. If within (0.0, 1.0), then `step` corresponds to the percentage (rounded down) of features to remove at each iteration. cv : int or cross-validation generator, optional (default=None) If int, it is the number of folds. If None, 3-fold cross-validation is performed by default. Specific cross-validation objects can also be passed, see `sklearn.cross_validation module` for details. scoring : string, callable or None, optional, default: None A string (see model evaluation documentation) or a scorer callable object / function with signature ``scorer(estimator, X, y)``. estimator_params : dict Parameters for the external estimator. This attribute is deprecated as of version 0.16 and will be removed in 0.18. Use estimator initialisation or set_params method instead. verbose : int, default=0 Controls verbosity of output. Attributes ---------- n_features_ : int The number of selected features with cross-validation. support_ : array of shape [n_features] The mask of selected features. ranking_ : array of shape [n_features] The feature ranking, such that `ranking_[i]` corresponds to the ranking position of the i-th feature. Selected (i.e., estimated best) features are assigned rank 1. grid_scores_ : array of shape [n_subsets_of_features] The cross-validation scores such that ``grid_scores_[i]`` corresponds to the CV score of the i-th subset of features. estimator_ : object The external estimator fit on the reduced dataset. Notes ----- The size of ``grid_scores_`` is equal to ceil((n_features - 1) / step) + 1, where step is the number of features removed at each iteration. Examples -------- The following example shows how to retrieve the a-priori not known 5 informative features in the Friedman #1 dataset. >>> from sklearn.datasets import make_friedman1 >>> from sklearn.feature_selection import RFECV >>> from sklearn.svm import SVR >>> X, y = make_friedman1(n_samples=50, n_features=10, random_state=0) >>> estimator = SVR(kernel="linear") >>> selector = RFECV(estimator, step=1, cv=5) >>> selector = selector.fit(X, y) >>> selector.support_ # doctest: +NORMALIZE_WHITESPACE array([ True, True, True, True, True, False, False, False, False, False], dtype=bool) >>> selector.ranking_ array([1, 1, 1, 1, 1, 6, 4, 3, 2, 5]) References ---------- .. [1] Guyon, I., Weston, J., Barnhill, S., & Vapnik, V., "Gene selection for cancer classification using support vector machines", Mach. Learn., 46(1-3), 389--422, 2002. """ def __init__(self, estimator, step=1, cv=None, scoring=None, estimator_params=None, verbose=0): self.estimator = estimator self.step = step self.cv = cv self.scoring = scoring self.estimator_params = estimator_params self.verbose = verbose def fit(self, X, y): """Fit the RFE model and automatically tune the number of selected features. Parameters ---------- X : {array-like, sparse matrix}, shape = [n_samples, n_features] Training vector, where `n_samples` is the number of samples and `n_features` is the total number of features. y : array-like, shape = [n_samples] Target values (integers for classification, real numbers for regression). """ X, y = check_X_y(X, y, "csr") if self.estimator_params is not None: warnings.warn("The parameter 'estimator_params' is deprecated as " "of version 0.16 and will be removed in 0.18. " "The parameter is no longer necessary because the " "value is set via the estimator initialisation or " "set_params method.", DeprecationWarning) # Initialization cv = check_cv(self.cv, X, y, is_classifier(self.estimator)) scorer = check_scoring(self.estimator, scoring=self.scoring) n_features = X.shape[1] n_features_to_select = 1 # Determine the number of subsets of features scores = [] # Cross-validation for n, (train, test) in enumerate(cv): X_train, y_train = _safe_split(self.estimator, X, y, train) X_test, y_test = _safe_split(self.estimator, X, y, test, train) rfe = RFE(estimator=self.estimator, n_features_to_select=n_features_to_select, step=self.step, estimator_params=self.estimator_params, verbose=self.verbose - 1) rfe._fit(X_train, y_train, lambda estimator, features: _score(estimator, X_test[:, features], y_test, scorer)) scores.append(np.array(rfe.scores_[::-1]).reshape(1, -1)) scores = np.sum(np.concatenate(scores, 0), 0) # The index in 'scores' when 'n_features' features are selected n_feature_index = np.ceil((n_features - n_features_to_select) / float(self.step)) n_features_to_select = max(n_features_to_select, n_features - ((n_feature_index - np.argmax(scores)) * self.step)) # Re-execute an elimination with best_k over the whole set rfe = RFE(estimator=self.estimator, n_features_to_select=n_features_to_select, step=self.step, estimator_params=self.estimator_params) rfe.fit(X, y) # Set final attributes self.support_ = rfe.support_ self.n_features_ = rfe.n_features_ self.ranking_ = rfe.ranking_ self.estimator_ = clone(self.estimator) if self.estimator_params: self.estimator_.set_params(**self.estimator_params) self.estimator_.fit(self.transform(X), y) # Fixing a normalization error, n is equal to len(cv) - 1 # here, the scores are normalized by len(cv) self.grid_scores_ = scores / len(cv) return self
apache-2.0
[ 3, 6642, 26, 22986, 28547, 27211, 10279, 665, 24421, 28547, 14, 1679, 10279, 32, 262, 23714, 14, 4391, 30, 199, 3, 3515, 28882, 2946, 603, 1158, 352, 665, 11908, 2946, 14, 77, 1158, 352, 32, 262, 23714, 14, 4391, 30, 199, 3, 3515, 598, 382, 2978, 3835, 384, 321, 665, 71, 14, 320, 384, 321, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 624, 25122, 3878, 20714, 425, 367, 3878, 6915, 316, 624, 199, 199, 646, 3598, 199, 646, 2680, 465, 980, 199, 504, 2508, 1208, 492, 1104, 63, 56, 63, 89, 12, 5048, 63, 3526, 82, 199, 504, 2508, 1208, 14, 2024, 10646, 492, 340, 63, 15286, 63, 1989, 63, 765, 199, 504, 2508, 1095, 492, 3523, 13183, 199, 504, 2508, 1095, 492, 6288, 13183, 4256, 199, 504, 2508, 1095, 492, 7289, 199, 504, 2508, 1095, 492, 365, 63, 14720, 199, 504, 2508, 7925, 63, 6136, 492, 485, 1074, 63, 5107, 465, 1104, 63, 5107, 199, 504, 2508, 7925, 63, 6136, 492, 485, 3489, 63, 1294, 12, 485, 3397, 199, 504, 2508, 6759, 14, 22135, 492, 1104, 63, 27128, 199, 504, 1275, 1095, 492, 3240, 3283, 4256, 421, 199, 533, 820, 5100, 8, 1563, 13183, 12, 6288, 13183, 4256, 12, 3240, 3283, 4256, 304, 272, 408, 5968, 6915, 316, 543, 9133, 3878, 20714, 425, 14, 339, 9138, 376, 5957, 8943, 626, 465, 20440, 4931, 370, 4534, 334, 69, 14, 71, 2020, 314, 272, 12343, 402, 282, 7798, 1402, 395, 314, 14850, 402, 9133, 3878, 20714, 425, 272, 334, 50, 5100, 9, 365, 370, 3504, 4534, 701, 15035, 11201, 316, 12700, 436, 12700, 272, 5951, 402, 4534, 14, 7758, 12, 314, 8943, 365, 28161, 641, 314, 2536, 663, 402, 272, 4534, 436, 4931, 787, 7943, 370, 1924, 1373, 402, 3062, 14, 9442, 12, 4534, 7447, 272, 3679, 4931, 787, 314, 18604, 787, 29501, 379, 687, 314, 1453, 663, 4534, 14, 272, 10314, 17782, 365, 15035, 10877, 641, 314, 29501, 379, 663, 5133, 314, 6387, 272, 1329, 402, 4534, 370, 3504, 365, 21356, 13075, 14, 339, 5574, 1655, 315, 314, 520, 1121, 1705, 1899, 15423, 665, 82, 771, 14943, 339, 3897, 272, 4143, 272, 8943, 520, 909, 267, 437, 1613, 17311, 9328, 8943, 543, 282, 658, 3269, 64, 1083, 626, 7029, 282, 267, 658, 8009, 28116, 2225, 626, 15164, 314, 26093, 2633, 14, 3161, 867, 4534, 267, 1471, 17118, 370, 4721, 3679, 1338, 315, 314, 658, 8009, 28116, 1625, 14, 398, 2104, 1256, 12, 642, 365, 314, 1930, 367, 4750, 1613, 17311, 9328, 267, 18036, 4066, 465, 12502, 11388, 8465, 2608, 6069, 436, 1696, 1759, 267, 12489, 29941, 687, 314, 658, 16820, 64, 436, 658, 6676, 63, 1238, 64, 4621, 14, 339, 302, 63, 3179, 63, 475, 63, 2416, 520, 1109, 503, 488, 334, 885, 29, 403, 9, 267, 710, 1329, 402, 4534, 370, 3504, 14, 982, 658, 403, 3559, 12995, 402, 314, 4534, 267, 787, 4895, 14, 339, 3650, 520, 1109, 503, 2069, 12, 2716, 334, 885, 29, 17, 9, 267, 982, 8932, 2419, 503, 4472, 370, 413, 12, 2066, 658, 2926, 64, 13718, 370, 314, 334, 4115, 9, 267, 1329, 402, 4534, 370, 2813, 737, 1924, 8494, 14, 267, 982, 4453, 334, 16, 14, 16, 12, 413, 14, 16, 395, 2066, 658, 2926, 64, 13718, 370, 314, 16327, 267, 334, 25677, 3224, 9, 402, 4534, 370, 2813, 737, 1924, 8494, 14, 339, 8943, 63, 1162, 520, 1211, 267, 3897, 367, 314, 5957, 8943, 14, 267, 961, 2225, 365, 5906, 465, 402, 1015, 378, 14, 975, 436, 911, 506, 4829, 315, 267, 378, 14, 1085, 14, 3645, 8943, 2536, 19914, 503, 663, 63, 1162, 1083, 3140, 14, 339, 3376, 520, 1109, 12, 849, 29, 16, 267, 29001, 8661, 402, 1072, 14, 339, 9382, 272, 4143, 272, 302, 63, 3179, 63, 520, 1109, 267, 710, 1329, 402, 4895, 4534, 14, 339, 2291, 63, 520, 1625, 402, 2215, 359, 78, 63, 3179, 61, 267, 710, 3656, 402, 4895, 4534, 14, 339, 6915, 316, 63, 520, 1625, 402, 2215, 359, 78, 63, 3179, 61, 267, 710, 3878, 6915, 316, 12, 4066, 626, 1124, 31950, 9925, 73, 21133, 13718, 370, 314, 267, 6915, 316, 3421, 402, 314, 284, 13, 273, 3878, 14, 3240, 2820, 334, 73, 14, 69, 2020, 20077, 267, 5526, 9, 4534, 787, 7943, 6915, 413, 14, 339, 8943, 63, 520, 909, 267, 710, 5957, 8943, 5542, 641, 314, 14953, 4789, 14, 339, 6058, 272, 3001, 272, 710, 2569, 2893, 13703, 4212, 370, 8044, 314, 959, 2451, 315, 20889, 272, 4534, 315, 314, 481, 18906, 1237, 327, 17, 4789, 14, 339, 1306, 687, 6357, 14, 12281, 492, 1852, 63, 70, 18906, 1237, 17, 272, 1306, 687, 6357, 14, 4445, 63, 5592, 492, 820, 5100, 272, 1306, 687, 6357, 14, 16820, 492, 14056, 50, 272, 1306, 1323, 12, 612, 275, 1852, 63, 70, 18906, 1237, 17, 8, 78, 63, 3356, 29, 1400, 12, 302, 63, 3179, 29, 709, 12, 2196, 63, 929, 29, 16, 9, 272, 1306, 8943, 275, 14056, 50, 8, 4989, 628, 6676, 531, 272, 1306, 9759, 275, 820, 5100, 8, 8627, 12, 959, 12, 3650, 29, 17, 9, 272, 1306, 9759, 275, 9759, 14, 3269, 8, 56, 12, 612, 9, 272, 1306, 9759, 14, 4058, 63, 327, 8868, 26, 435, 10765, 11025, 63, 20620, 272, 1625, 779, 715, 12, 221, 715, 12, 221, 715, 12, 221, 715, 12, 221, 715, 12, 288, 756, 12, 756, 12, 756, 12, 756, 12, 756, 467, 2152, 29, 2245, 9, 272, 1306, 9759, 14, 31950, 63, 272, 1625, 779, 17, 12, 413, 12, 413, 12, 413, 12, 413, 12, 1227, 12, 841, 12, 650, 12, 499, 12, 959, 566, 339, 14504, 272, 4143, 339, 2508, 359, 17, 61, 12436, 89, 265, 12, 473, 2020, 644, 597, 265, 12, 1603, 2020, 699, 1060, 72, 778, 12, 428, 2020, 1253, 812, 439, 22998, 12, 812, 2020, 298, 39, 6349, 7267, 1779, 367, 883, 2247, 12505, 1808, 2291, 5477, 20601, 401, 1779, 30611, 14, 7005, 1060, 2020, 12426, 8, 17, 13, 19, 395, 650, 1407, 306, 23814, 12, 14790, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 8943, 12, 302, 63, 3179, 63, 475, 63, 2416, 29, 403, 12, 3650, 29 ]
[ 6642, 26, 22986, 28547, 27211, 10279, 665, 24421, 28547, 14, 1679, 10279, 32, 262, 23714, 14, 4391, 30, 199, 3, 3515, 28882, 2946, 603, 1158, 352, 665, 11908, 2946, 14, 77, 1158, 352, 32, 262, 23714, 14, 4391, 30, 199, 3, 3515, 598, 382, 2978, 3835, 384, 321, 665, 71, 14, 320, 384, 321, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 624, 25122, 3878, 20714, 425, 367, 3878, 6915, 316, 624, 199, 199, 646, 3598, 199, 646, 2680, 465, 980, 199, 504, 2508, 1208, 492, 1104, 63, 56, 63, 89, 12, 5048, 63, 3526, 82, 199, 504, 2508, 1208, 14, 2024, 10646, 492, 340, 63, 15286, 63, 1989, 63, 765, 199, 504, 2508, 1095, 492, 3523, 13183, 199, 504, 2508, 1095, 492, 6288, 13183, 4256, 199, 504, 2508, 1095, 492, 7289, 199, 504, 2508, 1095, 492, 365, 63, 14720, 199, 504, 2508, 7925, 63, 6136, 492, 485, 1074, 63, 5107, 465, 1104, 63, 5107, 199, 504, 2508, 7925, 63, 6136, 492, 485, 3489, 63, 1294, 12, 485, 3397, 199, 504, 2508, 6759, 14, 22135, 492, 1104, 63, 27128, 199, 504, 1275, 1095, 492, 3240, 3283, 4256, 421, 199, 533, 820, 5100, 8, 1563, 13183, 12, 6288, 13183, 4256, 12, 3240, 3283, 4256, 304, 272, 408, 5968, 6915, 316, 543, 9133, 3878, 20714, 425, 14, 339, 9138, 376, 5957, 8943, 626, 465, 20440, 4931, 370, 4534, 334, 69, 14, 71, 2020, 314, 272, 12343, 402, 282, 7798, 1402, 395, 314, 14850, 402, 9133, 3878, 20714, 425, 272, 334, 50, 5100, 9, 365, 370, 3504, 4534, 701, 15035, 11201, 316, 12700, 436, 12700, 272, 5951, 402, 4534, 14, 7758, 12, 314, 8943, 365, 28161, 641, 314, 2536, 663, 402, 272, 4534, 436, 4931, 787, 7943, 370, 1924, 1373, 402, 3062, 14, 9442, 12, 4534, 7447, 272, 3679, 4931, 787, 314, 18604, 787, 29501, 379, 687, 314, 1453, 663, 4534, 14, 272, 10314, 17782, 365, 15035, 10877, 641, 314, 29501, 379, 663, 5133, 314, 6387, 272, 1329, 402, 4534, 370, 3504, 365, 21356, 13075, 14, 339, 5574, 1655, 315, 314, 520, 1121, 1705, 1899, 15423, 665, 82, 771, 14943, 339, 3897, 272, 4143, 272, 8943, 520, 909, 267, 437, 1613, 17311, 9328, 8943, 543, 282, 658, 3269, 64, 1083, 626, 7029, 282, 267, 658, 8009, 28116, 2225, 626, 15164, 314, 26093, 2633, 14, 3161, 867, 4534, 267, 1471, 17118, 370, 4721, 3679, 1338, 315, 314, 658, 8009, 28116, 1625, 14, 398, 2104, 1256, 12, 642, 365, 314, 1930, 367, 4750, 1613, 17311, 9328, 267, 18036, 4066, 465, 12502, 11388, 8465, 2608, 6069, 436, 1696, 1759, 267, 12489, 29941, 687, 314, 658, 16820, 64, 436, 658, 6676, 63, 1238, 64, 4621, 14, 339, 302, 63, 3179, 63, 475, 63, 2416, 520, 1109, 503, 488, 334, 885, 29, 403, 9, 267, 710, 1329, 402, 4534, 370, 3504, 14, 982, 658, 403, 3559, 12995, 402, 314, 4534, 267, 787, 4895, 14, 339, 3650, 520, 1109, 503, 2069, 12, 2716, 334, 885, 29, 17, 9, 267, 982, 8932, 2419, 503, 4472, 370, 413, 12, 2066, 658, 2926, 64, 13718, 370, 314, 334, 4115, 9, 267, 1329, 402, 4534, 370, 2813, 737, 1924, 8494, 14, 267, 982, 4453, 334, 16, 14, 16, 12, 413, 14, 16, 395, 2066, 658, 2926, 64, 13718, 370, 314, 16327, 267, 334, 25677, 3224, 9, 402, 4534, 370, 2813, 737, 1924, 8494, 14, 339, 8943, 63, 1162, 520, 1211, 267, 3897, 367, 314, 5957, 8943, 14, 267, 961, 2225, 365, 5906, 465, 402, 1015, 378, 14, 975, 436, 911, 506, 4829, 315, 267, 378, 14, 1085, 14, 3645, 8943, 2536, 19914, 503, 663, 63, 1162, 1083, 3140, 14, 339, 3376, 520, 1109, 12, 849, 29, 16, 267, 29001, 8661, 402, 1072, 14, 339, 9382, 272, 4143, 272, 302, 63, 3179, 63, 520, 1109, 267, 710, 1329, 402, 4895, 4534, 14, 339, 2291, 63, 520, 1625, 402, 2215, 359, 78, 63, 3179, 61, 267, 710, 3656, 402, 4895, 4534, 14, 339, 6915, 316, 63, 520, 1625, 402, 2215, 359, 78, 63, 3179, 61, 267, 710, 3878, 6915, 316, 12, 4066, 626, 1124, 31950, 9925, 73, 21133, 13718, 370, 314, 267, 6915, 316, 3421, 402, 314, 284, 13, 273, 3878, 14, 3240, 2820, 334, 73, 14, 69, 2020, 20077, 267, 5526, 9, 4534, 787, 7943, 6915, 413, 14, 339, 8943, 63, 520, 909, 267, 710, 5957, 8943, 5542, 641, 314, 14953, 4789, 14, 339, 6058, 272, 3001, 272, 710, 2569, 2893, 13703, 4212, 370, 8044, 314, 959, 2451, 315, 20889, 272, 4534, 315, 314, 481, 18906, 1237, 327, 17, 4789, 14, 339, 1306, 687, 6357, 14, 12281, 492, 1852, 63, 70, 18906, 1237, 17, 272, 1306, 687, 6357, 14, 4445, 63, 5592, 492, 820, 5100, 272, 1306, 687, 6357, 14, 16820, 492, 14056, 50, 272, 1306, 1323, 12, 612, 275, 1852, 63, 70, 18906, 1237, 17, 8, 78, 63, 3356, 29, 1400, 12, 302, 63, 3179, 29, 709, 12, 2196, 63, 929, 29, 16, 9, 272, 1306, 8943, 275, 14056, 50, 8, 4989, 628, 6676, 531, 272, 1306, 9759, 275, 820, 5100, 8, 8627, 12, 959, 12, 3650, 29, 17, 9, 272, 1306, 9759, 275, 9759, 14, 3269, 8, 56, 12, 612, 9, 272, 1306, 9759, 14, 4058, 63, 327, 8868, 26, 435, 10765, 11025, 63, 20620, 272, 1625, 779, 715, 12, 221, 715, 12, 221, 715, 12, 221, 715, 12, 221, 715, 12, 288, 756, 12, 756, 12, 756, 12, 756, 12, 756, 467, 2152, 29, 2245, 9, 272, 1306, 9759, 14, 31950, 63, 272, 1625, 779, 17, 12, 413, 12, 413, 12, 413, 12, 413, 12, 1227, 12, 841, 12, 650, 12, 499, 12, 959, 566, 339, 14504, 272, 4143, 339, 2508, 359, 17, 61, 12436, 89, 265, 12, 473, 2020, 644, 597, 265, 12, 1603, 2020, 699, 1060, 72, 778, 12, 428, 2020, 1253, 812, 439, 22998, 12, 812, 2020, 298, 39, 6349, 7267, 1779, 367, 883, 2247, 12505, 1808, 2291, 5477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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 ]
geminy/aidear
oss/qt/qt-everywhere-opensource-src-5.9.0/qtwebengine/src/3rdparty/chromium/v8/tools/testrunner/local/statusfile_unittest.py
10
4126
#!/usr/bin/env python # Copyright 2016 the V8 project authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import unittest import statusfile from utils import Freeze TEST_VARIABLES = { 'system': 'linux', 'mode': 'release', } TEST_STATUS_FILE = """ [ [ALWAYS, { 'foo/bar': [PASS, SKIP], 'baz/bar': [PASS, FAIL], 'foo/*': [PASS, SLOW], }], # ALWAYS ['%s', { 'baz/bar': [PASS, SLOW], 'foo/*': [FAIL], }], ] """ def make_variables(): variables = {} variables.update(TEST_VARIABLES) return variables class UtilsTest(unittest.TestCase): def test_freeze(self): self.assertEqual(2, Freeze({1: [2]})[1][0]) self.assertEqual(set([3]), Freeze({1: [2], 2: set([3])})[2]) with self.assertRaises(Exception): Freeze({1: [], 2: set([3])})[2] = 4 with self.assertRaises(Exception): Freeze({1: [], 2: set([3])}).update({3: 4}) with self.assertRaises(Exception): Freeze({1: [], 2: set([3])})[1].append(2) with self.assertRaises(Exception): Freeze({1: [], 2: set([3])})[2] |= set([3]) # Sanity check that we can do the same calls on a non-frozen object. {1: [], 2: set([3])}[2] = 4 {1: [], 2: set([3])}.update({3: 4}) {1: [], 2: set([3])}[1].append(2) {1: [], 2: set([3])}[2] |= set([3]) class StatusFileTest(unittest.TestCase): def test_eval_expression(self): variables = make_variables() variables.update(statusfile.VARIABLES) self.assertTrue( statusfile._EvalExpression( 'system==linux and mode==release', variables)) self.assertTrue( statusfile._EvalExpression( 'system==linux or variant==default', variables)) self.assertFalse( statusfile._EvalExpression( 'system==linux and mode==debug', variables)) self.assertRaises( AssertionError, lambda: statusfile._EvalExpression( 'system==linux and mode==foo', variables)) self.assertRaises( SyntaxError, lambda: statusfile._EvalExpression( 'system==linux and mode=release', variables)) self.assertEquals( statusfile.VARIANT_EXPRESSION, statusfile._EvalExpression( 'system==linux and variant==default', variables) ) def test_read_statusfile_section_true(self): rules, wildcards = statusfile.ReadStatusFile( TEST_STATUS_FILE % 'system==linux', make_variables()) self.assertEquals( { 'foo/bar': set(['PASS', 'SKIP']), 'baz/bar': set(['PASS', 'FAIL', 'SLOW']), }, rules[''], ) self.assertEquals( { 'foo/*': set(['SLOW', 'FAIL']), }, wildcards[''], ) self.assertEquals({}, rules['default']) self.assertEquals({}, wildcards['default']) def test_read_statusfile_section_false(self): rules, wildcards = statusfile.ReadStatusFile( TEST_STATUS_FILE % 'system==windows', make_variables()) self.assertEquals( { 'foo/bar': set(['PASS', 'SKIP']), 'baz/bar': set(['PASS', 'FAIL']), }, rules[''], ) self.assertEquals( { 'foo/*': set(['PASS', 'SLOW']), }, wildcards[''], ) self.assertEquals({}, rules['default']) self.assertEquals({}, wildcards['default']) def test_read_statusfile_section_variant(self): rules, wildcards = statusfile.ReadStatusFile( TEST_STATUS_FILE % 'system==linux and variant==default', make_variables(), ) self.assertEquals( { 'foo/bar': set(['PASS', 'SKIP']), 'baz/bar': set(['PASS', 'FAIL']), }, rules[''], ) self.assertEquals( { 'foo/*': set(['PASS', 'SLOW']), }, wildcards[''], ) self.assertEquals( { 'baz/bar': set(['PASS', 'SLOW']), }, rules['default'], ) self.assertEquals( { 'foo/*': set(['FAIL']), }, wildcards['default'], ) if __name__ == '__main__': unittest.main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 7800, 314, 812, 24, 2199, 11462, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 2882, 199, 199, 646, 2004, 493, 199, 504, 3778, 492, 2868, 806, 421, 199, 2864, 63, 21161, 275, 469, 523, 283, 2253, 356, 283, 5135, 297, 523, 283, 632, 356, 283, 3221, 297, 199, 93, 421, 199, 2864, 63, 6305, 63, 3817, 275, 408, 199, 59, 199, 59, 32509, 12, 469, 523, 283, 1421, 15, 1700, 356, 359, 6909, 12, 27885, 467, 523, 283, 6185, 15, 1700, 356, 359, 6909, 12, 10341, 467, 523, 283, 1421, 6331, 356, 359, 6909, 12, 428, 5896, 467, 199, 22140, 221, 327, 12112, 26194, 199, 199, 13890, 83, 297, 469, 523, 283, 6185, 15, 1700, 356, 359, 6909, 12, 428, 5896, 467, 523, 283, 1421, 6331, 356, 359, 8784, 467, 199, 22140, 199, 61, 199, 624, 421, 199, 318, 1852, 63, 3669, 837, 523, 2860, 275, 1052, 523, 2860, 14, 873, 8, 2864, 63, 21161, 9, 523, 372, 2860, 421, 199, 533, 17397, 774, 8, 2796, 14, 1746, 304, 523, 347, 511, 63, 18459, 8, 277, 304, 272, 291, 14, 629, 8, 18, 12, 2868, 806, 2561, 17, 26, 359, 18, 13412, 59, 17, 1527, 16, 566, 272, 291, 14, 629, 8, 409, 779, 19, 2522, 2868, 806, 2561, 17, 26, 359, 18, 467, 499, 26, 663, 779, 19, 566, 1552, 59, 18, 566, 339, 543, 291, 14, 1855, 8, 1726, 304, 489, 2868, 806, 2561, 17, 26, 990, 499, 26, 663, 779, 19, 566, 1552, 59, 18, 61, 275, 841, 272, 543, 291, 14, 1855, 8, 1726, 304, 489, 2868, 806, 2561, 17, 26, 990, 499, 26, 663, 779, 19, 566, 21385, 873, 2561, 19, 26, 841, 1552, 272, 543, 291, 14, 1855, 8, 1726, 304, 489, 2868, 806, 2561, 17, 26, 990, 499, 26, 663, 779, 19, 566, 1552, 59, 17, 1055, 740, 8, 18, 9, 272, 543, 291, 14, 1855, 8, 1726, 304, 489, 2868, 806, 2561, 17, 26, 990, 499, 26, 663, 779, 19, 566, 1552, 59, 18, 61, 8901, 663, 779, 19, 566, 339, 327, 22111, 1104, 626, 781, 883, 886, 314, 2011, 4882, 641, 282, 2222, 13, 11202, 909, 14, 272, 469, 17, 26, 990, 499, 26, 663, 779, 19, 566, 22857, 18, 61, 275, 841, 272, 469, 17, 26, 990, 499, 26, 663, 779, 19, 566, 5565, 873, 2561, 19, 26, 841, 1552, 272, 469, 17, 26, 990, 499, 26, 663, 779, 19, 566, 22857, 17, 1055, 740, 8, 18, 9, 272, 469, 17, 26, 990, 499, 26, 663, 779, 19, 566, 22857, 18, 61, 8901, 663, 779, 19, 566, 421, 199, 533, 9795, 1173, 774, 8, 2796, 14, 1746, 304, 523, 347, 511, 63, 2579, 63, 5599, 8, 277, 304, 272, 2860, 275, 1852, 63, 3669, 342, 272, 2860, 14, 873, 8, 1205, 493, 14, 21161, 9, 339, 291, 14, 1815, 8, 267, 2004, 493, 423, 10006, 9093, 8, 288, 283, 2253, 389, 5135, 436, 818, 389, 3221, 297, 2860, 430, 272, 291, 14, 1815, 8, 267, 2004, 493, 423, 10006, 9093, 8, 288, 283, 2253, 389, 5135, 503, 9854, 389, 885, 297, 2860, 430, 272, 291, 14, 3334, 8, 267, 2004, 493, 423, 10006, 9093, 8, 288, 283, 2253, 389, 5135, 436, 818, 389, 1757, 297, 2860, 430, 272, 291, 14, 1855, 8, 267, 9070, 12, 267, 2400, 26, 2004, 493, 423, 10006, 9093, 8, 288, 283, 2253, 389, 5135, 436, 818, 389, 1421, 297, 2860, 430, 272, 291, 14, 1855, 8, 267, 12053, 12, 267, 2400, 26, 2004, 493, 423, 10006, 9093, 8, 288, 283, 2253, 389, 5135, 436, 818, 29, 3221, 297, 2860, 430, 272, 291, 14, 2947, 8, 267, 2004, 493, 14, 30582, 63, 1438, 5786, 1075, 12, 267, 2004, 493, 423, 10006, 9093, 8, 288, 283, 2253, 389, 5135, 436, 9854, 389, 885, 297, 2860, 9, 272, 776, 819, 347, 511, 63, 739, 63, 1205, 493, 63, 2792, 63, 2052, 8, 277, 304, 272, 4713, 12, 24952, 275, 2004, 493, 14, 3284, 3694, 1173, 8, 267, 7393, 63, 6305, 63, 3817, 450, 283, 2253, 389, 5135, 297, 1852, 63, 3669, 1012, 339, 291, 14, 2947, 8, 267, 469, 881, 283, 1421, 15, 1700, 356, 663, 2941, 6909, 297, 283, 13525, 3815, 881, 283, 6185, 15, 1700, 356, 663, 2941, 6909, 297, 283, 8784, 297, 283, 51, 5896, 3815, 267, 1660, 267, 4713, 459, 995, 272, 776, 272, 291, 14, 2947, 8, 267, 469, 881, 283, 1421, 6331, 356, 663, 2941, 51, 5896, 297, 283, 8784, 3815, 267, 1660, 267, 24952, 459, 995, 272, 776, 272, 291, 14, 2947, 16037, 4713, 459, 885, 1105, 272, 291, 14, 2947, 16037, 24952, 459, 885, 1105, 819, 347, 511, 63, 739, 63, 1205, 493, 63, 2792, 63, 3910, 8, 277, 304, 272, 4713, 12, 24952, 275, 2004, 493, 14, 3284, 3694, 1173, 8, 267, 7393, 63, 6305, 63, 3817, 450, 283, 2253, 389, 8258, 297, 1852, 63, 3669, 1012, 339, 291, 14, 2947, 8, 267, 469, 881, 283, 1421, 15, 1700, 356, 663, 2941, 6909, 297, 283, 13525, 3815, 881, 283, 6185, 15, 1700, 356, 663, 2941, 6909, 297, 283, 8784, 3815, 267, 1660, 267, 4713, 459, 995, 272, 776, 272, 291, 14, 2947, 8, 267, 469, 881, 283, 1421, 6331, 356, 663, 2941, 6909, 297, 283, 51, 5896, 3815, 267, 1660, 267, 24952, 459, 995, 272, 776, 272, 291, 14, 2947, 16037, 4713, 459, 885, 1105, 272, 291, 14, 2947, 16037, 24952, 459, 885, 1105, 819, 347, 511, 63, 739, 63, 1205, 493, 63, 2792, 63, 8759, 8, 277, 304, 272, 4713, 12, 24952, 275, 2004, 493, 14, 3284, 3694, 1173, 8, 267, 7393, 63, 6305, 63, 3817, 450, 283, 2253, 389, 5135, 436, 9854, 389, 885, 297, 267, 1852, 63, 3669, 1062, 272, 776, 339, 291, 14, 2947, 8, 267, 469, 881, 283, 1421, 15, 1700, 356, 663, 2941, 6909, 297, 283, 13525, 3815, 881, 283, 6185, 15, 1700, 356, 663, 2941, 6909, 297, 283, 8784, 3815, 267, 1660, 267, 4713, 459, 995, 272, 776, 272, 291 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 7800, 314, 812, 24, 2199, 11462, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 2882, 199, 199, 646, 2004, 493, 199, 504, 3778, 492, 2868, 806, 421, 199, 2864, 63, 21161, 275, 469, 523, 283, 2253, 356, 283, 5135, 297, 523, 283, 632, 356, 283, 3221, 297, 199, 93, 421, 199, 2864, 63, 6305, 63, 3817, 275, 408, 199, 59, 199, 59, 32509, 12, 469, 523, 283, 1421, 15, 1700, 356, 359, 6909, 12, 27885, 467, 523, 283, 6185, 15, 1700, 356, 359, 6909, 12, 10341, 467, 523, 283, 1421, 6331, 356, 359, 6909, 12, 428, 5896, 467, 199, 22140, 221, 327, 12112, 26194, 199, 199, 13890, 83, 297, 469, 523, 283, 6185, 15, 1700, 356, 359, 6909, 12, 428, 5896, 467, 523, 283, 1421, 6331, 356, 359, 8784, 467, 199, 22140, 199, 61, 199, 624, 421, 199, 318, 1852, 63, 3669, 837, 523, 2860, 275, 1052, 523, 2860, 14, 873, 8, 2864, 63, 21161, 9, 523, 372, 2860, 421, 199, 533, 17397, 774, 8, 2796, 14, 1746, 304, 523, 347, 511, 63, 18459, 8, 277, 304, 272, 291, 14, 629, 8, 18, 12, 2868, 806, 2561, 17, 26, 359, 18, 13412, 59, 17, 1527, 16, 566, 272, 291, 14, 629, 8, 409, 779, 19, 2522, 2868, 806, 2561, 17, 26, 359, 18, 467, 499, 26, 663, 779, 19, 566, 1552, 59, 18, 566, 339, 543, 291, 14, 1855, 8, 1726, 304, 489, 2868, 806, 2561, 17, 26, 990, 499, 26, 663, 779, 19, 566, 1552, 59, 18, 61, 275, 841, 272, 543, 291, 14, 1855, 8, 1726, 304, 489, 2868, 806, 2561, 17, 26, 990, 499, 26, 663, 779, 19, 566, 21385, 873, 2561, 19, 26, 841, 1552, 272, 543, 291, 14, 1855, 8, 1726, 304, 489, 2868, 806, 2561, 17, 26, 990, 499, 26, 663, 779, 19, 566, 1552, 59, 17, 1055, 740, 8, 18, 9, 272, 543, 291, 14, 1855, 8, 1726, 304, 489, 2868, 806, 2561, 17, 26, 990, 499, 26, 663, 779, 19, 566, 1552, 59, 18, 61, 8901, 663, 779, 19, 566, 339, 327, 22111, 1104, 626, 781, 883, 886, 314, 2011, 4882, 641, 282, 2222, 13, 11202, 909, 14, 272, 469, 17, 26, 990, 499, 26, 663, 779, 19, 566, 22857, 18, 61, 275, 841, 272, 469, 17, 26, 990, 499, 26, 663, 779, 19, 566, 5565, 873, 2561, 19, 26, 841, 1552, 272, 469, 17, 26, 990, 499, 26, 663, 779, 19, 566, 22857, 17, 1055, 740, 8, 18, 9, 272, 469, 17, 26, 990, 499, 26, 663, 779, 19, 566, 22857, 18, 61, 8901, 663, 779, 19, 566, 421, 199, 533, 9795, 1173, 774, 8, 2796, 14, 1746, 304, 523, 347, 511, 63, 2579, 63, 5599, 8, 277, 304, 272, 2860, 275, 1852, 63, 3669, 342, 272, 2860, 14, 873, 8, 1205, 493, 14, 21161, 9, 339, 291, 14, 1815, 8, 267, 2004, 493, 423, 10006, 9093, 8, 288, 283, 2253, 389, 5135, 436, 818, 389, 3221, 297, 2860, 430, 272, 291, 14, 1815, 8, 267, 2004, 493, 423, 10006, 9093, 8, 288, 283, 2253, 389, 5135, 503, 9854, 389, 885, 297, 2860, 430, 272, 291, 14, 3334, 8, 267, 2004, 493, 423, 10006, 9093, 8, 288, 283, 2253, 389, 5135, 436, 818, 389, 1757, 297, 2860, 430, 272, 291, 14, 1855, 8, 267, 9070, 12, 267, 2400, 26, 2004, 493, 423, 10006, 9093, 8, 288, 283, 2253, 389, 5135, 436, 818, 389, 1421, 297, 2860, 430, 272, 291, 14, 1855, 8, 267, 12053, 12, 267, 2400, 26, 2004, 493, 423, 10006, 9093, 8, 288, 283, 2253, 389, 5135, 436, 818, 29, 3221, 297, 2860, 430, 272, 291, 14, 2947, 8, 267, 2004, 493, 14, 30582, 63, 1438, 5786, 1075, 12, 267, 2004, 493, 423, 10006, 9093, 8, 288, 283, 2253, 389, 5135, 436, 9854, 389, 885, 297, 2860, 9, 272, 776, 819, 347, 511, 63, 739, 63, 1205, 493, 63, 2792, 63, 2052, 8, 277, 304, 272, 4713, 12, 24952, 275, 2004, 493, 14, 3284, 3694, 1173, 8, 267, 7393, 63, 6305, 63, 3817, 450, 283, 2253, 389, 5135, 297, 1852, 63, 3669, 1012, 339, 291, 14, 2947, 8, 267, 469, 881, 283, 1421, 15, 1700, 356, 663, 2941, 6909, 297, 283, 13525, 3815, 881, 283, 6185, 15, 1700, 356, 663, 2941, 6909, 297, 283, 8784, 297, 283, 51, 5896, 3815, 267, 1660, 267, 4713, 459, 995, 272, 776, 272, 291, 14, 2947, 8, 267, 469, 881, 283, 1421, 6331, 356, 663, 2941, 51, 5896, 297, 283, 8784, 3815, 267, 1660, 267, 24952, 459, 995, 272, 776, 272, 291, 14, 2947, 16037, 4713, 459, 885, 1105, 272, 291, 14, 2947, 16037, 24952, 459, 885, 1105, 819, 347, 511, 63, 739, 63, 1205, 493, 63, 2792, 63, 3910, 8, 277, 304, 272, 4713, 12, 24952, 275, 2004, 493, 14, 3284, 3694, 1173, 8, 267, 7393, 63, 6305, 63, 3817, 450, 283, 2253, 389, 8258, 297, 1852, 63, 3669, 1012, 339, 291, 14, 2947, 8, 267, 469, 881, 283, 1421, 15, 1700, 356, 663, 2941, 6909, 297, 283, 13525, 3815, 881, 283, 6185, 15, 1700, 356, 663, 2941, 6909, 297, 283, 8784, 3815, 267, 1660, 267, 4713, 459, 995, 272, 776, 272, 291, 14, 2947, 8, 267, 469, 881, 283, 1421, 6331, 356, 663, 2941, 6909, 297, 283, 51, 5896, 3815, 267, 1660, 267, 24952, 459, 995, 272, 776, 272, 291, 14, 2947, 16037, 4713, 459, 885, 1105, 272, 291, 14, 2947, 16037, 24952, 459, 885, 1105, 819, 347, 511, 63, 739, 63, 1205, 493, 63, 2792, 63, 8759, 8, 277, 304, 272, 4713, 12, 24952, 275, 2004, 493, 14, 3284, 3694, 1173, 8, 267, 7393, 63, 6305, 63, 3817, 450, 283, 2253, 389, 5135, 436, 9854, 389, 885, 297, 267, 1852, 63, 3669, 1062, 272, 776, 339, 291, 14, 2947, 8, 267, 469, 881, 283, 1421, 15, 1700, 356, 663, 2941, 6909, 297, 283, 13525, 3815, 881, 283, 6185, 15, 1700, 356, 663, 2941, 6909, 297, 283, 8784, 3815, 267, 1660, 267, 4713, 459, 995, 272, 776, 272, 291, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
klusark/android_external_chromium_org
tools/clang/scripts/run_tool.py
72
10556
#!/usr/bin/env python # Copyright (c) 2013 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Wrapper script to help run clang tools across Chromium code. How to use this tool: If you want to run the tool across all Chromium code: run_tool.py <tool> <path/to/compiledb> If you only want to run the tool across just chrome/browser and content/browser: run_tool.py <tool> <path/to/compiledb> chrome/browser content/browser Please see https://code.google.com/p/chromium/wiki/ClangToolRefactoring for more information, which documents the entire automated refactoring flow in Chromium. Why use this tool: The clang tool implementation doesn't take advantage of multiple cores, and if it fails mysteriously in the middle, all the generated replacements will be lost. Unfortunately, if the work is simply sharded across multiple cores by running multiple RefactoringTools, problems arise when they attempt to rewrite a file at the same time. To work around that, clang tools that are run using this tool should output edits to stdout in the following format: ==== BEGIN EDITS ==== r:<file path>:<offset>:<length>:<replacement text> r:<file path>:<offset>:<length>:<replacement text> ...etc... ==== END EDITS ==== Any generated edits are applied once the clang tool has finished running across Chromium, regardless of whether some instances failed or not. """ import collections import functools import multiprocessing import os.path import subprocess import sys Edit = collections.namedtuple( 'Edit', ('edit_type', 'offset', 'length', 'replacement')) def _GetFilesFromGit(paths = None): """Gets the list of files in the git repository. Args: paths: Prefix filter for the returned paths. May contain multiple entries. """ args = ['git', 'ls-files'] if paths: args.extend(paths) command = subprocess.Popen(args, stdout=subprocess.PIPE) output, _ = command.communicate() return output.splitlines() def _ExtractEditsFromStdout(build_directory, stdout): """Extracts generated list of edits from the tool's stdout. The expected format is documented at the top of this file. Args: build_directory: Directory that contains the compile database. Used to normalize the filenames. stdout: The stdout from running the clang tool. Returns: A dictionary mapping filenames to the associated edits. """ lines = stdout.splitlines() start_index = lines.index('==== BEGIN EDITS ====') end_index = lines.index('==== END EDITS ====') edits = collections.defaultdict(list) for line in lines[start_index + 1:end_index]: try: edit_type, path, offset, length, replacement = line.split(':', 4) # Normalize the file path emitted by the clang tool to be relative to the # current working directory. path = os.path.relpath(os.path.join(build_directory, path)) edits[path].append(Edit(edit_type, int(offset), int(length), replacement)) except ValueError: print 'Unable to parse edit: %s' % line return edits def _ExecuteTool(toolname, build_directory, filename): """Executes the tool. This is defined outside the class so it can be pickled for the multiprocessing module. Args: toolname: Path to the tool to execute. build_directory: Directory that contains the compile database. filename: The file to run the tool over. Returns: A dictionary that must contain the key "status" and a boolean value associated with it. If status is True, then the generated edits are stored with the key "edits" in the dictionary. Otherwise, the filename and the output from stderr are associated with the keys "filename" and "stderr" respectively. """ command = subprocess.Popen((toolname, '-p', build_directory, filename), stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = command.communicate() if command.returncode != 0: return {'status': False, 'filename': filename, 'stderr': stderr} else: return {'status': True, 'edits': _ExtractEditsFromStdout(build_directory, stdout)} class _CompilerDispatcher(object): """Multiprocessing controller for running clang tools in parallel.""" def __init__(self, toolname, build_directory, filenames): """Initializer method. Args: toolname: Path to the tool to execute. build_directory: Directory that contains the compile database. filenames: The files to run the tool over. """ self.__toolname = toolname self.__build_directory = build_directory self.__filenames = filenames self.__success_count = 0 self.__failed_count = 0 self.__edits = collections.defaultdict(list) @property def edits(self): return self.__edits @property def failed_count(self): return self.__failed_count def Run(self): """Does the grunt work.""" pool = multiprocessing.Pool() result_iterator = pool.imap_unordered( functools.partial(_ExecuteTool, self.__toolname, self.__build_directory), self.__filenames) for result in result_iterator: self.__ProcessResult(result) sys.stdout.write('\n') sys.stdout.flush() def __ProcessResult(self, result): """Handles result processing. Args: result: The result dictionary returned by _ExecuteTool. """ if result['status']: self.__success_count += 1 for k, v in result['edits'].iteritems(): self.__edits[k].extend(v) else: self.__failed_count += 1 sys.stdout.write('\nFailed to process %s\n' % result['filename']) sys.stdout.write(result['stderr']) sys.stdout.write('\n') percentage = ( float(self.__success_count + self.__failed_count) / len(self.__filenames)) * 100 sys.stdout.write('Succeeded: %d, Failed: %d [%.2f%%]\r' % ( self.__success_count, self.__failed_count, percentage)) sys.stdout.flush() def _ApplyEdits(edits, clang_format_diff_path): """Apply the generated edits. Args: edits: A dict mapping filenames to Edit instances that apply to that file. clang_format_diff_path: Path to the clang-format-diff.py helper to help automatically reformat diffs to avoid style violations. Pass None if the clang-format step should be skipped. """ edit_count = 0 for k, v in edits.iteritems(): # Sort the edits and iterate through them in reverse order. Sorting allows # duplicate edits to be quickly skipped, while reversing means that # subsequent edits don't need to have their offsets updated with each edit # applied. v.sort() last_edit = None with open(k, 'rb+') as f: contents = bytearray(f.read()) for edit in reversed(v): if edit == last_edit: continue last_edit = edit contents[edit.offset:edit.offset + edit.length] = edit.replacement if not edit.replacement: _ExtendDeletionIfElementIsInList(contents, edit.offset) edit_count += 1 f.seek(0) f.truncate() f.write(contents) if clang_format_diff_path: if subprocess.call('git diff -U0 %s | python %s -style=Chromium' % ( k, clang_format_diff_path), shell=True) != 0: print 'clang-format failed for %s' % k print 'Applied %d edits to %d files' % (edit_count, len(edits)) _WHITESPACE_BYTES = frozenset((ord('\t'), ord('\n'), ord('\r'), ord(' '))) def _ExtendDeletionIfElementIsInList(contents, offset): """Extends the range of a deletion if the deleted element was part of a list. This rewriter helper makes it easy for refactoring tools to remove elements from a list. Even if a matcher callback knows that it is removing an element from a list, it may not have enough information to accurately remove the list element; for example, another matcher callback may end up removing an adjacent list element, or all the list elements may end up being removed. With this helper, refactoring tools can simply remove the list element and not worry about having to include the comma in the replacement. Args: contents: A bytearray with the deletion already applied. offset: The offset in the bytearray where the deleted range used to be. """ char_before = char_after = None left_trim_count = 0 for byte in reversed(contents[:offset]): left_trim_count += 1 if byte in _WHITESPACE_BYTES: continue if byte in (ord(','), ord(':'), ord('('), ord('{')): char_before = chr(byte) break right_trim_count = 0 for byte in contents[offset:]: right_trim_count += 1 if byte in _WHITESPACE_BYTES: continue if byte == ord(','): char_after = chr(byte) break if char_before: if char_after: del contents[offset:offset + right_trim_count] elif char_before in (',', ':'): del contents[offset - left_trim_count:offset] def main(argv): if len(argv) < 2: print 'Usage: run_tool.py <clang tool> <compile DB> <path 1> <path 2> ...' print ' <clang tool> is the clang tool that should be run.' print ' <compile db> is the directory that contains the compile database' print ' <path 1> <path2> ... can be used to filter what files are edited' return 1 clang_format_diff_path = os.path.join( os.path.dirname(os.path.realpath(__file__)), '../../../third_party/llvm/tools/clang/tools/clang-format', 'clang-format-diff.py') # TODO(dcheng): Allow this to be controlled with a flag as well. if not os.path.isfile(clang_format_diff_path): clang_format_diff_path = None filenames = frozenset(_GetFilesFromGit(argv[2:])) # Filter out files that aren't C/C++/Obj-C/Obj-C++. extensions = frozenset(('.c', '.cc', '.m', '.mm')) dispatcher = _CompilerDispatcher(argv[0], argv[1], [f for f in filenames if os.path.splitext(f)[1] in extensions]) dispatcher.Run() # Filter out edits to files that aren't in the git repository, since it's not # useful to modify files that aren't under source control--typically, these # are generated files or files in a git submodule that's not part of Chromium. _ApplyEdits({k : v for k, v in dispatcher.edits.iteritems() if k in filenames}, clang_format_diff_path) if dispatcher.failed_count != 0: return 2 return 0 if __name__ == '__main__': sys.exit(main(sys.argv[1:]))
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6171, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 4590, 2884, 370, 1720, 1255, 25444, 7249, 9371, 12051, 1233, 14, 199, 199, 18335, 370, 675, 642, 4744, 26, 199, 3917, 1265, 2934, 370, 1255, 314, 4744, 9371, 1006, 12051, 1233, 26, 199, 1065, 63, 3557, 14, 647, 665, 3557, 30, 665, 515, 15, 475, 15, 2014, 697, 30, 199, 199, 3917, 1265, 1454, 2934, 370, 1255, 314, 4744, 9371, 2951, 18221, 15, 5750, 436, 1564, 15, 5750, 26, 199, 1065, 63, 3557, 14, 647, 665, 3557, 30, 665, 515, 15, 475, 15, 2014, 697, 30, 18221, 15, 5750, 1564, 15, 5750, 199, 199, 8254, 1937, 4178, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 13211, 15, 6797, 15, 1968, 621, 5157, 497, 4778, 316, 367, 1655, 199, 11697, 12, 1314, 8247, 314, 8039, 6384, 23513, 24200, 316, 6369, 315, 12051, 14, 199, 199, 55, 3577, 675, 642, 4744, 26, 199, 1918, 25444, 4744, 4514, 3181, 1133, 5452, 30268, 402, 3663, 23857, 12, 436, 340, 199, 390, 6918, 333, 588, 6236, 1785, 590, 315, 314, 12180, 12, 1006, 314, 4046, 22372, 911, 506, 199, 22031, 14, 199, 199, 1358, 21839, 12, 340, 314, 1736, 365, 9329, 1033, 12910, 9371, 3663, 23857, 701, 3879, 199, 6048, 799, 4778, 316, 11654, 12, 8826, 14554, 261, 1380, 2985, 7427, 370, 19913, 282, 570, 737, 199, 1589, 2011, 900, 14, 4005, 1736, 6818, 626, 12, 25444, 7249, 626, 787, 1255, 1808, 642, 4744, 199, 5626, 1072, 7860, 1086, 370, 3839, 315, 314, 2569, 1475, 26, 199, 199, 532, 16427, 24981, 51, 275, 5918, 199, 82, 16875, 493, 931, 30, 16875, 2743, 30, 16875, 1267, 30, 16875, 15895, 1318, 30, 199, 82, 16875, 493, 931, 30, 16875, 2743, 30, 16875, 1267, 30, 16875, 15895, 1318, 30, 199, 1396, 6839, 1396, 199, 532, 7729, 24981, 51, 275, 5918, 199, 199, 9874, 4046, 7860, 1086, 787, 6781, 5403, 314, 25444, 4744, 965, 9158, 3879, 199, 32293, 12051, 12, 15270, 402, 3775, 2005, 4454, 3405, 503, 440, 14, 199, 624, 199, 199, 646, 5055, 199, 646, 9143, 199, 646, 12866, 199, 646, 747, 14, 515, 199, 646, 3873, 199, 646, 984, 421, 199, 4685, 275, 5055, 14, 18921, 8, 272, 283, 4685, 297, 661, 3773, 63, 466, 297, 283, 2743, 297, 283, 1267, 297, 283, 15895, 1333, 421, 199, 318, 485, 1002, 5535, 2532, 14686, 8, 3771, 275, 488, 304, 523, 408, 14426, 314, 769, 402, 1584, 315, 314, 6135, 7611, 14, 819, 3033, 26, 272, 3792, 26, 25110, 2457, 367, 314, 2138, 3792, 14, 10162, 1395, 3663, 4811, 14, 523, 408, 523, 1249, 275, 788, 3187, 297, 283, 478, 13, 1725, 418, 523, 340, 3792, 26, 272, 1249, 14, 2880, 8, 3771, 9, 523, 1414, 275, 3873, 14, 7942, 8, 589, 12, 3839, 29, 5781, 14, 6089, 9, 523, 1072, 12, 485, 275, 1414, 14, 10664, 342, 523, 372, 1072, 14, 7644, 342, 421, 199, 318, 485, 12147, 37, 15256, 2532, 26080, 8, 1506, 63, 3619, 12, 3839, 304, 523, 408, 12147, 83, 4046, 769, 402, 7860, 1086, 687, 314, 4744, 1159, 3839, 14, 819, 710, 1420, 1475, 365, 22751, 737, 314, 2746, 402, 642, 570, 14, 819, 3033, 26, 272, 1900, 63, 3619, 26, 15191, 626, 3509, 314, 6555, 3050, 14, 8051, 370, 489, 7666, 314, 6203, 14, 272, 3839, 26, 710, 3839, 687, 3879, 314, 25444, 4744, 14, 819, 1803, 26, 272, 437, 2600, 4412, 6203, 370, 314, 4568, 7860, 1086, 14, 523, 408, 523, 2385, 275, 3839, 14, 7644, 342, 523, 1343, 63, 1080, 275, 2385, 14, 1080, 360, 532, 16427, 24981, 51, 275, 5918, 358, 523, 1284, 63, 1080, 275, 2385, 14, 1080, 360, 532, 7729, 24981, 51, 275, 5918, 358, 523, 7860, 1086, 275, 5055, 14, 21501, 8, 513, 9, 523, 367, 1004, 315, 2385, 59, 928, 63, 1080, 435, 413, 26, 500, 63, 1080, 2189, 272, 862, 26, 489, 5283, 63, 466, 12, 931, 12, 3268, 12, 2582, 12, 8343, 275, 1004, 14, 1294, 16451, 841, 9, 489, 327, 21017, 314, 570, 931, 19515, 701, 314, 25444, 4744, 370, 506, 3847, 370, 314, 489, 327, 1453, 6449, 2082, 14, 489, 931, 275, 747, 14, 515, 14, 12405, 8, 736, 14, 515, 14, 904, 8, 1506, 63, 3619, 12, 931, 430, 489, 7860, 1086, 59, 515, 1055, 740, 8, 4685, 8, 3773, 63, 466, 12, 1109, 8, 2743, 395, 1109, 8, 1267, 395, 8343, 430, 272, 871, 1722, 26, 489, 870, 283, 6005, 370, 2198, 5283, 26, 450, 83, 7, 450, 1004, 523, 372, 7860, 1086, 421, 199, 318, 485, 12049, 5157, 8, 3557, 354, 12, 1900, 63, 3619, 12, 1788, 304, 523, 408, 4858, 3862, 314, 4744, 14, 819, 961, 365, 3247, 9682, 314, 1021, 880, 652, 883, 506, 18731, 367, 314, 12866, 523, 859, 14, 819, 3033, 26, 272, 4744, 354, 26, 6912, 370, 314, 4744, 370, 5341, 14, 272, 1900, 63, 3619, 26, 15191, 626, 3509, 314, 6555, 3050, 14, 272, 1788, 26, 710, 570, 370, 1255, 314, 4744, 1806, 14, 819, 1803, 26, 272, 437, 2600, 626, 1471, 1395, 314, 790, 298, 1205, 2, 436, 282, 5046, 574, 272, 4568, 543, 652, 14, 339, 982, 2004, 365, 715, 12, 2066, 314, 4046, 7860, 1086, 787, 5489, 543, 314, 790, 298, 6297, 1086, 2, 272, 315, 314, 2600, 14, 339, 6630, 12, 314, 1788, 436, 314, 1072, 687, 4635, 787, 4568, 543, 314, 272, 2883, 298, 1501, 2, 436, 298, 3083, 2, 17342, 14, 523, 408, 523, 1414, 275, 3873, 14, 7942, 1332, 3557, 354, 12, 2475, 80, 297, 1900, 63, 3619, 12, 1788, 395, 2490, 3839, 29, 5781, 14, 6089, 12, 2490, 4635, 29, 5781, 14, 6089, 9, 523, 3839, 12, 4635, 275, 1414, 14, 10664, 342, 523, 340, 1414, 14, 9913, 1137, 378, 26, 272, 372, 791, 1205, 356, 756, 12, 283, 1501, 356, 1788, 12, 283, 3083, 356, 4635, 93, 523, 587, 26, 272, 372, 791, 1205, 356, 715, 12, 288, 283, 6297, 1086, 356, 485, 12147, 37 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6171, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 4590, 2884, 370, 1720, 1255, 25444, 7249, 9371, 12051, 1233, 14, 199, 199, 18335, 370, 675, 642, 4744, 26, 199, 3917, 1265, 2934, 370, 1255, 314, 4744, 9371, 1006, 12051, 1233, 26, 199, 1065, 63, 3557, 14, 647, 665, 3557, 30, 665, 515, 15, 475, 15, 2014, 697, 30, 199, 199, 3917, 1265, 1454, 2934, 370, 1255, 314, 4744, 9371, 2951, 18221, 15, 5750, 436, 1564, 15, 5750, 26, 199, 1065, 63, 3557, 14, 647, 665, 3557, 30, 665, 515, 15, 475, 15, 2014, 697, 30, 18221, 15, 5750, 1564, 15, 5750, 199, 199, 8254, 1937, 4178, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 13211, 15, 6797, 15, 1968, 621, 5157, 497, 4778, 316, 367, 1655, 199, 11697, 12, 1314, 8247, 314, 8039, 6384, 23513, 24200, 316, 6369, 315, 12051, 14, 199, 199, 55, 3577, 675, 642, 4744, 26, 199, 1918, 25444, 4744, 4514, 3181, 1133, 5452, 30268, 402, 3663, 23857, 12, 436, 340, 199, 390, 6918, 333, 588, 6236, 1785, 590, 315, 314, 12180, 12, 1006, 314, 4046, 22372, 911, 506, 199, 22031, 14, 199, 199, 1358, 21839, 12, 340, 314, 1736, 365, 9329, 1033, 12910, 9371, 3663, 23857, 701, 3879, 199, 6048, 799, 4778, 316, 11654, 12, 8826, 14554, 261, 1380, 2985, 7427, 370, 19913, 282, 570, 737, 199, 1589, 2011, 900, 14, 4005, 1736, 6818, 626, 12, 25444, 7249, 626, 787, 1255, 1808, 642, 4744, 199, 5626, 1072, 7860, 1086, 370, 3839, 315, 314, 2569, 1475, 26, 199, 199, 532, 16427, 24981, 51, 275, 5918, 199, 82, 16875, 493, 931, 30, 16875, 2743, 30, 16875, 1267, 30, 16875, 15895, 1318, 30, 199, 82, 16875, 493, 931, 30, 16875, 2743, 30, 16875, 1267, 30, 16875, 15895, 1318, 30, 199, 1396, 6839, 1396, 199, 532, 7729, 24981, 51, 275, 5918, 199, 199, 9874, 4046, 7860, 1086, 787, 6781, 5403, 314, 25444, 4744, 965, 9158, 3879, 199, 32293, 12051, 12, 15270, 402, 3775, 2005, 4454, 3405, 503, 440, 14, 199, 624, 199, 199, 646, 5055, 199, 646, 9143, 199, 646, 12866, 199, 646, 747, 14, 515, 199, 646, 3873, 199, 646, 984, 421, 199, 4685, 275, 5055, 14, 18921, 8, 272, 283, 4685, 297, 661, 3773, 63, 466, 297, 283, 2743, 297, 283, 1267, 297, 283, 15895, 1333, 421, 199, 318, 485, 1002, 5535, 2532, 14686, 8, 3771, 275, 488, 304, 523, 408, 14426, 314, 769, 402, 1584, 315, 314, 6135, 7611, 14, 819, 3033, 26, 272, 3792, 26, 25110, 2457, 367, 314, 2138, 3792, 14, 10162, 1395, 3663, 4811, 14, 523, 408, 523, 1249, 275, 788, 3187, 297, 283, 478, 13, 1725, 418, 523, 340, 3792, 26, 272, 1249, 14, 2880, 8, 3771, 9, 523, 1414, 275, 3873, 14, 7942, 8, 589, 12, 3839, 29, 5781, 14, 6089, 9, 523, 1072, 12, 485, 275, 1414, 14, 10664, 342, 523, 372, 1072, 14, 7644, 342, 421, 199, 318, 485, 12147, 37, 15256, 2532, 26080, 8, 1506, 63, 3619, 12, 3839, 304, 523, 408, 12147, 83, 4046, 769, 402, 7860, 1086, 687, 314, 4744, 1159, 3839, 14, 819, 710, 1420, 1475, 365, 22751, 737, 314, 2746, 402, 642, 570, 14, 819, 3033, 26, 272, 1900, 63, 3619, 26, 15191, 626, 3509, 314, 6555, 3050, 14, 8051, 370, 489, 7666, 314, 6203, 14, 272, 3839, 26, 710, 3839, 687, 3879, 314, 25444, 4744, 14, 819, 1803, 26, 272, 437, 2600, 4412, 6203, 370, 314, 4568, 7860, 1086, 14, 523, 408, 523, 2385, 275, 3839, 14, 7644, 342, 523, 1343, 63, 1080, 275, 2385, 14, 1080, 360, 532, 16427, 24981, 51, 275, 5918, 358, 523, 1284, 63, 1080, 275, 2385, 14, 1080, 360, 532, 7729, 24981, 51, 275, 5918, 358, 523, 7860, 1086, 275, 5055, 14, 21501, 8, 513, 9, 523, 367, 1004, 315, 2385, 59, 928, 63, 1080, 435, 413, 26, 500, 63, 1080, 2189, 272, 862, 26, 489, 5283, 63, 466, 12, 931, 12, 3268, 12, 2582, 12, 8343, 275, 1004, 14, 1294, 16451, 841, 9, 489, 327, 21017, 314, 570, 931, 19515, 701, 314, 25444, 4744, 370, 506, 3847, 370, 314, 489, 327, 1453, 6449, 2082, 14, 489, 931, 275, 747, 14, 515, 14, 12405, 8, 736, 14, 515, 14, 904, 8, 1506, 63, 3619, 12, 931, 430, 489, 7860, 1086, 59, 515, 1055, 740, 8, 4685, 8, 3773, 63, 466, 12, 1109, 8, 2743, 395, 1109, 8, 1267, 395, 8343, 430, 272, 871, 1722, 26, 489, 870, 283, 6005, 370, 2198, 5283, 26, 450, 83, 7, 450, 1004, 523, 372, 7860, 1086, 421, 199, 318, 485, 12049, 5157, 8, 3557, 354, 12, 1900, 63, 3619, 12, 1788, 304, 523, 408, 4858, 3862, 314, 4744, 14, 819, 961, 365, 3247, 9682, 314, 1021, 880, 652, 883, 506, 18731, 367, 314, 12866, 523, 859, 14, 819, 3033, 26, 272, 4744, 354, 26, 6912, 370, 314, 4744, 370, 5341, 14, 272, 1900, 63, 3619, 26, 15191, 626, 3509, 314, 6555, 3050, 14, 272, 1788, 26, 710, 570, 370, 1255, 314, 4744, 1806, 14, 819, 1803, 26, 272, 437, 2600, 626, 1471, 1395, 314, 790, 298, 1205, 2, 436, 282, 5046, 574, 272, 4568, 543, 652, 14, 339, 982, 2004, 365, 715, 12, 2066, 314, 4046, 7860, 1086, 787, 5489, 543, 314, 790, 298, 6297, 1086, 2, 272, 315, 314, 2600, 14, 339, 6630, 12, 314, 1788, 436, 314, 1072, 687, 4635, 787, 4568, 543, 314, 272, 2883, 298, 1501, 2, 436, 298, 3083, 2, 17342, 14, 523, 408, 523, 1414, 275, 3873, 14, 7942, 1332, 3557, 354, 12, 2475, 80, 297, 1900, 63, 3619, 12, 1788, 395, 2490, 3839, 29, 5781, 14, 6089, 12, 2490, 4635, 29, 5781, 14, 6089, 9, 523, 3839, 12, 4635, 275, 1414, 14, 10664, 342, 523, 340, 1414, 14, 9913, 1137, 378, 26, 272, 372, 791, 1205, 356, 756, 12, 283, 1501, 356, 1788, 12, 283, 3083, 356, 4635, 93, 523, 587, 26, 272, 372, 791, 1205, 356, 715, 12, 288, 283, 6297, 1086, 356, 485, 12147, 37, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jjas0nn/solvem
tensorflow/lib/python2.7/site-packages/numpy/lib/tests/test_nanfunctions.py
13
33689
from __future__ import division, absolute_import, print_function import warnings import numpy as np from numpy.testing import ( run_module_suite, TestCase, assert_, assert_equal, assert_almost_equal, assert_no_warnings, assert_raises, assert_array_equal, suppress_warnings ) # Test data _ndat = np.array([[0.6244, np.nan, 0.2692, 0.0116, np.nan, 0.1170], [0.5351, -0.9403, np.nan, 0.2100, 0.4759, 0.2833], [np.nan, np.nan, np.nan, 0.1042, np.nan, -0.5954], [0.1610, np.nan, np.nan, 0.1859, 0.3146, np.nan]]) # Rows of _ndat with nans removed _rdat = [np.array([0.6244, 0.2692, 0.0116, 0.1170]), np.array([0.5351, -0.9403, 0.2100, 0.4759, 0.2833]), np.array([0.1042, -0.5954]), np.array([0.1610, 0.1859, 0.3146])] # Rows of _ndat with nans converted to ones _ndat_ones = np.array([[0.6244, 1.0, 0.2692, 0.0116, 1.0, 0.1170], [0.5351, -0.9403, 1.0, 0.2100, 0.4759, 0.2833], [1.0, 1.0, 1.0, 0.1042, 1.0, -0.5954], [0.1610, 1.0, 1.0, 0.1859, 0.3146, 1.0]]) # Rows of _ndat with nans converted to zeros _ndat_zeros = np.array([[0.6244, 0.0, 0.2692, 0.0116, 0.0, 0.1170], [0.5351, -0.9403, 0.0, 0.2100, 0.4759, 0.2833], [0.0, 0.0, 0.0, 0.1042, 0.0, -0.5954], [0.1610, 0.0, 0.0, 0.1859, 0.3146, 0.0]]) class TestNanFunctions_MinMax(TestCase): nanfuncs = [np.nanmin, np.nanmax] stdfuncs = [np.min, np.max] def test_mutation(self): # Check that passed array is not modified. ndat = _ndat.copy() for f in self.nanfuncs: f(ndat) assert_equal(ndat, _ndat) def test_keepdims(self): mat = np.eye(3) for nf, rf in zip(self.nanfuncs, self.stdfuncs): for axis in [None, 0, 1]: tgt = rf(mat, axis=axis, keepdims=True) res = nf(mat, axis=axis, keepdims=True) assert_(res.ndim == tgt.ndim) def test_out(self): mat = np.eye(3) for nf, rf in zip(self.nanfuncs, self.stdfuncs): resout = np.zeros(3) tgt = rf(mat, axis=1) res = nf(mat, axis=1, out=resout) assert_almost_equal(res, resout) assert_almost_equal(res, tgt) def test_dtype_from_input(self): codes = 'efdgFDG' for nf, rf in zip(self.nanfuncs, self.stdfuncs): for c in codes: mat = np.eye(3, dtype=c) tgt = rf(mat, axis=1).dtype.type res = nf(mat, axis=1).dtype.type assert_(res is tgt) # scalar case tgt = rf(mat, axis=None).dtype.type res = nf(mat, axis=None).dtype.type assert_(res is tgt) def test_result_values(self): for nf, rf in zip(self.nanfuncs, self.stdfuncs): tgt = [rf(d) for d in _rdat] res = nf(_ndat, axis=1) assert_almost_equal(res, tgt) def test_allnans(self): mat = np.array([np.nan]*9).reshape(3, 3) for f in self.nanfuncs: for axis in [None, 0, 1]: with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') assert_(np.isnan(f(mat, axis=axis)).all()) assert_(len(w) == 1, 'no warning raised') assert_(issubclass(w[0].category, RuntimeWarning)) # Check scalars with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') assert_(np.isnan(f(np.nan))) assert_(len(w) == 1, 'no warning raised') assert_(issubclass(w[0].category, RuntimeWarning)) def test_masked(self): mat = np.ma.fix_invalid(_ndat) msk = mat._mask.copy() for f in [np.nanmin]: res = f(mat, axis=1) tgt = f(_ndat, axis=1) assert_equal(res, tgt) assert_equal(mat._mask, msk) assert_(not np.isinf(mat).any()) def test_scalar(self): for f in self.nanfuncs: assert_(f(0.) == 0.) def test_matrices(self): # Check that it works and that type and # shape are preserved mat = np.matrix(np.eye(3)) for f in self.nanfuncs: res = f(mat, axis=0) assert_(isinstance(res, np.matrix)) assert_(res.shape == (1, 3)) res = f(mat, axis=1) assert_(isinstance(res, np.matrix)) assert_(res.shape == (3, 1)) res = f(mat) assert_(np.isscalar(res)) # check that rows of nan are dealt with for subclasses (#4628) mat[1] = np.nan for f in self.nanfuncs: with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') res = f(mat, axis=0) assert_(isinstance(res, np.matrix)) assert_(not np.any(np.isnan(res))) assert_(len(w) == 0) with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') res = f(mat, axis=1) assert_(isinstance(res, np.matrix)) assert_(np.isnan(res[1, 0]) and not np.isnan(res[0, 0]) and not np.isnan(res[2, 0])) assert_(len(w) == 1, 'no warning raised') assert_(issubclass(w[0].category, RuntimeWarning)) with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') res = f(mat) assert_(np.isscalar(res)) assert_(res != np.nan) assert_(len(w) == 0) class TestNanFunctions_ArgminArgmax(TestCase): nanfuncs = [np.nanargmin, np.nanargmax] def test_mutation(self): # Check that passed array is not modified. ndat = _ndat.copy() for f in self.nanfuncs: f(ndat) assert_equal(ndat, _ndat) def test_result_values(self): for f, fcmp in zip(self.nanfuncs, [np.greater, np.less]): for row in _ndat: with suppress_warnings() as sup: sup.filter(RuntimeWarning, "invalid value encountered in") ind = f(row) val = row[ind] # comparing with NaN is tricky as the result # is always false except for NaN != NaN assert_(not np.isnan(val)) assert_(not fcmp(val, row).any()) assert_(not np.equal(val, row[:ind]).any()) def test_allnans(self): mat = np.array([np.nan]*9).reshape(3, 3) for f in self.nanfuncs: for axis in [None, 0, 1]: assert_raises(ValueError, f, mat, axis=axis) assert_raises(ValueError, f, np.nan) def test_empty(self): mat = np.zeros((0, 3)) for f in self.nanfuncs: for axis in [0, None]: assert_raises(ValueError, f, mat, axis=axis) for axis in [1]: res = f(mat, axis=axis) assert_equal(res, np.zeros(0)) def test_scalar(self): for f in self.nanfuncs: assert_(f(0.) == 0.) def test_matrices(self): # Check that it works and that type and # shape are preserved mat = np.matrix(np.eye(3)) for f in self.nanfuncs: res = f(mat, axis=0) assert_(isinstance(res, np.matrix)) assert_(res.shape == (1, 3)) res = f(mat, axis=1) assert_(isinstance(res, np.matrix)) assert_(res.shape == (3, 1)) res = f(mat) assert_(np.isscalar(res)) class TestNanFunctions_IntTypes(TestCase): int_types = (np.int8, np.int16, np.int32, np.int64, np.uint8, np.uint16, np.uint32, np.uint64) mat = np.array([127, 39, 93, 87, 46]) def integer_arrays(self): for dtype in self.int_types: yield self.mat.astype(dtype) def test_nanmin(self): tgt = np.min(self.mat) for mat in self.integer_arrays(): assert_equal(np.nanmin(mat), tgt) def test_nanmax(self): tgt = np.max(self.mat) for mat in self.integer_arrays(): assert_equal(np.nanmax(mat), tgt) def test_nanargmin(self): tgt = np.argmin(self.mat) for mat in self.integer_arrays(): assert_equal(np.nanargmin(mat), tgt) def test_nanargmax(self): tgt = np.argmax(self.mat) for mat in self.integer_arrays(): assert_equal(np.nanargmax(mat), tgt) def test_nansum(self): tgt = np.sum(self.mat) for mat in self.integer_arrays(): assert_equal(np.nansum(mat), tgt) def test_nanprod(self): tgt = np.prod(self.mat) for mat in self.integer_arrays(): assert_equal(np.nanprod(mat), tgt) def test_nancumsum(self): tgt = np.cumsum(self.mat) for mat in self.integer_arrays(): assert_equal(np.nancumsum(mat), tgt) def test_nancumprod(self): tgt = np.cumprod(self.mat) for mat in self.integer_arrays(): assert_equal(np.nancumprod(mat), tgt) def test_nanmean(self): tgt = np.mean(self.mat) for mat in self.integer_arrays(): assert_equal(np.nanmean(mat), tgt) def test_nanvar(self): tgt = np.var(self.mat) for mat in self.integer_arrays(): assert_equal(np.nanvar(mat), tgt) tgt = np.var(mat, ddof=1) for mat in self.integer_arrays(): assert_equal(np.nanvar(mat, ddof=1), tgt) def test_nanstd(self): tgt = np.std(self.mat) for mat in self.integer_arrays(): assert_equal(np.nanstd(mat), tgt) tgt = np.std(self.mat, ddof=1) for mat in self.integer_arrays(): assert_equal(np.nanstd(mat, ddof=1), tgt) class SharedNanFunctionsTestsMixin(object): def test_mutation(self): # Check that passed array is not modified. ndat = _ndat.copy() for f in self.nanfuncs: f(ndat) assert_equal(ndat, _ndat) def test_keepdims(self): mat = np.eye(3) for nf, rf in zip(self.nanfuncs, self.stdfuncs): for axis in [None, 0, 1]: tgt = rf(mat, axis=axis, keepdims=True) res = nf(mat, axis=axis, keepdims=True) assert_(res.ndim == tgt.ndim) def test_out(self): mat = np.eye(3) for nf, rf in zip(self.nanfuncs, self.stdfuncs): resout = np.zeros(3) tgt = rf(mat, axis=1) res = nf(mat, axis=1, out=resout) assert_almost_equal(res, resout) assert_almost_equal(res, tgt) def test_dtype_from_dtype(self): mat = np.eye(3) codes = 'efdgFDG' for nf, rf in zip(self.nanfuncs, self.stdfuncs): for c in codes: with suppress_warnings() as sup: if nf in {np.nanstd, np.nanvar} and c in 'FDG': # Giving the warning is a small bug, see gh-8000 sup.filter(np.ComplexWarning) tgt = rf(mat, dtype=np.dtype(c), axis=1).dtype.type res = nf(mat, dtype=np.dtype(c), axis=1).dtype.type assert_(res is tgt) # scalar case tgt = rf(mat, dtype=np.dtype(c), axis=None).dtype.type res = nf(mat, dtype=np.dtype(c), axis=None).dtype.type assert_(res is tgt) def test_dtype_from_char(self): mat = np.eye(3) codes = 'efdgFDG' for nf, rf in zip(self.nanfuncs, self.stdfuncs): for c in codes: with suppress_warnings() as sup: if nf in {np.nanstd, np.nanvar} and c in 'FDG': # Giving the warning is a small bug, see gh-8000 sup.filter(np.ComplexWarning) tgt = rf(mat, dtype=c, axis=1).dtype.type res = nf(mat, dtype=c, axis=1).dtype.type assert_(res is tgt) # scalar case tgt = rf(mat, dtype=c, axis=None).dtype.type res = nf(mat, dtype=c, axis=None).dtype.type assert_(res is tgt) def test_dtype_from_input(self): codes = 'efdgFDG' for nf, rf in zip(self.nanfuncs, self.stdfuncs): for c in codes: mat = np.eye(3, dtype=c) tgt = rf(mat, axis=1).dtype.type res = nf(mat, axis=1).dtype.type assert_(res is tgt, "res %s, tgt %s" % (res, tgt)) # scalar case tgt = rf(mat, axis=None).dtype.type res = nf(mat, axis=None).dtype.type assert_(res is tgt) def test_result_values(self): for nf, rf in zip(self.nanfuncs, self.stdfuncs): tgt = [rf(d) for d in _rdat] res = nf(_ndat, axis=1) assert_almost_equal(res, tgt) def test_scalar(self): for f in self.nanfuncs: assert_(f(0.) == 0.) def test_matrices(self): # Check that it works and that type and # shape are preserved mat = np.matrix(np.eye(3)) for f in self.nanfuncs: res = f(mat, axis=0) assert_(isinstance(res, np.matrix)) assert_(res.shape == (1, 3)) res = f(mat, axis=1) assert_(isinstance(res, np.matrix)) assert_(res.shape == (3, 1)) res = f(mat) assert_(np.isscalar(res)) class TestNanFunctions_SumProd(TestCase, SharedNanFunctionsTestsMixin): nanfuncs = [np.nansum, np.nanprod] stdfuncs = [np.sum, np.prod] def test_allnans(self): # Check for FutureWarning with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') res = np.nansum([np.nan]*3, axis=None) assert_(res == 0, 'result is not 0') assert_(len(w) == 0, 'warning raised') # Check scalar res = np.nansum(np.nan) assert_(res == 0, 'result is not 0') assert_(len(w) == 0, 'warning raised') # Check there is no warning for not all-nan np.nansum([0]*3, axis=None) assert_(len(w) == 0, 'unwanted warning raised') def test_empty(self): for f, tgt_value in zip([np.nansum, np.nanprod], [0, 1]): mat = np.zeros((0, 3)) tgt = [tgt_value]*3 res = f(mat, axis=0) assert_equal(res, tgt) tgt = [] res = f(mat, axis=1) assert_equal(res, tgt) tgt = tgt_value res = f(mat, axis=None) assert_equal(res, tgt) class TestNanFunctions_CumSumProd(TestCase, SharedNanFunctionsTestsMixin): nanfuncs = [np.nancumsum, np.nancumprod] stdfuncs = [np.cumsum, np.cumprod] def test_allnans(self): for f, tgt_value in zip(self.nanfuncs, [0, 1]): # Unlike other nan-functions, sum/prod/cumsum/cumprod don't warn on all nan input with assert_no_warnings(): res = f([np.nan]*3, axis=None) tgt = tgt_value*np.ones((3)) assert_(np.array_equal(res, tgt), 'result is not %s * np.ones((3))' % (tgt_value)) # Check scalar res = f(np.nan) tgt = tgt_value*np.ones((1)) assert_(np.array_equal(res, tgt), 'result is not %s * np.ones((1))' % (tgt_value)) # Check there is no warning for not all-nan f([0]*3, axis=None) def test_empty(self): for f, tgt_value in zip(self.nanfuncs, [0, 1]): mat = np.zeros((0, 3)) tgt = tgt_value*np.ones((0, 3)) res = f(mat, axis=0) assert_equal(res, tgt) tgt = mat res = f(mat, axis=1) assert_equal(res, tgt) tgt = np.zeros((0)) res = f(mat, axis=None) assert_equal(res, tgt) def test_keepdims(self): for f, g in zip(self.nanfuncs, self.stdfuncs): mat = np.eye(3) for axis in [None, 0, 1]: tgt = f(mat, axis=axis, out=None) res = g(mat, axis=axis, out=None) assert_(res.ndim == tgt.ndim) for f in self.nanfuncs: d = np.ones((3, 5, 7, 11)) # Randomly set some elements to NaN: rs = np.random.RandomState(0) d[rs.rand(*d.shape) < 0.5] = np.nan res = f(d, axis=None) assert_equal(res.shape, (1155,)) for axis in np.arange(4): res = f(d, axis=axis) assert_equal(res.shape, (3, 5, 7, 11)) def test_matrices(self): # Check that it works and that type and # shape are preserved mat = np.matrix(np.eye(3)) for f in self.nanfuncs: for axis in np.arange(2): res = f(mat, axis=axis) assert_(isinstance(res, np.matrix)) assert_(res.shape == (3, 3)) res = f(mat) assert_(res.shape == (1, 3*3)) def test_result_values(self): for axis in (-2, -1, 0, 1, None): tgt = np.cumprod(_ndat_ones, axis=axis) res = np.nancumprod(_ndat, axis=axis) assert_almost_equal(res, tgt) tgt = np.cumsum(_ndat_zeros,axis=axis) res = np.nancumsum(_ndat, axis=axis) assert_almost_equal(res, tgt) def test_out(self): mat = np.eye(3) for nf, rf in zip(self.nanfuncs, self.stdfuncs): resout = np.eye(3) for axis in (-2, -1, 0, 1): tgt = rf(mat, axis=axis) res = nf(mat, axis=axis, out=resout) assert_almost_equal(res, resout) assert_almost_equal(res, tgt) class TestNanFunctions_MeanVarStd(TestCase, SharedNanFunctionsTestsMixin): nanfuncs = [np.nanmean, np.nanvar, np.nanstd] stdfuncs = [np.mean, np.var, np.std] def test_dtype_error(self): for f in self.nanfuncs: for dtype in [np.bool_, np.int_, np.object_]: assert_raises(TypeError, f, _ndat, axis=1, dtype=dtype) def test_out_dtype_error(self): for f in self.nanfuncs: for dtype in [np.bool_, np.int_, np.object_]: out = np.empty(_ndat.shape[0], dtype=dtype) assert_raises(TypeError, f, _ndat, axis=1, out=out) def test_ddof(self): nanfuncs = [np.nanvar, np.nanstd] stdfuncs = [np.var, np.std] for nf, rf in zip(nanfuncs, stdfuncs): for ddof in [0, 1]: tgt = [rf(d, ddof=ddof) for d in _rdat] res = nf(_ndat, axis=1, ddof=ddof) assert_almost_equal(res, tgt) def test_ddof_too_big(self): nanfuncs = [np.nanvar, np.nanstd] stdfuncs = [np.var, np.std] dsize = [len(d) for d in _rdat] for nf, rf in zip(nanfuncs, stdfuncs): for ddof in range(5): with suppress_warnings() as sup: sup.record(RuntimeWarning) sup.filter(np.ComplexWarning) tgt = [ddof >= d for d in dsize] res = nf(_ndat, axis=1, ddof=ddof) assert_equal(np.isnan(res), tgt) if any(tgt): assert_(len(sup.log) == 1) else: assert_(len(sup.log) == 0) def test_allnans(self): mat = np.array([np.nan]*9).reshape(3, 3) for f in self.nanfuncs: for axis in [None, 0, 1]: with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') assert_(np.isnan(f(mat, axis=axis)).all()) assert_(len(w) == 1) assert_(issubclass(w[0].category, RuntimeWarning)) # Check scalar assert_(np.isnan(f(np.nan))) assert_(len(w) == 2) assert_(issubclass(w[0].category, RuntimeWarning)) def test_empty(self): mat = np.zeros((0, 3)) for f in self.nanfuncs: for axis in [0, None]: with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') assert_(np.isnan(f(mat, axis=axis)).all()) assert_(len(w) == 1) assert_(issubclass(w[0].category, RuntimeWarning)) for axis in [1]: with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') assert_equal(f(mat, axis=axis), np.zeros([])) assert_(len(w) == 0) class TestNanFunctions_Median(TestCase): def test_mutation(self): # Check that passed array is not modified. ndat = _ndat.copy() np.nanmedian(ndat) assert_equal(ndat, _ndat) def test_keepdims(self): mat = np.eye(3) for axis in [None, 0, 1]: tgt = np.median(mat, axis=axis, out=None, overwrite_input=False) res = np.nanmedian(mat, axis=axis, out=None, overwrite_input=False) assert_(res.ndim == tgt.ndim) d = np.ones((3, 5, 7, 11)) # Randomly set some elements to NaN: w = np.random.random((4, 200)) * np.array(d.shape)[:, None] w = w.astype(np.intp) d[tuple(w)] = np.nan with suppress_warnings() as sup: sup.filter(RuntimeWarning) res = np.nanmedian(d, axis=None, keepdims=True) assert_equal(res.shape, (1, 1, 1, 1)) res = np.nanmedian(d, axis=(0, 1), keepdims=True) assert_equal(res.shape, (1, 1, 7, 11)) res = np.nanmedian(d, axis=(0, 3), keepdims=True) assert_equal(res.shape, (1, 5, 7, 1)) res = np.nanmedian(d, axis=(1,), keepdims=True) assert_equal(res.shape, (3, 1, 7, 11)) res = np.nanmedian(d, axis=(0, 1, 2, 3), keepdims=True) assert_equal(res.shape, (1, 1, 1, 1)) res = np.nanmedian(d, axis=(0, 1, 3), keepdims=True) assert_equal(res.shape, (1, 1, 7, 1)) def test_out(self): mat = np.random.rand(3, 3) nan_mat = np.insert(mat, [0, 2], np.nan, axis=1) resout = np.zeros(3) tgt = np.median(mat, axis=1) res = np.nanmedian(nan_mat, axis=1, out=resout) assert_almost_equal(res, resout) assert_almost_equal(res, tgt) # 0-d output: resout = np.zeros(()) tgt = np.median(mat, axis=None) res = np.nanmedian(nan_mat, axis=None, out=resout) assert_almost_equal(res, resout) assert_almost_equal(res, tgt) res = np.nanmedian(nan_mat, axis=(0, 1), out=resout) assert_almost_equal(res, resout) assert_almost_equal(res, tgt) def test_small_large(self): # test the small and large code paths, current cutoff 400 elements for s in [5, 20, 51, 200, 1000]: d = np.random.randn(4, s) # Randomly set some elements to NaN: w = np.random.randint(0, d.size, size=d.size // 5) d.ravel()[w] = np.nan d[:,0] = 1. # ensure at least one good value # use normal median without nans to compare tgt = [] for x in d: nonan = np.compress(~np.isnan(x), x) tgt.append(np.median(nonan, overwrite_input=True)) assert_array_equal(np.nanmedian(d, axis=-1), tgt) def test_result_values(self): tgt = [np.median(d) for d in _rdat] res = np.nanmedian(_ndat, axis=1) assert_almost_equal(res, tgt) def test_allnans(self): mat = np.array([np.nan]*9).reshape(3, 3) for axis in [None, 0, 1]: with suppress_warnings() as sup: sup.record(RuntimeWarning) assert_(np.isnan(np.nanmedian(mat, axis=axis)).all()) if axis is None: assert_(len(sup.log) == 1) else: assert_(len(sup.log) == 3) # Check scalar assert_(np.isnan(np.nanmedian(np.nan))) if axis is None: assert_(len(sup.log) == 2) else: assert_(len(sup.log) == 4) def test_empty(self): mat = np.zeros((0, 3)) for axis in [0, None]: with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') assert_(np.isnan(np.nanmedian(mat, axis=axis)).all()) assert_(len(w) == 1) assert_(issubclass(w[0].category, RuntimeWarning)) for axis in [1]: with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') assert_equal(np.nanmedian(mat, axis=axis), np.zeros([])) assert_(len(w) == 0) def test_scalar(self): assert_(np.nanmedian(0.) == 0.) def test_extended_axis_invalid(self): d = np.ones((3, 5, 7, 11)) assert_raises(IndexError, np.nanmedian, d, axis=-5) assert_raises(IndexError, np.nanmedian, d, axis=(0, -5)) assert_raises(IndexError, np.nanmedian, d, axis=4) assert_raises(IndexError, np.nanmedian, d, axis=(0, 4)) assert_raises(ValueError, np.nanmedian, d, axis=(1, 1)) def test_float_special(self): with suppress_warnings() as sup: sup.filter(RuntimeWarning) for inf in [np.inf, -np.inf]: a = np.array([[inf, np.nan], [np.nan, np.nan]]) assert_equal(np.nanmedian(a, axis=0), [inf, np.nan]) assert_equal(np.nanmedian(a, axis=1), [inf, np.nan]) assert_equal(np.nanmedian(a), inf) # minimum fill value check a = np.array([[np.nan, np.nan, inf], [np.nan, np.nan, inf]]) assert_equal(np.nanmedian(a), inf) assert_equal(np.nanmedian(a, axis=0), [np.nan, np.nan, inf]) assert_equal(np.nanmedian(a, axis=1), inf) # no mask path a = np.array([[inf, inf], [inf, inf]]) assert_equal(np.nanmedian(a, axis=1), inf) for i in range(0, 10): for j in range(1, 10): a = np.array([([np.nan] * i) + ([inf] * j)] * 2) assert_equal(np.nanmedian(a), inf) assert_equal(np.nanmedian(a, axis=1), inf) assert_equal(np.nanmedian(a, axis=0), ([np.nan] * i) + [inf] * j) a = np.array([([np.nan] * i) + ([-inf] * j)] * 2) assert_equal(np.nanmedian(a), -inf) assert_equal(np.nanmedian(a, axis=1), -inf) assert_equal(np.nanmedian(a, axis=0), ([np.nan] * i) + [-inf] * j) class TestNanFunctions_Percentile(TestCase): def test_mutation(self): # Check that passed array is not modified. ndat = _ndat.copy() np.nanpercentile(ndat, 30) assert_equal(ndat, _ndat) def test_keepdims(self): mat = np.eye(3) for axis in [None, 0, 1]: tgt = np.percentile(mat, 70, axis=axis, out=None, overwrite_input=False) res = np.nanpercentile(mat, 70, axis=axis, out=None, overwrite_input=False) assert_(res.ndim == tgt.ndim) d = np.ones((3, 5, 7, 11)) # Randomly set some elements to NaN: w = np.random.random((4, 200)) * np.array(d.shape)[:, None] w = w.astype(np.intp) d[tuple(w)] = np.nan with suppress_warnings() as sup: sup.filter(RuntimeWarning) res = np.nanpercentile(d, 90, axis=None, keepdims=True) assert_equal(res.shape, (1, 1, 1, 1)) res = np.nanpercentile(d, 90, axis=(0, 1), keepdims=True) assert_equal(res.shape, (1, 1, 7, 11)) res = np.nanpercentile(d, 90, axis=(0, 3), keepdims=True) assert_equal(res.shape, (1, 5, 7, 1)) res = np.nanpercentile(d, 90, axis=(1,), keepdims=True) assert_equal(res.shape, (3, 1, 7, 11)) res = np.nanpercentile(d, 90, axis=(0, 1, 2, 3), keepdims=True) assert_equal(res.shape, (1, 1, 1, 1)) res = np.nanpercentile(d, 90, axis=(0, 1, 3), keepdims=True) assert_equal(res.shape, (1, 1, 7, 1)) def test_out(self): mat = np.random.rand(3, 3) nan_mat = np.insert(mat, [0, 2], np.nan, axis=1) resout = np.zeros(3) tgt = np.percentile(mat, 42, axis=1) res = np.nanpercentile(nan_mat, 42, axis=1, out=resout) assert_almost_equal(res, resout) assert_almost_equal(res, tgt) # 0-d output: resout = np.zeros(()) tgt = np.percentile(mat, 42, axis=None) res = np.nanpercentile(nan_mat, 42, axis=None, out=resout) assert_almost_equal(res, resout) assert_almost_equal(res, tgt) res = np.nanpercentile(nan_mat, 42, axis=(0, 1), out=resout) assert_almost_equal(res, resout) assert_almost_equal(res, tgt) def test_result_values(self): tgt = [np.percentile(d, 28) for d in _rdat] res = np.nanpercentile(_ndat, 28, axis=1) assert_almost_equal(res, tgt) # Transpose the array to fit the output convention of numpy.percentile tgt = np.transpose([np.percentile(d, (28, 98)) for d in _rdat]) res = np.nanpercentile(_ndat, (28, 98), axis=1) assert_almost_equal(res, tgt) def test_allnans(self): mat = np.array([np.nan]*9).reshape(3, 3) for axis in [None, 0, 1]: with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') assert_(np.isnan(np.nanpercentile(mat, 60, axis=axis)).all()) if axis is None: assert_(len(w) == 1) else: assert_(len(w) == 3) assert_(issubclass(w[0].category, RuntimeWarning)) # Check scalar assert_(np.isnan(np.nanpercentile(np.nan, 60))) if axis is None: assert_(len(w) == 2) else: assert_(len(w) == 4) assert_(issubclass(w[0].category, RuntimeWarning)) def test_empty(self): mat = np.zeros((0, 3)) for axis in [0, None]: with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') assert_(np.isnan(np.nanpercentile(mat, 40, axis=axis)).all()) assert_(len(w) == 1) assert_(issubclass(w[0].category, RuntimeWarning)) for axis in [1]: with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') assert_equal(np.nanpercentile(mat, 40, axis=axis), np.zeros([])) assert_(len(w) == 0) def test_scalar(self): assert_equal(np.nanpercentile(0., 100), 0.) a = np.arange(6) r = np.nanpercentile(a, 50, axis=0) assert_equal(r, 2.5) assert_(np.isscalar(r)) def test_extended_axis_invalid(self): d = np.ones((3, 5, 7, 11)) assert_raises(IndexError, np.nanpercentile, d, q=5, axis=-5) assert_raises(IndexError, np.nanpercentile, d, q=5, axis=(0, -5)) assert_raises(IndexError, np.nanpercentile, d, q=5, axis=4) assert_raises(IndexError, np.nanpercentile, d, q=5, axis=(0, 4)) assert_raises(ValueError, np.nanpercentile, d, q=5, axis=(1, 1)) def test_multiple_percentiles(self): perc = [50, 100] mat = np.ones((4, 3)) nan_mat = np.nan * mat # For checking consistency in higher dimensional case large_mat = np.ones((3, 4, 5)) large_mat[:, 0:2:4, :] = 0 large_mat[:, :, 3:] *= 2 for axis in [None, 0, 1]: for keepdim in [False, True]: with suppress_warnings() as sup: sup.filter(RuntimeWarning, "All-NaN slice encountered") val = np.percentile(mat, perc, axis=axis, keepdims=keepdim) nan_val = np.nanpercentile(nan_mat, perc, axis=axis, keepdims=keepdim) assert_equal(nan_val.shape, val.shape) val = np.percentile(large_mat, perc, axis=axis, keepdims=keepdim) nan_val = np.nanpercentile(large_mat, perc, axis=axis, keepdims=keepdim) assert_equal(nan_val, val) megamat = np.ones((3, 4, 5, 6)) assert_equal(np.nanpercentile(megamat, perc, axis=(1, 2)).shape, (2, 3, 6)) if __name__ == "__main__": run_module_suite()
mit
[ 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 3598, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 334, 272, 1255, 63, 578, 63, 5768, 12, 7640, 12, 702, 3131, 702, 63, 1452, 12, 702, 63, 4398, 63, 1452, 12, 272, 702, 63, 889, 63, 5451, 12, 702, 63, 3536, 12, 702, 63, 1144, 63, 1452, 12, 15678, 63, 5451, 272, 776, 421, 199, 3, 1379, 666, 199, 63, 977, 292, 275, 980, 14, 1144, 4038, 16, 14, 22, 11603, 12, 980, 14, 4304, 12, 378, 14, 1479, 2942, 12, 378, 14, 614, 975, 12, 980, 14, 4304, 12, 378, 14, 845, 2760, 467, 2116, 359, 16, 14, 7920, 17, 12, 446, 16, 14, 2635, 1644, 12, 980, 14, 4304, 12, 378, 14, 18, 1960, 12, 378, 14, 2417, 1427, 12, 378, 14, 1651, 1153, 467, 2116, 359, 1590, 14, 4304, 12, 980, 14, 4304, 12, 980, 14, 4304, 12, 378, 14, 709, 2260, 12, 980, 14, 4304, 12, 446, 16, 14, 1427, 1477, 467, 2116, 359, 16, 14, 975, 709, 12, 980, 14, 4304, 12, 980, 14, 4304, 12, 378, 14, 1085, 1427, 12, 378, 14, 8988, 22, 12, 980, 14, 4304, 3934, 421, 199, 3, 15231, 83, 402, 485, 977, 292, 543, 302, 796, 4829, 199, 63, 82, 4616, 275, 359, 1590, 14, 1144, 779, 16, 14, 22, 11603, 12, 378, 14, 1479, 2942, 12, 378, 14, 614, 975, 12, 378, 14, 845, 2760, 2522, 268, 980, 14, 1144, 779, 16, 14, 7920, 17, 12, 446, 16, 14, 2635, 1644, 12, 378, 14, 18, 1960, 12, 378, 14, 2417, 1427, 12, 378, 14, 1651, 1153, 2522, 268, 980, 14, 1144, 779, 16, 14, 709, 2260, 12, 446, 16, 14, 1427, 1477, 2522, 268, 980, 14, 1144, 779, 16, 14, 975, 709, 12, 378, 14, 1085, 1427, 12, 378, 14, 8988, 22, 12457, 199, 199, 3, 15231, 83, 402, 485, 977, 292, 543, 302, 796, 6702, 370, 7869, 199, 63, 977, 292, 63, 4548, 275, 980, 14, 1144, 4038, 16, 14, 22, 11603, 12, 413, 14, 16, 12, 378, 14, 1479, 2942, 12, 378, 14, 614, 975, 12, 413, 14, 16, 12, 378, 14, 845, 2760, 467, 2432, 359, 16, 14, 7920, 17, 12, 446, 16, 14, 2635, 1644, 12, 413, 14, 16, 12, 378, 14, 18, 1960, 12, 378, 14, 2417, 1427, 12, 378, 14, 1651, 1153, 467, 2432, 359, 17, 14, 16, 12, 413, 14, 16, 12, 413, 14, 16, 12, 378, 14, 709, 2260, 12, 413, 14, 16, 12, 446, 16, 14, 1427, 1477, 467, 2432, 359, 16, 14, 975, 709, 12, 413, 14, 16, 12, 413, 14, 16, 12, 378, 14, 1085, 1427, 12, 378, 14, 8988, 22, 12, 413, 14, 16, 3934, 199, 199, 3, 15231, 83, 402, 485, 977, 292, 543, 302, 796, 6702, 370, 10136, 199, 63, 977, 292, 63, 4250, 275, 980, 14, 1144, 4038, 16, 14, 22, 11603, 12, 378, 14, 16, 12, 378, 14, 1479, 2942, 12, 378, 14, 614, 975, 12, 378, 14, 16, 12, 378, 14, 845, 2760, 467, 717, 359, 16, 14, 7920, 17, 12, 446, 16, 14, 2635, 1644, 12, 378, 14, 16, 12, 378, 14, 18, 1960, 12, 378, 14, 2417, 1427, 12, 378, 14, 1651, 1153, 467, 717, 359, 16, 14, 16, 12, 378, 14, 16, 12, 378, 14, 16, 12, 378, 14, 709, 2260, 12, 378, 14, 16, 12, 446, 16, 14, 1427, 1477, 467, 717, 359, 16, 14, 975, 709, 12, 378, 14, 16, 12, 378, 14, 16, 12, 378, 14, 1085, 1427, 12, 378, 14, 8988, 22, 12, 378, 14, 16, 3934, 421, 199, 533, 1379, 27531, 13967, 63, 29334, 8, 1746, 304, 339, 12055, 9204, 275, 359, 1590, 14, 4304, 827, 12, 980, 14, 4304, 988, 61, 272, 2418, 9204, 275, 359, 1590, 14, 827, 12, 980, 14, 988, 61, 339, 347, 511, 63, 11627, 8, 277, 304, 267, 327, 2670, 626, 3032, 1625, 365, 440, 6042, 14, 267, 302, 4616, 275, 485, 977, 292, 14, 1574, 342, 267, 367, 289, 315, 291, 14, 4304, 9204, 26, 288, 289, 8, 977, 292, 9, 288, 702, 63, 1452, 8, 977, 292, 12, 485, 977, 292, 9, 339, 347, 511, 63, 3250, 5380, 8, 277, 304, 267, 2530, 275, 980, 14, 15240, 8, 19, 9, 267, 367, 302, 70, 12, 17781, 315, 3482, 8, 277, 14, 4304, 9204, 12, 291, 14, 1516, 9204, 304, 288, 367, 3114, 315, 359, 403, 12, 378, 12, 413, 2189, 355, 11967, 275, 17781, 8, 569, 12, 3114, 29, 3127, 12, 18492, 29, 549, 9, 355, 522, 275, 302, 70, 8, 569, 12, 3114, 29, 3127, 12, 18492, 29, 549, 9, 355, 702, 2531, 470, 14, 8322, 508, 11967, 14, 8322, 9, 339, 347, 511, 63, 548, 8, 277, 304, 267, 2530, 275, 980, 14, 15240, 8, 19, 9, 267, 367, 302, 70, 12, 17781, 315, 3482, 8, 277, 14, 4304, 9204, 12, 291, 14, 1516, 9204, 304, 288, 522, 548, 275, 980, 14, 4250, 8, 19, 9, 288, 11967, 275, 17781, 8, 569, 12, 3114, 29, 17, 9, 288, 522, 275, 302, 70, 8, 569, 12, 3114, 29, 17, 12, 734, 29, 470, 548, 9, 288, 702, 63, 4398, 63, 1452, 8, 470, 12, 522, 548, 9, 288, 702, 63, 4398, 63, 1452, 8, 470, 12, 11967, 9, 339, 347, 511, 63, 2271, 63, 504, 63, 1210, 8, 277, 304, 267, 9479, 275, 283, 69, 2592, 71, 7902, 39, 7, 267, 367, 302, 70, 12, 17781, 315, 3482, 8, 277, 14, 4304, 9204, 12, 291, 14, 1516, 9204, 304, 288, 367, 286, 315, 9479, 26, 355, 2530, 275, 980, 14, 15240, 8, 19, 12, 2152, 29, 67, 9, 355, 11967, 275, 17781, 8, 569, 12, 3114, 29, 17, 680, 2271, 14, 466, 355, 522, 275, 302, 70, 8, 569, 12, 3114, 29, 17, 680, 2271, 14, 466, 355, 702, 2531, 470, 365, 11967, 9, 355, 327, 6917, 1930, 355, 11967, 275, 17781, 8, 569, 12, 3114, 29, 403, 680, 2271, 14, 466, 355, 522, 275, 302, 70, 8, 569, 12, 3114, 29, 403, 680, 2271, 14, 466, 355, 702, 2531, 470, 365, 11967, 9, 339, 347, 511 ]
[ 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 3598, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 334, 272, 1255, 63, 578, 63, 5768, 12, 7640, 12, 702, 3131, 702, 63, 1452, 12, 702, 63, 4398, 63, 1452, 12, 272, 702, 63, 889, 63, 5451, 12, 702, 63, 3536, 12, 702, 63, 1144, 63, 1452, 12, 15678, 63, 5451, 272, 776, 421, 199, 3, 1379, 666, 199, 63, 977, 292, 275, 980, 14, 1144, 4038, 16, 14, 22, 11603, 12, 980, 14, 4304, 12, 378, 14, 1479, 2942, 12, 378, 14, 614, 975, 12, 980, 14, 4304, 12, 378, 14, 845, 2760, 467, 2116, 359, 16, 14, 7920, 17, 12, 446, 16, 14, 2635, 1644, 12, 980, 14, 4304, 12, 378, 14, 18, 1960, 12, 378, 14, 2417, 1427, 12, 378, 14, 1651, 1153, 467, 2116, 359, 1590, 14, 4304, 12, 980, 14, 4304, 12, 980, 14, 4304, 12, 378, 14, 709, 2260, 12, 980, 14, 4304, 12, 446, 16, 14, 1427, 1477, 467, 2116, 359, 16, 14, 975, 709, 12, 980, 14, 4304, 12, 980, 14, 4304, 12, 378, 14, 1085, 1427, 12, 378, 14, 8988, 22, 12, 980, 14, 4304, 3934, 421, 199, 3, 15231, 83, 402, 485, 977, 292, 543, 302, 796, 4829, 199, 63, 82, 4616, 275, 359, 1590, 14, 1144, 779, 16, 14, 22, 11603, 12, 378, 14, 1479, 2942, 12, 378, 14, 614, 975, 12, 378, 14, 845, 2760, 2522, 268, 980, 14, 1144, 779, 16, 14, 7920, 17, 12, 446, 16, 14, 2635, 1644, 12, 378, 14, 18, 1960, 12, 378, 14, 2417, 1427, 12, 378, 14, 1651, 1153, 2522, 268, 980, 14, 1144, 779, 16, 14, 709, 2260, 12, 446, 16, 14, 1427, 1477, 2522, 268, 980, 14, 1144, 779, 16, 14, 975, 709, 12, 378, 14, 1085, 1427, 12, 378, 14, 8988, 22, 12457, 199, 199, 3, 15231, 83, 402, 485, 977, 292, 543, 302, 796, 6702, 370, 7869, 199, 63, 977, 292, 63, 4548, 275, 980, 14, 1144, 4038, 16, 14, 22, 11603, 12, 413, 14, 16, 12, 378, 14, 1479, 2942, 12, 378, 14, 614, 975, 12, 413, 14, 16, 12, 378, 14, 845, 2760, 467, 2432, 359, 16, 14, 7920, 17, 12, 446, 16, 14, 2635, 1644, 12, 413, 14, 16, 12, 378, 14, 18, 1960, 12, 378, 14, 2417, 1427, 12, 378, 14, 1651, 1153, 467, 2432, 359, 17, 14, 16, 12, 413, 14, 16, 12, 413, 14, 16, 12, 378, 14, 709, 2260, 12, 413, 14, 16, 12, 446, 16, 14, 1427, 1477, 467, 2432, 359, 16, 14, 975, 709, 12, 413, 14, 16, 12, 413, 14, 16, 12, 378, 14, 1085, 1427, 12, 378, 14, 8988, 22, 12, 413, 14, 16, 3934, 199, 199, 3, 15231, 83, 402, 485, 977, 292, 543, 302, 796, 6702, 370, 10136, 199, 63, 977, 292, 63, 4250, 275, 980, 14, 1144, 4038, 16, 14, 22, 11603, 12, 378, 14, 16, 12, 378, 14, 1479, 2942, 12, 378, 14, 614, 975, 12, 378, 14, 16, 12, 378, 14, 845, 2760, 467, 717, 359, 16, 14, 7920, 17, 12, 446, 16, 14, 2635, 1644, 12, 378, 14, 16, 12, 378, 14, 18, 1960, 12, 378, 14, 2417, 1427, 12, 378, 14, 1651, 1153, 467, 717, 359, 16, 14, 16, 12, 378, 14, 16, 12, 378, 14, 16, 12, 378, 14, 709, 2260, 12, 378, 14, 16, 12, 446, 16, 14, 1427, 1477, 467, 717, 359, 16, 14, 975, 709, 12, 378, 14, 16, 12, 378, 14, 16, 12, 378, 14, 1085, 1427, 12, 378, 14, 8988, 22, 12, 378, 14, 16, 3934, 421, 199, 533, 1379, 27531, 13967, 63, 29334, 8, 1746, 304, 339, 12055, 9204, 275, 359, 1590, 14, 4304, 827, 12, 980, 14, 4304, 988, 61, 272, 2418, 9204, 275, 359, 1590, 14, 827, 12, 980, 14, 988, 61, 339, 347, 511, 63, 11627, 8, 277, 304, 267, 327, 2670, 626, 3032, 1625, 365, 440, 6042, 14, 267, 302, 4616, 275, 485, 977, 292, 14, 1574, 342, 267, 367, 289, 315, 291, 14, 4304, 9204, 26, 288, 289, 8, 977, 292, 9, 288, 702, 63, 1452, 8, 977, 292, 12, 485, 977, 292, 9, 339, 347, 511, 63, 3250, 5380, 8, 277, 304, 267, 2530, 275, 980, 14, 15240, 8, 19, 9, 267, 367, 302, 70, 12, 17781, 315, 3482, 8, 277, 14, 4304, 9204, 12, 291, 14, 1516, 9204, 304, 288, 367, 3114, 315, 359, 403, 12, 378, 12, 413, 2189, 355, 11967, 275, 17781, 8, 569, 12, 3114, 29, 3127, 12, 18492, 29, 549, 9, 355, 522, 275, 302, 70, 8, 569, 12, 3114, 29, 3127, 12, 18492, 29, 549, 9, 355, 702, 2531, 470, 14, 8322, 508, 11967, 14, 8322, 9, 339, 347, 511, 63, 548, 8, 277, 304, 267, 2530, 275, 980, 14, 15240, 8, 19, 9, 267, 367, 302, 70, 12, 17781, 315, 3482, 8, 277, 14, 4304, 9204, 12, 291, 14, 1516, 9204, 304, 288, 522, 548, 275, 980, 14, 4250, 8, 19, 9, 288, 11967, 275, 17781, 8, 569, 12, 3114, 29, 17, 9, 288, 522, 275, 302, 70, 8, 569, 12, 3114, 29, 17, 12, 734, 29, 470, 548, 9, 288, 702, 63, 4398, 63, 1452, 8, 470, 12, 522, 548, 9, 288, 702, 63, 4398, 63, 1452, 8, 470, 12, 11967, 9, 339, 347, 511, 63, 2271, 63, 504, 63, 1210, 8, 277, 304, 267, 9479, 275, 283, 69, 2592, 71, 7902, 39, 7, 267, 367, 302, 70, 12, 17781, 315, 3482, 8, 277, 14, 4304, 9204, 12, 291, 14, 1516, 9204, 304, 288, 367, 286, 315, 9479, 26, 355, 2530, 275, 980, 14, 15240, 8, 19, 12, 2152, 29, 67, 9, 355, 11967, 275, 17781, 8, 569, 12, 3114, 29, 17, 680, 2271, 14, 466, 355, 522, 275, 302, 70, 8, 569, 12, 3114, 29, 17, 680, 2271, 14, 466, 355, 702, 2531, 470, 365, 11967, 9, 355, 327, 6917, 1930, 355, 11967, 275, 17781, 8, 569, 12, 3114, 29, 403, 680, 2271, 14, 466, 355, 522, 275, 302, 70, 8, 569, 12, 3114, 29, 403, 680, 2271, 14, 466, 355, 702, 2531, 470, 365, 11967, 9, 339, 347, 511, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
fsimkovic/cptbx
conkit/io/pcons.py
2
6785
# BSD 3-Clause License # # Copyright (c) 2016-19, University of Liverpool # 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 holder 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 HOLDER 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. """ Parser module specific to Pcons predictions This module can be used to parse all versions of the Pcons programs, i.e. PconsC, PconsC2, and PconsC3. """ __author__ = "Felix Simkovic" __date__ = "26 Oct 2016" __version__ = "0.1" import re from conkit.io._parser import ContactFileParser from conkit.core.contact import Contact from conkit.core.contactmap import ContactMap from conkit.core.contactfile import ContactFile from conkit.core.sequence import Sequence RE_COMMENT = re.compile(r"^#+\s*$") RE_JUNK = re.compile(r"^(PconsC3|Total|Sequence number|Sequence length).*\s*$") RE_GENERATED = re.compile(r"^Generated.*$") RE_SEQUENCE_NAME = re.compile(r"^Sequence name:\s+(.*)\s*$") RE_SEQUENCE = re.compile(r"^Sequence:\s*$") RE_PRED_CONTACTS = re.compile(r"^Predicted\s+contacts:\s*$") RE_CONTACT_HEADER = re.compile(r"^Res1\s+Res2\s+Score\s*$") RE_CONTACT = re.compile(r"^\s*(\d+)\s+(\d+)\s+(-?\d*\.\d+|\d+)\s*$") class PconsParser(ContactFileParser): """Class to parse a Pcons output This module can be used to parse all versions of the Pcons programs, i.e. PconsC, PconsC2, and PconsC3. """ def __init__(self): super(PconsParser, self).__init__() def read(self, f_handle, f_id="pcons"): """Read a contact file Parameters ---------- f_handle Open file handle [read permissions] f_id : str, optional Unique contact file identifier Returns ------- :obj:`~conkit.core.contactfile.ContactFile` """ contact_file = ContactFile(f_id) contact_map = ContactMap("1") contact_file.add(contact_map) lines = iter([l.rstrip() for l in f_handle if l.rstrip()]) done = object() line = next(lines, done) seq = "" seq_id = "seq_1" while line is not done: if not line: pass elif RE_GENERATED.match(line): contact_file.remark = line elif RE_SEQUENCE_NAME.match(line): seq_id = RE_SEQUENCE_NAME.match(line).group(1) elif RE_SEQUENCE.match(line): line = next(lines, done) while line is not done: if not line: break elif RE_CONTACT_HEADER.match(line): break elif RE_PRED_CONTACTS.match(line): break elif RE_CONTACT.match(line): break else: seq += line line = next(lines, done) if RE_CONTACT.match(line): res1_seq, res2_seq, raw_score = line.split() contact = Contact(int(res1_seq), int(res2_seq), float(raw_score)) contact_map.add(contact) line = next(lines, done) if seq: contact_map.sequence = Sequence(seq_id, seq) contact_file.method = "Contact map predicted using Pcons" return contact_file def write(self, f_handle, hierarchy, write_header_footer=True): """Write a contact file instance to to file Default format is ``PconsC3`` style, including comments and sequence information (if provided). Parameters ---------- f_handle Open file handle [write permissions] hierarchy : :obj:`~conkit.core.contactfile.ContactFile`, :obj:`~conkit.core.contactmap.ContactMap` or :obj:`~conkit.core.contact.Contact` write_header_footer : bool Write a PconsC3-typical header Raises ------ :exc:`RuntimeError` More than one contact map in the hierarchy """ contact_file = self._reconstruct(hierarchy) if len(contact_file) > 1: raise RuntimeError("More than one contact map provided") comment_line = "##############################################################################\n" content = "" for contact_map in contact_file: if write_header_footer: content += comment_line content += "PconsC3 result file\n" content += "Generated using ConKit\n" content += comment_line if contact_map.sequence is not None: content += "Sequence number: 1\n" content += "Sequence name: {}\n".format(contact_map.sequence.id) content += "Sequence length: {} aa.\n".format(contact_map.sequence.seq_len) content += "Sequence:\n" content += contact_map.sequence.seq + "\n" * 3 content += "Predicted contacts:\n" content += "Res1 Res2 Score\n" for contact in contact_map: res1_seq = contact.res1_seq res2_seq = contact.res2_seq raw_score = contact.raw_score content += "{:>4} {:>4} {:>.6f}\n".format(res1_seq, res2_seq, raw_score) if write_header_footer: content += "\n" + comment_line f_handle.write(content)
gpl-3.0
[ 3, 6289, 650, 13, 16009, 844, 199, 3, 199, 3, 1898, 334, 67, 9, 7800, 13, 1167, 12, 15904, 402, 491, 4380, 2293, 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, 7647, 26, 199, 3, 199, 3, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 199, 3, 257, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 257, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 199, 3, 257, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 627, 11443, 314, 536, 402, 314, 4248, 16712, 6590, 314, 1561, 402, 2399, 199, 3, 257, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 257, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 6483, 6262, 7024, 199, 3, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 199, 3, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 199, 3, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 199, 3, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 624, 199, 2842, 859, 2488, 370, 510, 8704, 7914, 199, 199, 2765, 859, 883, 506, 1202, 370, 2198, 1006, 5459, 199, 1618, 314, 510, 8704, 18572, 12, 284, 14, 69, 14, 510, 8704, 35, 12, 510, 8704, 35, 18, 12, 199, 460, 510, 8704, 35, 19, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 298, 3456, 20528, 10751, 7697, 31629, 2, 199, 363, 602, 363, 275, 298, 1479, 18365, 7800, 2, 199, 363, 1023, 363, 275, 298, 16, 14, 17, 2, 199, 199, 646, 295, 199, 199, 504, 406, 6065, 14, 2308, 423, 2087, 492, 18684, 1173, 2842, 199, 504, 406, 6065, 14, 1018, 14, 7811, 492, 18684, 199, 504, 406, 6065, 14, 1018, 14, 7811, 1130, 492, 18684, 2956, 199, 504, 406, 6065, 14, 1018, 14, 7811, 493, 492, 18684, 1173, 199, 504, 406, 6065, 14, 1018, 14, 4041, 492, 10975, 199, 199, 907, 63, 10973, 275, 295, 14, 2014, 8, 82, 16136, 3, 7896, 83, 10, 22550, 199, 907, 63, 42, 8019, 275, 295, 14, 2014, 8, 82, 16136, 8, 48, 8704, 35, 19, 92, 7316, 92, 5826, 1329, 92, 5826, 2582, 680, 7590, 83, 10, 22550, 199, 907, 63, 12795, 6989, 275, 295, 14, 2014, 8, 82, 16136, 12706, 2795, 22550, 199, 907, 63, 16585, 63, 2339, 275, 295, 14, 2014, 8, 82, 16136, 5826, 536, 3427, 83, 15622, 2795, 2862, 83, 10, 22550, 199, 907, 63, 16585, 275, 295, 14, 2014, 8, 82, 16136, 5826, 3427, 83, 10, 22550, 199, 907, 63, 22973, 63, 5801, 3036, 51, 275, 295, 14, 2014, 8, 82, 16136, 30096, 60, 83, 11, 18147, 3427, 83, 10, 22550, 199, 907, 63, 5801, 3036, 63, 7311, 275, 295, 14, 2014, 8, 82, 16136, 1322, 17, 60, 83, 11, 1322, 18, 60, 83, 11, 12642, 60, 83, 10, 22550, 199, 907, 63, 5801, 3036, 275, 295, 14, 2014, 8, 82, 2, 12773, 83, 22588, 68, 13439, 83, 20900, 68, 13439, 83, 11, 2801, 8995, 68, 7590, 3134, 68, 11, 6113, 68, 13439, 83, 10, 22550, 421, 199, 533, 510, 8704, 2842, 8, 14499, 1173, 2842, 304, 272, 408, 2543, 370, 2198, 282, 510, 8704, 1072, 339, 961, 859, 883, 506, 1202, 370, 2198, 1006, 5459, 402, 314, 272, 510, 8704, 18572, 12, 284, 14, 69, 14, 510, 8704, 35, 12, 510, 8704, 35, 18, 12, 436, 510, 8704, 35, 19, 14, 339, 408, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 48, 8704, 2842, 12, 291, 2843, 826, 4533, 339, 347, 1586, 8, 277, 12, 289, 63, 2479, 12, 289, 63, 344, 628, 80, 8704, 2349, 267, 408, 3284, 282, 8966, 570, 398, 3897, 267, 4143, 267, 289, 63, 2479, 1779, 3232, 570, 2429, 359, 739, 3443, 61, 267, 289, 63, 344, 520, 620, 12, 2716, 1779, 18276, 8966, 570, 5148, 398, 1803, 267, 5514, 267, 520, 1113, 6054, 388, 6065, 14, 1018, 14, 7811, 493, 14, 14499, 1173, 64, 398, 408, 267, 8966, 63, 493, 275, 18684, 1173, 8, 70, 63, 344, 9, 267, 8966, 63, 1130, 275, 18684, 2956, 480, 17, 531, 267, 8966, 63, 493, 14, 525, 8, 7811, 63, 1130, 9, 398, 2385, 275, 2740, 779, 76, 14, 6735, 342, 367, 634, 315, 289, 63, 2479, 340, 634, 14, 6735, 9383, 267, 4224, 275, 909, 342, 267, 1004, 275, 2163, 8, 1278, 12, 4224, 9, 398, 5412, 275, 3087, 267, 5412, 63, 344, 275, 298, 3610, 63, 17, 2, 398, 1830, 1004, 365, 440, 4224, 26, 953, 340, 440, 1004, 26, 355, 986, 953, 916, 5363, 63, 12795, 6989, 14, 1431, 8, 604, 304, 355, 8966, 63, 493, 14, 264, 1657, 275, 1004, 953, 916, 5363, 63, 16585, 63, 2339, 14, 1431, 8, 604, 304, 355, 5412, 63, 344, 275, 5363, 63, 16585, 63, 2339, 14, 1431, 8, 604, 680, 923, 8, 17, 9, 953, 916, 5363, 63, 16585, 14, 1431, 8, 604, 304, 355, 1004, 275, 2163, 8, 1278, 12, 4224, 9, 355, 1830, 1004, 365, 440, 4224, 26, 490, 340, 440, 1004, 26, 717, 2059, 490, 916, 5363, 63, 5801, 3036, 63, 7311, 14, 1431, 8, 604, 304, 717, 2059, 490, 916, 5363, 63, 22973, 63, 5801, 3036, 51, 14, 1431 ]
[ 6289, 650, 13, 16009, 844, 199, 3, 199, 3, 1898, 334, 67, 9, 7800, 13, 1167, 12, 15904, 402, 491, 4380, 2293, 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, 7647, 26, 199, 3, 199, 3, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 199, 3, 257, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 257, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 199, 3, 257, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 627, 11443, 314, 536, 402, 314, 4248, 16712, 6590, 314, 1561, 402, 2399, 199, 3, 257, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 257, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 6483, 6262, 7024, 199, 3, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 199, 3, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 199, 3, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 199, 3, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 624, 199, 2842, 859, 2488, 370, 510, 8704, 7914, 199, 199, 2765, 859, 883, 506, 1202, 370, 2198, 1006, 5459, 199, 1618, 314, 510, 8704, 18572, 12, 284, 14, 69, 14, 510, 8704, 35, 12, 510, 8704, 35, 18, 12, 199, 460, 510, 8704, 35, 19, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 298, 3456, 20528, 10751, 7697, 31629, 2, 199, 363, 602, 363, 275, 298, 1479, 18365, 7800, 2, 199, 363, 1023, 363, 275, 298, 16, 14, 17, 2, 199, 199, 646, 295, 199, 199, 504, 406, 6065, 14, 2308, 423, 2087, 492, 18684, 1173, 2842, 199, 504, 406, 6065, 14, 1018, 14, 7811, 492, 18684, 199, 504, 406, 6065, 14, 1018, 14, 7811, 1130, 492, 18684, 2956, 199, 504, 406, 6065, 14, 1018, 14, 7811, 493, 492, 18684, 1173, 199, 504, 406, 6065, 14, 1018, 14, 4041, 492, 10975, 199, 199, 907, 63, 10973, 275, 295, 14, 2014, 8, 82, 16136, 3, 7896, 83, 10, 22550, 199, 907, 63, 42, 8019, 275, 295, 14, 2014, 8, 82, 16136, 8, 48, 8704, 35, 19, 92, 7316, 92, 5826, 1329, 92, 5826, 2582, 680, 7590, 83, 10, 22550, 199, 907, 63, 12795, 6989, 275, 295, 14, 2014, 8, 82, 16136, 12706, 2795, 22550, 199, 907, 63, 16585, 63, 2339, 275, 295, 14, 2014, 8, 82, 16136, 5826, 536, 3427, 83, 15622, 2795, 2862, 83, 10, 22550, 199, 907, 63, 16585, 275, 295, 14, 2014, 8, 82, 16136, 5826, 3427, 83, 10, 22550, 199, 907, 63, 22973, 63, 5801, 3036, 51, 275, 295, 14, 2014, 8, 82, 16136, 30096, 60, 83, 11, 18147, 3427, 83, 10, 22550, 199, 907, 63, 5801, 3036, 63, 7311, 275, 295, 14, 2014, 8, 82, 16136, 1322, 17, 60, 83, 11, 1322, 18, 60, 83, 11, 12642, 60, 83, 10, 22550, 199, 907, 63, 5801, 3036, 275, 295, 14, 2014, 8, 82, 2, 12773, 83, 22588, 68, 13439, 83, 20900, 68, 13439, 83, 11, 2801, 8995, 68, 7590, 3134, 68, 11, 6113, 68, 13439, 83, 10, 22550, 421, 199, 533, 510, 8704, 2842, 8, 14499, 1173, 2842, 304, 272, 408, 2543, 370, 2198, 282, 510, 8704, 1072, 339, 961, 859, 883, 506, 1202, 370, 2198, 1006, 5459, 402, 314, 272, 510, 8704, 18572, 12, 284, 14, 69, 14, 510, 8704, 35, 12, 510, 8704, 35, 18, 12, 436, 510, 8704, 35, 19, 14, 339, 408, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 48, 8704, 2842, 12, 291, 2843, 826, 4533, 339, 347, 1586, 8, 277, 12, 289, 63, 2479, 12, 289, 63, 344, 628, 80, 8704, 2349, 267, 408, 3284, 282, 8966, 570, 398, 3897, 267, 4143, 267, 289, 63, 2479, 1779, 3232, 570, 2429, 359, 739, 3443, 61, 267, 289, 63, 344, 520, 620, 12, 2716, 1779, 18276, 8966, 570, 5148, 398, 1803, 267, 5514, 267, 520, 1113, 6054, 388, 6065, 14, 1018, 14, 7811, 493, 14, 14499, 1173, 64, 398, 408, 267, 8966, 63, 493, 275, 18684, 1173, 8, 70, 63, 344, 9, 267, 8966, 63, 1130, 275, 18684, 2956, 480, 17, 531, 267, 8966, 63, 493, 14, 525, 8, 7811, 63, 1130, 9, 398, 2385, 275, 2740, 779, 76, 14, 6735, 342, 367, 634, 315, 289, 63, 2479, 340, 634, 14, 6735, 9383, 267, 4224, 275, 909, 342, 267, 1004, 275, 2163, 8, 1278, 12, 4224, 9, 398, 5412, 275, 3087, 267, 5412, 63, 344, 275, 298, 3610, 63, 17, 2, 398, 1830, 1004, 365, 440, 4224, 26, 953, 340, 440, 1004, 26, 355, 986, 953, 916, 5363, 63, 12795, 6989, 14, 1431, 8, 604, 304, 355, 8966, 63, 493, 14, 264, 1657, 275, 1004, 953, 916, 5363, 63, 16585, 63, 2339, 14, 1431, 8, 604, 304, 355, 5412, 63, 344, 275, 5363, 63, 16585, 63, 2339, 14, 1431, 8, 604, 680, 923, 8, 17, 9, 953, 916, 5363, 63, 16585, 14, 1431, 8, 604, 304, 355, 1004, 275, 2163, 8, 1278, 12, 4224, 9, 355, 1830, 1004, 365, 440, 4224, 26, 490, 340, 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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 ]
Distrotech/PyQt-x11
pyuic/uic/icon_cache.py
4
5431
############################################################################# ## ## Copyright (c) 2013 Riverbank Computing Limited <info@riverbankcomputing.com> ## ## This file is part of PyQt. ## ## This file may be used under the terms of the GNU General Public ## License versions 2.0 or 3.0 as published by the Free Software ## Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3 ## included in the packaging of this file. Alternatively you may (at ## your option) use any later version of the GNU General Public ## License if such license has been publicly approved by Riverbank ## Computing Limited (or its successors, if any) and the KDE Free Qt ## Foundation. In addition, as a special exception, Riverbank gives you ## certain additional rights. These rights are described in the Riverbank ## GPL Exception version 1.1, which can be found in the file ## GPL_EXCEPTION.txt in this package. ## ## If you are unsure which license is appropriate for your use, please ## contact the sales department at sales@riverbankcomputing.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 import os.path if sys.hexversion >= 0x03000000: from PyQt4.uic.port_v3.as_string import as_string else: from PyQt4.uic.port_v2.as_string import as_string class IconCache(object): """Maintain a cache of icons. If an icon is used more than once by a GUI then ensure that only one copy is created. """ def __init__(self, object_factory, qtgui_module): """Initialise the cache.""" self._object_factory = object_factory self._qtgui_module = qtgui_module self._base_dir = '' self._cache = [] def set_base_dir(self, base_dir): """ Set the base directory to be used for all relative filenames. """ self._base_dir = base_dir def get_icon(self, iconset): """Return an icon described by the given iconset tag.""" # Handle a themed icon. theme = iconset.attrib.get('theme') if theme is not None: return self._object_factory.createQObject("QIcon.fromTheme", 'icon', (as_string(theme), ), is_attribute=False) # Handle an empty iconset property. if iconset.text is None: return None iset = _IconSet(iconset, self._base_dir) try: idx = self._cache.index(iset) except ValueError: idx = -1 if idx >= 0: # Return the icon from the cache. iset = self._cache[idx] else: # Follow uic's naming convention. name = 'icon' idx = len(self._cache) if idx > 0: name += str(idx) icon = self._object_factory.createQObject("QIcon", name, (), is_attribute=False) iset.set_icon(icon, self._qtgui_module) self._cache.append(iset) return iset.icon class _IconSet(object): """An icon set, ie. the mode and state and the pixmap used for each.""" def __init__(self, iconset, base_dir): """Initialise the icon set from an XML tag.""" # Set the pre-Qt v4.4 fallback (ie. with no roles). self._fallback = self._file_name(iconset.text, base_dir) self._use_fallback = True # Parse the icon set. self._roles = {} for i in iconset: file_name = i.text if file_name is not None: file_name = self._file_name(file_name, base_dir) self._roles[i.tag] = file_name self._use_fallback = False # There is no real icon yet. self.icon = None @staticmethod def _file_name(fname, base_dir): """ Convert a relative filename if we have a base directory. """ fname = fname.replace("\\", "\\\\") if base_dir != '' and fname[0] != ':' and not os.path.isabs(fname): fname = os.path.join(base_dir, fname) return fname def set_icon(self, icon, qtgui_module): """Save the icon and set its attributes.""" if self._use_fallback: icon.addFile(self._fallback) else: for role, pixmap in self._roles.items(): if role.endswith("off"): mode = role[:-3] state = qtgui_module.QIcon.Off elif role.endswith("on"): mode = role[:-2] state = qtgui_module.QIcon.On else: continue mode = getattr(qtgui_module.QIcon, mode.title()) if pixmap: icon.addPixmap(qtgui_module.QPixmap(pixmap), mode, state) else: icon.addPixmap(qtgui_module.QPixmap(), mode, state) self.icon = icon def __eq__(self, other): """Compare two icon sets for equality.""" if not isinstance(other, type(self)): return NotImplemented if self._use_fallback: if other._use_fallback: return self._fallback == other._fallback return False if other._use_fallback: return False return self._roles == other._roles
gpl-2.0
[ 31635, 199, 309, 199, 309, 1898, 334, 67, 9, 6171, 820, 4380, 9860, 27799, 23954, 665, 815, 32, 2046, 9860, 863, 4655, 14, 957, 30, 199, 309, 221, 199, 309, 961, 570, 365, 1777, 402, 14084, 14, 199, 309, 221, 199, 309, 961, 570, 1443, 506, 1202, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 199, 309, 844, 5459, 499, 14, 16, 503, 650, 14, 16, 465, 3267, 701, 314, 2868, 2290, 199, 309, 2752, 436, 7468, 316, 315, 314, 1584, 5113, 14, 12006, 18, 436, 5113, 14, 12006, 19, 199, 309, 5120, 315, 314, 27369, 402, 642, 570, 14, 221, 26776, 1265, 1443, 334, 292, 199, 309, 2195, 945, 9, 675, 1263, 2945, 1015, 402, 314, 1664, 1696, 1684, 199, 309, 844, 340, 4066, 4190, 965, 2757, 7974, 317, 429, 89, 30055, 701, 820, 4380, 9860, 199, 309, 27799, 23954, 334, 269, 2399, 3182, 1384, 12, 340, 1263, 9, 436, 314, 1804, 1093, 2868, 3959, 199, 309, 2752, 14, 1010, 10234, 12, 465, 282, 4539, 1919, 12, 820, 4380, 9860, 10557, 1265, 199, 309, 9842, 4722, 4481, 14, 5723, 4481, 787, 11736, 315, 314, 820, 4380, 9860, 199, 309, 14629, 2186, 1015, 413, 14, 17, 12, 1314, 883, 506, 1911, 315, 314, 570, 199, 309, 14629, 63, 15375, 14, 2424, 315, 642, 2559, 14, 199, 309, 221, 199, 309, 982, 1265, 787, 625, 3253, 1314, 4190, 365, 5827, 367, 2195, 675, 12, 8749, 199, 309, 8966, 314, 21702, 27669, 737, 21702, 32, 2046, 9860, 863, 4655, 14, 957, 14, 199, 309, 221, 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, 421, 199, 646, 984, 199, 646, 747, 14, 515, 199, 199, 692, 984, 14, 4097, 1023, 2356, 378, 88, 1644, 3273, 26, 272, 687, 14084, 20, 14, 85, 530, 14, 719, 63, 86, 19, 14, 305, 63, 875, 492, 465, 63, 875, 199, 2836, 26, 272, 687, 14084, 20, 14, 85, 530, 14, 719, 63, 86, 18, 14, 305, 63, 875, 492, 465, 63, 875, 421, 199, 533, 473, 388, 4437, 8, 785, 304, 272, 408, 11903, 8368, 282, 2581, 402, 7016, 83, 14, 221, 982, 376, 7016, 365, 1202, 1655, 2419, 5403, 701, 282, 17160, 272, 2066, 4868, 626, 1454, 1373, 1331, 365, 2737, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 909, 63, 3702, 12, 19227, 5885, 63, 578, 304, 267, 408, 5733, 572, 314, 2581, 1041, 398, 291, 423, 785, 63, 3702, 275, 909, 63, 3702, 267, 291, 423, 8440, 5885, 63, 578, 275, 19227, 5885, 63, 578, 267, 291, 423, 1095, 63, 694, 275, 2125, 267, 291, 423, 1637, 275, 942, 339, 347, 663, 63, 1095, 63, 694, 8, 277, 12, 1300, 63, 694, 304, 267, 408, 2494, 314, 1300, 2082, 370, 506, 1202, 367, 1006, 3847, 6203, 14, 408, 398, 291, 423, 1095, 63, 694, 275, 1300, 63, 694, 339, 347, 664, 63, 4677, 8, 277, 12, 7016, 409, 304, 267, 408, 1767, 376, 7016, 11736, 701, 314, 1627, 7016, 409, 1947, 1041, 398, 327, 8690, 282, 314, 3594, 7016, 14, 267, 8879, 275, 7016, 409, 14, 6640, 14, 362, 360, 7915, 358, 267, 340, 8879, 365, 440, 488, 26, 288, 372, 291, 423, 785, 63, 3702, 14, 981, 32260, 480, 26196, 14, 504, 16849, 401, 490, 283, 4677, 297, 334, 305, 63, 875, 8, 7915, 395, 2318, 365, 63, 3215, 29, 797, 9, 398, 327, 8690, 376, 2701, 7016, 409, 3324, 14, 267, 340, 7016, 409, 14, 505, 365, 488, 26, 288, 372, 488, 398, 284, 409, 275, 485, 8954, 1084, 8, 4677, 409, 12, 291, 423, 1095, 63, 694, 9, 398, 862, 26, 288, 4280, 275, 291, 423, 1637, 14, 1080, 8, 73, 409, 9, 267, 871, 1722, 26, 288, 4280, 275, 446, 17, 398, 340, 4280, 2356, 378, 26, 288, 327, 1432, 314, 7016, 687, 314, 2581, 14, 288, 284, 409, 275, 291, 423, 1637, 59, 2996, 61, 267, 587, 26, 288, 327, 21876, 399, 530, 1159, 19720, 16129, 14, 288, 536, 275, 283, 4677, 7, 288, 4280, 275, 822, 8, 277, 423, 1637, 9, 953, 340, 4280, 690, 378, 26, 355, 536, 847, 620, 8, 2996, 9, 953, 7016, 275, 291, 423, 785, 63, 3702, 14, 981, 32260, 480, 26196, 401, 536, 12, 11969, 490, 365, 63, 3215, 29, 797, 9, 288, 284, 409, 14, 409, 63, 4677, 8, 4677, 12, 291, 423, 8440, 5885, 63, 578, 9, 288, 291, 423, 1637, 14, 740, 8, 73, 409, 9, 398, 372, 284, 409, 14, 4677, 421, 199, 533, 485, 8954, 1084, 8, 785, 304, 272, 408, 2493, 7016, 663, 12, 13446, 14, 314, 818, 436, 1174, 436, 314, 29876, 1202, 367, 1924, 1041, 339, 347, 636, 826, 721, 277, 12, 7016, 409, 12, 1300, 63, 694, 304, 267, 408, 5733, 572, 314, 7016, 663, 687, 376, 4692, 1947, 1041, 398, 327, 2494, 314, 876, 13, 4238, 373, 20, 14, 20, 9567, 334, 1873, 14, 543, 949, 11689, 680, 267, 291, 423, 10538, 275, 291, 423, 493, 63, 354, 8, 4677, 409, 14, 505, 12, 1300, 63, 694, 9, 267, 291, 423, 1180, 63, 10538, 275, 715, 398, 327, 6077, 314, 7016, 663, 14, 267, 291, 423, 8050, 275, 1052, 398, 367, 284, 315, 7016, 409, 26, 288, 570, 63, 354, 275, 284, 14, 505, 288, 340, 570, 63, 354, 365, 440, 488, 26, 355, 570, 63, 354, 275, 291, 423, 493, 63, 354, 8, 493, 63, 354, 12, 1300, 63, 694, 9, 953, 291, 423, 8050, 59, 73, 14, 1450, 61, 275, 570, 63, 354, 288, 291, 423, 1180, 63, 10538, 275, 756, 398, 327, 6006, 365, 949, 3363, 7016, 5966, 14, 267, 291, 14, 4677, 275, 488, 339, 768, 4639, 272, 347, 485, 493, 63, 354, 8, 5252, 12, 1300, 63, 694, 304, 267, 408, 7905, 282, 3847, 1788, 340, 781, 1172, 282, 1300, 2082, 14, 408, 398, 6748, 275, 6748, 14, 1814, 23236, 401, 298, 8712, 531, 398, 340, 1300, 63, 694, 1137, 2125, 436, 6748, 59, 16, 61, 1137, 10871, 436, 440, 747, 14, 515, 14, 17896, 8, 5252, 304, 288, 6748 ]
[ 199, 309, 199, 309, 1898, 334, 67, 9, 6171, 820, 4380, 9860, 27799, 23954, 665, 815, 32, 2046, 9860, 863, 4655, 14, 957, 30, 199, 309, 221, 199, 309, 961, 570, 365, 1777, 402, 14084, 14, 199, 309, 221, 199, 309, 961, 570, 1443, 506, 1202, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 199, 309, 844, 5459, 499, 14, 16, 503, 650, 14, 16, 465, 3267, 701, 314, 2868, 2290, 199, 309, 2752, 436, 7468, 316, 315, 314, 1584, 5113, 14, 12006, 18, 436, 5113, 14, 12006, 19, 199, 309, 5120, 315, 314, 27369, 402, 642, 570, 14, 221, 26776, 1265, 1443, 334, 292, 199, 309, 2195, 945, 9, 675, 1263, 2945, 1015, 402, 314, 1664, 1696, 1684, 199, 309, 844, 340, 4066, 4190, 965, 2757, 7974, 317, 429, 89, 30055, 701, 820, 4380, 9860, 199, 309, 27799, 23954, 334, 269, 2399, 3182, 1384, 12, 340, 1263, 9, 436, 314, 1804, 1093, 2868, 3959, 199, 309, 2752, 14, 1010, 10234, 12, 465, 282, 4539, 1919, 12, 820, 4380, 9860, 10557, 1265, 199, 309, 9842, 4722, 4481, 14, 5723, 4481, 787, 11736, 315, 314, 820, 4380, 9860, 199, 309, 14629, 2186, 1015, 413, 14, 17, 12, 1314, 883, 506, 1911, 315, 314, 570, 199, 309, 14629, 63, 15375, 14, 2424, 315, 642, 2559, 14, 199, 309, 221, 199, 309, 982, 1265, 787, 625, 3253, 1314, 4190, 365, 5827, 367, 2195, 675, 12, 8749, 199, 309, 8966, 314, 21702, 27669, 737, 21702, 32, 2046, 9860, 863, 4655, 14, 957, 14, 199, 309, 221, 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, 421, 199, 646, 984, 199, 646, 747, 14, 515, 199, 199, 692, 984, 14, 4097, 1023, 2356, 378, 88, 1644, 3273, 26, 272, 687, 14084, 20, 14, 85, 530, 14, 719, 63, 86, 19, 14, 305, 63, 875, 492, 465, 63, 875, 199, 2836, 26, 272, 687, 14084, 20, 14, 85, 530, 14, 719, 63, 86, 18, 14, 305, 63, 875, 492, 465, 63, 875, 421, 199, 533, 473, 388, 4437, 8, 785, 304, 272, 408, 11903, 8368, 282, 2581, 402, 7016, 83, 14, 221, 982, 376, 7016, 365, 1202, 1655, 2419, 5403, 701, 282, 17160, 272, 2066, 4868, 626, 1454, 1373, 1331, 365, 2737, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 909, 63, 3702, 12, 19227, 5885, 63, 578, 304, 267, 408, 5733, 572, 314, 2581, 1041, 398, 291, 423, 785, 63, 3702, 275, 909, 63, 3702, 267, 291, 423, 8440, 5885, 63, 578, 275, 19227, 5885, 63, 578, 267, 291, 423, 1095, 63, 694, 275, 2125, 267, 291, 423, 1637, 275, 942, 339, 347, 663, 63, 1095, 63, 694, 8, 277, 12, 1300, 63, 694, 304, 267, 408, 2494, 314, 1300, 2082, 370, 506, 1202, 367, 1006, 3847, 6203, 14, 408, 398, 291, 423, 1095, 63, 694, 275, 1300, 63, 694, 339, 347, 664, 63, 4677, 8, 277, 12, 7016, 409, 304, 267, 408, 1767, 376, 7016, 11736, 701, 314, 1627, 7016, 409, 1947, 1041, 398, 327, 8690, 282, 314, 3594, 7016, 14, 267, 8879, 275, 7016, 409, 14, 6640, 14, 362, 360, 7915, 358, 267, 340, 8879, 365, 440, 488, 26, 288, 372, 291, 423, 785, 63, 3702, 14, 981, 32260, 480, 26196, 14, 504, 16849, 401, 490, 283, 4677, 297, 334, 305, 63, 875, 8, 7915, 395, 2318, 365, 63, 3215, 29, 797, 9, 398, 327, 8690, 376, 2701, 7016, 409, 3324, 14, 267, 340, 7016, 409, 14, 505, 365, 488, 26, 288, 372, 488, 398, 284, 409, 275, 485, 8954, 1084, 8, 4677, 409, 12, 291, 423, 1095, 63, 694, 9, 398, 862, 26, 288, 4280, 275, 291, 423, 1637, 14, 1080, 8, 73, 409, 9, 267, 871, 1722, 26, 288, 4280, 275, 446, 17, 398, 340, 4280, 2356, 378, 26, 288, 327, 1432, 314, 7016, 687, 314, 2581, 14, 288, 284, 409, 275, 291, 423, 1637, 59, 2996, 61, 267, 587, 26, 288, 327, 21876, 399, 530, 1159, 19720, 16129, 14, 288, 536, 275, 283, 4677, 7, 288, 4280, 275, 822, 8, 277, 423, 1637, 9, 953, 340, 4280, 690, 378, 26, 355, 536, 847, 620, 8, 2996, 9, 953, 7016, 275, 291, 423, 785, 63, 3702, 14, 981, 32260, 480, 26196, 401, 536, 12, 11969, 490, 365, 63, 3215, 29, 797, 9, 288, 284, 409, 14, 409, 63, 4677, 8, 4677, 12, 291, 423, 8440, 5885, 63, 578, 9, 288, 291, 423, 1637, 14, 740, 8, 73, 409, 9, 398, 372, 284, 409, 14, 4677, 421, 199, 533, 485, 8954, 1084, 8, 785, 304, 272, 408, 2493, 7016, 663, 12, 13446, 14, 314, 818, 436, 1174, 436, 314, 29876, 1202, 367, 1924, 1041, 339, 347, 636, 826, 721, 277, 12, 7016, 409, 12, 1300, 63, 694, 304, 267, 408, 5733, 572, 314, 7016, 663, 687, 376, 4692, 1947, 1041, 398, 327, 2494, 314, 876, 13, 4238, 373, 20, 14, 20, 9567, 334, 1873, 14, 543, 949, 11689, 680, 267, 291, 423, 10538, 275, 291, 423, 493, 63, 354, 8, 4677, 409, 14, 505, 12, 1300, 63, 694, 9, 267, 291, 423, 1180, 63, 10538, 275, 715, 398, 327, 6077, 314, 7016, 663, 14, 267, 291, 423, 8050, 275, 1052, 398, 367, 284, 315, 7016, 409, 26, 288, 570, 63, 354, 275, 284, 14, 505, 288, 340, 570, 63, 354, 365, 440, 488, 26, 355, 570, 63, 354, 275, 291, 423, 493, 63, 354, 8, 493, 63, 354, 12, 1300, 63, 694, 9, 953, 291, 423, 8050, 59, 73, 14, 1450, 61, 275, 570, 63, 354, 288, 291, 423, 1180, 63, 10538, 275, 756, 398, 327, 6006, 365, 949, 3363, 7016, 5966, 14, 267, 291, 14, 4677, 275, 488, 339, 768, 4639, 272, 347, 485, 493, 63, 354, 8, 5252, 12, 1300, 63, 694, 304, 267, 408, 7905, 282, 3847, 1788, 340, 781, 1172, 282, 1300, 2082, 14, 408, 398, 6748, 275, 6748, 14, 1814, 23236, 401, 298, 8712, 531, 398, 340, 1300, 63, 694, 1137, 2125, 436, 6748, 59, 16, 61, 1137, 10871, 436, 440, 747, 14, 515, 14, 17896, 8, 5252, 304, 288, 6748, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
numerigraphe/odoo
addons/website_forum/tests/test_forum.py
87
7632
# -*- coding: utf-8 -*- from openerp.addons.website_forum.tests.common import KARMA, TestForumCommon from openerp.addons.website_forum.models.forum import KarmaError from openerp.exceptions import Warning, AccessError from openerp.tools import mute_logger class TestForum(TestForumCommon): @mute_logger('openerp.addons.base.ir.ir_model', 'openerp.models') def test_ask(self): Post = self.env['forum.post'] # Public user asks a question: not allowed with self.assertRaises(AccessError): Post.sudo(self.user_public).create({ 'name': " Question ?", 'forum_id': self.forum.id, }) # Portal user asks a question with tags: not allowed, unsufficient karma with self.assertRaises(KarmaError): Post.sudo(self.user_portal).create({ 'name': " Q_0", 'forum_id': self.forum.id, 'tag_ids': [(0, 0, {'name': 'Tag0', 'forum_id': self.forum.id})] }) # Portal user asks a question with tags: ok if enough karma self.user_portal.karma = KARMA['ask'] Post.sudo(self.user_portal).create({ 'name': " Q0", 'forum_id': self.forum.id, 'tag_ids': [(0, 0, {'name': 'Tag0', 'forum_id': self.forum.id})] }) self.assertEqual(self.user_portal.karma, KARMA['ask'] + KARMA['gen_que_new'], 'website_forum: wrong karma generation when asking question') @mute_logger('openerp.addons.base.ir.ir_model', 'openerp.models') def test_answer(self): Post = self.env['forum.post'] # Answers its own question: not allowed, unsufficient karma with self.assertRaises(KarmaError): Post.sudo(self.user_employee).create({ 'name': " A0", 'forum_id': self.forum.id, 'parent_id': self.post.id, }) # Answers on question: ok if enough karma self.user_employee.karma = KARMA['ans'] Post.sudo(self.user_employee).create({ 'name': " A0", 'forum_id': self.forum.id, 'parent_id': self.post.id, }) self.assertEqual(self.user_employee.karma, KARMA['ans'], 'website_forum: wrong karma generation when answering question') @mute_logger('openerp.addons.base.ir.ir_model', 'openerp.models') def test_vote_crash(self): Post = self.env['forum.post'] self.user_employee.karma = KARMA['ans'] emp_answer = Post.sudo(self.user_employee).create({ 'name': 'TestAnswer', 'forum_id': self.forum.id, 'parent_id': self.post.id}) # upvote its own post with self.assertRaises(Warning): emp_answer.vote(upvote=True) # not enough karma with self.assertRaises(KarmaError): self.post.sudo(self.user_portal).vote(upvote=True) def test_vote(self): self.post.create_uid.karma = KARMA['ask'] self.user_portal.karma = KARMA['upv'] self.post.sudo(self.user_portal).vote(upvote=True) self.assertEqual(self.post.create_uid.karma, KARMA['ask'] + KARMA['gen_que_upv'], 'website_forum: wrong karma generation of upvoted question author') @mute_logger('openerp.addons.base.ir.ir_model', 'openerp.models') def test_downvote_crash(self): Post = self.env['forum.post'] self.user_employee.karma = KARMA['ans'] emp_answer = Post.sudo(self.user_employee).create({ 'name': 'TestAnswer', 'forum_id': self.forum.id, 'parent_id': self.post.id}) # downvote its own post with self.assertRaises(Warning): emp_answer.vote(upvote=False) # not enough karma with self.assertRaises(KarmaError): self.post.sudo(self.user_portal).vote(upvote=False) def test_downvote(self): self.post.create_uid.karma = 50 self.user_portal.karma = KARMA['dwv'] self.post.sudo(self.user_portal).vote(upvote=False) self.assertEqual(self.post.create_uid.karma, 50 + KARMA['gen_que_dwv'], 'website_forum: wrong karma generation of downvoted question author') def test_comment_crash(self): with self.assertRaises(KarmaError): self.post.sudo(self.user_portal).message_post(body='Should crash', type='comment') def test_comment(self): self.post.sudo(self.user_employee).message_post(body='Test0', type='notification') self.user_employee.karma = KARMA['com_all'] self.post.sudo(self.user_employee).message_post(body='Test1', type='comment') self.assertEqual(len(self.post.message_ids), 4, 'website_forum: wrong behavior of message_post') def test_convert_answer_to_comment_crash(self): Post = self.env['forum.post'] # converting a question does nothing msg_ids = self.post.sudo(self.user_portal).convert_answer_to_comment() self.assertEqual(msg_ids[0], False, 'website_forum: question to comment conversion failed') self.assertEqual(Post.search([('name', '=', 'TestQuestion')])[0].forum_id.name, 'TestForum', 'website_forum: question to comment conversion failed') with self.assertRaises(KarmaError): self.answer.sudo(self.user_portal).convert_answer_to_comment() def test_convert_answer_to_comment(self): self.user_portal.karma = KARMA['com_conv_all'] post_author = self.answer.create_uid.partner_id msg_ids = self.answer.sudo(self.user_portal).convert_answer_to_comment() self.assertEqual(len(msg_ids), 1, 'website_forum: wrong answer to comment conversion') msg = self.env['mail.message'].browse(msg_ids[0]) self.assertEqual(msg.author_id, post_author, 'website_forum: wrong answer to comment conversion') self.assertIn('I am an anteater', msg.body, 'website_forum: wrong answer to comment conversion') def test_edit_post_crash(self): with self.assertRaises(KarmaError): self.post.sudo(self.user_portal).write({'name': 'I am not your father.'}) def test_edit_post(self): self.post.create_uid.karma = KARMA['edit_own'] self.post.write({'name': 'Actually I am your dog.'}) self.user_portal.karma = KARMA['edit_all'] self.post.sudo(self.user_portal).write({'name': 'Actually I am your cat.'}) def test_close_post_crash(self): with self.assertRaises(KarmaError): self.post.sudo(self.user_portal).close(None) def test_close_post_own(self): self.post.create_uid.karma = KARMA['close_own'] self.post.close(None) def test_close_post_all(self): self.user_portal.karma = KARMA['close_all'] self.post.sudo(self.user_portal).close(None) def test_deactivate_post_crash(self): with self.assertRaises(KarmaError): self.post.sudo(self.user_portal).write({'active': False}) def test_deactivate_post_own(self): self.post.create_uid.karma = KARMA['unlink_own'] self.post.write({'active': False}) def test_deactivate_post_all(self): self.user_portal.karma = KARMA['unlink_all'] self.post.sudo(self.user_portal).write({'active': False}) def test_unlink_post_crash(self): with self.assertRaises(KarmaError): self.post.sudo(self.user_portal).unlink() def test_unlink_post_own(self): self.post.create_uid.karma = KARMA['unlink_own'] self.post.unlink() def test_unlink_post_all(self): self.user_portal.karma = KARMA['unlink_all'] self.post.sudo(self.user_portal).unlink()
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 5166, 14, 10788, 14, 7360, 63, 10044, 14, 2219, 14, 2330, 492, 1804, 689, 2054, 12, 1379, 1858, 453, 7844, 199, 504, 5166, 14, 10788, 14, 7360, 63, 10044, 14, 992, 14, 10044, 492, 1804, 14886, 547, 199, 504, 5166, 14, 3924, 492, 15902, 12, 11003, 547, 199, 504, 5166, 14, 2537, 492, 333, 938, 63, 2921, 421, 199, 533, 1379, 1858, 453, 8, 774, 1858, 453, 7844, 304, 339, 768, 12423, 63, 2921, 360, 11267, 14, 10788, 14, 1095, 14, 723, 14, 723, 63, 1238, 297, 283, 11267, 14, 992, 358, 272, 347, 511, 63, 813, 8, 277, 304, 267, 7711, 275, 291, 14, 1813, 459, 10044, 14, 1932, 418, 398, 327, 1684, 922, 465, 6080, 282, 7894, 26, 440, 4370, 267, 543, 291, 14, 1855, 8, 3946, 547, 304, 288, 7711, 14, 12095, 8, 277, 14, 751, 63, 3455, 680, 981, 2561, 355, 283, 354, 356, 298, 21421, 5805, 401, 355, 283, 10044, 63, 344, 356, 291, 14, 10044, 14, 344, 12, 288, 3828, 398, 327, 10977, 279, 922, 465, 6080, 282, 7894, 543, 3762, 26, 440, 4370, 12, 625, 83, 12983, 1022, 14886, 267, 543, 291, 14, 1855, 8, 43, 14886, 547, 304, 288, 7711, 14, 12095, 8, 277, 14, 751, 63, 8707, 680, 981, 2561, 355, 283, 354, 356, 298, 1413, 63, 16, 401, 355, 283, 10044, 63, 344, 356, 291, 14, 10044, 14, 344, 12, 355, 283, 1450, 63, 1580, 356, 3842, 16, 12, 378, 12, 791, 354, 356, 283, 1931, 16, 297, 283, 10044, 63, 344, 356, 291, 14, 10044, 14, 344, 1552, 61, 288, 3828, 398, 327, 10977, 279, 922, 465, 6080, 282, 7894, 543, 3762, 26, 4112, 340, 8321, 1022, 14886, 267, 291, 14, 751, 63, 8707, 14, 20814, 275, 1804, 689, 2054, 459, 813, 418, 267, 7711, 14, 12095, 8, 277, 14, 751, 63, 8707, 680, 981, 2561, 288, 283, 354, 356, 298, 1413, 16, 401, 288, 283, 10044, 63, 344, 356, 291, 14, 10044, 14, 344, 12, 288, 283, 1450, 63, 1580, 356, 3842, 16, 12, 378, 12, 791, 354, 356, 283, 1931, 16, 297, 283, 10044, 63, 344, 356, 291, 14, 10044, 14, 344, 1552, 61, 267, 3828, 267, 291, 14, 629, 8, 277, 14, 751, 63, 8707, 14, 20814, 12, 1804, 689, 2054, 459, 813, 418, 435, 1804, 689, 2054, 459, 2268, 63, 544, 63, 1222, 995, 283, 7360, 63, 10044, 26, 6835, 1022, 14886, 10152, 1380, 7198, 316, 7894, 358, 339, 768, 12423, 63, 2921, 360, 11267, 14, 10788, 14, 1095, 14, 723, 14, 723, 63, 1238, 297, 283, 11267, 14, 992, 358, 272, 347, 511, 63, 5934, 8, 277, 304, 267, 7711, 275, 291, 14, 1813, 459, 10044, 14, 1932, 418, 398, 327, 437, 561, 12203, 2399, 5705, 7894, 26, 440, 4370, 12, 625, 83, 12983, 1022, 14886, 267, 543, 291, 14, 1855, 8, 43, 14886, 547, 304, 288, 7711, 14, 12095, 8, 277, 14, 751, 63, 10103, 680, 981, 2561, 355, 283, 354, 356, 298, 437, 16, 401, 355, 283, 10044, 63, 344, 356, 291, 14, 10044, 14, 344, 12, 355, 283, 1708, 63, 344, 356, 291, 14, 1932, 14, 344, 12, 288, 3828, 398, 327, 437, 561, 12203, 641, 7894, 26, 4112, 340, 8321, 1022, 14886, 267, 291, 14, 751, 63, 10103, 14, 20814, 275, 1804, 689, 2054, 459, 796, 418, 267, 7711, 14, 12095, 8, 277, 14, 751, 63, 10103, 680, 981, 2561, 288, 283, 354, 356, 298, 437, 16, 401, 288, 283, 10044, 63, 344, 356, 291, 14, 10044, 14, 344, 12, 288, 283, 1708, 63, 344, 356, 291, 14, 1932, 14, 344, 12, 267, 3828, 267, 291, 14, 629, 8, 277, 14, 751, 63, 10103, 14, 20814, 12, 1804, 689, 2054, 459, 796, 995, 283, 7360, 63, 10044, 26, 6835, 1022, 14886, 10152, 1380, 6385, 316, 7894, 358, 339, 768, 12423, 63, 2921, 360, 11267, 14, 10788, 14, 1095, 14, 723, 14, 723, 63, 1238, 297, 283, 11267, 14, 992, 358, 272, 347, 511, 63, 14317, 63, 14807, 8, 277, 304, 267, 7711, 275, 291, 14, 1813, 459, 10044, 14, 1932, 418, 267, 291, 14, 751, 63, 10103, 14, 20814, 275, 1804, 689, 2054, 459, 796, 418, 267, 9052, 63, 5934, 275, 7711, 14, 12095, 8, 277, 14, 751, 63, 10103, 680, 981, 2561, 288, 283, 354, 356, 283, 774, 19104, 297, 288, 283, 10044, 63, 344, 356, 291, 14, 10044, 14, 344, 12, 288, 283, 1708, 63, 344, 356, 291, 14, 1932, 14, 344, 1552, 398, 327, 1536, 14317, 2399, 5705, 2963, 267, 543, 291, 14, 1855, 8, 3849, 304, 288, 9052, 63, 5934, 14, 14317, 8, 384, 14317, 29, 549, 9, 398, 327, 440, 8321, 1022, 14886, 267, 543, 291, 14, 1855, 8, 43, 14886, 547, 304, 288, 291, 14, 1932, 14, 12095, 8, 277, 14, 751, 63, 8707, 680, 14317, 8, 384, 14317, 29, 549, 9, 339, 347, 511, 63, 14317, 8, 277, 304, 267, 291, 14, 1932, 14, 981, 63, 1535, 14, 20814, 275, 1804, 689, 2054, 459, 813, 418, 267, 291, 14, 751, 63, 8707, 14, 20814, 275, 1804, 689, 2054, 459, 384, 86, 418, 267, 291, 14, 1932, 14, 12095, 8, 277, 14, 751, 63, 8707, 680, 14317, 8, 384, 14317, 29, 549, 9, 267, 291, 14, 629, 8, 277, 14, 1932, 14, 981, 63, 1535, 14, 20814, 12, 1804, 689, 2054, 459, 813, 418, 435, 1804, 689, 2054, 459, 2268, 63, 544, 63, 384, 86, 995, 283, 7360, 63, 10044, 26, 6835, 1022, 14886, 10152, 402, 1536, 2392, 471, 7894, 4132, 358, 339, 768, 12423, 63, 2921, 360, 11267, 14, 10788, 14, 1095, 14, 723, 14, 723, 63, 1238, 297, 283, 11267, 14, 992, 358, 272, 347, 511, 63, 2110, 14317, 63, 14807, 8, 277, 304, 267, 7711, 275, 291, 14, 1813, 459, 10044, 14, 1932, 418, 267, 291, 14, 751, 63, 10103, 14, 20814, 275, 1804, 689, 2054, 459, 796, 418, 267, 9052, 63, 5934, 275, 7711, 14, 12095, 8, 277, 14, 751, 63, 10103, 680, 981, 2561, 288, 283, 354, 356, 283, 774, 19104, 297, 288, 283, 10044, 63, 344, 356, 291, 14, 10044, 14, 344, 12, 288, 283, 1708, 63, 344, 356, 291, 14 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 5166, 14, 10788, 14, 7360, 63, 10044, 14, 2219, 14, 2330, 492, 1804, 689, 2054, 12, 1379, 1858, 453, 7844, 199, 504, 5166, 14, 10788, 14, 7360, 63, 10044, 14, 992, 14, 10044, 492, 1804, 14886, 547, 199, 504, 5166, 14, 3924, 492, 15902, 12, 11003, 547, 199, 504, 5166, 14, 2537, 492, 333, 938, 63, 2921, 421, 199, 533, 1379, 1858, 453, 8, 774, 1858, 453, 7844, 304, 339, 768, 12423, 63, 2921, 360, 11267, 14, 10788, 14, 1095, 14, 723, 14, 723, 63, 1238, 297, 283, 11267, 14, 992, 358, 272, 347, 511, 63, 813, 8, 277, 304, 267, 7711, 275, 291, 14, 1813, 459, 10044, 14, 1932, 418, 398, 327, 1684, 922, 465, 6080, 282, 7894, 26, 440, 4370, 267, 543, 291, 14, 1855, 8, 3946, 547, 304, 288, 7711, 14, 12095, 8, 277, 14, 751, 63, 3455, 680, 981, 2561, 355, 283, 354, 356, 298, 21421, 5805, 401, 355, 283, 10044, 63, 344, 356, 291, 14, 10044, 14, 344, 12, 288, 3828, 398, 327, 10977, 279, 922, 465, 6080, 282, 7894, 543, 3762, 26, 440, 4370, 12, 625, 83, 12983, 1022, 14886, 267, 543, 291, 14, 1855, 8, 43, 14886, 547, 304, 288, 7711, 14, 12095, 8, 277, 14, 751, 63, 8707, 680, 981, 2561, 355, 283, 354, 356, 298, 1413, 63, 16, 401, 355, 283, 10044, 63, 344, 356, 291, 14, 10044, 14, 344, 12, 355, 283, 1450, 63, 1580, 356, 3842, 16, 12, 378, 12, 791, 354, 356, 283, 1931, 16, 297, 283, 10044, 63, 344, 356, 291, 14, 10044, 14, 344, 1552, 61, 288, 3828, 398, 327, 10977, 279, 922, 465, 6080, 282, 7894, 543, 3762, 26, 4112, 340, 8321, 1022, 14886, 267, 291, 14, 751, 63, 8707, 14, 20814, 275, 1804, 689, 2054, 459, 813, 418, 267, 7711, 14, 12095, 8, 277, 14, 751, 63, 8707, 680, 981, 2561, 288, 283, 354, 356, 298, 1413, 16, 401, 288, 283, 10044, 63, 344, 356, 291, 14, 10044, 14, 344, 12, 288, 283, 1450, 63, 1580, 356, 3842, 16, 12, 378, 12, 791, 354, 356, 283, 1931, 16, 297, 283, 10044, 63, 344, 356, 291, 14, 10044, 14, 344, 1552, 61, 267, 3828, 267, 291, 14, 629, 8, 277, 14, 751, 63, 8707, 14, 20814, 12, 1804, 689, 2054, 459, 813, 418, 435, 1804, 689, 2054, 459, 2268, 63, 544, 63, 1222, 995, 283, 7360, 63, 10044, 26, 6835, 1022, 14886, 10152, 1380, 7198, 316, 7894, 358, 339, 768, 12423, 63, 2921, 360, 11267, 14, 10788, 14, 1095, 14, 723, 14, 723, 63, 1238, 297, 283, 11267, 14, 992, 358, 272, 347, 511, 63, 5934, 8, 277, 304, 267, 7711, 275, 291, 14, 1813, 459, 10044, 14, 1932, 418, 398, 327, 437, 561, 12203, 2399, 5705, 7894, 26, 440, 4370, 12, 625, 83, 12983, 1022, 14886, 267, 543, 291, 14, 1855, 8, 43, 14886, 547, 304, 288, 7711, 14, 12095, 8, 277, 14, 751, 63, 10103, 680, 981, 2561, 355, 283, 354, 356, 298, 437, 16, 401, 355, 283, 10044, 63, 344, 356, 291, 14, 10044, 14, 344, 12, 355, 283, 1708, 63, 344, 356, 291, 14, 1932, 14, 344, 12, 288, 3828, 398, 327, 437, 561, 12203, 641, 7894, 26, 4112, 340, 8321, 1022, 14886, 267, 291, 14, 751, 63, 10103, 14, 20814, 275, 1804, 689, 2054, 459, 796, 418, 267, 7711, 14, 12095, 8, 277, 14, 751, 63, 10103, 680, 981, 2561, 288, 283, 354, 356, 298, 437, 16, 401, 288, 283, 10044, 63, 344, 356, 291, 14, 10044, 14, 344, 12, 288, 283, 1708, 63, 344, 356, 291, 14, 1932, 14, 344, 12, 267, 3828, 267, 291, 14, 629, 8, 277, 14, 751, 63, 10103, 14, 20814, 12, 1804, 689, 2054, 459, 796, 995, 283, 7360, 63, 10044, 26, 6835, 1022, 14886, 10152, 1380, 6385, 316, 7894, 358, 339, 768, 12423, 63, 2921, 360, 11267, 14, 10788, 14, 1095, 14, 723, 14, 723, 63, 1238, 297, 283, 11267, 14, 992, 358, 272, 347, 511, 63, 14317, 63, 14807, 8, 277, 304, 267, 7711, 275, 291, 14, 1813, 459, 10044, 14, 1932, 418, 267, 291, 14, 751, 63, 10103, 14, 20814, 275, 1804, 689, 2054, 459, 796, 418, 267, 9052, 63, 5934, 275, 7711, 14, 12095, 8, 277, 14, 751, 63, 10103, 680, 981, 2561, 288, 283, 354, 356, 283, 774, 19104, 297, 288, 283, 10044, 63, 344, 356, 291, 14, 10044, 14, 344, 12, 288, 283, 1708, 63, 344, 356, 291, 14, 1932, 14, 344, 1552, 398, 327, 1536, 14317, 2399, 5705, 2963, 267, 543, 291, 14, 1855, 8, 3849, 304, 288, 9052, 63, 5934, 14, 14317, 8, 384, 14317, 29, 549, 9, 398, 327, 440, 8321, 1022, 14886, 267, 543, 291, 14, 1855, 8, 43, 14886, 547, 304, 288, 291, 14, 1932, 14, 12095, 8, 277, 14, 751, 63, 8707, 680, 14317, 8, 384, 14317, 29, 549, 9, 339, 347, 511, 63, 14317, 8, 277, 304, 267, 291, 14, 1932, 14, 981, 63, 1535, 14, 20814, 275, 1804, 689, 2054, 459, 813, 418, 267, 291, 14, 751, 63, 8707, 14, 20814, 275, 1804, 689, 2054, 459, 384, 86, 418, 267, 291, 14, 1932, 14, 12095, 8, 277, 14, 751, 63, 8707, 680, 14317, 8, 384, 14317, 29, 549, 9, 267, 291, 14, 629, 8, 277, 14, 1932, 14, 981, 63, 1535, 14, 20814, 12, 1804, 689, 2054, 459, 813, 418, 435, 1804, 689, 2054, 459, 2268, 63, 544, 63, 384, 86, 995, 283, 7360, 63, 10044, 26, 6835, 1022, 14886, 10152, 402, 1536, 2392, 471, 7894, 4132, 358, 339, 768, 12423, 63, 2921, 360, 11267, 14, 10788, 14, 1095, 14, 723, 14, 723, 63, 1238, 297, 283, 11267, 14, 992, 358, 272, 347, 511, 63, 2110, 14317, 63, 14807, 8, 277, 304, 267, 7711, 275, 291, 14, 1813, 459, 10044, 14, 1932, 418, 267, 291, 14, 751, 63, 10103, 14, 20814, 275, 1804, 689, 2054, 459, 796, 418, 267, 9052, 63, 5934, 275, 7711, 14, 12095, 8, 277, 14, 751, 63, 10103, 680, 981, 2561, 288, 283, 354, 356, 283, 774, 19104, 297, 288, 283, 10044, 63, 344, 356, 291, 14, 10044, 14, 344, 12, 288, 283, 1708, 63, 344, 356, 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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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 ]
evernym/zeno
plenum/common/ledger_uncommitted_tracker.py
2
2603
from stp_core.common.log import getlogger from collections import deque from common.exceptions import PlenumValueError, LogicError logger = getlogger() class LedgerUncommittedTracker: def __init__(self, last_committed_hash, last_txn_root, ledger_size): self.un_committed = deque() self.set_last_committed(last_committed_hash, last_txn_root, ledger_size) def apply_batch(self, state_root, txn_root, ledger_size): """ :param state_root: uncommitted state root :param ledger_size: ledger size, after committing (future ledger size) :return: """ if ledger_size < 0: raise PlenumValueError('ledger_size', ledger_size, "Incorrect size of ledger") self.un_committed.append((state_root, txn_root, ledger_size)) def commit_batch(self): """ :param state_root: committed state root :param ledger_size: committed ledger size :return: tuple of next committed state and count of committed transactions """ if len(self.un_committed) == 0: raise PlenumValueError("un_committed", self.un_committed, "commit_batch was called, but there is no tracked uncommitted states") last_committed_size_before = self.last_committed[2] uncommitted_hash, uncommitted_txn_root, uncommitted_size = self.un_committed.popleft() self.set_last_committed(uncommitted_hash, uncommitted_txn_root, uncommitted_size) return uncommitted_hash, uncommitted_txn_root, uncommitted_size - last_committed_size_before def reject_batch(self): """ Return hash reverting for and calculate count of reverted txns :return: root_hash, for reverting to (needed in revertToHead method) and count of reverted txns """ prev_size = 0 if len(self.un_committed) == 0: raise LogicError("No items to return") if len(self.un_committed) > 0: _, _, prev_size = self.un_committed.pop() if len(self.un_committed) == 0: committed_hash, committed_root, committed_size = self.last_committed return committed_hash, committed_root, prev_size - committed_size else: lhash, ltxn_root, lsize = self.un_committed[-1] return lhash, ltxn_root, prev_size - lsize def set_last_committed(self, state_root, txn_root, ledger_size): self.last_committed = (state_root, txn_root, ledger_size)
apache-2.0
[ 504, 410, 80, 63, 1018, 14, 2330, 14, 793, 492, 664, 2921, 199, 504, 5055, 492, 15782, 199, 504, 2863, 14, 3924, 492, 510, 552, 453, 3393, 12, 5297, 530, 547, 199, 199, 2921, 275, 664, 2921, 342, 421, 199, 533, 491, 379, 836, 1358, 20300, 13652, 26, 339, 347, 636, 826, 721, 277, 12, 2061, 63, 20300, 63, 2227, 12, 2061, 63, 18174, 63, 1231, 12, 29239, 836, 63, 890, 304, 267, 291, 14, 324, 63, 20300, 275, 15782, 342, 267, 291, 14, 409, 63, 2019, 63, 20300, 8, 2019, 63, 20300, 63, 2227, 12, 2061, 63, 18174, 63, 1231, 12, 29239, 836, 63, 890, 9, 339, 347, 4838, 63, 2912, 8, 277, 12, 1174, 63, 1231, 12, 23883, 63, 1231, 12, 29239, 836, 63, 890, 304, 267, 408, 398, 520, 635, 1174, 63, 1231, 26, 625, 20300, 1174, 1738, 267, 520, 635, 29239, 836, 63, 890, 26, 29239, 836, 1568, 12, 2410, 5532, 1337, 334, 2443, 29239, 836, 1568, 9, 267, 520, 1107, 26, 267, 408, 398, 340, 29239, 836, 63, 890, 665, 378, 26, 288, 746, 510, 552, 453, 3393, 360, 28771, 63, 890, 297, 3521, 29239, 836, 63, 890, 12, 3521, 298, 18298, 1568, 402, 29239, 836, 531, 398, 291, 14, 324, 63, 20300, 14, 740, 1332, 929, 63, 1231, 12, 23883, 63, 1231, 12, 29239, 836, 63, 890, 430, 339, 347, 5532, 63, 2912, 8, 277, 304, 267, 408, 398, 520, 635, 1174, 63, 1231, 26, 27659, 1174, 1738, 267, 520, 635, 29239, 836, 63, 890, 26, 27659, 29239, 836, 1568, 267, 520, 1107, 26, 2008, 402, 2163, 27659, 1174, 436, 2338, 402, 27659, 15809, 267, 408, 267, 340, 822, 8, 277, 14, 324, 63, 20300, 9, 508, 378, 26, 288, 746, 510, 552, 453, 3393, 480, 324, 63, 20300, 401, 3521, 291, 14, 324, 63, 20300, 12, 3521, 298, 3543, 63, 2912, 1990, 2797, 12, 1325, 2337, 365, 949, 23268, 625, 20300, 6363, 531, 267, 2061, 63, 20300, 63, 890, 63, 5182, 275, 291, 14, 2019, 63, 20300, 59, 18, 61, 267, 625, 20300, 63, 2227, 12, 625, 20300, 63, 18174, 63, 1231, 12, 625, 20300, 63, 890, 275, 291, 14, 324, 63, 20300, 14, 25704, 342, 267, 291, 14, 409, 63, 2019, 63, 20300, 8, 324, 20300, 63, 2227, 12, 625, 20300, 63, 18174, 63, 1231, 12, 625, 20300, 63, 890, 9, 267, 372, 625, 20300, 63, 2227, 12, 625, 20300, 63, 18174, 63, 1231, 12, 625, 20300, 63, 890, 446, 2061, 63, 20300, 63, 890, 63, 5182, 339, 347, 17100, 63, 2912, 8, 277, 304, 267, 408, 267, 1432, 2631, 29465, 1337, 367, 436, 8671, 2338, 402, 295, 16542, 4773, 561, 267, 520, 1107, 26, 1738, 63, 2227, 12, 367, 29465, 1337, 370, 334, 11368, 315, 23347, 1378, 11664, 1083, 9, 436, 2338, 402, 295, 16542, 4773, 561, 267, 408, 267, 5071, 63, 890, 275, 378, 267, 340, 822, 8, 277, 14, 324, 63, 20300, 9, 508, 378, 26, 288, 746, 5297, 530, 547, 480, 1944, 2974, 370, 372, 531, 267, 340, 822, 8, 277, 14, 324, 63, 20300, 9, 690, 378, 26, 288, 5501, 5501, 5071, 63, 890, 275, 291, 14, 324, 63, 20300, 14, 1935, 342, 267, 340, 822, 8, 277, 14, 324, 63, 20300, 9, 508, 378, 26, 288, 27659, 63, 2227, 12, 27659, 63, 1231, 12, 27659, 63, 890, 275, 291, 14, 2019, 63, 20300, 288, 372, 27659, 63, 2227, 12, 27659, 63, 1231, 12, 5071, 63, 890, 446, 27659, 63, 890, 267, 587, 26, 288, 634, 2227, 12, 634, 18174, 63, 1231, 12, 634, 890, 275, 291, 14, 324, 63, 20300, 1988, 17, 61, 288, 372, 634, 2227, 12, 634, 18174, 63, 1231, 12, 5071, 63, 890, 446, 634, 890, 339, 347, 663, 63, 2019, 63, 20300, 8, 277, 12, 1174, 63, 1231, 12, 23883, 63, 1231, 12, 29239, 836, 63, 890, 304, 267, 291, 14, 2019, 63, 20300, 275, 334, 929, 63, 1231, 12, 23883, 63, 1231, 12, 29239, 836, 63, 890, 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 ]
[ 410, 80, 63, 1018, 14, 2330, 14, 793, 492, 664, 2921, 199, 504, 5055, 492, 15782, 199, 504, 2863, 14, 3924, 492, 510, 552, 453, 3393, 12, 5297, 530, 547, 199, 199, 2921, 275, 664, 2921, 342, 421, 199, 533, 491, 379, 836, 1358, 20300, 13652, 26, 339, 347, 636, 826, 721, 277, 12, 2061, 63, 20300, 63, 2227, 12, 2061, 63, 18174, 63, 1231, 12, 29239, 836, 63, 890, 304, 267, 291, 14, 324, 63, 20300, 275, 15782, 342, 267, 291, 14, 409, 63, 2019, 63, 20300, 8, 2019, 63, 20300, 63, 2227, 12, 2061, 63, 18174, 63, 1231, 12, 29239, 836, 63, 890, 9, 339, 347, 4838, 63, 2912, 8, 277, 12, 1174, 63, 1231, 12, 23883, 63, 1231, 12, 29239, 836, 63, 890, 304, 267, 408, 398, 520, 635, 1174, 63, 1231, 26, 625, 20300, 1174, 1738, 267, 520, 635, 29239, 836, 63, 890, 26, 29239, 836, 1568, 12, 2410, 5532, 1337, 334, 2443, 29239, 836, 1568, 9, 267, 520, 1107, 26, 267, 408, 398, 340, 29239, 836, 63, 890, 665, 378, 26, 288, 746, 510, 552, 453, 3393, 360, 28771, 63, 890, 297, 3521, 29239, 836, 63, 890, 12, 3521, 298, 18298, 1568, 402, 29239, 836, 531, 398, 291, 14, 324, 63, 20300, 14, 740, 1332, 929, 63, 1231, 12, 23883, 63, 1231, 12, 29239, 836, 63, 890, 430, 339, 347, 5532, 63, 2912, 8, 277, 304, 267, 408, 398, 520, 635, 1174, 63, 1231, 26, 27659, 1174, 1738, 267, 520, 635, 29239, 836, 63, 890, 26, 27659, 29239, 836, 1568, 267, 520, 1107, 26, 2008, 402, 2163, 27659, 1174, 436, 2338, 402, 27659, 15809, 267, 408, 267, 340, 822, 8, 277, 14, 324, 63, 20300, 9, 508, 378, 26, 288, 746, 510, 552, 453, 3393, 480, 324, 63, 20300, 401, 3521, 291, 14, 324, 63, 20300, 12, 3521, 298, 3543, 63, 2912, 1990, 2797, 12, 1325, 2337, 365, 949, 23268, 625, 20300, 6363, 531, 267, 2061, 63, 20300, 63, 890, 63, 5182, 275, 291, 14, 2019, 63, 20300, 59, 18, 61, 267, 625, 20300, 63, 2227, 12, 625, 20300, 63, 18174, 63, 1231, 12, 625, 20300, 63, 890, 275, 291, 14, 324, 63, 20300, 14, 25704, 342, 267, 291, 14, 409, 63, 2019, 63, 20300, 8, 324, 20300, 63, 2227, 12, 625, 20300, 63, 18174, 63, 1231, 12, 625, 20300, 63, 890, 9, 267, 372, 625, 20300, 63, 2227, 12, 625, 20300, 63, 18174, 63, 1231, 12, 625, 20300, 63, 890, 446, 2061, 63, 20300, 63, 890, 63, 5182, 339, 347, 17100, 63, 2912, 8, 277, 304, 267, 408, 267, 1432, 2631, 29465, 1337, 367, 436, 8671, 2338, 402, 295, 16542, 4773, 561, 267, 520, 1107, 26, 1738, 63, 2227, 12, 367, 29465, 1337, 370, 334, 11368, 315, 23347, 1378, 11664, 1083, 9, 436, 2338, 402, 295, 16542, 4773, 561, 267, 408, 267, 5071, 63, 890, 275, 378, 267, 340, 822, 8, 277, 14, 324, 63, 20300, 9, 508, 378, 26, 288, 746, 5297, 530, 547, 480, 1944, 2974, 370, 372, 531, 267, 340, 822, 8, 277, 14, 324, 63, 20300, 9, 690, 378, 26, 288, 5501, 5501, 5071, 63, 890, 275, 291, 14, 324, 63, 20300, 14, 1935, 342, 267, 340, 822, 8, 277, 14, 324, 63, 20300, 9, 508, 378, 26, 288, 27659, 63, 2227, 12, 27659, 63, 1231, 12, 27659, 63, 890, 275, 291, 14, 2019, 63, 20300, 288, 372, 27659, 63, 2227, 12, 27659, 63, 1231, 12, 5071, 63, 890, 446, 27659, 63, 890, 267, 587, 26, 288, 634, 2227, 12, 634, 18174, 63, 1231, 12, 634, 890, 275, 291, 14, 324, 63, 20300, 1988, 17, 61, 288, 372, 634, 2227, 12, 634, 18174, 63, 1231, 12, 5071, 63, 890, 446, 634, 890, 339, 347, 663, 63, 2019, 63, 20300, 8, 277, 12, 1174, 63, 1231, 12, 23883, 63, 1231, 12, 29239, 836, 63, 890, 304, 267, 291, 14, 2019, 63, 20300, 275, 334, 929, 63, 1231, 12, 23883, 63, 1231, 12, 29239, 836, 63, 890, 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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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 ]
collects/VTK
Examples/Tutorial/Step4/Python/Cone4.py
23
3052
#!/usr/bin/env python # # This example demonstrates the creation of multiple actors and the # manipulation of their properties and transformations. It is a # derivative of Cone.py, see that example for more information. # import vtk import time # # Next we create an instance of vtkConeSource and set some of its # properties. The instance of vtkConeSource "cone" is part of a visualization # pipeline (it is a source process object); it produces data (output type is # vtkPolyData) which other filters may process. # cone = vtk.vtkConeSource () cone.SetHeight( 3.0 ) cone.SetRadius( 1.0 ) cone.SetResolution( 10 ) # # In this example we terminate the pipeline with a mapper process object. # (Intermediate filters such as vtkShrinkPolyData could be inserted in # between the source and the mapper.) We create an instance of # vtkPolyDataMapper to map the polygonal data into graphics primitives. We # connect the output of the cone souece to the input of this mapper. # coneMapper = vtk.vtkPolyDataMapper() coneMapper.SetInputConnection(cone.GetOutputPort()) # # Create an actor to represent the first cone. The actor's properties are # modified to give it different surface properties. By default, an actor # is create with a property so the GetProperty() method can be used. # coneActor = vtk.vtkActor() coneActor.SetMapper(coneMapper) coneActor.GetProperty().SetColor(0.2, 0.63, 0.79) coneActor.GetProperty().SetDiffuse(0.7) coneActor.GetProperty().SetSpecular(0.4) coneActor.GetProperty().SetSpecularPower(20) # # Create a property and directly manipulate it. Assign it to the # second actor. # property = vtk.vtkProperty() property.SetColor(1.0, 0.3882, 0.2784) property.SetDiffuse(0.7) property.SetSpecular(0.4) property.SetSpecularPower(20) # # Create a second actor and a property. The property is directly # manipulated and then assigned to the actor. In this way, a single # property can be shared among many actors. Note also that we use the # same mapper as the first actor did. This way we avoid duplicating # geometry, which may save lots of memory if the geoemtry is large. coneActor2 = vtk.vtkActor() coneActor2.SetMapper(coneMapper) coneActor2.GetProperty().SetColor(0.2, 0.63, 0.79) coneActor2.SetProperty(property) coneActor2.SetPosition(0, 2, 0) # # Create the Renderer and assign actors to it. A renderer is like a # viewport. It is part or all of a window on the screen and it is responsible # for drawing the actors it has. We also set the background color here. # ren1 = vtk.vtkRenderer() ren1.AddActor(coneActor) ren1.AddActor(coneActor2) ren1.SetBackground(0.1, 0.2, 0.4) # # Finally we create the render window which will show up on the screen # We put our renderer into the render window using AddRenderer. We also # set the size to be 300 pixels by 300. # renWin = vtk.vtkRenderWindow() renWin.AddRenderer(ren1) renWin.SetSize(300, 300) # # Now we loop over 360 degreeees and render the cone each time. # for i in range(0,360): time.sleep(0.03) renWin.Render() ren1.GetActiveCamera().Azimuth( 1 )
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 961, 2893, 23789, 31216, 314, 7143, 402, 3663, 282, 13451, 436, 314, 199, 3, 26212, 402, 3932, 4382, 436, 25947, 14, 2779, 365, 282, 199, 3, 18883, 402, 445, 368, 14, 647, 12, 1937, 626, 2893, 367, 1655, 2556, 14, 199, 3, 199, 199, 646, 11144, 199, 646, 900, 199, 199, 3, 199, 3, 16840, 781, 1218, 376, 1256, 402, 11144, 35, 368, 2980, 436, 663, 2005, 402, 2399, 199, 3, 4382, 14, 710, 1256, 402, 11144, 35, 368, 2980, 298, 67, 368, 2, 365, 1777, 402, 282, 13104, 2072, 199, 3, 7679, 334, 390, 365, 282, 1350, 2112, 909, 2736, 652, 16904, 666, 334, 1199, 730, 365, 199, 3, 11144, 12747, 1451, 9, 1314, 1163, 4766, 1443, 2112, 14, 199, 3, 199, 67, 368, 275, 11144, 14, 11919, 35, 368, 2980, 6248, 199, 67, 368, 14, 1084, 8436, 8, 650, 14, 16, 776, 199, 67, 368, 14, 1084, 19800, 8, 413, 14, 16, 776, 199, 67, 368, 14, 1084, 18508, 8, 1616, 776, 199, 199, 3, 199, 3, 1010, 642, 2893, 781, 15095, 314, 7679, 543, 282, 7796, 2112, 909, 14, 199, 3, 334, 2620, 5050, 4766, 4066, 465, 11144, 2662, 12465, 12747, 1451, 4293, 506, 11788, 315, 199, 3, 3382, 314, 1350, 436, 314, 7796, 4959, 221, 2136, 1218, 376, 1256, 402, 199, 3, 11144, 12747, 1451, 11880, 370, 2341, 314, 17248, 279, 666, 1901, 24348, 1979, 22337, 14, 2136, 199, 3, 4907, 314, 1072, 402, 314, 286, 368, 880, 310, 301, 370, 314, 1324, 402, 642, 7796, 14, 199, 3, 199, 67, 368, 11880, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 67, 368, 11880, 14, 32195, 8, 67, 368, 14, 30810, 1012, 199, 199, 3, 199, 3, 2790, 376, 20318, 370, 2954, 314, 1642, 286, 368, 14, 710, 20318, 1159, 4382, 787, 199, 3, 6042, 370, 8120, 652, 3365, 13195, 4382, 14, 4885, 849, 12, 376, 20318, 199, 3, 365, 1218, 543, 282, 3324, 880, 314, 2372, 3697, 342, 1083, 883, 506, 1202, 14, 199, 3, 199, 67, 368, 12258, 275, 11144, 14, 11919, 12258, 342, 199, 67, 368, 12258, 14, 1084, 11880, 8, 67, 368, 11880, 9, 199, 67, 368, 12258, 14, 22845, 1252, 1084, 4117, 8, 16, 14, 18, 12, 378, 14, 2766, 12, 378, 14, 1965, 9, 199, 67, 368, 12258, 14, 22845, 1252, 1084, 10746, 1180, 8, 16, 14, 23, 9, 199, 67, 368, 12258, 14, 22845, 1252, 1084, 5307, 2238, 8, 16, 14, 20, 9, 199, 67, 368, 12258, 14, 22845, 1252, 1084, 5307, 2238, 6921, 8, 1165, 9, 199, 199, 3, 199, 3, 2790, 282, 3324, 436, 5370, 27232, 652, 14, 16927, 652, 370, 314, 199, 3, 3499, 20318, 14, 199, 3, 199, 1829, 275, 11144, 14, 11919, 3697, 342, 199, 1829, 14, 1084, 4117, 8, 17, 14, 16, 12, 378, 14, 11403, 18, 12, 378, 14, 1465, 1349, 9, 199, 1829, 14, 1084, 10746, 1180, 8, 16, 14, 23, 9, 199, 1829, 14, 1084, 5307, 2238, 8, 16, 14, 20, 9, 199, 1829, 14, 1084, 5307, 2238, 6921, 8, 1165, 9, 199, 199, 3, 199, 3, 2790, 282, 3499, 20318, 436, 282, 3324, 14, 710, 3324, 365, 5370, 199, 3, 13335, 8097, 436, 2066, 7943, 370, 314, 20318, 14, 1010, 642, 4340, 12, 282, 2849, 199, 3, 3324, 883, 506, 5709, 16885, 5002, 282, 13451, 14, 3390, 2597, 626, 781, 675, 314, 199, 3, 2011, 7796, 465, 314, 1642, 20318, 8103, 14, 961, 4340, 781, 5126, 366, 4230, 1958, 199, 3, 3400, 12, 1314, 1443, 3354, 24213, 402, 4402, 340, 314, 8509, 5633, 893, 365, 7031, 14, 199, 67, 368, 12258, 18, 275, 11144, 14, 11919, 12258, 342, 199, 67, 368, 12258, 18, 14, 1084, 11880, 8, 67, 368, 11880, 9, 199, 67, 368, 12258, 18, 14, 22845, 1252, 1084, 4117, 8, 16, 14, 18, 12, 378, 14, 2766, 12, 378, 14, 1965, 9, 199, 67, 368, 12258, 18, 14, 1084, 3697, 8, 1829, 9, 199, 67, 368, 12258, 18, 14, 1084, 5625, 8, 16, 12, 499, 12, 378, 9, 199, 199, 3, 199, 3, 2790, 314, 10055, 5813, 436, 5090, 282, 13451, 370, 652, 14, 437, 11889, 365, 2839, 282, 199, 3, 2455, 719, 14, 2779, 365, 1777, 503, 1006, 402, 282, 4353, 641, 314, 6426, 436, 652, 365, 17845, 199, 3, 367, 17455, 314, 282, 13451, 652, 965, 14, 221, 2136, 2597, 663, 314, 8020, 3164, 2348, 14, 199, 3, 199, 828, 17, 275, 11144, 14, 11919, 11355, 342, 199, 828, 17, 14, 1123, 12258, 8, 67, 368, 12258, 9, 199, 828, 17, 14, 1123, 12258, 8, 67, 368, 12258, 18, 9, 199, 828, 17, 14, 1084, 14148, 8, 16, 14, 17, 12, 378, 14, 18, 12, 378, 14, 20, 9, 199, 199, 3, 199, 3, 19177, 781, 1218, 314, 3795, 4353, 1314, 911, 2498, 1536, 641, 314, 6426, 199, 3, 2136, 5324, 4154, 11889, 1901, 314, 3795, 4353, 1808, 2654, 11355, 14, 2136, 2597, 199, 3, 663, 314, 1568, 370, 506, 9601, 11094, 701, 9601, 14, 199, 3, 199, 828, 8886, 275, 11144, 14, 11919, 9216, 4301, 342, 199, 828, 8886, 14, 1123, 11355, 8, 828, 17, 9, 199, 828, 8886, 14, 1084, 2320, 8, 5863, 12, 9601, 9, 199, 199, 3, 199, 3, 7356, 781, 4438, 1806, 19434, 13666, 16950, 436, 3795, 314, 286, 368, 1924, 900, 14, 199, 3, 199, 509, 284, 315, 1425, 8, 16, 12, 11197, 304, 272, 900, 14, 4532, 8, 16, 14, 1644, 9, 339, 2903, 8886, 14, 9216, 342, 272, 2903, 17, 14, 1002, 7472, 18425, 1252, 32171, 26720, 8, 413, 776, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 961, 2893, 23789, 31216, 314, 7143, 402, 3663, 282, 13451, 436, 314, 199, 3, 26212, 402, 3932, 4382, 436, 25947, 14, 2779, 365, 282, 199, 3, 18883, 402, 445, 368, 14, 647, 12, 1937, 626, 2893, 367, 1655, 2556, 14, 199, 3, 199, 199, 646, 11144, 199, 646, 900, 199, 199, 3, 199, 3, 16840, 781, 1218, 376, 1256, 402, 11144, 35, 368, 2980, 436, 663, 2005, 402, 2399, 199, 3, 4382, 14, 710, 1256, 402, 11144, 35, 368, 2980, 298, 67, 368, 2, 365, 1777, 402, 282, 13104, 2072, 199, 3, 7679, 334, 390, 365, 282, 1350, 2112, 909, 2736, 652, 16904, 666, 334, 1199, 730, 365, 199, 3, 11144, 12747, 1451, 9, 1314, 1163, 4766, 1443, 2112, 14, 199, 3, 199, 67, 368, 275, 11144, 14, 11919, 35, 368, 2980, 6248, 199, 67, 368, 14, 1084, 8436, 8, 650, 14, 16, 776, 199, 67, 368, 14, 1084, 19800, 8, 413, 14, 16, 776, 199, 67, 368, 14, 1084, 18508, 8, 1616, 776, 199, 199, 3, 199, 3, 1010, 642, 2893, 781, 15095, 314, 7679, 543, 282, 7796, 2112, 909, 14, 199, 3, 334, 2620, 5050, 4766, 4066, 465, 11144, 2662, 12465, 12747, 1451, 4293, 506, 11788, 315, 199, 3, 3382, 314, 1350, 436, 314, 7796, 4959, 221, 2136, 1218, 376, 1256, 402, 199, 3, 11144, 12747, 1451, 11880, 370, 2341, 314, 17248, 279, 666, 1901, 24348, 1979, 22337, 14, 2136, 199, 3, 4907, 314, 1072, 402, 314, 286, 368, 880, 310, 301, 370, 314, 1324, 402, 642, 7796, 14, 199, 3, 199, 67, 368, 11880, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 67, 368, 11880, 14, 32195, 8, 67, 368, 14, 30810, 1012, 199, 199, 3, 199, 3, 2790, 376, 20318, 370, 2954, 314, 1642, 286, 368, 14, 710, 20318, 1159, 4382, 787, 199, 3, 6042, 370, 8120, 652, 3365, 13195, 4382, 14, 4885, 849, 12, 376, 20318, 199, 3, 365, 1218, 543, 282, 3324, 880, 314, 2372, 3697, 342, 1083, 883, 506, 1202, 14, 199, 3, 199, 67, 368, 12258, 275, 11144, 14, 11919, 12258, 342, 199, 67, 368, 12258, 14, 1084, 11880, 8, 67, 368, 11880, 9, 199, 67, 368, 12258, 14, 22845, 1252, 1084, 4117, 8, 16, 14, 18, 12, 378, 14, 2766, 12, 378, 14, 1965, 9, 199, 67, 368, 12258, 14, 22845, 1252, 1084, 10746, 1180, 8, 16, 14, 23, 9, 199, 67, 368, 12258, 14, 22845, 1252, 1084, 5307, 2238, 8, 16, 14, 20, 9, 199, 67, 368, 12258, 14, 22845, 1252, 1084, 5307, 2238, 6921, 8, 1165, 9, 199, 199, 3, 199, 3, 2790, 282, 3324, 436, 5370, 27232, 652, 14, 16927, 652, 370, 314, 199, 3, 3499, 20318, 14, 199, 3, 199, 1829, 275, 11144, 14, 11919, 3697, 342, 199, 1829, 14, 1084, 4117, 8, 17, 14, 16, 12, 378, 14, 11403, 18, 12, 378, 14, 1465, 1349, 9, 199, 1829, 14, 1084, 10746, 1180, 8, 16, 14, 23, 9, 199, 1829, 14, 1084, 5307, 2238, 8, 16, 14, 20, 9, 199, 1829, 14, 1084, 5307, 2238, 6921, 8, 1165, 9, 199, 199, 3, 199, 3, 2790, 282, 3499, 20318, 436, 282, 3324, 14, 710, 3324, 365, 5370, 199, 3, 13335, 8097, 436, 2066, 7943, 370, 314, 20318, 14, 1010, 642, 4340, 12, 282, 2849, 199, 3, 3324, 883, 506, 5709, 16885, 5002, 282, 13451, 14, 3390, 2597, 626, 781, 675, 314, 199, 3, 2011, 7796, 465, 314, 1642, 20318, 8103, 14, 961, 4340, 781, 5126, 366, 4230, 1958, 199, 3, 3400, 12, 1314, 1443, 3354, 24213, 402, 4402, 340, 314, 8509, 5633, 893, 365, 7031, 14, 199, 67, 368, 12258, 18, 275, 11144, 14, 11919, 12258, 342, 199, 67, 368, 12258, 18, 14, 1084, 11880, 8, 67, 368, 11880, 9, 199, 67, 368, 12258, 18, 14, 22845, 1252, 1084, 4117, 8, 16, 14, 18, 12, 378, 14, 2766, 12, 378, 14, 1965, 9, 199, 67, 368, 12258, 18, 14, 1084, 3697, 8, 1829, 9, 199, 67, 368, 12258, 18, 14, 1084, 5625, 8, 16, 12, 499, 12, 378, 9, 199, 199, 3, 199, 3, 2790, 314, 10055, 5813, 436, 5090, 282, 13451, 370, 652, 14, 437, 11889, 365, 2839, 282, 199, 3, 2455, 719, 14, 2779, 365, 1777, 503, 1006, 402, 282, 4353, 641, 314, 6426, 436, 652, 365, 17845, 199, 3, 367, 17455, 314, 282, 13451, 652, 965, 14, 221, 2136, 2597, 663, 314, 8020, 3164, 2348, 14, 199, 3, 199, 828, 17, 275, 11144, 14, 11919, 11355, 342, 199, 828, 17, 14, 1123, 12258, 8, 67, 368, 12258, 9, 199, 828, 17, 14, 1123, 12258, 8, 67, 368, 12258, 18, 9, 199, 828, 17, 14, 1084, 14148, 8, 16, 14, 17, 12, 378, 14, 18, 12, 378, 14, 20, 9, 199, 199, 3, 199, 3, 19177, 781, 1218, 314, 3795, 4353, 1314, 911, 2498, 1536, 641, 314, 6426, 199, 3, 2136, 5324, 4154, 11889, 1901, 314, 3795, 4353, 1808, 2654, 11355, 14, 2136, 2597, 199, 3, 663, 314, 1568, 370, 506, 9601, 11094, 701, 9601, 14, 199, 3, 199, 828, 8886, 275, 11144, 14, 11919, 9216, 4301, 342, 199, 828, 8886, 14, 1123, 11355, 8, 828, 17, 9, 199, 828, 8886, 14, 1084, 2320, 8, 5863, 12, 9601, 9, 199, 199, 3, 199, 3, 7356, 781, 4438, 1806, 19434, 13666, 16950, 436, 3795, 314, 286, 368, 1924, 900, 14, 199, 3, 199, 509, 284, 315, 1425, 8, 16, 12, 11197, 304, 272, 900, 14, 4532, 8, 16, 14, 1644, 9, 339, 2903, 8886, 14, 9216, 342, 272, 2903, 17, 14, 1002, 7472, 18425, 1252, 32171, 26720, 8, 413, 776, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
unnikrishnankgs/va
venv/lib/python3.5/site-packages/PIL/ImageDraw2.py
17
3229
# # The Python Imaging Library # $Id$ # # WCK-style drawing interface operations # # History: # 2003-12-07 fl created # 2005-05-15 fl updated; added to PIL as ImageDraw2 # 2005-05-15 fl added text support # 2005-05-20 fl added arc/chord/pieslice support # # Copyright (c) 2003-2005 by Secret Labs AB # Copyright (c) 2003-2005 by Fredrik Lundh # # See the README file for information on usage and redistribution. # from . import Image, ImageColor, ImageDraw, ImageFont, ImagePath class Pen(object): def __init__(self, color, width=1, opacity=255): self.color = ImageColor.getrgb(color) self.width = width class Brush(object): def __init__(self, color, opacity=255): self.color = ImageColor.getrgb(color) class Font(object): def __init__(self, color, file, size=12): # FIXME: add support for bitmap fonts self.color = ImageColor.getrgb(color) self.font = ImageFont.truetype(file, size) class Draw(object): def __init__(self, image, size=None, color=None): if not hasattr(image, "im"): image = Image.new(image, size, color) self.draw = ImageDraw.Draw(image) self.image = image self.transform = None def flush(self): return self.image def render(self, op, xy, pen, brush=None): # handle color arguments outline = fill = None width = 1 if isinstance(pen, Pen): outline = pen.color width = pen.width elif isinstance(brush, Pen): outline = brush.color width = brush.width if isinstance(brush, Brush): fill = brush.color elif isinstance(pen, Brush): fill = pen.color # handle transformation if self.transform: xy = ImagePath.Path(xy) xy.transform(self.transform) # render the item if op == "line": self.draw.line(xy, fill=outline, width=width) else: getattr(self.draw, op)(xy, fill=fill, outline=outline) def settransform(self, offset): (xoffset, yoffset) = offset self.transform = (1, 0, xoffset, 0, 1, yoffset) def arc(self, xy, start, end, *options): self.render("arc", xy, start, end, *options) def chord(self, xy, start, end, *options): self.render("chord", xy, start, end, *options) def ellipse(self, xy, *options): self.render("ellipse", xy, *options) def line(self, xy, *options): self.render("line", xy, *options) def pieslice(self, xy, start, end, *options): self.render("pieslice", xy, start, end, *options) def polygon(self, xy, *options): self.render("polygon", xy, *options) def rectangle(self, xy, *options): self.render("rectangle", xy, *options) def symbol(self, xy, symbol, *options): raise NotImplementedError("not in this version") def text(self, xy, text, font): if self.transform: xy = ImagePath.Path(xy) xy.transform(self.transform) self.draw.text(xy, text, font=font.font, fill=font.color) def textsize(self, text, font): return self.draw.textsize(text, font=font.font)
bsd-2-clause
[ 3, 199, 3, 710, 2018, 473, 391, 1540, 11243, 199, 3, 2672, 1304, 4, 199, 3, 199, 3, 644, 2504, 13, 2487, 17455, 3217, 5331, 199, 3, 199, 3, 27829, 26, 199, 3, 13004, 13, 713, 13, 1780, 2717, 257, 2737, 199, 3, 11811, 13, 1717, 13, 1046, 2717, 257, 4588, 27, 3483, 370, 14937, 465, 6047, 9654, 18, 199, 3, 11811, 13, 1717, 13, 1046, 2717, 257, 3483, 1318, 2291, 199, 3, 11811, 13, 1717, 13, 1165, 2717, 257, 3483, 14972, 15, 335, 2181, 15, 1038, 397, 3037, 2291, 199, 3, 199, 3, 1898, 334, 67, 9, 13004, 13, 9397, 701, 23580, 491, 2101, 14840, 199, 3, 1898, 334, 67, 9, 13004, 13, 9397, 701, 481, 581, 25844, 491, 725, 72, 199, 3, 199, 3, 1666, 314, 27781, 570, 367, 2556, 641, 4503, 436, 295, 4972, 14, 199, 3, 199, 199, 504, 1275, 492, 6047, 12, 6047, 4117, 12, 6047, 9654, 12, 6047, 6986, 12, 6047, 2042, 421, 199, 533, 510, 287, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 3164, 12, 3462, 29, 17, 12, 31835, 29, 2299, 304, 267, 291, 14, 2326, 275, 6047, 4117, 14, 362, 10090, 8, 2326, 9, 267, 291, 14, 2063, 275, 3462, 421, 199, 533, 699, 82, 2084, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 3164, 12, 31835, 29, 2299, 304, 267, 291, 14, 2326, 275, 6047, 4117, 14, 362, 10090, 8, 2326, 9, 421, 199, 533, 26159, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 3164, 12, 570, 12, 1568, 29, 713, 304, 267, 327, 7600, 26, 1050, 2291, 367, 20810, 26219, 267, 291, 14, 2326, 275, 6047, 4117, 14, 362, 10090, 8, 2326, 9, 267, 291, 14, 4246, 275, 6047, 6986, 14, 2052, 466, 8, 493, 12, 1568, 9, 421, 199, 533, 17813, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1834, 12, 1568, 29, 403, 12, 3164, 29, 403, 304, 267, 340, 440, 2688, 8, 1569, 12, 298, 1017, 2349, 288, 1834, 275, 6047, 14, 1222, 8, 1569, 12, 1568, 12, 3164, 9, 267, 291, 14, 5485, 275, 6047, 9654, 14, 9654, 8, 1569, 9, 267, 291, 14, 1569, 275, 1834, 267, 291, 14, 4711, 275, 488, 339, 347, 8976, 8, 277, 304, 267, 372, 291, 14, 1569, 339, 347, 3795, 8, 277, 12, 1687, 12, 13222, 12, 12374, 12, 31101, 29, 403, 304, 267, 327, 2429, 3164, 2368, 267, 17964, 275, 5554, 275, 488, 267, 3462, 275, 413, 267, 340, 1228, 8, 897, 12, 510, 287, 304, 288, 17964, 275, 12374, 14, 2326, 288, 3462, 275, 12374, 14, 2063, 267, 916, 1228, 8, 22302, 12, 510, 287, 304, 288, 17964, 275, 31101, 14, 2326, 288, 3462, 275, 31101, 14, 2063, 267, 340, 1228, 8, 22302, 12, 699, 82, 2084, 304, 288, 5554, 275, 31101, 14, 2326, 267, 916, 1228, 8, 897, 12, 699, 82, 2084, 304, 288, 5554, 275, 12374, 14, 2326, 267, 327, 2429, 13315, 267, 340, 291, 14, 4711, 26, 288, 13222, 275, 6047, 2042, 14, 2042, 8, 1702, 9, 288, 13222, 14, 4711, 8, 277, 14, 4711, 9, 267, 327, 3795, 314, 1242, 267, 340, 1687, 508, 298, 604, 582, 288, 291, 14, 5485, 14, 604, 8, 1702, 12, 5554, 29, 11550, 12, 3462, 29, 2063, 9, 267, 587, 26, 288, 2519, 8, 277, 14, 5485, 12, 1687, 5130, 1702, 12, 5554, 29, 4498, 12, 17964, 29, 11550, 9, 339, 347, 663, 4711, 8, 277, 12, 3268, 304, 267, 334, 88, 2743, 12, 612, 2743, 9, 275, 3268, 267, 291, 14, 4711, 275, 334, 17, 12, 378, 12, 671, 2743, 12, 378, 12, 413, 12, 612, 2743, 9, 339, 347, 14972, 8, 277, 12, 13222, 12, 1343, 12, 1284, 12, 627, 1419, 304, 267, 291, 14, 3352, 480, 9912, 401, 13222, 12, 1343, 12, 1284, 12, 627, 1419, 9, 339, 347, 682, 2181, 8, 277, 12, 13222, 12, 1343, 12, 1284, 12, 627, 1419, 304, 267, 291, 14, 3352, 480, 335, 2181, 401, 13222, 12, 1343, 12, 1284, 12, 627, 1419, 9, 339, 347, 16028, 261, 8, 277, 12, 13222, 12, 627, 1419, 304, 267, 291, 14, 3352, 480, 16514, 261, 401, 13222, 12, 627, 1419, 9, 339, 347, 1004, 8, 277, 12, 13222, 12, 627, 1419, 304, 267, 291, 14, 3352, 480, 604, 401, 13222, 12, 627, 1419, 9, 339, 347, 299, 1500, 3037, 8, 277, 12, 13222, 12, 1343, 12, 1284, 12, 627, 1419, 304, 267, 291, 14, 3352, 480, 1038, 397, 3037, 401, 13222, 12, 1343, 12, 1284, 12, 627, 1419, 9, 339, 347, 17248, 8, 277, 12, 13222, 12, 627, 1419, 304, 267, 291, 14, 3352, 480, 16295, 401, 13222, 12, 627, 1419, 9, 339, 347, 20412, 8, 277, 12, 13222, 12, 627, 1419, 304, 267, 291, 14, 3352, 480, 19954, 401, 13222, 12, 627, 1419, 9, 339, 347, 5272, 8, 277, 12, 13222, 12, 5272, 12, 627, 1419, 304, 267, 746, 4279, 480, 1397, 315, 642, 1015, 531, 339, 347, 1318, 8, 277, 12, 13222, 12, 1318, 12, 5023, 304, 267, 340, 291, 14, 4711, 26, 288, 13222, 275, 6047, 2042, 14, 2042, 8, 1702, 9, 288, 13222, 14, 4711, 8, 277, 14, 4711, 9, 267, 291, 14, 5485, 14, 505, 8, 1702, 12, 1318, 12, 5023, 29, 4246, 14, 4246, 12, 5554, 29, 4246, 14, 2326, 9, 339, 347, 1318, 890, 8, 277, 12, 1318, 12, 5023, 304, 267, 372, 291, 14, 5485, 14, 505, 890, 8, 505, 12, 5023, 29, 4246, 14, 4246, 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 ]
[ 199, 3, 710, 2018, 473, 391, 1540, 11243, 199, 3, 2672, 1304, 4, 199, 3, 199, 3, 644, 2504, 13, 2487, 17455, 3217, 5331, 199, 3, 199, 3, 27829, 26, 199, 3, 13004, 13, 713, 13, 1780, 2717, 257, 2737, 199, 3, 11811, 13, 1717, 13, 1046, 2717, 257, 4588, 27, 3483, 370, 14937, 465, 6047, 9654, 18, 199, 3, 11811, 13, 1717, 13, 1046, 2717, 257, 3483, 1318, 2291, 199, 3, 11811, 13, 1717, 13, 1165, 2717, 257, 3483, 14972, 15, 335, 2181, 15, 1038, 397, 3037, 2291, 199, 3, 199, 3, 1898, 334, 67, 9, 13004, 13, 9397, 701, 23580, 491, 2101, 14840, 199, 3, 1898, 334, 67, 9, 13004, 13, 9397, 701, 481, 581, 25844, 491, 725, 72, 199, 3, 199, 3, 1666, 314, 27781, 570, 367, 2556, 641, 4503, 436, 295, 4972, 14, 199, 3, 199, 199, 504, 1275, 492, 6047, 12, 6047, 4117, 12, 6047, 9654, 12, 6047, 6986, 12, 6047, 2042, 421, 199, 533, 510, 287, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 3164, 12, 3462, 29, 17, 12, 31835, 29, 2299, 304, 267, 291, 14, 2326, 275, 6047, 4117, 14, 362, 10090, 8, 2326, 9, 267, 291, 14, 2063, 275, 3462, 421, 199, 533, 699, 82, 2084, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 3164, 12, 31835, 29, 2299, 304, 267, 291, 14, 2326, 275, 6047, 4117, 14, 362, 10090, 8, 2326, 9, 421, 199, 533, 26159, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 3164, 12, 570, 12, 1568, 29, 713, 304, 267, 327, 7600, 26, 1050, 2291, 367, 20810, 26219, 267, 291, 14, 2326, 275, 6047, 4117, 14, 362, 10090, 8, 2326, 9, 267, 291, 14, 4246, 275, 6047, 6986, 14, 2052, 466, 8, 493, 12, 1568, 9, 421, 199, 533, 17813, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1834, 12, 1568, 29, 403, 12, 3164, 29, 403, 304, 267, 340, 440, 2688, 8, 1569, 12, 298, 1017, 2349, 288, 1834, 275, 6047, 14, 1222, 8, 1569, 12, 1568, 12, 3164, 9, 267, 291, 14, 5485, 275, 6047, 9654, 14, 9654, 8, 1569, 9, 267, 291, 14, 1569, 275, 1834, 267, 291, 14, 4711, 275, 488, 339, 347, 8976, 8, 277, 304, 267, 372, 291, 14, 1569, 339, 347, 3795, 8, 277, 12, 1687, 12, 13222, 12, 12374, 12, 31101, 29, 403, 304, 267, 327, 2429, 3164, 2368, 267, 17964, 275, 5554, 275, 488, 267, 3462, 275, 413, 267, 340, 1228, 8, 897, 12, 510, 287, 304, 288, 17964, 275, 12374, 14, 2326, 288, 3462, 275, 12374, 14, 2063, 267, 916, 1228, 8, 22302, 12, 510, 287, 304, 288, 17964, 275, 31101, 14, 2326, 288, 3462, 275, 31101, 14, 2063, 267, 340, 1228, 8, 22302, 12, 699, 82, 2084, 304, 288, 5554, 275, 31101, 14, 2326, 267, 916, 1228, 8, 897, 12, 699, 82, 2084, 304, 288, 5554, 275, 12374, 14, 2326, 267, 327, 2429, 13315, 267, 340, 291, 14, 4711, 26, 288, 13222, 275, 6047, 2042, 14, 2042, 8, 1702, 9, 288, 13222, 14, 4711, 8, 277, 14, 4711, 9, 267, 327, 3795, 314, 1242, 267, 340, 1687, 508, 298, 604, 582, 288, 291, 14, 5485, 14, 604, 8, 1702, 12, 5554, 29, 11550, 12, 3462, 29, 2063, 9, 267, 587, 26, 288, 2519, 8, 277, 14, 5485, 12, 1687, 5130, 1702, 12, 5554, 29, 4498, 12, 17964, 29, 11550, 9, 339, 347, 663, 4711, 8, 277, 12, 3268, 304, 267, 334, 88, 2743, 12, 612, 2743, 9, 275, 3268, 267, 291, 14, 4711, 275, 334, 17, 12, 378, 12, 671, 2743, 12, 378, 12, 413, 12, 612, 2743, 9, 339, 347, 14972, 8, 277, 12, 13222, 12, 1343, 12, 1284, 12, 627, 1419, 304, 267, 291, 14, 3352, 480, 9912, 401, 13222, 12, 1343, 12, 1284, 12, 627, 1419, 9, 339, 347, 682, 2181, 8, 277, 12, 13222, 12, 1343, 12, 1284, 12, 627, 1419, 304, 267, 291, 14, 3352, 480, 335, 2181, 401, 13222, 12, 1343, 12, 1284, 12, 627, 1419, 9, 339, 347, 16028, 261, 8, 277, 12, 13222, 12, 627, 1419, 304, 267, 291, 14, 3352, 480, 16514, 261, 401, 13222, 12, 627, 1419, 9, 339, 347, 1004, 8, 277, 12, 13222, 12, 627, 1419, 304, 267, 291, 14, 3352, 480, 604, 401, 13222, 12, 627, 1419, 9, 339, 347, 299, 1500, 3037, 8, 277, 12, 13222, 12, 1343, 12, 1284, 12, 627, 1419, 304, 267, 291, 14, 3352, 480, 1038, 397, 3037, 401, 13222, 12, 1343, 12, 1284, 12, 627, 1419, 9, 339, 347, 17248, 8, 277, 12, 13222, 12, 627, 1419, 304, 267, 291, 14, 3352, 480, 16295, 401, 13222, 12, 627, 1419, 9, 339, 347, 20412, 8, 277, 12, 13222, 12, 627, 1419, 304, 267, 291, 14, 3352, 480, 19954, 401, 13222, 12, 627, 1419, 9, 339, 347, 5272, 8, 277, 12, 13222, 12, 5272, 12, 627, 1419, 304, 267, 746, 4279, 480, 1397, 315, 642, 1015, 531, 339, 347, 1318, 8, 277, 12, 13222, 12, 1318, 12, 5023, 304, 267, 340, 291, 14, 4711, 26, 288, 13222, 275, 6047, 2042, 14, 2042, 8, 1702, 9, 288, 13222, 14, 4711, 8, 277, 14, 4711, 9, 267, 291, 14, 5485, 14, 505, 8, 1702, 12, 1318, 12, 5023, 29, 4246, 14, 4246, 12, 5554, 29, 4246, 14, 2326, 9, 339, 347, 1318, 890, 8, 277, 12, 1318, 12, 5023, 304, 267, 372, 291, 14, 5485, 14, 505, 890, 8, 505, 12, 5023, 29, 4246, 14, 4246, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
saurabh6790/test-med-lib
core/page/data_import_tool/data_import_tool.py
34
16043
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # MIT License. See license.txt from __future__ import unicode_literals import webnotes, json import webnotes.model.doc import webnotes.model.doctype from webnotes.model.meta import get_table_fields from webnotes.model.doc import Document from webnotes.utils import cstr from webnotes.utils.datautils import UnicodeWriter, check_record, import_doc, getlink, cint, flt from webnotes import _ data_keys = webnotes._dict({ "data_separator": 'Start entering data below this line', "main_table": "Table:", "parent_table": "Parent Table:", "columns": "Column Name:", "doctype": "DocType:" }) @webnotes.whitelist() def get_doctypes(): return [r[0] for r in webnotes.conn.sql("""select name from `tabDocType` where document_type = 'Master' or allow_import = 1""")] @webnotes.whitelist() def get_doctype_options(): doctype = webnotes.form_dict['doctype'] return [doctype] + filter(None, map(lambda d: \ d.doctype=='DocField' and d.fieldtype=='Table' and d.options or None, webnotes.model.doctype.get(doctype))) @webnotes.whitelist() def get_template(doctype=None, parent_doctype=None, all_doctypes="No", with_data="No"): webnotes.check_admin_or_system_manager() all_doctypes = all_doctypes=="Yes" if not parent_doctype: parent_doctype = doctype column_start_end = {} if all_doctypes: doctype_parentfield = {} child_doctypes = [] for d in get_table_fields(doctype): child_doctypes.append(d[0]) doctype_parentfield[d[0]] = d[1] def add_main_header(): w.writerow(['Data Import Template']) w.writerow([data_keys.main_table, doctype]) if parent_doctype != doctype: w.writerow([data_keys.parent_table, parent_doctype]) else: w.writerow(['']) w.writerow(['']) w.writerow(['Notes:']) w.writerow(['Please do not change the template headings.']) w.writerow(['First data column must be blank.']) w.writerow(['If you are uploading new records, leave the "name" (ID) column blank.']) w.writerow(['If you are uploading new records, "Naming Series" becomes mandatory, if present.']) w.writerow(['Only mandatory fields are necessary for new records. You can delete non-mandatory columns if you wish.']) w.writerow(['For updating, you can update only selective columns.']) w.writerow(['You can only upload upto 5000 records in one go. (may be less in some cases)']) if key == "parent": w.writerow(['"Parent" signifies the parent table in which this row must be added']) w.writerow(['If you are updating, please select "Overwrite" else existing rows will not be deleted.']) def build_field_columns(dt): doctype_dl = webnotes.model.doctype.get(dt) tablecolumns = filter(None, [doctype_dl.get_field(f[0]) for f in webnotes.conn.sql('desc `tab%s`' % dt)]) tablecolumns.sort(lambda a, b: a.idx - b.idx) if dt==doctype: column_start_end[dt] = webnotes._dict({"start": 0}) else: column_start_end[dt] = webnotes._dict({"start": len(columns)}) append_field_column(webnotes._dict({ "fieldname": "name", "label": "ID", "fieldtype": "Data", "reqd": 1, "idx": 0, "info": "Leave blank for new records" }), True) for docfield in tablecolumns: append_field_column(docfield, True) # all non mandatory fields for docfield in tablecolumns: append_field_column(docfield, False) # append DocType name tablerow[column_start_end[dt].start + 1] = dt if dt!=doctype: tablerow[column_start_end[dt].start + 2] = doctype_parentfield[dt] column_start_end[dt].end = len(columns) + 1 def append_field_column(docfield, mandatory): if docfield and ((mandatory and docfield.reqd) or not (mandatory or docfield.reqd)) \ and (docfield.fieldname not in ('parenttype', 'trash_reason')) and not docfield.hidden: tablerow.append("") fieldrow.append(docfield.fieldname) labelrow.append(docfield.label) mandatoryrow.append(docfield.reqd and 'Yes' or 'No') typerow.append(docfield.fieldtype) inforow.append(getinforow(docfield)) columns.append(docfield.fieldname) def append_empty_field_column(): tablerow.append("~") fieldrow.append("~") labelrow.append("") mandatoryrow.append("") typerow.append("") inforow.append("") columns.append("") def getinforow(docfield): """make info comment for options, links etc.""" if docfield.fieldtype == 'Select': if not docfield.options: return '' elif docfield.options.startswith('link:'): return 'Valid %s' % docfield.options[5:] else: return 'One of: %s' % ', '.join(filter(None, docfield.options.split('\n'))) elif docfield.fieldtype == 'Link': return 'Valid %s' % docfield.options elif docfield.fieldtype in ('Int'): return 'Integer' elif docfield.fieldtype == "Check": return "0 or 1" elif docfield.info: return docfield.info else: return '' def add_field_headings(): w.writerow(tablerow) w.writerow(labelrow) w.writerow(fieldrow) w.writerow(mandatoryrow) w.writerow(typerow) w.writerow(inforow) w.writerow([data_keys.data_separator]) def add_data(): def add_data_row(row_group, dt, doc, rowidx): d = doc.copy() if all_doctypes: d.name = '"'+ d.name+'"' if len(row_group) < rowidx + 1: row_group.append([""] * (len(columns) + 1)) row = row_group[rowidx] for i, c in enumerate(columns[column_start_end[dt].start:column_start_end[dt].end]): row[column_start_end[dt].start + i + 1] = d.get(c, "") if with_data=='Yes': data = webnotes.conn.sql("""select * from `tab%s` where docstatus<2""" \ % doctype, as_dict=1) for doc in data: # add main table row_group = [] add_data_row(row_group, doctype, doc, 0) if all_doctypes: # add child tables for child_doctype in child_doctypes: for ci, child in enumerate(webnotes.conn.sql("""select * from `tab%s` where parent=%s order by idx""" % (child_doctype, "%s"), doc.name, as_dict=1)): add_data_row(row_group, child_doctype, child, ci) for row in row_group: w.writerow(row) w = UnicodeWriter() key = 'parent' if parent_doctype != doctype else 'name' add_main_header() w.writerow(['']) tablerow = [data_keys.doctype, ""] labelrow = ["Column Labels:", "ID"] fieldrow = [data_keys.columns, key] mandatoryrow = ['Mandatory:', 'Yes'] typerow = ['Type:', 'Data (text)'] inforow = ['Info:', ''] columns = [key] build_field_columns(doctype) if all_doctypes: for d in child_doctypes: append_empty_field_column() build_field_columns(d) add_field_headings() add_data() # write out response as a type csv webnotes.response['result'] = cstr(w.getvalue()) webnotes.response['type'] = 'csv' webnotes.response['doctype'] = doctype @webnotes.whitelist() def upload(rows = None, submit_after_import=None, ignore_encoding_errors=False, overwrite=False, ignore_links=False): """upload data""" webnotes.flags.mute_emails = True webnotes.check_admin_or_system_manager() # extra input params params = json.loads(webnotes.form_dict.get("params") or '{}') if params.get("_submit"): submit_after_import = True if params.get("ignore_encoding_errors"): ignore_encoding_errors = True from webnotes.utils.datautils import read_csv_content_from_uploaded_file def bad_template(): webnotes.msgprint("Please do not change the rows above '%s'" % data_keys.data_separator, raise_exception=1) def check_data_length(): max_rows = 5000 if not data: webnotes.msgprint("No data found", raise_exception=True) elif len(data) > max_rows: webnotes.msgprint("Please upload only upto %d %ss at a time" % \ (max_rows, doctype), raise_exception=True) def get_start_row(): for i, row in enumerate(rows): if row and row[0]==data_keys.data_separator: return i+1 bad_template() def get_header_row(key): return get_header_row_and_idx(key)[0] def get_header_row_and_idx(key): for i, row in enumerate(header): if row and row[0]==key: return row, i return [], -1 def filter_empty_columns(columns): empty_cols = filter(lambda x: x in ("", None), columns) if empty_cols: if columns[-1*len(empty_cols):] == empty_cols: # filter empty columns if they exist at the end columns = columns[:-1*len(empty_cols)] else: webnotes.msgprint(_("Please make sure that there are no empty columns in the file."), raise_exception=1) return columns def make_column_map(): doctype_row, row_idx = get_header_row_and_idx(data_keys.doctype) if row_idx == -1: # old style return dt = None for i, d in enumerate(doctype_row[1:]): if d not in ("~", "-"): if d: # value in doctype_row if doctype_row[i]==dt: # prev column is doctype (in case of parentfield) doctype_parentfield[dt] = doctype_row[i+1] else: dt = d doctypes.append(d) column_idx_to_fieldname[dt] = {} column_idx_to_fieldtype[dt] = {} if dt: column_idx_to_fieldname[dt][i+1] = rows[row_idx + 2][i+1] column_idx_to_fieldtype[dt][i+1] = rows[row_idx + 4][i+1] def get_doclist(start_idx): if doctypes: doclist = [] for idx in xrange(start_idx, len(rows)): if (not len(doclist)) or main_doc_empty(rows[idx]): for dt in doctypes: d = {} for column_idx in column_idx_to_fieldname[dt]: try: fieldname = column_idx_to_fieldname[dt][column_idx] fieldtype = column_idx_to_fieldtype[dt][column_idx] d[fieldname] = rows[idx][column_idx] if fieldtype in ("Int", "Check"): d[fieldname] = cint(d[fieldname]) elif fieldtype in ("Float", "Currency"): d[fieldname] = flt(d[fieldname]) except IndexError, e: pass # scrub quotes from name and modified if d.get("name") and d["name"].startswith('"'): d["name"] = d["name"][1:-1] if sum([0 if not val else 1 for val in d.values()]): d['doctype'] = dt if dt != doctype: if not overwrite: d['parent'] = doclist[0]["name"] d['parenttype'] = doctype d['parentfield'] = doctype_parentfield[dt] doclist.append(d) else: break return doclist else: d = webnotes._dict(zip(columns, rows[start_idx][1:])) d['doctype'] = doctype return [d] def main_doc_empty(row): return not (row and ((len(row) > 1 and row[1]) or (len(row) > 2 and row[2]))) # header if not rows: rows = read_csv_content_from_uploaded_file(ignore_encoding_errors) start_row = get_start_row() header = rows[:start_row] data = rows[start_row:] doctype = get_header_row(data_keys.main_table)[1] columns = filter_empty_columns(get_header_row(data_keys.columns)[1:]) doctypes = [] doctype_parentfield = {} column_idx_to_fieldname = {} column_idx_to_fieldtype = {} if submit_after_import and not cint(webnotes.conn.get_value("DocType", doctype, "is_submittable")): submit_after_import = False parenttype = get_header_row(data_keys.parent_table) if len(parenttype) > 1: parenttype = parenttype[1] parentfield = get_parent_field(doctype, parenttype) # allow limit rows to be uploaded check_data_length() make_column_map() webnotes.conn.begin() if not overwrite: overwrite = params.get('overwrite') doctype_dl = webnotes.model.doctype.get(doctype) # delete child rows (if parenttype) if parenttype and overwrite: delete_child_rows(data, doctype) ret = [] error = False parent_list = [] for i, row in enumerate(data): # bypass empty rows if main_doc_empty(row): continue row_idx = i + start_row bean = None doclist = get_doclist(row_idx) try: webnotes.local.message_log = [] if len(doclist) > 1: for d in doclist: # ignoring parent check as it will be automatically added check_record(d, None, doctype_dl) if overwrite and webnotes.conn.exists(doctype, doclist[0]["name"]): bean = webnotes.bean(doctype, doclist[0]["name"]) bean.ignore_links = ignore_links bean.doclist.update(doclist) bean.save() ret.append('Updated row (#%d) %s' % (row_idx + 1, getlink(bean.doc.doctype, bean.doc.name))) else: bean = webnotes.bean(doclist) bean.ignore_links = ignore_links bean.insert() ret.append('Inserted row (#%d) %s' % (row_idx + 1, getlink(bean.doc.doctype, bean.doc.name))) if submit_after_import: bean.submit() ret.append('Submitted row (#%d) %s' % (row_idx + 1, getlink(bean.doc.doctype, bean.doc.name))) else: check_record(doclist[0], parenttype, doctype_dl) if parenttype: # child doc doc = Document(doctype) doc.fields.update(doclist[0]) if parenttype: doc.parenttype = parenttype doc.parentfield = parentfield doc.save() ret.append('Inserted row for %s at #%s' % (getlink(parenttype, doc.parent), unicode(doc.idx))) parent_list.append(doc.parent) else: ret.append(import_doc(doclist[0], doctype, overwrite, row_idx, submit_after_import, ignore_links)) except Exception, e: error = True if bean: webnotes.errprint(bean.doclist) err_msg = webnotes.local.message_log and "<br>".join(webnotes.local.message_log) or cstr(e) ret.append('Error for row (#%d) %s : %s' % (row_idx + 1, len(row)>1 and row[1] or "", err_msg)) webnotes.errprint(webnotes.getTraceback()) ret, error = validate_parent(parent_list, parenttype, ret, error) if error: webnotes.conn.rollback() else: webnotes.conn.commit() webnotes.flags.mute_emails = False return {"messages": ret, "error": error} def validate_parent(parent_list, parenttype, ret, error): if parent_list: parent_list = list(set(parent_list)) for p in parent_list: try: obj = webnotes.bean(parenttype, p) obj.run_method("validate") obj.run_method("on_update") except Exception, e: error = True ret.append('Validation Error for %s %s: %s' % (parenttype, p, cstr(e))) webnotes.errprint(webnotes.getTraceback()) return ret, error def get_parent_field(doctype, parenttype): parentfield = None # get parentfield if parenttype: for d in webnotes.model.doctype.get(parenttype): if d.fieldtype=='Table' and d.options==doctype: parentfield = d.fieldname break if not parentfield: webnotes.msgprint("Did not find parentfield for %s (%s)" % \ (parenttype, doctype)) raise Exception return parentfield def delete_child_rows(rows, doctype): """delete child rows for all parents""" for p in list(set([r[1] for r in rows])): webnotes.conn.sql("""delete from `tab%s` where parent=%s""" % (doctype, '%s'), p) def import_file_by_path(path, ignore_links=False, overwrite=False): from webnotes.utils.datautils import read_csv_content print "Importing " + path with open(path, "r") as infile: upload(rows = read_csv_content(infile.read()), ignore_links=ignore_links, overwrite=overwrite) def export_csv(doctype, path): with open(path, "w") as csvfile: get_template(doctype=doctype, all_doctypes="Yes", with_data="Yes") csvfile.write(webnotes.response.result.encode("utf-8")) def export_json(doctype, name, path): from webnotes.handler import json_handler if not name or name=="-": name = doctype with open(path, "w") as outfile: doclist = [d.fields for d in webnotes.bean(doctype, name).doclist] for d in doclist: if d.get("parent"): del d["parent"] del d["name"] d["__islocal"] = 1 outfile.write(json.dumps(doclist, default=json_handler, indent=1, sort_keys=True)) def import_doclist(path, overwrite=False): import os if os.path.isdir(path): files = [os.path.join(path, f) for f in os.listdir(path)] else: files = [path] for f in files: if f.endswith(".json"): with open(f, "r") as infile: b = webnotes.bean(json.loads(infile.read())).insert_or_update() print "Imported: " + b.doc.doctype + " / " + b.doc.name webnotes.conn.commit() if f.endswith(".csv"): import_file_by_path(f, ignore_links=True, overwrite=overwrite) webnotes.conn.commit()
mit
[ 3, 1898, 334, 67, 9, 6171, 12, 6001, 8144, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 10697, 844, 14, 1666, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 23154, 12, 2022, 199, 646, 23154, 14, 1238, 14, 1301, 199, 646, 23154, 14, 1238, 14, 6356, 199, 504, 23154, 14, 1238, 14, 2024, 492, 664, 63, 1224, 63, 955, 199, 504, 23154, 14, 1238, 14, 1301, 492, 7543, 199, 504, 23154, 14, 1208, 492, 286, 495, 199, 504, 23154, 14, 1208, 14, 576, 1208, 492, 6140, 6261, 12, 1104, 63, 3059, 12, 492, 63, 1301, 12, 664, 1073, 12, 286, 442, 12, 17166, 199, 504, 23154, 492, 485, 199, 199, 576, 63, 1612, 275, 23154, 423, 807, 2561, 199, 198, 2, 576, 63, 9896, 582, 283, 3162, 9509, 316, 666, 5084, 642, 1004, 297, 199, 198, 2, 973, 63, 1224, 582, 298, 3186, 6783, 199, 198, 2, 1708, 63, 1224, 582, 298, 6652, 6957, 6783, 199, 198, 2, 3406, 582, 298, 4547, 2812, 6783, 199, 198, 2, 6356, 582, 298, 3768, 804, 5424, 199, 1552, 199, 199, 32, 30307, 14, 14189, 342, 199, 318, 664, 63, 6356, 83, 837, 272, 372, 359, 82, 59, 16, 61, 367, 519, 315, 23154, 14, 1631, 14, 3009, 4852, 2416, 536, 687, 658, 2902, 3768, 804, 64, 11083, 198, 4509, 2213, 63, 466, 275, 283, 12288, 7, 503, 2040, 63, 646, 275, 413, 6141, 61, 686, 199, 32, 30307, 14, 14189, 342, 199, 318, 664, 63, 6356, 63, 1419, 837, 199, 198, 6356, 275, 23154, 14, 964, 63, 807, 459, 6356, 418, 199, 198, 1107, 359, 6356, 61, 435, 2457, 8, 403, 12, 2341, 8, 2734, 366, 26, 971, 507, 198, 68, 14, 6356, 6803, 3768, 792, 7, 436, 366, 14, 698, 466, 6803, 3186, 7, 436, 366, 14, 1419, 503, 488, 12, 11083, 198, 30307, 14, 1238, 14, 6356, 14, 362, 8, 6356, 1724, 199, 199, 32, 30307, 14, 14189, 342, 199, 318, 664, 63, 1160, 8, 6356, 29, 403, 12, 1676, 63, 6356, 29, 403, 12, 1006, 63, 6356, 83, 628, 1944, 401, 543, 63, 576, 628, 1944, 2349, 199, 198, 30307, 14, 1074, 63, 2113, 63, 269, 63, 2253, 63, 2609, 342, 199, 198, 452, 63, 6356, 83, 275, 1006, 63, 6356, 83, 11800, 12555, 2, 199, 198, 692, 440, 1676, 63, 6356, 26, 507, 198, 1708, 63, 6356, 275, 13265, 8299, 198, 2301, 63, 928, 63, 500, 275, 1052, 8299, 198, 692, 1006, 63, 6356, 83, 26, 507, 198, 6356, 63, 1708, 698, 275, 1052, 507, 198, 1739, 63, 6356, 83, 275, 942, 507, 198, 509, 366, 315, 664, 63, 1224, 63, 955, 8, 6356, 304, 686, 198, 1739, 63, 6356, 83, 14, 740, 8, 68, 59, 16, 566, 686, 198, 6356, 63, 1708, 698, 59, 68, 59, 16, 2677, 275, 366, 59, 17, 61, 18118, 198, 318, 1050, 63, 973, 63, 1291, 837, 507, 198, 87, 14, 22686, 2941, 1451, 3161, 5458, 1105, 507, 198, 87, 14, 22686, 779, 576, 63, 1612, 14, 973, 63, 1224, 12, 13265, 566, 9068, 198, 692, 1676, 63, 6356, 1137, 13265, 26, 686, 198, 87, 14, 22686, 779, 576, 63, 1612, 14, 1708, 63, 1224, 12, 1676, 63, 6356, 566, 507, 198, 2836, 26, 686, 198, 87, 14, 22686, 2941, 1105, 2742, 198, 87, 14, 22686, 2941, 1105, 507, 198, 87, 14, 22686, 2941, 18685, 26, 1105, 507, 198, 87, 14, 22686, 2941, 8254, 886, 440, 1570, 314, 1978, 26967, 25367, 507, 198, 87, 14, 22686, 2941, 7147, 666, 2763, 1471, 506, 4596, 25367, 507, 198, 87, 14, 22686, 2941, 3917, 1265, 787, 24349, 892, 5767, 12, 10137, 314, 298, 354, 2, 334, 998, 9, 2763, 4596, 25367, 507, 198, 87, 14, 22686, 2941, 3917, 1265, 787, 24349, 892, 5767, 12, 298, 46, 9568, 12403, 2, 15410, 15230, 12, 340, 3451, 25367, 507, 198, 87, 14, 22686, 2941, 5903, 15230, 1504, 787, 5784, 367, 892, 5767, 14, 2047, 883, 3145, 2222, 13, 19900, 4362, 340, 1265, 13809, 25367, 507, 198, 87, 14, 22686, 2941, 1858, 12928, 12, 1265, 883, 1678, 1454, 542, 25982, 4362, 25367, 507, 198, 87, 14, 22686, 2941, 5556, 883, 1454, 5802, 1536, 475, 22369, 5767, 315, 1373, 2621, 14, 334, 7551, 506, 6656, 315, 2005, 5560, 9, 1105, 507, 198, 692, 790, 508, 298, 1708, 582, 686, 198, 87, 14, 22686, 2941, 2, 6652, 2, 2070, 11594, 314, 1676, 1817, 315, 1314, 642, 1962, 1471, 506, 3483, 1105, 686, 198, 87, 14, 22686, 2941, 3917, 1265, 787, 12928, 12, 8749, 3504, 298, 5674, 952, 2, 587, 3411, 4730, 911, 440, 506, 5463, 25367, 421, 198, 318, 1900, 63, 698, 63, 3406, 8, 3583, 304, 507, 198, 6356, 63, 5030, 275, 23154, 14, 1238, 14, 6356, 14, 362, 8, 3583, 9, 2742, 198, 1224, 3406, 275, 2457, 8, 403, 12, 20866, 198, 59, 6356, 63, 5030, 14, 362, 63, 698, 8, 70, 59, 16, 566, 367, 289, 315, 23154, 14, 1631, 14, 3009, 360, 3257, 658, 2902, 5, 83, 19097, 450, 4487, 3948, 2742, 198, 1224, 3406, 14, 3191, 8, 2734, 282, 12, 330, 26, 282, 14, 2996, 446, 330, 14, 2996, 9, 2742, 198, 692, 4487, 389, 6356, 26, 686, 198, 2301, 63, 928, 63, 500, 59, 3583, 61, 275, 23154, 423, 807, 6333, 928, 582, 378, 1552, 507, 198, 2836, 26, 686, 198, 2301, 63, 928, 63, 500, 59, 3583, 61, 275, 23154, 423, 807, 6333, 928, 582, 822, 8, 3406, 11466, 26140, 198, 740, 63, 698, 63, 2301, 8, 30307, 423, 807, 2561, 1585, 198, 2, 13646, 582, 298, 354, 401, 1585, 198, 2, 1302, 582, 298, 998, 401, 1585, 198, 2, 698, 466, 582, 298, 1451, 401, 1585, 198, 2, 2103, 68, 582, 413, 12, 1585, 198, 2, 2996, 582, 378, 12, 1585, 198, 2, 815, 582, 298, 23679, 4596, 367, 892, 5767, 2, 686, 198, 8688, 715, 9, 1585, 507, 198, 509, 1382, 698, 315, 1817, 3406, 26, 686, 198, 740, 63, 698, 63, 2301, 8, 1301, 698, 12, 715, 9, 2742, 198, 3, 1006, 2222, 15230, 1504, 507, 198, 509, 1382, 698, 315, 1817, 3406, 26, 686, 198, 740, 63, 698, 63, 2301, 8, 1301, 698, 12, 756, 9 ]
[ 1898, 334, 67, 9, 6171, 12, 6001, 8144, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 10697, 844, 14, 1666, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 23154, 12, 2022, 199, 646, 23154, 14, 1238, 14, 1301, 199, 646, 23154, 14, 1238, 14, 6356, 199, 504, 23154, 14, 1238, 14, 2024, 492, 664, 63, 1224, 63, 955, 199, 504, 23154, 14, 1238, 14, 1301, 492, 7543, 199, 504, 23154, 14, 1208, 492, 286, 495, 199, 504, 23154, 14, 1208, 14, 576, 1208, 492, 6140, 6261, 12, 1104, 63, 3059, 12, 492, 63, 1301, 12, 664, 1073, 12, 286, 442, 12, 17166, 199, 504, 23154, 492, 485, 199, 199, 576, 63, 1612, 275, 23154, 423, 807, 2561, 199, 198, 2, 576, 63, 9896, 582, 283, 3162, 9509, 316, 666, 5084, 642, 1004, 297, 199, 198, 2, 973, 63, 1224, 582, 298, 3186, 6783, 199, 198, 2, 1708, 63, 1224, 582, 298, 6652, 6957, 6783, 199, 198, 2, 3406, 582, 298, 4547, 2812, 6783, 199, 198, 2, 6356, 582, 298, 3768, 804, 5424, 199, 1552, 199, 199, 32, 30307, 14, 14189, 342, 199, 318, 664, 63, 6356, 83, 837, 272, 372, 359, 82, 59, 16, 61, 367, 519, 315, 23154, 14, 1631, 14, 3009, 4852, 2416, 536, 687, 658, 2902, 3768, 804, 64, 11083, 198, 4509, 2213, 63, 466, 275, 283, 12288, 7, 503, 2040, 63, 646, 275, 413, 6141, 61, 686, 199, 32, 30307, 14, 14189, 342, 199, 318, 664, 63, 6356, 63, 1419, 837, 199, 198, 6356, 275, 23154, 14, 964, 63, 807, 459, 6356, 418, 199, 198, 1107, 359, 6356, 61, 435, 2457, 8, 403, 12, 2341, 8, 2734, 366, 26, 971, 507, 198, 68, 14, 6356, 6803, 3768, 792, 7, 436, 366, 14, 698, 466, 6803, 3186, 7, 436, 366, 14, 1419, 503, 488, 12, 11083, 198, 30307, 14, 1238, 14, 6356, 14, 362, 8, 6356, 1724, 199, 199, 32, 30307, 14, 14189, 342, 199, 318, 664, 63, 1160, 8, 6356, 29, 403, 12, 1676, 63, 6356, 29, 403, 12, 1006, 63, 6356, 83, 628, 1944, 401, 543, 63, 576, 628, 1944, 2349, 199, 198, 30307, 14, 1074, 63, 2113, 63, 269, 63, 2253, 63, 2609, 342, 199, 198, 452, 63, 6356, 83, 275, 1006, 63, 6356, 83, 11800, 12555, 2, 199, 198, 692, 440, 1676, 63, 6356, 26, 507, 198, 1708, 63, 6356, 275, 13265, 8299, 198, 2301, 63, 928, 63, 500, 275, 1052, 8299, 198, 692, 1006, 63, 6356, 83, 26, 507, 198, 6356, 63, 1708, 698, 275, 1052, 507, 198, 1739, 63, 6356, 83, 275, 942, 507, 198, 509, 366, 315, 664, 63, 1224, 63, 955, 8, 6356, 304, 686, 198, 1739, 63, 6356, 83, 14, 740, 8, 68, 59, 16, 566, 686, 198, 6356, 63, 1708, 698, 59, 68, 59, 16, 2677, 275, 366, 59, 17, 61, 18118, 198, 318, 1050, 63, 973, 63, 1291, 837, 507, 198, 87, 14, 22686, 2941, 1451, 3161, 5458, 1105, 507, 198, 87, 14, 22686, 779, 576, 63, 1612, 14, 973, 63, 1224, 12, 13265, 566, 9068, 198, 692, 1676, 63, 6356, 1137, 13265, 26, 686, 198, 87, 14, 22686, 779, 576, 63, 1612, 14, 1708, 63, 1224, 12, 1676, 63, 6356, 566, 507, 198, 2836, 26, 686, 198, 87, 14, 22686, 2941, 1105, 2742, 198, 87, 14, 22686, 2941, 1105, 507, 198, 87, 14, 22686, 2941, 18685, 26, 1105, 507, 198, 87, 14, 22686, 2941, 8254, 886, 440, 1570, 314, 1978, 26967, 25367, 507, 198, 87, 14, 22686, 2941, 7147, 666, 2763, 1471, 506, 4596, 25367, 507, 198, 87, 14, 22686, 2941, 3917, 1265, 787, 24349, 892, 5767, 12, 10137, 314, 298, 354, 2, 334, 998, 9, 2763, 4596, 25367, 507, 198, 87, 14, 22686, 2941, 3917, 1265, 787, 24349, 892, 5767, 12, 298, 46, 9568, 12403, 2, 15410, 15230, 12, 340, 3451, 25367, 507, 198, 87, 14, 22686, 2941, 5903, 15230, 1504, 787, 5784, 367, 892, 5767, 14, 2047, 883, 3145, 2222, 13, 19900, 4362, 340, 1265, 13809, 25367, 507, 198, 87, 14, 22686, 2941, 1858, 12928, 12, 1265, 883, 1678, 1454, 542, 25982, 4362, 25367, 507, 198, 87, 14, 22686, 2941, 5556, 883, 1454, 5802, 1536, 475, 22369, 5767, 315, 1373, 2621, 14, 334, 7551, 506, 6656, 315, 2005, 5560, 9, 1105, 507, 198, 692, 790, 508, 298, 1708, 582, 686, 198, 87, 14, 22686, 2941, 2, 6652, 2, 2070, 11594, 314, 1676, 1817, 315, 1314, 642, 1962, 1471, 506, 3483, 1105, 686, 198, 87, 14, 22686, 2941, 3917, 1265, 787, 12928, 12, 8749, 3504, 298, 5674, 952, 2, 587, 3411, 4730, 911, 440, 506, 5463, 25367, 421, 198, 318, 1900, 63, 698, 63, 3406, 8, 3583, 304, 507, 198, 6356, 63, 5030, 275, 23154, 14, 1238, 14, 6356, 14, 362, 8, 3583, 9, 2742, 198, 1224, 3406, 275, 2457, 8, 403, 12, 20866, 198, 59, 6356, 63, 5030, 14, 362, 63, 698, 8, 70, 59, 16, 566, 367, 289, 315, 23154, 14, 1631, 14, 3009, 360, 3257, 658, 2902, 5, 83, 19097, 450, 4487, 3948, 2742, 198, 1224, 3406, 14, 3191, 8, 2734, 282, 12, 330, 26, 282, 14, 2996, 446, 330, 14, 2996, 9, 2742, 198, 692, 4487, 389, 6356, 26, 686, 198, 2301, 63, 928, 63, 500, 59, 3583, 61, 275, 23154, 423, 807, 6333, 928, 582, 378, 1552, 507, 198, 2836, 26, 686, 198, 2301, 63, 928, 63, 500, 59, 3583, 61, 275, 23154, 423, 807, 6333, 928, 582, 822, 8, 3406, 11466, 26140, 198, 740, 63, 698, 63, 2301, 8, 30307, 423, 807, 2561, 1585, 198, 2, 13646, 582, 298, 354, 401, 1585, 198, 2, 1302, 582, 298, 998, 401, 1585, 198, 2, 698, 466, 582, 298, 1451, 401, 1585, 198, 2, 2103, 68, 582, 413, 12, 1585, 198, 2, 2996, 582, 378, 12, 1585, 198, 2, 815, 582, 298, 23679, 4596, 367, 892, 5767, 2, 686, 198, 8688, 715, 9, 1585, 507, 198, 509, 1382, 698, 315, 1817, 3406, 26, 686, 198, 740, 63, 698, 63, 2301, 8, 1301, 698, 12, 715, 9, 2742, 198, 3, 1006, 2222, 15230, 1504, 507, 198, 509, 1382, 698, 315, 1817, 3406, 26, 686, 198, 740, 63, 698, 63, 2301, 8, 1301, 698, 12, 756, 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,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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 ]
alekz112/statsmodels
docs/source/plots/graphics_gofplots_qqplot.py
38
1911
# -*- coding: utf-8 -*- """ Created on Sun May 06 05:32:15 2012 Author: Josef Perktold editted by: Paul Hobson (2012-08-19) """ from scipy import stats from matplotlib import pyplot as plt import statsmodels.api as sm #example from docstring data = sm.datasets.longley.load() data.exog = sm.add_constant(data.exog, prepend=True) mod_fit = sm.OLS(data.endog, data.exog).fit() res = mod_fit.resid left = -1.8 #x coordinate for text insert fig = plt.figure() ax = fig.add_subplot(2, 2, 1) sm.graphics.qqplot(res, ax=ax) top = ax.get_ylim()[1] * 0.75 txt = ax.text(left, top, 'no keywords', verticalalignment='top') txt.set_bbox(dict(facecolor='k', alpha=0.1)) ax = fig.add_subplot(2, 2, 2) sm.graphics.qqplot(res, line='s', ax=ax) top = ax.get_ylim()[1] * 0.75 txt = ax.text(left, top, "line='s'", verticalalignment='top') txt.set_bbox(dict(facecolor='k', alpha=0.1)) ax = fig.add_subplot(2, 2, 3) sm.graphics.qqplot(res, line='45', fit=True, ax=ax) ax.set_xlim(-2, 2) top = ax.get_ylim()[1] * 0.75 txt = ax.text(left, top, "line='45', \nfit=True", verticalalignment='top') txt.set_bbox(dict(facecolor='k', alpha=0.1)) ax = fig.add_subplot(2, 2, 4) sm.graphics.qqplot(res, dist=stats.t, line='45', fit=True, ax=ax) ax.set_xlim(-2, 2) top = ax.get_ylim()[1] * 0.75 txt = ax.text(left, top, "dist=stats.t, \nline='45', \nfit=True", verticalalignment='top') txt.set_bbox(dict(facecolor='k', alpha=0.1)) fig.tight_layout() plt.gcf() # example with the new ProbPlot class import numpy as np x = np.random.normal(loc=8.25, scale=3.5, size=37) y = np.random.normal(loc=8.00, scale=3.25, size=37) pp_x = sm.ProbPlot(x, fit=True) pp_y = sm.ProbPlot(y, fit=True) # probability of exceedance fig2 = pp_x.probplot(exceed=True) # compare x quantiles to y quantiles fig3 = pp_x.qqplot(other=pp_y, line='45') # same as above with probabilities/percentiles fig4 = pp_x.ppplot(other=pp_y, line='45')
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 10502, 641, 25625, 10162, 24293, 22528, 26, 708, 26, 1046, 6029, 199, 199, 5949, 26, 1603, 3362, 70, 3492, 5973, 1753, 199, 3773, 471, 701, 26, 28574, 869, 2873, 834, 334, 7409, 13, 2036, 13, 1167, 9, 199, 624, 199, 504, 7026, 492, 5020, 199, 504, 8027, 492, 1134, 2798, 465, 4488, 199, 646, 5020, 992, 14, 1246, 465, 4383, 199, 199, 3, 2694, 687, 9214, 199, 576, 275, 4383, 14, 12281, 14, 2809, 15515, 14, 912, 342, 199, 576, 14, 23919, 275, 4383, 14, 525, 63, 4083, 8, 576, 14, 23919, 12, 18213, 29, 549, 9, 199, 1494, 63, 3269, 275, 4383, 14, 2228, 51, 8, 576, 14, 27647, 12, 666, 14, 23919, 680, 3269, 342, 199, 470, 275, 3413, 63, 3269, 14, 19581, 199, 199, 3039, 275, 446, 17, 14, 24, 257, 327, 88, 10021, 367, 1318, 5518, 199, 199, 592, 275, 4488, 14, 8941, 342, 199, 199, 1219, 275, 6085, 14, 525, 63, 13334, 8, 18, 12, 499, 12, 413, 9, 199, 3300, 14, 15707, 14, 16672, 2798, 8, 470, 12, 2185, 29, 1219, 9, 199, 2119, 275, 2185, 14, 362, 63, 18123, 3430, 17, 61, 627, 378, 14, 2194, 199, 2424, 275, 2185, 14, 505, 8, 3039, 12, 2746, 12, 283, 889, 7681, 297, 13763, 13699, 534, 2119, 358, 199, 2424, 14, 409, 63, 11246, 8, 807, 8, 1409, 2326, 534, 75, 297, 5131, 29, 16, 14, 17, 430, 199, 199, 1219, 275, 6085, 14, 525, 63, 13334, 8, 18, 12, 499, 12, 499, 9, 199, 3300, 14, 15707, 14, 16672, 2798, 8, 470, 12, 1004, 534, 83, 297, 2185, 29, 1219, 9, 199, 2119, 275, 2185, 14, 362, 63, 18123, 3430, 17, 61, 627, 378, 14, 2194, 199, 2424, 275, 2185, 14, 505, 8, 3039, 12, 2746, 12, 298, 604, 534, 83, 4662, 13763, 13699, 534, 2119, 358, 199, 2424, 14, 409, 63, 11246, 8, 807, 8, 1409, 2326, 534, 75, 297, 5131, 29, 16, 14, 17, 430, 199, 199, 1219, 275, 6085, 14, 525, 63, 13334, 8, 18, 12, 499, 12, 650, 9, 199, 3300, 14, 15707, 14, 16672, 2798, 8, 470, 12, 1004, 534, 2322, 297, 5542, 29, 549, 12, 2185, 29, 1219, 9, 199, 1219, 14, 409, 63, 18512, 2801, 18, 12, 499, 9, 199, 2119, 275, 2185, 14, 362, 63, 18123, 3430, 17, 61, 627, 378, 14, 2194, 199, 2424, 275, 2185, 14, 505, 8, 3039, 12, 2746, 12, 298, 604, 534, 2322, 297, 971, 78, 3269, 29, 549, 401, 13763, 13699, 534, 2119, 358, 199, 2424, 14, 409, 63, 11246, 8, 807, 8, 1409, 2326, 534, 75, 297, 5131, 29, 16, 14, 17, 430, 199, 199, 1219, 275, 6085, 14, 525, 63, 13334, 8, 18, 12, 499, 12, 841, 9, 199, 3300, 14, 15707, 14, 16672, 2798, 8, 470, 12, 2917, 29, 3200, 14, 84, 12, 1004, 534, 2322, 297, 5542, 29, 549, 12, 2185, 29, 1219, 9, 199, 1219, 14, 409, 63, 18512, 2801, 18, 12, 499, 9, 199, 2119, 275, 2185, 14, 362, 63, 18123, 3430, 17, 61, 627, 378, 14, 2194, 199, 2424, 275, 2185, 14, 505, 8, 3039, 12, 2746, 12, 298, 2686, 29, 3200, 14, 84, 12, 971, 78, 604, 534, 2322, 297, 971, 78, 3269, 29, 549, 401, 1598, 13763, 13699, 534, 2119, 358, 199, 2424, 14, 409, 63, 11246, 8, 807, 8, 1409, 2326, 534, 75, 297, 5131, 29, 16, 14, 17, 430, 199, 199, 592, 14, 23787, 63, 4209, 342, 199, 199, 6003, 14, 71, 2177, 342, 421, 199, 3, 2893, 543, 314, 892, 22770, 10711, 1021, 199, 646, 2680, 465, 980, 199, 88, 275, 980, 14, 2355, 14, 3302, 8, 2102, 29, 24, 14, 821, 12, 4666, 29, 19, 14, 21, 12, 1568, 29, 1401, 9, 199, 89, 275, 980, 14, 2355, 14, 3302, 8, 2102, 29, 24, 14, 383, 12, 4666, 29, 19, 14, 821, 12, 1568, 29, 1401, 9, 199, 802, 63, 88, 275, 4383, 14, 20122, 10711, 8, 88, 12, 5542, 29, 549, 9, 199, 802, 63, 89, 275, 4383, 14, 20122, 10711, 8, 89, 12, 5542, 29, 549, 9, 199, 199, 3, 12224, 402, 24068, 554, 199, 592, 18, 275, 11618, 63, 88, 14, 6101, 2798, 8, 476, 15648, 29, 549, 9, 199, 199, 3, 6540, 671, 13621, 2978, 370, 612, 13621, 2978, 199, 592, 19, 275, 11618, 63, 88, 14, 16672, 2798, 8, 1848, 29, 802, 63, 89, 12, 1004, 534, 2322, 358, 199, 199, 3, 2011, 465, 3432, 543, 19555, 15, 529, 2497, 18819, 199, 592, 20, 275, 11618, 63, 88, 14, 802, 2798, 8, 1848, 29, 802, 63, 89, 12, 1004, 534, 2322, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 10502, 641, 25625, 10162, 24293, 22528, 26, 708, 26, 1046, 6029, 199, 199, 5949, 26, 1603, 3362, 70, 3492, 5973, 1753, 199, 3773, 471, 701, 26, 28574, 869, 2873, 834, 334, 7409, 13, 2036, 13, 1167, 9, 199, 624, 199, 504, 7026, 492, 5020, 199, 504, 8027, 492, 1134, 2798, 465, 4488, 199, 646, 5020, 992, 14, 1246, 465, 4383, 199, 199, 3, 2694, 687, 9214, 199, 576, 275, 4383, 14, 12281, 14, 2809, 15515, 14, 912, 342, 199, 576, 14, 23919, 275, 4383, 14, 525, 63, 4083, 8, 576, 14, 23919, 12, 18213, 29, 549, 9, 199, 1494, 63, 3269, 275, 4383, 14, 2228, 51, 8, 576, 14, 27647, 12, 666, 14, 23919, 680, 3269, 342, 199, 470, 275, 3413, 63, 3269, 14, 19581, 199, 199, 3039, 275, 446, 17, 14, 24, 257, 327, 88, 10021, 367, 1318, 5518, 199, 199, 592, 275, 4488, 14, 8941, 342, 199, 199, 1219, 275, 6085, 14, 525, 63, 13334, 8, 18, 12, 499, 12, 413, 9, 199, 3300, 14, 15707, 14, 16672, 2798, 8, 470, 12, 2185, 29, 1219, 9, 199, 2119, 275, 2185, 14, 362, 63, 18123, 3430, 17, 61, 627, 378, 14, 2194, 199, 2424, 275, 2185, 14, 505, 8, 3039, 12, 2746, 12, 283, 889, 7681, 297, 13763, 13699, 534, 2119, 358, 199, 2424, 14, 409, 63, 11246, 8, 807, 8, 1409, 2326, 534, 75, 297, 5131, 29, 16, 14, 17, 430, 199, 199, 1219, 275, 6085, 14, 525, 63, 13334, 8, 18, 12, 499, 12, 499, 9, 199, 3300, 14, 15707, 14, 16672, 2798, 8, 470, 12, 1004, 534, 83, 297, 2185, 29, 1219, 9, 199, 2119, 275, 2185, 14, 362, 63, 18123, 3430, 17, 61, 627, 378, 14, 2194, 199, 2424, 275, 2185, 14, 505, 8, 3039, 12, 2746, 12, 298, 604, 534, 83, 4662, 13763, 13699, 534, 2119, 358, 199, 2424, 14, 409, 63, 11246, 8, 807, 8, 1409, 2326, 534, 75, 297, 5131, 29, 16, 14, 17, 430, 199, 199, 1219, 275, 6085, 14, 525, 63, 13334, 8, 18, 12, 499, 12, 650, 9, 199, 3300, 14, 15707, 14, 16672, 2798, 8, 470, 12, 1004, 534, 2322, 297, 5542, 29, 549, 12, 2185, 29, 1219, 9, 199, 1219, 14, 409, 63, 18512, 2801, 18, 12, 499, 9, 199, 2119, 275, 2185, 14, 362, 63, 18123, 3430, 17, 61, 627, 378, 14, 2194, 199, 2424, 275, 2185, 14, 505, 8, 3039, 12, 2746, 12, 298, 604, 534, 2322, 297, 971, 78, 3269, 29, 549, 401, 13763, 13699, 534, 2119, 358, 199, 2424, 14, 409, 63, 11246, 8, 807, 8, 1409, 2326, 534, 75, 297, 5131, 29, 16, 14, 17, 430, 199, 199, 1219, 275, 6085, 14, 525, 63, 13334, 8, 18, 12, 499, 12, 841, 9, 199, 3300, 14, 15707, 14, 16672, 2798, 8, 470, 12, 2917, 29, 3200, 14, 84, 12, 1004, 534, 2322, 297, 5542, 29, 549, 12, 2185, 29, 1219, 9, 199, 1219, 14, 409, 63, 18512, 2801, 18, 12, 499, 9, 199, 2119, 275, 2185, 14, 362, 63, 18123, 3430, 17, 61, 627, 378, 14, 2194, 199, 2424, 275, 2185, 14, 505, 8, 3039, 12, 2746, 12, 298, 2686, 29, 3200, 14, 84, 12, 971, 78, 604, 534, 2322, 297, 971, 78, 3269, 29, 549, 401, 1598, 13763, 13699, 534, 2119, 358, 199, 2424, 14, 409, 63, 11246, 8, 807, 8, 1409, 2326, 534, 75, 297, 5131, 29, 16, 14, 17, 430, 199, 199, 592, 14, 23787, 63, 4209, 342, 199, 199, 6003, 14, 71, 2177, 342, 421, 199, 3, 2893, 543, 314, 892, 22770, 10711, 1021, 199, 646, 2680, 465, 980, 199, 88, 275, 980, 14, 2355, 14, 3302, 8, 2102, 29, 24, 14, 821, 12, 4666, 29, 19, 14, 21, 12, 1568, 29, 1401, 9, 199, 89, 275, 980, 14, 2355, 14, 3302, 8, 2102, 29, 24, 14, 383, 12, 4666, 29, 19, 14, 821, 12, 1568, 29, 1401, 9, 199, 802, 63, 88, 275, 4383, 14, 20122, 10711, 8, 88, 12, 5542, 29, 549, 9, 199, 802, 63, 89, 275, 4383, 14, 20122, 10711, 8, 89, 12, 5542, 29, 549, 9, 199, 199, 3, 12224, 402, 24068, 554, 199, 592, 18, 275, 11618, 63, 88, 14, 6101, 2798, 8, 476, 15648, 29, 549, 9, 199, 199, 3, 6540, 671, 13621, 2978, 370, 612, 13621, 2978, 199, 592, 19, 275, 11618, 63, 88, 14, 16672, 2798, 8, 1848, 29, 802, 63, 89, 12, 1004, 534, 2322, 358, 199, 199, 3, 2011, 465, 3432, 543, 19555, 15, 529, 2497, 18819, 199, 592, 20, 275, 11618, 63, 88, 14, 802, 2798, 8, 1848, 29, 802, 63, 89, 12, 1004, 534, 2322, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
eayunstack/rally
rally/plugins/__init__.py
20
1275
# Copyright 2015: Mirantis Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import os import decorator from rally.common.plugin import discover PLUGINS_LOADED = False def load(): global PLUGINS_LOADED if not PLUGINS_LOADED: discover.import_modules_from_package("rally.deployment.engines") discover.import_modules_from_package("rally.deployment.serverprovider") discover.import_modules_from_package("rally.plugins") discover.load_plugins("/opt/rally/plugins/") discover.load_plugins(os.path.expanduser("~/.rally/plugins/")) PLUGINS_LOADED = True @decorator.decorator def ensure_plugins_are_loaded(f, *args, **kwargs): load() return f(*args, **kwargs)
apache-2.0
[ 3, 1898, 6900, 26, 603, 723, 4466, 83, 3277, 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, 747, 199, 199, 646, 7531, 199, 199, 504, 519, 1183, 14, 2330, 14, 2718, 492, 20131, 421, 199, 16483, 10789, 63, 1484, 33, 8280, 275, 756, 421, 199, 318, 2248, 837, 272, 2288, 10092, 10134, 10789, 63, 1484, 33, 8280, 339, 340, 440, 10092, 10134, 10789, 63, 1484, 33, 8280, 26, 267, 20131, 14, 646, 63, 3112, 63, 504, 63, 2491, 480, 82, 1183, 14, 13605, 14, 30378, 531, 267, 20131, 14, 646, 63, 3112, 63, 504, 63, 2491, 480, 82, 1183, 14, 13605, 14, 1000, 3780, 531, 267, 20131, 14, 646, 63, 3112, 63, 504, 63, 2491, 480, 82, 1183, 14, 5265, 531, 398, 20131, 14, 912, 63, 5265, 4769, 2992, 15, 82, 1183, 15, 5265, 13589, 267, 20131, 14, 912, 63, 5265, 8, 736, 14, 515, 14, 12131, 20793, 8083, 82, 1183, 15, 5265, 15, 2237, 339, 10092, 10134, 10789, 63, 1484, 33, 8280, 275, 715, 421, 199, 32, 11547, 14, 11547, 199, 318, 4868, 63, 5265, 63, 1530, 63, 4591, 8, 70, 12, 627, 589, 12, 1011, 958, 304, 272, 2248, 342, 272, 372, 289, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6900, 26, 603, 723, 4466, 83, 3277, 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, 747, 199, 199, 646, 7531, 199, 199, 504, 519, 1183, 14, 2330, 14, 2718, 492, 20131, 421, 199, 16483, 10789, 63, 1484, 33, 8280, 275, 756, 421, 199, 318, 2248, 837, 272, 2288, 10092, 10134, 10789, 63, 1484, 33, 8280, 339, 340, 440, 10092, 10134, 10789, 63, 1484, 33, 8280, 26, 267, 20131, 14, 646, 63, 3112, 63, 504, 63, 2491, 480, 82, 1183, 14, 13605, 14, 30378, 531, 267, 20131, 14, 646, 63, 3112, 63, 504, 63, 2491, 480, 82, 1183, 14, 13605, 14, 1000, 3780, 531, 267, 20131, 14, 646, 63, 3112, 63, 504, 63, 2491, 480, 82, 1183, 14, 5265, 531, 398, 20131, 14, 912, 63, 5265, 4769, 2992, 15, 82, 1183, 15, 5265, 13589, 267, 20131, 14, 912, 63, 5265, 8, 736, 14, 515, 14, 12131, 20793, 8083, 82, 1183, 15, 5265, 15, 2237, 339, 10092, 10134, 10789, 63, 1484, 33, 8280, 275, 715, 421, 199, 32, 11547, 14, 11547, 199, 318, 4868, 63, 5265, 63, 1530, 63, 4591, 8, 70, 12, 627, 589, 12, 1011, 958, 304, 272, 2248, 342, 272, 372, 289, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
IITBinterns13/edx-platform-dev
common/djangoapps/terrain/factories.py
9
1312
''' Factories are defined in other modules and absorbed here into the lettuce world so that they can be used by both unit tests and integration / BDD tests. ''' import student.tests.factories as sf import xmodule.modulestore.tests.factories as xf from lettuce import world @world.absorb class UserFactory(sf.UserFactory): """ User account for lms / cms """ FACTORY_DJANGO_GET_OR_CREATE = ('username',) pass @world.absorb class UserProfileFactory(sf.UserProfileFactory): """ Demographics etc for the User """ FACTORY_DJANGO_GET_OR_CREATE = ('user',) pass @world.absorb class RegistrationFactory(sf.RegistrationFactory): """ Activation key for registering the user account """ FACTORY_DJANGO_GET_OR_CREATE = ('user',) pass @world.absorb class GroupFactory(sf.GroupFactory): """ Groups for user permissions for courses """ pass @world.absorb class CourseEnrollmentAllowedFactory(sf.CourseEnrollmentAllowedFactory): """ Users allowed to enroll in the course outside of the usual window """ pass @world.absorb class CourseFactory(xf.CourseFactory): """ Courseware courses """ pass @world.absorb class ItemFactory(xf.ItemFactory): """ Everything included inside a course """ pass
agpl-3.0
[ 2344, 199, 1906, 4253, 787, 3247, 315, 1163, 4621, 436, 2236, 1509, 6123, 2348, 1901, 314, 199, 22784, 3683, 6701, 880, 626, 2985, 883, 506, 1202, 701, 3865, 4137, 2295, 199, 460, 13150, 1182, 699, 5745, 2295, 14, 199, 2344, 199, 646, 6474, 14, 2219, 14, 15406, 465, 13330, 199, 646, 9872, 14, 10012, 14, 2219, 14, 15406, 465, 27366, 199, 504, 4691, 84, 3683, 492, 6701, 421, 199, 32, 7617, 14, 371, 1509, 66, 199, 533, 16047, 8, 7646, 14, 24594, 304, 272, 408, 272, 2876, 2933, 367, 21577, 1182, 19240, 272, 408, 272, 481, 3036, 5347, 63, 22848, 63, 2970, 63, 726, 63, 8366, 275, 661, 2473, 9538, 272, 986, 421, 199, 32, 7617, 14, 371, 1509, 66, 199, 533, 19037, 2927, 8, 7646, 14, 23544, 2927, 304, 272, 408, 272, 28939, 15707, 5423, 367, 314, 2876, 272, 408, 272, 481, 3036, 5347, 63, 22848, 63, 2970, 63, 726, 63, 8366, 275, 661, 751, 9538, 272, 986, 421, 199, 32, 7617, 14, 371, 1509, 66, 199, 533, 20764, 2927, 8, 7646, 14, 11757, 2927, 304, 272, 408, 272, 29441, 790, 367, 2274, 316, 314, 922, 2933, 272, 408, 272, 481, 3036, 5347, 63, 22848, 63, 2970, 63, 726, 63, 8366, 275, 661, 751, 9538, 272, 986, 421, 199, 32, 7617, 14, 371, 1509, 66, 199, 533, 5611, 2927, 8, 7646, 14, 2448, 2927, 304, 272, 408, 272, 25031, 367, 922, 3443, 367, 13588, 272, 408, 272, 986, 421, 199, 32, 7617, 14, 371, 1509, 66, 199, 533, 18946, 16070, 2927, 8, 7646, 14, 6979, 13842, 16070, 2927, 304, 272, 408, 272, 20123, 4370, 370, 26361, 315, 314, 2518, 9682, 402, 314, 20195, 4353, 272, 408, 272, 986, 421, 199, 32, 7617, 14, 371, 1509, 66, 199, 533, 17862, 8, 1949, 14, 6979, 2927, 304, 272, 408, 272, 5531, 1068, 13588, 272, 408, 272, 986, 421, 199, 32, 7617, 14, 371, 1509, 66, 199, 533, 19319, 8, 1949, 14, 2081, 2927, 304, 272, 408, 272, 18414, 2127, 5120, 6272, 282, 2518, 272, 408, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 1906, 4253, 787, 3247, 315, 1163, 4621, 436, 2236, 1509, 6123, 2348, 1901, 314, 199, 22784, 3683, 6701, 880, 626, 2985, 883, 506, 1202, 701, 3865, 4137, 2295, 199, 460, 13150, 1182, 699, 5745, 2295, 14, 199, 2344, 199, 646, 6474, 14, 2219, 14, 15406, 465, 13330, 199, 646, 9872, 14, 10012, 14, 2219, 14, 15406, 465, 27366, 199, 504, 4691, 84, 3683, 492, 6701, 421, 199, 32, 7617, 14, 371, 1509, 66, 199, 533, 16047, 8, 7646, 14, 24594, 304, 272, 408, 272, 2876, 2933, 367, 21577, 1182, 19240, 272, 408, 272, 481, 3036, 5347, 63, 22848, 63, 2970, 63, 726, 63, 8366, 275, 661, 2473, 9538, 272, 986, 421, 199, 32, 7617, 14, 371, 1509, 66, 199, 533, 19037, 2927, 8, 7646, 14, 23544, 2927, 304, 272, 408, 272, 28939, 15707, 5423, 367, 314, 2876, 272, 408, 272, 481, 3036, 5347, 63, 22848, 63, 2970, 63, 726, 63, 8366, 275, 661, 751, 9538, 272, 986, 421, 199, 32, 7617, 14, 371, 1509, 66, 199, 533, 20764, 2927, 8, 7646, 14, 11757, 2927, 304, 272, 408, 272, 29441, 790, 367, 2274, 316, 314, 922, 2933, 272, 408, 272, 481, 3036, 5347, 63, 22848, 63, 2970, 63, 726, 63, 8366, 275, 661, 751, 9538, 272, 986, 421, 199, 32, 7617, 14, 371, 1509, 66, 199, 533, 5611, 2927, 8, 7646, 14, 2448, 2927, 304, 272, 408, 272, 25031, 367, 922, 3443, 367, 13588, 272, 408, 272, 986, 421, 199, 32, 7617, 14, 371, 1509, 66, 199, 533, 18946, 16070, 2927, 8, 7646, 14, 6979, 13842, 16070, 2927, 304, 272, 408, 272, 20123, 4370, 370, 26361, 315, 314, 2518, 9682, 402, 314, 20195, 4353, 272, 408, 272, 986, 421, 199, 32, 7617, 14, 371, 1509, 66, 199, 533, 17862, 8, 1949, 14, 6979, 2927, 304, 272, 408, 272, 5531, 1068, 13588, 272, 408, 272, 986, 421, 199, 32, 7617, 14, 371, 1509, 66, 199, 533, 19319, 8, 1949, 14, 2081, 2927, 304, 272, 408, 272, 18414, 2127, 5120, 6272, 282, 2518, 272, 408, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ahmed-mahran/hue
desktop/core/ext-py/Django-1.6.10/django/conf/locale/de/formats.py
118
1104
# -*- encoding: utf-8 -*- # This file is distributed under the same license as the Django package. # from __future__ import unicode_literals # The *_FORMAT strings use the Django date format syntax, # see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date DATE_FORMAT = 'j. F Y' TIME_FORMAT = 'H:i:s' DATETIME_FORMAT = 'j. F Y H:i:s' YEAR_MONTH_FORMAT = 'F Y' MONTH_DAY_FORMAT = 'j. F' SHORT_DATE_FORMAT = 'd.m.Y' SHORT_DATETIME_FORMAT = 'd.m.Y H:i:s' FIRST_DAY_OF_WEEK = 1 # Monday # The *_INPUT_FORMATS strings use the Python strftime format syntax, # see http://docs.python.org/library/datetime.html#strftime-strptime-behavior DATE_INPUT_FORMATS = ( '%d.%m.%Y', '%d.%m.%y', # '25.10.2006', '25.10.06' # '%d. %B %Y', '%d. %b. %Y', # '25. October 2006', '25. Oct. 2006' ) DATETIME_INPUT_FORMATS = ( '%d.%m.%Y %H:%M:%S', # '25.10.2006 14:30:59' '%d.%m.%Y %H:%M:%S.%f', # '25.10.2006 14:30:59.000200' '%d.%m.%Y %H:%M', # '25.10.2006 14:30' '%d.%m.%Y', # '25.10.2006' ) DECIMAL_SEPARATOR = ',' THOUSAND_SEPARATOR = '.' NUMBER_GROUPING = 3
apache-2.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 283, 74, 14, 481, 1488, 7, 199, 4961, 63, 4807, 275, 283, 40, 26, 73, 26, 83, 7, 199, 12488, 63, 4807, 275, 283, 74, 14, 481, 1488, 869, 26, 73, 26, 83, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 7, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 14, 481, 7, 199, 13003, 63, 5390, 63, 4807, 275, 283, 68, 14, 77, 14, 57, 7, 199, 13003, 63, 12488, 63, 4807, 275, 283, 68, 14, 77, 14, 57, 869, 26, 73, 26, 83, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 327, 32740, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 5390, 63, 7321, 63, 14019, 275, 334, 272, 1543, 68, 4111, 77, 4111, 57, 297, 1543, 68, 4111, 77, 4111, 89, 297, 258, 327, 283, 821, 14, 709, 14, 7968, 297, 283, 821, 14, 709, 14, 1690, 7, 272, 327, 1543, 68, 14, 450, 34, 450, 57, 297, 1543, 68, 14, 450, 66, 14, 450, 57, 297, 221, 327, 283, 821, 14, 18365, 22459, 8315, 297, 283, 821, 14, 18365, 14, 8315, 7, 199, 9, 199, 12488, 63, 7321, 63, 14019, 275, 334, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 297, 259, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 297, 755, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 297, 3777, 327, 283, 821, 14, 709, 14, 7968, 7, 199, 9, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 7815, 199, 9190, 63, 7823, 1206, 275, 650, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 283, 74, 14, 481, 1488, 7, 199, 4961, 63, 4807, 275, 283, 40, 26, 73, 26, 83, 7, 199, 12488, 63, 4807, 275, 283, 74, 14, 481, 1488, 869, 26, 73, 26, 83, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 7, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 14, 481, 7, 199, 13003, 63, 5390, 63, 4807, 275, 283, 68, 14, 77, 14, 57, 7, 199, 13003, 63, 12488, 63, 4807, 275, 283, 68, 14, 77, 14, 57, 869, 26, 73, 26, 83, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 327, 32740, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 5390, 63, 7321, 63, 14019, 275, 334, 272, 1543, 68, 4111, 77, 4111, 57, 297, 1543, 68, 4111, 77, 4111, 89, 297, 258, 327, 283, 821, 14, 709, 14, 7968, 297, 283, 821, 14, 709, 14, 1690, 7, 272, 327, 1543, 68, 14, 450, 34, 450, 57, 297, 1543, 68, 14, 450, 66, 14, 450, 57, 297, 221, 327, 283, 821, 14, 18365, 22459, 8315, 297, 283, 821, 14, 18365, 14, 8315, 7, 199, 9, 199, 12488, 63, 7321, 63, 14019, 275, 334, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 297, 259, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 297, 755, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 297, 3777, 327, 283, 821, 14, 709, 14, 7968, 7, 199, 9, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 7815, 199, 9190, 63, 7823, 1206, 275, 650, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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]
AutonomyLab/deep_intent
code/gan_model/scripts/model_config_3d.py
2
1462
from __future__ import absolute_import from __future__ import division from __future__ import print_function from keras.optimizers import SGD from keras.optimizers import Adam import os # ------------------------------------------------- # Background config: # DATA_DIR= '/home/pratik/DeepIntent_Datasets/KITTI_Dataset/' # DATA_DIR= '/local_home/data/JAAD_data/' # DATA_DIR= '/local_home/data/KITTI_data/' # DATA_DIR = '/grad/2/pgujjar/DeepIntent/data/JAAD_data' DATA_DIR = './../data/KITTI_data' MODEL_DIR = './../models' if not os.path.exists(MODEL_DIR): os.mkdir(MODEL_DIR) CHECKPOINT_DIR = './../checkpoints' if not os.path.exists(CHECKPOINT_DIR): os.mkdir(CHECKPOINT_DIR) GEN_IMAGES_DIR = './../generated_images' if not os.path.exists(GEN_IMAGES_DIR): os.mkdir(GEN_IMAGES_DIR) LOG_DIR = './../logs' if not os.path.exists(LOG_DIR): os.mkdir(LOG_DIR) TF_LOG_DIR = "./../tf_logs" if not os.path.exists(TF_LOG_DIR): os.mkdir(TF_LOG_DIR) PRINT_MODEL_SUMMARY = True SAVE_MODEL = False SAVE_GENERATED_IMAGES = True DATA_AUGMENTATION = False SHUFFLE = False # ------------------------------------------------- # Network configuration: print ("Loading network/training configuration...") BATCH_SIZE = 128 NB_EPOCHS = 100 IMAGE_SHAPE = (64, 64, 3) # g_optim = SGD(lr=0.0001, momentum=0.5, nesterov=True) # d_optim = Adam(lr=0.005, beta_1=0.5) G_OPTIM = Adam(lr=0.00001, beta_1=0.5) D_OPTIM = SGD(lr=0.0002, momentum=0.5, nesterov=True)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 11708, 14, 6433, 6315, 492, 18868, 36, 199, 504, 11708, 14, 6433, 6315, 492, 4431, 455, 199, 646, 747, 199, 199, 3, 9527, 13, 199, 3, 10257, 3928, 1101, 26, 199, 3, 7126, 63, 3022, 29, 1994, 4219, 15, 80, 345, 30298, 15, 27753, 607, 767, 63, 1451, 2193, 15, 43, 649, 13247, 63, 9271, 4805, 199, 3, 7126, 63, 3022, 29, 1994, 1832, 63, 4219, 15, 576, 15, 29849, 1554, 63, 576, 4805, 199, 3, 7126, 63, 3022, 29, 1994, 1832, 63, 4219, 15, 576, 15, 43, 649, 13247, 63, 576, 4805, 199, 3, 7126, 63, 3022, 275, 1994, 6017, 15, 18, 15, 4198, 17189, 7338, 15, 27753, 607, 767, 15, 576, 15, 29849, 1554, 63, 576, 7, 199, 3998, 63, 3022, 275, 21526, 5093, 576, 15, 43, 649, 13247, 63, 576, 7, 199, 199, 11429, 63, 3022, 275, 21526, 5093, 992, 7, 199, 692, 440, 747, 14, 515, 14, 2444, 8, 11429, 63, 3022, 304, 272, 747, 14, 8215, 8, 11429, 63, 3022, 9, 199, 199, 8936, 7217, 63, 3022, 275, 21526, 5093, 32475, 7, 199, 692, 440, 747, 14, 515, 14, 2444, 8, 8936, 7217, 63, 3022, 304, 272, 747, 14, 8215, 8, 8936, 7217, 63, 3022, 9, 199, 199, 9289, 63, 1469, 5383, 63, 3022, 275, 21526, 5093, 10176, 63, 4782, 7, 199, 692, 440, 747, 14, 515, 14, 2444, 8, 9289, 63, 1469, 5383, 63, 3022, 304, 272, 747, 14, 8215, 8, 9289, 63, 1469, 5383, 63, 3022, 9, 199, 199, 4947, 63, 3022, 275, 21526, 5093, 7270, 7, 199, 692, 440, 747, 14, 515, 14, 2444, 8, 4947, 63, 3022, 304, 272, 747, 14, 8215, 8, 4947, 63, 3022, 9, 199, 199, 6145, 63, 4947, 63, 3022, 275, 26069, 5093, 3249, 63, 7270, 2, 199, 692, 440, 747, 14, 515, 14, 2444, 8, 6145, 63, 4947, 63, 3022, 304, 272, 747, 14, 8215, 8, 6145, 63, 4947, 63, 3022, 9, 199, 199, 21754, 63, 11429, 63, 29508, 275, 715, 199, 19318, 63, 11429, 275, 756, 199, 19318, 63, 12795, 6989, 63, 1469, 5383, 275, 715, 199, 3998, 63, 9331, 39, 4479, 2594, 275, 756, 199, 3234, 8158, 906, 275, 756, 199, 199, 3, 9527, 13, 199, 3, 7220, 2897, 26, 199, 1361, 1689, 19236, 2784, 15, 7588, 2897, 12594, 199, 199, 20813, 63, 4305, 275, 7960, 199, 16170, 63, 37, 1512, 1244, 51, 275, 2948, 199, 9438, 63, 3234, 25380, 275, 334, 772, 12, 5049, 12, 650, 9, 199, 199, 3, 486, 63, 6433, 275, 18868, 36, 8, 7493, 29, 16, 14, 4183, 12, 23887, 29, 16, 14, 21, 12, 302, 397, 24208, 86, 29, 549, 9, 199, 3, 366, 63, 6433, 275, 4431, 455, 8, 7493, 29, 16, 14, 7972, 12, 8201, 63, 17, 29, 16, 14, 21, 9, 199, 39, 63, 5123, 1469, 275, 4431, 455, 8, 7493, 29, 16, 14, 22417, 12, 8201, 63, 17, 29, 16, 14, 21, 9, 199, 36, 63, 5123, 1469, 275, 18868, 36, 8, 7493, 29, 16, 14, 9425, 12, 23887, 29, 16, 14, 21, 12, 302, 397, 24208, 86, 29, 549, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 11708, 14, 6433, 6315, 492, 18868, 36, 199, 504, 11708, 14, 6433, 6315, 492, 4431, 455, 199, 646, 747, 199, 199, 3, 9527, 13, 199, 3, 10257, 3928, 1101, 26, 199, 3, 7126, 63, 3022, 29, 1994, 4219, 15, 80, 345, 30298, 15, 27753, 607, 767, 63, 1451, 2193, 15, 43, 649, 13247, 63, 9271, 4805, 199, 3, 7126, 63, 3022, 29, 1994, 1832, 63, 4219, 15, 576, 15, 29849, 1554, 63, 576, 4805, 199, 3, 7126, 63, 3022, 29, 1994, 1832, 63, 4219, 15, 576, 15, 43, 649, 13247, 63, 576, 4805, 199, 3, 7126, 63, 3022, 275, 1994, 6017, 15, 18, 15, 4198, 17189, 7338, 15, 27753, 607, 767, 15, 576, 15, 29849, 1554, 63, 576, 7, 199, 3998, 63, 3022, 275, 21526, 5093, 576, 15, 43, 649, 13247, 63, 576, 7, 199, 199, 11429, 63, 3022, 275, 21526, 5093, 992, 7, 199, 692, 440, 747, 14, 515, 14, 2444, 8, 11429, 63, 3022, 304, 272, 747, 14, 8215, 8, 11429, 63, 3022, 9, 199, 199, 8936, 7217, 63, 3022, 275, 21526, 5093, 32475, 7, 199, 692, 440, 747, 14, 515, 14, 2444, 8, 8936, 7217, 63, 3022, 304, 272, 747, 14, 8215, 8, 8936, 7217, 63, 3022, 9, 199, 199, 9289, 63, 1469, 5383, 63, 3022, 275, 21526, 5093, 10176, 63, 4782, 7, 199, 692, 440, 747, 14, 515, 14, 2444, 8, 9289, 63, 1469, 5383, 63, 3022, 304, 272, 747, 14, 8215, 8, 9289, 63, 1469, 5383, 63, 3022, 9, 199, 199, 4947, 63, 3022, 275, 21526, 5093, 7270, 7, 199, 692, 440, 747, 14, 515, 14, 2444, 8, 4947, 63, 3022, 304, 272, 747, 14, 8215, 8, 4947, 63, 3022, 9, 199, 199, 6145, 63, 4947, 63, 3022, 275, 26069, 5093, 3249, 63, 7270, 2, 199, 692, 440, 747, 14, 515, 14, 2444, 8, 6145, 63, 4947, 63, 3022, 304, 272, 747, 14, 8215, 8, 6145, 63, 4947, 63, 3022, 9, 199, 199, 21754, 63, 11429, 63, 29508, 275, 715, 199, 19318, 63, 11429, 275, 756, 199, 19318, 63, 12795, 6989, 63, 1469, 5383, 275, 715, 199, 3998, 63, 9331, 39, 4479, 2594, 275, 756, 199, 3234, 8158, 906, 275, 756, 199, 199, 3, 9527, 13, 199, 3, 7220, 2897, 26, 199, 1361, 1689, 19236, 2784, 15, 7588, 2897, 12594, 199, 199, 20813, 63, 4305, 275, 7960, 199, 16170, 63, 37, 1512, 1244, 51, 275, 2948, 199, 9438, 63, 3234, 25380, 275, 334, 772, 12, 5049, 12, 650, 9, 199, 199, 3, 486, 63, 6433, 275, 18868, 36, 8, 7493, 29, 16, 14, 4183, 12, 23887, 29, 16, 14, 21, 12, 302, 397, 24208, 86, 29, 549, 9, 199, 3, 366, 63, 6433, 275, 4431, 455, 8, 7493, 29, 16, 14, 7972, 12, 8201, 63, 17, 29, 16, 14, 21, 9, 199, 39, 63, 5123, 1469, 275, 4431, 455, 8, 7493, 29, 16, 14, 22417, 12, 8201, 63, 17, 29, 16, 14, 21, 9, 199, 36, 63, 5123, 1469, 275, 18868, 36, 8, 7493, 29, 16, 14, 9425, 12, 23887, 29, 16, 14, 21, 12, 302, 397, 24208, 86, 29, 549, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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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 ]
gengliangwang/spark
python/pyspark/mllib/tests/test_linalg.py
15
27588
# # 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 array as pyarray import unittest from numpy import array, array_equal, zeros, arange, tile, ones, inf import pyspark.ml.linalg as newlinalg from pyspark.serializers import PickleSerializer from pyspark.mllib.linalg import ( # type: ignore[attr-defined] Vector, SparseVector, DenseVector, VectorUDT, _convert_to_vector, DenseMatrix, SparseMatrix, Vectors, Matrices, MatrixUDT ) from pyspark.mllib.linalg.distributed import RowMatrix, IndexedRowMatrix, IndexedRow from pyspark.mllib.regression import LabeledPoint from pyspark.sql import Row from pyspark.testing.mllibutils import MLlibTestCase from pyspark.testing.utils import have_scipy class VectorTests(MLlibTestCase): def _test_serialize(self, v): ser = PickleSerializer() self.assertEqual(v, ser.loads(ser.dumps(v))) jvec = self.sc._jvm.org.apache.spark.mllib.api.python.SerDe.loads(bytearray(ser.dumps(v))) nv = ser.loads(bytes(self.sc._jvm.org.apache.spark.mllib.api.python.SerDe.dumps(jvec))) self.assertEqual(v, nv) vs = [v] * 100 jvecs = self.sc._jvm.org.apache.spark.mllib.api.python.SerDe.loads(bytearray(ser.dumps(vs))) nvs = ser.loads(bytes(self.sc._jvm.org.apache.spark.mllib.api.python.SerDe.dumps(jvecs))) self.assertEqual(vs, nvs) def test_serialize(self): self._test_serialize(DenseVector(range(10))) self._test_serialize(DenseVector(array([1., 2., 3., 4.]))) self._test_serialize(DenseVector(pyarray.array('d', range(10)))) self._test_serialize(SparseVector(4, {1: 1, 3: 2})) self._test_serialize(SparseVector(3, {})) self._test_serialize(DenseMatrix(2, 3, range(6))) sm1 = SparseMatrix( 3, 4, [0, 2, 2, 4, 4], [1, 2, 1, 2], [1.0, 2.0, 4.0, 5.0]) self._test_serialize(sm1) def test_dot(self): sv = SparseVector(4, {1: 1, 3: 2}) dv = DenseVector(array([1., 2., 3., 4.])) lst = DenseVector([1, 2, 3, 4]) mat = array([[1., 2., 3., 4.], [1., 2., 3., 4.], [1., 2., 3., 4.], [1., 2., 3., 4.]]) arr = pyarray.array('d', [0, 1, 2, 3]) self.assertEqual(10.0, sv.dot(dv)) self.assertTrue(array_equal(array([3., 6., 9., 12.]), sv.dot(mat))) self.assertEqual(30.0, dv.dot(dv)) self.assertTrue(array_equal(array([10., 20., 30., 40.]), dv.dot(mat))) self.assertEqual(30.0, lst.dot(dv)) self.assertTrue(array_equal(array([10., 20., 30., 40.]), lst.dot(mat))) self.assertEqual(7.0, sv.dot(arr)) def test_squared_distance(self): def squared_distance(a, b): if isinstance(a, Vector): return a.squared_distance(b) else: return b.squared_distance(a) sv = SparseVector(4, {1: 1, 3: 2}) dv = DenseVector(array([1., 2., 3., 4.])) lst = DenseVector([4, 3, 2, 1]) lst1 = [4, 3, 2, 1] arr = pyarray.array('d', [0, 2, 1, 3]) narr = array([0, 2, 1, 3]) self.assertEqual(15.0, squared_distance(sv, dv)) self.assertEqual(25.0, squared_distance(sv, lst)) self.assertEqual(20.0, squared_distance(dv, lst)) self.assertEqual(15.0, squared_distance(dv, sv)) self.assertEqual(25.0, squared_distance(lst, sv)) self.assertEqual(20.0, squared_distance(lst, dv)) self.assertEqual(0.0, squared_distance(sv, sv)) self.assertEqual(0.0, squared_distance(dv, dv)) self.assertEqual(0.0, squared_distance(lst, lst)) self.assertEqual(25.0, squared_distance(sv, lst1)) self.assertEqual(3.0, squared_distance(sv, arr)) self.assertEqual(3.0, squared_distance(sv, narr)) def test_hash(self): v1 = DenseVector([0.0, 1.0, 0.0, 5.5]) v2 = SparseVector(4, [(1, 1.0), (3, 5.5)]) v3 = DenseVector([0.0, 1.0, 0.0, 5.5]) v4 = SparseVector(4, [(1, 1.0), (3, 2.5)]) self.assertEqual(hash(v1), hash(v2)) self.assertEqual(hash(v1), hash(v3)) self.assertEqual(hash(v2), hash(v3)) self.assertFalse(hash(v1) == hash(v4)) self.assertFalse(hash(v2) == hash(v4)) def test_eq(self): v1 = DenseVector([0.0, 1.0, 0.0, 5.5]) v2 = SparseVector(4, [(1, 1.0), (3, 5.5)]) v3 = DenseVector([0.0, 1.0, 0.0, 5.5]) v4 = SparseVector(6, [(1, 1.0), (3, 5.5)]) v5 = DenseVector([0.0, 1.0, 0.0, 2.5]) v6 = SparseVector(4, [(1, 1.0), (3, 2.5)]) dm1 = DenseMatrix(2, 2, [2, 0, 0, 0]) sm1 = SparseMatrix(2, 2, [0, 2, 3], [0], [2]) self.assertEqual(v1, v2) self.assertEqual(v1, v3) self.assertFalse(v2 == v4) self.assertFalse(v1 == v5) self.assertFalse(v1 == v6) # this is done as Dense and Sparse matrices can be semantically # equal while still implementing a different __eq__ method self.assertEqual(dm1, sm1) self.assertEqual(sm1, dm1) def test_equals(self): indices = [1, 2, 4] values = [1., 3., 2.] self.assertTrue(Vectors._equals(indices, values, list(range(5)), [0., 1., 3., 0., 2.])) self.assertFalse(Vectors._equals(indices, values, list(range(5)), [0., 3., 1., 0., 2.])) self.assertFalse(Vectors._equals(indices, values, list(range(5)), [0., 3., 0., 2.])) self.assertFalse(Vectors._equals(indices, values, list(range(5)), [0., 1., 3., 2., 2.])) def test_conversion(self): # numpy arrays should be automatically upcast to float64 # tests for fix of [SPARK-5089] v = array([1, 2, 3, 4], dtype='float64') dv = DenseVector(v) self.assertTrue(dv.array.dtype == 'float64') v = array([1, 2, 3, 4], dtype='float32') dv = DenseVector(v) self.assertTrue(dv.array.dtype == 'float64') def test_sparse_vector_indexing(self): sv = SparseVector(5, {1: 1, 3: 2}) self.assertEqual(sv[0], 0.) self.assertEqual(sv[3], 2.) self.assertEqual(sv[1], 1.) self.assertEqual(sv[2], 0.) self.assertEqual(sv[4], 0.) self.assertEqual(sv[-1], 0.) self.assertEqual(sv[-2], 2.) self.assertEqual(sv[-3], 0.) self.assertEqual(sv[-5], 0.) for ind in [5, -6]: self.assertRaises(IndexError, sv.__getitem__, ind) for ind in [7.8, '1']: self.assertRaises(TypeError, sv.__getitem__, ind) zeros = SparseVector(4, {}) self.assertEqual(zeros[0], 0.0) self.assertEqual(zeros[3], 0.0) for ind in [4, -5]: self.assertRaises(IndexError, zeros.__getitem__, ind) empty = SparseVector(0, {}) for ind in [-1, 0, 1]: self.assertRaises(IndexError, empty.__getitem__, ind) def test_sparse_vector_iteration(self): self.assertListEqual(list(SparseVector(3, [], [])), [0.0, 0.0, 0.0]) self.assertListEqual(list(SparseVector(5, [0, 3], [1.0, 2.0])), [1.0, 0.0, 0.0, 2.0, 0.0]) def test_matrix_indexing(self): mat = DenseMatrix(3, 2, [0, 1, 4, 6, 8, 10]) expected = [[0, 6], [1, 8], [4, 10]] for i in range(3): for j in range(2): self.assertEqual(mat[i, j], expected[i][j]) for i, j in [(-1, 0), (4, 1), (3, 4)]: self.assertRaises(IndexError, mat.__getitem__, (i, j)) def test_repr_dense_matrix(self): mat = DenseMatrix(3, 2, [0, 1, 4, 6, 8, 10]) self.assertTrue( repr(mat), 'DenseMatrix(3, 2, [0.0, 1.0, 4.0, 6.0, 8.0, 10.0], False)') mat = DenseMatrix(3, 2, [0, 1, 4, 6, 8, 10], True) self.assertTrue( repr(mat), 'DenseMatrix(3, 2, [0.0, 1.0, 4.0, 6.0, 8.0, 10.0], False)') mat = DenseMatrix(6, 3, zeros(18)) self.assertTrue( repr(mat), 'DenseMatrix(6, 3, [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ..., \ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], False)') def test_repr_sparse_matrix(self): sm1t = SparseMatrix( 3, 4, [0, 2, 3, 5], [0, 1, 2, 0, 2], [3.0, 2.0, 4.0, 9.0, 8.0], isTransposed=True) self.assertTrue( repr(sm1t), 'SparseMatrix(3, 4, [0, 2, 3, 5], [0, 1, 2, 0, 2], [3.0, 2.0, 4.0, 9.0, 8.0], True)') indices = tile(arange(6), 3) values = ones(18) sm = SparseMatrix(6, 3, [0, 6, 12, 18], indices, values) self.assertTrue( repr(sm), "SparseMatrix(6, 3, [0, 6, 12, 18], \ [0, 1, 2, 3, 4, 5, 0, 1, ..., 4, 5, 0, 1, 2, 3, 4, 5], \ [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, ..., \ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], False)") self.assertTrue( str(sm), "6 X 3 CSCMatrix\n\ (0,0) 1.0\n(1,0) 1.0\n(2,0) 1.0\n(3,0) 1.0\n(4,0) 1.0\n(5,0) 1.0\n\ (0,1) 1.0\n(1,1) 1.0\n(2,1) 1.0\n(3,1) 1.0\n(4,1) 1.0\n(5,1) 1.0\n\ (0,2) 1.0\n(1,2) 1.0\n(2,2) 1.0\n(3,2) 1.0\n..\n..") sm = SparseMatrix(1, 18, zeros(19), [], []) self.assertTrue( repr(sm), 'SparseMatrix(1, 18, \ [0, 0, 0, 0, 0, 0, 0, 0, ..., 0, 0, 0, 0, 0, 0, 0, 0], [], [], False)') def test_sparse_matrix(self): # Test sparse matrix creation. sm1 = SparseMatrix( 3, 4, [0, 2, 2, 4, 4], [1, 2, 1, 2], [1.0, 2.0, 4.0, 5.0]) self.assertEqual(sm1.numRows, 3) self.assertEqual(sm1.numCols, 4) self.assertEqual(sm1.colPtrs.tolist(), [0, 2, 2, 4, 4]) self.assertEqual(sm1.rowIndices.tolist(), [1, 2, 1, 2]) self.assertEqual(sm1.values.tolist(), [1.0, 2.0, 4.0, 5.0]) self.assertTrue( repr(sm1), 'SparseMatrix(3, 4, [0, 2, 2, 4, 4], [1, 2, 1, 2], [1.0, 2.0, 4.0, 5.0], False)') # Test indexing expected = [ [0, 0, 0, 0], [1, 0, 4, 0], [2, 0, 5, 0]] for i in range(3): for j in range(4): self.assertEqual(expected[i][j], sm1[i, j]) self.assertTrue(array_equal(sm1.toArray(), expected)) for i, j in [(-1, 1), (4, 3), (3, 5)]: self.assertRaises(IndexError, sm1.__getitem__, (i, j)) # Test conversion to dense and sparse. smnew = sm1.toDense().toSparse() self.assertEqual(sm1.numRows, smnew.numRows) self.assertEqual(sm1.numCols, smnew.numCols) self.assertTrue(array_equal(sm1.colPtrs, smnew.colPtrs)) self.assertTrue(array_equal(sm1.rowIndices, smnew.rowIndices)) self.assertTrue(array_equal(sm1.values, smnew.values)) sm1t = SparseMatrix( 3, 4, [0, 2, 3, 5], [0, 1, 2, 0, 2], [3.0, 2.0, 4.0, 9.0, 8.0], isTransposed=True) self.assertEqual(sm1t.numRows, 3) self.assertEqual(sm1t.numCols, 4) self.assertEqual(sm1t.colPtrs.tolist(), [0, 2, 3, 5]) self.assertEqual(sm1t.rowIndices.tolist(), [0, 1, 2, 0, 2]) self.assertEqual(sm1t.values.tolist(), [3.0, 2.0, 4.0, 9.0, 8.0]) expected = [ [3, 2, 0, 0], [0, 0, 4, 0], [9, 0, 8, 0]] for i in range(3): for j in range(4): self.assertEqual(expected[i][j], sm1t[i, j]) self.assertTrue(array_equal(sm1t.toArray(), expected)) def test_dense_matrix_is_transposed(self): mat1 = DenseMatrix(3, 2, [0, 4, 1, 6, 3, 9], isTransposed=True) mat = DenseMatrix(3, 2, [0, 1, 3, 4, 6, 9]) self.assertEqual(mat1, mat) expected = [[0, 4], [1, 6], [3, 9]] for i in range(3): for j in range(2): self.assertEqual(mat1[i, j], expected[i][j]) self.assertTrue(array_equal(mat1.toArray(), expected)) sm = mat1.toSparse() self.assertTrue(array_equal(sm.rowIndices, [1, 2, 0, 1, 2])) self.assertTrue(array_equal(sm.colPtrs, [0, 2, 5])) self.assertTrue(array_equal(sm.values, [1, 3, 4, 6, 9])) def test_parse_vector(self): a = DenseVector([]) self.assertEqual(str(a), '[]') self.assertEqual(Vectors.parse(str(a)), a) a = DenseVector([3, 4, 6, 7]) self.assertEqual(str(a), '[3.0,4.0,6.0,7.0]') self.assertEqual(Vectors.parse(str(a)), a) a = SparseVector(4, [], []) self.assertEqual(str(a), '(4,[],[])') self.assertEqual(SparseVector.parse(str(a)), a) a = SparseVector(4, [0, 2], [3, 4]) self.assertEqual(str(a), '(4,[0,2],[3.0,4.0])') self.assertEqual(Vectors.parse(str(a)), a) a = SparseVector(10, [0, 1], [4, 5]) self.assertEqual(SparseVector.parse(' (10, [0,1 ],[ 4.0,5.0] )'), a) def test_norms(self): a = DenseVector([0, 2, 3, -1]) self.assertAlmostEqual(a.norm(2), 3.742, 3) self.assertTrue(a.norm(1), 6) self.assertTrue(a.norm(inf), 3) a = SparseVector(4, [0, 2], [3, -4]) self.assertAlmostEqual(a.norm(2), 5) self.assertTrue(a.norm(1), 7) self.assertTrue(a.norm(inf), 4) tmp = SparseVector(4, [0, 2], [3, 0]) self.assertEqual(tmp.numNonzeros(), 1) def test_ml_mllib_vector_conversion(self): # to ml # dense mllibDV = Vectors.dense([1, 2, 3]) mlDV1 = newlinalg.Vectors.dense([1, 2, 3]) mlDV2 = mllibDV.asML() self.assertEqual(mlDV2, mlDV1) # sparse mllibSV = Vectors.sparse(4, {1: 1.0, 3: 5.5}) mlSV1 = newlinalg.Vectors.sparse(4, {1: 1.0, 3: 5.5}) mlSV2 = mllibSV.asML() self.assertEqual(mlSV2, mlSV1) # from ml # dense mllibDV1 = Vectors.dense([1, 2, 3]) mlDV = newlinalg.Vectors.dense([1, 2, 3]) mllibDV2 = Vectors.fromML(mlDV) self.assertEqual(mllibDV1, mllibDV2) # sparse mllibSV1 = Vectors.sparse(4, {1: 1.0, 3: 5.5}) mlSV = newlinalg.Vectors.sparse(4, {1: 1.0, 3: 5.5}) mllibSV2 = Vectors.fromML(mlSV) self.assertEqual(mllibSV1, mllibSV2) def test_ml_mllib_matrix_conversion(self): # to ml # dense mllibDM = Matrices.dense(2, 2, [0, 1, 2, 3]) mlDM1 = newlinalg.Matrices.dense(2, 2, [0, 1, 2, 3]) mlDM2 = mllibDM.asML() self.assertEqual(mlDM2, mlDM1) # transposed mllibDMt = DenseMatrix(2, 2, [0, 1, 2, 3], True) mlDMt1 = newlinalg.DenseMatrix(2, 2, [0, 1, 2, 3], True) mlDMt2 = mllibDMt.asML() self.assertEqual(mlDMt2, mlDMt1) # sparse mllibSM = Matrices.sparse(2, 2, [0, 2, 3], [0, 1, 1], [2, 3, 4]) mlSM1 = newlinalg.Matrices.sparse(2, 2, [0, 2, 3], [0, 1, 1], [2, 3, 4]) mlSM2 = mllibSM.asML() self.assertEqual(mlSM2, mlSM1) # transposed mllibSMt = SparseMatrix(2, 2, [0, 2, 3], [0, 1, 1], [2, 3, 4], True) mlSMt1 = newlinalg.SparseMatrix(2, 2, [0, 2, 3], [0, 1, 1], [2, 3, 4], True) mlSMt2 = mllibSMt.asML() self.assertEqual(mlSMt2, mlSMt1) # from ml # dense mllibDM1 = Matrices.dense(2, 2, [1, 2, 3, 4]) mlDM = newlinalg.Matrices.dense(2, 2, [1, 2, 3, 4]) mllibDM2 = Matrices.fromML(mlDM) self.assertEqual(mllibDM1, mllibDM2) # transposed mllibDMt1 = DenseMatrix(2, 2, [1, 2, 3, 4], True) mlDMt = newlinalg.DenseMatrix(2, 2, [1, 2, 3, 4], True) mllibDMt2 = Matrices.fromML(mlDMt) self.assertEqual(mllibDMt1, mllibDMt2) # sparse mllibSM1 = Matrices.sparse(2, 2, [0, 2, 3], [0, 1, 1], [2, 3, 4]) mlSM = newlinalg.Matrices.sparse(2, 2, [0, 2, 3], [0, 1, 1], [2, 3, 4]) mllibSM2 = Matrices.fromML(mlSM) self.assertEqual(mllibSM1, mllibSM2) # transposed mllibSMt1 = SparseMatrix(2, 2, [0, 2, 3], [0, 1, 1], [2, 3, 4], True) mlSMt = newlinalg.SparseMatrix(2, 2, [0, 2, 3], [0, 1, 1], [2, 3, 4], True) mllibSMt2 = Matrices.fromML(mlSMt) self.assertEqual(mllibSMt1, mllibSMt2) class VectorUDTTests(MLlibTestCase): dv0 = DenseVector([]) dv1 = DenseVector([1.0, 2.0]) sv0 = SparseVector(2, [], []) sv1 = SparseVector(2, [1], [2.0]) udt = VectorUDT() def test_json_schema(self): self.assertEqual(VectorUDT.fromJson(self.udt.jsonValue()), self.udt) def test_serialization(self): for v in [self.dv0, self.dv1, self.sv0, self.sv1]: self.assertEqual(v, self.udt.deserialize(self.udt.serialize(v))) def test_infer_schema(self): rdd = self.sc.parallelize([LabeledPoint(1.0, self.dv1), LabeledPoint(0.0, self.sv1)]) df = rdd.toDF() schema = df.schema field = [f for f in schema.fields if f.name == "features"][0] self.assertEqual(field.dataType, self.udt) vectors = df.rdd.map(lambda p: p.features).collect() self.assertEqual(len(vectors), 2) for v in vectors: if isinstance(v, SparseVector): self.assertEqual(v, self.sv1) elif isinstance(v, DenseVector): self.assertEqual(v, self.dv1) else: raise TypeError("expecting a vector but got %r of type %r" % (v, type(v))) def test_row_matrix_from_dataframe(self): from pyspark.sql.utils import IllegalArgumentException df = self.spark.createDataFrame([Row(Vectors.dense(1))]) row_matrix = RowMatrix(df) self.assertEqual(row_matrix.numRows(), 1) self.assertEqual(row_matrix.numCols(), 1) with self.assertRaises(IllegalArgumentException): RowMatrix(df.selectExpr("'monkey'")) def test_indexed_row_matrix_from_dataframe(self): from pyspark.sql.utils import IllegalArgumentException df = self.spark.createDataFrame([Row(int(0), Vectors.dense(1))]) matrix = IndexedRowMatrix(df) self.assertEqual(matrix.numRows(), 1) self.assertEqual(matrix.numCols(), 1) with self.assertRaises(IllegalArgumentException): IndexedRowMatrix(df.drop("_1")) def test_row_matrix_invalid_type(self): rows = self.sc.parallelize([[1, 2, 3], [4, 5, 6]]) invalid_type = "" matrix = RowMatrix(rows) self.assertRaises(TypeError, matrix.multiply, invalid_type) irows = self.sc.parallelize([IndexedRow(0, [1, 2, 3]), IndexedRow(1, [4, 5, 6])]) imatrix = IndexedRowMatrix(irows) self.assertRaises(TypeError, imatrix.multiply, invalid_type) class MatrixUDTTests(MLlibTestCase): dm1 = DenseMatrix(3, 2, [0, 1, 4, 5, 9, 10]) dm2 = DenseMatrix(3, 2, [0, 1, 4, 5, 9, 10], isTransposed=True) sm1 = SparseMatrix(1, 1, [0, 1], [0], [2.0]) sm2 = SparseMatrix(2, 1, [0, 0, 1], [0], [5.0], isTransposed=True) udt = MatrixUDT() def test_json_schema(self): self.assertEqual(MatrixUDT.fromJson(self.udt.jsonValue()), self.udt) def test_serialization(self): for m in [self.dm1, self.dm2, self.sm1, self.sm2]: self.assertEqual(m, self.udt.deserialize(self.udt.serialize(m))) def test_infer_schema(self): rdd = self.sc.parallelize([("dense", self.dm1), ("sparse", self.sm1)]) df = rdd.toDF() schema = df.schema self.assertTrue(schema.fields[1].dataType, self.udt) matrices = df.rdd.map(lambda x: x._2).collect() self.assertEqual(len(matrices), 2) for m in matrices: if isinstance(m, DenseMatrix): self.assertTrue(m, self.dm1) elif isinstance(m, SparseMatrix): self.assertTrue(m, self.sm1) else: raise ValueError("Expected a matrix but got type %r" % type(m)) @unittest.skipIf(not have_scipy, "SciPy not installed") class SciPyTests(MLlibTestCase): """ Test both vector operations and MLlib algorithms with SciPy sparse matrices, if SciPy is available. """ def test_serialize(self): from scipy.sparse import lil_matrix ser = PickleSerializer() lil = lil_matrix((4, 1)) lil[1, 0] = 1 lil[3, 0] = 2 sv = SparseVector(4, {1: 1, 3: 2}) self.assertEqual(sv, _convert_to_vector(lil)) self.assertEqual(sv, _convert_to_vector(lil.tocsc())) self.assertEqual(sv, _convert_to_vector(lil.tocoo())) self.assertEqual(sv, _convert_to_vector(lil.tocsr())) self.assertEqual(sv, _convert_to_vector(lil.todok())) def serialize(l): return ser.loads(ser.dumps(_convert_to_vector(l))) self.assertEqual(sv, serialize(lil)) self.assertEqual(sv, serialize(lil.tocsc())) self.assertEqual(sv, serialize(lil.tocsr())) self.assertEqual(sv, serialize(lil.todok())) def test_convert_to_vector(self): from scipy.sparse import csc_matrix # Create a CSC matrix with non-sorted indices indptr = array([0, 2]) indices = array([3, 1]) data = array([2.0, 1.0]) csc = csc_matrix((data, indices, indptr)) self.assertFalse(csc.has_sorted_indices) sv = SparseVector(4, {1: 1, 3: 2}) self.assertEqual(sv, _convert_to_vector(csc)) def test_dot(self): from scipy.sparse import lil_matrix lil = lil_matrix((4, 1)) lil[1, 0] = 1 lil[3, 0] = 2 dv = DenseVector(array([1., 2., 3., 4.])) self.assertEqual(10.0, dv.dot(lil)) def test_squared_distance(self): from scipy.sparse import lil_matrix lil = lil_matrix((4, 1)) lil[1, 0] = 3 lil[3, 0] = 2 dv = DenseVector(array([1., 2., 3., 4.])) sv = SparseVector(4, {0: 1, 1: 2, 2: 3, 3: 4}) self.assertEqual(15.0, dv.squared_distance(lil)) self.assertEqual(15.0, sv.squared_distance(lil)) def scipy_matrix(self, size, values): """Create a column SciPy matrix from a dictionary of values""" from scipy.sparse import lil_matrix lil = lil_matrix((size, 1)) for key, value in values.items(): lil[key, 0] = value return lil def test_clustering(self): from pyspark.mllib.clustering import KMeans data = [ self.scipy_matrix(3, {1: 1.0}), self.scipy_matrix(3, {1: 1.1}), self.scipy_matrix(3, {2: 1.0}), self.scipy_matrix(3, {2: 1.1}) ] clusters = KMeans.train(self.sc.parallelize(data), 2, initializationMode="k-means||") self.assertEqual(clusters.predict(data[0]), clusters.predict(data[1])) self.assertEqual(clusters.predict(data[2]), clusters.predict(data[3])) def test_classification(self): from pyspark.mllib.classification import LogisticRegressionWithSGD, SVMWithSGD, NaiveBayes from pyspark.mllib.tree import DecisionTree data = [ LabeledPoint(0.0, self.scipy_matrix(2, {0: 1.0})), LabeledPoint(1.0, self.scipy_matrix(2, {1: 1.0})), LabeledPoint(0.0, self.scipy_matrix(2, {0: 2.0})), LabeledPoint(1.0, self.scipy_matrix(2, {1: 2.0})) ] rdd = self.sc.parallelize(data) features = [p.features for p in data] lr_model = LogisticRegressionWithSGD.train(rdd) self.assertTrue(lr_model.predict(features[0]) <= 0) self.assertTrue(lr_model.predict(features[1]) > 0) self.assertTrue(lr_model.predict(features[2]) <= 0) self.assertTrue(lr_model.predict(features[3]) > 0) svm_model = SVMWithSGD.train(rdd) self.assertTrue(svm_model.predict(features[0]) <= 0) self.assertTrue(svm_model.predict(features[1]) > 0) self.assertTrue(svm_model.predict(features[2]) <= 0) self.assertTrue(svm_model.predict(features[3]) > 0) nb_model = NaiveBayes.train(rdd) self.assertTrue(nb_model.predict(features[0]) <= 0) self.assertTrue(nb_model.predict(features[1]) > 0) self.assertTrue(nb_model.predict(features[2]) <= 0) self.assertTrue(nb_model.predict(features[3]) > 0) categoricalFeaturesInfo = {0: 3} # feature 0 has 3 categories dt_model = DecisionTree.trainClassifier(rdd, numClasses=2, categoricalFeaturesInfo=categoricalFeaturesInfo) self.assertTrue(dt_model.predict(features[0]) <= 0) self.assertTrue(dt_model.predict(features[1]) > 0) self.assertTrue(dt_model.predict(features[2]) <= 0) self.assertTrue(dt_model.predict(features[3]) > 0) def test_regression(self): from pyspark.mllib.regression import LinearRegressionWithSGD, LassoWithSGD, \ RidgeRegressionWithSGD from pyspark.mllib.tree import DecisionTree data = [ LabeledPoint(-1.0, self.scipy_matrix(2, {1: -1.0})), LabeledPoint(1.0, self.scipy_matrix(2, {1: 1.0})), LabeledPoint(-1.0, self.scipy_matrix(2, {1: -2.0})), LabeledPoint(1.0, self.scipy_matrix(2, {1: 2.0})) ] rdd = self.sc.parallelize(data) features = [p.features for p in data] lr_model = LinearRegressionWithSGD.train(rdd) self.assertTrue(lr_model.predict(features[0]) <= 0) self.assertTrue(lr_model.predict(features[1]) > 0) self.assertTrue(lr_model.predict(features[2]) <= 0) self.assertTrue(lr_model.predict(features[3]) > 0) lasso_model = LassoWithSGD.train(rdd) self.assertTrue(lasso_model.predict(features[0]) <= 0) self.assertTrue(lasso_model.predict(features[1]) > 0) self.assertTrue(lasso_model.predict(features[2]) <= 0) self.assertTrue(lasso_model.predict(features[3]) > 0) rr_model = RidgeRegressionWithSGD.train(rdd) self.assertTrue(rr_model.predict(features[0]) <= 0) self.assertTrue(rr_model.predict(features[1]) > 0) self.assertTrue(rr_model.predict(features[2]) <= 0) self.assertTrue(rr_model.predict(features[3]) > 0) categoricalFeaturesInfo = {0: 2} # feature 0 has 2 categories dt_model = DecisionTree.trainRegressor(rdd, categoricalFeaturesInfo=categoricalFeaturesInfo) self.assertTrue(dt_model.predict(features[0]) <= 0) self.assertTrue(dt_model.predict(features[1]) > 0) self.assertTrue(dt_model.predict(features[2]) <= 0) self.assertTrue(dt_model.predict(features[3]) > 0) if __name__ == "__main__": from pyspark.mllib.tests.test_linalg import * # noqa: F401 try: import xmlrunner # type: ignore[import] testRunner = xmlrunner.XMLTestRunner(output='target/test-reports', verbosity=2) except ImportError: testRunner = None unittest.main(testRunner=testRunner, verbosity=2)
apache-2.0
[ 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 1625, 465, 1134, 1144, 199, 646, 2882, 199, 199, 504, 2680, 492, 1625, 12, 1625, 63, 1452, 12, 10136, 12, 20461, 12, 12835, 12, 7869, 12, 10739, 199, 199, 646, 15847, 14, 757, 14, 10096, 465, 892, 10096, 199, 504, 15847, 14, 12844, 492, 31732, 7299, 199, 504, 15847, 14, 25598, 14, 10096, 492, 334, 221, 327, 730, 26, 3686, 59, 962, 13, 4037, 61, 272, 11388, 12, 14531, 3646, 12, 20847, 3646, 12, 11388, 3383, 52, 12, 485, 3916, 63, 475, 63, 4106, 12, 272, 20847, 6443, 12, 14531, 6443, 12, 812, 9177, 12, 18619, 9355, 12, 8449, 3383, 52, 199, 9, 199, 504, 15847, 14, 25598, 14, 10096, 14, 16832, 492, 15231, 6443, 12, 26437, 5810, 6443, 12, 26437, 5810, 199, 504, 15847, 14, 25598, 14, 12513, 492, 491, 14502, 3428, 199, 504, 15847, 14, 3009, 492, 15231, 199, 504, 15847, 14, 4776, 14, 757, 317, 464, 3024, 492, 28007, 773, 1746, 199, 504, 15847, 14, 4776, 14, 1208, 492, 1172, 63, 14248, 421, 199, 533, 11388, 2925, 8, 1698, 773, 1746, 304, 339, 347, 485, 396, 63, 3549, 8, 277, 12, 373, 304, 267, 8926, 275, 31732, 7299, 342, 267, 291, 14, 629, 8, 86, 12, 8926, 14, 3640, 8, 332, 14, 4180, 8, 86, 1724, 267, 1335, 6046, 275, 291, 14, 551, 423, 15813, 14, 1308, 14, 3796, 14, 9852, 14, 25598, 14, 1246, 14, 1548, 14, 1505, 872, 14, 3640, 8, 20108, 8, 332, 14, 4180, 8, 86, 1724, 267, 26510, 275, 8926, 14, 3640, 8, 2394, 8, 277, 14, 551, 423, 15813, 14, 1308, 14, 3796, 14, 9852, 14, 25598, 14, 1246, 14, 1548, 14, 1505, 872, 14, 4180, 8, 74, 6046, 1724, 267, 291, 14, 629, 8, 86, 12, 26510, 9, 267, 8118, 275, 359, 86, 61, 627, 2948, 267, 1335, 25130, 275, 291, 14, 551, 423, 15813, 14, 1308, 14, 3796, 14, 9852, 14, 25598, 14, 1246, 14, 1548, 14, 1505, 872, 14, 3640, 8, 20108, 8, 332, 14, 4180, 8, 3122, 1724, 267, 302, 3122, 275, 8926, 14, 3640, 8, 2394, 8, 277, 14, 551, 423, 15813, 14, 1308, 14, 3796, 14, 9852, 14, 25598, 14, 1246, 14, 1548, 14, 1505, 872, 14, 4180, 8, 74, 25130, 1724, 267, 291, 14, 629, 8, 3122, 12, 302, 3122, 9, 339, 347, 511, 63, 3549, 8, 277, 304, 267, 291, 423, 396, 63, 3549, 8, 15327, 3646, 8, 1842, 8, 709, 1724, 267, 291, 423, 396, 63, 3549, 8, 15327, 3646, 8, 1144, 779, 17, 2020, 499, 2020, 650, 2020, 841, 14, 11845, 267, 291, 423, 396, 63, 3549, 8, 15327, 3646, 8, 647, 1144, 14, 1144, 360, 68, 297, 1425, 8, 709, 7845, 267, 291, 423, 396, 63, 3549, 8, 8629, 3646, 8, 20, 12, 469, 17, 26, 413, 12, 650, 26, 499, 12466, 267, 291, 423, 396, 63, 3549, 8, 8629, 3646, 8, 19, 12, 17003, 267, 291, 423, 396, 63, 3549, 8, 15327, 6443, 8, 18, 12, 650, 12, 1425, 8, 22, 1724, 267, 4383, 17, 275, 14531, 6443, 8, 288, 650, 12, 841, 12, 359, 16, 12, 499, 12, 499, 12, 841, 12, 841, 467, 359, 17, 12, 499, 12, 413, 12, 499, 467, 359, 17, 14, 16, 12, 499, 14, 16, 12, 841, 14, 16, 12, 959, 14, 16, 566, 267, 291, 423, 396, 63, 3549, 8, 3300, 17, 9, 339, 347, 511, 63, 3287, 8, 277, 304, 267, 19291, 275, 14531, 3646, 8, 20, 12, 469, 17, 26, 413, 12, 650, 26, 499, 1552, 267, 26869, 275, 20847, 3646, 8, 1144, 779, 17, 2020, 499, 2020, 650, 2020, 841, 14, 2459, 267, 9877, 275, 20847, 3646, 779, 17, 12, 499, 12, 650, 12, 841, 566, 267, 2530, 275, 1625, 4038, 17, 2020, 499, 2020, 650, 2020, 841, 8333, 2151, 359, 17, 2020, 499, 2020, 650, 2020, 841, 8333, 2151, 359, 17, 2020, 499, 2020, 650, 2020, 841, 8333, 2151, 359, 17, 2020, 499, 2020, 650, 2020, 841, 19450, 267, 7953, 275, 1134, 1144, 14, 1144, 360, 68, 297, 359, 16, 12, 413, 12, 499, 12, 650, 566, 267, 291, 14, 629, 8, 709, 14, 16, 12, 19291, 14, 3287, 8, 8398, 430, 267, 291, 14, 1815, 8, 1144, 63, 1452, 8, 1144, 779, 19, 2020, 1227, 2020, 1749, 2020, 3144, 14, 2522, 19291, 14, 3287, 8, 569, 1724, 267, 291, 14, 629, 8, 1216, 14, 16, 12, 26869, 14, 3287, 8, 8398, 430, 267, 291, 14, 1815, 8, 1144, 63, 1452, 8, 1144, 779, 709, 2020, 3388, 2020, 4233, 2020, 6335, 14, 2522, 26869, 14, 3287, 8, 569, 1724, 267, 291, 14, 629, 8, 1216, 14, 16, 12, 9877, 14, 3287, 8, 8398, 430, 267, 291, 14, 1815, 8, 1144, 63, 1452, 8, 1144, 779, 709, 2020, 3388, 2020, 4233, 2020, 6335, 14, 2522, 9877, 14, 3287, 8, 569, 1724, 267, 291, 14, 629, 8, 23, 14, 16, 12, 19291, 14, 3287, 8, 5250, 430, 339, 347, 511, 63, 12973, 63, 5590, 8, 277, 304, 267, 347, 20478, 63, 5590, 8, 65, 12, 330, 304, 288, 340, 1228, 8, 65, 12, 11388, 304, 355, 372, 282, 14, 12973, 63, 5590 ]
[ 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 1625, 465, 1134, 1144, 199, 646, 2882, 199, 199, 504, 2680, 492, 1625, 12, 1625, 63, 1452, 12, 10136, 12, 20461, 12, 12835, 12, 7869, 12, 10739, 199, 199, 646, 15847, 14, 757, 14, 10096, 465, 892, 10096, 199, 504, 15847, 14, 12844, 492, 31732, 7299, 199, 504, 15847, 14, 25598, 14, 10096, 492, 334, 221, 327, 730, 26, 3686, 59, 962, 13, 4037, 61, 272, 11388, 12, 14531, 3646, 12, 20847, 3646, 12, 11388, 3383, 52, 12, 485, 3916, 63, 475, 63, 4106, 12, 272, 20847, 6443, 12, 14531, 6443, 12, 812, 9177, 12, 18619, 9355, 12, 8449, 3383, 52, 199, 9, 199, 504, 15847, 14, 25598, 14, 10096, 14, 16832, 492, 15231, 6443, 12, 26437, 5810, 6443, 12, 26437, 5810, 199, 504, 15847, 14, 25598, 14, 12513, 492, 491, 14502, 3428, 199, 504, 15847, 14, 3009, 492, 15231, 199, 504, 15847, 14, 4776, 14, 757, 317, 464, 3024, 492, 28007, 773, 1746, 199, 504, 15847, 14, 4776, 14, 1208, 492, 1172, 63, 14248, 421, 199, 533, 11388, 2925, 8, 1698, 773, 1746, 304, 339, 347, 485, 396, 63, 3549, 8, 277, 12, 373, 304, 267, 8926, 275, 31732, 7299, 342, 267, 291, 14, 629, 8, 86, 12, 8926, 14, 3640, 8, 332, 14, 4180, 8, 86, 1724, 267, 1335, 6046, 275, 291, 14, 551, 423, 15813, 14, 1308, 14, 3796, 14, 9852, 14, 25598, 14, 1246, 14, 1548, 14, 1505, 872, 14, 3640, 8, 20108, 8, 332, 14, 4180, 8, 86, 1724, 267, 26510, 275, 8926, 14, 3640, 8, 2394, 8, 277, 14, 551, 423, 15813, 14, 1308, 14, 3796, 14, 9852, 14, 25598, 14, 1246, 14, 1548, 14, 1505, 872, 14, 4180, 8, 74, 6046, 1724, 267, 291, 14, 629, 8, 86, 12, 26510, 9, 267, 8118, 275, 359, 86, 61, 627, 2948, 267, 1335, 25130, 275, 291, 14, 551, 423, 15813, 14, 1308, 14, 3796, 14, 9852, 14, 25598, 14, 1246, 14, 1548, 14, 1505, 872, 14, 3640, 8, 20108, 8, 332, 14, 4180, 8, 3122, 1724, 267, 302, 3122, 275, 8926, 14, 3640, 8, 2394, 8, 277, 14, 551, 423, 15813, 14, 1308, 14, 3796, 14, 9852, 14, 25598, 14, 1246, 14, 1548, 14, 1505, 872, 14, 4180, 8, 74, 25130, 1724, 267, 291, 14, 629, 8, 3122, 12, 302, 3122, 9, 339, 347, 511, 63, 3549, 8, 277, 304, 267, 291, 423, 396, 63, 3549, 8, 15327, 3646, 8, 1842, 8, 709, 1724, 267, 291, 423, 396, 63, 3549, 8, 15327, 3646, 8, 1144, 779, 17, 2020, 499, 2020, 650, 2020, 841, 14, 11845, 267, 291, 423, 396, 63, 3549, 8, 15327, 3646, 8, 647, 1144, 14, 1144, 360, 68, 297, 1425, 8, 709, 7845, 267, 291, 423, 396, 63, 3549, 8, 8629, 3646, 8, 20, 12, 469, 17, 26, 413, 12, 650, 26, 499, 12466, 267, 291, 423, 396, 63, 3549, 8, 8629, 3646, 8, 19, 12, 17003, 267, 291, 423, 396, 63, 3549, 8, 15327, 6443, 8, 18, 12, 650, 12, 1425, 8, 22, 1724, 267, 4383, 17, 275, 14531, 6443, 8, 288, 650, 12, 841, 12, 359, 16, 12, 499, 12, 499, 12, 841, 12, 841, 467, 359, 17, 12, 499, 12, 413, 12, 499, 467, 359, 17, 14, 16, 12, 499, 14, 16, 12, 841, 14, 16, 12, 959, 14, 16, 566, 267, 291, 423, 396, 63, 3549, 8, 3300, 17, 9, 339, 347, 511, 63, 3287, 8, 277, 304, 267, 19291, 275, 14531, 3646, 8, 20, 12, 469, 17, 26, 413, 12, 650, 26, 499, 1552, 267, 26869, 275, 20847, 3646, 8, 1144, 779, 17, 2020, 499, 2020, 650, 2020, 841, 14, 2459, 267, 9877, 275, 20847, 3646, 779, 17, 12, 499, 12, 650, 12, 841, 566, 267, 2530, 275, 1625, 4038, 17, 2020, 499, 2020, 650, 2020, 841, 8333, 2151, 359, 17, 2020, 499, 2020, 650, 2020, 841, 8333, 2151, 359, 17, 2020, 499, 2020, 650, 2020, 841, 8333, 2151, 359, 17, 2020, 499, 2020, 650, 2020, 841, 19450, 267, 7953, 275, 1134, 1144, 14, 1144, 360, 68, 297, 359, 16, 12, 413, 12, 499, 12, 650, 566, 267, 291, 14, 629, 8, 709, 14, 16, 12, 19291, 14, 3287, 8, 8398, 430, 267, 291, 14, 1815, 8, 1144, 63, 1452, 8, 1144, 779, 19, 2020, 1227, 2020, 1749, 2020, 3144, 14, 2522, 19291, 14, 3287, 8, 569, 1724, 267, 291, 14, 629, 8, 1216, 14, 16, 12, 26869, 14, 3287, 8, 8398, 430, 267, 291, 14, 1815, 8, 1144, 63, 1452, 8, 1144, 779, 709, 2020, 3388, 2020, 4233, 2020, 6335, 14, 2522, 26869, 14, 3287, 8, 569, 1724, 267, 291, 14, 629, 8, 1216, 14, 16, 12, 9877, 14, 3287, 8, 8398, 430, 267, 291, 14, 1815, 8, 1144, 63, 1452, 8, 1144, 779, 709, 2020, 3388, 2020, 4233, 2020, 6335, 14, 2522, 9877, 14, 3287, 8, 569, 1724, 267, 291, 14, 629, 8, 23, 14, 16, 12, 19291, 14, 3287, 8, 5250, 430, 339, 347, 511, 63, 12973, 63, 5590, 8, 277, 304, 267, 347, 20478, 63, 5590, 8, 65, 12, 330, 304, 288, 340, 1228, 8, 65, 12, 11388, 304, 355, 372, 282, 14, 12973, 63, 5590, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mozvip/CouchPotatoServer
libs/migrate/versioning/schema.py
53
7595
""" Database schema version management. """ import sys import logging from sqlalchemy import (Table, Column, MetaData, String, Text, Integer, create_engine) from sqlalchemy.sql import and_ from sqlalchemy import exceptions as sa_exceptions from sqlalchemy.sql import bindparam from migrate import exceptions from migrate.changeset import SQLA_07 from migrate.versioning import genmodel, schemadiff from migrate.versioning.repository import Repository from migrate.versioning.util import load_model from migrate.versioning.version import VerNum log = logging.getLogger(__name__) class ControlledSchema(object): """A database under version control""" def __init__(self, engine, repository): if isinstance(repository, basestring): repository = Repository(repository) self.engine = engine self.repository = repository self.meta = MetaData(engine) self.load() def __eq__(self, other): """Compare two schemas by repositories and versions""" return (self.repository is other.repository \ and self.version == other.version) def load(self): """Load controlled schema version info from DB""" tname = self.repository.version_table try: if not hasattr(self, 'table') or self.table is None: self.table = Table(tname, self.meta, autoload=True) result = self.engine.execute(self.table.select( self.table.c.repository_id == str(self.repository.id))) data = list(result)[0] except: cls, exc, tb = sys.exc_info() raise exceptions.DatabaseNotControlledError, exc.__str__(), tb self.version = data['version'] return data def drop(self): """ Remove version control from a database. """ if SQLA_07: try: self.table.drop() except sa_exceptions.DatabaseError: raise exceptions.DatabaseNotControlledError(str(self.table)) else: try: self.table.drop() except (sa_exceptions.SQLError): raise exceptions.DatabaseNotControlledError(str(self.table)) def changeset(self, version=None): """API to Changeset creation. Uses self.version for start version and engine.name to get database name. """ database = self.engine.name start_ver = self.version changeset = self.repository.changeset(database, start_ver, version) return changeset def runchange(self, ver, change, step): startver = ver endver = ver + step # Current database version must be correct! Don't run if corrupt! if self.version != startver: raise exceptions.InvalidVersionError("%s is not %s" % \ (self.version, startver)) # Run the change change.run(self.engine, step) # Update/refresh database version self.update_repository_table(startver, endver) self.load() def update_repository_table(self, startver, endver): """Update version_table with new information""" update = self.table.update(and_(self.table.c.version == int(startver), self.table.c.repository_id == str(self.repository.id))) self.engine.execute(update, version=int(endver)) def upgrade(self, version=None): """ Upgrade (or downgrade) to a specified version, or latest version. """ changeset = self.changeset(version) for ver, change in changeset: self.runchange(ver, change, changeset.step) def update_db_from_model(self, model): """ Modify the database to match the structure of the current Python model. """ model = load_model(model) diff = schemadiff.getDiffOfModelAgainstDatabase( model, self.engine, excludeTables=[self.repository.version_table] ) genmodel.ModelGenerator(diff,self.engine).runB2A() self.update_repository_table(self.version, int(self.repository.latest)) self.load() @classmethod def create(cls, engine, repository, version=None): """ Declare a database to be under a repository's version control. :raises: :exc:`DatabaseAlreadyControlledError` :returns: :class:`ControlledSchema` """ # Confirm that the version # is valid: positive, integer, # exists in repos if isinstance(repository, basestring): repository = Repository(repository) version = cls._validate_version(repository, version) table = cls._create_table_version(engine, repository, version) # TODO: history table # Load repository information and return return cls(engine, repository) @classmethod def _validate_version(cls, repository, version): """ Ensures this is a valid version number for this repository. :raises: :exc:`InvalidVersionError` if invalid :return: valid version number """ if version is None: version = 0 try: version = VerNum(version) # raises valueerror if version < 0 or version > repository.latest: raise ValueError() except ValueError: raise exceptions.InvalidVersionError(version) return version @classmethod def _create_table_version(cls, engine, repository, version): """ Creates the versioning table in a database. :raises: :exc:`DatabaseAlreadyControlledError` """ # Create tables tname = repository.version_table meta = MetaData(engine) table = Table( tname, meta, Column('repository_id', String(250), primary_key=True), Column('repository_path', Text), Column('version', Integer), ) # there can be multiple repositories/schemas in the same db if not table.exists(): table.create() # test for existing repository_id s = table.select(table.c.repository_id == bindparam("repository_id")) result = engine.execute(s, repository_id=repository.id) if result.fetchone(): raise exceptions.DatabaseAlreadyControlledError # Insert data engine.execute(table.insert().values( repository_id=repository.id, repository_path=repository.path, version=int(version))) return table @classmethod def compare_model_to_db(cls, engine, model, repository): """ Compare the current model against the current database. """ if isinstance(repository, basestring): repository = Repository(repository) model = load_model(model) diff = schemadiff.getDiffOfModelAgainstDatabase( model, engine, excludeTables=[repository.version_table]) return diff @classmethod def create_model(cls, engine, repository, declarative=False): """ Dump the current database as a Python model. """ if isinstance(repository, basestring): repository = Repository(repository) diff = schemadiff.getDiffOfModelAgainstDatabase( MetaData(), engine, excludeTables=[repository.version_table] ) return genmodel.ModelGenerator(diff, engine, declarative).genBDefinition()
gpl-3.0
[ 624, 2043, 8692, 4177, 1015, 10041, 14, 199, 624, 199, 646, 984, 199, 646, 2050, 199, 199, 504, 8335, 492, 334, 3186, 12, 4996, 12, 24905, 12, 2624, 12, 4516, 12, 7225, 12, 272, 1218, 63, 3908, 9, 199, 504, 8335, 14, 3009, 492, 436, 63, 199, 504, 8335, 492, 4967, 465, 2937, 63, 3924, 199, 504, 8335, 14, 3009, 492, 5398, 635, 199, 199, 504, 12810, 492, 4967, 199, 504, 12810, 14, 26027, 492, 5385, 33, 63, 1780, 199, 504, 12810, 14, 30968, 492, 3805, 1238, 12, 4177, 3028, 199, 504, 12810, 14, 30968, 14, 8421, 492, 24426, 199, 504, 12810, 14, 30968, 14, 1974, 492, 2248, 63, 1238, 199, 504, 12810, 14, 30968, 14, 1023, 492, 5444, 5667, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 533, 8612, 1146, 6700, 8, 785, 304, 272, 408, 33, 3050, 1334, 1015, 3304, 624, 339, 347, 636, 826, 721, 277, 12, 6869, 12, 7611, 304, 267, 340, 1228, 8, 8421, 12, 7116, 304, 288, 7611, 275, 24426, 8, 8421, 9, 267, 291, 14, 3908, 275, 6869, 267, 291, 14, 8421, 275, 7611, 267, 291, 14, 2024, 275, 24905, 8, 3908, 9, 267, 291, 14, 912, 342, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 408, 16051, 2877, 32536, 701, 23737, 436, 5459, 624, 267, 372, 334, 277, 14, 8421, 365, 1163, 14, 8421, 971, 288, 436, 291, 14, 1023, 508, 1163, 14, 1023, 9, 339, 347, 2248, 8, 277, 304, 267, 408, 6200, 22284, 4177, 1015, 2256, 687, 6249, 624, 267, 307, 354, 275, 291, 14, 8421, 14, 1023, 63, 1224, 267, 862, 26, 288, 340, 440, 2688, 8, 277, 12, 283, 1224, 358, 503, 291, 14, 1224, 365, 488, 26, 490, 291, 14, 1224, 275, 6957, 8, 31383, 12, 291, 14, 2024, 12, 2599, 912, 29, 549, 9, 953, 754, 275, 291, 14, 3908, 14, 2526, 8, 277, 14, 1224, 14, 2416, 8, 355, 291, 14, 1224, 14, 67, 14, 8421, 63, 344, 508, 620, 8, 277, 14, 8421, 14, 344, 1724, 953, 666, 275, 769, 8, 1099, 2788, 16, 61, 267, 871, 26, 288, 843, 12, 3178, 12, 7070, 275, 984, 14, 2804, 63, 815, 342, 288, 746, 4967, 14, 7243, 1763, 3717, 1146, 547, 12, 3178, 855, 495, 29709, 7070, 398, 291, 14, 1023, 275, 666, 459, 1023, 418, 267, 372, 666, 339, 347, 5978, 8, 277, 304, 267, 408, 267, 5852, 1015, 3304, 687, 282, 3050, 14, 267, 408, 267, 340, 5385, 33, 63, 1780, 26, 288, 862, 26, 355, 291, 14, 1224, 14, 4824, 342, 288, 871, 2937, 63, 3924, 14, 25198, 26, 355, 746, 4967, 14, 7243, 1763, 3717, 1146, 547, 8, 495, 8, 277, 14, 1224, 430, 267, 587, 26, 288, 862, 26, 355, 291, 14, 1224, 14, 4824, 342, 288, 871, 334, 2231, 63, 3924, 14, 4657, 547, 304, 355, 746, 4967, 14, 7243, 1763, 3717, 1146, 547, 8, 495, 8, 277, 14, 1224, 430, 339, 347, 23316, 8, 277, 12, 1015, 29, 403, 304, 267, 408, 3735, 370, 7743, 409, 7143, 14, 398, 14911, 291, 14, 1023, 367, 1343, 1015, 436, 6869, 14, 354, 267, 370, 664, 3050, 536, 14, 267, 408, 267, 3050, 275, 291, 14, 3908, 14, 354, 267, 1343, 63, 422, 275, 291, 14, 1023, 267, 23316, 275, 291, 14, 8421, 14, 26027, 8, 4659, 12, 1343, 63, 422, 12, 1015, 9, 267, 372, 23316, 339, 347, 1255, 1461, 8, 277, 12, 809, 12, 1570, 12, 3650, 304, 267, 1343, 422, 275, 809, 267, 1284, 422, 275, 809, 435, 3650, 267, 327, 9338, 3050, 1015, 1471, 506, 3211, 1, 7529, 1133, 1255, 340, 29221, 1, 267, 340, 291, 14, 1023, 1137, 1343, 422, 26, 288, 746, 4967, 14, 3364, 3353, 547, 3647, 83, 365, 440, 450, 83, 2, 450, 971, 9349, 334, 277, 14, 1023, 12, 1343, 422, 430, 267, 327, 3378, 314, 1570, 267, 1570, 14, 1065, 8, 277, 14, 3908, 12, 3650, 9, 398, 327, 6162, 15, 6635, 3050, 1015, 267, 291, 14, 873, 63, 8421, 63, 1224, 8, 928, 422, 12, 1284, 422, 9, 267, 291, 14, 912, 342, 339, 347, 1678, 63, 8421, 63, 1224, 8, 277, 12, 1343, 422, 12, 1284, 422, 304, 267, 408, 4152, 1015, 63, 1224, 543, 892, 2556, 624, 267, 1678, 275, 291, 14, 1224, 14, 873, 8, 460, 2531, 277, 14, 1224, 14, 67, 14, 1023, 508, 1109, 8, 928, 422, 395, 1467, 291, 14, 1224, 14, 67, 14, 8421, 63, 344, 508, 620, 8, 277, 14, 8421, 14, 344, 1724, 267, 291, 14, 3908, 14, 2526, 8, 873, 12, 1015, 29, 442, 8, 500, 422, 430, 339, 347, 10754, 8, 277, 12, 1015, 29, 403, 304, 267, 408, 267, 4949, 4523, 334, 269, 32498, 9, 370, 282, 2013, 1015, 12, 503, 8839, 1015, 14, 267, 408, 267, 23316, 275, 291, 14, 26027, 8, 1023, 9, 267, 367, 809, 12, 1570, 315, 23316, 26, 288, 291, 14, 1065, 1461, 8, 422, 12, 1570, 12, 23316, 14, 2926, 9, 339, 347, 1678, 63, 697, 63, 504, 63, 1238, 8, 277, 12, 1402, 304, 267, 408, 267, 22520, 314, 3050, 370, 1336, 314, 5523, 402, 314, 1453, 2018, 1402, 14, 267, 408, 267, 1402, 275, 2248, 63, 1238, 8, 1238, 9, 398, 3915, 275, 4177, 3028, 14, 362, 10746, 3466, 1685, 5676, 1581, 270, 7243, 8, 288, 1402, 12, 291, 14, 3908, 12, 5760, 18845, 1524, 277, 14, 8421, 14, 1023, 63, 1224, 61, 288, 776, 267, 3805, 1238, 14, 1685, 7599, 8, 3028, 12, 277, 14, 3908, 680, 1065, 34, 18, 33, 342, 398, 291, 14, 873, 63, 8421, 63, 1224, 8, 277, 14, 1023, 12, 1109, 8, 277, 14, 8421, 14, 7410, 430, 398, 291, 14, 912, 342, 339, 768, 3744, 272, 347, 1218, 8, 1886, 12, 6869, 12, 7611, 12, 1015, 29, 403, 304, 267, 408, 267, 13966, 29200, 282, 3050, 370, 506, 1334, 282, 7611, 1159, 1015, 3304, 14, 398, 520, 3536, 26, 520, 2804, 1705, 7243, 16760, 3717, 1146, 547, 64, 267, 520, 5808, 26, 520, 533, 1705, 3717, 1146, 6700, 64, 267, 408, 267, 327, 32112, 626, 314, 1015, 327, 365, 1686, 26, 7317, 12, 3000, 12, 267, 327, 3495, 315, 20416, 267 ]
[ 2043, 8692, 4177, 1015, 10041, 14, 199, 624, 199, 646, 984, 199, 646, 2050, 199, 199, 504, 8335, 492, 334, 3186, 12, 4996, 12, 24905, 12, 2624, 12, 4516, 12, 7225, 12, 272, 1218, 63, 3908, 9, 199, 504, 8335, 14, 3009, 492, 436, 63, 199, 504, 8335, 492, 4967, 465, 2937, 63, 3924, 199, 504, 8335, 14, 3009, 492, 5398, 635, 199, 199, 504, 12810, 492, 4967, 199, 504, 12810, 14, 26027, 492, 5385, 33, 63, 1780, 199, 504, 12810, 14, 30968, 492, 3805, 1238, 12, 4177, 3028, 199, 504, 12810, 14, 30968, 14, 8421, 492, 24426, 199, 504, 12810, 14, 30968, 14, 1974, 492, 2248, 63, 1238, 199, 504, 12810, 14, 30968, 14, 1023, 492, 5444, 5667, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 533, 8612, 1146, 6700, 8, 785, 304, 272, 408, 33, 3050, 1334, 1015, 3304, 624, 339, 347, 636, 826, 721, 277, 12, 6869, 12, 7611, 304, 267, 340, 1228, 8, 8421, 12, 7116, 304, 288, 7611, 275, 24426, 8, 8421, 9, 267, 291, 14, 3908, 275, 6869, 267, 291, 14, 8421, 275, 7611, 267, 291, 14, 2024, 275, 24905, 8, 3908, 9, 267, 291, 14, 912, 342, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 408, 16051, 2877, 32536, 701, 23737, 436, 5459, 624, 267, 372, 334, 277, 14, 8421, 365, 1163, 14, 8421, 971, 288, 436, 291, 14, 1023, 508, 1163, 14, 1023, 9, 339, 347, 2248, 8, 277, 304, 267, 408, 6200, 22284, 4177, 1015, 2256, 687, 6249, 624, 267, 307, 354, 275, 291, 14, 8421, 14, 1023, 63, 1224, 267, 862, 26, 288, 340, 440, 2688, 8, 277, 12, 283, 1224, 358, 503, 291, 14, 1224, 365, 488, 26, 490, 291, 14, 1224, 275, 6957, 8, 31383, 12, 291, 14, 2024, 12, 2599, 912, 29, 549, 9, 953, 754, 275, 291, 14, 3908, 14, 2526, 8, 277, 14, 1224, 14, 2416, 8, 355, 291, 14, 1224, 14, 67, 14, 8421, 63, 344, 508, 620, 8, 277, 14, 8421, 14, 344, 1724, 953, 666, 275, 769, 8, 1099, 2788, 16, 61, 267, 871, 26, 288, 843, 12, 3178, 12, 7070, 275, 984, 14, 2804, 63, 815, 342, 288, 746, 4967, 14, 7243, 1763, 3717, 1146, 547, 12, 3178, 855, 495, 29709, 7070, 398, 291, 14, 1023, 275, 666, 459, 1023, 418, 267, 372, 666, 339, 347, 5978, 8, 277, 304, 267, 408, 267, 5852, 1015, 3304, 687, 282, 3050, 14, 267, 408, 267, 340, 5385, 33, 63, 1780, 26, 288, 862, 26, 355, 291, 14, 1224, 14, 4824, 342, 288, 871, 2937, 63, 3924, 14, 25198, 26, 355, 746, 4967, 14, 7243, 1763, 3717, 1146, 547, 8, 495, 8, 277, 14, 1224, 430, 267, 587, 26, 288, 862, 26, 355, 291, 14, 1224, 14, 4824, 342, 288, 871, 334, 2231, 63, 3924, 14, 4657, 547, 304, 355, 746, 4967, 14, 7243, 1763, 3717, 1146, 547, 8, 495, 8, 277, 14, 1224, 430, 339, 347, 23316, 8, 277, 12, 1015, 29, 403, 304, 267, 408, 3735, 370, 7743, 409, 7143, 14, 398, 14911, 291, 14, 1023, 367, 1343, 1015, 436, 6869, 14, 354, 267, 370, 664, 3050, 536, 14, 267, 408, 267, 3050, 275, 291, 14, 3908, 14, 354, 267, 1343, 63, 422, 275, 291, 14, 1023, 267, 23316, 275, 291, 14, 8421, 14, 26027, 8, 4659, 12, 1343, 63, 422, 12, 1015, 9, 267, 372, 23316, 339, 347, 1255, 1461, 8, 277, 12, 809, 12, 1570, 12, 3650, 304, 267, 1343, 422, 275, 809, 267, 1284, 422, 275, 809, 435, 3650, 267, 327, 9338, 3050, 1015, 1471, 506, 3211, 1, 7529, 1133, 1255, 340, 29221, 1, 267, 340, 291, 14, 1023, 1137, 1343, 422, 26, 288, 746, 4967, 14, 3364, 3353, 547, 3647, 83, 365, 440, 450, 83, 2, 450, 971, 9349, 334, 277, 14, 1023, 12, 1343, 422, 430, 267, 327, 3378, 314, 1570, 267, 1570, 14, 1065, 8, 277, 14, 3908, 12, 3650, 9, 398, 327, 6162, 15, 6635, 3050, 1015, 267, 291, 14, 873, 63, 8421, 63, 1224, 8, 928, 422, 12, 1284, 422, 9, 267, 291, 14, 912, 342, 339, 347, 1678, 63, 8421, 63, 1224, 8, 277, 12, 1343, 422, 12, 1284, 422, 304, 267, 408, 4152, 1015, 63, 1224, 543, 892, 2556, 624, 267, 1678, 275, 291, 14, 1224, 14, 873, 8, 460, 2531, 277, 14, 1224, 14, 67, 14, 1023, 508, 1109, 8, 928, 422, 395, 1467, 291, 14, 1224, 14, 67, 14, 8421, 63, 344, 508, 620, 8, 277, 14, 8421, 14, 344, 1724, 267, 291, 14, 3908, 14, 2526, 8, 873, 12, 1015, 29, 442, 8, 500, 422, 430, 339, 347, 10754, 8, 277, 12, 1015, 29, 403, 304, 267, 408, 267, 4949, 4523, 334, 269, 32498, 9, 370, 282, 2013, 1015, 12, 503, 8839, 1015, 14, 267, 408, 267, 23316, 275, 291, 14, 26027, 8, 1023, 9, 267, 367, 809, 12, 1570, 315, 23316, 26, 288, 291, 14, 1065, 1461, 8, 422, 12, 1570, 12, 23316, 14, 2926, 9, 339, 347, 1678, 63, 697, 63, 504, 63, 1238, 8, 277, 12, 1402, 304, 267, 408, 267, 22520, 314, 3050, 370, 1336, 314, 5523, 402, 314, 1453, 2018, 1402, 14, 267, 408, 267, 1402, 275, 2248, 63, 1238, 8, 1238, 9, 398, 3915, 275, 4177, 3028, 14, 362, 10746, 3466, 1685, 5676, 1581, 270, 7243, 8, 288, 1402, 12, 291, 14, 3908, 12, 5760, 18845, 1524, 277, 14, 8421, 14, 1023, 63, 1224, 61, 288, 776, 267, 3805, 1238, 14, 1685, 7599, 8, 3028, 12, 277, 14, 3908, 680, 1065, 34, 18, 33, 342, 398, 291, 14, 873, 63, 8421, 63, 1224, 8, 277, 14, 1023, 12, 1109, 8, 277, 14, 8421, 14, 7410, 430, 398, 291, 14, 912, 342, 339, 768, 3744, 272, 347, 1218, 8, 1886, 12, 6869, 12, 7611, 12, 1015, 29, 403, 304, 267, 408, 267, 13966, 29200, 282, 3050, 370, 506, 1334, 282, 7611, 1159, 1015, 3304, 14, 398, 520, 3536, 26, 520, 2804, 1705, 7243, 16760, 3717, 1146, 547, 64, 267, 520, 5808, 26, 520, 533, 1705, 3717, 1146, 6700, 64, 267, 408, 267, 327, 32112, 626, 314, 1015, 327, 365, 1686,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
piotrek-golda/CivilHubCopy
topics/forms.py
2
1878
# -*- coding: utf-8 -*- from django import forms from django.utils.translation import ugettext_lazy as _ from locations.models import Location from taggit.forms import TagField from places_core.forms import BootstrapBaseForm from .models import Category, Entry, Discussion class DiscussionForm(forms.ModelForm, BootstrapBaseForm): """ Custom form for Discussion - autocomplete value of location field. """ question = forms.CharField( label = _(u'Question'), widget = forms.TextInput(attrs={'class': 'form-control'}) ) intro = forms.CharField( label = _(u'Intro'), max_length = 10248, widget = forms.Textarea(attrs={'class': 'form-control'}) ) category = forms.ModelChoiceField( label = _(u'Category'), queryset = Category.objects.all(), widget = forms.Select(attrs={'class': 'form-control'}) ) status = forms.BooleanField( required = False, label = _(u'Status'), ) tags = TagField(label=_(u"Tags"), required=False) class Meta: model = Discussion fields = ('question', 'intro', 'category', 'status', 'tags', 'image',) class ReplyForm(forms.ModelForm): """ Reply to discussion topic. """ content = forms.CharField( label = _(u'Content'), required = False, max_length = 2048, widget = forms.Textarea(attrs={'class': 'form-control'}), ) discussion = forms.ModelChoiceField( required = False, queryset = Discussion.objects.all(), widget = forms.HiddenInput() ) class Meta: model = Entry fields = ('content', 'discussion',) class ConfirmDeleteForm(forms.Form): """ Delete discussion. """ confirm = forms.BooleanField( widget = forms.HiddenInput() ) class Meta: fields = ('confirm',)
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 9918, 14, 992, 492, 12625, 199, 504, 1947, 3187, 14, 3351, 492, 8053, 792, 199, 504, 9825, 63, 1018, 14, 3351, 492, 27324, 7868, 1563, 2821, 199, 504, 1275, 992, 492, 13573, 12, 11855, 12, 5289, 67, 8817, 421, 199, 533, 5289, 67, 8817, 2821, 8, 3351, 14, 15937, 12, 27324, 7868, 1563, 2821, 304, 272, 408, 272, 8388, 1824, 367, 5289, 67, 8817, 446, 2599, 4883, 574, 402, 2909, 901, 14, 272, 408, 272, 7894, 275, 4513, 14, 2183, 8, 267, 1768, 275, 12561, 85, 7, 16778, 659, 267, 3938, 275, 4513, 14, 18362, 8, 3288, 3713, 533, 356, 283, 964, 13, 2785, 3071, 272, 776, 272, 13318, 275, 4513, 14, 2183, 8, 267, 1768, 275, 12561, 85, 7, 3241, 293, 659, 267, 1390, 63, 1267, 275, 12996, 2006, 12, 267, 3938, 275, 4513, 14, 1872, 6789, 8, 3288, 3713, 533, 356, 283, 964, 13, 2785, 3071, 272, 776, 272, 4637, 275, 4513, 14, 1685, 15792, 8, 267, 1768, 275, 12561, 85, 7, 7841, 659, 267, 7594, 275, 13573, 14, 1462, 14, 452, 1062, 267, 3938, 275, 4513, 14, 5446, 8, 3288, 3713, 533, 356, 283, 964, 13, 2785, 3071, 272, 776, 272, 2004, 275, 4513, 14, 5036, 8, 267, 1415, 275, 756, 12, 267, 1768, 275, 12561, 85, 7, 3694, 659, 272, 776, 272, 3762, 275, 8053, 792, 8, 1302, 17441, 85, 2, 9440, 1288, 1415, 29, 797, 9, 339, 1021, 6288, 26, 267, 1402, 275, 5289, 67, 8817, 267, 1504, 275, 661, 4790, 297, 283, 18206, 297, 283, 3710, 297, 283, 1205, 297, 283, 2969, 297, 283, 1569, 9538, 421, 199, 533, 16000, 590, 2821, 8, 3351, 14, 15937, 304, 272, 408, 272, 16000, 590, 370, 16582, 7482, 14, 272, 408, 272, 1564, 275, 4513, 14, 2183, 8, 267, 1768, 275, 12561, 85, 7, 2714, 659, 267, 1415, 275, 756, 12, 267, 1390, 63, 1267, 275, 18427, 12, 267, 3938, 275, 4513, 14, 1872, 6789, 8, 3288, 3713, 533, 356, 283, 964, 13, 2785, 1604, 272, 776, 272, 16582, 275, 4513, 14, 1685, 15792, 8, 267, 1415, 275, 756, 12, 267, 7594, 275, 5289, 67, 8817, 14, 1462, 14, 452, 1062, 267, 3938, 275, 4513, 14, 25419, 342, 272, 776, 339, 1021, 6288, 26, 267, 1402, 275, 11855, 267, 1504, 275, 661, 1317, 297, 283, 14410, 9538, 421, 199, 533, 32112, 5392, 2821, 8, 3351, 14, 2821, 304, 272, 408, 272, 8496, 16582, 14, 272, 408, 272, 12679, 275, 4513, 14, 5036, 8, 267, 3938, 275, 4513, 14, 25419, 342, 272, 776, 339, 1021, 6288, 26, 267, 1504, 275, 661, 9548, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 9918, 14, 992, 492, 12625, 199, 504, 1947, 3187, 14, 3351, 492, 8053, 792, 199, 504, 9825, 63, 1018, 14, 3351, 492, 27324, 7868, 1563, 2821, 199, 504, 1275, 992, 492, 13573, 12, 11855, 12, 5289, 67, 8817, 421, 199, 533, 5289, 67, 8817, 2821, 8, 3351, 14, 15937, 12, 27324, 7868, 1563, 2821, 304, 272, 408, 272, 8388, 1824, 367, 5289, 67, 8817, 446, 2599, 4883, 574, 402, 2909, 901, 14, 272, 408, 272, 7894, 275, 4513, 14, 2183, 8, 267, 1768, 275, 12561, 85, 7, 16778, 659, 267, 3938, 275, 4513, 14, 18362, 8, 3288, 3713, 533, 356, 283, 964, 13, 2785, 3071, 272, 776, 272, 13318, 275, 4513, 14, 2183, 8, 267, 1768, 275, 12561, 85, 7, 3241, 293, 659, 267, 1390, 63, 1267, 275, 12996, 2006, 12, 267, 3938, 275, 4513, 14, 1872, 6789, 8, 3288, 3713, 533, 356, 283, 964, 13, 2785, 3071, 272, 776, 272, 4637, 275, 4513, 14, 1685, 15792, 8, 267, 1768, 275, 12561, 85, 7, 7841, 659, 267, 7594, 275, 13573, 14, 1462, 14, 452, 1062, 267, 3938, 275, 4513, 14, 5446, 8, 3288, 3713, 533, 356, 283, 964, 13, 2785, 3071, 272, 776, 272, 2004, 275, 4513, 14, 5036, 8, 267, 1415, 275, 756, 12, 267, 1768, 275, 12561, 85, 7, 3694, 659, 272, 776, 272, 3762, 275, 8053, 792, 8, 1302, 17441, 85, 2, 9440, 1288, 1415, 29, 797, 9, 339, 1021, 6288, 26, 267, 1402, 275, 5289, 67, 8817, 267, 1504, 275, 661, 4790, 297, 283, 18206, 297, 283, 3710, 297, 283, 1205, 297, 283, 2969, 297, 283, 1569, 9538, 421, 199, 533, 16000, 590, 2821, 8, 3351, 14, 15937, 304, 272, 408, 272, 16000, 590, 370, 16582, 7482, 14, 272, 408, 272, 1564, 275, 4513, 14, 2183, 8, 267, 1768, 275, 12561, 85, 7, 2714, 659, 267, 1415, 275, 756, 12, 267, 1390, 63, 1267, 275, 18427, 12, 267, 3938, 275, 4513, 14, 1872, 6789, 8, 3288, 3713, 533, 356, 283, 964, 13, 2785, 1604, 272, 776, 272, 16582, 275, 4513, 14, 1685, 15792, 8, 267, 1415, 275, 756, 12, 267, 7594, 275, 5289, 67, 8817, 14, 1462, 14, 452, 1062, 267, 3938, 275, 4513, 14, 25419, 342, 272, 776, 339, 1021, 6288, 26, 267, 1402, 275, 11855, 267, 1504, 275, 661, 1317, 297, 283, 14410, 9538, 421, 199, 533, 32112, 5392, 2821, 8, 3351, 14, 2821, 304, 272, 408, 272, 8496, 16582, 14, 272, 408, 272, 12679, 275, 4513, 14, 5036, 8, 267, 3938, 275, 4513, 14, 25419, 342, 272, 776, 339, 1021, 6288, 26, 267, 1504, 275, 661, 9548, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
rthallisey/kolla-kubernetes-personal
kolla/ansible/library/merge_configs.py
8
1313
#!/usr/bin/python # Copyright 2015 Sam Yaple # # 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. DOCUMENTATION = ''' --- module: merge_configs short_description: Merge ini-style configs description: - ConfigParser is used to merge several ini-style configs into one options: dest: description: - The destination file name required: True type: str sources: description: - A list of files on the destination node to merge together default: None required: True type: str author: Sam Yaple ''' EXAMPLES = ''' Merge multiple configs: - hosts: database tasks: - name: Merge configs merge_configs: sources: - "/tmp/config_1.cnf" - "/tmp/config_2.cnf" - "/tmp/config_3.cnf" dest: - "/etc/mysql/my.cnf" '''
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 3, 1898, 6900, 428, 455, 1488, 439, 274, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 5389, 63, 7532, 199, 3612, 63, 1802, 26, 14076, 20364, 13, 2487, 11585, 199, 1802, 26, 1362, 446, 14196, 365, 1202, 370, 5389, 9978, 20364, 13, 2487, 11585, 1901, 1373, 199, 1419, 26, 523, 2053, 26, 272, 1369, 26, 489, 446, 710, 5724, 570, 536, 272, 1415, 26, 715, 272, 730, 26, 620, 523, 5274, 26, 272, 1369, 26, 489, 446, 437, 769, 402, 1584, 641, 314, 5724, 1031, 370, 5389, 10451, 272, 849, 26, 488, 272, 1415, 26, 715, 272, 730, 26, 620, 199, 2502, 26, 428, 455, 1488, 439, 274, 199, 2344, 199, 199, 8918, 275, 1449, 199, 11359, 3663, 11585, 26, 199, 199, 13, 7057, 26, 3050, 523, 6527, 26, 272, 446, 536, 26, 14076, 11585, 489, 5389, 63, 7532, 26, 267, 5274, 26, 881, 446, 3286, 2791, 15, 888, 63, 17, 14, 23600, 2, 881, 446, 3286, 2791, 15, 888, 63, 18, 14, 23600, 2, 881, 446, 3286, 2791, 15, 888, 63, 19, 14, 23600, 2, 267, 2053, 26, 881, 446, 3286, 6839, 15, 8644, 15, 1662, 14, 23600, 2, 199, 2344, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 3, 1898, 6900, 428, 455, 1488, 439, 274, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 5389, 63, 7532, 199, 3612, 63, 1802, 26, 14076, 20364, 13, 2487, 11585, 199, 1802, 26, 1362, 446, 14196, 365, 1202, 370, 5389, 9978, 20364, 13, 2487, 11585, 1901, 1373, 199, 1419, 26, 523, 2053, 26, 272, 1369, 26, 489, 446, 710, 5724, 570, 536, 272, 1415, 26, 715, 272, 730, 26, 620, 523, 5274, 26, 272, 1369, 26, 489, 446, 437, 769, 402, 1584, 641, 314, 5724, 1031, 370, 5389, 10451, 272, 849, 26, 488, 272, 1415, 26, 715, 272, 730, 26, 620, 199, 2502, 26, 428, 455, 1488, 439, 274, 199, 2344, 199, 199, 8918, 275, 1449, 199, 11359, 3663, 11585, 26, 199, 199, 13, 7057, 26, 3050, 523, 6527, 26, 272, 446, 536, 26, 14076, 11585, 489, 5389, 63, 7532, 26, 267, 5274, 26, 881, 446, 3286, 2791, 15, 888, 63, 17, 14, 23600, 2, 881, 446, 3286, 2791, 15, 888, 63, 18, 14, 23600, 2, 881, 446, 3286, 2791, 15, 888, 63, 19, 14, 23600, 2, 267, 2053, 26, 881, 446, 3286, 6839, 15, 8644, 15, 1662, 14, 23600, 2, 199, 2344, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
smaffulli/libcloud
libcloud/test/compute/test_exoscale.py
64
1147
# 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 sys from libcloud.compute.drivers.exoscale import ExoscaleNodeDriver from libcloud.test.compute.test_cloudstack import CloudStackCommonTestCase from libcloud.test import unittest class ExoscaleNodeDriverTestCase(CloudStackCommonTestCase, unittest.TestCase): driver_klass = ExoscaleNodeDriver if __name__ == '__main__': sys.exit(unittest.main())
apache-2.0
[ 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 984, 199, 199, 504, 17069, 14, 3357, 14, 13337, 14, 476, 79, 3467, 492, 1316, 79, 3467, 1716, 6158, 199, 504, 17069, 14, 396, 14, 3357, 14, 396, 63, 4091, 2340, 492, 8142, 4851, 7844, 1746, 199, 199, 504, 17069, 14, 396, 492, 2882, 421, 199, 533, 1316, 79, 3467, 1716, 6158, 1746, 8, 24404, 7844, 1746, 12, 2882, 14, 1746, 304, 272, 5253, 63, 11645, 275, 1316, 79, 3467, 1716, 6158, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 984, 14, 2224, 8, 2796, 14, 973, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 984, 199, 199, 504, 17069, 14, 3357, 14, 13337, 14, 476, 79, 3467, 492, 1316, 79, 3467, 1716, 6158, 199, 504, 17069, 14, 396, 14, 3357, 14, 396, 63, 4091, 2340, 492, 8142, 4851, 7844, 1746, 199, 199, 504, 17069, 14, 396, 492, 2882, 421, 199, 533, 1316, 79, 3467, 1716, 6158, 1746, 8, 24404, 7844, 1746, 12, 2882, 14, 1746, 304, 272, 5253, 63, 11645, 275, 1316, 79, 3467, 1716, 6158, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 984, 14, 2224, 8, 2796, 14, 973, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
offlinehacker/pyfilesystem
fs/expose/http.py
14
5609
__all__ = ["serve_fs"] import SimpleHTTPServer import SocketServer from fs.path import pathjoin, dirname from fs.errors import FSError from time import mktime from cStringIO import StringIO import cgi import urllib import posixpath import time import threading import socket def _datetime_to_epoch(d): return mktime(d.timetuple()) class FSHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): """A hacked together version of SimpleHTTPRequestHandler""" def __init__(self, fs, request, client_address, server): self._fs = fs SimpleHTTPServer.SimpleHTTPRequestHandler.__init__(self, request, client_address, server) def do_GET(self): """Serve a GET request.""" f = None try: f = self.send_head() if f: try: self.copyfile(f, self.wfile) except socket.error: pass finally: if f is not None: f.close() def send_head(self): """Common code for GET and HEAD commands. This sends the response code and MIME headers. Return value is either a file object (which has to be copied to the outputfile by the caller unless the command was HEAD, and must be closed by the caller under all circumstances), or None, in which case the caller has nothing further to do. """ path = self.translate_path(self.path) f = None if self._fs.isdir(path): if not self.path.endswith('/'): # redirect browser - doing basically what apache does self.send_response(301) self.send_header("Location", self.path + "/") self.end_headers() return None for index in ("index.html", "index.htm"): index = pathjoin(path, index) if self._fs.exists(index): path = index break else: return self.list_directory(path) ctype = self.guess_type(path) try: info = self._fs.getinfo(path) f = self._fs.open(path, 'r') except FSError, e: self.send_error(404, str(e)) return None self.send_response(200) self.send_header("Content-type", ctype) self.send_header("Content-Length", str(info['size'])) if 'modified_time' in info: self.send_header("Last-Modified", self.date_time_string(_datetime_to_epoch(info['modified_time']))) self.end_headers() return f def list_directory(self, path): """Helper to produce a directory listing (absent index.html). Return value is either a file object, or None (indicating an error). In either case, the headers are sent, making the interface the same as for send_head(). """ try: dir_paths = self._fs.listdir(path, dirs_only=True) file_paths = self._fs.listdir(path, files_only=True) except FSError: self.send_error(404, "No permission to list directory") return None paths = [p+'/' for p in sorted(dir_paths, key=lambda p:p.lower())] + sorted(file_paths, key=lambda p:p.lower()) #list.sort(key=lambda a: a.lower()) f = StringIO() displaypath = cgi.escape(urllib.unquote(self.path)) f.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">') f.write("<html>\n<title>Directory listing for %s</title>\n" % displaypath) f.write("<body>\n<h2>Directory listing for %s</h2>\n" % displaypath) f.write("<hr>\n<ul>\n") parent = dirname(path) if path != parent: f.write('<li><a href="%s">../</a></li>' % urllib.quote(parent.rstrip('/') + '/')) for path in paths: f.write('<li><a href="%s">%s</a>\n' % (urllib.quote(path), cgi.escape(path))) f.write("</ul>\n<hr>\n</body>\n</html>\n") length = f.tell() f.seek(0) self.send_response(200) self.send_header("Content-type", "text/html") self.send_header("Content-Length", str(length)) self.end_headers() return f def translate_path(self, path): # abandon query parameters path = path.split('?',1)[0] path = path.split('#',1)[0] path = posixpath.normpath(urllib.unquote(path)) return path def serve_fs(fs, address='', port=8000): """Serve an FS instance over http :param fs: an FS object :param address: IP address to serve on :param port: port number """ def Handler(request, client_address, server): return FSHTTPRequestHandler(fs, request, client_address, server) #class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): # pass httpd = SocketServer.TCPServer((address, port), Handler, bind_and_activate=False) #httpd = ThreadedTCPServer((address, port), Handler, bind_and_activate=False) httpd.allow_reuse_address = True httpd.server_bind() httpd.server_activate() server_thread = threading.Thread(target=httpd.serve_forever) server_thread.start() try: while True: time.sleep(0.1) except (KeyboardInterrupt, SystemExit): httpd.shutdown() if __name__ == "__main__": from fs.osfs import OSFS serve_fs(OSFS('~/'))
bsd-3-clause
[ 363, 452, 363, 275, 2097, 4909, 63, 2319, 937, 199, 199, 646, 5870, 14938, 199, 646, 17766, 3120, 199, 504, 7449, 14, 515, 492, 931, 904, 12, 9017, 199, 504, 7449, 14, 2550, 492, 27500, 547, 199, 504, 900, 492, 9199, 521, 199, 504, 15073, 492, 5228, 199, 646, 16004, 199, 646, 4011, 199, 646, 15454, 199, 646, 900, 199, 646, 5796, 199, 646, 2838, 199, 199, 318, 485, 2083, 63, 475, 63, 7367, 8, 68, 304, 272, 372, 9199, 521, 8, 68, 14, 22309, 1012, 199, 199, 533, 27500, 23518, 8, 3184, 14938, 14, 3184, 23518, 304, 2286, 408, 33, 11176, 379, 10451, 1015, 402, 5870, 23518, 624, 2286, 347, 636, 826, 721, 277, 12, 7449, 12, 1056, 12, 1890, 63, 1562, 12, 1654, 304, 267, 291, 423, 2319, 275, 7449, 267, 5870, 14938, 14, 3184, 23518, 855, 826, 721, 277, 12, 1056, 12, 1890, 63, 1562, 12, 1654, 9, 2286, 347, 886, 63, 2970, 8, 277, 304, 267, 408, 1505, 432, 282, 9576, 1056, 1041, 27439, 289, 275, 488, 267, 862, 26, 288, 289, 275, 291, 14, 2254, 63, 2993, 342, 288, 340, 289, 26, 355, 862, 26, 490, 291, 14, 21997, 8, 70, 12, 291, 14, 18076, 9, 355, 871, 2838, 14, 705, 26, 490, 986, 463, 267, 3753, 26, 288, 340, 289, 365, 440, 488, 26, 355, 289, 14, 1600, 342, 4519, 339, 347, 3222, 63, 2993, 8, 277, 304, 267, 408, 7844, 1233, 367, 9576, 436, 13053, 3718, 14, 398, 961, 16178, 314, 1177, 1233, 436, 14735, 2323, 14, 398, 1432, 574, 365, 1902, 282, 570, 909, 334, 6777, 965, 370, 506, 8876, 267, 370, 314, 32513, 701, 314, 8025, 7444, 314, 1414, 1990, 13053, 12, 267, 436, 1471, 506, 6876, 701, 314, 8025, 1334, 1006, 27027, 611, 83, 395, 503, 267, 488, 12, 315, 1314, 1930, 314, 8025, 965, 6548, 9848, 370, 886, 14, 398, 408, 267, 931, 275, 291, 14, 5275, 63, 515, 8, 277, 14, 515, 9, 267, 289, 275, 488, 267, 340, 291, 423, 2319, 14, 6027, 8, 515, 304, 288, 340, 440, 291, 14, 515, 14, 4130, 18265, 355, 327, 4660, 7042, 446, 9689, 26014, 4052, 17098, 1630, 355, 291, 14, 2254, 63, 1310, 8, 8507, 9, 355, 291, 14, 2254, 63, 1291, 480, 6592, 401, 291, 14, 515, 435, 3286, 531, 355, 291, 14, 500, 63, 2139, 342, 355, 372, 488, 288, 367, 1478, 315, 1689, 1080, 14, 1360, 401, 298, 1080, 14, 15575, 2349, 355, 1478, 275, 931, 904, 8, 515, 12, 1478, 9, 355, 340, 291, 423, 2319, 14, 2444, 8, 1080, 304, 490, 931, 275, 1478, 490, 2059, 288, 587, 26, 355, 372, 291, 14, 513, 63, 3619, 8, 515, 9, 267, 16360, 275, 291, 14, 11636, 63, 466, 8, 515, 9, 18418, 862, 26, 288, 2256, 275, 291, 423, 2319, 14, 32286, 8, 515, 9, 288, 289, 275, 291, 423, 2319, 14, 1490, 8, 515, 12, 283, 82, 358, 267, 871, 27500, 547, 12, 325, 26, 288, 291, 14, 2254, 63, 705, 8, 5188, 12, 620, 8, 69, 430, 288, 372, 488, 267, 291, 14, 2254, 63, 1310, 8, 1840, 9, 18418, 291, 14, 2254, 63, 1291, 480, 2714, 13, 466, 401, 16360, 9, 18418, 291, 14, 2254, 63, 1291, 480, 2714, 13, 4625, 401, 620, 8, 815, 459, 890, 5156, 267, 340, 283, 5540, 63, 521, 7, 315, 2256, 26, 288, 291, 14, 2254, 63, 1291, 480, 6090, 13, 11911, 401, 291, 14, 602, 63, 521, 63, 875, 1547, 2083, 63, 475, 63, 7367, 8, 815, 459, 5540, 63, 521, 26991, 267, 291, 14, 500, 63, 2139, 342, 267, 372, 289, 2378, 347, 769, 63, 3619, 8, 277, 12, 931, 304, 267, 408, 4433, 370, 7389, 282, 2082, 13778, 334, 5575, 1478, 14, 1360, 680, 398, 1432, 574, 365, 1902, 282, 570, 909, 12, 503, 488, 334, 13363, 1958, 376, 267, 1125, 680, 221, 1010, 1902, 1930, 12, 314, 2323, 787, 4847, 12, 10663, 314, 267, 3217, 314, 2011, 465, 367, 3222, 63, 2993, 1252, 398, 408, 267, 862, 26, 288, 2935, 63, 3771, 275, 291, 423, 2319, 14, 7374, 8, 515, 12, 7606, 63, 2118, 29, 549, 9, 288, 570, 63, 3771, 275, 291, 423, 2319, 14, 7374, 8, 515, 12, 1584, 63, 2118, 29, 549, 9, 267, 871, 27500, 547, 26, 288, 291, 14, 2254, 63, 705, 8, 5188, 12, 298, 1944, 4983, 370, 769, 2082, 531, 288, 372, 488, 267, 3792, 275, 359, 80, 4786, 4805, 367, 299, 315, 3355, 8, 694, 63, 3771, 12, 790, 29, 2734, 299, 26, 80, 14, 2325, 24821, 435, 3355, 8, 493, 63, 3771, 12, 790, 29, 2734, 299, 26, 80, 14, 2325, 1012, 267, 327, 513, 14, 3191, 8, 498, 29, 2734, 282, 26, 282, 14, 2325, 1012, 267, 289, 275, 5228, 342, 267, 2929, 515, 275, 16004, 14, 3765, 8, 4078, 14, 12240, 8, 277, 14, 515, 430, 267, 289, 14, 952, 4827, 1, 16556, 3517, 21755, 21486, 55, 19, 35, 501, 21156, 4163, 650, 14, 18, 21789, 501, 742, 1743, 358, 267, 289, 14, 952, 6757, 1360, 3072, 78, 28, 1213, 30, 6231, 13778, 367, 450, 83, 1108, 1213, 3072, 78, 2, 450, 2929, 515, 9, 267, 289, 14, 952, 6757, 2030, 3072, 78, 28, 72, 18, 30, 6231, 13778, 367, 450, 83, 1108, 72, 18, 3072, 78, 2, 450, 2929, 515, 9, 267, 289, 14, 952, 6757, 6271, 3072, 78, 28, 348, 3072, 78, 531, 2728, 1676, 275, 9017, 8, 515, 9, 267, 340, 931, 1137, 1676, 26, 288, 289, 14, 952, 4827, 317, 2535, 65, 4369, 5961, 83, 1743, 5093, 1108, 65, 2957, 317, 3524, 450, 4011, 14, 3513, 8, 1708, 14, 6735, 7825, 435, 1994, 1333, 2728, 367, 931, 315, 3792, 26, 288, 289, 14, 952, 4827, 317, 2535, 65, 4369, 5961, 83, 14423, 83, 1108, 65, 3072, 78, 7, 490, 450, 334, 4078, 14, 3513, 8, 515, 395, 16004, 14, 3765, 8, 515, 1724, 267, 289, 14, 952, 23790, 348, 3072, 78, 28, 6271, 3072, 78, 1108, 2030, 3072, 78, 1108, 1360, 3072, 78, 531, 267, 2582, 275, 289, 14, 9974, 342, 267, 289, 14, 5507, 8, 16, 9, 267, 291, 14, 2254, 63, 1310, 8, 1840, 9, 267, 291, 14, 2254 ]
[ 452, 363, 275, 2097, 4909, 63, 2319, 937, 199, 199, 646, 5870, 14938, 199, 646, 17766, 3120, 199, 504, 7449, 14, 515, 492, 931, 904, 12, 9017, 199, 504, 7449, 14, 2550, 492, 27500, 547, 199, 504, 900, 492, 9199, 521, 199, 504, 15073, 492, 5228, 199, 646, 16004, 199, 646, 4011, 199, 646, 15454, 199, 646, 900, 199, 646, 5796, 199, 646, 2838, 199, 199, 318, 485, 2083, 63, 475, 63, 7367, 8, 68, 304, 272, 372, 9199, 521, 8, 68, 14, 22309, 1012, 199, 199, 533, 27500, 23518, 8, 3184, 14938, 14, 3184, 23518, 304, 2286, 408, 33, 11176, 379, 10451, 1015, 402, 5870, 23518, 624, 2286, 347, 636, 826, 721, 277, 12, 7449, 12, 1056, 12, 1890, 63, 1562, 12, 1654, 304, 267, 291, 423, 2319, 275, 7449, 267, 5870, 14938, 14, 3184, 23518, 855, 826, 721, 277, 12, 1056, 12, 1890, 63, 1562, 12, 1654, 9, 2286, 347, 886, 63, 2970, 8, 277, 304, 267, 408, 1505, 432, 282, 9576, 1056, 1041, 27439, 289, 275, 488, 267, 862, 26, 288, 289, 275, 291, 14, 2254, 63, 2993, 342, 288, 340, 289, 26, 355, 862, 26, 490, 291, 14, 21997, 8, 70, 12, 291, 14, 18076, 9, 355, 871, 2838, 14, 705, 26, 490, 986, 463, 267, 3753, 26, 288, 340, 289, 365, 440, 488, 26, 355, 289, 14, 1600, 342, 4519, 339, 347, 3222, 63, 2993, 8, 277, 304, 267, 408, 7844, 1233, 367, 9576, 436, 13053, 3718, 14, 398, 961, 16178, 314, 1177, 1233, 436, 14735, 2323, 14, 398, 1432, 574, 365, 1902, 282, 570, 909, 334, 6777, 965, 370, 506, 8876, 267, 370, 314, 32513, 701, 314, 8025, 7444, 314, 1414, 1990, 13053, 12, 267, 436, 1471, 506, 6876, 701, 314, 8025, 1334, 1006, 27027, 611, 83, 395, 503, 267, 488, 12, 315, 1314, 1930, 314, 8025, 965, 6548, 9848, 370, 886, 14, 398, 408, 267, 931, 275, 291, 14, 5275, 63, 515, 8, 277, 14, 515, 9, 267, 289, 275, 488, 267, 340, 291, 423, 2319, 14, 6027, 8, 515, 304, 288, 340, 440, 291, 14, 515, 14, 4130, 18265, 355, 327, 4660, 7042, 446, 9689, 26014, 4052, 17098, 1630, 355, 291, 14, 2254, 63, 1310, 8, 8507, 9, 355, 291, 14, 2254, 63, 1291, 480, 6592, 401, 291, 14, 515, 435, 3286, 531, 355, 291, 14, 500, 63, 2139, 342, 355, 372, 488, 288, 367, 1478, 315, 1689, 1080, 14, 1360, 401, 298, 1080, 14, 15575, 2349, 355, 1478, 275, 931, 904, 8, 515, 12, 1478, 9, 355, 340, 291, 423, 2319, 14, 2444, 8, 1080, 304, 490, 931, 275, 1478, 490, 2059, 288, 587, 26, 355, 372, 291, 14, 513, 63, 3619, 8, 515, 9, 267, 16360, 275, 291, 14, 11636, 63, 466, 8, 515, 9, 18418, 862, 26, 288, 2256, 275, 291, 423, 2319, 14, 32286, 8, 515, 9, 288, 289, 275, 291, 423, 2319, 14, 1490, 8, 515, 12, 283, 82, 358, 267, 871, 27500, 547, 12, 325, 26, 288, 291, 14, 2254, 63, 705, 8, 5188, 12, 620, 8, 69, 430, 288, 372, 488, 267, 291, 14, 2254, 63, 1310, 8, 1840, 9, 18418, 291, 14, 2254, 63, 1291, 480, 2714, 13, 466, 401, 16360, 9, 18418, 291, 14, 2254, 63, 1291, 480, 2714, 13, 4625, 401, 620, 8, 815, 459, 890, 5156, 267, 340, 283, 5540, 63, 521, 7, 315, 2256, 26, 288, 291, 14, 2254, 63, 1291, 480, 6090, 13, 11911, 401, 291, 14, 602, 63, 521, 63, 875, 1547, 2083, 63, 475, 63, 7367, 8, 815, 459, 5540, 63, 521, 26991, 267, 291, 14, 500, 63, 2139, 342, 267, 372, 289, 2378, 347, 769, 63, 3619, 8, 277, 12, 931, 304, 267, 408, 4433, 370, 7389, 282, 2082, 13778, 334, 5575, 1478, 14, 1360, 680, 398, 1432, 574, 365, 1902, 282, 570, 909, 12, 503, 488, 334, 13363, 1958, 376, 267, 1125, 680, 221, 1010, 1902, 1930, 12, 314, 2323, 787, 4847, 12, 10663, 314, 267, 3217, 314, 2011, 465, 367, 3222, 63, 2993, 1252, 398, 408, 267, 862, 26, 288, 2935, 63, 3771, 275, 291, 423, 2319, 14, 7374, 8, 515, 12, 7606, 63, 2118, 29, 549, 9, 288, 570, 63, 3771, 275, 291, 423, 2319, 14, 7374, 8, 515, 12, 1584, 63, 2118, 29, 549, 9, 267, 871, 27500, 547, 26, 288, 291, 14, 2254, 63, 705, 8, 5188, 12, 298, 1944, 4983, 370, 769, 2082, 531, 288, 372, 488, 267, 3792, 275, 359, 80, 4786, 4805, 367, 299, 315, 3355, 8, 694, 63, 3771, 12, 790, 29, 2734, 299, 26, 80, 14, 2325, 24821, 435, 3355, 8, 493, 63, 3771, 12, 790, 29, 2734, 299, 26, 80, 14, 2325, 1012, 267, 327, 513, 14, 3191, 8, 498, 29, 2734, 282, 26, 282, 14, 2325, 1012, 267, 289, 275, 5228, 342, 267, 2929, 515, 275, 16004, 14, 3765, 8, 4078, 14, 12240, 8, 277, 14, 515, 430, 267, 289, 14, 952, 4827, 1, 16556, 3517, 21755, 21486, 55, 19, 35, 501, 21156, 4163, 650, 14, 18, 21789, 501, 742, 1743, 358, 267, 289, 14, 952, 6757, 1360, 3072, 78, 28, 1213, 30, 6231, 13778, 367, 450, 83, 1108, 1213, 3072, 78, 2, 450, 2929, 515, 9, 267, 289, 14, 952, 6757, 2030, 3072, 78, 28, 72, 18, 30, 6231, 13778, 367, 450, 83, 1108, 72, 18, 3072, 78, 2, 450, 2929, 515, 9, 267, 289, 14, 952, 6757, 6271, 3072, 78, 28, 348, 3072, 78, 531, 2728, 1676, 275, 9017, 8, 515, 9, 267, 340, 931, 1137, 1676, 26, 288, 289, 14, 952, 4827, 317, 2535, 65, 4369, 5961, 83, 1743, 5093, 1108, 65, 2957, 317, 3524, 450, 4011, 14, 3513, 8, 1708, 14, 6735, 7825, 435, 1994, 1333, 2728, 367, 931, 315, 3792, 26, 288, 289, 14, 952, 4827, 317, 2535, 65, 4369, 5961, 83, 14423, 83, 1108, 65, 3072, 78, 7, 490, 450, 334, 4078, 14, 3513, 8, 515, 395, 16004, 14, 3765, 8, 515, 1724, 267, 289, 14, 952, 23790, 348, 3072, 78, 28, 6271, 3072, 78, 1108, 2030, 3072, 78, 1108, 1360, 3072, 78, 531, 267, 2582, 275, 289, 14, 9974, 342, 267, 289, 14, 5507, 8, 16, 9, 267, 291, 14, 2254, 63, 1310, 8, 1840, 9, 267, 291, 14, 2254, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bsmrstu-warriors/Moytri--The-Drone-Aider
Lib/pdb.py
119
46016
#! /usr/bin/env python """A Python debugger.""" # (See pdb.doc for documentation.) import sys import linecache import cmd import bdb from repr import Repr import os import re import pprint import traceback class Restart(Exception): """Causes a debugger to be restarted for the debugged python program.""" pass # Create a custom safe Repr instance and increase its maxstring. # The default of 30 truncates error messages too easily. _repr = Repr() _repr.maxstring = 200 _saferepr = _repr.repr __all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace", "post_mortem", "help"] def find_function(funcname, filename): cre = re.compile(r'def\s+%s\s*[(]' % re.escape(funcname)) try: fp = open(filename) except IOError: return None # consumer of this info expects the first line to be 1 lineno = 1 answer = None while 1: line = fp.readline() if line == '': break if cre.match(line): answer = funcname, filename, lineno break lineno = lineno + 1 fp.close() return answer # Interaction prompt line will separate file and call info from code # text using value of line_prefix string. A newline and arrow may # be to your liking. You can set it once pdb is imported using the # command "pdb.line_prefix = '\n% '". # line_prefix = ': ' # Use this to get the old situation back line_prefix = '\n-> ' # Probably a better default class Pdb(bdb.Bdb, cmd.Cmd): def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None): bdb.Bdb.__init__(self, skip=skip) cmd.Cmd.__init__(self, completekey, stdin, stdout) if stdout: self.use_rawinput = 0 self.prompt = '(Pdb) ' self.aliases = {} self.mainpyfile = '' self._wait_for_mainpyfile = 0 # Try to load readline if it exists try: import readline except ImportError: pass # Read $HOME/.pdbrc and ./.pdbrc self.rcLines = [] if 'HOME' in os.environ: envHome = os.environ['HOME'] try: rcFile = open(os.path.join(envHome, ".pdbrc")) except IOError: pass else: for line in rcFile.readlines(): self.rcLines.append(line) rcFile.close() try: rcFile = open(".pdbrc") except IOError: pass else: for line in rcFile.readlines(): self.rcLines.append(line) rcFile.close() self.commands = {} # associates a command list to breakpoint numbers self.commands_doprompt = {} # for each bp num, tells if the prompt # must be disp. after execing the cmd list self.commands_silent = {} # for each bp num, tells if the stack trace # must be disp. after execing the cmd list self.commands_defining = False # True while in the process of defining # a command list self.commands_bnum = None # The breakpoint number for which we are # defining a list def reset(self): bdb.Bdb.reset(self) self.forget() def forget(self): self.lineno = None self.stack = [] self.curindex = 0 self.curframe = None def setup(self, f, t): self.forget() self.stack, self.curindex = self.get_stack(f, t) self.curframe = self.stack[self.curindex][0] # The f_locals dictionary is updated from the actual frame # locals whenever the .f_locals accessor is called, so we # cache it here to ensure that modifications are not overwritten. self.curframe_locals = self.curframe.f_locals self.execRcLines() # Can be executed earlier than 'setup' if desired def execRcLines(self): if self.rcLines: # Make local copy because of recursion rcLines = self.rcLines # executed only once self.rcLines = [] for line in rcLines: line = line[:-1] if len(line) > 0 and line[0] != '#': self.onecmd(line) # Override Bdb methods def user_call(self, frame, argument_list): """This method is called when there is the remote possibility that we ever need to stop in this function.""" if self._wait_for_mainpyfile: return if self.stop_here(frame): print >>self.stdout, '--Call--' self.interaction(frame, None) def user_line(self, frame): """This function is called when we stop or break at this line.""" if self._wait_for_mainpyfile: if (self.mainpyfile != self.canonic(frame.f_code.co_filename) or frame.f_lineno<= 0): return self._wait_for_mainpyfile = 0 if self.bp_commands(frame): self.interaction(frame, None) def bp_commands(self,frame): """Call every command that was set for the current active breakpoint (if there is one). Returns True if the normal interaction function must be called, False otherwise.""" # self.currentbp is set in bdb in Bdb.break_here if a breakpoint was hit if getattr(self, "currentbp", False) and \ self.currentbp in self.commands: currentbp = self.currentbp self.currentbp = 0 lastcmd_back = self.lastcmd self.setup(frame, None) for line in self.commands[currentbp]: self.onecmd(line) self.lastcmd = lastcmd_back if not self.commands_silent[currentbp]: self.print_stack_entry(self.stack[self.curindex]) if self.commands_doprompt[currentbp]: self.cmdloop() self.forget() return return 1 def user_return(self, frame, return_value): """This function is called when a return trap is set here.""" if self._wait_for_mainpyfile: return frame.f_locals['__return__'] = return_value print >>self.stdout, '--Return--' self.interaction(frame, None) def user_exception(self, frame, exc_info): """This function is called if an exception occurs, but only if we are to stop at or just below this level.""" if self._wait_for_mainpyfile: return exc_type, exc_value, exc_traceback = exc_info frame.f_locals['__exception__'] = exc_type, exc_value if type(exc_type) == type(''): exc_type_name = exc_type else: exc_type_name = exc_type.__name__ print >>self.stdout, exc_type_name + ':', _saferepr(exc_value) self.interaction(frame, exc_traceback) # General interaction function def interaction(self, frame, traceback): self.setup(frame, traceback) self.print_stack_entry(self.stack[self.curindex]) self.cmdloop() self.forget() def displayhook(self, obj): """Custom displayhook for the exec in default(), which prevents assignment of the _ variable in the builtins. """ # reproduce the behavior of the standard displayhook, not printing None if obj is not None: print repr(obj) def default(self, line): if line[:1] == '!': line = line[1:] locals = self.curframe_locals globals = self.curframe.f_globals try: code = compile(line + '\n', '<stdin>', 'single') save_stdout = sys.stdout save_stdin = sys.stdin save_displayhook = sys.displayhook try: sys.stdin = self.stdin sys.stdout = self.stdout sys.displayhook = self.displayhook exec code in globals, locals finally: sys.stdout = save_stdout sys.stdin = save_stdin sys.displayhook = save_displayhook except: t, v = sys.exc_info()[:2] if type(t) == type(''): exc_type_name = t else: exc_type_name = t.__name__ print >>self.stdout, '***', exc_type_name + ':', v def precmd(self, line): """Handle alias expansion and ';;' separator.""" if not line.strip(): return line args = line.split() while args[0] in self.aliases: line = self.aliases[args[0]] ii = 1 for tmpArg in args[1:]: line = line.replace("%" + str(ii), tmpArg) ii = ii + 1 line = line.replace("%*", ' '.join(args[1:])) args = line.split() # split into ';;' separated commands # unless it's an alias command if args[0] != 'alias': marker = line.find(';;') if marker >= 0: # queue up everything after marker next = line[marker+2:].lstrip() self.cmdqueue.append(next) line = line[:marker].rstrip() return line def onecmd(self, line): """Interpret the argument as though it had been typed in response to the prompt. Checks whether this line is typed at the normal prompt or in a breakpoint command list definition. """ if not self.commands_defining: return cmd.Cmd.onecmd(self, line) else: return self.handle_command_def(line) def handle_command_def(self,line): """Handles one command line during command list definition.""" cmd, arg, line = self.parseline(line) if not cmd: return if cmd == 'silent': self.commands_silent[self.commands_bnum] = True return # continue to handle other cmd def in the cmd list elif cmd == 'end': self.cmdqueue = [] return 1 # end of cmd list cmdlist = self.commands[self.commands_bnum] if arg: cmdlist.append(cmd+' '+arg) else: cmdlist.append(cmd) # Determine if we must stop try: func = getattr(self, 'do_' + cmd) except AttributeError: func = self.default # one of the resuming commands if func.func_name in self.commands_resuming: self.commands_doprompt[self.commands_bnum] = False self.cmdqueue = [] return 1 return # Command definitions, called by cmdloop() # The argument is the remaining string on the command line # Return true to exit from the command loop do_h = cmd.Cmd.do_help def do_commands(self, arg): """Defines a list of commands associated to a breakpoint. Those commands will be executed whenever the breakpoint causes the program to stop execution.""" if not arg: bnum = len(bdb.Breakpoint.bpbynumber)-1 else: try: bnum = int(arg) except: print >>self.stdout, "Usage : commands [bnum]\n ..." \ "\n end" return self.commands_bnum = bnum self.commands[bnum] = [] self.commands_doprompt[bnum] = True self.commands_silent[bnum] = False prompt_back = self.prompt self.prompt = '(com) ' self.commands_defining = True try: self.cmdloop() finally: self.commands_defining = False self.prompt = prompt_back def do_break(self, arg, temporary = 0): # break [ ([filename:]lineno | function) [, "condition"] ] if not arg: if self.breaks: # There's at least one print >>self.stdout, "Num Type Disp Enb Where" for bp in bdb.Breakpoint.bpbynumber: if bp: bp.bpprint(self.stdout) return # parse arguments; comma has lowest precedence # and cannot occur in filename filename = None lineno = None cond = None comma = arg.find(',') if comma > 0: # parse stuff after comma: "condition" cond = arg[comma+1:].lstrip() arg = arg[:comma].rstrip() # parse stuff before comma: [filename:]lineno | function colon = arg.rfind(':') funcname = None if colon >= 0: filename = arg[:colon].rstrip() f = self.lookupmodule(filename) if not f: print >>self.stdout, '*** ', repr(filename), print >>self.stdout, 'not found from sys.path' return else: filename = f arg = arg[colon+1:].lstrip() try: lineno = int(arg) except ValueError, msg: print >>self.stdout, '*** Bad lineno:', arg return else: # no colon; can be lineno or function try: lineno = int(arg) except ValueError: try: func = eval(arg, self.curframe.f_globals, self.curframe_locals) except: func = arg try: if hasattr(func, 'im_func'): func = func.im_func code = func.func_code #use co_name to identify the bkpt (function names #could be aliased, but co_name is invariant) funcname = code.co_name lineno = code.co_firstlineno filename = code.co_filename except: # last thing to try (ok, filename, ln) = self.lineinfo(arg) if not ok: print >>self.stdout, '*** The specified object', print >>self.stdout, repr(arg), print >>self.stdout, 'is not a function' print >>self.stdout, 'or was not found along sys.path.' return funcname = ok # ok contains a function name lineno = int(ln) if not filename: filename = self.defaultFile() # Check for reasonable breakpoint line = self.checkline(filename, lineno) if line: # now set the break point err = self.set_break(filename, line, temporary, cond, funcname) if err: print >>self.stdout, '***', err else: bp = self.get_breaks(filename, line)[-1] print >>self.stdout, "Breakpoint %d at %s:%d" % (bp.number, bp.file, bp.line) # To be overridden in derived debuggers def defaultFile(self): """Produce a reasonable default.""" filename = self.curframe.f_code.co_filename if filename == '<string>' and self.mainpyfile: filename = self.mainpyfile return filename do_b = do_break def do_tbreak(self, arg): self.do_break(arg, 1) def lineinfo(self, identifier): failed = (None, None, None) # Input is identifier, may be in single quotes idstring = identifier.split("'") if len(idstring) == 1: # not in single quotes id = idstring[0].strip() elif len(idstring) == 3: # quoted id = idstring[1].strip() else: return failed if id == '': return failed parts = id.split('.') # Protection for derived debuggers if parts[0] == 'self': del parts[0] if len(parts) == 0: return failed # Best first guess at file to look at fname = self.defaultFile() if len(parts) == 1: item = parts[0] else: # More than one part. # First is module, second is method/class f = self.lookupmodule(parts[0]) if f: fname = f item = parts[1] answer = find_function(item, fname) return answer or failed def checkline(self, filename, lineno): """Check whether specified line seems to be executable. Return `lineno` if it is, 0 if not (e.g. a docstring, comment, blank line or EOF). Warning: testing is not comprehensive. """ # this method should be callable before starting debugging, so default # to "no globals" if there is no current frame globs = self.curframe.f_globals if hasattr(self, 'curframe') else None line = linecache.getline(filename, lineno, globs) if not line: print >>self.stdout, 'End of file' return 0 line = line.strip() # Don't allow setting breakpoint at a blank line if (not line or (line[0] == '#') or (line[:3] == '"""') or line[:3] == "'''"): print >>self.stdout, '*** Blank or comment' return 0 return lineno def do_enable(self, arg): args = arg.split() for i in args: try: i = int(i) except ValueError: print >>self.stdout, 'Breakpoint index %r is not a number' % i continue if not (0 <= i < len(bdb.Breakpoint.bpbynumber)): print >>self.stdout, 'No breakpoint numbered', i continue bp = bdb.Breakpoint.bpbynumber[i] if bp: bp.enable() def do_disable(self, arg): args = arg.split() for i in args: try: i = int(i) except ValueError: print >>self.stdout, 'Breakpoint index %r is not a number' % i continue if not (0 <= i < len(bdb.Breakpoint.bpbynumber)): print >>self.stdout, 'No breakpoint numbered', i continue bp = bdb.Breakpoint.bpbynumber[i] if bp: bp.disable() def do_condition(self, arg): # arg is breakpoint number and condition args = arg.split(' ', 1) try: bpnum = int(args[0].strip()) except ValueError: # something went wrong print >>self.stdout, \ 'Breakpoint index %r is not a number' % args[0] return try: cond = args[1] except: cond = None try: bp = bdb.Breakpoint.bpbynumber[bpnum] except IndexError: print >>self.stdout, 'Breakpoint index %r is not valid' % args[0] return if bp: bp.cond = cond if not cond: print >>self.stdout, 'Breakpoint', bpnum, print >>self.stdout, 'is now unconditional.' def do_ignore(self,arg): """arg is bp number followed by ignore count.""" args = arg.split() try: bpnum = int(args[0].strip()) except ValueError: # something went wrong print >>self.stdout, \ 'Breakpoint index %r is not a number' % args[0] return try: count = int(args[1].strip()) except: count = 0 try: bp = bdb.Breakpoint.bpbynumber[bpnum] except IndexError: print >>self.stdout, 'Breakpoint index %r is not valid' % args[0] return if bp: bp.ignore = count if count > 0: reply = 'Will ignore next ' if count > 1: reply = reply + '%d crossings' % count else: reply = reply + '1 crossing' print >>self.stdout, reply + ' of breakpoint %d.' % bpnum else: print >>self.stdout, 'Will stop next time breakpoint', print >>self.stdout, bpnum, 'is reached.' def do_clear(self, arg): """Three possibilities, tried in this order: clear -> clear all breaks, ask for confirmation clear file:lineno -> clear all breaks at file:lineno clear bpno bpno ... -> clear breakpoints by number""" if not arg: try: reply = raw_input('Clear all breaks? ') except EOFError: reply = 'no' reply = reply.strip().lower() if reply in ('y', 'yes'): self.clear_all_breaks() return if ':' in arg: # Make sure it works for "clear C:\foo\bar.py:12" i = arg.rfind(':') filename = arg[:i] arg = arg[i+1:] try: lineno = int(arg) except ValueError: err = "Invalid line number (%s)" % arg else: err = self.clear_break(filename, lineno) if err: print >>self.stdout, '***', err return numberlist = arg.split() for i in numberlist: try: i = int(i) except ValueError: print >>self.stdout, 'Breakpoint index %r is not a number' % i continue if not (0 <= i < len(bdb.Breakpoint.bpbynumber)): print >>self.stdout, 'No breakpoint numbered', i continue err = self.clear_bpbynumber(i) if err: print >>self.stdout, '***', err else: print >>self.stdout, 'Deleted breakpoint', i do_cl = do_clear # 'c' is already an abbreviation for 'continue' def do_where(self, arg): self.print_stack_trace() do_w = do_where do_bt = do_where def do_up(self, arg): if self.curindex == 0: print >>self.stdout, '*** Oldest frame' else: self.curindex = self.curindex - 1 self.curframe = self.stack[self.curindex][0] self.curframe_locals = self.curframe.f_locals self.print_stack_entry(self.stack[self.curindex]) self.lineno = None do_u = do_up def do_down(self, arg): if self.curindex + 1 == len(self.stack): print >>self.stdout, '*** Newest frame' else: self.curindex = self.curindex + 1 self.curframe = self.stack[self.curindex][0] self.curframe_locals = self.curframe.f_locals self.print_stack_entry(self.stack[self.curindex]) self.lineno = None do_d = do_down def do_until(self, arg): self.set_until(self.curframe) return 1 do_unt = do_until def do_step(self, arg): self.set_step() return 1 do_s = do_step def do_next(self, arg): self.set_next(self.curframe) return 1 do_n = do_next def do_run(self, arg): """Restart program by raising an exception to be caught in the main debugger loop. If arguments were given, set them in sys.argv.""" if arg: import shlex argv0 = sys.argv[0:1] sys.argv = shlex.split(arg) sys.argv[:0] = argv0 raise Restart do_restart = do_run def do_return(self, arg): self.set_return(self.curframe) return 1 do_r = do_return def do_continue(self, arg): self.set_continue() return 1 do_c = do_cont = do_continue def do_jump(self, arg): if self.curindex + 1 != len(self.stack): print >>self.stdout, "*** You can only jump within the bottom frame" return try: arg = int(arg) except ValueError: print >>self.stdout, "*** The 'jump' command requires a line number." else: try: # Do the jump, fix up our copy of the stack, and display the # new position self.curframe.f_lineno = arg self.stack[self.curindex] = self.stack[self.curindex][0], arg self.print_stack_entry(self.stack[self.curindex]) except ValueError, e: print >>self.stdout, '*** Jump failed:', e do_j = do_jump def do_debug(self, arg): sys.settrace(None) globals = self.curframe.f_globals locals = self.curframe_locals p = Pdb(self.completekey, self.stdin, self.stdout) p.prompt = "(%s) " % self.prompt.strip() print >>self.stdout, "ENTERING RECURSIVE DEBUGGER" sys.call_tracing(p.run, (arg, globals, locals)) print >>self.stdout, "LEAVING RECURSIVE DEBUGGER" sys.settrace(self.trace_dispatch) self.lastcmd = p.lastcmd def do_quit(self, arg): self._user_requested_quit = 1 self.set_quit() return 1 do_q = do_quit do_exit = do_quit def do_EOF(self, arg): print >>self.stdout self._user_requested_quit = 1 self.set_quit() return 1 def do_args(self, arg): co = self.curframe.f_code dict = self.curframe_locals n = co.co_argcount if co.co_flags & 4: n = n+1 if co.co_flags & 8: n = n+1 for i in range(n): name = co.co_varnames[i] print >>self.stdout, name, '=', if name in dict: print >>self.stdout, dict[name] else: print >>self.stdout, "*** undefined ***" do_a = do_args def do_retval(self, arg): if '__return__' in self.curframe_locals: print >>self.stdout, self.curframe_locals['__return__'] else: print >>self.stdout, '*** Not yet returned!' do_rv = do_retval def _getval(self, arg): try: return eval(arg, self.curframe.f_globals, self.curframe_locals) except: t, v = sys.exc_info()[:2] if isinstance(t, str): exc_type_name = t else: exc_type_name = t.__name__ print >>self.stdout, '***', exc_type_name + ':', repr(v) raise def do_p(self, arg): try: print >>self.stdout, repr(self._getval(arg)) except: pass def do_pp(self, arg): try: pprint.pprint(self._getval(arg), self.stdout) except: pass def do_list(self, arg): self.lastcmd = 'list' last = None if arg: try: x = eval(arg, {}, {}) if type(x) == type(()): first, last = x first = int(first) last = int(last) if last < first: # Assume it's a count last = first + last else: first = max(1, int(x) - 5) except: print >>self.stdout, '*** Error in argument:', repr(arg) return elif self.lineno is None: first = max(1, self.curframe.f_lineno - 5) else: first = self.lineno + 1 if last is None: last = first + 10 filename = self.curframe.f_code.co_filename breaklist = self.get_file_breaks(filename) try: for lineno in range(first, last+1): line = linecache.getline(filename, lineno, self.curframe.f_globals) if not line: print >>self.stdout, '[EOF]' break else: s = repr(lineno).rjust(3) if len(s) < 4: s = s + ' ' if lineno in breaklist: s = s + 'B' else: s = s + ' ' if lineno == self.curframe.f_lineno: s = s + '->' print >>self.stdout, s + '\t' + line, self.lineno = lineno except KeyboardInterrupt: pass do_l = do_list def do_whatis(self, arg): try: value = eval(arg, self.curframe.f_globals, self.curframe_locals) except: t, v = sys.exc_info()[:2] if type(t) == type(''): exc_type_name = t else: exc_type_name = t.__name__ print >>self.stdout, '***', exc_type_name + ':', repr(v) return code = None # Is it a function? try: code = value.func_code except: pass if code: print >>self.stdout, 'Function', code.co_name return # Is it an instance method? try: code = value.im_func.func_code except: pass if code: print >>self.stdout, 'Method', code.co_name return # None of the above... print >>self.stdout, type(value) def do_alias(self, arg): args = arg.split() if len(args) == 0: keys = self.aliases.keys() keys.sort() for alias in keys: print >>self.stdout, "%s = %s" % (alias, self.aliases[alias]) return if args[0] in self.aliases and len(args) == 1: print >>self.stdout, "%s = %s" % (args[0], self.aliases[args[0]]) else: self.aliases[args[0]] = ' '.join(args[1:]) def do_unalias(self, arg): args = arg.split() if len(args) == 0: return if args[0] in self.aliases: del self.aliases[args[0]] #list of all the commands making the program resume execution. commands_resuming = ['do_continue', 'do_step', 'do_next', 'do_return', 'do_quit', 'do_jump'] # Print a traceback starting at the top stack frame. # The most recently entered frame is printed last; # this is different from dbx and gdb, but consistent with # the Python interpreter's stack trace. # It is also consistent with the up/down commands (which are # compatible with dbx and gdb: up moves towards 'main()' # and down moves towards the most recent stack frame). def print_stack_trace(self): try: for frame_lineno in self.stack: self.print_stack_entry(frame_lineno) except KeyboardInterrupt: pass def print_stack_entry(self, frame_lineno, prompt_prefix=line_prefix): frame, lineno = frame_lineno if frame is self.curframe: print >>self.stdout, '>', else: print >>self.stdout, ' ', print >>self.stdout, self.format_stack_entry(frame_lineno, prompt_prefix) # Help methods (derived from pdb.doc) def help_help(self): self.help_h() def help_h(self): print >>self.stdout, """h(elp) Without argument, print the list of available commands. With a command name as argument, print help about that command "help pdb" pipes the full documentation file to the $PAGER "help exec" gives help on the ! command""" def help_where(self): self.help_w() def help_w(self): print >>self.stdout, """w(here) Print a stack trace, with the most recent frame at the bottom. An arrow indicates the "current frame", which determines the context of most commands. 'bt' is an alias for this command.""" help_bt = help_w def help_down(self): self.help_d() def help_d(self): print >>self.stdout, """d(own) Move the current frame one level down in the stack trace (to a newer frame).""" def help_up(self): self.help_u() def help_u(self): print >>self.stdout, """u(p) Move the current frame one level up in the stack trace (to an older frame).""" def help_break(self): self.help_b() def help_b(self): print >>self.stdout, """b(reak) ([file:]lineno | function) [, condition] With a line number argument, set a break there in the current file. With a function name, set a break at first executable line of that function. Without argument, list all breaks. If a second argument is present, it is a string specifying an expression which must evaluate to true before the breakpoint is honored. The line number may be prefixed with a filename and a colon, to specify a breakpoint in another file (probably one that hasn't been loaded yet). The file is searched for on sys.path; the .py suffix may be omitted.""" def help_clear(self): self.help_cl() def help_cl(self): print >>self.stdout, "cl(ear) filename:lineno" print >>self.stdout, """cl(ear) [bpnumber [bpnumber...]] With a space separated list of breakpoint numbers, clear those breakpoints. Without argument, clear all breaks (but first ask confirmation). With a filename:lineno argument, clear all breaks at that line in that file. Note that the argument is different from previous versions of the debugger (in python distributions 1.5.1 and before) where a linenumber was used instead of either filename:lineno or breakpoint numbers.""" def help_tbreak(self): print >>self.stdout, """tbreak same arguments as break, but breakpoint is removed when first hit.""" def help_enable(self): print >>self.stdout, """enable bpnumber [bpnumber ...] Enables the breakpoints given as a space separated list of bp numbers.""" def help_disable(self): print >>self.stdout, """disable bpnumber [bpnumber ...] Disables the breakpoints given as a space separated list of bp numbers.""" def help_ignore(self): print >>self.stdout, """ignore bpnumber count Sets the ignore count for the given breakpoint number. A breakpoint becomes active when the ignore count is zero. When non-zero, the count is decremented each time the breakpoint is reached and the breakpoint is not disabled and any associated condition evaluates to true.""" def help_condition(self): print >>self.stdout, """condition bpnumber str_condition str_condition is a string specifying an expression which must evaluate to true before the breakpoint is honored. If str_condition is absent, any existing condition is removed; i.e., the breakpoint is made unconditional.""" def help_step(self): self.help_s() def help_s(self): print >>self.stdout, """s(tep) Execute the current line, stop at the first possible occasion (either in a function that is called or in the current function).""" def help_until(self): self.help_unt() def help_unt(self): print """unt(il) Continue execution until the line with a number greater than the current one is reached or until the current frame returns""" def help_next(self): self.help_n() def help_n(self): print >>self.stdout, """n(ext) Continue execution until the next line in the current function is reached or it returns.""" def help_return(self): self.help_r() def help_r(self): print >>self.stdout, """r(eturn) Continue execution until the current function returns.""" def help_continue(self): self.help_c() def help_cont(self): self.help_c() def help_c(self): print >>self.stdout, """c(ont(inue)) Continue execution, only stop when a breakpoint is encountered.""" def help_jump(self): self.help_j() def help_j(self): print >>self.stdout, """j(ump) lineno Set the next line that will be executed.""" def help_debug(self): print >>self.stdout, """debug code Enter a recursive debugger that steps through the code argument (which is an arbitrary expression or statement to be executed in the current environment).""" def help_list(self): self.help_l() def help_l(self): print >>self.stdout, """l(ist) [first [,last]] List source code for the current file. Without arguments, list 11 lines around the current line or continue the previous listing. With one argument, list 11 lines starting at that line. With two arguments, list the given range; if the second argument is less than the first, it is a count.""" def help_args(self): self.help_a() def help_a(self): print >>self.stdout, """a(rgs) Print the arguments of the current function.""" def help_p(self): print >>self.stdout, """p expression Print the value of the expression.""" def help_pp(self): print >>self.stdout, """pp expression Pretty-print the value of the expression.""" def help_exec(self): print >>self.stdout, """(!) statement Execute the (one-line) statement in the context of the current stack frame. The exclamation point can be omitted unless the first word of the statement resembles a debugger command. To assign to a global variable you must always prefix the command with a 'global' command, e.g.: (Pdb) global list_options; list_options = ['-l'] (Pdb)""" def help_run(self): print """run [args...] Restart the debugged python program. If a string is supplied, it is splitted with "shlex" and the result is used as the new sys.argv. History, breakpoints, actions and debugger options are preserved. "restart" is an alias for "run".""" help_restart = help_run def help_quit(self): self.help_q() def help_q(self): print >>self.stdout, """q(uit) or exit - Quit from the debugger. The program being executed is aborted.""" help_exit = help_q def help_whatis(self): print >>self.stdout, """whatis arg Prints the type of the argument.""" def help_EOF(self): print >>self.stdout, """EOF Handles the receipt of EOF as a command.""" def help_alias(self): print >>self.stdout, """alias [name [command [parameter parameter ...]]] Creates an alias called 'name' the executes 'command'. The command must *not* be enclosed in quotes. Replaceable parameters are indicated by %1, %2, and so on, while %* is replaced by all the parameters. If no command is given, the current alias for name is shown. If no name is given, all aliases are listed. Aliases may be nested and can contain anything that can be legally typed at the pdb prompt. Note! You *can* override internal pdb commands with aliases! Those internal commands are then hidden until the alias is removed. Aliasing is recursively applied to the first word of the command line; all other words in the line are left alone. Some useful aliases (especially when placed in the .pdbrc file) are: #Print instance variables (usage "pi classInst") alias pi for k in %1.__dict__.keys(): print "%1.",k,"=",%1.__dict__[k] #Print instance variables in self alias ps pi self """ def help_unalias(self): print >>self.stdout, """unalias name Deletes the specified alias.""" def help_commands(self): print >>self.stdout, """commands [bpnumber] (com) ... (com) end (Pdb) Specify a list of commands for breakpoint number bpnumber. The commands themselves appear on the following lines. Type a line containing just 'end' to terminate the commands. To remove all commands from a breakpoint, type commands and follow it immediately with end; that is, give no commands. With no bpnumber argument, commands refers to the last breakpoint set. You can use breakpoint commands to start your program up again. Simply use the continue command, or step, or any other command that resumes execution. Specifying any command resuming execution (currently continue, step, next, return, jump, quit and their abbreviations) terminates the command list (as if that command was immediately followed by end). This is because any time you resume execution (even with a simple next or step), you may encounter another breakpoint--which could have its own command list, leading to ambiguities about which list to execute. If you use the 'silent' command in the command list, the usual message about stopping at a breakpoint is not printed. This may be desirable for breakpoints that are to print a specific message and then continue. If none of the other commands print anything, you see no sign that the breakpoint was reached. """ def help_pdb(self): help() def lookupmodule(self, filename): """Helper function for break/clear parsing -- may be overridden. lookupmodule() translates (possibly incomplete) file or module name into an absolute file name. """ if os.path.isabs(filename) and os.path.exists(filename): return filename f = os.path.join(sys.path[0], filename) if os.path.exists(f) and self.canonic(f) == self.mainpyfile: return f root, ext = os.path.splitext(filename) if ext == '': filename = filename + '.py' if os.path.isabs(filename): return filename for dirname in sys.path: while os.path.islink(dirname): dirname = os.readlink(dirname) fullname = os.path.join(dirname, filename) if os.path.exists(fullname): return fullname return None def _runscript(self, filename): # The script has to run in __main__ namespace (or imports from # __main__ will break). # # So we clear up the __main__ and set several special variables # (this gets rid of pdb's globals and cleans old variables on restarts). import __main__ __main__.__dict__.clear() __main__.__dict__.update({"__name__" : "__main__", "__file__" : filename, "__builtins__": __builtins__, }) # When bdb sets tracing, a number of call and line events happens # BEFORE debugger even reaches user's code (and the exact sequence of # events depends on python version). So we take special measures to # avoid stopping before we reach the main script (see user_line and # user_call for details). self._wait_for_mainpyfile = 1 self.mainpyfile = self.canonic(filename) self._user_requested_quit = 0 statement = 'execfile(%r)' % filename self.run(statement) # Simplified interface def run(statement, globals=None, locals=None): Pdb().run(statement, globals, locals) def runeval(expression, globals=None, locals=None): return Pdb().runeval(expression, globals, locals) def runctx(statement, globals, locals): # B/W compatibility run(statement, globals, locals) def runcall(*args, **kwds): return Pdb().runcall(*args, **kwds) def set_trace(): Pdb().set_trace(sys._getframe().f_back) # Post-Mortem interface def post_mortem(t=None): # handling the default if t is None: # sys.exc_info() returns (type, value, traceback) if an exception is # being handled, otherwise it returns None t = sys.exc_info()[2] if t is None: raise ValueError("A valid traceback must be passed if no " "exception is being handled") p = Pdb() p.reset() p.interaction(None, t) def pm(): post_mortem(sys.last_traceback) # Main program for testing TESTCMD = 'import x; x.main()' def test(): run(TESTCMD) # print help def help(): for dirname in sys.path: fullname = os.path.join(dirname, 'pdb.doc') if os.path.exists(fullname): sts = os.system('${PAGER-more} '+fullname) if sts: print '*** Pager exit status:', sts break else: print 'Sorry, can\'t find the help file "pdb.doc"', print 'along the Python search path' def main(): if not sys.argv[1:] or sys.argv[1] in ("--help", "-h"): print "usage: pdb.py scriptfile [arg] ..." sys.exit(2) mainpyfile = sys.argv[1] # Get script filename if not os.path.exists(mainpyfile): print 'Error:', mainpyfile, 'does not exist' sys.exit(1) del sys.argv[0] # Hide "pdb.py" from argument list # Replace pdb's dir with script's dir in front of module search path. sys.path[0] = os.path.dirname(mainpyfile) # Note on saving/restoring sys.argv: it's a good idea when sys.argv was # modified by the script being debugged. It's a bad idea when it was # changed by the user from the command line. There is a "restart" command # which allows explicit specification of command line arguments. pdb = Pdb() while True: try: pdb._runscript(mainpyfile) if pdb._user_requested_quit: break print "The program finished and will be restarted" except Restart: print "Restarting", mainpyfile, "with arguments:" print "\t" + " ".join(sys.argv[1:]) except SystemExit: # In most cases SystemExit does not warrant a post-mortem session. print "The program exited via sys.exit(). Exit status: ", print sys.exc_info()[1] except: traceback.print_exc() print "Uncaught exception. Entering post mortem debugging" print "Running 'cont' or 'step' will restart the program" t = sys.exc_info()[2] pdb.interaction(None, t) print "Post mortem debugger finished. The " + mainpyfile + \ " will be restarted" # When invoked as main program, invoke the debugger on a script if __name__ == '__main__': import pdb pdb.main()
gpl-3.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 33, 2018, 14958, 1041, 199, 199, 3, 334, 9295, 10543, 14, 1301, 367, 3794, 4959, 199, 199, 646, 984, 199, 646, 26026, 199, 646, 2088, 199, 646, 330, 697, 199, 504, 4700, 492, 799, 2700, 199, 646, 747, 199, 646, 295, 199, 646, 10933, 199, 646, 5190, 421, 199, 533, 799, 928, 8, 1726, 304, 272, 408, 3630, 5589, 282, 14958, 370, 506, 32277, 367, 314, 3105, 3046, 2366, 2240, 1041, 272, 986, 199, 199, 3, 2790, 282, 3537, 5048, 799, 2700, 1256, 436, 19781, 2399, 1390, 875, 14, 199, 3, 710, 849, 402, 4233, 14547, 83, 1125, 3788, 4634, 16174, 14, 199, 63, 2722, 275, 799, 2700, 342, 199, 63, 2722, 14, 988, 875, 275, 1926, 199, 63, 3489, 2722, 275, 485, 2722, 14, 2722, 199, 199, 363, 452, 363, 275, 2097, 1065, 401, 298, 7073, 401, 298, 21427, 401, 298, 1065, 2579, 401, 298, 1065, 3799, 401, 298, 1065, 1250, 401, 298, 409, 63, 3446, 401, 1779, 298, 1932, 63, 12416, 563, 401, 298, 3437, 937, 199, 199, 318, 2342, 63, 1593, 8, 29577, 12, 1788, 304, 272, 2837, 275, 295, 14, 2014, 8, 82, 5121, 2829, 60, 83, 25389, 83, 60, 83, 10, 7528, 6616, 450, 295, 14, 3765, 8, 29577, 430, 272, 862, 26, 267, 4090, 275, 1551, 8, 1501, 9, 272, 871, 5925, 26, 267, 372, 488, 272, 327, 9790, 402, 642, 2256, 14292, 314, 1642, 1004, 370, 506, 413, 272, 5874, 275, 413, 272, 6385, 275, 488, 272, 1830, 413, 26, 267, 1004, 275, 4090, 14, 6407, 342, 267, 340, 1004, 508, 8061, 288, 2059, 267, 340, 2837, 14, 1431, 8, 604, 304, 288, 6385, 275, 24092, 12, 1788, 12, 5874, 288, 2059, 267, 5874, 275, 5874, 435, 413, 272, 4090, 14, 1600, 342, 272, 372, 6385, 421, 199, 3, 1010, 11732, 8457, 1004, 911, 7396, 570, 436, 1240, 2256, 687, 1233, 199, 3, 1318, 1808, 574, 402, 1004, 63, 1861, 1059, 14, 221, 437, 8057, 436, 18800, 1443, 199, 3, 506, 370, 2195, 1212, 17443, 14, 221, 2047, 883, 663, 652, 5403, 10543, 365, 8439, 1808, 314, 199, 3, 1414, 298, 10511, 14, 604, 63, 1861, 275, 1557, 78, 5, 283, 1674, 199, 3, 1004, 63, 1861, 275, 7596, 283, 259, 327, 3645, 642, 370, 664, 314, 2269, 25781, 1771, 199, 604, 63, 1861, 275, 1557, 78, 5118, 283, 257, 327, 22770, 6665, 282, 8034, 849, 199, 199, 533, 510, 697, 8, 27178, 14, 34, 697, 12, 2088, 14, 7874, 304, 339, 347, 636, 826, 721, 277, 12, 4890, 498, 534, 2902, 297, 9009, 29, 403, 12, 3839, 29, 403, 12, 3372, 29, 403, 304, 267, 330, 697, 14, 34, 697, 855, 826, 721, 277, 12, 3372, 29, 2759, 9, 267, 2088, 14, 7874, 855, 826, 721, 277, 12, 4890, 498, 12, 9009, 12, 3839, 9, 267, 340, 3839, 26, 288, 291, 14, 1180, 63, 1773, 1210, 275, 378, 267, 291, 14, 7650, 275, 8189, 21427, 9, 283, 267, 291, 14, 8602, 275, 1052, 267, 291, 14, 973, 14792, 275, 2125, 267, 291, 423, 2573, 63, 509, 63, 973, 14792, 275, 378, 267, 327, 7649, 370, 2248, 14441, 340, 652, 3495, 267, 862, 26, 288, 492, 14441, 267, 871, 3545, 26, 288, 986, 398, 327, 5574, 2672, 9524, 8083, 10511, 1195, 436, 1275, 8083, 10511, 1195, 267, 291, 14, 1195, 9863, 275, 942, 267, 340, 283, 9524, 7, 315, 747, 14, 2314, 26, 288, 2589, 12054, 275, 747, 14, 2314, 459, 9524, 418, 288, 862, 26, 355, 4819, 1173, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 1813, 12054, 12, 3680, 10511, 1195, 2237, 288, 871, 5925, 26, 355, 986, 288, 587, 26, 355, 367, 1004, 315, 4819, 1173, 14, 9684, 837, 490, 291, 14, 1195, 9863, 14, 740, 8, 604, 9, 355, 4819, 1173, 14, 1600, 342, 267, 862, 26, 288, 4819, 1173, 275, 1551, 9520, 10511, 1195, 531, 267, 871, 5925, 26, 288, 986, 267, 587, 26, 288, 367, 1004, 315, 4819, 1173, 14, 9684, 837, 355, 291, 14, 1195, 9863, 14, 740, 8, 604, 9, 288, 4819, 1173, 14, 1600, 342, 398, 291, 14, 4405, 275, 1052, 327, 4035, 2335, 282, 1414, 769, 370, 17944, 5579, 267, 291, 14, 4405, 63, 68, 11340, 4787, 275, 1052, 327, 367, 1924, 13292, 1967, 12, 26544, 340, 314, 8457, 2511, 327, 1471, 506, 9628, 14, 2410, 2146, 316, 314, 2088, 769, 267, 291, 14, 4405, 63, 14434, 275, 1052, 327, 367, 1924, 13292, 1967, 12, 26544, 340, 314, 3464, 3307, 3303, 327, 1471, 506, 9628, 14, 2410, 2146, 316, 314, 2088, 769, 267, 291, 14, 4405, 63, 318, 7969, 275, 756, 327, 715, 1830, 315, 314, 2112, 402, 12669, 4318, 327, 282, 1414, 769, 267, 291, 14, 4405, 63, 66, 1507, 275, 488, 327, 710, 17944, 1329, 367, 1314, 781, 787, 3303, 327, 12669, 282, 769, 339, 347, 5305, 8, 277, 304, 267, 330, 697, 14, 34, 697, 14, 3958, 8, 277, 9, 267, 291, 14, 28767, 342, 339, 347, 19459, 8, 277, 304, 267, 291, 14, 3469, 275, 488, 267, 291, 14, 2340, 275, 942, 267, 291, 14, 895, 1080, 275, 378, 267, 291, 14, 895, 1943, 275, 488, 339, 347, 3272, 8, 277, 12, 289, 12, 307, 304, 267, 291, 14, 28767, 342, 267, 291, 14, 2340, 12, 291, 14, 895, 1080, 275, 291, 14, 362, 63, 2340, 8, 70, 12, 307, 9, 267, 291, 14, 895, 1943, 275, 291, 14, 2340, 59, 277, 14, 895, 1080, 1527, 16, 61, 267, 327, 710, 289, 63, 9350, 2600, 365, 4588, 687, 314, 3503, 2787, 267, 327, 9480, 18119, 314, 1275, 70, 63, 9350, 19474, 365, 2797, 12, 880, 781, 267, 327, 2581, 652, 2348, 370, 4868, 626, 23070, 787, 440, 20200, 14, 267, 291, 14, 895, 1943, 63, 9350, 275, 291, 14, 895, 1943, 14, 70, 63, 9350, 267, 291, 14, 1628, 19360, 9863, 342, 339, 327, 6855, 506, 7934, 14119, 2419, 283, 2758, 7, 340, 6387, 272, 347, 2146, 19360, 9863, 8, 277, 304, 267, 340, 291, 14, 1195, 9863, 26, 288, 327, 4155, 2257, 1331, 2952, 402, 16189, 288, 4819, 9863, 275, 291, 14, 1195, 9863, 288, 327, 7934, 1454, 5403, 288 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 33, 2018, 14958, 1041, 199, 199, 3, 334, 9295, 10543, 14, 1301, 367, 3794, 4959, 199, 199, 646, 984, 199, 646, 26026, 199, 646, 2088, 199, 646, 330, 697, 199, 504, 4700, 492, 799, 2700, 199, 646, 747, 199, 646, 295, 199, 646, 10933, 199, 646, 5190, 421, 199, 533, 799, 928, 8, 1726, 304, 272, 408, 3630, 5589, 282, 14958, 370, 506, 32277, 367, 314, 3105, 3046, 2366, 2240, 1041, 272, 986, 199, 199, 3, 2790, 282, 3537, 5048, 799, 2700, 1256, 436, 19781, 2399, 1390, 875, 14, 199, 3, 710, 849, 402, 4233, 14547, 83, 1125, 3788, 4634, 16174, 14, 199, 63, 2722, 275, 799, 2700, 342, 199, 63, 2722, 14, 988, 875, 275, 1926, 199, 63, 3489, 2722, 275, 485, 2722, 14, 2722, 199, 199, 363, 452, 363, 275, 2097, 1065, 401, 298, 7073, 401, 298, 21427, 401, 298, 1065, 2579, 401, 298, 1065, 3799, 401, 298, 1065, 1250, 401, 298, 409, 63, 3446, 401, 1779, 298, 1932, 63, 12416, 563, 401, 298, 3437, 937, 199, 199, 318, 2342, 63, 1593, 8, 29577, 12, 1788, 304, 272, 2837, 275, 295, 14, 2014, 8, 82, 5121, 2829, 60, 83, 25389, 83, 60, 83, 10, 7528, 6616, 450, 295, 14, 3765, 8, 29577, 430, 272, 862, 26, 267, 4090, 275, 1551, 8, 1501, 9, 272, 871, 5925, 26, 267, 372, 488, 272, 327, 9790, 402, 642, 2256, 14292, 314, 1642, 1004, 370, 506, 413, 272, 5874, 275, 413, 272, 6385, 275, 488, 272, 1830, 413, 26, 267, 1004, 275, 4090, 14, 6407, 342, 267, 340, 1004, 508, 8061, 288, 2059, 267, 340, 2837, 14, 1431, 8, 604, 304, 288, 6385, 275, 24092, 12, 1788, 12, 5874, 288, 2059, 267, 5874, 275, 5874, 435, 413, 272, 4090, 14, 1600, 342, 272, 372, 6385, 421, 199, 3, 1010, 11732, 8457, 1004, 911, 7396, 570, 436, 1240, 2256, 687, 1233, 199, 3, 1318, 1808, 574, 402, 1004, 63, 1861, 1059, 14, 221, 437, 8057, 436, 18800, 1443, 199, 3, 506, 370, 2195, 1212, 17443, 14, 221, 2047, 883, 663, 652, 5403, 10543, 365, 8439, 1808, 314, 199, 3, 1414, 298, 10511, 14, 604, 63, 1861, 275, 1557, 78, 5, 283, 1674, 199, 3, 1004, 63, 1861, 275, 7596, 283, 259, 327, 3645, 642, 370, 664, 314, 2269, 25781, 1771, 199, 604, 63, 1861, 275, 1557, 78, 5118, 283, 257, 327, 22770, 6665, 282, 8034, 849, 199, 199, 533, 510, 697, 8, 27178, 14, 34, 697, 12, 2088, 14, 7874, 304, 339, 347, 636, 826, 721, 277, 12, 4890, 498, 534, 2902, 297, 9009, 29, 403, 12, 3839, 29, 403, 12, 3372, 29, 403, 304, 267, 330, 697, 14, 34, 697, 855, 826, 721, 277, 12, 3372, 29, 2759, 9, 267, 2088, 14, 7874, 855, 826, 721, 277, 12, 4890, 498, 12, 9009, 12, 3839, 9, 267, 340, 3839, 26, 288, 291, 14, 1180, 63, 1773, 1210, 275, 378, 267, 291, 14, 7650, 275, 8189, 21427, 9, 283, 267, 291, 14, 8602, 275, 1052, 267, 291, 14, 973, 14792, 275, 2125, 267, 291, 423, 2573, 63, 509, 63, 973, 14792, 275, 378, 267, 327, 7649, 370, 2248, 14441, 340, 652, 3495, 267, 862, 26, 288, 492, 14441, 267, 871, 3545, 26, 288, 986, 398, 327, 5574, 2672, 9524, 8083, 10511, 1195, 436, 1275, 8083, 10511, 1195, 267, 291, 14, 1195, 9863, 275, 942, 267, 340, 283, 9524, 7, 315, 747, 14, 2314, 26, 288, 2589, 12054, 275, 747, 14, 2314, 459, 9524, 418, 288, 862, 26, 355, 4819, 1173, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 1813, 12054, 12, 3680, 10511, 1195, 2237, 288, 871, 5925, 26, 355, 986, 288, 587, 26, 355, 367, 1004, 315, 4819, 1173, 14, 9684, 837, 490, 291, 14, 1195, 9863, 14, 740, 8, 604, 9, 355, 4819, 1173, 14, 1600, 342, 267, 862, 26, 288, 4819, 1173, 275, 1551, 9520, 10511, 1195, 531, 267, 871, 5925, 26, 288, 986, 267, 587, 26, 288, 367, 1004, 315, 4819, 1173, 14, 9684, 837, 355, 291, 14, 1195, 9863, 14, 740, 8, 604, 9, 288, 4819, 1173, 14, 1600, 342, 398, 291, 14, 4405, 275, 1052, 327, 4035, 2335, 282, 1414, 769, 370, 17944, 5579, 267, 291, 14, 4405, 63, 68, 11340, 4787, 275, 1052, 327, 367, 1924, 13292, 1967, 12, 26544, 340, 314, 8457, 2511, 327, 1471, 506, 9628, 14, 2410, 2146, 316, 314, 2088, 769, 267, 291, 14, 4405, 63, 14434, 275, 1052, 327, 367, 1924, 13292, 1967, 12, 26544, 340, 314, 3464, 3307, 3303, 327, 1471, 506, 9628, 14, 2410, 2146, 316, 314, 2088, 769, 267, 291, 14, 4405, 63, 318, 7969, 275, 756, 327, 715, 1830, 315, 314, 2112, 402, 12669, 4318, 327, 282, 1414, 769, 267, 291, 14, 4405, 63, 66, 1507, 275, 488, 327, 710, 17944, 1329, 367, 1314, 781, 787, 3303, 327, 12669, 282, 769, 339, 347, 5305, 8, 277, 304, 267, 330, 697, 14, 34, 697, 14, 3958, 8, 277, 9, 267, 291, 14, 28767, 342, 339, 347, 19459, 8, 277, 304, 267, 291, 14, 3469, 275, 488, 267, 291, 14, 2340, 275, 942, 267, 291, 14, 895, 1080, 275, 378, 267, 291, 14, 895, 1943, 275, 488, 339, 347, 3272, 8, 277, 12, 289, 12, 307, 304, 267, 291, 14, 28767, 342, 267, 291, 14, 2340, 12, 291, 14, 895, 1080, 275, 291, 14, 362, 63, 2340, 8, 70, 12, 307, 9, 267, 291, 14, 895, 1943, 275, 291, 14, 2340, 59, 277, 14, 895, 1080, 1527, 16, 61, 267, 327, 710, 289, 63, 9350, 2600, 365, 4588, 687, 314, 3503, 2787, 267, 327, 9480, 18119, 314, 1275, 70, 63, 9350, 19474, 365, 2797, 12, 880, 781, 267, 327, 2581, 652, 2348, 370, 4868, 626, 23070, 787, 440, 20200, 14, 267, 291, 14, 895, 1943, 63, 9350, 275, 291, 14, 895, 1943, 14, 70, 63, 9350, 267, 291, 14, 1628, 19360, 9863, 342, 339, 327, 6855, 506, 7934, 14119, 2419, 283, 2758, 7, 340, 6387, 272, 347, 2146, 19360, 9863, 8, 277, 304, 267, 340, 291, 14, 1195, 9863, 26, 288, 327, 4155, 2257, 1331, 2952, 402, 16189, 288, 4819, 9863, 275, 291, 14, 1195, 9863, 288, 327, 7934, 1454, 5403, 288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 1, 1, 1 ]
vijaylbais/boto
tests/unit/vpc/test_vpnconnection.py
114
10421
# -*- coding: UTF-8 -*- from tests.unit import unittest from tests.unit import AWSMockServiceTestCase from boto.vpc import VPCConnection, VpnConnection DESCRIBE_VPNCONNECTIONS = b'''<?xml version="1.0" encoding="UTF-8"?> <DescribeVpnConnectionsResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/"> <requestId>12345678-asdf-ghjk-zxcv-0987654321nb</requestId> <vpnConnectionSet> <item> <vpnConnectionId>vpn-12qw34er56ty</vpnConnectionId> <state>available</state> <customerGatewayConfiguration> &lt;?xml version="1.0" encoding="UTF-8"?&gt; </customerGatewayConfiguration> <type>ipsec.1</type> <customerGatewayId>cgw-1234qwe9</customerGatewayId> <vpnGatewayId>vgw-lkjh1234</vpnGatewayId> <tagSet> <item> <key>Name</key> <value>VPN 1</value> </item> </tagSet> <vgwTelemetry> <item> <outsideIpAddress>123.45.67.89</outsideIpAddress> <status>DOWN</status> <lastStatusChange>2013-03-19T19:20:34.000Z</lastStatusChange> <statusMessage/> <acceptedRouteCount>0</acceptedRouteCount> </item> <item> <outsideIpAddress>123.45.67.90</outsideIpAddress> <status>UP</status> <lastStatusChange>2013-03-20T08:00:14.000Z</lastStatusChange> <statusMessage/> <acceptedRouteCount>0</acceptedRouteCount> </item> </vgwTelemetry> <options> <staticRoutesOnly>true</staticRoutesOnly> </options> <routes> <item> <destinationCidrBlock>192.168.0.0/24</destinationCidrBlock> <source>static</source> <state>available</state> </item> </routes> </item> <item> <vpnConnectionId>vpn-qwerty12</vpnConnectionId> <state>pending</state> <customerGatewayConfiguration> &lt;?xml version="1.0" encoding="UTF-8"?&gt; </customerGatewayConfiguration> <type>ipsec.1</type> <customerGatewayId>cgw-01234567</customerGatewayId> <vpnGatewayId>vgw-asdfghjk</vpnGatewayId> <vgwTelemetry> <item> <outsideIpAddress>134.56.78.78</outsideIpAddress> <status>UP</status> <lastStatusChange>2013-03-20T01:46:30.000Z</lastStatusChange> <statusMessage/> <acceptedRouteCount>0</acceptedRouteCount> </item> <item> <outsideIpAddress>134.56.78.79</outsideIpAddress> <status>UP</status> <lastStatusChange>2013-03-19T19:23:59.000Z</lastStatusChange> <statusMessage/> <acceptedRouteCount>0</acceptedRouteCount> </item> </vgwTelemetry> <options> <staticRoutesOnly>true</staticRoutesOnly> </options> <routes> <item> <destinationCidrBlock>10.0.0.0/16</destinationCidrBlock> <source>static</source> <state>pending</state> </item> </routes> </item> </vpnConnectionSet> </DescribeVpnConnectionsResponse>''' class TestDescribeVPNConnections(AWSMockServiceTestCase): connection_class = VPCConnection def default_body(self): return DESCRIBE_VPNCONNECTIONS def test_get_vpcs(self): self.set_http_response(status_code=200) api_response = self.service_connection.get_all_vpn_connections( ['vpn-12qw34er56ty', 'vpn-qwerty12'], filters=[('state', ['pending', 'available'])]) self.assert_request_parameters({ 'Action': 'DescribeVpnConnections', 'VpnConnectionId.1': 'vpn-12qw34er56ty', 'VpnConnectionId.2': 'vpn-qwerty12', 'Filter.1.Name': 'state', 'Filter.1.Value.1': 'pending', 'Filter.1.Value.2': 'available'}, ignore_params_values=['AWSAccessKeyId', 'SignatureMethod', 'SignatureVersion', 'Timestamp', 'Version']) self.assertEqual(len(api_response), 2) vpn0 = api_response[0] self.assertEqual(vpn0.type, 'ipsec.1') self.assertEqual(vpn0.customer_gateway_id, 'cgw-1234qwe9') self.assertEqual(vpn0.vpn_gateway_id, 'vgw-lkjh1234') self.assertEqual(len(vpn0.tunnels), 2) self.assertDictEqual(vpn0.tags, {'Name': 'VPN 1'}) vpn1 = api_response[1] self.assertEqual(vpn1.state, 'pending') self.assertEqual(len(vpn1.static_routes), 1) self.assertTrue(vpn1.options.static_routes_only) self.assertEqual(vpn1.tunnels[0].status, 'UP') self.assertEqual(vpn1.tunnels[1].status, 'UP') self.assertDictEqual(vpn1.tags, {}) self.assertEqual(vpn1.static_routes[0].source, 'static') self.assertEqual(vpn1.static_routes[0].state, 'pending') class TestCreateVPNConnection(AWSMockServiceTestCase): connection_class = VPCConnection def default_body(self): return b""" <CreateVpnConnectionResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-01/"> <requestId>5cc7891f-1f3b-4fc4-a626-bdea8f63ff5a</requestId> <vpnConnection> <vpnConnectionId>vpn-83ad48ea</vpnConnectionId> <state>pending</state> <customerGatewayConfiguration> &lt;?xml version="1.0" encoding="UTF-8"?&gt; </customerGatewayConfiguration> <customerGatewayId>cgw-b4dc3961</customerGatewayId> <vpnGatewayId>vgw-8db04f81</vpnGatewayId> <options> <staticRoutesOnly>true</staticRoutesOnly> </options> <routes/> </vpnConnection> </CreateVpnConnectionResponse> """ def test_create_vpn_connection(self): self.set_http_response(status_code=200) api_response = self.service_connection.create_vpn_connection( 'ipsec.1', 'cgw-b4dc3961', 'vgw-8db04f81', static_routes_only=True) self.assert_request_parameters({ 'Action': 'CreateVpnConnection', 'Type': 'ipsec.1', 'CustomerGatewayId': 'cgw-b4dc3961', 'VpnGatewayId': 'vgw-8db04f81', 'Options.StaticRoutesOnly': 'true'}, ignore_params_values=['AWSAccessKeyId', 'SignatureMethod', 'SignatureVersion', 'Timestamp', 'Version']) self.assertIsInstance(api_response, VpnConnection) self.assertEquals(api_response.id, 'vpn-83ad48ea') self.assertEquals(api_response.customer_gateway_id, 'cgw-b4dc3961') self.assertEquals(api_response.options.static_routes_only, True) class TestDeleteVPNConnection(AWSMockServiceTestCase): connection_class = VPCConnection def default_body(self): return b""" <DeleteVpnConnectionResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-01/"> <requestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</requestId> <return>true</return> </DeleteVpnConnectionResponse> """ def test_delete_vpn_connection(self): self.set_http_response(status_code=200) api_response = self.service_connection.delete_vpn_connection('vpn-44a8938f') self.assert_request_parameters({ 'Action': 'DeleteVpnConnection', 'VpnConnectionId': 'vpn-44a8938f'}, ignore_params_values=['AWSAccessKeyId', 'SignatureMethod', 'SignatureVersion', 'Timestamp', 'Version']) self.assertEquals(api_response, True) class TestCreateVPNConnectionRoute(AWSMockServiceTestCase): connection_class = VPCConnection def default_body(self): return b""" <CreateVpnConnectionRouteResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-01/"> <requestId>4f35a1b2-c2c3-4093-b51f-abb9d7311990</requestId> <return>true</return> </CreateVpnConnectionRouteResponse> """ def test_create_vpn_connection_route(self): self.set_http_response(status_code=200) api_response = self.service_connection.create_vpn_connection_route( '11.12.0.0/16', 'vpn-83ad48ea') self.assert_request_parameters({ 'Action': 'CreateVpnConnectionRoute', 'DestinationCidrBlock': '11.12.0.0/16', 'VpnConnectionId': 'vpn-83ad48ea'}, ignore_params_values=['AWSAccessKeyId', 'SignatureMethod', 'SignatureVersion', 'Timestamp', 'Version']) self.assertEquals(api_response, True) class TestDeleteVPNConnectionRoute(AWSMockServiceTestCase): connection_class = VPCConnection def default_body(self): return b""" <DeleteVpnConnectionRouteResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-01/"> <requestId>4f35a1b2-c2c3-4093-b51f-abb9d7311990</requestId> <return>true</return> </DeleteVpnConnectionRouteResponse> """ def test_delete_vpn_connection_route(self): self.set_http_response(status_code=200) api_response = self.service_connection.delete_vpn_connection_route( '11.12.0.0/16', 'vpn-83ad48ea') self.assert_request_parameters({ 'Action': 'DeleteVpnConnectionRoute', 'DestinationCidrBlock': '11.12.0.0/16', 'VpnConnectionId': 'vpn-83ad48ea'}, ignore_params_values=['AWSAccessKeyId', 'SignatureMethod', 'SignatureVersion', 'Timestamp', 'Version']) self.assertEquals(api_response, True) if __name__ == '__main__': unittest.main()
mit
[ 3, 1882, 2803, 26, 9094, 13, 24, 1882, 199, 504, 2295, 14, 3248, 492, 2882, 199, 504, 2295, 14, 3248, 492, 10168, 3346, 3167, 1746, 199, 199, 504, 6055, 14, 11742, 492, 19209, 3225, 12, 812, 4812, 3225, 199, 199, 4448, 27448, 37, 63, 54, 9060, 14657, 2823, 275, 330, 2344, 28, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 24327, 199, 28, 19506, 20975, 22122, 2364, 9604, 628, 1014, 921, 825, 18, 14, 21442, 14, 957, 15, 1301, 15, 6965, 13, 996, 13, 614, 26049, 272, 665, 1069, 1304, 30, 19542, 13, 18196, 13, 3561, 17421, 13, 90, 1812, 86, 13, 1643, 1555, 11157, 12638, 4994, 1108, 1069, 1304, 30, 272, 665, 9702, 3225, 1084, 30, 267, 665, 1053, 30, 288, 665, 9702, 3225, 1304, 30, 9702, 13, 713, 81, 87, 1082, 281, 1367, 369, 1108, 9702, 3225, 1304, 30, 288, 665, 929, 30, 4561, 1108, 929, 30, 288, 665, 10178, 12455, 5688, 30, 355, 1253, 4116, 27, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 14863, 6, 3308, 27, 288, 3068, 10178, 12455, 5688, 30, 288, 665, 466, 30, 19867, 14, 17, 1108, 466, 30, 288, 665, 10178, 12455, 1304, 30, 67, 8392, 13, 4321, 81, 1129, 25, 1108, 10178, 12455, 1304, 30, 288, 665, 9702, 12455, 1304, 30, 26408, 13, 23333, 31623, 4321, 1108, 9702, 12455, 1304, 30, 288, 665, 27420, 30, 355, 665, 1053, 30, 490, 665, 498, 30, 985, 1108, 498, 30, 490, 665, 585, 30, 54, 9060, 413, 1108, 585, 30, 355, 3068, 1053, 30, 288, 3068, 27420, 30, 288, 665, 26408, 24944, 10987, 30, 355, 665, 1053, 30, 490, 665, 22431, 23211, 30, 4288, 14, 2322, 14, 1822, 14, 1407, 1108, 22431, 23211, 30, 490, 665, 1205, 30, 8819, 1108, 1205, 30, 490, 665, 2019, 3694, 4001, 30, 6965, 13, 1644, 13, 1167, 52, 1167, 26, 1165, 26, 1082, 14, 1493, 58, 1108, 2019, 3694, 4001, 30, 490, 665, 1205, 2209, 3133, 490, 665, 16121, 7161, 2353, 30, 16, 1108, 16121, 7161, 2353, 30, 355, 3068, 1053, 30, 355, 665, 1053, 30, 490, 665, 22431, 23211, 30, 4288, 14, 2322, 14, 1822, 14, 2710, 1108, 22431, 23211, 30, 490, 665, 1205, 30, 2160, 1108, 1205, 30, 490, 665, 2019, 3694, 4001, 30, 6965, 13, 1644, 13, 1165, 52, 2036, 26, 383, 26, 1079, 14, 1493, 58, 1108, 2019, 3694, 4001, 30, 490, 665, 1205, 2209, 3133, 490, 665, 16121, 7161, 2353, 30, 16, 1108, 16121, 7161, 2353, 30, 355, 3068, 1053, 30, 288, 3068, 26408, 24944, 10987, 30, 288, 665, 1419, 30, 355, 665, 1986, 5407, 744, 5903, 30, 2052, 1108, 1986, 5407, 744, 5903, 30, 288, 3068, 1419, 30, 288, 665, 13243, 30, 355, 665, 1053, 30, 490, 665, 6881, 21456, 82, 3142, 30, 5756, 14, 6568, 14, 16, 14, 16, 15, 1194, 1108, 6881, 21456, 82, 3142, 30, 490, 665, 1365, 30, 1986, 1108, 1365, 30, 490, 665, 929, 30, 4561, 1108, 929, 30, 355, 3068, 1053, 30, 288, 3068, 13243, 30, 267, 3068, 1053, 30, 267, 665, 1053, 30, 288, 665, 9702, 3225, 1304, 30, 9702, 13, 81, 2135, 369, 713, 1108, 9702, 3225, 1304, 30, 288, 665, 929, 30, 6455, 1108, 929, 30, 288, 665, 10178, 12455, 5688, 30, 355, 1253, 4116, 27, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 14863, 6, 3308, 27, 288, 3068, 10178, 12455, 5688, 30, 288, 665, 466, 30, 19867, 14, 17, 1108, 466, 30, 288, 665, 10178, 12455, 1304, 30, 67, 8392, 13, 9461, 5308, 1108, 10178, 12455, 1304, 30, 288, 665, 9702, 12455, 1304, 30, 26408, 13, 18196, 3561, 17421, 1108, 9702, 12455, 1304, 30, 288, 665, 26408, 24944, 10987, 30, 355, 665, 1053, 30, 490, 665, 22431, 23211, 30, 7582, 14, 1367, 14, 2277, 14, 2277, 1108, 22431, 23211, 30, 490, 665, 1205, 30, 2160, 1108, 1205, 30, 490, 665, 2019, 3694, 4001, 30, 6965, 13, 1644, 13, 1165, 52, 614, 26, 2466, 26, 1216, 14, 1493, 58, 1108, 2019, 3694, 4001, 30, 490, 665, 1205, 2209, 3133, 490, 665, 16121, 7161, 2353, 30, 16, 1108, 16121, 7161, 2353, 30, 355, 3068, 1053, 30, 355, 665, 1053, 30, 490, 665, 22431, 23211, 30, 7582, 14, 1367, 14, 2277, 14, 1965, 1108, 22431, 23211, 30, 490, 665, 1205, 30, 2160, 1108, 1205, 30, 490, 665, 2019, 3694, 4001, 30, 6965, 13, 1644, 13, 1167, 52, 1167, 26, 1789, 26, 1427, 14, 1493, 58, 1108, 2019, 3694, 4001, 30, 490, 665, 1205, 2209, 3133, 490, 665, 16121, 7161, 2353, 30, 16, 1108, 16121, 7161, 2353, 30, 355, 3068, 1053, 30, 288, 3068, 26408, 24944, 10987, 30, 288, 665, 1419, 30, 355, 665, 1986, 5407, 744, 5903, 30, 2052, 1108, 1986, 5407, 744, 5903, 30, 288, 3068, 1419, 30, 288, 665, 13243, 30, 355, 665, 1053, 30, 490, 665, 6881, 21456, 82, 3142, 30, 709, 14, 16, 14, 16, 14, 16, 15, 975, 1108, 6881, 21456, 82, 3142, 30, 490, 665, 1365, 30, 1986, 1108, 1365, 30, 490, 665, 929, 30, 6455, 1108, 929, 30, 355, 3068, 1053, 30, 288, 3068, 13243, 30, 267, 3068, 1053, 30, 272, 3068, 9702, 3225, 1084, 30, 199, 1108, 19506, 20975, 22122, 2364, 26934, 421, 199, 533, 1379, 19506, 54, 9060, 22122, 8, 13226, 3346, 3167, 1746, 304, 339, 1950, 63, 533, 275, 19209, 3225, 339, 347, 849, 63, 2030, 8, 277, 304, 267, 372, 11758, 27448, 37, 63, 54, 9060, 14657, 2823, 339, 347, 511, 63, 362, 63, 11702, 1259, 8, 277, 304, 267, 291, 14, 409, 63, 1014, 63, 1310, 8, 1205, 63, 600, 29, 1840, 9, 398, 2986, 63, 1310, 275, 291, 14, 1364, 63, 2105, 14, 362, 63, 452, 63, 9702, 63, 7995, 8, 288, 788, 9702, 13, 713, 81, 87, 1082, 281, 1367, 369, 297, 283, 9702, 13, 81, 2135, 369, 713, 995, 4766, 11699, 929, 297, 788, 6455, 297, 283, 4561, 31161, 267, 291, 14, 479, 63, 1069, 63, 3214, 2561, 288, 283, 3310, 356, 283, 19506, 20975, 22122, 297, 288, 283, 20975, 3225, 1304, 14, 17, 356, 283, 9702, 13, 713, 81, 87, 1082, 281, 1367, 369, 297, 288, 283, 20975, 3225, 1304, 14, 18, 356, 283, 9702, 13 ]
[ 1882, 2803, 26, 9094, 13, 24, 1882, 199, 504, 2295, 14, 3248, 492, 2882, 199, 504, 2295, 14, 3248, 492, 10168, 3346, 3167, 1746, 199, 199, 504, 6055, 14, 11742, 492, 19209, 3225, 12, 812, 4812, 3225, 199, 199, 4448, 27448, 37, 63, 54, 9060, 14657, 2823, 275, 330, 2344, 28, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 24327, 199, 28, 19506, 20975, 22122, 2364, 9604, 628, 1014, 921, 825, 18, 14, 21442, 14, 957, 15, 1301, 15, 6965, 13, 996, 13, 614, 26049, 272, 665, 1069, 1304, 30, 19542, 13, 18196, 13, 3561, 17421, 13, 90, 1812, 86, 13, 1643, 1555, 11157, 12638, 4994, 1108, 1069, 1304, 30, 272, 665, 9702, 3225, 1084, 30, 267, 665, 1053, 30, 288, 665, 9702, 3225, 1304, 30, 9702, 13, 713, 81, 87, 1082, 281, 1367, 369, 1108, 9702, 3225, 1304, 30, 288, 665, 929, 30, 4561, 1108, 929, 30, 288, 665, 10178, 12455, 5688, 30, 355, 1253, 4116, 27, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 14863, 6, 3308, 27, 288, 3068, 10178, 12455, 5688, 30, 288, 665, 466, 30, 19867, 14, 17, 1108, 466, 30, 288, 665, 10178, 12455, 1304, 30, 67, 8392, 13, 4321, 81, 1129, 25, 1108, 10178, 12455, 1304, 30, 288, 665, 9702, 12455, 1304, 30, 26408, 13, 23333, 31623, 4321, 1108, 9702, 12455, 1304, 30, 288, 665, 27420, 30, 355, 665, 1053, 30, 490, 665, 498, 30, 985, 1108, 498, 30, 490, 665, 585, 30, 54, 9060, 413, 1108, 585, 30, 355, 3068, 1053, 30, 288, 3068, 27420, 30, 288, 665, 26408, 24944, 10987, 30, 355, 665, 1053, 30, 490, 665, 22431, 23211, 30, 4288, 14, 2322, 14, 1822, 14, 1407, 1108, 22431, 23211, 30, 490, 665, 1205, 30, 8819, 1108, 1205, 30, 490, 665, 2019, 3694, 4001, 30, 6965, 13, 1644, 13, 1167, 52, 1167, 26, 1165, 26, 1082, 14, 1493, 58, 1108, 2019, 3694, 4001, 30, 490, 665, 1205, 2209, 3133, 490, 665, 16121, 7161, 2353, 30, 16, 1108, 16121, 7161, 2353, 30, 355, 3068, 1053, 30, 355, 665, 1053, 30, 490, 665, 22431, 23211, 30, 4288, 14, 2322, 14, 1822, 14, 2710, 1108, 22431, 23211, 30, 490, 665, 1205, 30, 2160, 1108, 1205, 30, 490, 665, 2019, 3694, 4001, 30, 6965, 13, 1644, 13, 1165, 52, 2036, 26, 383, 26, 1079, 14, 1493, 58, 1108, 2019, 3694, 4001, 30, 490, 665, 1205, 2209, 3133, 490, 665, 16121, 7161, 2353, 30, 16, 1108, 16121, 7161, 2353, 30, 355, 3068, 1053, 30, 288, 3068, 26408, 24944, 10987, 30, 288, 665, 1419, 30, 355, 665, 1986, 5407, 744, 5903, 30, 2052, 1108, 1986, 5407, 744, 5903, 30, 288, 3068, 1419, 30, 288, 665, 13243, 30, 355, 665, 1053, 30, 490, 665, 6881, 21456, 82, 3142, 30, 5756, 14, 6568, 14, 16, 14, 16, 15, 1194, 1108, 6881, 21456, 82, 3142, 30, 490, 665, 1365, 30, 1986, 1108, 1365, 30, 490, 665, 929, 30, 4561, 1108, 929, 30, 355, 3068, 1053, 30, 288, 3068, 13243, 30, 267, 3068, 1053, 30, 267, 665, 1053, 30, 288, 665, 9702, 3225, 1304, 30, 9702, 13, 81, 2135, 369, 713, 1108, 9702, 3225, 1304, 30, 288, 665, 929, 30, 6455, 1108, 929, 30, 288, 665, 10178, 12455, 5688, 30, 355, 1253, 4116, 27, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 14863, 6, 3308, 27, 288, 3068, 10178, 12455, 5688, 30, 288, 665, 466, 30, 19867, 14, 17, 1108, 466, 30, 288, 665, 10178, 12455, 1304, 30, 67, 8392, 13, 9461, 5308, 1108, 10178, 12455, 1304, 30, 288, 665, 9702, 12455, 1304, 30, 26408, 13, 18196, 3561, 17421, 1108, 9702, 12455, 1304, 30, 288, 665, 26408, 24944, 10987, 30, 355, 665, 1053, 30, 490, 665, 22431, 23211, 30, 7582, 14, 1367, 14, 2277, 14, 2277, 1108, 22431, 23211, 30, 490, 665, 1205, 30, 2160, 1108, 1205, 30, 490, 665, 2019, 3694, 4001, 30, 6965, 13, 1644, 13, 1165, 52, 614, 26, 2466, 26, 1216, 14, 1493, 58, 1108, 2019, 3694, 4001, 30, 490, 665, 1205, 2209, 3133, 490, 665, 16121, 7161, 2353, 30, 16, 1108, 16121, 7161, 2353, 30, 355, 3068, 1053, 30, 355, 665, 1053, 30, 490, 665, 22431, 23211, 30, 7582, 14, 1367, 14, 2277, 14, 1965, 1108, 22431, 23211, 30, 490, 665, 1205, 30, 2160, 1108, 1205, 30, 490, 665, 2019, 3694, 4001, 30, 6965, 13, 1644, 13, 1167, 52, 1167, 26, 1789, 26, 1427, 14, 1493, 58, 1108, 2019, 3694, 4001, 30, 490, 665, 1205, 2209, 3133, 490, 665, 16121, 7161, 2353, 30, 16, 1108, 16121, 7161, 2353, 30, 355, 3068, 1053, 30, 288, 3068, 26408, 24944, 10987, 30, 288, 665, 1419, 30, 355, 665, 1986, 5407, 744, 5903, 30, 2052, 1108, 1986, 5407, 744, 5903, 30, 288, 3068, 1419, 30, 288, 665, 13243, 30, 355, 665, 1053, 30, 490, 665, 6881, 21456, 82, 3142, 30, 709, 14, 16, 14, 16, 14, 16, 15, 975, 1108, 6881, 21456, 82, 3142, 30, 490, 665, 1365, 30, 1986, 1108, 1365, 30, 490, 665, 929, 30, 6455, 1108, 929, 30, 355, 3068, 1053, 30, 288, 3068, 13243, 30, 267, 3068, 1053, 30, 272, 3068, 9702, 3225, 1084, 30, 199, 1108, 19506, 20975, 22122, 2364, 26934, 421, 199, 533, 1379, 19506, 54, 9060, 22122, 8, 13226, 3346, 3167, 1746, 304, 339, 1950, 63, 533, 275, 19209, 3225, 339, 347, 849, 63, 2030, 8, 277, 304, 267, 372, 11758, 27448, 37, 63, 54, 9060, 14657, 2823, 339, 347, 511, 63, 362, 63, 11702, 1259, 8, 277, 304, 267, 291, 14, 409, 63, 1014, 63, 1310, 8, 1205, 63, 600, 29, 1840, 9, 398, 2986, 63, 1310, 275, 291, 14, 1364, 63, 2105, 14, 362, 63, 452, 63, 9702, 63, 7995, 8, 288, 788, 9702, 13, 713, 81, 87, 1082, 281, 1367, 369, 297, 283, 9702, 13, 81, 2135, 369, 713, 995, 4766, 11699, 929, 297, 788, 6455, 297, 283, 4561, 31161, 267, 291, 14, 479, 63, 1069, 63, 3214, 2561, 288, 283, 3310, 356, 283, 19506, 20975, 22122, 297, 288, 283, 20975, 3225, 1304, 14, 17, 356, 283, 9702, 13, 713, 81, 87, 1082, 281, 1367, 369, 297, 288, 283, 20975, 3225, 1304, 14, 18, 356, 283, 9702, 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, 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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 ]
thanm/devel-scripts
munge-root-dump.py
1
3865
#!/usr/bin/python3 """Post-process a GC roots dump. """ import getopt import os import re import sys import script_utils as u # Input and output file (if not specified, defaults to stdin/stdout) flag_infile = None flag_outfile = None # Binary to analyze flag_module = None #...................................................................... # Regular expressions to match: # Start of root collection rcstartre = re.compile(r"^root collection\s+(\d+)\s*$") # Root list entry rlere = re.compile(r"^\s*\d+\s+\:\s+0x(\S+)\s+(\d+)\s*$") def perform_filt(inf, outf): """Read inf and emit summary to outf.""" ncollections = 0 nroots = 0 collections = [] elist = [] addrsize = {} # Read input while True: line = inf.readline() if not line: break u.verbose(3, "line is %s" % line) # Root collection start? m1 = rcstartre.match(line) if m1: collections.append(elist) elist = [] ncollections += 1 continue # Root list entry? m2 = rlere.match(line) if m2: nroots += 1 hexaddr = m2.group(1) siz = m2.group(2) addrsize[hexaddr] = int(siz) elist.append(hexaddr) continue if elist: collections.append(elist) # Now that we've read everything, write GDB script. if os.path.exists("gdb-cmds.txt"): os.unlink("gdb-cmds.txt") if os.path.exists("gdb-out.txt"): os.unlink("gdb-out.txt") try: gf = open("gdb-cmds.txt", "wb") except IOError as e: u.error("unable to open output file 'gdbcmds.txt': %s" % e.strerror) gf.write("set height 0\n") gf.write("set width 0\n") gf.write("set pagination off\n") gf.write("set logging file gdb-out.txt\n") gf.write("set logging on\n") gf.write("file %s\n" % flag_module) ncol = 0 for el in collections: gf.write("print \"collection %d\"\n" % ncol) ncol += 1 for hexaddr in el: gf.write("print \"0x%x size %d\"\n" % (int(hexaddr, 16), addrsize[hexaddr])) gf.write("info sym 0x%s\n" % hexaddr) gf.close() # Invoke GDB u.docmd("gdb -batch -nh -x gdb-cmds.txt") # Emit try: rf = open("gdb-out.txt", "r") except IOError as e: u.error("unable to open output file 'gdb-out.txt': %s" % e.strerror) lines = rf.readlines() rf.close() for line in lines: outf.write(line) outf.close() u.verbose(0, "processed %d roots in %d collections" % (nroots, ncollections)) def perform(): """Main driver routine.""" inf = sys.stdin outf = sys.stdout if flag_infile: try: inf = open(flag_infile, "rb") except IOError as e: u.error("unable to open input file %s: " "%s" % (flag_infile, e.strerror)) if flag_outfile: try: outf = open(flag_outfile, "wb") except IOError as e: u.error("unable to open output file %s: " "%s" % (flag_outfile, e.strerror)) perform_filt(inf, outf) if flag_infile: inf.close() if flag_outfile: outf.close() def usage(msgarg): """Print usage and exit.""" me = os.path.basename(sys.argv[0]) if msgarg: sys.stderr.write("error: %s\n" % msgarg) print("""\ usage: %s [options] < input > output options: -d increase debug msg verbosity level -i F read from input file F -o G write to output file O -m M analyze load module M """ % me) sys.exit(1) def parse_args(): """Command line argument parsing.""" global flag_infile, flag_outfile, flag_module try: optlist, _ = getopt.getopt(sys.argv[1:], "di:o:m:") except getopt.GetoptError as err: # unrecognized option usage(str(err)) for opt, arg in optlist: if opt == "-d": u.increment_verbosity() elif opt == "-i": flag_infile = arg elif opt == "-m": flag_module = arg elif opt == "-o": flag_outfile = arg parse_args() u.setdeflanglocale() perform()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 19, 199, 624, 6564, 13, 1412, 282, 31555, 14361, 5461, 14, 199, 624, 199, 199, 646, 12733, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 199, 646, 2884, 63, 1208, 465, 399, 199, 199, 3, 6924, 436, 1072, 570, 334, 692, 440, 2013, 12, 4243, 370, 9009, 15, 2703, 9, 199, 4173, 63, 13880, 275, 488, 199, 4173, 63, 4984, 275, 488, 199, 199, 3, 14161, 370, 19897, 199, 4173, 63, 578, 275, 488, 199, 199, 3, 29301, 29301, 32478, 199, 199, 3, 18528, 8455, 370, 1336, 26, 199, 199, 3, 7707, 402, 1738, 3245, 199, 1195, 928, 264, 275, 295, 14, 2014, 8, 82, 16136, 1231, 3245, 60, 83, 20900, 68, 13439, 83, 10, 22550, 199, 199, 3, 12826, 769, 2397, 199, 82, 274, 264, 275, 295, 14, 2014, 8, 82, 2, 12773, 83, 7590, 68, 7896, 83, 7896, 3427, 83, 11, 16, 88, 2961, 51, 13439, 83, 20900, 68, 13439, 83, 10, 22550, 421, 199, 318, 5147, 63, 18872, 8, 4904, 12, 27552, 304, 523, 408, 3284, 10739, 436, 8689, 6212, 370, 27552, 1041, 819, 302, 7882, 275, 378, 523, 302, 12065, 275, 378, 523, 5055, 275, 942, 523, 325, 513, 275, 942, 523, 5552, 890, 275, 1052, 819, 327, 5574, 1324, 523, 1830, 715, 26, 272, 1004, 275, 10739, 14, 6407, 342, 272, 340, 440, 1004, 26, 489, 2059, 272, 399, 14, 3832, 8, 19, 12, 298, 604, 365, 450, 83, 2, 450, 1004, 9, 339, 327, 12826, 3245, 1343, 31, 272, 333, 17, 275, 4819, 928, 264, 14, 1431, 8, 604, 9, 272, 340, 333, 17, 26, 489, 5055, 14, 740, 8, 69, 513, 9, 489, 325, 513, 275, 942, 489, 302, 7882, 847, 413, 489, 1980, 339, 327, 12826, 769, 2397, 31, 272, 333, 18, 275, 519, 274, 264, 14, 1431, 8, 604, 9, 272, 340, 333, 18, 26, 489, 302, 12065, 847, 413, 489, 6318, 2697, 275, 333, 18, 14, 923, 8, 17, 9, 489, 308, 565, 275, 333, 18, 14, 923, 8, 18, 9, 489, 5552, 890, 59, 4097, 2697, 61, 275, 1109, 8, 5946, 9, 489, 325, 513, 14, 740, 8, 4097, 2697, 9, 489, 1980, 819, 340, 325, 513, 26, 272, 5055, 14, 740, 8, 69, 513, 9, 819, 327, 7356, 626, 781, 9064, 1586, 8137, 12, 2218, 598, 2846, 2884, 14, 523, 340, 747, 14, 515, 14, 2444, 480, 17119, 13, 12975, 14, 2424, 2349, 272, 747, 14, 7162, 480, 17119, 13, 12975, 14, 2424, 531, 523, 340, 747, 14, 515, 14, 2444, 480, 17119, 13, 548, 14, 2424, 2349, 272, 747, 14, 7162, 480, 17119, 13, 548, 14, 2424, 531, 523, 862, 26, 272, 15719, 275, 1551, 480, 17119, 13, 12975, 14, 2424, 401, 298, 6603, 531, 523, 871, 5925, 465, 325, 26, 272, 399, 14, 705, 480, 17200, 370, 1551, 1072, 570, 283, 17119, 12975, 14, 2424, 356, 450, 83, 2, 450, 325, 14, 20395, 9, 523, 15719, 14, 952, 480, 409, 4569, 378, 60, 78, 531, 523, 15719, 14, 952, 480, 409, 3462, 378, 60, 78, 531, 523, 15719, 14, 952, 480, 409, 21192, 2331, 60, 78, 531, 523, 15719, 14, 952, 480, 409, 2050, 570, 12124, 13, 548, 14, 2424, 60, 78, 531, 523, 15719, 14, 952, 480, 409, 2050, 641, 60, 78, 531, 523, 15719, 14, 952, 480, 493, 450, 83, 60, 78, 2, 450, 3305, 63, 578, 9, 523, 302, 761, 275, 378, 523, 367, 579, 315, 5055, 26, 272, 15719, 14, 952, 480, 1361, 8441, 3627, 450, 68, 13356, 78, 2, 450, 302, 761, 9, 272, 302, 761, 847, 413, 272, 367, 6318, 2697, 315, 579, 26, 489, 15719, 14, 952, 480, 1361, 8441, 16, 88, 5, 88, 1568, 450, 68, 13356, 78, 2, 450, 334, 442, 8, 4097, 2697, 12, 3193, 395, 5552, 890, 59, 4097, 2697, 2459, 489, 15719, 14, 952, 480, 815, 4678, 378, 88, 5, 83, 60, 78, 2, 450, 6318, 2697, 9, 523, 15719, 14, 1600, 342, 819, 327, 31049, 598, 2846, 523, 399, 14, 1301, 1064, 480, 17119, 446, 2912, 446, 29199, 446, 88, 12124, 13, 12975, 14, 2424, 531, 819, 327, 662, 1147, 523, 862, 26, 272, 17781, 275, 1551, 480, 17119, 13, 548, 14, 2424, 401, 298, 82, 531, 523, 871, 5925, 465, 325, 26, 272, 399, 14, 705, 480, 17200, 370, 1551, 1072, 570, 283, 17119, 13, 548, 14, 2424, 356, 450, 83, 2, 450, 325, 14, 20395, 9, 523, 2385, 275, 17781, 14, 9684, 342, 523, 17781, 14, 1600, 342, 523, 367, 1004, 315, 2385, 26, 272, 27552, 14, 952, 8, 604, 9, 523, 27552, 14, 1600, 342, 523, 399, 14, 3832, 8, 16, 12, 298, 7292, 450, 68, 14361, 315, 450, 68, 5055, 2, 450, 334, 78, 12065, 12, 302, 7882, 430, 421, 199, 318, 5147, 837, 523, 408, 6756, 5253, 12981, 1041, 523, 10739, 275, 984, 14, 6626, 523, 27552, 275, 984, 14, 2703, 523, 340, 3305, 63, 13880, 26, 272, 862, 26, 489, 10739, 275, 1551, 8, 4173, 63, 13880, 12, 298, 4848, 531, 272, 871, 5925, 465, 325, 26, 489, 399, 14, 705, 480, 17200, 370, 1551, 1324, 570, 450, 83, 26, 298, 1598, 2071, 83, 2, 450, 334, 4173, 63, 13880, 12, 325, 14, 20395, 430, 523, 340, 3305, 63, 4984, 26, 272, 862, 26, 489, 27552, 275, 1551, 8, 4173, 63, 4984, 12, 298, 6603, 531, 272, 871, 5925, 465, 325, 26, 489, 399, 14, 705, 480, 17200, 370, 1551, 1072, 570, 450, 83, 26, 298, 1598, 2071, 83, 2, 450, 334, 4173, 63, 4984, 12, 325, 14, 20395, 430, 523, 5147, 63, 18872, 8, 4904, 12, 27552, 9, 523, 340, 3305, 63, 13880, 26, 272, 10739, 14, 1600, 342, 523, 340, 3305, 63, 4984, 26, 272, 27552, 14, 1600, 342, 421, 199, 318, 4503, 8, 1328, 1273, 304, 523, 408, 5375, 4503, 436, 4458, 1041, 523, 562, 275, 747, 14, 515, 14, 4846, 8, 1274, 14, 3020, 59, 16, 566, 523, 340, 1499, 1273, 26, 272, 984, 14, 3083, 14, 952, 480, 705, 26, 450, 83, 60, 78, 2, 450, 1499, 1273, 9, 523, 870, 21723, 272, 4503, 26, 221, 450, 83, 359, 1419, 61, 665, 1324, 690, 1072, 339, 1511, 26 ]
[ 2647, 15, 1393, 15, 1548, 19, 199, 624, 6564, 13, 1412, 282, 31555, 14361, 5461, 14, 199, 624, 199, 199, 646, 12733, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 199, 646, 2884, 63, 1208, 465, 399, 199, 199, 3, 6924, 436, 1072, 570, 334, 692, 440, 2013, 12, 4243, 370, 9009, 15, 2703, 9, 199, 4173, 63, 13880, 275, 488, 199, 4173, 63, 4984, 275, 488, 199, 199, 3, 14161, 370, 19897, 199, 4173, 63, 578, 275, 488, 199, 199, 3, 29301, 29301, 32478, 199, 199, 3, 18528, 8455, 370, 1336, 26, 199, 199, 3, 7707, 402, 1738, 3245, 199, 1195, 928, 264, 275, 295, 14, 2014, 8, 82, 16136, 1231, 3245, 60, 83, 20900, 68, 13439, 83, 10, 22550, 199, 199, 3, 12826, 769, 2397, 199, 82, 274, 264, 275, 295, 14, 2014, 8, 82, 2, 12773, 83, 7590, 68, 7896, 83, 7896, 3427, 83, 11, 16, 88, 2961, 51, 13439, 83, 20900, 68, 13439, 83, 10, 22550, 421, 199, 318, 5147, 63, 18872, 8, 4904, 12, 27552, 304, 523, 408, 3284, 10739, 436, 8689, 6212, 370, 27552, 1041, 819, 302, 7882, 275, 378, 523, 302, 12065, 275, 378, 523, 5055, 275, 942, 523, 325, 513, 275, 942, 523, 5552, 890, 275, 1052, 819, 327, 5574, 1324, 523, 1830, 715, 26, 272, 1004, 275, 10739, 14, 6407, 342, 272, 340, 440, 1004, 26, 489, 2059, 272, 399, 14, 3832, 8, 19, 12, 298, 604, 365, 450, 83, 2, 450, 1004, 9, 339, 327, 12826, 3245, 1343, 31, 272, 333, 17, 275, 4819, 928, 264, 14, 1431, 8, 604, 9, 272, 340, 333, 17, 26, 489, 5055, 14, 740, 8, 69, 513, 9, 489, 325, 513, 275, 942, 489, 302, 7882, 847, 413, 489, 1980, 339, 327, 12826, 769, 2397, 31, 272, 333, 18, 275, 519, 274, 264, 14, 1431, 8, 604, 9, 272, 340, 333, 18, 26, 489, 302, 12065, 847, 413, 489, 6318, 2697, 275, 333, 18, 14, 923, 8, 17, 9, 489, 308, 565, 275, 333, 18, 14, 923, 8, 18, 9, 489, 5552, 890, 59, 4097, 2697, 61, 275, 1109, 8, 5946, 9, 489, 325, 513, 14, 740, 8, 4097, 2697, 9, 489, 1980, 819, 340, 325, 513, 26, 272, 5055, 14, 740, 8, 69, 513, 9, 819, 327, 7356, 626, 781, 9064, 1586, 8137, 12, 2218, 598, 2846, 2884, 14, 523, 340, 747, 14, 515, 14, 2444, 480, 17119, 13, 12975, 14, 2424, 2349, 272, 747, 14, 7162, 480, 17119, 13, 12975, 14, 2424, 531, 523, 340, 747, 14, 515, 14, 2444, 480, 17119, 13, 548, 14, 2424, 2349, 272, 747, 14, 7162, 480, 17119, 13, 548, 14, 2424, 531, 523, 862, 26, 272, 15719, 275, 1551, 480, 17119, 13, 12975, 14, 2424, 401, 298, 6603, 531, 523, 871, 5925, 465, 325, 26, 272, 399, 14, 705, 480, 17200, 370, 1551, 1072, 570, 283, 17119, 12975, 14, 2424, 356, 450, 83, 2, 450, 325, 14, 20395, 9, 523, 15719, 14, 952, 480, 409, 4569, 378, 60, 78, 531, 523, 15719, 14, 952, 480, 409, 3462, 378, 60, 78, 531, 523, 15719, 14, 952, 480, 409, 21192, 2331, 60, 78, 531, 523, 15719, 14, 952, 480, 409, 2050, 570, 12124, 13, 548, 14, 2424, 60, 78, 531, 523, 15719, 14, 952, 480, 409, 2050, 641, 60, 78, 531, 523, 15719, 14, 952, 480, 493, 450, 83, 60, 78, 2, 450, 3305, 63, 578, 9, 523, 302, 761, 275, 378, 523, 367, 579, 315, 5055, 26, 272, 15719, 14, 952, 480, 1361, 8441, 3627, 450, 68, 13356, 78, 2, 450, 302, 761, 9, 272, 302, 761, 847, 413, 272, 367, 6318, 2697, 315, 579, 26, 489, 15719, 14, 952, 480, 1361, 8441, 16, 88, 5, 88, 1568, 450, 68, 13356, 78, 2, 450, 334, 442, 8, 4097, 2697, 12, 3193, 395, 5552, 890, 59, 4097, 2697, 2459, 489, 15719, 14, 952, 480, 815, 4678, 378, 88, 5, 83, 60, 78, 2, 450, 6318, 2697, 9, 523, 15719, 14, 1600, 342, 819, 327, 31049, 598, 2846, 523, 399, 14, 1301, 1064, 480, 17119, 446, 2912, 446, 29199, 446, 88, 12124, 13, 12975, 14, 2424, 531, 819, 327, 662, 1147, 523, 862, 26, 272, 17781, 275, 1551, 480, 17119, 13, 548, 14, 2424, 401, 298, 82, 531, 523, 871, 5925, 465, 325, 26, 272, 399, 14, 705, 480, 17200, 370, 1551, 1072, 570, 283, 17119, 13, 548, 14, 2424, 356, 450, 83, 2, 450, 325, 14, 20395, 9, 523, 2385, 275, 17781, 14, 9684, 342, 523, 17781, 14, 1600, 342, 523, 367, 1004, 315, 2385, 26, 272, 27552, 14, 952, 8, 604, 9, 523, 27552, 14, 1600, 342, 523, 399, 14, 3832, 8, 16, 12, 298, 7292, 450, 68, 14361, 315, 450, 68, 5055, 2, 450, 334, 78, 12065, 12, 302, 7882, 430, 421, 199, 318, 5147, 837, 523, 408, 6756, 5253, 12981, 1041, 523, 10739, 275, 984, 14, 6626, 523, 27552, 275, 984, 14, 2703, 523, 340, 3305, 63, 13880, 26, 272, 862, 26, 489, 10739, 275, 1551, 8, 4173, 63, 13880, 12, 298, 4848, 531, 272, 871, 5925, 465, 325, 26, 489, 399, 14, 705, 480, 17200, 370, 1551, 1324, 570, 450, 83, 26, 298, 1598, 2071, 83, 2, 450, 334, 4173, 63, 13880, 12, 325, 14, 20395, 430, 523, 340, 3305, 63, 4984, 26, 272, 862, 26, 489, 27552, 275, 1551, 8, 4173, 63, 4984, 12, 298, 6603, 531, 272, 871, 5925, 465, 325, 26, 489, 399, 14, 705, 480, 17200, 370, 1551, 1072, 570, 450, 83, 26, 298, 1598, 2071, 83, 2, 450, 334, 4173, 63, 4984, 12, 325, 14, 20395, 430, 523, 5147, 63, 18872, 8, 4904, 12, 27552, 9, 523, 340, 3305, 63, 13880, 26, 272, 10739, 14, 1600, 342, 523, 340, 3305, 63, 4984, 26, 272, 27552, 14, 1600, 342, 421, 199, 318, 4503, 8, 1328, 1273, 304, 523, 408, 5375, 4503, 436, 4458, 1041, 523, 562, 275, 747, 14, 515, 14, 4846, 8, 1274, 14, 3020, 59, 16, 566, 523, 340, 1499, 1273, 26, 272, 984, 14, 3083, 14, 952, 480, 705, 26, 450, 83, 60, 78, 2, 450, 1499, 1273, 9, 523, 870, 21723, 272, 4503, 26, 221, 450, 83, 359, 1419, 61, 665, 1324, 690, 1072, 339, 1511, 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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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 ]
esikachev/scenario
sahara/tests/unit/service/edp/test_job_utils.py
1
10221
# Copyright (c) 2013 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 uuid import mock import six import testtools from sahara import conductor as cond from sahara.service.edp import job_utils from sahara.tests.unit.service.edp import edp_test_utils as u conductor = cond.API class JobUtilsTestCase(testtools.TestCase): def setUp(self): super(JobUtilsTestCase, self).setUp() def test_args_may_contain_data_sources(self): job_configs = None # No configs, default false by_name, by_uuid = job_utils.may_contain_data_source_refs(job_configs) self.assertFalse(by_name | by_uuid) # Empty configs, default false job_configs = {'configs': {}} by_name, by_uuid = job_utils.may_contain_data_source_refs(job_configs) self.assertFalse(by_name | by_uuid) job_configs['configs'] = {job_utils.DATA_SOURCE_SUBST_NAME: True, job_utils.DATA_SOURCE_SUBST_UUID: True} by_name, by_uuid = job_utils.may_contain_data_source_refs(job_configs) self.assertTrue(by_name & by_uuid) job_configs['configs'][job_utils.DATA_SOURCE_SUBST_NAME] = False by_name, by_uuid = job_utils.may_contain_data_source_refs(job_configs) self.assertFalse(by_name) self.assertTrue(by_uuid) job_configs['configs'][job_utils.DATA_SOURCE_SUBST_UUID] = False by_name, by_uuid = job_utils.may_contain_data_source_refs(job_configs) self.assertFalse(by_name | by_uuid) job_configs['configs'] = {job_utils.DATA_SOURCE_SUBST_NAME: 'True', job_utils.DATA_SOURCE_SUBST_UUID: 'Fish'} by_name, by_uuid = job_utils.may_contain_data_source_refs(job_configs) self.assertTrue(by_name) self.assertFalse(by_uuid) def test_find_possible_data_source_refs_by_name(self): id = six.text_type(uuid.uuid4()) job_configs = {} self.assertEqual([], job_utils.find_possible_data_source_refs_by_name( job_configs)) name_ref = job_utils.DATA_SOURCE_PREFIX+'name' name_ref2 = name_ref+'2' job_configs = {'args': ['first', id], 'configs': {'config': 'value'}, 'params': {'param': 'value'}} self.assertEqual([], job_utils.find_possible_data_source_refs_by_name( job_configs)) job_configs = {'args': [name_ref, id], 'configs': {'config': 'value'}, 'params': {'param': 'value'}} self.assertEqual( ['name'], job_utils.find_possible_data_source_refs_by_name(job_configs)) job_configs = {'args': ['first', id], 'configs': {'config': name_ref}, 'params': {'param': 'value'}} self.assertEqual( ['name'], job_utils.find_possible_data_source_refs_by_name(job_configs)) job_configs = {'args': ['first', id], 'configs': {'config': 'value'}, 'params': {'param': name_ref}} self.assertEqual( ['name'], job_utils.find_possible_data_source_refs_by_name(job_configs)) job_configs = {'args': [name_ref, name_ref2, id], 'configs': {'config': name_ref}, 'params': {'param': name_ref}} self.assertItemsEqual( ['name', 'name2'], job_utils.find_possible_data_source_refs_by_name(job_configs)) def test_find_possible_data_source_refs_by_uuid(self): job_configs = {} name_ref = job_utils.DATA_SOURCE_PREFIX+'name' self.assertEqual([], job_utils.find_possible_data_source_refs_by_uuid( job_configs)) id = six.text_type(uuid.uuid4()) job_configs = {'args': ['first', name_ref], 'configs': {'config': 'value'}, 'params': {'param': 'value'}} self.assertEqual([], job_utils.find_possible_data_source_refs_by_uuid( job_configs)) job_configs = {'args': [id, name_ref], 'configs': {'config': 'value'}, 'params': {'param': 'value'}} self.assertEqual( [id], job_utils.find_possible_data_source_refs_by_uuid(job_configs)) job_configs = {'args': ['first', name_ref], 'configs': {'config': id}, 'params': {'param': 'value'}} self.assertEqual( [id], job_utils.find_possible_data_source_refs_by_uuid(job_configs)) job_configs = {'args': ['first', name_ref], 'configs': {'config': 'value'}, 'params': {'param': id}} self.assertEqual( [id], job_utils.find_possible_data_source_refs_by_uuid(job_configs)) id2 = six.text_type(uuid.uuid4()) job_configs = {'args': [id, id2, name_ref], 'configs': {'config': id}, 'params': {'param': id}} self.assertItemsEqual([id, id2], job_utils.find_possible_data_source_refs_by_uuid( job_configs)) @mock.patch('sahara.context.ctx') @mock.patch('sahara.conductor.API.data_source_get_all') def test_resolve_data_source_refs(self, data_source_get_all, ctx): ctx.return_value = 'dummy' name_ref = job_utils.DATA_SOURCE_PREFIX+'input' input = u.create_data_source("swift://container/input", name="input", id=six.text_type(uuid.uuid4())) output = u.create_data_source("swift://container/output", name="output", id=six.text_type(uuid.uuid4())) by_name = {'input': input, 'output': output} by_id = {input.id: input, output.id: output} # Pretend to be the database def _get_all(ctx, **kwargs): name = kwargs.get('name') if name in by_name: name_list = [by_name[name]] else: name_list = [] id = kwargs.get('id') if id in by_id: id_list = [by_id[id]] else: id_list = [] return list(set(name_list + id_list)) data_source_get_all.side_effect = _get_all job_configs = { 'configs': { job_utils.DATA_SOURCE_SUBST_NAME: True, job_utils.DATA_SOURCE_SUBST_UUID: True}, 'args': [name_ref, output.id, input.id]} ds, nc = job_utils.resolve_data_source_references(job_configs) self.assertEqual(len(ds), 2) self.assertEqual(nc['args'], [input.url, output.url, input.url]) # Swift configs should be filled in since they were blank self.assertEqual(nc['configs']['fs.swift.service.sahara.username'], input.credentials['user']) self.assertEqual(nc['configs']['fs.swift.service.sahara.password'], input.credentials['password']) job_configs['configs'] = {'fs.swift.service.sahara.username': 'sam', 'fs.swift.service.sahara.password': 'gamgee', job_utils.DATA_SOURCE_SUBST_NAME: False, job_utils.DATA_SOURCE_SUBST_UUID: True} ds, nc = job_utils.resolve_data_source_references(job_configs) self.assertEqual(len(ds), 2) self.assertEqual(nc['args'], [name_ref, output.url, input.url]) # Swift configs should not be overwritten self.assertEqual(nc['configs'], job_configs['configs']) job_configs['configs'] = {job_utils.DATA_SOURCE_SUBST_NAME: True, job_utils.DATA_SOURCE_SUBST_UUID: False} job_configs['proxy_configs'] = {'proxy_username': 'john', 'proxy_password': 'smith', 'proxy_trust_id': 'trustme'} ds, nc = job_utils.resolve_data_source_references(job_configs) self.assertEqual(len(ds), 1) self.assertEqual(nc['args'], [input.url, output.id, input.id]) # Swift configs should be empty and proxy configs should be preserved self.assertEqual(nc['configs'], job_configs['configs']) self.assertEqual(nc['proxy_configs'], job_configs['proxy_configs']) # Substitution not enabled job_configs['configs'] = {job_utils.DATA_SOURCE_SUBST_NAME: False, job_utils.DATA_SOURCE_SUBST_UUID: False} ds, nc = job_utils.resolve_data_source_references(job_configs) self.assertEqual(len(ds), 0) self.assertEqual(nc['args'], job_configs['args']) self.assertEqual(nc['configs'], job_configs['configs']) # Substitution enabled but no values to modify job_configs['configs'] = {job_utils.DATA_SOURCE_SUBST_NAME: True, job_utils.DATA_SOURCE_SUBST_UUID: True} job_configs['args'] = ['val1', 'val2', 'val3'] ds, nc = job_utils.resolve_data_source_references(job_configs) self.assertEqual(len(ds), 0) self.assertEqual(nc['args'], job_configs['args']) self.assertEqual(nc['configs'], job_configs['configs'])
apache-2.0
[ 3, 1898, 334, 67, 9, 6171, 603, 723, 4466, 83, 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, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 5377, 199, 199, 646, 1683, 199, 646, 3816, 199, 646, 30741, 199, 199, 504, 2937, 27314, 492, 406, 19966, 465, 9288, 199, 504, 2937, 27314, 14, 1364, 14, 379, 80, 492, 3906, 63, 1208, 199, 504, 2937, 27314, 14, 2219, 14, 3248, 14, 1364, 14, 379, 80, 492, 3988, 80, 63, 396, 63, 1208, 465, 399, 199, 199, 28678, 275, 9288, 14, 3735, 421, 199, 533, 15057, 7535, 1746, 8, 396, 2537, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 6694, 7535, 1746, 12, 291, 680, 5996, 342, 339, 347, 511, 63, 589, 63, 7551, 63, 7747, 63, 576, 63, 4553, 8, 277, 304, 267, 3906, 63, 7532, 275, 488, 398, 327, 3091, 11585, 12, 849, 3055, 267, 701, 63, 354, 12, 701, 63, 2580, 275, 3906, 63, 1208, 14, 7551, 63, 7747, 63, 576, 63, 1365, 63, 7655, 8, 2423, 63, 7532, 9, 267, 291, 14, 3334, 8, 991, 63, 354, 1204, 701, 63, 2580, 9, 398, 327, 9630, 11585, 12, 849, 3055, 267, 3906, 63, 7532, 275, 791, 7532, 356, 24312, 267, 701, 63, 354, 12, 701, 63, 2580, 275, 3906, 63, 1208, 14, 7551, 63, 7747, 63, 576, 63, 1365, 63, 7655, 8, 2423, 63, 7532, 9, 267, 291, 14, 3334, 8, 991, 63, 354, 1204, 701, 63, 2580, 9, 398, 3906, 63, 7532, 459, 7532, 418, 275, 469, 2423, 63, 1208, 14, 3998, 63, 10187, 63, 6348, 840, 63, 2339, 26, 715, 12, 3303, 3906, 63, 1208, 14, 3998, 63, 10187, 63, 6348, 840, 63, 8757, 26, 715, 93, 267, 701, 63, 354, 12, 701, 63, 2580, 275, 3906, 63, 1208, 14, 7551, 63, 7747, 63, 576, 63, 1365, 63, 7655, 8, 2423, 63, 7532, 9, 267, 291, 14, 1815, 8, 991, 63, 354, 1253, 701, 63, 2580, 9, 398, 3906, 63, 7532, 459, 7532, 3488, 2423, 63, 1208, 14, 3998, 63, 10187, 63, 6348, 840, 63, 2339, 61, 275, 756, 267, 701, 63, 354, 12, 701, 63, 2580, 275, 3906, 63, 1208, 14, 7551, 63, 7747, 63, 576, 63, 1365, 63, 7655, 8, 2423, 63, 7532, 9, 267, 291, 14, 3334, 8, 991, 63, 354, 9, 267, 291, 14, 1815, 8, 991, 63, 2580, 9, 398, 3906, 63, 7532, 459, 7532, 3488, 2423, 63, 1208, 14, 3998, 63, 10187, 63, 6348, 840, 63, 8757, 61, 275, 756, 267, 701, 63, 354, 12, 701, 63, 2580, 275, 3906, 63, 1208, 14, 7551, 63, 7747, 63, 576, 63, 1365, 63, 7655, 8, 2423, 63, 7532, 9, 267, 291, 14, 3334, 8, 991, 63, 354, 1204, 701, 63, 2580, 9, 398, 3906, 63, 7532, 459, 7532, 418, 275, 469, 2423, 63, 1208, 14, 3998, 63, 10187, 63, 6348, 840, 63, 2339, 26, 283, 549, 297, 3303, 3906, 63, 1208, 14, 3998, 63, 10187, 63, 6348, 840, 63, 8757, 26, 283, 38, 2453, 936, 267, 701, 63, 354, 12, 701, 63, 2580, 275, 3906, 63, 1208, 14, 7551, 63, 7747, 63, 576, 63, 1365, 63, 7655, 8, 2423, 63, 7532, 9, 267, 291, 14, 1815, 8, 991, 63, 354, 9, 267, 291, 14, 3334, 8, 991, 63, 2580, 9, 339, 347, 511, 63, 1623, 63, 13893, 63, 576, 63, 1365, 63, 7655, 63, 991, 63, 354, 8, 277, 304, 267, 1305, 275, 3816, 14, 505, 63, 466, 8, 2580, 14, 2580, 20, 1012, 267, 3906, 63, 7532, 275, 1052, 267, 291, 14, 629, 8798, 586, 3906, 63, 1208, 14, 1623, 63, 13893, 63, 576, 63, 1365, 63, 7655, 63, 991, 63, 354, 8, 2490, 3906, 63, 7532, 430, 398, 536, 63, 1121, 275, 3906, 63, 1208, 14, 3998, 63, 10187, 63, 6351, 4786, 354, 7, 267, 536, 63, 1121, 18, 275, 536, 63, 1121, 4786, 18, 7, 398, 3906, 63, 7532, 275, 791, 589, 356, 788, 2246, 297, 1305, 467, 2432, 283, 7532, 356, 791, 888, 356, 283, 585, 2267, 2432, 283, 1162, 356, 791, 635, 356, 283, 585, 18620, 267, 291, 14, 629, 8798, 586, 3906, 63, 1208, 14, 1623, 63, 13893, 63, 576, 63, 1365, 63, 7655, 63, 991, 63, 354, 8, 2490, 3906, 63, 7532, 430, 398, 3906, 63, 7532, 275, 791, 589, 356, 359, 354, 63, 1121, 12, 1305, 467, 2432, 283, 7532, 356, 791, 888, 356, 283, 585, 2267, 2432, 283, 1162, 356, 791, 635, 356, 283, 585, 18620, 267, 291, 14, 629, 8, 288, 788, 354, 995, 288, 3906, 63, 1208, 14, 1623, 63, 13893, 63, 576, 63, 1365, 63, 7655, 63, 991, 63, 354, 8, 2423, 63, 7532, 430, 398, 3906, 63, 7532, 275, 791, 589, 356, 788, 2246, 297, 1305, 467, 2432, 283, 7532, 356, 791, 888, 356, 536, 63, 1121, 1386, 2432, 283, 1162, 356, 791, 635, 356, 283, 585, 18620, 267, 291, 14, 629, 8, 288, 788, 354, 995, 288, 3906, 63, 1208, 14, 1623, 63, 13893, 63, 576, 63, 1365, 63, 7655, 63, 991, 63, 354, 8, 2423, 63, 7532, 430, 398, 3906, 63, 7532, 275, 791, 589, 356, 788, 2246, 297, 1305, 467, 2432, 283, 7532, 356, 791, 888, 356, 283, 585, 2267, 2432, 283, 1162, 356, 791, 635, 356, 536, 63, 1121, 4863, 267, 291, 14, 629, 8, 288, 788, 354, 995, 288, 3906, 63, 1208, 14, 1623, 63, 13893, 63, 576, 63, 1365, 63, 7655, 63, 991, 63, 354, 8, 2423, 63, 7532, 430, 398, 3906, 63 ]
[ 1898, 334, 67, 9, 6171, 603, 723, 4466, 83, 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, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 5377, 199, 199, 646, 1683, 199, 646, 3816, 199, 646, 30741, 199, 199, 504, 2937, 27314, 492, 406, 19966, 465, 9288, 199, 504, 2937, 27314, 14, 1364, 14, 379, 80, 492, 3906, 63, 1208, 199, 504, 2937, 27314, 14, 2219, 14, 3248, 14, 1364, 14, 379, 80, 492, 3988, 80, 63, 396, 63, 1208, 465, 399, 199, 199, 28678, 275, 9288, 14, 3735, 421, 199, 533, 15057, 7535, 1746, 8, 396, 2537, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 6694, 7535, 1746, 12, 291, 680, 5996, 342, 339, 347, 511, 63, 589, 63, 7551, 63, 7747, 63, 576, 63, 4553, 8, 277, 304, 267, 3906, 63, 7532, 275, 488, 398, 327, 3091, 11585, 12, 849, 3055, 267, 701, 63, 354, 12, 701, 63, 2580, 275, 3906, 63, 1208, 14, 7551, 63, 7747, 63, 576, 63, 1365, 63, 7655, 8, 2423, 63, 7532, 9, 267, 291, 14, 3334, 8, 991, 63, 354, 1204, 701, 63, 2580, 9, 398, 327, 9630, 11585, 12, 849, 3055, 267, 3906, 63, 7532, 275, 791, 7532, 356, 24312, 267, 701, 63, 354, 12, 701, 63, 2580, 275, 3906, 63, 1208, 14, 7551, 63, 7747, 63, 576, 63, 1365, 63, 7655, 8, 2423, 63, 7532, 9, 267, 291, 14, 3334, 8, 991, 63, 354, 1204, 701, 63, 2580, 9, 398, 3906, 63, 7532, 459, 7532, 418, 275, 469, 2423, 63, 1208, 14, 3998, 63, 10187, 63, 6348, 840, 63, 2339, 26, 715, 12, 3303, 3906, 63, 1208, 14, 3998, 63, 10187, 63, 6348, 840, 63, 8757, 26, 715, 93, 267, 701, 63, 354, 12, 701, 63, 2580, 275, 3906, 63, 1208, 14, 7551, 63, 7747, 63, 576, 63, 1365, 63, 7655, 8, 2423, 63, 7532, 9, 267, 291, 14, 1815, 8, 991, 63, 354, 1253, 701, 63, 2580, 9, 398, 3906, 63, 7532, 459, 7532, 3488, 2423, 63, 1208, 14, 3998, 63, 10187, 63, 6348, 840, 63, 2339, 61, 275, 756, 267, 701, 63, 354, 12, 701, 63, 2580, 275, 3906, 63, 1208, 14, 7551, 63, 7747, 63, 576, 63, 1365, 63, 7655, 8, 2423, 63, 7532, 9, 267, 291, 14, 3334, 8, 991, 63, 354, 9, 267, 291, 14, 1815, 8, 991, 63, 2580, 9, 398, 3906, 63, 7532, 459, 7532, 3488, 2423, 63, 1208, 14, 3998, 63, 10187, 63, 6348, 840, 63, 8757, 61, 275, 756, 267, 701, 63, 354, 12, 701, 63, 2580, 275, 3906, 63, 1208, 14, 7551, 63, 7747, 63, 576, 63, 1365, 63, 7655, 8, 2423, 63, 7532, 9, 267, 291, 14, 3334, 8, 991, 63, 354, 1204, 701, 63, 2580, 9, 398, 3906, 63, 7532, 459, 7532, 418, 275, 469, 2423, 63, 1208, 14, 3998, 63, 10187, 63, 6348, 840, 63, 2339, 26, 283, 549, 297, 3303, 3906, 63, 1208, 14, 3998, 63, 10187, 63, 6348, 840, 63, 8757, 26, 283, 38, 2453, 936, 267, 701, 63, 354, 12, 701, 63, 2580, 275, 3906, 63, 1208, 14, 7551, 63, 7747, 63, 576, 63, 1365, 63, 7655, 8, 2423, 63, 7532, 9, 267, 291, 14, 1815, 8, 991, 63, 354, 9, 267, 291, 14, 3334, 8, 991, 63, 2580, 9, 339, 347, 511, 63, 1623, 63, 13893, 63, 576, 63, 1365, 63, 7655, 63, 991, 63, 354, 8, 277, 304, 267, 1305, 275, 3816, 14, 505, 63, 466, 8, 2580, 14, 2580, 20, 1012, 267, 3906, 63, 7532, 275, 1052, 267, 291, 14, 629, 8798, 586, 3906, 63, 1208, 14, 1623, 63, 13893, 63, 576, 63, 1365, 63, 7655, 63, 991, 63, 354, 8, 2490, 3906, 63, 7532, 430, 398, 536, 63, 1121, 275, 3906, 63, 1208, 14, 3998, 63, 10187, 63, 6351, 4786, 354, 7, 267, 536, 63, 1121, 18, 275, 536, 63, 1121, 4786, 18, 7, 398, 3906, 63, 7532, 275, 791, 589, 356, 788, 2246, 297, 1305, 467, 2432, 283, 7532, 356, 791, 888, 356, 283, 585, 2267, 2432, 283, 1162, 356, 791, 635, 356, 283, 585, 18620, 267, 291, 14, 629, 8798, 586, 3906, 63, 1208, 14, 1623, 63, 13893, 63, 576, 63, 1365, 63, 7655, 63, 991, 63, 354, 8, 2490, 3906, 63, 7532, 430, 398, 3906, 63, 7532, 275, 791, 589, 356, 359, 354, 63, 1121, 12, 1305, 467, 2432, 283, 7532, 356, 791, 888, 356, 283, 585, 2267, 2432, 283, 1162, 356, 791, 635, 356, 283, 585, 18620, 267, 291, 14, 629, 8, 288, 788, 354, 995, 288, 3906, 63, 1208, 14, 1623, 63, 13893, 63, 576, 63, 1365, 63, 7655, 63, 991, 63, 354, 8, 2423, 63, 7532, 430, 398, 3906, 63, 7532, 275, 791, 589, 356, 788, 2246, 297, 1305, 467, 2432, 283, 7532, 356, 791, 888, 356, 536, 63, 1121, 1386, 2432, 283, 1162, 356, 791, 635, 356, 283, 585, 18620, 267, 291, 14, 629, 8, 288, 788, 354, 995, 288, 3906, 63, 1208, 14, 1623, 63, 13893, 63, 576, 63, 1365, 63, 7655, 63, 991, 63, 354, 8, 2423, 63, 7532, 430, 398, 3906, 63, 7532, 275, 791, 589, 356, 788, 2246, 297, 1305, 467, 2432, 283, 7532, 356, 791, 888, 356, 283, 585, 2267, 2432, 283, 1162, 356, 791, 635, 356, 536, 63, 1121, 4863, 267, 291, 14, 629, 8, 288, 788, 354, 995, 288, 3906, 63, 1208, 14, 1623, 63, 13893, 63, 576, 63, 1365, 63, 7655, 63, 991, 63, 354, 8, 2423, 63, 7532, 430, 398, 3906, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
codesparkle/youtube-dl
youtube_dl/extractor/tinypic.py
26
1895
from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ExtractorError class TinyPicIE(InfoExtractor): IE_NAME = 'tinypic' IE_DESC = 'tinypic.com videos' _VALID_URL = r'https?://(?:.+?\.)?tinypic\.com/player\.php\?v=(?P<id>[^&]+)&s=\d+' _TESTS = [ { 'url': 'http://tinypic.com/player.php?v=6xw7tc%3E&s=5#.UtqZmbRFCM8', 'md5': '609b74432465364e72727ebc6203f044', 'info_dict': { 'id': '6xw7tc', 'ext': 'flv', 'title': 'shadow phenomenon weird', }, }, { 'url': 'http://de.tinypic.com/player.php?v=dy90yh&s=8', 'only_matching': True, } ] def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') webpage = self._download_webpage(url, video_id, 'Downloading page') mobj = re.search(r'(?m)fo\.addVariable\("file",\s"(?P<fileid>[\da-z]+)"\);\n' '\s+fo\.addVariable\("s",\s"(?P<serverid>\d+)"\);', webpage) if mobj is None: raise ExtractorError('Video %s does not exist' % video_id, expected=True) file_id = mobj.group('fileid') server_id = mobj.group('serverid') KEYWORDS_SUFFIX = ', Video, images, photos, videos, myspace, ebay, video hosting, photo hosting' keywords = self._html_search_meta('keywords', webpage, 'title') title = keywords[:-len(KEYWORDS_SUFFIX)] if keywords.endswith(KEYWORDS_SUFFIX) else '' video_url = 'http://v%s.tinypic.com/%s.flv' % (server_id, file_id) thumbnail = 'http://v%s.tinypic.com/%s_th.jpg' % (server_id, file_id) return { 'id': file_id, 'url': video_url, 'thumbnail': thumbnail, 'title': title }
unlicense
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 19783, 421, 199, 533, 11947, 48, 530, 4332, 8, 18283, 304, 272, 15292, 63, 2339, 275, 283, 1346, 2279, 530, 7, 272, 15292, 63, 15119, 275, 283, 1346, 2279, 530, 14, 957, 22010, 7, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 11198, 20316, 1346, 2279, 530, 4537, 957, 15, 6147, 4537, 8624, 29635, 86, 29, 2229, 48, 28, 344, 13489, 6, 11896, 6, 83, 9529, 68, 4786, 339, 485, 7569, 275, 359, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 1346, 2279, 530, 14, 957, 15, 6147, 14, 8624, 31, 86, 29, 22, 88, 87, 23, 3641, 5, 19, 37, 6, 83, 29, 21, 31827, 53, 84, 81, 58, 887, 14468, 45, 24, 297, 288, 283, 1064, 21, 356, 283, 14520, 66, 1342, 10657, 22474, 22775, 69, 30624, 1465, 26816, 22, 11341, 70, 9111, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 22, 88, 87, 23, 3641, 297, 355, 283, 832, 356, 283, 22753, 297, 355, 283, 1213, 356, 283, 14714, 3945, 287, 1377, 2865, 22965, 297, 288, 1660, 267, 1660, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 271, 14, 1346, 2279, 530, 14, 957, 15, 6147, 14, 8624, 31, 86, 29, 8161, 2710, 89, 72, 6, 83, 29, 24, 297, 288, 283, 2118, 63, 9467, 356, 715, 12, 267, 789, 272, 1622, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 14208, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 3991, 63, 344, 275, 14208, 14, 923, 360, 344, 358, 398, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 12, 283, 18085, 2034, 358, 398, 14208, 275, 295, 14, 1733, 8, 82, 10120, 77, 9, 545, 4537, 525, 2773, 60, 480, 493, 22260, 83, 24726, 48, 28, 493, 344, 24693, 983, 13, 90, 2807, 2924, 60, 6152, 78, 7, 586, 1557, 83, 11, 545, 4537, 525, 2773, 60, 480, 83, 22260, 83, 24726, 48, 28, 1000, 344, 3072, 68, 20415, 60, 27853, 9248, 9, 267, 340, 14208, 365, 488, 26, 288, 746, 19783, 360, 9166, 450, 83, 1630, 440, 2187, 7, 450, 3991, 63, 344, 12, 1420, 29, 549, 9, 398, 570, 63, 344, 275, 14208, 14, 923, 360, 493, 344, 358, 267, 1654, 63, 344, 275, 14208, 14, 923, 360, 1000, 344, 358, 398, 9301, 19984, 63, 12273, 275, 1656, 15709, 12, 5935, 12, 3945, 17278, 12, 22010, 12, 333, 588, 1142, 12, 325, 19558, 12, 3991, 1591, 316, 12, 19397, 1591, 316, 7, 267, 7681, 275, 291, 423, 1360, 63, 1733, 63, 2024, 360, 7511, 297, 9248, 12, 283, 1213, 358, 267, 2538, 275, 7681, 4439, 552, 8, 32187, 63, 12273, 1874, 340, 7681, 14, 4130, 8, 32187, 63, 12273, 9, 587, 2125, 398, 3991, 63, 633, 275, 283, 1014, 921, 86, 5, 83, 14, 1346, 2279, 530, 14, 957, 3149, 83, 14, 22753, 7, 450, 334, 1000, 63, 344, 12, 570, 63, 344, 9, 267, 10062, 275, 283, 1014, 921, 86, 5, 83, 14, 1346, 2279, 530, 14, 957, 3149, 83, 63, 273, 14, 8476, 7, 450, 334, 1000, 63, 344, 12, 570, 63, 344, 9, 398, 372, 469, 288, 283, 344, 356, 570, 63, 344, 12, 288, 283, 633, 356, 3991, 63, 633, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 1213, 356, 2538, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 19783, 421, 199, 533, 11947, 48, 530, 4332, 8, 18283, 304, 272, 15292, 63, 2339, 275, 283, 1346, 2279, 530, 7, 272, 15292, 63, 15119, 275, 283, 1346, 2279, 530, 14, 957, 22010, 7, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 11198, 20316, 1346, 2279, 530, 4537, 957, 15, 6147, 4537, 8624, 29635, 86, 29, 2229, 48, 28, 344, 13489, 6, 11896, 6, 83, 9529, 68, 4786, 339, 485, 7569, 275, 359, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 1346, 2279, 530, 14, 957, 15, 6147, 14, 8624, 31, 86, 29, 22, 88, 87, 23, 3641, 5, 19, 37, 6, 83, 29, 21, 31827, 53, 84, 81, 58, 887, 14468, 45, 24, 297, 288, 283, 1064, 21, 356, 283, 14520, 66, 1342, 10657, 22474, 22775, 69, 30624, 1465, 26816, 22, 11341, 70, 9111, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 22, 88, 87, 23, 3641, 297, 355, 283, 832, 356, 283, 22753, 297, 355, 283, 1213, 356, 283, 14714, 3945, 287, 1377, 2865, 22965, 297, 288, 1660, 267, 1660, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 271, 14, 1346, 2279, 530, 14, 957, 15, 6147, 14, 8624, 31, 86, 29, 8161, 2710, 89, 72, 6, 83, 29, 24, 297, 288, 283, 2118, 63, 9467, 356, 715, 12, 267, 789, 272, 1622, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 14208, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 3991, 63, 344, 275, 14208, 14, 923, 360, 344, 358, 398, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 12, 283, 18085, 2034, 358, 398, 14208, 275, 295, 14, 1733, 8, 82, 10120, 77, 9, 545, 4537, 525, 2773, 60, 480, 493, 22260, 83, 24726, 48, 28, 493, 344, 24693, 983, 13, 90, 2807, 2924, 60, 6152, 78, 7, 586, 1557, 83, 11, 545, 4537, 525, 2773, 60, 480, 83, 22260, 83, 24726, 48, 28, 1000, 344, 3072, 68, 20415, 60, 27853, 9248, 9, 267, 340, 14208, 365, 488, 26, 288, 746, 19783, 360, 9166, 450, 83, 1630, 440, 2187, 7, 450, 3991, 63, 344, 12, 1420, 29, 549, 9, 398, 570, 63, 344, 275, 14208, 14, 923, 360, 493, 344, 358, 267, 1654, 63, 344, 275, 14208, 14, 923, 360, 1000, 344, 358, 398, 9301, 19984, 63, 12273, 275, 1656, 15709, 12, 5935, 12, 3945, 17278, 12, 22010, 12, 333, 588, 1142, 12, 325, 19558, 12, 3991, 1591, 316, 12, 19397, 1591, 316, 7, 267, 7681, 275, 291, 423, 1360, 63, 1733, 63, 2024, 360, 7511, 297, 9248, 12, 283, 1213, 358, 267, 2538, 275, 7681, 4439, 552, 8, 32187, 63, 12273, 1874, 340, 7681, 14, 4130, 8, 32187, 63, 12273, 9, 587, 2125, 398, 3991, 63, 633, 275, 283, 1014, 921, 86, 5, 83, 14, 1346, 2279, 530, 14, 957, 3149, 83, 14, 22753, 7, 450, 334, 1000, 63, 344, 12, 570, 63, 344, 9, 267, 10062, 275, 283, 1014, 921, 86, 5, 83, 14, 1346, 2279, 530, 14, 957, 3149, 83, 63, 273, 14, 8476, 7, 450, 334, 1000, 63, 344, 12, 570, 63, 344, 9, 398, 372, 469, 288, 283, 344, 356, 570, 63, 344, 12, 288, 283, 633, 356, 3991, 63, 633, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 1213, 356, 2538, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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fnmatch import fnmatch from glob import glob import os from fabric.api import prompt, task import app_config import utils @task def sync(path): """ Intelligently synchronize assets between S3 and local folder. """ ignore_globs = [] slug, abspath = utils.parse_path(path) if not os.path.exists('%s/%s' % (abspath, slug)): print 'Slug "%s" does not exist!' % slug return True assets_root = '%s/%s/assets' % (abspath, slug) s3_root = '%s/%s' % (app_config.ASSETS_SLUG, slug) try: with open('%s/assetsignore' % assets_root, 'r') as f: ignore_globs = [l.strip() for l in f] except IOError: ignore_globs = [] local_paths = [] not_lowercase = [] for local_path, subdirs, filenames in os.walk(assets_root): for name in filenames: full_path = os.path.join(local_path, name) glob_path = full_path.split(assets_root)[1].strip('/') ignore = False for ignore_glob in ignore_globs: if fnmatch(glob_path, ignore_glob): ignore = True break if ignore: print 'Ignoring: %s' % full_path continue if name.lower() != name: not_lowercase.append(full_path) local_paths.append(full_path) # Prevent case sensitivity differences between OSX and S3 # from screwing us up if not_lowercase: print 'The following filenames are not lowercase, ' \ 'please change them before running `assets.sync`. ' for name in not_lowercase: print ' %s' % name print 'WARNING: This must be fixed before you can deploy.' return True bucket = _assets_get_bucket() keys = bucket.list(s3_root) which = None always = False for key in keys: download = False upload = False local_path = key.name.replace(s3_root, assets_root, 1) # Skip root key if local_path == '%s/' % assets_root: continue print local_path if local_path in local_paths: # A file can only exist once, this speeds up future checks # and provides a list of non-existing files when complete local_paths.remove(local_path) # We need an actual key, not a "list key" # http://stackoverflow.com/a/18981298/24608 key = bucket.get_key(key.name) with open(local_path, 'rb') as f: local_md5 = key.compute_md5(f)[0] # Hashes are different if key.get_metadata('md5') != local_md5: if not always: # Ask user which file to take which, always = _assets_confirm(local_path) if not which: print 'Cancelling!' return True if which == 'remote': download = True elif which == 'local': upload = True else: download = True if download: _assets_download(key, local_path) if upload: _assets_upload(local_path, key) action = None always = False # Iterate over files that didn't exist on S3 for local_path in local_paths: key_name = local_path.replace(assets_root, s3_root, 1) key = bucket.get_key(key_name, validate=False) print local_path if not always: action, always = _assets_upload_confirm() if not action: print 'Cancelling!' return True if action == 'upload': _assets_upload(local_path, key) elif action == 'delete': _assets_delete(local_path, key) return False @task def rm(path): """ Remove an asset from s3 and locally """ bucket = _assets_get_bucket() slug = path.split('/assets')[0] static_path = '%s/%s' % (app_config.GRAPHICS_PATH, slug) assets_root = '%s/assets' % static_path real_path = '%s/%s' % (app_config.GRAPHICS_PATH, path) file_list = glob(real_path) found_folder = True # Add files in folders, instead of folders themselves (S3 doesn't have folders) while found_folder: found_folder = False for local_path in file_list: if os.path.isdir(local_path): found_folder = True file_list.remove(local_path) for path in os.listdir(local_path): file_list.append(os.path.join(local_path, path)) if len(file_list) > 0: utils.confirm("You are about to destroy %i files. Are you sure?" % len(file_list)) for local_path in file_list: print local_path if os.path.isdir(local_path): file_list.extend(os.listdir(local_path)) continue assets_slug = '%s/%s' % (app_config.ASSETS_SLUG, slug) key_name = local_path.replace(assets_root, assets_slug, 1) key = bucket.get_key(key_name) _assets_delete(local_path, key) def _assets_get_bucket(): """ Get a reference to the assets bucket. """ return utils.get_bucket(app_config.ASSETS_S3_BUCKET['bucket_name']) def _assets_confirm(local_path): """ Check with user about whether to keep local or remote file. """ print '--> This file has been changed locally and on S3.' answer = prompt('Take remote [r] Take local [l] Take all remote [ra] Take all local [la] cancel', default='c') if answer == 'r': return ('remote', False) elif answer == 'l': return ('local', False) elif answer == 'ra': return ('remote', True) elif answer == 'la': return ('local', True) return (None, False) def _assets_upload_confirm(): print '--> This file does not exist on S3.' answer = prompt('Upload local copy [u] Delete local copy [d] Upload all [ua] Delete all [da] cancel', default='c') if answer == 'u': return ('upload', False) elif answer == 'd': return ('delete', False) elif answer == 'ua': return ('upload', True) elif answer == 'da': return ('delete', True) return (None, False) def _assets_download(s3_key, local_path): """ Utility method to download a single asset from S3. """ print '--> Downloading!' dirname = os.path.dirname(local_path) if not (os.path.exists(dirname)): os.makedirs(dirname) s3_key.get_contents_to_filename(local_path) def _assets_upload(local_path, s3_key): """ Utility method to upload a single asset to S3. """ print '--> Uploading!' with open(local_path, 'rb') as f: local_md5 = s3_key.compute_md5(f)[0] s3_key.set_metadata('md5', local_md5) s3_key.set_contents_from_filename(local_path) def _assets_delete(local_path, s3_key): """ Utility method to delete assets both locally and remotely. """ print '--> Deleting!' s3_key.delete() os.remove(local_path)
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 199, 14680, 4048, 370, 314, 7604, 316, 17202, 14, 199, 624, 199, 199, 504, 15951, 492, 15951, 199, 504, 5739, 492, 5739, 199, 646, 747, 199, 199, 504, 2630, 14, 1246, 492, 8457, 12, 2120, 199, 199, 646, 1145, 63, 888, 199, 646, 3778, 199, 199, 32, 1765, 199, 318, 7604, 8, 515, 304, 272, 408, 272, 8883, 24024, 590, 31021, 17202, 3382, 428, 19, 436, 2257, 4922, 14, 272, 408, 272, 3686, 63, 15581, 275, 942, 272, 8889, 12, 19529, 275, 3778, 14, 1122, 63, 515, 8, 515, 9, 272, 340, 440, 747, 14, 515, 14, 2444, 3508, 83, 3149, 83, 7, 450, 334, 4832, 12, 8889, 2298, 267, 870, 283, 15554, 2071, 83, 2, 1630, 440, 2187, 11213, 450, 8889, 267, 372, 715, 339, 17202, 63, 1231, 275, 1543, 83, 3149, 83, 15, 12186, 7, 450, 334, 4832, 12, 8889, 9, 272, 308, 19, 63, 1231, 275, 1543, 83, 3149, 83, 7, 450, 334, 571, 63, 888, 14, 1179, 3597, 51, 63, 4929, 10134, 12, 8889, 9, 339, 862, 26, 267, 543, 1551, 3508, 83, 15, 6562, 1037, 720, 7, 450, 17202, 63, 1231, 12, 283, 82, 358, 465, 289, 26, 288, 3686, 63, 15581, 275, 359, 76, 14, 1913, 342, 367, 634, 315, 289, 61, 272, 871, 5925, 26, 267, 3686, 63, 15581, 275, 942, 339, 2257, 63, 3771, 275, 942, 272, 440, 63, 21636, 275, 942, 339, 367, 2257, 63, 515, 12, 31396, 12, 6203, 315, 747, 14, 7757, 8, 12186, 63, 1231, 304, 267, 367, 536, 315, 6203, 26, 288, 2615, 63, 515, 275, 747, 14, 515, 14, 904, 8, 1832, 63, 515, 12, 536, 9, 288, 5739, 63, 515, 275, 2615, 63, 515, 14, 1294, 8, 12186, 63, 1231, 2788, 17, 1055, 1913, 7825, 953, 3686, 275, 756, 953, 367, 3686, 63, 6463, 315, 3686, 63, 15581, 26, 355, 340, 15951, 8, 6463, 63, 515, 12, 3686, 63, 6463, 304, 490, 3686, 275, 715, 490, 2059, 953, 340, 3686, 26, 355, 870, 283, 32390, 26, 450, 83, 7, 450, 2615, 63, 515, 355, 1980, 953, 340, 536, 14, 2325, 342, 1137, 536, 26, 355, 440, 63, 21636, 14, 740, 8, 2861, 63, 515, 9, 953, 2257, 63, 3771, 14, 740, 8, 2861, 63, 515, 9, 339, 327, 29861, 1930, 4334, 20635, 15109, 3382, 32144, 436, 428, 19, 272, 327, 687, 308, 1353, 87, 316, 2739, 1536, 272, 340, 440, 63, 21636, 26, 267, 870, 283, 1918, 2569, 6203, 787, 440, 12141, 12, 283, 971, 288, 283, 27567, 1570, 3062, 2544, 3879, 658, 12186, 14, 5186, 2313, 283, 267, 367, 536, 315, 440, 63, 21636, 26, 288, 870, 283, 259, 450, 83, 7, 450, 536, 398, 870, 283, 9171, 26, 961, 1471, 506, 6317, 2544, 1265, 883, 12287, 3530, 267, 372, 715, 339, 5315, 275, 485, 12186, 63, 362, 63, 4623, 342, 272, 2883, 275, 5315, 14, 513, 8, 83, 19, 63, 1231, 9, 339, 1314, 275, 488, 272, 3544, 275, 756, 339, 367, 790, 315, 2883, 26, 267, 5235, 275, 756, 267, 5802, 275, 756, 398, 2257, 63, 515, 275, 790, 14, 354, 14, 1814, 8, 83, 19, 63, 1231, 12, 17202, 63, 1231, 12, 413, 9, 398, 327, 8232, 1738, 790, 267, 340, 2257, 63, 515, 508, 1543, 83, 4805, 450, 17202, 63, 1231, 26, 288, 1980, 398, 870, 2257, 63, 515, 398, 340, 2257, 63, 515, 315, 2257, 63, 3771, 26, 288, 327, 437, 570, 883, 1454, 2187, 5403, 12, 642, 8112, 83, 1536, 6466, 5920, 288, 327, 436, 6571, 282, 769, 402, 2222, 13, 5952, 1584, 1380, 4890, 288, 2257, 63, 3771, 14, 2168, 8, 1832, 63, 515, 9, 953, 327, 2136, 1929, 376, 3503, 790, 12, 440, 282, 298, 513, 790, 2, 288, 327, 1455, 921, 23153, 14, 957, 15, 65, 15, 1085, 2905, 713, 2905, 15, 11440, 2036, 288, 790, 275, 5315, 14, 362, 63, 498, 8, 498, 14, 354, 9, 953, 543, 1551, 8, 1832, 63, 515, 12, 283, 4848, 358, 465, 289, 26, 355, 2257, 63, 1064, 21, 275, 790, 14, 3357, 63, 1064, 21, 8, 70, 2788, 16, 61, 953, 327, 869, 9030, 787, 3365, 288, 340, 790, 14, 362, 63, 2343, 360, 1064, 21, 358, 1137, 2257, 63, 1064, 21, 26, 355, 340, 440, 3544, 26, 490, 327, 30481, 922, 1314, 570, 370, 5452, 490, 1314, 12, 3544, 275, 485, 12186, 63, 9548, 8, 1832, 63, 515, 9, 2234, 340, 440, 1314, 26, 490, 870, 283, 35, 554, 10564, 11213, 4951, 372, 715, 2234, 340, 1314, 508, 283, 3846, 356, 490, 5235, 275, 715, 355, 916, 1314, 508, 283, 1832, 356, 490, 5802, 275, 715, 267, 587, 26, 288, 5235, 275, 715, 398, 340, 5235, 26, 288, 485, 12186, 63, 4249, 8, 498, 12, 2257, 63, 515, 9, 398, 340, 5802, 26, 288, 485, 12186, 63, 5064, 8, 1832, 63, 515, 12, 790, 9, 339, 1595, 275, 488, 272, 3544, 275, 756, 339, 327, 23989, 1806, 1584, 626, 9980, 1133, 2187, 641, 428, 19, 272, 367, 2257, 63, 515, 315, 2257, 63, 3771, 26, 267, 790, 63, 354, 275, 2257, 63, 515, 14, 1814, 8, 12186, 63, 1231, 12, 308, 19, 63, 1231, 12, 413, 9, 267, 790, 275, 5315, 14, 362, 63, 498, 8, 498, 63, 354, 12, 4107, 29, 797, 9, 398, 870, 2257, 63, 515, 398, 340, 440, 3544, 26, 288, 1595, 12, 3544, 275, 485, 12186, 63, 5064, 63, 9548, 342, 398, 340, 440, 1595, 26, 288, 870, 283, 35, 554, 10564, 11213, 953, 372, 715, 398, 340, 1595, 508, 283, 5064, 356, 288, 485, 12186, 63, 5064, 8, 1832, 63, 515, 12, 790, 9, 267, 916, 1595, 508, 283, 1807, 356, 288, 485, 12186, 63, 1807, 8, 1832, 63, 515, 12, 790, 9, 339, 372, 756, 199, 199, 32, 1765, 199, 318, 14267, 8, 515, 304, 272, 408, 272, 5852, 376, 8977, 687, 308, 19, 436, 17738, 272, 408, 272, 5315, 275, 485, 12186, 63, 362, 63, 4623, 342, 339, 8889, 275, 931, 14, 1294, 2336, 12186, 5832, 16, 61, 272, 2955, 63, 515, 275, 1543, 83, 3149, 83, 7, 450, 334, 571, 63, 888, 14, 25302, 21174, 63, 3243, 12, 8889, 9, 272 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 199, 14680, 4048, 370, 314, 7604, 316, 17202, 14, 199, 624, 199, 199, 504, 15951, 492, 15951, 199, 504, 5739, 492, 5739, 199, 646, 747, 199, 199, 504, 2630, 14, 1246, 492, 8457, 12, 2120, 199, 199, 646, 1145, 63, 888, 199, 646, 3778, 199, 199, 32, 1765, 199, 318, 7604, 8, 515, 304, 272, 408, 272, 8883, 24024, 590, 31021, 17202, 3382, 428, 19, 436, 2257, 4922, 14, 272, 408, 272, 3686, 63, 15581, 275, 942, 272, 8889, 12, 19529, 275, 3778, 14, 1122, 63, 515, 8, 515, 9, 272, 340, 440, 747, 14, 515, 14, 2444, 3508, 83, 3149, 83, 7, 450, 334, 4832, 12, 8889, 2298, 267, 870, 283, 15554, 2071, 83, 2, 1630, 440, 2187, 11213, 450, 8889, 267, 372, 715, 339, 17202, 63, 1231, 275, 1543, 83, 3149, 83, 15, 12186, 7, 450, 334, 4832, 12, 8889, 9, 272, 308, 19, 63, 1231, 275, 1543, 83, 3149, 83, 7, 450, 334, 571, 63, 888, 14, 1179, 3597, 51, 63, 4929, 10134, 12, 8889, 9, 339, 862, 26, 267, 543, 1551, 3508, 83, 15, 6562, 1037, 720, 7, 450, 17202, 63, 1231, 12, 283, 82, 358, 465, 289, 26, 288, 3686, 63, 15581, 275, 359, 76, 14, 1913, 342, 367, 634, 315, 289, 61, 272, 871, 5925, 26, 267, 3686, 63, 15581, 275, 942, 339, 2257, 63, 3771, 275, 942, 272, 440, 63, 21636, 275, 942, 339, 367, 2257, 63, 515, 12, 31396, 12, 6203, 315, 747, 14, 7757, 8, 12186, 63, 1231, 304, 267, 367, 536, 315, 6203, 26, 288, 2615, 63, 515, 275, 747, 14, 515, 14, 904, 8, 1832, 63, 515, 12, 536, 9, 288, 5739, 63, 515, 275, 2615, 63, 515, 14, 1294, 8, 12186, 63, 1231, 2788, 17, 1055, 1913, 7825, 953, 3686, 275, 756, 953, 367, 3686, 63, 6463, 315, 3686, 63, 15581, 26, 355, 340, 15951, 8, 6463, 63, 515, 12, 3686, 63, 6463, 304, 490, 3686, 275, 715, 490, 2059, 953, 340, 3686, 26, 355, 870, 283, 32390, 26, 450, 83, 7, 450, 2615, 63, 515, 355, 1980, 953, 340, 536, 14, 2325, 342, 1137, 536, 26, 355, 440, 63, 21636, 14, 740, 8, 2861, 63, 515, 9, 953, 2257, 63, 3771, 14, 740, 8, 2861, 63, 515, 9, 339, 327, 29861, 1930, 4334, 20635, 15109, 3382, 32144, 436, 428, 19, 272, 327, 687, 308, 1353, 87, 316, 2739, 1536, 272, 340, 440, 63, 21636, 26, 267, 870, 283, 1918, 2569, 6203, 787, 440, 12141, 12, 283, 971, 288, 283, 27567, 1570, 3062, 2544, 3879, 658, 12186, 14, 5186, 2313, 283, 267, 367, 536, 315, 440, 63, 21636, 26, 288, 870, 283, 259, 450, 83, 7, 450, 536, 398, 870, 283, 9171, 26, 961, 1471, 506, 6317, 2544, 1265, 883, 12287, 3530, 267, 372, 715, 339, 5315, 275, 485, 12186, 63, 362, 63, 4623, 342, 272, 2883, 275, 5315, 14, 513, 8, 83, 19, 63, 1231, 9, 339, 1314, 275, 488, 272, 3544, 275, 756, 339, 367, 790, 315, 2883, 26, 267, 5235, 275, 756, 267, 5802, 275, 756, 398, 2257, 63, 515, 275, 790, 14, 354, 14, 1814, 8, 83, 19, 63, 1231, 12, 17202, 63, 1231, 12, 413, 9, 398, 327, 8232, 1738, 790, 267, 340, 2257, 63, 515, 508, 1543, 83, 4805, 450, 17202, 63, 1231, 26, 288, 1980, 398, 870, 2257, 63, 515, 398, 340, 2257, 63, 515, 315, 2257, 63, 3771, 26, 288, 327, 437, 570, 883, 1454, 2187, 5403, 12, 642, 8112, 83, 1536, 6466, 5920, 288, 327, 436, 6571, 282, 769, 402, 2222, 13, 5952, 1584, 1380, 4890, 288, 2257, 63, 3771, 14, 2168, 8, 1832, 63, 515, 9, 953, 327, 2136, 1929, 376, 3503, 790, 12, 440, 282, 298, 513, 790, 2, 288, 327, 1455, 921, 23153, 14, 957, 15, 65, 15, 1085, 2905, 713, 2905, 15, 11440, 2036, 288, 790, 275, 5315, 14, 362, 63, 498, 8, 498, 14, 354, 9, 953, 543, 1551, 8, 1832, 63, 515, 12, 283, 4848, 358, 465, 289, 26, 355, 2257, 63, 1064, 21, 275, 790, 14, 3357, 63, 1064, 21, 8, 70, 2788, 16, 61, 953, 327, 869, 9030, 787, 3365, 288, 340, 790, 14, 362, 63, 2343, 360, 1064, 21, 358, 1137, 2257, 63, 1064, 21, 26, 355, 340, 440, 3544, 26, 490, 327, 30481, 922, 1314, 570, 370, 5452, 490, 1314, 12, 3544, 275, 485, 12186, 63, 9548, 8, 1832, 63, 515, 9, 2234, 340, 440, 1314, 26, 490, 870, 283, 35, 554, 10564, 11213, 4951, 372, 715, 2234, 340, 1314, 508, 283, 3846, 356, 490, 5235, 275, 715, 355, 916, 1314, 508, 283, 1832, 356, 490, 5802, 275, 715, 267, 587, 26, 288, 5235, 275, 715, 398, 340, 5235, 26, 288, 485, 12186, 63, 4249, 8, 498, 12, 2257, 63, 515, 9, 398, 340, 5802, 26, 288, 485, 12186, 63, 5064, 8, 1832, 63, 515, 12, 790, 9, 339, 1595, 275, 488, 272, 3544, 275, 756, 339, 327, 23989, 1806, 1584, 626, 9980, 1133, 2187, 641, 428, 19, 272, 367, 2257, 63, 515, 315, 2257, 63, 3771, 26, 267, 790, 63, 354, 275, 2257, 63, 515, 14, 1814, 8, 12186, 63, 1231, 12, 308, 19, 63, 1231, 12, 413, 9, 267, 790, 275, 5315, 14, 362, 63, 498, 8, 498, 63, 354, 12, 4107, 29, 797, 9, 398, 870, 2257, 63, 515, 398, 340, 440, 3544, 26, 288, 1595, 12, 3544, 275, 485, 12186, 63, 5064, 63, 9548, 342, 398, 340, 440, 1595, 26, 288, 870, 283, 35, 554, 10564, 11213, 953, 372, 715, 398, 340, 1595, 508, 283, 5064, 356, 288, 485, 12186, 63, 5064, 8, 1832, 63, 515, 12, 790, 9, 267, 916, 1595, 508, 283, 1807, 356, 288, 485, 12186, 63, 1807, 8, 1832, 63, 515, 12, 790, 9, 339, 372, 756, 199, 199, 32, 1765, 199, 318, 14267, 8, 515, 304, 272, 408, 272, 5852, 376, 8977, 687, 308, 19, 436, 17738, 272, 408, 272, 5315, 275, 485, 12186, 63, 362, 63, 4623, 342, 339, 8889, 275, 931, 14, 1294, 2336, 12186, 5832, 16, 61, 272, 2955, 63, 515, 275, 1543, 83, 3149, 83, 7, 450, 334, 571, 63, 888, 14, 25302, 21174, 63, 3243, 12, 8889, 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,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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 ]
Djabbz/scikit-learn
benchmarks/bench_plot_nmf.py
90
5742
""" Benchmarks of Non-Negative Matrix Factorization """ from __future__ import print_function from collections import defaultdict import gc from time import time import numpy as np from scipy.linalg import norm from sklearn.decomposition.nmf import NMF, _initialize_nmf from sklearn.datasets.samples_generator import make_low_rank_matrix from sklearn.externals.six.moves import xrange def alt_nnmf(V, r, max_iter=1000, tol=1e-3, init='random'): ''' A, S = nnmf(X, r, tol=1e-3, R=None) Implement Lee & Seung's algorithm Parameters ---------- V : 2-ndarray, [n_samples, n_features] input matrix r : integer number of latent features max_iter : integer, optional maximum number of iterations (default: 1000) tol : double tolerance threshold for early exit (when the update factor is within tol of 1., the function exits) init : string Method used to initialize the procedure. Returns ------- A : 2-ndarray, [n_samples, r] Component part of the factorization S : 2-ndarray, [r, n_features] Data part of the factorization Reference --------- "Algorithms for Non-negative Matrix Factorization" by Daniel D Lee, Sebastian H Seung (available at http://citeseer.ist.psu.edu/lee01algorithms.html) ''' # Nomenclature in the function follows Lee & Seung eps = 1e-5 n, m = V.shape W, H = _initialize_nmf(V, r, init, random_state=0) for i in xrange(max_iter): updateH = np.dot(W.T, V) / (np.dot(np.dot(W.T, W), H) + eps) H *= updateH updateW = np.dot(V, H.T) / (np.dot(W, np.dot(H, H.T)) + eps) W *= updateW if i % 10 == 0: max_update = max(updateW.max(), updateH.max()) if abs(1. - max_update) < tol: break return W, H def report(error, time): print("Frobenius loss: %.5f" % error) print("Took: %.2fs" % time) print() def benchmark(samples_range, features_range, rank=50, tolerance=1e-5): timeset = defaultdict(lambda: []) err = defaultdict(lambda: []) for n_samples in samples_range: for n_features in features_range: print("%2d samples, %2d features" % (n_samples, n_features)) print('=======================') X = np.abs(make_low_rank_matrix(n_samples, n_features, effective_rank=rank, tail_strength=0.2)) gc.collect() print("benchmarking nndsvd-nmf: ") tstart = time() m = NMF(n_components=30, tol=tolerance, init='nndsvd').fit(X) tend = time() - tstart timeset['nndsvd-nmf'].append(tend) err['nndsvd-nmf'].append(m.reconstruction_err_) report(m.reconstruction_err_, tend) gc.collect() print("benchmarking nndsvda-nmf: ") tstart = time() m = NMF(n_components=30, init='nndsvda', tol=tolerance).fit(X) tend = time() - tstart timeset['nndsvda-nmf'].append(tend) err['nndsvda-nmf'].append(m.reconstruction_err_) report(m.reconstruction_err_, tend) gc.collect() print("benchmarking nndsvdar-nmf: ") tstart = time() m = NMF(n_components=30, init='nndsvdar', tol=tolerance).fit(X) tend = time() - tstart timeset['nndsvdar-nmf'].append(tend) err['nndsvdar-nmf'].append(m.reconstruction_err_) report(m.reconstruction_err_, tend) gc.collect() print("benchmarking random-nmf") tstart = time() m = NMF(n_components=30, init='random', max_iter=1000, tol=tolerance).fit(X) tend = time() - tstart timeset['random-nmf'].append(tend) err['random-nmf'].append(m.reconstruction_err_) report(m.reconstruction_err_, tend) gc.collect() print("benchmarking alt-random-nmf") tstart = time() W, H = alt_nnmf(X, r=30, init='random', tol=tolerance) tend = time() - tstart timeset['alt-random-nmf'].append(tend) err['alt-random-nmf'].append(np.linalg.norm(X - np.dot(W, H))) report(norm(X - np.dot(W, H)), tend) return timeset, err if __name__ == '__main__': from mpl_toolkits.mplot3d import axes3d # register the 3d projection axes3d import matplotlib.pyplot as plt samples_range = np.linspace(50, 500, 3).astype(np.int) features_range = np.linspace(50, 500, 3).astype(np.int) timeset, err = benchmark(samples_range, features_range) for i, results in enumerate((timeset, err)): fig = plt.figure('scikit-learn Non-Negative Matrix Factorization' 'benchmark results') ax = fig.gca(projection='3d') for c, (label, timings) in zip('rbgcm', sorted(results.iteritems())): X, Y = np.meshgrid(samples_range, features_range) Z = np.asarray(timings).reshape(samples_range.shape[0], features_range.shape[0]) # plot the actual surface ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3, color=c) # dummy point plot to stick the legend to since surface plot do not # support legends (yet?) ax.plot([1], [1], [1], color=c, label=label) ax.set_xlabel('n_samples') ax.set_ylabel('n_features') zlabel = 'Time (s)' if i == 0 else 'reconstruction error' ax.set_zlabel(zlabel) ax.legend() plt.show()
bsd-3-clause
[ 624, 199, 18644, 83, 402, 10172, 13, 15562, 8449, 27348, 2072, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 5055, 492, 10018, 199, 646, 9486, 199, 504, 900, 492, 900, 199, 199, 646, 2680, 465, 980, 199, 504, 7026, 14, 10096, 492, 6316, 199, 199, 504, 6357, 14, 31384, 14, 10756, 70, 492, 653, 13463, 12, 485, 8489, 63, 10756, 70, 199, 504, 6357, 14, 12281, 14, 3356, 63, 4679, 492, 1852, 63, 674, 63, 4648, 63, 3642, 199, 504, 6357, 14, 24688, 14, 4174, 14, 4912, 492, 4945, 421, 199, 318, 8791, 63, 4411, 11821, 8, 54, 12, 519, 12, 1390, 63, 1661, 29, 5279, 12, 9561, 29, 17, 69, 13, 19, 12, 4205, 534, 2355, 735, 272, 1449, 272, 437, 12, 428, 275, 302, 10756, 70, 8, 56, 12, 519, 12, 9561, 29, 17, 69, 13, 19, 12, 820, 29, 403, 9, 339, 22467, 491, 1024, 1253, 3240, 10335, 1159, 5563, 339, 3897, 272, 4143, 272, 812, 520, 499, 13, 8237, 12, 359, 78, 63, 3356, 12, 302, 63, 3179, 61, 267, 1324, 3634, 272, 519, 520, 3000, 267, 1329, 402, 2465, 343, 4534, 272, 1390, 63, 1661, 520, 3000, 12, 2716, 267, 5696, 1329, 402, 10615, 334, 885, 26, 5198, 9, 272, 9561, 520, 4270, 267, 13464, 8765, 367, 14670, 4458, 334, 6526, 314, 1678, 6535, 365, 4453, 267, 9561, 402, 413, 2020, 314, 805, 20100, 9, 272, 4205, 520, 1059, 267, 9075, 1202, 370, 8265, 314, 17782, 14, 339, 1803, 272, 5514, 272, 437, 520, 499, 13, 8237, 12, 359, 78, 63, 3356, 12, 519, 61, 267, 12727, 1777, 402, 314, 6535, 2072, 339, 428, 520, 499, 13, 8237, 12, 359, 82, 12, 302, 63, 3179, 61, 267, 3918, 1777, 402, 314, 6535, 2072, 272, 10944, 272, 3001, 13, 272, 298, 2439, 12719, 367, 10172, 13, 7371, 8449, 27348, 2072, 2, 272, 701, 24747, 14769, 577, 491, 1024, 12, 428, 2871, 1810, 5653, 869, 3240, 10335, 272, 334, 4561, 737, 1455, 921, 25171, 261, 281, 14, 631, 14, 1190, 85, 14, 8654, 15, 18387, 614, 24365, 14, 1360, 9, 272, 1449, 272, 327, 653, 1377, 78, 429, 1463, 315, 314, 805, 11924, 491, 1024, 1253, 3240, 10335, 272, 10245, 275, 413, 69, 13, 21, 272, 302, 12, 333, 275, 812, 14, 1392, 272, 644, 12, 869, 275, 485, 8489, 63, 10756, 70, 8, 54, 12, 519, 12, 4205, 12, 2196, 63, 929, 29, 16, 9, 339, 367, 284, 315, 4945, 8, 988, 63, 1661, 304, 267, 1678, 40, 275, 980, 14, 3287, 8, 55, 14, 52, 12, 812, 9, 1182, 334, 1590, 14, 3287, 8, 1590, 14, 3287, 8, 55, 14, 52, 12, 644, 395, 869, 9, 435, 10245, 9, 267, 869, 9000, 1678, 40, 267, 1678, 55, 275, 980, 14, 3287, 8, 54, 12, 869, 14, 52, 9, 1182, 334, 1590, 14, 3287, 8, 55, 12, 980, 14, 3287, 8, 40, 12, 869, 14, 52, 430, 435, 10245, 9, 267, 644, 9000, 1678, 55, 267, 340, 284, 450, 1616, 508, 378, 26, 288, 1390, 63, 873, 275, 1390, 8, 873, 55, 14, 988, 1062, 1678, 40, 14, 988, 1012, 288, 340, 2853, 8, 17, 14, 446, 1390, 63, 873, 9, 665, 9561, 26, 355, 2059, 272, 372, 644, 12, 869, 421, 199, 318, 3622, 8, 705, 12, 900, 304, 272, 870, 480, 38, 293, 18486, 73, 527, 5621, 26, 10536, 21, 70, 2, 450, 1125, 9, 272, 870, 480, 1378, 745, 26, 10536, 18, 2319, 2, 450, 900, 9, 272, 870, 342, 421, 199, 318, 12338, 8, 3356, 63, 1842, 12, 4534, 63, 1842, 12, 6915, 29, 1400, 12, 13464, 29, 17, 69, 13, 21, 304, 272, 900, 409, 275, 10018, 8, 2734, 26, 3073, 272, 2329, 275, 10018, 8, 2734, 26, 3073, 339, 367, 302, 63, 3356, 315, 5845, 63, 1842, 26, 267, 367, 302, 63, 3179, 315, 4534, 63, 1842, 26, 288, 870, 3647, 18, 68, 5845, 12, 450, 18, 68, 4534, 2, 450, 334, 78, 63, 3356, 12, 302, 63, 3179, 430, 288, 870, 360, 1280, 18673, 358, 288, 1323, 275, 980, 14, 2101, 8, 1875, 63, 674, 63, 4648, 63, 3642, 8, 78, 63, 3356, 12, 302, 63, 3179, 12, 2432, 15826, 63, 4648, 29, 4648, 12, 9483, 63, 21049, 29, 16, 14, 18, 430, 953, 9486, 14, 7112, 342, 288, 870, 480, 11861, 316, 11542, 795, 11549, 13, 10756, 70, 26, 6099, 288, 29921, 275, 900, 342, 288, 333, 275, 653, 13463, 8, 78, 63, 4608, 29, 1216, 12, 9561, 29, 16312, 12, 4205, 534, 4411, 795, 11549, 1959, 3269, 8, 56, 9, 288, 221, 7169, 275, 900, 342, 446, 29921, 288, 900, 409, 459, 4411, 795, 11549, 13, 10756, 70, 2278, 740, 8, 7169, 9, 288, 2329, 459, 4411, 795, 11549, 13, 10756, 70, 2278, 740, 8, 77, 14, 264, 12708, 63, 1508, 4602, 288, 3622, 8, 77, 14, 264, 12708, 63, 1508, 3131, 221, 7169, 9, 953, 9486, 14, 7112, 342, 288, 870, 480, 11861, 316, 11542, 795, 86, 983, 13, 10756, 70, 26, 6099, 288, 29921, 275, 900, 342, 288, 333, 275, 653, 13463, 8, 78, 63, 4608, 29, 1216, 12, 4205, 534, 4411, 795, 86, 983, 297, 490, 9561, 29, 16312, 680, 3269, 8, 56, 9, 288, 221, 7169, 275, 900, 342, 446, 29921, 288, 900, 409, 459, 4411, 795, 86, 983, 13, 10756, 70, 2278, 740, 8, 7169, 9, 288, 2329, 459, 4411, 795, 86, 983, 13, 10756, 70, 2278, 740, 8, 77, 14, 264, 12708, 63, 1508, 4602, 288, 3622, 8, 77, 14, 264, 12708, 63, 1508, 3131, 221, 7169, 9, 953, 9486, 14, 7112, 342, 288, 870, 480, 11861, 316, 11542, 795, 86, 4460, 13, 10756, 70, 26, 6099, 288, 29921, 275, 900, 342, 288, 333, 275, 653, 13463, 8, 78, 63, 4608, 29, 1216, 12, 4205, 534, 4411, 795, 86, 4460, 297, 490, 9561, 29, 16312, 680, 3269, 8, 56, 9, 288, 221, 7169, 275, 900, 342, 446, 29921, 288, 900, 409, 459, 4411, 795, 86, 4460, 13, 10756, 70, 2278, 740, 8, 7169, 9, 288, 2329, 459, 4411, 795, 86, 4460, 13, 10756, 70, 2278, 740, 8, 77, 14, 264, 12708, 63, 1508, 4602, 288, 3622, 8, 77 ]
[ 199, 18644, 83, 402, 10172, 13, 15562, 8449, 27348, 2072, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 5055, 492, 10018, 199, 646, 9486, 199, 504, 900, 492, 900, 199, 199, 646, 2680, 465, 980, 199, 504, 7026, 14, 10096, 492, 6316, 199, 199, 504, 6357, 14, 31384, 14, 10756, 70, 492, 653, 13463, 12, 485, 8489, 63, 10756, 70, 199, 504, 6357, 14, 12281, 14, 3356, 63, 4679, 492, 1852, 63, 674, 63, 4648, 63, 3642, 199, 504, 6357, 14, 24688, 14, 4174, 14, 4912, 492, 4945, 421, 199, 318, 8791, 63, 4411, 11821, 8, 54, 12, 519, 12, 1390, 63, 1661, 29, 5279, 12, 9561, 29, 17, 69, 13, 19, 12, 4205, 534, 2355, 735, 272, 1449, 272, 437, 12, 428, 275, 302, 10756, 70, 8, 56, 12, 519, 12, 9561, 29, 17, 69, 13, 19, 12, 820, 29, 403, 9, 339, 22467, 491, 1024, 1253, 3240, 10335, 1159, 5563, 339, 3897, 272, 4143, 272, 812, 520, 499, 13, 8237, 12, 359, 78, 63, 3356, 12, 302, 63, 3179, 61, 267, 1324, 3634, 272, 519, 520, 3000, 267, 1329, 402, 2465, 343, 4534, 272, 1390, 63, 1661, 520, 3000, 12, 2716, 267, 5696, 1329, 402, 10615, 334, 885, 26, 5198, 9, 272, 9561, 520, 4270, 267, 13464, 8765, 367, 14670, 4458, 334, 6526, 314, 1678, 6535, 365, 4453, 267, 9561, 402, 413, 2020, 314, 805, 20100, 9, 272, 4205, 520, 1059, 267, 9075, 1202, 370, 8265, 314, 17782, 14, 339, 1803, 272, 5514, 272, 437, 520, 499, 13, 8237, 12, 359, 78, 63, 3356, 12, 519, 61, 267, 12727, 1777, 402, 314, 6535, 2072, 339, 428, 520, 499, 13, 8237, 12, 359, 82, 12, 302, 63, 3179, 61, 267, 3918, 1777, 402, 314, 6535, 2072, 272, 10944, 272, 3001, 13, 272, 298, 2439, 12719, 367, 10172, 13, 7371, 8449, 27348, 2072, 2, 272, 701, 24747, 14769, 577, 491, 1024, 12, 428, 2871, 1810, 5653, 869, 3240, 10335, 272, 334, 4561, 737, 1455, 921, 25171, 261, 281, 14, 631, 14, 1190, 85, 14, 8654, 15, 18387, 614, 24365, 14, 1360, 9, 272, 1449, 272, 327, 653, 1377, 78, 429, 1463, 315, 314, 805, 11924, 491, 1024, 1253, 3240, 10335, 272, 10245, 275, 413, 69, 13, 21, 272, 302, 12, 333, 275, 812, 14, 1392, 272, 644, 12, 869, 275, 485, 8489, 63, 10756, 70, 8, 54, 12, 519, 12, 4205, 12, 2196, 63, 929, 29, 16, 9, 339, 367, 284, 315, 4945, 8, 988, 63, 1661, 304, 267, 1678, 40, 275, 980, 14, 3287, 8, 55, 14, 52, 12, 812, 9, 1182, 334, 1590, 14, 3287, 8, 1590, 14, 3287, 8, 55, 14, 52, 12, 644, 395, 869, 9, 435, 10245, 9, 267, 869, 9000, 1678, 40, 267, 1678, 55, 275, 980, 14, 3287, 8, 54, 12, 869, 14, 52, 9, 1182, 334, 1590, 14, 3287, 8, 55, 12, 980, 14, 3287, 8, 40, 12, 869, 14, 52, 430, 435, 10245, 9, 267, 644, 9000, 1678, 55, 267, 340, 284, 450, 1616, 508, 378, 26, 288, 1390, 63, 873, 275, 1390, 8, 873, 55, 14, 988, 1062, 1678, 40, 14, 988, 1012, 288, 340, 2853, 8, 17, 14, 446, 1390, 63, 873, 9, 665, 9561, 26, 355, 2059, 272, 372, 644, 12, 869, 421, 199, 318, 3622, 8, 705, 12, 900, 304, 272, 870, 480, 38, 293, 18486, 73, 527, 5621, 26, 10536, 21, 70, 2, 450, 1125, 9, 272, 870, 480, 1378, 745, 26, 10536, 18, 2319, 2, 450, 900, 9, 272, 870, 342, 421, 199, 318, 12338, 8, 3356, 63, 1842, 12, 4534, 63, 1842, 12, 6915, 29, 1400, 12, 13464, 29, 17, 69, 13, 21, 304, 272, 900, 409, 275, 10018, 8, 2734, 26, 3073, 272, 2329, 275, 10018, 8, 2734, 26, 3073, 339, 367, 302, 63, 3356, 315, 5845, 63, 1842, 26, 267, 367, 302, 63, 3179, 315, 4534, 63, 1842, 26, 288, 870, 3647, 18, 68, 5845, 12, 450, 18, 68, 4534, 2, 450, 334, 78, 63, 3356, 12, 302, 63, 3179, 430, 288, 870, 360, 1280, 18673, 358, 288, 1323, 275, 980, 14, 2101, 8, 1875, 63, 674, 63, 4648, 63, 3642, 8, 78, 63, 3356, 12, 302, 63, 3179, 12, 2432, 15826, 63, 4648, 29, 4648, 12, 9483, 63, 21049, 29, 16, 14, 18, 430, 953, 9486, 14, 7112, 342, 288, 870, 480, 11861, 316, 11542, 795, 11549, 13, 10756, 70, 26, 6099, 288, 29921, 275, 900, 342, 288, 333, 275, 653, 13463, 8, 78, 63, 4608, 29, 1216, 12, 9561, 29, 16312, 12, 4205, 534, 4411, 795, 11549, 1959, 3269, 8, 56, 9, 288, 221, 7169, 275, 900, 342, 446, 29921, 288, 900, 409, 459, 4411, 795, 11549, 13, 10756, 70, 2278, 740, 8, 7169, 9, 288, 2329, 459, 4411, 795, 11549, 13, 10756, 70, 2278, 740, 8, 77, 14, 264, 12708, 63, 1508, 4602, 288, 3622, 8, 77, 14, 264, 12708, 63, 1508, 3131, 221, 7169, 9, 953, 9486, 14, 7112, 342, 288, 870, 480, 11861, 316, 11542, 795, 86, 983, 13, 10756, 70, 26, 6099, 288, 29921, 275, 900, 342, 288, 333, 275, 653, 13463, 8, 78, 63, 4608, 29, 1216, 12, 4205, 534, 4411, 795, 86, 983, 297, 490, 9561, 29, 16312, 680, 3269, 8, 56, 9, 288, 221, 7169, 275, 900, 342, 446, 29921, 288, 900, 409, 459, 4411, 795, 86, 983, 13, 10756, 70, 2278, 740, 8, 7169, 9, 288, 2329, 459, 4411, 795, 86, 983, 13, 10756, 70, 2278, 740, 8, 77, 14, 264, 12708, 63, 1508, 4602, 288, 3622, 8, 77, 14, 264, 12708, 63, 1508, 3131, 221, 7169, 9, 953, 9486, 14, 7112, 342, 288, 870, 480, 11861, 316, 11542, 795, 86, 4460, 13, 10756, 70, 26, 6099, 288, 29921, 275, 900, 342, 288, 333, 275, 653, 13463, 8, 78, 63, 4608, 29, 1216, 12, 4205, 534, 4411, 795, 86, 4460, 297, 490, 9561, 29, 16312, 680, 3269, 8, 56, 9, 288, 221, 7169, 275, 900, 342, 446, 29921, 288, 900, 409, 459, 4411, 795, 86, 4460, 13, 10756, 70, 2278, 740, 8, 7169, 9, 288, 2329, 459, 4411, 795, 86, 4460, 13, 10756, 70, 2278, 740, 8, 77, 14, 264, 12708, 63, 1508, 4602, 288, 3622, 8, 77, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
devoid/nova
nova/version.py
15
2486
# Copyright 2011 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. import pbr.version from nova.openstack.common.gettextutils import _ NOVA_VENDOR = "OpenStack Foundation" NOVA_PRODUCT = "OpenStack Nova" NOVA_PACKAGE = None # OS distro package version suffix loaded = False version_info = pbr.version.VersionInfo('nova') version_string = version_info.version_string def _load_config(): # Don't load in global context, since we can't assume # these modules are accessible when distutils uses # this module import ConfigParser from oslo.config import cfg from nova.openstack.common import log as logging global loaded, NOVA_VENDOR, NOVA_PRODUCT, NOVA_PACKAGE if loaded: return loaded = True cfgfile = cfg.CONF.find_file("release") if cfgfile is None: return try: cfg = ConfigParser.RawConfigParser() cfg.read(cfgfile) NOVA_VENDOR = cfg.get("Nova", "vendor") if cfg.has_option("Nova", "vendor"): NOVA_VENDOR = cfg.get("Nova", "vendor") NOVA_PRODUCT = cfg.get("Nova", "product") if cfg.has_option("Nova", "product"): NOVA_PRODUCT = cfg.get("Nova", "product") NOVA_PACKAGE = cfg.get("Nova", "package") if cfg.has_option("Nova", "package"): NOVA_PACKAGE = cfg.get("Nova", "package") except Exception as ex: LOG = logging.getLogger(__name__) LOG.error(_("Failed to load %(cfgfile)s: %(ex)s"), {'cfgfile': cfgfile, 'ex': ex}) def vendor_string(): _load_config() return NOVA_VENDOR def product_string(): _load_config() return NOVA_PRODUCT def package_string(): _load_config() return NOVA_PACKAGE def version_string_with_package(): if package_string() is None: return version_info.version_string() else: return "%s-%s" % (version_info.version_string(), package_string())
apache-2.0
[ 3, 259, 1898, 7760, 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, 199, 646, 299, 3289, 14, 1023, 199, 199, 504, 5913, 14, 8512, 14, 2330, 14, 5152, 1208, 492, 485, 199, 199, 2826, 15162, 63, 27839, 726, 275, 298, 26208, 2752, 2, 199, 2826, 15162, 63, 14853, 275, 298, 26208, 28184, 2, 199, 2826, 15162, 63, 19265, 275, 488, 221, 327, 4403, 20499, 2559, 1015, 4739, 199, 199, 4591, 275, 756, 199, 1023, 63, 815, 275, 299, 3289, 14, 1023, 14, 3353, 2354, 360, 6765, 358, 199, 1023, 63, 875, 275, 1015, 63, 815, 14, 1023, 63, 875, 421, 199, 318, 485, 912, 63, 888, 837, 272, 327, 7529, 1133, 2248, 315, 2288, 1067, 12, 3967, 781, 883, 1133, 5534, 272, 327, 3520, 4621, 787, 17909, 1380, 7065, 4440, 272, 327, 642, 859, 272, 492, 14196, 339, 687, 11258, 14, 888, 492, 4810, 339, 687, 5913, 14, 8512, 14, 2330, 492, 943, 465, 2050, 339, 2288, 6511, 12, 4825, 15162, 63, 27839, 726, 12, 4825, 15162, 63, 14853, 12, 4825, 15162, 63, 19265, 272, 340, 6511, 26, 267, 372, 339, 6511, 275, 715, 339, 4810, 493, 275, 4810, 14, 3103, 14, 1623, 63, 493, 480, 3221, 531, 272, 340, 4810, 493, 365, 488, 26, 267, 372, 339, 862, 26, 267, 4810, 275, 14196, 14, 7963, 15218, 342, 267, 4810, 14, 739, 8, 4128, 493, 9, 398, 4825, 15162, 63, 27839, 726, 275, 4810, 14, 362, 480, 19884, 401, 298, 9884, 531, 267, 340, 4810, 14, 1989, 63, 1422, 480, 19884, 401, 298, 9884, 2349, 288, 4825, 15162, 63, 27839, 726, 275, 4810, 14, 362, 480, 19884, 401, 298, 9884, 531, 398, 4825, 15162, 63, 14853, 275, 4810, 14, 362, 480, 19884, 401, 298, 2558, 531, 267, 340, 4810, 14, 1989, 63, 1422, 480, 19884, 401, 298, 2558, 2349, 288, 4825, 15162, 63, 14853, 275, 4810, 14, 362, 480, 19884, 401, 298, 2558, 531, 398, 4825, 15162, 63, 19265, 275, 4810, 14, 362, 480, 19884, 401, 298, 2491, 531, 267, 340, 4810, 14, 1989, 63, 1422, 480, 19884, 401, 298, 2491, 2349, 288, 4825, 15162, 63, 19265, 275, 4810, 14, 362, 480, 19884, 401, 298, 2491, 531, 272, 871, 2186, 465, 444, 26, 267, 5051, 275, 2050, 14, 5572, 3460, 354, 3368, 267, 5051, 14, 705, 6115, 4276, 370, 2248, 2818, 4128, 493, 9, 83, 26, 2818, 476, 9, 83, 1288, 2116, 791, 4128, 493, 356, 4810, 493, 12, 283, 476, 356, 444, 1552, 421, 199, 318, 20868, 63, 875, 837, 272, 485, 912, 63, 888, 342, 339, 372, 4825, 15162, 63, 27839, 726, 421, 199, 318, 3336, 63, 875, 837, 272, 485, 912, 63, 888, 342, 339, 372, 4825, 15162, 63, 14853, 421, 199, 318, 2559, 63, 875, 837, 272, 485, 912, 63, 888, 342, 339, 372, 4825, 15162, 63, 19265, 421, 199, 318, 1015, 63, 875, 63, 1045, 63, 2491, 837, 272, 340, 2559, 63, 875, 342, 365, 488, 26, 267, 372, 1015, 63, 815, 14, 1023, 63, 875, 342, 272, 587, 26, 267, 372, 2071, 83, 3295, 83, 2, 450, 334, 1023, 63, 815, 14, 1023, 63, 875, 1062, 2559, 63, 875, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 259, 1898, 7760, 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, 199, 646, 299, 3289, 14, 1023, 199, 199, 504, 5913, 14, 8512, 14, 2330, 14, 5152, 1208, 492, 485, 199, 199, 2826, 15162, 63, 27839, 726, 275, 298, 26208, 2752, 2, 199, 2826, 15162, 63, 14853, 275, 298, 26208, 28184, 2, 199, 2826, 15162, 63, 19265, 275, 488, 221, 327, 4403, 20499, 2559, 1015, 4739, 199, 199, 4591, 275, 756, 199, 1023, 63, 815, 275, 299, 3289, 14, 1023, 14, 3353, 2354, 360, 6765, 358, 199, 1023, 63, 875, 275, 1015, 63, 815, 14, 1023, 63, 875, 421, 199, 318, 485, 912, 63, 888, 837, 272, 327, 7529, 1133, 2248, 315, 2288, 1067, 12, 3967, 781, 883, 1133, 5534, 272, 327, 3520, 4621, 787, 17909, 1380, 7065, 4440, 272, 327, 642, 859, 272, 492, 14196, 339, 687, 11258, 14, 888, 492, 4810, 339, 687, 5913, 14, 8512, 14, 2330, 492, 943, 465, 2050, 339, 2288, 6511, 12, 4825, 15162, 63, 27839, 726, 12, 4825, 15162, 63, 14853, 12, 4825, 15162, 63, 19265, 272, 340, 6511, 26, 267, 372, 339, 6511, 275, 715, 339, 4810, 493, 275, 4810, 14, 3103, 14, 1623, 63, 493, 480, 3221, 531, 272, 340, 4810, 493, 365, 488, 26, 267, 372, 339, 862, 26, 267, 4810, 275, 14196, 14, 7963, 15218, 342, 267, 4810, 14, 739, 8, 4128, 493, 9, 398, 4825, 15162, 63, 27839, 726, 275, 4810, 14, 362, 480, 19884, 401, 298, 9884, 531, 267, 340, 4810, 14, 1989, 63, 1422, 480, 19884, 401, 298, 9884, 2349, 288, 4825, 15162, 63, 27839, 726, 275, 4810, 14, 362, 480, 19884, 401, 298, 9884, 531, 398, 4825, 15162, 63, 14853, 275, 4810, 14, 362, 480, 19884, 401, 298, 2558, 531, 267, 340, 4810, 14, 1989, 63, 1422, 480, 19884, 401, 298, 2558, 2349, 288, 4825, 15162, 63, 14853, 275, 4810, 14, 362, 480, 19884, 401, 298, 2558, 531, 398, 4825, 15162, 63, 19265, 275, 4810, 14, 362, 480, 19884, 401, 298, 2491, 531, 267, 340, 4810, 14, 1989, 63, 1422, 480, 19884, 401, 298, 2491, 2349, 288, 4825, 15162, 63, 19265, 275, 4810, 14, 362, 480, 19884, 401, 298, 2491, 531, 272, 871, 2186, 465, 444, 26, 267, 5051, 275, 2050, 14, 5572, 3460, 354, 3368, 267, 5051, 14, 705, 6115, 4276, 370, 2248, 2818, 4128, 493, 9, 83, 26, 2818, 476, 9, 83, 1288, 2116, 791, 4128, 493, 356, 4810, 493, 12, 283, 476, 356, 444, 1552, 421, 199, 318, 20868, 63, 875, 837, 272, 485, 912, 63, 888, 342, 339, 372, 4825, 15162, 63, 27839, 726, 421, 199, 318, 3336, 63, 875, 837, 272, 485, 912, 63, 888, 342, 339, 372, 4825, 15162, 63, 14853, 421, 199, 318, 2559, 63, 875, 837, 272, 485, 912, 63, 888, 342, 339, 372, 4825, 15162, 63, 19265, 421, 199, 318, 1015, 63, 875, 63, 1045, 63, 2491, 837, 272, 340, 2559, 63, 875, 342, 365, 488, 26, 267, 372, 1015, 63, 815, 14, 1023, 63, 875, 342, 272, 587, 26, 267, 372, 2071, 83, 3295, 83, 2, 450, 334, 1023, 63, 815, 14, 1023, 63, 875, 1062, 2559, 63, 875, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
klmitch/neutron
neutron/db/availability_zone/router.py
9
1979
# # 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 neutron.common import utils from neutron.db import l3_attrs_db from neutron.extensions import availability_zone as az_ext class RouterAvailabilityZoneMixin(l3_attrs_db.ExtraAttributesMixin): """Mixin class to enable router's availability zone attributes.""" extra_attributes = [{'name': az_ext.AZ_HINTS, 'default': "[]"}] def _extend_extra_router_dict(self, router_res, router_db): super(RouterAvailabilityZoneMixin, self)._extend_extra_router_dict( router_res, router_db) if not utils.is_extension_supported(self, 'router_availability_zone'): return router_res[az_ext.AZ_HINTS] = az_ext.convert_az_string_to_list( router_res[az_ext.AZ_HINTS]) router_res['availability_zones'] = ( self.get_router_availability_zones(router_db)) def _process_extra_attr_router_create( self, context, router_db, router_req): if az_ext.AZ_HINTS in router_req: self.validate_availability_zones(context, 'router', router_req[az_ext.AZ_HINTS]) router_req[az_ext.AZ_HINTS] = az_ext.convert_az_list_to_string( router_req[az_ext.AZ_HINTS]) super(RouterAvailabilityZoneMixin, self)._process_extra_attr_router_create(context, router_db, router_req)
apache-2.0
[ 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 8224, 14, 2330, 492, 3778, 199, 504, 8224, 14, 697, 492, 634, 19, 63, 3288, 63, 697, 199, 504, 8224, 14, 5359, 492, 14962, 63, 2619, 465, 24978, 63, 832, 421, 199, 533, 22708, 26462, 11860, 4256, 8, 76, 19, 63, 3288, 63, 697, 14, 7426, 5379, 4256, 304, 272, 408, 4256, 1021, 370, 4756, 6197, 1159, 14962, 5718, 3004, 1041, 339, 2402, 63, 2987, 275, 9016, 354, 356, 24978, 63, 832, 14, 17613, 63, 32456, 51, 12, 283, 885, 356, 7369, 61, 3570, 61, 339, 347, 485, 2880, 63, 2911, 63, 4995, 63, 807, 8, 277, 12, 6197, 63, 470, 12, 6197, 63, 697, 304, 267, 1613, 8, 11691, 26462, 11860, 4256, 12, 291, 10445, 2880, 63, 2911, 63, 4995, 63, 807, 8, 288, 6197, 63, 470, 12, 6197, 63, 697, 9, 267, 340, 440, 3778, 14, 374, 63, 3435, 63, 4946, 8, 277, 12, 283, 4995, 63, 11856, 63, 2619, 735, 288, 372, 267, 6197, 63, 470, 59, 4651, 63, 832, 14, 17613, 63, 32456, 51, 61, 275, 24978, 63, 832, 14, 3916, 63, 4651, 63, 875, 63, 475, 63, 513, 8, 288, 6197, 63, 470, 59, 4651, 63, 832, 14, 17613, 63, 32456, 51, 566, 267, 6197, 63, 470, 459, 11856, 63, 13325, 418, 275, 334, 288, 291, 14, 362, 63, 4995, 63, 11856, 63, 13325, 8, 4995, 63, 697, 430, 339, 347, 485, 1412, 63, 2911, 63, 962, 63, 4995, 63, 981, 8, 267, 291, 12, 1067, 12, 6197, 63, 697, 12, 6197, 63, 2103, 304, 267, 340, 24978, 63, 832, 14, 17613, 63, 32456, 51, 315, 6197, 63, 2103, 26, 288, 291, 14, 3502, 63, 11856, 63, 13325, 8, 1100, 12, 283, 4995, 297, 6163, 6197, 63, 2103, 59, 4651, 63, 832, 14, 17613, 63, 32456, 51, 566, 288, 6197, 63, 2103, 59, 4651, 63, 832, 14, 17613, 63, 32456, 51, 61, 275, 24978, 63, 832, 14, 3916, 63, 4651, 63, 513, 63, 475, 63, 875, 8, 355, 6197, 63, 2103, 59, 4651, 63, 832, 14, 17613, 63, 32456, 51, 566, 267, 1613, 8, 11691, 26462, 11860, 4256, 12, 1598, 291, 10445, 1412, 63, 2911, 63, 962, 63, 4995, 63, 981, 8, 1100, 12, 6197, 63, 697, 12, 10028, 6197, 63, 2103, 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 ]
[ 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 8224, 14, 2330, 492, 3778, 199, 504, 8224, 14, 697, 492, 634, 19, 63, 3288, 63, 697, 199, 504, 8224, 14, 5359, 492, 14962, 63, 2619, 465, 24978, 63, 832, 421, 199, 533, 22708, 26462, 11860, 4256, 8, 76, 19, 63, 3288, 63, 697, 14, 7426, 5379, 4256, 304, 272, 408, 4256, 1021, 370, 4756, 6197, 1159, 14962, 5718, 3004, 1041, 339, 2402, 63, 2987, 275, 9016, 354, 356, 24978, 63, 832, 14, 17613, 63, 32456, 51, 12, 283, 885, 356, 7369, 61, 3570, 61, 339, 347, 485, 2880, 63, 2911, 63, 4995, 63, 807, 8, 277, 12, 6197, 63, 470, 12, 6197, 63, 697, 304, 267, 1613, 8, 11691, 26462, 11860, 4256, 12, 291, 10445, 2880, 63, 2911, 63, 4995, 63, 807, 8, 288, 6197, 63, 470, 12, 6197, 63, 697, 9, 267, 340, 440, 3778, 14, 374, 63, 3435, 63, 4946, 8, 277, 12, 283, 4995, 63, 11856, 63, 2619, 735, 288, 372, 267, 6197, 63, 470, 59, 4651, 63, 832, 14, 17613, 63, 32456, 51, 61, 275, 24978, 63, 832, 14, 3916, 63, 4651, 63, 875, 63, 475, 63, 513, 8, 288, 6197, 63, 470, 59, 4651, 63, 832, 14, 17613, 63, 32456, 51, 566, 267, 6197, 63, 470, 459, 11856, 63, 13325, 418, 275, 334, 288, 291, 14, 362, 63, 4995, 63, 11856, 63, 13325, 8, 4995, 63, 697, 430, 339, 347, 485, 1412, 63, 2911, 63, 962, 63, 4995, 63, 981, 8, 267, 291, 12, 1067, 12, 6197, 63, 697, 12, 6197, 63, 2103, 304, 267, 340, 24978, 63, 832, 14, 17613, 63, 32456, 51, 315, 6197, 63, 2103, 26, 288, 291, 14, 3502, 63, 11856, 63, 13325, 8, 1100, 12, 283, 4995, 297, 6163, 6197, 63, 2103, 59, 4651, 63, 832, 14, 17613, 63, 32456, 51, 566, 288, 6197, 63, 2103, 59, 4651, 63, 832, 14, 17613, 63, 32456, 51, 61, 275, 24978, 63, 832, 14, 3916, 63, 4651, 63, 513, 63, 475, 63, 875, 8, 355, 6197, 63, 2103, 59, 4651, 63, 832, 14, 17613, 63, 32456, 51, 566, 267, 1613, 8, 11691, 26462, 11860, 4256, 12, 1598, 291, 10445, 1412, 63, 2911, 63, 962, 63, 4995, 63, 981, 8, 1100, 12, 6197, 63, 697, 12, 10028, 6197, 63, 2103, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bionoid/kivy
kivy/core/clipboard/__init__.py
6
4556
''' Clipboard ========= Core class for accessing the Clipboard. If we are not able to access the system clipboard, a fake one will be used. Usage example: .. code-block:: kv #:import Clipboard kivy.core.clipboard.Clipboard Button: on_release: self.text = Clipboard.paste() Clipboard.copy('Data') ''' __all__ = ('ClipboardBase', 'Clipboard') from kivy import Logger from kivy.core import core_select_lib from kivy.utils import platform from kivy.setupconfig import USE_SDL2 class ClipboardBase(object): def get(self, mimetype): '''Get the current data in clipboard, using the mimetype if possible. You not use this method directly. Use :meth:`paste` instead. ''' pass def put(self, data, mimetype): '''Put data on the clipboard, and attach a mimetype. You should not use this method directly. Use :meth:`copy` instead. ''' pass def get_types(self): '''Return a list of supported mimetypes ''' return [] def _ensure_clipboard(self): ''' Ensure that the clipboard has been properly initialised. ''' if hasattr(self, '_clip_mime_type'): return if platform == 'win': self._clip_mime_type = 'text/plain;charset=utf-8' # windows clipboard uses a utf-16 little endian encoding self._encoding = 'utf-16-le' elif platform == 'linux': self._clip_mime_type = 'text/plain;charset=utf-8' self._encoding = 'utf-8' else: self._clip_mime_type = 'text/plain' self._encoding = 'utf-8' def copy(self, data=''): ''' Copy the value provided in argument `data` into current clipboard. If data is not of type string it will be converted to string. .. versionadded:: 1.9.0 ''' if data: self._copy(data) def paste(self): ''' Get text from the system clipboard and return it a usable string. .. versionadded:: 1.9.0 ''' return self._paste() def _copy(self, data): self._ensure_clipboard() if not isinstance(data, bytes): data = data.encode(self._encoding) self.put(data, self._clip_mime_type) def _paste(self): self._ensure_clipboard() _clip_types = Clipboard.get_types() mime_type = self._clip_mime_type if mime_type not in _clip_types: mime_type = 'text/plain' data = self.get(mime_type) if data is not None: # decode only if we don't have unicode # we would still need to decode from utf-16 (windows) # data is of type bytes in PY3 if isinstance(data, bytes): data = data.decode(self._encoding, 'ignore') # remove null strings mostly a windows issue data = data.replace(u'\x00', u'') return data return u'' # load clipboard implementation _clipboards = [] if platform == 'android': _clipboards.append( ('android', 'clipboard_android', 'ClipboardAndroid')) elif platform == 'macosx': _clipboards.append( ('nspaste', 'clipboard_nspaste', 'ClipboardNSPaste')) elif platform == 'win': _clipboards.append( ('winctypes', 'clipboard_winctypes', 'ClipboardWindows')) elif platform == 'linux': _clipboards.append( ('dbusklipper', 'clipboard_dbusklipper', 'ClipboardDbusKlipper')) _clipboards.append( ('gtk3', 'clipboard_gtk3', 'ClipboardGtk3')) _clipboards.append( ('xclip', 'clipboard_xclip', 'ClipboardXclip')) _clipboards.append( ('xsel', 'clipboard_xsel', 'ClipboardXsel')) if USE_SDL2: _clipboards.append( ('sdl2', 'clipboard_sdl2', 'ClipboardSDL2')) else: _clipboards.append( ('pygame', 'clipboard_pygame', 'ClipboardPygame')) _clipboards.append( ('dummy', 'clipboard_dummy', 'ClipboardDummy')) Clipboard = core_select_lib('clipboard', _clipboards, True) CutBuffer = None if platform == 'linux': _cutbuffers = [ ('xclip', 'clipboard_xclip', 'ClipboardXclip'), ('xsel', 'clipboard_xsel', 'ClipboardXsel'), ] if Clipboard.__class__.__name__ in (c[2] for c in _cutbuffers): CutBuffer = Clipboard else: CutBuffer = core_select_lib('cutbuffer', _cutbuffers, True, basemodule='clipboard') if CutBuffer: Logger.info('CutBuffer: cut buffer support enabled')
mit
[ 2344, 199, 28459, 199, 15495, 199, 199, 5402, 1021, 367, 18549, 314, 445, 3587, 3576, 14, 982, 781, 787, 440, 7688, 370, 2879, 314, 199, 2253, 11353, 3576, 12, 282, 4026, 1373, 911, 506, 1202, 14, 199, 199, 7692, 2893, 26, 199, 199, 703, 1233, 13, 1457, 447, 16616, 339, 6079, 646, 445, 3587, 3576, 17227, 14, 1018, 14, 7548, 3576, 14, 28459, 339, 16005, 26, 267, 641, 63, 3221, 26, 288, 291, 14, 505, 275, 445, 3587, 3576, 14, 16586, 342, 288, 445, 3587, 3576, 14, 1574, 360, 1451, 358, 199, 2344, 199, 199, 363, 452, 363, 275, 661, 28459, 1563, 297, 283, 28459, 358, 199, 199, 504, 17227, 492, 15996, 199, 504, 17227, 14, 1018, 492, 6170, 63, 2416, 63, 773, 199, 504, 17227, 14, 1208, 492, 4298, 199, 504, 17227, 14, 2758, 888, 492, 4815, 63, 14029, 18, 421, 199, 533, 445, 3587, 3576, 1563, 8, 785, 304, 339, 347, 664, 8, 277, 12, 12200, 304, 267, 1449, 1002, 314, 1453, 666, 315, 11353, 3576, 12, 1808, 314, 12200, 340, 3962, 14, 267, 2047, 440, 675, 642, 1083, 5370, 14, 3645, 520, 5247, 1705, 16586, 64, 3140, 14, 267, 1449, 267, 986, 339, 347, 5324, 8, 277, 12, 666, 12, 12200, 304, 267, 1449, 18989, 666, 641, 314, 11353, 3576, 12, 436, 6554, 282, 12200, 14, 267, 2047, 1077, 440, 675, 642, 1083, 5370, 14, 3645, 520, 5247, 1705, 1574, 64, 3140, 14, 267, 1449, 267, 986, 339, 347, 664, 63, 1313, 8, 277, 304, 267, 1449, 1767, 282, 769, 402, 3748, 13290, 267, 1449, 267, 372, 942, 339, 347, 485, 7505, 63, 7548, 3576, 8, 277, 304, 267, 1449, 7523, 626, 314, 11353, 3576, 965, 2757, 7684, 2536, 9096, 14, 267, 1449, 398, 340, 2688, 8, 277, 12, 2513, 7548, 63, 7626, 63, 466, 735, 288, 372, 398, 340, 4298, 508, 283, 2676, 356, 288, 291, 423, 7548, 63, 7626, 63, 466, 275, 283, 505, 15, 6104, 27, 6043, 29, 1624, 13, 24, 7, 288, 327, 10061, 11353, 3576, 4440, 282, 2774, 13, 975, 12050, 17638, 2644, 288, 291, 423, 2991, 275, 283, 1624, 13, 975, 13, 274, 7, 267, 916, 4298, 508, 283, 5135, 356, 288, 291, 423, 7548, 63, 7626, 63, 466, 275, 283, 505, 15, 6104, 27, 6043, 29, 1624, 13, 24, 7, 288, 291, 423, 2991, 275, 283, 1624, 13, 24, 7, 267, 587, 26, 288, 291, 423, 7548, 63, 7626, 63, 466, 275, 283, 505, 15, 6104, 7, 288, 291, 423, 2991, 275, 283, 1624, 13, 24, 7, 339, 347, 1331, 8, 277, 12, 666, 9280, 267, 1449, 11247, 314, 574, 2741, 315, 1423, 658, 576, 64, 1901, 1453, 11353, 3576, 14, 267, 982, 666, 365, 440, 402, 730, 1059, 652, 911, 506, 6702, 370, 1059, 14, 398, 2508, 7445, 447, 413, 14, 25, 14, 16, 398, 1449, 267, 340, 666, 26, 288, 291, 423, 1574, 8, 576, 9, 339, 347, 20901, 8, 277, 304, 267, 1449, 2372, 1318, 687, 314, 2656, 11353, 3576, 436, 372, 652, 282, 18025, 1059, 14, 398, 2508, 7445, 447, 413, 14, 25, 14, 16, 398, 1449, 267, 372, 291, 423, 16586, 342, 339, 347, 485, 1574, 8, 277, 12, 666, 304, 267, 291, 423, 7505, 63, 7548, 3576, 342, 267, 340, 440, 1228, 8, 576, 12, 2783, 304, 288, 666, 275, 666, 14, 2143, 8, 277, 423, 2991, 9, 267, 291, 14, 524, 8, 576, 12, 291, 423, 7548, 63, 7626, 63, 466, 9, 339, 347, 485, 16586, 8, 277, 304, 267, 291, 423, 7505, 63, 7548, 3576, 342, 267, 485, 7548, 63, 1313, 275, 445, 3587, 3576, 14, 362, 63, 1313, 342, 398, 6660, 63, 466, 275, 291, 423, 7548, 63, 7626, 63, 466, 267, 340, 6660, 63, 466, 440, 315, 485, 7548, 63, 1313, 26, 288, 6660, 63, 466, 275, 283, 505, 15, 6104, 7, 398, 666, 275, 291, 14, 362, 8, 7626, 63, 466, 9, 267, 340, 666, 365, 440, 488, 26, 288, 327, 4849, 1454, 340, 781, 2793, 1133, 1172, 2649, 288, 327, 781, 3955, 5139, 1929, 370, 4849, 687, 2774, 13, 975, 334, 8258, 9, 288, 327, 666, 365, 402, 730, 2783, 315, 7843, 19, 288, 340, 1228, 8, 576, 12, 2783, 304, 355, 666, 275, 666, 14, 2708, 8, 277, 423, 2991, 12, 283, 4247, 358, 288, 327, 2813, 2973, 3326, 19762, 282, 10061, 4976, 288, 666, 275, 666, 14, 1814, 8, 85, 1154, 88, 383, 297, 399, 17483, 288, 372, 666, 267, 372, 399, 891, 421, 199, 3, 2248, 11353, 3576, 4514, 199, 63, 7548, 19267, 275, 942, 199, 692, 4298, 508, 283, 6238, 356, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 6238, 297, 283, 7548, 3576, 63, 6238, 297, 283, 28459, 20762, 1333, 199, 4164, 4298, 508, 283, 28546, 356, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 561, 16586, 297, 283, 7548, 3576, 63, 561, 16586, 297, 283, 28459, 2709, 48, 9209, 1333, 199, 4164, 4298, 508, 283, 2676, 356, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 2676, 9798, 297, 283, 7548, 3576, 63, 2676, 9798, 297, 283, 28459, 8647, 1333, 199, 4164, 4298, 508, 283, 5135, 356, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 68, 464, 1339, 3587, 529, 297, 283, 7548, 3576, 63, 68, 464, 1339, 3587, 529, 297, 283, 28459, 36, 5610, 43, 3587, 529, 1333, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 12275, 19, 297, 283, 7548, 3576, 63, 12275, 19, 297, 283, 28459, 18891, 19, 1333, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 1812, 3587, 297, 283, 7548, 3576, 63, 1812, 3587, 297, 283, 28459, 56, 7548, 1333, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 88, 5891, 297, 283, 7548, 3576, 63, 88, 5891, 297, 283, 28459, 56, 5891, 1333, 199, 199, 692, 4815, 63, 14029, 18, 26, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 22837, 18, 297, 283, 7548, 3576, 63, 22837, 18, 297, 283, 28459, 14029, 18, 1333, 199, 2836, 26, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 22278, 297, 283, 7548, 3576, 63, 22278, 297, 283, 28459, 2713, 5097, 1333, 199, 199, 63, 7548, 19267, 14, 740, 8, 272, 661, 5869, 297, 283, 7548, 3576 ]
[ 199, 28459, 199, 15495, 199, 199, 5402, 1021, 367, 18549, 314, 445, 3587, 3576, 14, 982, 781, 787, 440, 7688, 370, 2879, 314, 199, 2253, 11353, 3576, 12, 282, 4026, 1373, 911, 506, 1202, 14, 199, 199, 7692, 2893, 26, 199, 199, 703, 1233, 13, 1457, 447, 16616, 339, 6079, 646, 445, 3587, 3576, 17227, 14, 1018, 14, 7548, 3576, 14, 28459, 339, 16005, 26, 267, 641, 63, 3221, 26, 288, 291, 14, 505, 275, 445, 3587, 3576, 14, 16586, 342, 288, 445, 3587, 3576, 14, 1574, 360, 1451, 358, 199, 2344, 199, 199, 363, 452, 363, 275, 661, 28459, 1563, 297, 283, 28459, 358, 199, 199, 504, 17227, 492, 15996, 199, 504, 17227, 14, 1018, 492, 6170, 63, 2416, 63, 773, 199, 504, 17227, 14, 1208, 492, 4298, 199, 504, 17227, 14, 2758, 888, 492, 4815, 63, 14029, 18, 421, 199, 533, 445, 3587, 3576, 1563, 8, 785, 304, 339, 347, 664, 8, 277, 12, 12200, 304, 267, 1449, 1002, 314, 1453, 666, 315, 11353, 3576, 12, 1808, 314, 12200, 340, 3962, 14, 267, 2047, 440, 675, 642, 1083, 5370, 14, 3645, 520, 5247, 1705, 16586, 64, 3140, 14, 267, 1449, 267, 986, 339, 347, 5324, 8, 277, 12, 666, 12, 12200, 304, 267, 1449, 18989, 666, 641, 314, 11353, 3576, 12, 436, 6554, 282, 12200, 14, 267, 2047, 1077, 440, 675, 642, 1083, 5370, 14, 3645, 520, 5247, 1705, 1574, 64, 3140, 14, 267, 1449, 267, 986, 339, 347, 664, 63, 1313, 8, 277, 304, 267, 1449, 1767, 282, 769, 402, 3748, 13290, 267, 1449, 267, 372, 942, 339, 347, 485, 7505, 63, 7548, 3576, 8, 277, 304, 267, 1449, 7523, 626, 314, 11353, 3576, 965, 2757, 7684, 2536, 9096, 14, 267, 1449, 398, 340, 2688, 8, 277, 12, 2513, 7548, 63, 7626, 63, 466, 735, 288, 372, 398, 340, 4298, 508, 283, 2676, 356, 288, 291, 423, 7548, 63, 7626, 63, 466, 275, 283, 505, 15, 6104, 27, 6043, 29, 1624, 13, 24, 7, 288, 327, 10061, 11353, 3576, 4440, 282, 2774, 13, 975, 12050, 17638, 2644, 288, 291, 423, 2991, 275, 283, 1624, 13, 975, 13, 274, 7, 267, 916, 4298, 508, 283, 5135, 356, 288, 291, 423, 7548, 63, 7626, 63, 466, 275, 283, 505, 15, 6104, 27, 6043, 29, 1624, 13, 24, 7, 288, 291, 423, 2991, 275, 283, 1624, 13, 24, 7, 267, 587, 26, 288, 291, 423, 7548, 63, 7626, 63, 466, 275, 283, 505, 15, 6104, 7, 288, 291, 423, 2991, 275, 283, 1624, 13, 24, 7, 339, 347, 1331, 8, 277, 12, 666, 9280, 267, 1449, 11247, 314, 574, 2741, 315, 1423, 658, 576, 64, 1901, 1453, 11353, 3576, 14, 267, 982, 666, 365, 440, 402, 730, 1059, 652, 911, 506, 6702, 370, 1059, 14, 398, 2508, 7445, 447, 413, 14, 25, 14, 16, 398, 1449, 267, 340, 666, 26, 288, 291, 423, 1574, 8, 576, 9, 339, 347, 20901, 8, 277, 304, 267, 1449, 2372, 1318, 687, 314, 2656, 11353, 3576, 436, 372, 652, 282, 18025, 1059, 14, 398, 2508, 7445, 447, 413, 14, 25, 14, 16, 398, 1449, 267, 372, 291, 423, 16586, 342, 339, 347, 485, 1574, 8, 277, 12, 666, 304, 267, 291, 423, 7505, 63, 7548, 3576, 342, 267, 340, 440, 1228, 8, 576, 12, 2783, 304, 288, 666, 275, 666, 14, 2143, 8, 277, 423, 2991, 9, 267, 291, 14, 524, 8, 576, 12, 291, 423, 7548, 63, 7626, 63, 466, 9, 339, 347, 485, 16586, 8, 277, 304, 267, 291, 423, 7505, 63, 7548, 3576, 342, 267, 485, 7548, 63, 1313, 275, 445, 3587, 3576, 14, 362, 63, 1313, 342, 398, 6660, 63, 466, 275, 291, 423, 7548, 63, 7626, 63, 466, 267, 340, 6660, 63, 466, 440, 315, 485, 7548, 63, 1313, 26, 288, 6660, 63, 466, 275, 283, 505, 15, 6104, 7, 398, 666, 275, 291, 14, 362, 8, 7626, 63, 466, 9, 267, 340, 666, 365, 440, 488, 26, 288, 327, 4849, 1454, 340, 781, 2793, 1133, 1172, 2649, 288, 327, 781, 3955, 5139, 1929, 370, 4849, 687, 2774, 13, 975, 334, 8258, 9, 288, 327, 666, 365, 402, 730, 2783, 315, 7843, 19, 288, 340, 1228, 8, 576, 12, 2783, 304, 355, 666, 275, 666, 14, 2708, 8, 277, 423, 2991, 12, 283, 4247, 358, 288, 327, 2813, 2973, 3326, 19762, 282, 10061, 4976, 288, 666, 275, 666, 14, 1814, 8, 85, 1154, 88, 383, 297, 399, 17483, 288, 372, 666, 267, 372, 399, 891, 421, 199, 3, 2248, 11353, 3576, 4514, 199, 63, 7548, 19267, 275, 942, 199, 692, 4298, 508, 283, 6238, 356, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 6238, 297, 283, 7548, 3576, 63, 6238, 297, 283, 28459, 20762, 1333, 199, 4164, 4298, 508, 283, 28546, 356, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 561, 16586, 297, 283, 7548, 3576, 63, 561, 16586, 297, 283, 28459, 2709, 48, 9209, 1333, 199, 4164, 4298, 508, 283, 2676, 356, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 2676, 9798, 297, 283, 7548, 3576, 63, 2676, 9798, 297, 283, 28459, 8647, 1333, 199, 4164, 4298, 508, 283, 5135, 356, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 68, 464, 1339, 3587, 529, 297, 283, 7548, 3576, 63, 68, 464, 1339, 3587, 529, 297, 283, 28459, 36, 5610, 43, 3587, 529, 1333, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 12275, 19, 297, 283, 7548, 3576, 63, 12275, 19, 297, 283, 28459, 18891, 19, 1333, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 1812, 3587, 297, 283, 7548, 3576, 63, 1812, 3587, 297, 283, 28459, 56, 7548, 1333, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 88, 5891, 297, 283, 7548, 3576, 63, 88, 5891, 297, 283, 28459, 56, 5891, 1333, 199, 199, 692, 4815, 63, 14029, 18, 26, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 22837, 18, 297, 283, 7548, 3576, 63, 22837, 18, 297, 283, 28459, 14029, 18, 1333, 199, 2836, 26, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 22278, 297, 283, 7548, 3576, 63, 22278, 297, 283, 28459, 2713, 5097, 1333, 199, 199, 63, 7548, 19267, 14, 740, 8, 272, 661, 5869, 297, 283, 7548, 3576, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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ts=4 sw=4 et: # Copyright 2015-2017 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # # qutebrowser 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. # # qutebrowser 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 qutebrowser. If not, see <http://www.gnu.org/licenses/>. """Tests for browser.network.schemehandler.""" import pytest from qutebrowser.browser.webkit.network import schemehandler def test_init(): handler = schemehandler.SchemeHandler(0) assert handler._win_id == 0 def test_create_request(): handler = schemehandler.SchemeHandler(0) with pytest.raises(NotImplementedError): handler.createRequest(None, None, None)
gpl-3.0
[ 3, 6695, 26, 18133, 29, 1548, 570, 2991, 29, 1624, 13, 24, 23014, 29, 20, 5584, 29, 20, 10844, 26, 199, 199, 3, 1898, 6900, 13, 10680, 11040, 269, 5653, 699, 6558, 72, 262, 334, 1918, 27154, 9, 665, 1198, 32, 392, 31127, 14, 1308, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2173, 31127, 14, 199, 3, 199, 3, 2173, 31127, 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, 2173, 31127, 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, 2173, 31127, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 2925, 367, 7042, 14, 1200, 14, 5512, 2232, 1041, 199, 199, 646, 4613, 199, 199, 504, 2173, 31127, 14, 5750, 14, 12554, 14, 1200, 492, 5687, 2232, 421, 199, 318, 511, 63, 826, 837, 272, 3016, 275, 5687, 2232, 14, 19530, 2461, 8, 16, 9, 272, 702, 3016, 423, 2676, 63, 344, 508, 378, 421, 199, 318, 511, 63, 981, 63, 1069, 837, 272, 3016, 275, 5687, 2232, 14, 19530, 2461, 8, 16, 9, 272, 543, 4613, 14, 3536, 8, 18097, 304, 267, 3016, 14, 981, 2017, 8, 403, 12, 488, 12, 488, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 6695, 26, 18133, 29, 1548, 570, 2991, 29, 1624, 13, 24, 23014, 29, 20, 5584, 29, 20, 10844, 26, 199, 199, 3, 1898, 6900, 13, 10680, 11040, 269, 5653, 699, 6558, 72, 262, 334, 1918, 27154, 9, 665, 1198, 32, 392, 31127, 14, 1308, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2173, 31127, 14, 199, 3, 199, 3, 2173, 31127, 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, 2173, 31127, 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, 2173, 31127, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 2925, 367, 7042, 14, 1200, 14, 5512, 2232, 1041, 199, 199, 646, 4613, 199, 199, 504, 2173, 31127, 14, 5750, 14, 12554, 14, 1200, 492, 5687, 2232, 421, 199, 318, 511, 63, 826, 837, 272, 3016, 275, 5687, 2232, 14, 19530, 2461, 8, 16, 9, 272, 702, 3016, 423, 2676, 63, 344, 508, 378, 421, 199, 318, 511, 63, 981, 63, 1069, 837, 272, 3016, 275, 5687, 2232, 14, 19530, 2461, 8, 16, 9, 272, 543, 4613, 14, 3536, 8, 18097, 304, 267, 3016, 14, 981, 2017, 8, 403, 12, 488, 12, 488, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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 ]
flexpeace/django-rest-auth
rest_auth/tests.py
28
18071
import json from django.conf import settings from django.core.urlresolvers import reverse from django.test.client import Client, MULTIPART_CONTENT from django.test import TestCase from django.contrib.auth import get_user_model from django.core import mail from django.test.utils import override_settings from django.contrib.sites.models import Site from allauth.socialaccount.models import SocialApp from allauth.socialaccount.providers.facebook.provider import GRAPH_API_URL import responses from rest_framework import status class APIClient(Client): def patch(self, path, data='', content_type=MULTIPART_CONTENT, follow=False, **extra): return self.generic('PATCH', path, data, content_type, **extra) def options(self, path, data='', content_type=MULTIPART_CONTENT, follow=False, **extra): return self.generic('OPTIONS', path, data, content_type, **extra) class BaseAPITestCase(object): """ base for API tests: * easy request calls, f.e.: self.post(url, data), self.get(url) * easy status check, f.e.: self.post(url, data, status_code=200) """ def send_request(self, request_method, *args, **kwargs): request_func = getattr(self.client, request_method) status_code = None if 'content_type' not in kwargs and request_method != 'get': kwargs['content_type'] = 'application/json' if 'data' in kwargs and request_method != 'get' and kwargs['content_type'] == 'application/json': data = kwargs.get('data', '') kwargs['data'] = json.dumps(data) # , cls=CustomJSONEncoder if 'status_code' in kwargs: status_code = kwargs.pop('status_code') # check_headers = kwargs.pop('check_headers', True) if hasattr(self, 'token'): kwargs['HTTP_AUTHORIZATION'] = 'Token %s' % self.token self.response = request_func(*args, **kwargs) is_json = bool( filter(lambda x: 'json' in x, self.response._headers['content-type'])) if is_json and self.response.content: self.response.json = json.loads(self.response.content) else: self.response.json = {} if status_code: self.assertEqual(self.response.status_code, status_code) return self.response def post(self, *args, **kwargs): return self.send_request('post', *args, **kwargs) def get(self, *args, **kwargs): return self.send_request('get', *args, **kwargs) def patch(self, *args, **kwargs): return self.send_request('patch', *args, **kwargs) # def put(self, *args, **kwargs): # return self.send_request('put', *args, **kwargs) # def delete(self, *args, **kwargs): # return self.send_request('delete', *args, **kwargs) # def options(self, *args, **kwargs): # return self.send_request('options', *args, **kwargs) # def post_file(self, *args, **kwargs): # kwargs['content_type'] = MULTIPART_CONTENT # return self.send_request('post', *args, **kwargs) # def get_file(self, *args, **kwargs): # content_type = None # if 'content_type' in kwargs: # content_type = kwargs.pop('content_type') # response = self.send_request('get', *args, **kwargs) # if content_type: # self.assertEqual( # bool(filter(lambda x: content_type in x, response._headers['content-type'])), True) # return response def init(self): settings.DEBUG = True self.client = APIClient() self.login_url = reverse('rest_login') self.logout_url = reverse('rest_logout') self.password_change_url = reverse('rest_password_change') self.register_url = reverse('rest_register') self.password_reset_url = reverse('rest_password_reset') self.user_url = reverse('rest_user_details') self.veirfy_email_url = reverse('rest_verify_email') self.fb_login_url = reverse('fb_login') def _login(self): payload = { "username": self.USERNAME, "password": self.PASS } self.post(self.login_url, data=payload, status_code=status.HTTP_200_OK) def _logout(self): self.post(self.logout_url, status=status.HTTP_200_OK) # ----------------------- # T E S T H E R E # ----------------------- class APITestCase1(TestCase, BaseAPITestCase): """ Case #1: - user profile: defined - custom registration: backend defined """ urls = 'rest_auth.test_urls' USERNAME = 'person' PASS = 'person' EMAIL = "person1@world.com" NEW_PASS = 'new-test-pass' REGISTRATION_VIEW = 'rest_auth.runtests.RegistrationView' # data without user profile REGISTRATION_DATA = { "username": USERNAME, "password1": PASS, "password2": PASS } REGISTRATION_DATA_WITH_EMAIL = REGISTRATION_DATA.copy() REGISTRATION_DATA_WITH_EMAIL['email'] = EMAIL BASIC_USER_DATA = { 'first_name': "John", 'last_name': 'Smith', 'email': EMAIL } USER_DATA = BASIC_USER_DATA.copy() USER_DATA['newsletter_subscribe'] = True def setUp(self): self.init() def _generate_uid_and_token(self, user): result = {} from django.utils.encoding import force_bytes from django.contrib.auth.tokens import default_token_generator from django import VERSION if VERSION[1] == 5: from django.utils.http import int_to_base36 result['uid'] = int_to_base36(user.pk) else: from django.utils.http import urlsafe_base64_encode result['uid'] = urlsafe_base64_encode(force_bytes(user.pk)) result['token'] = default_token_generator.make_token(user) return result def test_login(self): payload = { "username": self.USERNAME, "password": self.PASS } # there is no users in db so it should throw error (400) self.post(self.login_url, data=payload, status_code=400) self.post(self.password_change_url, status_code=403) # create user user = get_user_model().objects.create_user(self.USERNAME, '', self.PASS) self.post(self.login_url, data=payload, status_code=200) self.assertEqual('key' in self.response.json.keys(), True) self.token = self.response.json['key'] self.post(self.password_change_url, status_code=400) # test inactive user user.is_active = False user.save() self.post(self.login_url, data=payload, status_code=400) # test wrong username/password payload = { "username": self.USERNAME + '?', "password": self.PASS } self.post(self.login_url, data=payload, status_code=400) # test empty payload self.post(self.login_url, data={}, status_code=400) def test_password_change(self): login_payload = { "username": self.USERNAME, "password": self.PASS } get_user_model().objects.create_user(self.USERNAME, '', self.PASS) self.post(self.login_url, data=login_payload, status_code=200) self.token = self.response.json['key'] new_password_payload = { "new_password1": "new_person", "new_password2": "new_person" } self.post( self.password_change_url, data=new_password_payload, status_code=200 ) # user should not be able to login using old password self.post(self.login_url, data=login_payload, status_code=400) # new password should work login_payload['password'] = new_password_payload['new_password1'] self.post(self.login_url, data=login_payload, status_code=200) # pass1 and pass2 are not equal new_password_payload = { "new_password1": "new_person1", "new_password2": "new_person" } self.post( self.password_change_url, data=new_password_payload, status_code=400 ) # send empty payload self.post(self.password_change_url, data={}, status_code=400) @override_settings(OLD_PASSWORD_FIELD_ENABLED=True) def test_password_change_with_old_password(self): login_payload = { "username": self.USERNAME, "password": self.PASS } get_user_model().objects.create_user(self.USERNAME, '', self.PASS) self.post(self.login_url, data=login_payload, status_code=200) self.token = self.response.json['key'] new_password_payload = { "old_password": "%s!" % self.PASS, # wrong password "new_password1": "new_person", "new_password2": "new_person" } self.post( self.password_change_url, data=new_password_payload, status_code=400 ) new_password_payload = { "old_password": self.PASS, "new_password1": "new_person", "new_password2": "new_person" } self.post( self.password_change_url, data=new_password_payload, status_code=200 ) # user should not be able to login using old password self.post(self.login_url, data=login_payload, status_code=400) # new password should work login_payload['password'] = new_password_payload['new_password1'] self.post(self.login_url, data=login_payload, status_code=200) def test_password_reset(self): user = get_user_model().objects.create_user(self.USERNAME, self.EMAIL, self.PASS) # call password reset mail_count = len(mail.outbox) payload = {'email': self.EMAIL} self.post(self.password_reset_url, data=payload, status_code=200) self.assertEqual(len(mail.outbox), mail_count + 1) url_kwargs = self._generate_uid_and_token(user) url = reverse('rest_password_reset_confirm') # wrong token data = { 'new_password1': self.NEW_PASS, 'new_password2': self.NEW_PASS, 'uid': url_kwargs['uid'], 'token': '-wrong-token-' } self.post(url, data=data, status_code=400) # wrong uid data = { 'new_password1': self.NEW_PASS, 'new_password2': self.NEW_PASS, 'uid': '-wrong-uid-', 'token': url_kwargs['token'] } self.post(url, data=data, status_code=400) # wrong token and uid data = { 'new_password1': self.NEW_PASS, 'new_password2': self.NEW_PASS, 'uid': '-wrong-uid-', 'token': '-wrong-token-' } self.post(url, data=data, status_code=400) # valid payload data = { 'new_password1': self.NEW_PASS, 'new_password2': self.NEW_PASS, 'uid': url_kwargs['uid'], 'token': url_kwargs['token'] } url = reverse('rest_password_reset_confirm') self.post(url, data=data, status_code=200) payload = { "username": self.USERNAME, "password": self.NEW_PASS } self.post(self.login_url, data=payload, status_code=200) def test_user_details(self): user = get_user_model().objects.create_user(self.USERNAME, self.EMAIL, self.PASS) payload = { "username": self.USERNAME, "password": self.PASS } self.post(self.login_url, data=payload, status_code=200) self.token = self.response.json['key'] self.get(self.user_url, status_code=200) self.patch(self.user_url, data=self.BASIC_USER_DATA, status_code=200) user = get_user_model().objects.get(pk=user.pk) self.assertEqual(user.first_name, self.response.json['first_name']) self.assertEqual(user.last_name, self.response.json['last_name']) self.assertEqual(user.email, self.response.json['email']) def test_registration(self): user_count = get_user_model().objects.all().count() # test empty payload self.post(self.register_url, data={}, status_code=400) self.post(self.register_url, data=self.REGISTRATION_DATA, status_code=201) self.assertEqual(get_user_model().objects.all().count(), user_count + 1) new_user = get_user_model().objects.latest('id') self.assertEqual(new_user.username, self.REGISTRATION_DATA['username']) self._login() self._logout() @override_settings( ACCOUNT_EMAIL_VERIFICATION='mandatory', ACCOUNT_EMAIL_REQUIRED=True ) def test_registration_with_email_verification(self): user_count = get_user_model().objects.all().count() mail_count = len(mail.outbox) # test empty payload self.post( self.register_url, data={}, status_code=status.HTTP_400_BAD_REQUEST ) self.post( self.register_url, data=self.REGISTRATION_DATA_WITH_EMAIL, status_code=status.HTTP_201_CREATED ) self.assertEqual(get_user_model().objects.all().count(), user_count + 1) self.assertEqual(len(mail.outbox), mail_count + 1) new_user = get_user_model().objects.latest('id') self.assertEqual(new_user.username, self.REGISTRATION_DATA['username']) # email is not verified yet payload = { "username": self.USERNAME, "password": self.PASS } self.post( self.login_url, data=payload, status=status.HTTP_400_BAD_REQUEST ) # verify email email_confirmation = new_user.emailaddress_set.get(email=self.EMAIL)\ .emailconfirmation_set.order_by('-created')[0] self.post( self.veirfy_email_url, data={"key": email_confirmation.key}, status_code=status.HTTP_200_OK ) # try to login again self._login() self._logout() class TestSocialAuth(TestCase, BaseAPITestCase): urls = 'rest_auth.test_urls' USERNAME = 'person' PASS = 'person' EMAIL = "person1@world.com" REGISTRATION_DATA = { "username": USERNAME, "password1": PASS, "password2": PASS, "email": EMAIL } def setUp(self): self.init() social_app = SocialApp.objects.create( provider='facebook', name='Facebook', client_id='123123123', secret='321321321', ) site = Site.objects.get_current() social_app.sites.add(site) self.graph_api_url = GRAPH_API_URL + '/me' @responses.activate def test_failed_social_auth(self): # fake response responses.add( responses.GET, self.graph_api_url, body='', status=400, content_type='application/json' ) payload = { 'access_token': 'abc123' } self.post(self.fb_login_url, data=payload, status_code=400) @responses.activate def test_social_auth(self): # fake response for facebook call resp_body = '{"id":"123123123123","first_name":"John","gender":"male","last_name":"Smith","link":"https:\\/\\/www.facebook.com\\/john.smith","locale":"en_US","name":"John Smith","timezone":2,"updated_time":"2014-08-13T10:14:38+0000","username":"john.smith","verified":true}' # noqa responses.add( responses.GET, self.graph_api_url, body=resp_body, status=200, content_type='application/json' ) users_count = get_user_model().objects.all().count() payload = { 'access_token': 'abc123' } self.post(self.fb_login_url, data=payload, status_code=200) self.assertIn('key', self.response.json.keys()) self.assertEqual(get_user_model().objects.all().count(), users_count + 1) # make sure that second request will not create a new user self.post(self.fb_login_url, data=payload, status_code=200) self.assertIn('key', self.response.json.keys()) self.assertEqual(get_user_model().objects.all().count(), users_count + 1) @responses.activate @override_settings( ACCOUNT_EMAIL_VERIFICATION='mandatory', ACCOUNT_EMAIL_REQUIRED=True, REST_SESSION_LOGIN=False ) def test_edge_case(self): resp_body = '{"id":"123123123123","first_name":"John","gender":"male","last_name":"Smith","link":"https:\\/\\/www.facebook.com\\/john.smith","locale":"en_US","name":"John Smith","timezone":2,"updated_time":"2014-08-13T10:14:38+0000","username":"john.smith","verified":true,"email":"%s"}' # noqa responses.add( responses.GET, self.graph_api_url, body=resp_body % self.EMAIL, status=200, content_type='application/json' ) # test empty payload self.post(self.register_url, data={}, status_code=400) self.post( self.register_url, data=self.REGISTRATION_DATA, status_code=201 ) new_user = get_user_model().objects.latest('id') self.assertEqual(new_user.username, self.REGISTRATION_DATA['username']) # verify email email_confirmation = new_user.emailaddress_set.get(email=self.EMAIL)\ .emailconfirmation_set.order_by('-created')[0] self.post( self.veirfy_email_url, data={"key": email_confirmation.key}, status_code=status.HTTP_200_OK ) self._login() self._logout() payload = { 'access_token': 'abc123' } self.post(self.fb_login_url, data=payload, status_code=200) self.assertIn('key', self.response.json.keys())
mit
[ 646, 2022, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 396, 14, 1258, 492, 6810, 12, 24895, 1772, 2294, 63, 9663, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 63, 1238, 199, 504, 1639, 14, 1018, 492, 6016, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 199, 504, 741, 416, 762, 14, 31932, 14, 992, 492, 2002, 7180, 2640, 199, 504, 741, 416, 762, 14, 31932, 14, 9710, 14, 16652, 14, 3780, 492, 21772, 21126, 63, 3735, 63, 2632, 199, 646, 9320, 199, 199, 504, 4618, 63, 4857, 492, 2004, 421, 199, 533, 25418, 864, 8, 3041, 304, 339, 347, 3371, 8, 277, 12, 931, 12, 666, 4581, 1564, 63, 466, 29, 21894, 2294, 63, 9663, 12, 2035, 29, 797, 12, 1011, 2911, 304, 267, 372, 291, 14, 6767, 360, 17073, 297, 931, 12, 666, 12, 1564, 63, 466, 12, 1011, 2911, 9, 339, 347, 1511, 8, 277, 12, 931, 12, 666, 4581, 1564, 63, 466, 29, 21894, 2294, 63, 9663, 12, 2035, 29, 797, 12, 1011, 2911, 304, 267, 372, 291, 14, 6767, 360, 8808, 297, 931, 12, 666, 12, 1564, 63, 466, 12, 1011, 2911, 9, 421, 199, 533, 3523, 2642, 27309, 8, 785, 304, 339, 408, 272, 1300, 367, 3261, 2295, 26, 267, 627, 8837, 1056, 4882, 12, 289, 14, 69, 16781, 291, 14, 1932, 8, 633, 12, 666, 395, 291, 14, 362, 8, 633, 9, 267, 627, 8837, 2004, 1104, 12, 289, 14, 69, 16781, 291, 14, 1932, 8, 633, 12, 666, 12, 2004, 63, 600, 29, 1840, 9, 272, 408, 272, 347, 3222, 63, 1069, 8, 277, 12, 1056, 63, 765, 12, 627, 589, 12, 1011, 958, 304, 267, 1056, 63, 1532, 275, 2519, 8, 277, 14, 1258, 12, 1056, 63, 765, 9, 267, 2004, 63, 600, 275, 488, 267, 340, 283, 1317, 63, 466, 7, 440, 315, 2074, 436, 1056, 63, 765, 1137, 283, 362, 356, 288, 2074, 459, 1317, 63, 466, 418, 275, 283, 3578, 15, 1001, 7, 267, 340, 283, 576, 7, 315, 2074, 436, 1056, 63, 765, 1137, 283, 362, 7, 436, 2074, 459, 1317, 63, 466, 418, 508, 283, 3578, 15, 1001, 356, 288, 666, 275, 2074, 14, 362, 360, 576, 297, 4074, 288, 2074, 459, 576, 418, 275, 2022, 14, 4180, 8, 576, 9, 221, 327, 2360, 843, 29, 7223, 23069, 267, 340, 283, 1205, 63, 600, 7, 315, 2074, 26, 288, 2004, 63, 600, 275, 2074, 14, 1935, 360, 1205, 63, 600, 358, 398, 327, 1104, 63, 2139, 275, 2074, 14, 1935, 360, 1074, 63, 2139, 297, 715, 9, 267, 340, 2688, 8, 277, 12, 283, 1418, 735, 288, 2074, 459, 2856, 63, 25303, 2594, 418, 275, 283, 3264, 450, 83, 7, 450, 291, 14, 1418, 398, 291, 14, 1310, 275, 1056, 63, 1532, 2031, 589, 12, 1011, 958, 9, 267, 365, 63, 1001, 275, 2155, 8, 288, 2457, 8, 2734, 671, 26, 283, 1001, 7, 315, 671, 12, 291, 14, 1310, 423, 2139, 459, 1317, 13, 466, 5156, 267, 340, 365, 63, 1001, 436, 291, 14, 1310, 14, 1317, 26, 288, 291, 14, 1310, 14, 1001, 275, 2022, 14, 3640, 8, 277, 14, 1310, 14, 1317, 9, 267, 587, 26, 288, 291, 14, 1310, 14, 1001, 275, 1052, 267, 340, 2004, 63, 600, 26, 288, 291, 14, 629, 8, 277, 14, 1310, 14, 1205, 63, 600, 12, 2004, 63, 600, 9, 267, 372, 291, 14, 1310, 339, 347, 2963, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 291, 14, 2254, 63, 1069, 360, 1932, 297, 627, 589, 12, 1011, 958, 9, 339, 347, 664, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 291, 14, 2254, 63, 1069, 360, 362, 297, 627, 589, 12, 1011, 958, 9, 339, 347, 3371, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 291, 14, 2254, 63, 1069, 360, 2068, 297, 627, 589, 12, 1011, 958, 9, 339, 327, 347, 5324, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 272, 327, 258, 372, 291, 14, 2254, 63, 1069, 360, 524, 297, 627, 589, 12, 1011, 958, 9, 339, 327, 347, 3145, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 272, 327, 258, 372, 291, 14, 2254, 63, 1069, 360, 1807, 297, 627, 589, 12, 1011, 958, 9, 339, 327, 347, 1511, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 272, 327, 258, 372, 291, 14, 2254, 63, 1069, 360, 1419, 297, 627, 589, 12, 1011, 958, 9, 339, 327, 347, 2963, 63, 493, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 272, 327, 258, 2074, 459, 1317, 63, 466, 418, 275, 24895, 1772, 2294, 63, 9663, 272, 327, 258, 372, 291, 14, 2254, 63, 1069, 360, 1932, 297, 627, 589, 12, 1011, 958, 9, 339, 327, 347, 664, 63, 493, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 272, 327, 258, 1564, 63, 466, 275, 488, 272, 327, 258, 340, 283, 1317, 63, 466, 7, 315, 2074, 26, 272, 327, 260, 1564, 63, 466, 275, 2074, 14, 1935, 360, 1317, 63, 466, 358, 272, 327, 258, 1177, 275, 291, 14, 2254, 63, 1069, 360, 362, 297, 627, 589, 12, 1011, 958, 9, 272, 327, 258, 340, 1564, 63, 466, 26, 272, 327, 260, 291, 14, 629, 8, 272, 327, 3777, 2155, 8, 1541, 8, 2734, 671, 26, 1564, 63, 466, 315, 671, 12, 1177, 423, 2139, 459, 1317, 13, 466, 16607, 715, 9, 272, 327, 258, 372, 1177, 339, 347, 4205, 8, 277, 304, 267, 2202, 14, 5287, 275, 715, 267, 291, 14, 1258, 275, 25418, 864, 342, 398, 291, 14, 2886, 63, 633, 275, 3837, 360, 3911, 63, 2886, 358, 267, 291, 14, 11646, 63, 633, 275, 3837, 360, 3911, 63, 11646, 358, 267, 291, 14, 2060, 63, 1461, 63, 633, 275, 3837, 360, 3911, 63, 2060, 63, 1461, 358, 267, 291, 14, 2683, 63, 633, 275, 3837, 360, 3911, 63, 2683, 358, 267, 291, 14, 2060, 63, 3958, 63, 633, 275, 3837, 360 ]
[ 2022, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 396, 14, 1258, 492, 6810, 12, 24895, 1772, 2294, 63, 9663, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 63, 1238, 199, 504, 1639, 14, 1018, 492, 6016, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 199, 504, 741, 416, 762, 14, 31932, 14, 992, 492, 2002, 7180, 2640, 199, 504, 741, 416, 762, 14, 31932, 14, 9710, 14, 16652, 14, 3780, 492, 21772, 21126, 63, 3735, 63, 2632, 199, 646, 9320, 199, 199, 504, 4618, 63, 4857, 492, 2004, 421, 199, 533, 25418, 864, 8, 3041, 304, 339, 347, 3371, 8, 277, 12, 931, 12, 666, 4581, 1564, 63, 466, 29, 21894, 2294, 63, 9663, 12, 2035, 29, 797, 12, 1011, 2911, 304, 267, 372, 291, 14, 6767, 360, 17073, 297, 931, 12, 666, 12, 1564, 63, 466, 12, 1011, 2911, 9, 339, 347, 1511, 8, 277, 12, 931, 12, 666, 4581, 1564, 63, 466, 29, 21894, 2294, 63, 9663, 12, 2035, 29, 797, 12, 1011, 2911, 304, 267, 372, 291, 14, 6767, 360, 8808, 297, 931, 12, 666, 12, 1564, 63, 466, 12, 1011, 2911, 9, 421, 199, 533, 3523, 2642, 27309, 8, 785, 304, 339, 408, 272, 1300, 367, 3261, 2295, 26, 267, 627, 8837, 1056, 4882, 12, 289, 14, 69, 16781, 291, 14, 1932, 8, 633, 12, 666, 395, 291, 14, 362, 8, 633, 9, 267, 627, 8837, 2004, 1104, 12, 289, 14, 69, 16781, 291, 14, 1932, 8, 633, 12, 666, 12, 2004, 63, 600, 29, 1840, 9, 272, 408, 272, 347, 3222, 63, 1069, 8, 277, 12, 1056, 63, 765, 12, 627, 589, 12, 1011, 958, 304, 267, 1056, 63, 1532, 275, 2519, 8, 277, 14, 1258, 12, 1056, 63, 765, 9, 267, 2004, 63, 600, 275, 488, 267, 340, 283, 1317, 63, 466, 7, 440, 315, 2074, 436, 1056, 63, 765, 1137, 283, 362, 356, 288, 2074, 459, 1317, 63, 466, 418, 275, 283, 3578, 15, 1001, 7, 267, 340, 283, 576, 7, 315, 2074, 436, 1056, 63, 765, 1137, 283, 362, 7, 436, 2074, 459, 1317, 63, 466, 418, 508, 283, 3578, 15, 1001, 356, 288, 666, 275, 2074, 14, 362, 360, 576, 297, 4074, 288, 2074, 459, 576, 418, 275, 2022, 14, 4180, 8, 576, 9, 221, 327, 2360, 843, 29, 7223, 23069, 267, 340, 283, 1205, 63, 600, 7, 315, 2074, 26, 288, 2004, 63, 600, 275, 2074, 14, 1935, 360, 1205, 63, 600, 358, 398, 327, 1104, 63, 2139, 275, 2074, 14, 1935, 360, 1074, 63, 2139, 297, 715, 9, 267, 340, 2688, 8, 277, 12, 283, 1418, 735, 288, 2074, 459, 2856, 63, 25303, 2594, 418, 275, 283, 3264, 450, 83, 7, 450, 291, 14, 1418, 398, 291, 14, 1310, 275, 1056, 63, 1532, 2031, 589, 12, 1011, 958, 9, 267, 365, 63, 1001, 275, 2155, 8, 288, 2457, 8, 2734, 671, 26, 283, 1001, 7, 315, 671, 12, 291, 14, 1310, 423, 2139, 459, 1317, 13, 466, 5156, 267, 340, 365, 63, 1001, 436, 291, 14, 1310, 14, 1317, 26, 288, 291, 14, 1310, 14, 1001, 275, 2022, 14, 3640, 8, 277, 14, 1310, 14, 1317, 9, 267, 587, 26, 288, 291, 14, 1310, 14, 1001, 275, 1052, 267, 340, 2004, 63, 600, 26, 288, 291, 14, 629, 8, 277, 14, 1310, 14, 1205, 63, 600, 12, 2004, 63, 600, 9, 267, 372, 291, 14, 1310, 339, 347, 2963, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 291, 14, 2254, 63, 1069, 360, 1932, 297, 627, 589, 12, 1011, 958, 9, 339, 347, 664, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 291, 14, 2254, 63, 1069, 360, 362, 297, 627, 589, 12, 1011, 958, 9, 339, 347, 3371, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 291, 14, 2254, 63, 1069, 360, 2068, 297, 627, 589, 12, 1011, 958, 9, 339, 327, 347, 5324, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 272, 327, 258, 372, 291, 14, 2254, 63, 1069, 360, 524, 297, 627, 589, 12, 1011, 958, 9, 339, 327, 347, 3145, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 272, 327, 258, 372, 291, 14, 2254, 63, 1069, 360, 1807, 297, 627, 589, 12, 1011, 958, 9, 339, 327, 347, 1511, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 272, 327, 258, 372, 291, 14, 2254, 63, 1069, 360, 1419, 297, 627, 589, 12, 1011, 958, 9, 339, 327, 347, 2963, 63, 493, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 272, 327, 258, 2074, 459, 1317, 63, 466, 418, 275, 24895, 1772, 2294, 63, 9663, 272, 327, 258, 372, 291, 14, 2254, 63, 1069, 360, 1932, 297, 627, 589, 12, 1011, 958, 9, 339, 327, 347, 664, 63, 493, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 272, 327, 258, 1564, 63, 466, 275, 488, 272, 327, 258, 340, 283, 1317, 63, 466, 7, 315, 2074, 26, 272, 327, 260, 1564, 63, 466, 275, 2074, 14, 1935, 360, 1317, 63, 466, 358, 272, 327, 258, 1177, 275, 291, 14, 2254, 63, 1069, 360, 362, 297, 627, 589, 12, 1011, 958, 9, 272, 327, 258, 340, 1564, 63, 466, 26, 272, 327, 260, 291, 14, 629, 8, 272, 327, 3777, 2155, 8, 1541, 8, 2734, 671, 26, 1564, 63, 466, 315, 671, 12, 1177, 423, 2139, 459, 1317, 13, 466, 16607, 715, 9, 272, 327, 258, 372, 1177, 339, 347, 4205, 8, 277, 304, 267, 2202, 14, 5287, 275, 715, 267, 291, 14, 1258, 275, 25418, 864, 342, 398, 291, 14, 2886, 63, 633, 275, 3837, 360, 3911, 63, 2886, 358, 267, 291, 14, 11646, 63, 633, 275, 3837, 360, 3911, 63, 11646, 358, 267, 291, 14, 2060, 63, 1461, 63, 633, 275, 3837, 360, 3911, 63, 2060, 63, 1461, 358, 267, 291, 14, 2683, 63, 633, 275, 3837, 360, 3911, 63, 2683, 358, 267, 291, 14, 2060, 63, 3958, 63, 633, 275, 3837, 360, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
JeanKossaifi/scikit-learn
sklearn/datasets/lfw.py
141
19372
"""Loader for the Labeled Faces in the Wild (LFW) dataset This dataset is a collection of JPEG pictures of famous people collected over the internet, all details are available on the official website: http://vis-www.cs.umass.edu/lfw/ Each picture is centered on a single face. The typical task is called Face Verification: given a pair of two pictures, a binary classifier must predict whether the two images are from the same person. An alternative task, Face Recognition or Face Identification is: given the picture of the face of an unknown person, identify the name of the person by referring to a gallery of previously seen pictures of identified persons. Both Face Verification and Face Recognition are tasks that are typically performed on the output of a model trained to perform Face Detection. The most popular model for Face Detection is called Viola-Johns and is implemented in the OpenCV library. The LFW faces were extracted by this face detector from various online websites. """ # Copyright (c) 2011 Olivier Grisel <olivier.grisel@ensta.org> # License: BSD 3 clause from os import listdir, makedirs, remove from os.path import join, exists, isdir from sklearn.utils import deprecated import logging import numpy as np try: import urllib.request as urllib # for backwards compatibility except ImportError: import urllib from .base import get_data_home, Bunch from ..externals.joblib import Memory from ..externals.six import b logger = logging.getLogger(__name__) BASE_URL = "http://vis-www.cs.umass.edu/lfw/" ARCHIVE_NAME = "lfw.tgz" FUNNELED_ARCHIVE_NAME = "lfw-funneled.tgz" TARGET_FILENAMES = [ 'pairsDevTrain.txt', 'pairsDevTest.txt', 'pairs.txt', ] def scale_face(face): """Scale back to 0-1 range in case of normalization for plotting""" scaled = face - face.min() scaled /= scaled.max() return scaled # # Common private utilities for data fetching from the original LFW website # local disk caching, and image decoding. # def check_fetch_lfw(data_home=None, funneled=True, download_if_missing=True): """Helper function to download any missing LFW data""" data_home = get_data_home(data_home=data_home) lfw_home = join(data_home, "lfw_home") if funneled: archive_path = join(lfw_home, FUNNELED_ARCHIVE_NAME) data_folder_path = join(lfw_home, "lfw_funneled") archive_url = BASE_URL + FUNNELED_ARCHIVE_NAME else: archive_path = join(lfw_home, ARCHIVE_NAME) data_folder_path = join(lfw_home, "lfw") archive_url = BASE_URL + ARCHIVE_NAME if not exists(lfw_home): makedirs(lfw_home) for target_filename in TARGET_FILENAMES: target_filepath = join(lfw_home, target_filename) if not exists(target_filepath): if download_if_missing: url = BASE_URL + target_filename logger.warning("Downloading LFW metadata: %s", url) urllib.urlretrieve(url, target_filepath) else: raise IOError("%s is missing" % target_filepath) if not exists(data_folder_path): if not exists(archive_path): if download_if_missing: logger.warning("Downloading LFW data (~200MB): %s", archive_url) urllib.urlretrieve(archive_url, archive_path) else: raise IOError("%s is missing" % target_filepath) import tarfile logger.info("Decompressing the data archive to %s", data_folder_path) tarfile.open(archive_path, "r:gz").extractall(path=lfw_home) remove(archive_path) return lfw_home, data_folder_path def _load_imgs(file_paths, slice_, color, resize): """Internally used to load images""" # Try to import imread and imresize from PIL. We do this here to prevent # the whole sklearn.datasets module from depending on PIL. try: try: from scipy.misc import imread except ImportError: from scipy.misc.pilutil import imread from scipy.misc import imresize except ImportError: raise ImportError("The Python Imaging Library (PIL)" " is required to load data from jpeg files") # compute the portion of the images to load to respect the slice_ parameter # given by the caller default_slice = (slice(0, 250), slice(0, 250)) if slice_ is None: slice_ = default_slice else: slice_ = tuple(s or ds for s, ds in zip(slice_, default_slice)) h_slice, w_slice = slice_ h = (h_slice.stop - h_slice.start) // (h_slice.step or 1) w = (w_slice.stop - w_slice.start) // (w_slice.step or 1) if resize is not None: resize = float(resize) h = int(resize * h) w = int(resize * w) # allocate some contiguous memory to host the decoded image slices n_faces = len(file_paths) if not color: faces = np.zeros((n_faces, h, w), dtype=np.float32) else: faces = np.zeros((n_faces, h, w, 3), dtype=np.float32) # iterate over the collected file path to load the jpeg files as numpy # arrays for i, file_path in enumerate(file_paths): if i % 1000 == 0: logger.info("Loading face #%05d / %05d", i + 1, n_faces) # Checks if jpeg reading worked. Refer to issue #3594 for more # details. img = imread(file_path) if img.ndim is 0: raise RuntimeError("Failed to read the image file %s, " "Please make sure that libjpeg is installed" % file_path) face = np.asarray(img[slice_], dtype=np.float32) face /= 255.0 # scale uint8 coded colors to the [0.0, 1.0] floats if resize is not None: face = imresize(face, resize) if not color: # average the color channels to compute a gray levels # representaion face = face.mean(axis=2) faces[i, ...] = face return faces # # Task #1: Face Identification on picture with names # def _fetch_lfw_people(data_folder_path, slice_=None, color=False, resize=None, min_faces_per_person=0): """Perform the actual data loading for the lfw people dataset This operation is meant to be cached by a joblib wrapper. """ # scan the data folder content to retain people with more that # `min_faces_per_person` face pictures person_names, file_paths = [], [] for person_name in sorted(listdir(data_folder_path)): folder_path = join(data_folder_path, person_name) if not isdir(folder_path): continue paths = [join(folder_path, f) for f in listdir(folder_path)] n_pictures = len(paths) if n_pictures >= min_faces_per_person: person_name = person_name.replace('_', ' ') person_names.extend([person_name] * n_pictures) file_paths.extend(paths) n_faces = len(file_paths) if n_faces == 0: raise ValueError("min_faces_per_person=%d is too restrictive" % min_faces_per_person) target_names = np.unique(person_names) target = np.searchsorted(target_names, person_names) faces = _load_imgs(file_paths, slice_, color, resize) # shuffle the faces with a deterministic RNG scheme to avoid having # all faces of the same person in a row, as it would break some # cross validation and learning algorithms such as SGD and online # k-means that make an IID assumption indices = np.arange(n_faces) np.random.RandomState(42).shuffle(indices) faces, target = faces[indices], target[indices] return faces, target, target_names def fetch_lfw_people(data_home=None, funneled=True, resize=0.5, min_faces_per_person=0, color=False, slice_=(slice(70, 195), slice(78, 172)), download_if_missing=True): """Loader for the Labeled Faces in the Wild (LFW) people dataset This dataset is a collection of JPEG pictures of famous people collected on the internet, all details are available on the official website: http://vis-www.cs.umass.edu/lfw/ Each picture is centered on a single face. Each pixel of each channel (color in RGB) is encoded by a float in range 0.0 - 1.0. The task is called Face Recognition (or Identification): given the picture of a face, find the name of the person given a training set (gallery). The original images are 250 x 250 pixels, but the default slice and resize arguments reduce them to 62 x 74. Parameters ---------- data_home : optional, default: None Specify another download and cache folder for the datasets. By default all scikit learn data is stored in '~/scikit_learn_data' subfolders. funneled : boolean, optional, default: True Download and use the funneled variant of the dataset. resize : float, optional, default 0.5 Ratio used to resize the each face picture. min_faces_per_person : int, optional, default None The extracted dataset will only retain pictures of people that have at least `min_faces_per_person` different pictures. color : boolean, optional, default False Keep the 3 RGB channels instead of averaging them to a single gray level channel. If color is True the shape of the data has one more dimension than than the shape with color = False. slice_ : optional Provide a custom 2D slice (height, width) to extract the 'interesting' part of the jpeg files and avoid use statistical correlation from the background download_if_missing : optional, True by default If False, raise a IOError if the data is not locally available instead of trying to download the data from the source site. Returns ------- dataset : dict-like object with the following attributes: dataset.data : numpy array of shape (13233, 2914) Each row corresponds to a ravelled face image of original size 62 x 47 pixels. Changing the ``slice_`` or resize parameters will change the shape of the output. dataset.images : numpy array of shape (13233, 62, 47) Each row is a face image corresponding to one of the 5749 people in the dataset. Changing the ``slice_`` or resize parameters will change the shape of the output. dataset.target : numpy array of shape (13233,) Labels associated to each face image. Those labels range from 0-5748 and correspond to the person IDs. dataset.DESCR : string Description of the Labeled Faces in the Wild (LFW) dataset. """ lfw_home, data_folder_path = check_fetch_lfw( data_home=data_home, funneled=funneled, download_if_missing=download_if_missing) logger.info('Loading LFW people faces from %s', lfw_home) # wrap the loader in a memoizing function that will return memmaped data # arrays for optimal memory usage m = Memory(cachedir=lfw_home, compress=6, verbose=0) load_func = m.cache(_fetch_lfw_people) # load and memoize the pairs as np arrays faces, target, target_names = load_func( data_folder_path, resize=resize, min_faces_per_person=min_faces_per_person, color=color, slice_=slice_) # pack the results as a Bunch instance return Bunch(data=faces.reshape(len(faces), -1), images=faces, target=target, target_names=target_names, DESCR="LFW faces dataset") # # Task #2: Face Verification on pairs of face pictures # def _fetch_lfw_pairs(index_file_path, data_folder_path, slice_=None, color=False, resize=None): """Perform the actual data loading for the LFW pairs dataset This operation is meant to be cached by a joblib wrapper. """ # parse the index file to find the number of pairs to be able to allocate # the right amount of memory before starting to decode the jpeg files with open(index_file_path, 'rb') as index_file: split_lines = [ln.strip().split(b('\t')) for ln in index_file] pair_specs = [sl for sl in split_lines if len(sl) > 2] n_pairs = len(pair_specs) # interating over the metadata lines for each pair to find the filename to # decode and load in memory target = np.zeros(n_pairs, dtype=np.int) file_paths = list() for i, components in enumerate(pair_specs): if len(components) == 3: target[i] = 1 pair = ( (components[0], int(components[1]) - 1), (components[0], int(components[2]) - 1), ) elif len(components) == 4: target[i] = 0 pair = ( (components[0], int(components[1]) - 1), (components[2], int(components[3]) - 1), ) else: raise ValueError("invalid line %d: %r" % (i + 1, components)) for j, (name, idx) in enumerate(pair): try: person_folder = join(data_folder_path, name) except TypeError: person_folder = join(data_folder_path, str(name, 'UTF-8')) filenames = list(sorted(listdir(person_folder))) file_path = join(person_folder, filenames[idx]) file_paths.append(file_path) pairs = _load_imgs(file_paths, slice_, color, resize) shape = list(pairs.shape) n_faces = shape.pop(0) shape.insert(0, 2) shape.insert(0, n_faces // 2) pairs.shape = shape return pairs, target, np.array(['Different persons', 'Same person']) @deprecated("Function 'load_lfw_people' has been deprecated in 0.17 and will be " "removed in 0.19." "Use fetch_lfw_people(download_if_missing=False) instead.") def load_lfw_people(download_if_missing=False, **kwargs): """Alias for fetch_lfw_people(download_if_missing=False) Check fetch_lfw_people.__doc__ for the documentation and parameter list. """ return fetch_lfw_people(download_if_missing=download_if_missing, **kwargs) def fetch_lfw_pairs(subset='train', data_home=None, funneled=True, resize=0.5, color=False, slice_=(slice(70, 195), slice(78, 172)), download_if_missing=True): """Loader for the Labeled Faces in the Wild (LFW) pairs dataset This dataset is a collection of JPEG pictures of famous people collected on the internet, all details are available on the official website: http://vis-www.cs.umass.edu/lfw/ Each picture is centered on a single face. Each pixel of each channel (color in RGB) is encoded by a float in range 0.0 - 1.0. The task is called Face Verification: given a pair of two pictures, a binary classifier must predict whether the two images are from the same person. In the official `README.txt`_ this task is described as the "Restricted" task. As I am not sure as to implement the "Unrestricted" variant correctly, I left it as unsupported for now. .. _`README.txt`: http://vis-www.cs.umass.edu/lfw/README.txt The original images are 250 x 250 pixels, but the default slice and resize arguments reduce them to 62 x 74. Read more in the :ref:`User Guide <labeled_faces_in_the_wild>`. Parameters ---------- subset : optional, default: 'train' Select the dataset to load: 'train' for the development training set, 'test' for the development test set, and '10_folds' for the official evaluation set that is meant to be used with a 10-folds cross validation. data_home : optional, default: None Specify another download and cache folder for the datasets. By default all scikit learn data is stored in '~/scikit_learn_data' subfolders. funneled : boolean, optional, default: True Download and use the funneled variant of the dataset. resize : float, optional, default 0.5 Ratio used to resize the each face picture. color : boolean, optional, default False Keep the 3 RGB channels instead of averaging them to a single gray level channel. If color is True the shape of the data has one more dimension than than the shape with color = False. slice_ : optional Provide a custom 2D slice (height, width) to extract the 'interesting' part of the jpeg files and avoid use statistical correlation from the background download_if_missing : optional, True by default If False, raise a IOError if the data is not locally available instead of trying to download the data from the source site. Returns ------- The data is returned as a Bunch object with the following attributes: data : numpy array of shape (2200, 5828) Each row corresponds to 2 ravel'd face images of original size 62 x 47 pixels. Changing the ``slice_`` or resize parameters will change the shape of the output. pairs : numpy array of shape (2200, 2, 62, 47) Each row has 2 face images corresponding to same or different person from the dataset containing 5749 people. Changing the ``slice_`` or resize parameters will change the shape of the output. target : numpy array of shape (13233,) Labels associated to each pair of images. The two label values being different persons or the same person. DESCR : string Description of the Labeled Faces in the Wild (LFW) dataset. """ lfw_home, data_folder_path = check_fetch_lfw( data_home=data_home, funneled=funneled, download_if_missing=download_if_missing) logger.info('Loading %s LFW pairs from %s', subset, lfw_home) # wrap the loader in a memoizing function that will return memmaped data # arrays for optimal memory usage m = Memory(cachedir=lfw_home, compress=6, verbose=0) load_func = m.cache(_fetch_lfw_pairs) # select the right metadata file according to the requested subset label_filenames = { 'train': 'pairsDevTrain.txt', 'test': 'pairsDevTest.txt', '10_folds': 'pairs.txt', } if subset not in label_filenames: raise ValueError("subset='%s' is invalid: should be one of %r" % ( subset, list(sorted(label_filenames.keys())))) index_file_path = join(lfw_home, label_filenames[subset]) # load and memoize the pairs as np arrays pairs, target, target_names = load_func( index_file_path, data_folder_path, resize=resize, color=color, slice_=slice_) # pack the results as a Bunch instance return Bunch(data=pairs.reshape(len(pairs), -1), pairs=pairs, target=target, target_names=target_names, DESCR="'%s' segment of the LFW pairs dataset" % subset) @deprecated("Function 'load_lfw_pairs' has been deprecated in 0.17 and will be " "removed in 0.19." "Use fetch_lfw_pairs(download_if_missing=False) instead.") def load_lfw_pairs(download_if_missing=False, **kwargs): """Alias for fetch_lfw_pairs(download_if_missing=False) Check fetch_lfw_pairs.__doc__ for the documentation and parameter list. """ return fetch_lfw_pairs(download_if_missing=download_if_missing, **kwargs)
bsd-3-clause
[ 624, 5455, 367, 314, 491, 14502, 10859, 823, 315, 314, 644, 668, 334, 15965, 55, 9, 4789, 199, 199, 2765, 4789, 365, 282, 3245, 402, 1603, 17557, 6682, 22004, 402, 21450, 1785, 13135, 13736, 199, 1883, 314, 21408, 12, 1006, 2436, 787, 2808, 641, 314, 25410, 10691, 26, 339, 1455, 921, 5068, 13, 1544, 14, 1259, 14, 453, 405, 14, 8654, 15, 31624, 15, 199, 199, 22321, 24945, 365, 23903, 641, 282, 2849, 8870, 14, 710, 25780, 2120, 365, 2797, 199, 13414, 5444, 7313, 26, 1627, 282, 4092, 402, 2877, 6682, 22004, 12, 282, 3366, 12429, 199, 7790, 12610, 3775, 314, 2877, 5935, 787, 687, 314, 2011, 4954, 14, 199, 199, 2493, 13943, 2120, 12, 21459, 799, 6862, 15415, 503, 21459, 473, 24926, 365, 26, 199, 11809, 314, 24945, 402, 314, 8870, 402, 376, 5809, 4954, 12, 10405, 314, 536, 199, 1618, 314, 4954, 701, 21864, 370, 282, 486, 17787, 402, 10889, 6775, 6682, 22004, 402, 199, 9281, 8981, 12103, 14, 199, 199, 18088, 21459, 5444, 7313, 436, 21459, 799, 6862, 15415, 787, 6527, 626, 787, 13609, 199, 31652, 641, 314, 1072, 402, 282, 1402, 28161, 370, 5147, 21459, 1487, 5860, 14, 710, 199, 2786, 4560, 2238, 1402, 367, 21459, 1487, 5860, 365, 2797, 6561, 22205, 13, 5691, 25338, 436, 365, 199, 13825, 315, 314, 3232, 12847, 3555, 14, 710, 491, 19445, 21143, 4898, 12509, 701, 642, 8870, 199, 19401, 687, 7750, 18470, 3330, 8619, 14, 199, 624, 199, 3, 1898, 334, 67, 9, 7760, 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, 504, 747, 492, 27483, 12, 1852, 3220, 12, 2813, 199, 504, 747, 14, 515, 492, 4263, 12, 3495, 12, 26004, 199, 199, 504, 6357, 14, 1208, 492, 5906, 199, 199, 646, 2050, 199, 646, 2680, 465, 980, 199, 199, 893, 26, 272, 492, 4011, 14, 1069, 465, 4011, 221, 327, 367, 8552, 7163, 199, 2590, 3545, 26, 272, 492, 4011, 199, 199, 504, 1275, 1095, 492, 664, 63, 576, 63, 4219, 12, 699, 4689, 199, 504, 2508, 24688, 14, 2423, 773, 492, 15825, 199, 199, 504, 2508, 24688, 14, 4174, 492, 330, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 5825, 63, 2632, 275, 298, 1014, 921, 5068, 13, 1544, 14, 1259, 14, 453, 405, 14, 8654, 15, 31624, 6687, 199, 28800, 63, 2339, 275, 298, 31624, 14, 27220, 2, 199, 9309, 6388, 5290, 63, 28800, 63, 2339, 275, 298, 31624, 13, 7036, 685, 1146, 14, 27220, 2, 199, 9268, 63, 5110, 742, 31819, 275, 359, 272, 283, 7322, 12680, 18591, 14, 2424, 297, 272, 283, 7322, 12680, 774, 14, 2424, 297, 272, 283, 7322, 14, 2424, 297, 199, 61, 421, 199, 318, 4666, 63, 1409, 8, 1409, 304, 272, 408, 9944, 1771, 370, 378, 13, 17, 1425, 315, 1930, 402, 16973, 367, 25174, 624, 272, 17923, 275, 8870, 446, 8870, 14, 827, 342, 272, 17923, 12257, 17923, 14, 988, 342, 272, 372, 17923, 421, 199, 3, 199, 3, 13964, 5726, 15841, 367, 666, 21239, 687, 314, 3379, 491, 19445, 10691, 199, 3, 2257, 4543, 13627, 12, 436, 1834, 15952, 14, 199, 3, 421, 199, 318, 1104, 63, 3535, 63, 31624, 8, 576, 63, 4219, 29, 403, 12, 9627, 685, 1146, 29, 549, 12, 5235, 63, 692, 63, 4752, 29, 549, 304, 272, 408, 4433, 805, 370, 5235, 1263, 4124, 491, 19445, 666, 624, 272, 666, 63, 4219, 275, 664, 63, 576, 63, 4219, 8, 576, 63, 4219, 29, 576, 63, 4219, 9, 272, 14642, 87, 63, 4219, 275, 4263, 8, 576, 63, 4219, 12, 298, 31624, 63, 4219, 531, 339, 340, 9627, 685, 1146, 26, 267, 6359, 63, 515, 275, 4263, 8, 31624, 63, 4219, 12, 21498, 6388, 5290, 63, 28800, 63, 2339, 9, 267, 666, 63, 3741, 63, 515, 275, 4263, 8, 31624, 63, 4219, 12, 298, 31624, 63, 7036, 685, 1146, 531, 267, 6359, 63, 633, 275, 19721, 63, 2632, 435, 21498, 6388, 5290, 63, 28800, 63, 2339, 272, 587, 26, 267, 6359, 63, 515, 275, 4263, 8, 31624, 63, 4219, 12, 4160, 1244, 5399, 63, 2339, 9, 267, 666, 63, 3741, 63, 515, 275, 4263, 8, 31624, 63, 4219, 12, 298, 31624, 531, 267, 6359, 63, 633, 275, 19721, 63, 2632, 435, 4160, 1244, 5399, 63, 2339, 339, 340, 440, 3495, 8, 31624, 63, 4219, 304, 267, 1852, 3220, 8, 31624, 63, 4219, 9, 339, 367, 1347, 63, 1501, 315, 26134, 63, 5110, 742, 31819, 26, 267, 1347, 63, 7218, 275, 4263, 8, 31624, 63, 4219, 12, 1347, 63, 1501, 9, 267, 340, 440, 3495, 8, 1375, 63, 7218, 304, 288, 340, 5235, 63, 692, 63, 4752, 26, 355, 1166, 275, 19721, 63, 2632, 435, 1347, 63, 1501, 355, 2512, 14, 3764, 480, 18085, 491, 19445, 3341, 26, 450, 83, 401, 1166, 9, 355, 4011, 14, 633, 14270, 8, 633, 12, 1347, 63, 7218, 9, 288, 587, 26, 355, 746, 5925, 3647, 83, 365, 4124, 2, 450, 1347, 63, 7218, 9, 339, 340, 440, 3495, 8, 576, 63, 3741, 63, 515, 304, 398, 340, 440, 3495, 8, 6404, 63, 515, 304, 288, 340, 5235, 63, 692, 63, 4752, 26, 355, 2512, 14, 3764, 480, 18085, 491, 19445, 666, 31742, 1840, 4567, 304, 450, 83, 401, 6359, 63, 633, 9, 355, 4011, 14, 633, 14270, 8, 6404, 63, 633, 12, 6359, 63, 515, 9, 288, 587, 26, 355, 746, 5925, 3647, 83, 365, 4124, 2, 450, 1347, 63, 7218, 9, 398, 492, 13608, 267, 2512, 14, 815, 480, 872, 6447, 316, 314, 666, 6359, 370, 450, 83, 401, 666, 63, 3741, 63, 515, 9, 267, 13608, 14, 1490, 8, 6404, 63, 515, 12, 298, 82, 26, 6838, 3471, 5005, 452, 8, 515, 29, 31624, 63, 4219, 9, 267, 2813, 8, 6404, 63, 515, 9, 339, 372, 14642, 87, 63, 4219, 12, 666, 63, 3741, 63, 515, 421, 199, 318, 485, 912, 63, 1017, 458, 8, 493, 63, 3771, 12, 6014, 3131, 3164, 12, 15210, 304, 272, 408, 607, 1203, 1183, 1202, 370, 2248, 5935, 624, 339, 327, 7649, 370, 492, 3416, 739, 436, 3416, 8709, 687, 14937, 14, 2136, 886, 642, 2348, 370, 7981, 272 ]
[ 5455, 367, 314, 491, 14502, 10859, 823, 315, 314, 644, 668, 334, 15965, 55, 9, 4789, 199, 199, 2765, 4789, 365, 282, 3245, 402, 1603, 17557, 6682, 22004, 402, 21450, 1785, 13135, 13736, 199, 1883, 314, 21408, 12, 1006, 2436, 787, 2808, 641, 314, 25410, 10691, 26, 339, 1455, 921, 5068, 13, 1544, 14, 1259, 14, 453, 405, 14, 8654, 15, 31624, 15, 199, 199, 22321, 24945, 365, 23903, 641, 282, 2849, 8870, 14, 710, 25780, 2120, 365, 2797, 199, 13414, 5444, 7313, 26, 1627, 282, 4092, 402, 2877, 6682, 22004, 12, 282, 3366, 12429, 199, 7790, 12610, 3775, 314, 2877, 5935, 787, 687, 314, 2011, 4954, 14, 199, 199, 2493, 13943, 2120, 12, 21459, 799, 6862, 15415, 503, 21459, 473, 24926, 365, 26, 199, 11809, 314, 24945, 402, 314, 8870, 402, 376, 5809, 4954, 12, 10405, 314, 536, 199, 1618, 314, 4954, 701, 21864, 370, 282, 486, 17787, 402, 10889, 6775, 6682, 22004, 402, 199, 9281, 8981, 12103, 14, 199, 199, 18088, 21459, 5444, 7313, 436, 21459, 799, 6862, 15415, 787, 6527, 626, 787, 13609, 199, 31652, 641, 314, 1072, 402, 282, 1402, 28161, 370, 5147, 21459, 1487, 5860, 14, 710, 199, 2786, 4560, 2238, 1402, 367, 21459, 1487, 5860, 365, 2797, 6561, 22205, 13, 5691, 25338, 436, 365, 199, 13825, 315, 314, 3232, 12847, 3555, 14, 710, 491, 19445, 21143, 4898, 12509, 701, 642, 8870, 199, 19401, 687, 7750, 18470, 3330, 8619, 14, 199, 624, 199, 3, 1898, 334, 67, 9, 7760, 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, 504, 747, 492, 27483, 12, 1852, 3220, 12, 2813, 199, 504, 747, 14, 515, 492, 4263, 12, 3495, 12, 26004, 199, 199, 504, 6357, 14, 1208, 492, 5906, 199, 199, 646, 2050, 199, 646, 2680, 465, 980, 199, 199, 893, 26, 272, 492, 4011, 14, 1069, 465, 4011, 221, 327, 367, 8552, 7163, 199, 2590, 3545, 26, 272, 492, 4011, 199, 199, 504, 1275, 1095, 492, 664, 63, 576, 63, 4219, 12, 699, 4689, 199, 504, 2508, 24688, 14, 2423, 773, 492, 15825, 199, 199, 504, 2508, 24688, 14, 4174, 492, 330, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 5825, 63, 2632, 275, 298, 1014, 921, 5068, 13, 1544, 14, 1259, 14, 453, 405, 14, 8654, 15, 31624, 6687, 199, 28800, 63, 2339, 275, 298, 31624, 14, 27220, 2, 199, 9309, 6388, 5290, 63, 28800, 63, 2339, 275, 298, 31624, 13, 7036, 685, 1146, 14, 27220, 2, 199, 9268, 63, 5110, 742, 31819, 275, 359, 272, 283, 7322, 12680, 18591, 14, 2424, 297, 272, 283, 7322, 12680, 774, 14, 2424, 297, 272, 283, 7322, 14, 2424, 297, 199, 61, 421, 199, 318, 4666, 63, 1409, 8, 1409, 304, 272, 408, 9944, 1771, 370, 378, 13, 17, 1425, 315, 1930, 402, 16973, 367, 25174, 624, 272, 17923, 275, 8870, 446, 8870, 14, 827, 342, 272, 17923, 12257, 17923, 14, 988, 342, 272, 372, 17923, 421, 199, 3, 199, 3, 13964, 5726, 15841, 367, 666, 21239, 687, 314, 3379, 491, 19445, 10691, 199, 3, 2257, 4543, 13627, 12, 436, 1834, 15952, 14, 199, 3, 421, 199, 318, 1104, 63, 3535, 63, 31624, 8, 576, 63, 4219, 29, 403, 12, 9627, 685, 1146, 29, 549, 12, 5235, 63, 692, 63, 4752, 29, 549, 304, 272, 408, 4433, 805, 370, 5235, 1263, 4124, 491, 19445, 666, 624, 272, 666, 63, 4219, 275, 664, 63, 576, 63, 4219, 8, 576, 63, 4219, 29, 576, 63, 4219, 9, 272, 14642, 87, 63, 4219, 275, 4263, 8, 576, 63, 4219, 12, 298, 31624, 63, 4219, 531, 339, 340, 9627, 685, 1146, 26, 267, 6359, 63, 515, 275, 4263, 8, 31624, 63, 4219, 12, 21498, 6388, 5290, 63, 28800, 63, 2339, 9, 267, 666, 63, 3741, 63, 515, 275, 4263, 8, 31624, 63, 4219, 12, 298, 31624, 63, 7036, 685, 1146, 531, 267, 6359, 63, 633, 275, 19721, 63, 2632, 435, 21498, 6388, 5290, 63, 28800, 63, 2339, 272, 587, 26, 267, 6359, 63, 515, 275, 4263, 8, 31624, 63, 4219, 12, 4160, 1244, 5399, 63, 2339, 9, 267, 666, 63, 3741, 63, 515, 275, 4263, 8, 31624, 63, 4219, 12, 298, 31624, 531, 267, 6359, 63, 633, 275, 19721, 63, 2632, 435, 4160, 1244, 5399, 63, 2339, 339, 340, 440, 3495, 8, 31624, 63, 4219, 304, 267, 1852, 3220, 8, 31624, 63, 4219, 9, 339, 367, 1347, 63, 1501, 315, 26134, 63, 5110, 742, 31819, 26, 267, 1347, 63, 7218, 275, 4263, 8, 31624, 63, 4219, 12, 1347, 63, 1501, 9, 267, 340, 440, 3495, 8, 1375, 63, 7218, 304, 288, 340, 5235, 63, 692, 63, 4752, 26, 355, 1166, 275, 19721, 63, 2632, 435, 1347, 63, 1501, 355, 2512, 14, 3764, 480, 18085, 491, 19445, 3341, 26, 450, 83, 401, 1166, 9, 355, 4011, 14, 633, 14270, 8, 633, 12, 1347, 63, 7218, 9, 288, 587, 26, 355, 746, 5925, 3647, 83, 365, 4124, 2, 450, 1347, 63, 7218, 9, 339, 340, 440, 3495, 8, 576, 63, 3741, 63, 515, 304, 398, 340, 440, 3495, 8, 6404, 63, 515, 304, 288, 340, 5235, 63, 692, 63, 4752, 26, 355, 2512, 14, 3764, 480, 18085, 491, 19445, 666, 31742, 1840, 4567, 304, 450, 83, 401, 6359, 63, 633, 9, 355, 4011, 14, 633, 14270, 8, 6404, 63, 633, 12, 6359, 63, 515, 9, 288, 587, 26, 355, 746, 5925, 3647, 83, 365, 4124, 2, 450, 1347, 63, 7218, 9, 398, 492, 13608, 267, 2512, 14, 815, 480, 872, 6447, 316, 314, 666, 6359, 370, 450, 83, 401, 666, 63, 3741, 63, 515, 9, 267, 13608, 14, 1490, 8, 6404, 63, 515, 12, 298, 82, 26, 6838, 3471, 5005, 452, 8, 515, 29, 31624, 63, 4219, 9, 267, 2813, 8, 6404, 63, 515, 9, 339, 372, 14642, 87, 63, 4219, 12, 666, 63, 3741, 63, 515, 421, 199, 318, 485, 912, 63, 1017, 458, 8, 493, 63, 3771, 12, 6014, 3131, 3164, 12, 15210, 304, 272, 408, 607, 1203, 1183, 1202, 370, 2248, 5935, 624, 339, 327, 7649, 370, 492, 3416, 739, 436, 3416, 8709, 687, 14937, 14, 2136, 886, 642, 2348, 370, 7981, 272, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Fredehagelund92/Cheetax
setup.py
1
1885
from setuptools import setup, find_packages from cheetax import __version__ as VERSION long_description = 'Cheetax is a data loader command-line interface that helps transfer data between storages, \ databases and files into EXASOL. Cheetax is build around generic EXASOL import statements \ in order to maximize the performance of the load.' setup( name = 'cheetax', version = VERSION, description = 'Exasol data loader CLI', long_description = long_description, url = 'https://github.com/Fredehagelund92/Cheetax', author = 'Frederik Hagelund', author_email = 'frederik.hagelund@gmail.com', license = 'MIT', classifiers = [ # How mature is this project? Common values are # 3 - Alpha # 4 - Beta # 5 - Production/Stable 'Development Status :: 3 - Alpha', # Indicate who your project is intended for 'Intended Audience :: Developers', 'Topic :: Software Development :: Build Tools', # Pick your license as you wish (should match "license" above) 'License :: OSI Approved :: MIT License', # Specify the Python versions you support here. In particular, ensure # that you indicate whether you support Python 2, Python 3 or both. 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', ], keywords = 'cli', install_requires = [ 'docopt==0.6.2', 'pyyaml==3.12', 'colorama==0.3.9', 'websocket-client==0.44.0', 'rsa==3.4.2', 'yamlordereddictloader==0.4.0', 'voluptuous==0.10.5', 'enum34==1.1.6' ], extras_require = { 'test': ['coverage', 'pytest', 'pytest-cov'], }, entry_points = { 'console_scripts': [ 'cheetax=cheetax.cli:main', ], } #cmdclass = {'test': RunTests}, )
apache-2.0
[ 504, 9116, 492, 3272, 12, 2342, 63, 5154, 199, 504, 286, 3797, 1219, 492, 636, 1023, 363, 465, 15945, 199, 199, 2809, 63, 1802, 275, 283, 35, 3797, 1219, 365, 282, 666, 5077, 1414, 13, 604, 3217, 626, 22577, 9307, 666, 3382, 4887, 83, 12, 971, 199, 17439, 436, 1584, 1901, 3651, 1179, 2228, 14, 445, 3797, 1219, 365, 1900, 6818, 7809, 3651, 1179, 2228, 492, 9834, 971, 199, 262, 1865, 370, 1390, 11807, 314, 10238, 402, 314, 2248, 3530, 421, 199, 2758, 8, 272, 536, 275, 283, 595, 386, 1219, 297, 272, 1015, 275, 15945, 12, 272, 1369, 275, 283, 920, 305, 393, 666, 5077, 14214, 297, 272, 1846, 63, 1802, 275, 1846, 63, 1802, 12, 272, 1166, 275, 283, 2859, 921, 5031, 14, 957, 15, 38, 21919, 72, 474, 76, 725, 2942, 15, 35, 3797, 1219, 297, 272, 4132, 275, 283, 38, 264, 9910, 75, 869, 474, 76, 725, 297, 272, 4132, 63, 2123, 275, 283, 20153, 9910, 75, 14, 72, 474, 76, 725, 32, 6799, 14, 957, 297, 272, 4190, 275, 283, 13965, 297, 272, 19137, 275, 359, 267, 327, 7494, 333, 1463, 365, 642, 2199, 31, 13964, 1338, 787, 267, 327, 257, 650, 446, 32657, 267, 327, 257, 841, 446, 29521, 267, 327, 257, 959, 446, 24114, 15, 933, 461, 267, 283, 23753, 9795, 3800, 650, 446, 32657, 297, 398, 327, 1010, 10188, 3963, 2195, 2199, 365, 11619, 367, 267, 283, 23910, 23975, 3800, 23493, 297, 267, 283, 12157, 3800, 2290, 15290, 3800, 6516, 23228, 297, 398, 327, 16568, 2195, 4190, 465, 1265, 13809, 334, 5626, 1336, 298, 1682, 2, 3432, 9, 267, 283, 3761, 3800, 25718, 26330, 3800, 10697, 844, 297, 398, 327, 13327, 314, 2018, 5459, 1265, 2291, 2348, 14, 1010, 6770, 12, 4868, 267, 327, 626, 1265, 6623, 3775, 1265, 2291, 2018, 499, 12, 2018, 650, 503, 3865, 14, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 21, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 22, 297, 272, 2156, 272, 7681, 275, 283, 2764, 297, 272, 3907, 63, 6537, 275, 359, 267, 283, 1117, 32626, 389, 16, 14, 22, 14, 18, 297, 267, 283, 647, 5963, 389, 19, 14, 713, 297, 267, 283, 2326, 14541, 389, 16, 14, 19, 14, 25, 297, 267, 283, 13508, 13, 1258, 389, 16, 14, 1602, 14, 16, 297, 267, 283, 13487, 389, 19, 14, 20, 14, 18, 297, 267, 283, 5963, 8235, 807, 3422, 389, 16, 14, 20, 14, 16, 297, 267, 283, 5650, 22963, 7514, 389, 16, 14, 709, 14, 21, 297, 267, 283, 4869, 1082, 389, 17, 14, 17, 14, 22, 7, 272, 2156, 272, 13751, 63, 4365, 275, 469, 267, 283, 396, 356, 788, 10828, 297, 283, 4462, 297, 283, 4462, 13, 8695, 995, 272, 1660, 272, 2397, 63, 3438, 275, 469, 267, 283, 6614, 63, 6429, 356, 359, 288, 283, 595, 386, 1219, 29, 595, 386, 1219, 14, 2764, 26, 973, 297, 267, 2156, 272, 789, 272, 327, 1760, 533, 275, 791, 396, 356, 3378, 2925, 1386, 199, 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 ]
[ 9116, 492, 3272, 12, 2342, 63, 5154, 199, 504, 286, 3797, 1219, 492, 636, 1023, 363, 465, 15945, 199, 199, 2809, 63, 1802, 275, 283, 35, 3797, 1219, 365, 282, 666, 5077, 1414, 13, 604, 3217, 626, 22577, 9307, 666, 3382, 4887, 83, 12, 971, 199, 17439, 436, 1584, 1901, 3651, 1179, 2228, 14, 445, 3797, 1219, 365, 1900, 6818, 7809, 3651, 1179, 2228, 492, 9834, 971, 199, 262, 1865, 370, 1390, 11807, 314, 10238, 402, 314, 2248, 3530, 421, 199, 2758, 8, 272, 536, 275, 283, 595, 386, 1219, 297, 272, 1015, 275, 15945, 12, 272, 1369, 275, 283, 920, 305, 393, 666, 5077, 14214, 297, 272, 1846, 63, 1802, 275, 1846, 63, 1802, 12, 272, 1166, 275, 283, 2859, 921, 5031, 14, 957, 15, 38, 21919, 72, 474, 76, 725, 2942, 15, 35, 3797, 1219, 297, 272, 4132, 275, 283, 38, 264, 9910, 75, 869, 474, 76, 725, 297, 272, 4132, 63, 2123, 275, 283, 20153, 9910, 75, 14, 72, 474, 76, 725, 32, 6799, 14, 957, 297, 272, 4190, 275, 283, 13965, 297, 272, 19137, 275, 359, 267, 327, 7494, 333, 1463, 365, 642, 2199, 31, 13964, 1338, 787, 267, 327, 257, 650, 446, 32657, 267, 327, 257, 841, 446, 29521, 267, 327, 257, 959, 446, 24114, 15, 933, 461, 267, 283, 23753, 9795, 3800, 650, 446, 32657, 297, 398, 327, 1010, 10188, 3963, 2195, 2199, 365, 11619, 367, 267, 283, 23910, 23975, 3800, 23493, 297, 267, 283, 12157, 3800, 2290, 15290, 3800, 6516, 23228, 297, 398, 327, 16568, 2195, 4190, 465, 1265, 13809, 334, 5626, 1336, 298, 1682, 2, 3432, 9, 267, 283, 3761, 3800, 25718, 26330, 3800, 10697, 844, 297, 398, 327, 13327, 314, 2018, 5459, 1265, 2291, 2348, 14, 1010, 6770, 12, 4868, 267, 327, 626, 1265, 6623, 3775, 1265, 2291, 2018, 499, 12, 2018, 650, 503, 3865, 14, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 21, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 22, 297, 272, 2156, 272, 7681, 275, 283, 2764, 297, 272, 3907, 63, 6537, 275, 359, 267, 283, 1117, 32626, 389, 16, 14, 22, 14, 18, 297, 267, 283, 647, 5963, 389, 19, 14, 713, 297, 267, 283, 2326, 14541, 389, 16, 14, 19, 14, 25, 297, 267, 283, 13508, 13, 1258, 389, 16, 14, 1602, 14, 16, 297, 267, 283, 13487, 389, 19, 14, 20, 14, 18, 297, 267, 283, 5963, 8235, 807, 3422, 389, 16, 14, 20, 14, 16, 297, 267, 283, 5650, 22963, 7514, 389, 16, 14, 709, 14, 21, 297, 267, 283, 4869, 1082, 389, 17, 14, 17, 14, 22, 7, 272, 2156, 272, 13751, 63, 4365, 275, 469, 267, 283, 396, 356, 788, 10828, 297, 283, 4462, 297, 283, 4462, 13, 8695, 995, 272, 1660, 272, 2397, 63, 3438, 275, 469, 267, 283, 6614, 63, 6429, 356, 359, 288, 283, 595, 386, 1219, 29, 595, 386, 1219, 14, 2764, 26, 973, 297, 267, 2156, 272, 789, 272, 327, 1760, 533, 275, 791, 396, 356, 3378, 2925, 1386, 199, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
thw17/NextGenUtilities
fasta_utils/Trim_Ns_fasta.py
1
17895
""" Trim_Ns_Fasta.py Author: Tim Webster, Arizona State University Date: April 17, 2017 Currently requires Python 2.7 This script takes as input a fasta file and trims Ns from the beginning and end. It also allows for abitrarily sized "buffers" to ignore in this procedure. For example, if you set a buffer to 2 and a fasta sequence started with "AGNNNNNNNNNTCCG", the "AG" and Ns would all be trimmed. It also allows for wrapping of fasta sequences at arbitrary lengths. """ from __future__ import print_function import argparse import csv import sys from itertools import groupby import re def main(): """ Main Function """ args = parse_args() if args.wrap_length != 'None': wrap = int(args.wrap_length) else: wrap = None if args.hard_buffer > 0: no_buffer = False lead_soft_buffer = 0 tail_soft_buffer = 0 lead_hard_buffer = args.hard_buffer tail_hard_buffer = args.hard_buffer elif args.soft_buffer > 0: no_buffer = False lead_hard_buffer = 0 tail_hard_buffer = 0 lead_soft_buffer = args.soft_buffer tail_soft_buffer = args.soft_buffer else: lead_hard_buffer = args.lead_hard_buffer tail_hard_buffer = args.tail_hard_buffer lead_soft_buffer = args.lead_soft_buffer tail_soft_buffer = args.tail_soft_buffer buffers = [ lead_hard_buffer, lead_soft_buffer, tail_hard_buffer, tail_soft_buffer] if len([x for x in buffers if x == 0]) == 4: no_buffer = True else: no_buffer = False if args.min_n > 1: lead_min_n = args.min_n tail_min_n = args.min_n else: if args.lead_min_n > 1: lead_min_n = args.lead_min_n else: lead_min_n = 1 if args.tail_min_n > 1: tail_min_n = args.tail_min_n else: tail_min_n = 1 if lead_min_n == 0 and tail_min_n == 0: no_min_n = True else: no_min_n = False print(no_buffer, no_min_n) # Process fasta with open(args.fasta, "r") as f: with open(args.output_fasta, "w") as o: with open(args.filtered_scaffolds, "w") as o_filt: # the following text for parsing fasta based on Brent Pedersen's # response here: https://www.biostars.org/p/710/ faiter = (x[1] for x in groupby(f, lambda line: line[0] == ">")) for header in faiter: # drop the ">" header_id = header.next()[1:].strip() # join all sequence lines to one. seq = "".join(s.strip() for s in faiter.next()) orig_len = len(seq) orig_n = count_n(seq) # trim sequence new_seq = trim_sequence( seq, lead_hard_buffer, tail_hard_buffer, lead_soft_buffer, tail_soft_buffer, lead_min_n, tail_min_n) if new_seq is not None: new_len = len(new_seq) if new_len >= args.minimum_length: new_n = count_n(new_seq) # Write fasta record o.write(">{}\n".format(header_id)) length = len(new_seq) if wrap is not None: for i in range(0, length, wrap): o.write(new_seq[i: i + wrap] + "\n") else: o.write(new_seq + "\n") print( "{}\tLength {}\tPercent_N {}\tFiltered_length {}\tFiltered_percent_N {}\tPASS".format( header_id, orig_len, (orig_n * 100) / float(orig_len), new_len, (new_n * 100) / float(new_len))) else: o_filt.write("{}\n".format(header_id)) if new_len > 0: print( "{}\tLength {}\tPercent_N {}\tFiltered_length {}\tFiltered_percent_N {}\tFAIL".format( header_id, orig_len, (orig_n * 100) / float(orig_len), new_len, (new_n * 100) / float(new_len))) else: print( "{}\tLength {}\tPercent_N {}\tFiltered_length 0\tFiltered_percent_N 0\tFAIL".format( header_id, orig_len, (orig_n * 100) / float(orig_len))) else: print( "{}\tLength {}\tPercent_N {}\tFiltered_length 0\tFiltered_percent_N 0\tFAIL".format( header_id, orig_len, (orig_n * 100) / float(orig_len))) o_filt.write("{}\n".format(header_id)) def parse_args(): """ Parse command line arguments """ parser = argparse.ArgumentParser( description="This program trims Ns from the beginning and/or ends " "of fasta records. It also allows for an arbitrarily long hard or soft " "buffer to handle 'orphan' bases before Ns at the beginning of a " "sequence or after Ns at the end of a sequence.") parser.add_argument( "--fasta", required=True, help="Fasta reference file to be processed") parser.add_argument( "--output_fasta", required=True, help="Output file to write new reference") parser.add_argument( "--filtered_scaffolds", default="removed_scaffolds.txt", help="Output file to write names of scaffolds that were removed during " "filtering. Default is 'removed_scaffolds.txt'. Will overwrite file if " "already exists.") parser.add_argument( "--wrap_length", default=50, help="Provide either intger length of each line to use " "when writing sequence data or None to prevent wrapping and write " "sequence on a single line. Default = 50.") parser.add_argument( "--hard_buffer", default=0, type=int, help="If set, length of sequence to remove from the beginning and end " "of a fasta sequence before looking for Ns. This has the effect " "of hard clipping a sequence *whether or not there are Ns*.") parser.add_argument( "--soft_buffer", default=0, type=int, help="If set, script will remove *up to/including this length* " "from the beginning and end of a fasta sequence before looking for Ns. " "This is the dynamic version of --hard_buffer, and will not clip " "if Ns aren't discovered.") parser.add_argument( "--lead_hard_buffer", default=0, type=int, help="If set, length of sequence to remove from the BEGINNING " "of a fasta sequence before looking for Ns. This has the effect " "of hard clipping a sequence *whether or not there are Ns*.") parser.add_argument( "--lead_soft_buffer", default=0, type=int, help="If set, script will remove *up to/including this length* " "from the BEGINNING of a fasta sequence before looking for Ns. " "This is the dynamic version of --hard_buffer, and will not clip " "if Ns aren't discovered.") parser.add_argument( "--tail_hard_buffer", default=0, type=int, help="If set, length of sequence to remove from the END " "of a fasta sequence before looking for Ns. This has the effect " "of hard clipping a sequence *whether or not there are Ns*.") parser.add_argument( "--tail_soft_buffer", default=0, type=int, help="If set, script will remove *up to/including this length* " "from the END of a fasta sequence before looking for Ns. " "This is the dynamic version of --hard_buffer, and will not clip " "if Ns aren't discovered.") parser.add_argument( "--min_n", default=0, type=int, help="The minimum number of consecutive Ns for a sequence to be trimmed. " "This number is applied separately at the beginning and end of a sequence. " "This count starts AFTER buffers are applied. Trimming Ns starts from " "the beginning of a sequence first and then moves to the end. Values of " "0 and 1 are treated equivalently (trim even if only a single N present)") parser.add_argument( "--lead_min_n", default=0, type=int, help="The minimum number of consecutive Ns for a sequence to be trimmed. " "This number is applied to the BEGINNING of a sequence. " "This count starts AFTER buffers are applied. Trimming Ns starts from " "the beginning of a sequence first and then moves to the end. Values of " "0 and 1 are treated equivalently (trim even if only a single N present)") parser.add_argument( "--tail_min_n", default=0, type=int, help="The minimum number of consecutive Ns for a sequence to be trimmed. " "This number is applied to the END of a sequence. " "This count starts AFTER buffers are applied. Trimming Ns starts from " "the beginning of a sequence first and then moves to the end. Values of " "0 and 1 are treated equivalently (trim even if only a single N present)") parser.add_argument( "--minimum_length", default=1, type=int, help="Minimum length of a sequence, after filtering, to include it in " "output file. Default is 1.") args = parser.parse_args() # Validate command line flags features = [ args.hard_buffer, args.soft_buffer, args.lead_hard_buffer, args.lead_soft_buffer, args.tail_hard_buffer, args.tail_soft_buffer, args.min_n, args.lead_min_n, args.tail_min_n] if len([x for x in features if x < 0]) > 0: sys.exit( "Command line parameters cannot be negative for any buffer or " "min_n flags.") if args.hard_buffer > 0: features = [ args.soft_buffer, args.lead_hard_buffer, args.lead_soft_buffer, args.tail_hard_buffer, args.tail_soft_buffer] if len([x for x in features if x > 0]) > 0: sys.exit( "--hard_buffer set, so no other buffer flags can be set.") if args.soft_buffer > 0: features = [ args.hard_buffer, args.lead_hard_buffer, args.lead_soft_buffer, args.tail_hard_buffer, args.tail_soft_buffer] if len([x for x in features if x > 0]) > 0: sys.exit( "--soft_buffer set, so no other buffer flags can be set.") if args.lead_hard_buffer > 0: features = [args.hard_buffer, args.soft_buffer, args.lead_soft_buffer] if len([x for x in features if x > 0]) > 0: sys.exit( "--lead_hard_buffer set, so --soft_buffer and --lead_soft_buffer " "cannot be set.") if args.lead_soft_buffer > 0: features = [args.hard_buffer, args.soft_buffer, args.lead_hard_buffer] if len([x for x in features if x > 0]) > 0: sys.exit( "--lead_soft_buffer set, so --soft_buffer and --lead_hard_buffer " "cannot be set.") if args.tail_hard_buffer > 0: features = [args.hard_buffer, args.soft_buffer, args.tail_soft_buffer] if len([x for x in features if x > 0]) > 0: sys.exit( "--tail_hard_buffer set, so --soft_buffer and --tail_soft_buffer " "cannot be set.") if args.tail_soft_buffer > 0: features = [args.hard_buffer, args.soft_buffer, args.tail_hard_buffer] if len([x for x in features if x > 0]) > 0: sys.exit( "--tail_hard_buffer set, so --soft_buffer and --tail_hard_buffer " "cannot be set.") if args.min_n > 0: features = [args.lead_min_n, args.tail_min_n] if len([x for x in features if x > 0]) > 0: sys.exit( "--min_n set, so --lead_min_n and tail_min_n cannot be set.") if args.lead_min_n > 0: if args.min_n > 0: sys.exit( "--lead_min_n set, so --min_n cannot be set.") if args.tail_min_n > 0: if args.tail_min_n > 0: sys.exit( "--tail_min_n set, so --min_n cannot be set.") if args.wrap_length != "None": if int(args.wrap_length) <= 0: sys.exit("--wrap_length must either be 'None' or a positive integer") return args def trim_sequence( input_sequence, l_hard_buffer, t_hard_buffer, l_soft_buffer, t_soft_buffer, l_min_n, t_min_n): """ Trim Ns from a sequence. Inputs ------ input_sequence : the sequence to be trimmed l_hard_buffer : Number of bases to be hard clipped (no matter what) from beginning of sequence before looking for Ns. Note that even if Ns are not present, these bases will be clipped. t_hard_buffer : Number of bases to be hard clipped (no matter what) from end of sequence before looking for Ns. Note that even if Ns are not present, these bases will be clipped. l_soft_buffer : Number of bases to be dynamically clipped from beginning of sequence before looking for Ns. Function will move base by base through sequence up to this value. If a N is hit, all preceeding bases are removed and then trimming of Ns commences. Otherwise, if an N is not found, then the sequence is left as is. t_soft_buffer : Number of bases to be dynamically clipped from end of sequence before looking for Ns. Function will move base by base backwards through sequence up to this value. If a N is hit, all preceeding bases are removed and then trimming of Ns commences. Otherwise, if an N is not found, then the sequence is left as is. l_min_n : The minimum number of consecutive Ns at the beginning of a sequence before trimming occurs. Count happens after the application of any buffers. t_min_n : The minimum number of consecutive Ns at the end of a sequence before trimming occurs. Count happens after the application of any buffers. Output ------ trimmed_sequence : The processed sequence output as a string if buffers not longer than available sequence None : If buffers are longer than available sequence """ if l_hard_buffer > 0: if len(input_sequence) <= l_hard_buffer: return None else: # Handle beginning of sequence trimmed_sequence = input_sequence[l_hard_buffer:] n_count = 0 for base in trimmed_sequence: if base == "N" or base == "n": n_count += 1 else: break if n_count >= l_min_n: trimmed_sequence = trimmed_sequence[n_count:] # Handle end of sequence if t_hard_buffer > 0: if len(trimmed_sequence) <= t_hard_buffer: return None else: t_hard_buffer = t_hard_buffer * -1 trimmed_sequence = trimmed_sequence[:t_hard_buffer] n_count = 0 for base in trimmed_sequence[::-1]: if base == "N" or base == "n": n_count += 1 else: break if n_count >= t_min_n: n_count = n_count * -1 return trimmed_sequence[:n_count] else: return trimmed_sequence elif t_soft_buffer > 0: b_seen = 0 while b_seen < t_soft_buffer: b_index = -1 * (b_seen + 1) try: base = trimmed_sequence[b_index] except IndexError: return trimmed_sequence if base == "N" or base == "n": break else: b_seen += 1 if b_seen == t_soft_buffer: return trimmed_sequence else: if b_seen > 0: trimmed_sequence = trimmed_sequence[:b_index] n_count = 0 for base in trimmed_sequence[::-1]: if base == "N" or base == "n": n_count += 1 else: break if n_count >= t_min_n: n_count = n_count * -1 return trimmed_sequence[:n_count] else: return trimmed_sequence else: return trimmed_sequence elif l_soft_buffer > 0: # Handle beginning of a sequence b_seen = 0 while b_seen < l_soft_buffer: try: base = input_sequence[b_seen] except IndexError: return trimmed_sequence if base == "N" or base == "n": break else: b_seen += 1 if b_seen == l_soft_buffer: trimmed_sequence = input_sequence else: if b_seen > 0: trimmed_sequence = input_sequence[b_seen:] else: trimmed_sequence = input_sequence n_count = 0 for base in trimmed_sequence: if base == "N" or base == "n": n_count += 1 else: break if n_count >= l_min_n: trimmed_sequence = trimmed_sequence[n_count:] # Handle end of sequence if t_hard_buffer > 0: if len(trimmed_sequence) <= t_hard_buffer: return None else: t_hard_buffer = t_hard_buffer * -1 trimmed_sequence = trimmed_sequence[:t_hard_buffer] n_count = 0 for base in trimmed_sequence[::-1]: if base == "N" or base == "n": n_count += 1 else: break if n_count >= t_min_n: n_count = n_count * -1 return trimmed_sequence[:n_count] else: return trimmed_sequence elif t_soft_buffer > 0: b_seen = 0 while b_seen < t_soft_buffer: b_index = -1 * (b_seen + 1) try: base = trimmed_sequence[b_index] except IndexError: return trimmed_sequence if base == "N" or base == "n": break else: b_seen += 1 if b_seen == t_soft_buffer: return trimmed_sequence else: if b_seen > 0: trimmed_sequence = trimmed_sequence[:b_index] n_count = 0 for base in trimmed_sequence[::-1]: if base == "N" or base == "n": n_count += 1 else: break if n_count >= t_min_n: n_count = n_count * -1 return trimmed_sequence[:n_count] else: return trimmed_sequence else: return trimmed_sequence else: # No leading buffer, head directly to trailing buffers trimmed_sequence = input_sequence if t_hard_buffer > 0: if len(trimmed_sequence) <= t_hard_buffer: return None else: t_hard_buffer = t_hard_buffer * -1 trimmed_sequence = trimmed_sequence[:t_hard_buffer] n_count = 0 for base in trimmed_sequence[::-1]: if base == "N" or base == "n": n_count += 1 else: break if n_count >= t_min_n: n_count = n_count * -1 return trimmed_sequence[:n_count] else: return trimmed_sequence elif t_soft_buffer > 0: b_seen = 0 while b_seen < t_soft_buffer: b_index = -1 * (b_seen + 1) try: base = trimmed_sequence[b_index] except IndexError: return trimmed_sequence if base == "N" or base == "n": break else: b_seen += 1 if b_seen == t_soft_buffer: return trimmed_sequence else: if b_seen > 0: trimmed_sequence = trimmed_sequence[:b_index] n_count = 0 for base in trimmed_sequence[::-1]: if base == "N" or base == "n": n_count += 1 else: break if n_count >= t_min_n: n_count = n_count * -1 return trimmed_sequence[:n_count] else: return trimmed_sequence else: # No leading buffer AND no trailing buffer # Handle beginning of sequence n_count = 0 for base in input_sequence: if base == "N" or base == "n": n_count += 1 else: break if n_count >= l_min_n: trimmed_sequence = input_sequence[n_count:] # n_count = 0 for base in trimmed_sequence[::-1]: if base == "N" or base == "n": n_count += 1 else: break if n_count >= t_min_n: n_count = n_count * -1 return trimmed_sequence[:n_count] else: return trimmed_sequence def count_n(input_sequence): """ Simply counts the occurrence of 'n' and 'N' in a sequence """ lower = input_sequence.count("n") upper = input_sequence.count("N") return upper + lower if __name__ == '__main__': main()
mit
[ 624, 199, 31081, 63, 2438, 63, 1906, 1207, 14, 647, 199, 199, 5949, 26, 26244, 2136, 1533, 351, 12, 31153, 8384, 65, 8511, 15904, 199, 2506, 26, 437, 28026, 5557, 12, 9708, 199, 199, 31499, 5074, 2018, 499, 14, 23, 199, 199, 2765, 2884, 6181, 465, 1324, 282, 30544, 570, 436, 3229, 706, 653, 83, 687, 314, 9608, 436, 199, 500, 14, 221, 2779, 2597, 6127, 367, 282, 2075, 82, 11406, 308, 1759, 298, 17389, 2, 370, 3686, 315, 642, 199, 21978, 14, 221, 2104, 2893, 12, 340, 1265, 663, 282, 3335, 370, 499, 436, 282, 30544, 3414, 8239, 199, 1045, 298, 1254, 7178, 7178, 7178, 7178, 12460, 18636, 401, 314, 298, 1254, 2, 436, 653, 83, 3955, 1006, 506, 24196, 14, 199, 199, 7940, 2597, 6127, 367, 19696, 402, 30544, 8013, 737, 9697, 17464, 14, 199, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 7534, 199, 646, 7392, 199, 646, 984, 199, 504, 7975, 492, 20371, 199, 646, 295, 421, 199, 318, 2446, 837, 199, 198, 624, 11298, 6801, 408, 199, 198, 589, 275, 2198, 63, 589, 342, 421, 198, 692, 1249, 14, 3823, 63, 1267, 1137, 283, 403, 356, 507, 198, 3823, 275, 1109, 8, 589, 14, 3823, 63, 1267, 9, 199, 198, 2836, 26, 507, 198, 3823, 275, 488, 421, 198, 692, 1249, 14, 8726, 63, 2738, 690, 378, 26, 507, 198, 889, 63, 2738, 275, 756, 507, 198, 13799, 63, 4617, 63, 2738, 275, 378, 507, 198, 1521, 63, 4617, 63, 2738, 275, 378, 507, 198, 13799, 63, 8726, 63, 2738, 275, 1249, 14, 8726, 63, 2738, 507, 198, 1521, 63, 8726, 63, 2738, 275, 1249, 14, 8726, 63, 2738, 421, 198, 4164, 1249, 14, 4617, 63, 2738, 690, 378, 26, 507, 198, 889, 63, 2738, 275, 756, 507, 198, 13799, 63, 8726, 63, 2738, 275, 378, 507, 198, 1521, 63, 8726, 63, 2738, 275, 378, 507, 198, 13799, 63, 4617, 63, 2738, 275, 1249, 14, 4617, 63, 2738, 507, 198, 1521, 63, 4617, 63, 2738, 275, 1249, 14, 4617, 63, 2738, 421, 198, 2836, 26, 507, 198, 13799, 63, 8726, 63, 2738, 275, 1249, 14, 13799, 63, 8726, 63, 2738, 507, 198, 1521, 63, 8726, 63, 2738, 275, 1249, 14, 1521, 63, 8726, 63, 2738, 507, 198, 13799, 63, 4617, 63, 2738, 275, 1249, 14, 13799, 63, 4617, 63, 2738, 507, 198, 1521, 63, 4617, 63, 2738, 275, 1249, 14, 1521, 63, 4617, 63, 2738, 421, 198, 17389, 275, 359, 507, 198, 13799, 63, 8726, 63, 2738, 12, 12690, 63, 4617, 63, 2738, 12, 9483, 63, 8726, 63, 2738, 12, 9483, 63, 4617, 63, 2738, 61, 421, 198, 692, 822, 779, 88, 367, 671, 315, 19383, 340, 671, 508, 378, 566, 508, 841, 26, 507, 198, 889, 63, 2738, 275, 715, 199, 198, 2836, 26, 507, 198, 889, 63, 2738, 275, 756, 421, 198, 692, 1249, 14, 827, 63, 78, 690, 413, 26, 507, 198, 13799, 63, 827, 63, 78, 275, 1249, 14, 827, 63, 78, 507, 198, 1521, 63, 827, 63, 78, 275, 1249, 14, 827, 63, 78, 199, 198, 2836, 26, 507, 198, 692, 1249, 14, 13799, 63, 827, 63, 78, 690, 413, 26, 686, 198, 13799, 63, 827, 63, 78, 275, 1249, 14, 13799, 63, 827, 63, 78, 507, 198, 2836, 26, 686, 198, 13799, 63, 827, 63, 78, 275, 413, 507, 198, 692, 1249, 14, 1521, 63, 827, 63, 78, 690, 413, 26, 686, 198, 1521, 63, 827, 63, 78, 275, 1249, 14, 1521, 63, 827, 63, 78, 507, 198, 2836, 26, 686, 198, 1521, 63, 827, 63, 78, 275, 413, 421, 198, 692, 12690, 63, 827, 63, 78, 508, 378, 436, 9483, 63, 827, 63, 78, 508, 378, 26, 507, 198, 889, 63, 827, 63, 78, 275, 715, 199, 198, 2836, 26, 507, 198, 889, 63, 827, 63, 78, 275, 756, 421, 198, 1361, 8, 889, 63, 2738, 12, 949, 63, 827, 63, 78, 9, 199, 198, 3, 7132, 30544, 199, 198, 1045, 1551, 8, 589, 14, 20309, 12, 298, 82, 531, 465, 289, 26, 507, 198, 1045, 1551, 8, 589, 14, 1199, 63, 20309, 12, 298, 87, 531, 465, 312, 26, 686, 198, 1045, 1551, 8, 589, 14, 11142, 63, 7101, 556, 8250, 12, 298, 87, 531, 465, 312, 63, 18872, 26, 1585, 198, 3, 314, 2569, 1318, 367, 6057, 30544, 4079, 641, 699, 640, 11379, 424, 2464, 1159, 1585, 198, 3, 1177, 2348, 26, 221, 4178, 921, 1544, 14, 4492, 941, 4291, 14, 1308, 15, 80, 15, 26072, 15, 1585, 198, 667, 1661, 275, 334, 88, 59, 17, 61, 367, 671, 315, 20371, 8, 70, 12, 2400, 1004, 26, 1004, 59, 16, 61, 508, 15281, 2237, 1585, 198, 509, 1406, 315, 1433, 1661, 26, 1871, 198, 3, 5978, 314, 28192, 1871, 198, 1291, 63, 344, 275, 1406, 14, 2184, 3430, 17, 11455, 1913, 342, 1871, 198, 3, 4263, 1006, 3414, 2385, 370, 1373, 14, 1871, 198, 3610, 275, 10587, 904, 8, 83, 14, 1913, 342, 367, 308, 315, 1433, 1661, 14, 2184, 1012, 1871, 198, 2981, 63, 552, 275, 822, 8, 3610, 9, 1871, 198, 2981, 63, 78, 275, 2338, 63, 78, 8, 3610, 9, 1871, 198, 3, 11639, 3414, 1871, 198, 1222, 63, 3610, 275, 11639, 63, 4041, 8, 4671, 198, 3610, 12, 12690, 63, 8726, 63, 2738, 12, 9483, 63, 8726, 63, 2738, 12, 12690, 63, 4617, 63, 2738, 12, 4671, 198, 1521, 63, 4617, 63, 2738, 12, 12690, 63, 827, 63, 78, 12, 9483, 63, 827, 63, 78, 9, 1871, 198, 692, 892, 63, 3610, 365, 440, 488, 26, 4671, 198, 1222, 63, 552, 275, 822, 8, 1222, 63, 3610, 9, 4671, 198, 692, 892, 63, 552, 2356, 1249, 14, 10700, 63, 1267, 26, 5264, 198, 1222, 63, 78, 275, 2338, 63, 78, 8, 1222, 63, 3610, 9, 6319, 7542, 198, 3, 6990, 30544, 2777, 5264, 198, 79, 14, 952, 19651, 24423, 78, 1674, 908, 8, 1291, 63, 344, 430, 5264, 198, 1267, 275, 822, 8, 1222, 63, 3610, 9, 5264, 198, 692, 4816, 365, 440, 488, 26, 11674, 198, 509, 284, 315, 1425, 8, 16, 12, 2582, 12, 4816, 304, 22680, 198, 79, 14, 952, 8, 1222, 63, 3610, 59, 73, 26 ]
[ 199, 31081, 63, 2438, 63, 1906, 1207, 14, 647, 199, 199, 5949, 26, 26244, 2136, 1533, 351, 12, 31153, 8384, 65, 8511, 15904, 199, 2506, 26, 437, 28026, 5557, 12, 9708, 199, 199, 31499, 5074, 2018, 499, 14, 23, 199, 199, 2765, 2884, 6181, 465, 1324, 282, 30544, 570, 436, 3229, 706, 653, 83, 687, 314, 9608, 436, 199, 500, 14, 221, 2779, 2597, 6127, 367, 282, 2075, 82, 11406, 308, 1759, 298, 17389, 2, 370, 3686, 315, 642, 199, 21978, 14, 221, 2104, 2893, 12, 340, 1265, 663, 282, 3335, 370, 499, 436, 282, 30544, 3414, 8239, 199, 1045, 298, 1254, 7178, 7178, 7178, 7178, 12460, 18636, 401, 314, 298, 1254, 2, 436, 653, 83, 3955, 1006, 506, 24196, 14, 199, 199, 7940, 2597, 6127, 367, 19696, 402, 30544, 8013, 737, 9697, 17464, 14, 199, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 7534, 199, 646, 7392, 199, 646, 984, 199, 504, 7975, 492, 20371, 199, 646, 295, 421, 199, 318, 2446, 837, 199, 198, 624, 11298, 6801, 408, 199, 198, 589, 275, 2198, 63, 589, 342, 421, 198, 692, 1249, 14, 3823, 63, 1267, 1137, 283, 403, 356, 507, 198, 3823, 275, 1109, 8, 589, 14, 3823, 63, 1267, 9, 199, 198, 2836, 26, 507, 198, 3823, 275, 488, 421, 198, 692, 1249, 14, 8726, 63, 2738, 690, 378, 26, 507, 198, 889, 63, 2738, 275, 756, 507, 198, 13799, 63, 4617, 63, 2738, 275, 378, 507, 198, 1521, 63, 4617, 63, 2738, 275, 378, 507, 198, 13799, 63, 8726, 63, 2738, 275, 1249, 14, 8726, 63, 2738, 507, 198, 1521, 63, 8726, 63, 2738, 275, 1249, 14, 8726, 63, 2738, 421, 198, 4164, 1249, 14, 4617, 63, 2738, 690, 378, 26, 507, 198, 889, 63, 2738, 275, 756, 507, 198, 13799, 63, 8726, 63, 2738, 275, 378, 507, 198, 1521, 63, 8726, 63, 2738, 275, 378, 507, 198, 13799, 63, 4617, 63, 2738, 275, 1249, 14, 4617, 63, 2738, 507, 198, 1521, 63, 4617, 63, 2738, 275, 1249, 14, 4617, 63, 2738, 421, 198, 2836, 26, 507, 198, 13799, 63, 8726, 63, 2738, 275, 1249, 14, 13799, 63, 8726, 63, 2738, 507, 198, 1521, 63, 8726, 63, 2738, 275, 1249, 14, 1521, 63, 8726, 63, 2738, 507, 198, 13799, 63, 4617, 63, 2738, 275, 1249, 14, 13799, 63, 4617, 63, 2738, 507, 198, 1521, 63, 4617, 63, 2738, 275, 1249, 14, 1521, 63, 4617, 63, 2738, 421, 198, 17389, 275, 359, 507, 198, 13799, 63, 8726, 63, 2738, 12, 12690, 63, 4617, 63, 2738, 12, 9483, 63, 8726, 63, 2738, 12, 9483, 63, 4617, 63, 2738, 61, 421, 198, 692, 822, 779, 88, 367, 671, 315, 19383, 340, 671, 508, 378, 566, 508, 841, 26, 507, 198, 889, 63, 2738, 275, 715, 199, 198, 2836, 26, 507, 198, 889, 63, 2738, 275, 756, 421, 198, 692, 1249, 14, 827, 63, 78, 690, 413, 26, 507, 198, 13799, 63, 827, 63, 78, 275, 1249, 14, 827, 63, 78, 507, 198, 1521, 63, 827, 63, 78, 275, 1249, 14, 827, 63, 78, 199, 198, 2836, 26, 507, 198, 692, 1249, 14, 13799, 63, 827, 63, 78, 690, 413, 26, 686, 198, 13799, 63, 827, 63, 78, 275, 1249, 14, 13799, 63, 827, 63, 78, 507, 198, 2836, 26, 686, 198, 13799, 63, 827, 63, 78, 275, 413, 507, 198, 692, 1249, 14, 1521, 63, 827, 63, 78, 690, 413, 26, 686, 198, 1521, 63, 827, 63, 78, 275, 1249, 14, 1521, 63, 827, 63, 78, 507, 198, 2836, 26, 686, 198, 1521, 63, 827, 63, 78, 275, 413, 421, 198, 692, 12690, 63, 827, 63, 78, 508, 378, 436, 9483, 63, 827, 63, 78, 508, 378, 26, 507, 198, 889, 63, 827, 63, 78, 275, 715, 199, 198, 2836, 26, 507, 198, 889, 63, 827, 63, 78, 275, 756, 421, 198, 1361, 8, 889, 63, 2738, 12, 949, 63, 827, 63, 78, 9, 199, 198, 3, 7132, 30544, 199, 198, 1045, 1551, 8, 589, 14, 20309, 12, 298, 82, 531, 465, 289, 26, 507, 198, 1045, 1551, 8, 589, 14, 1199, 63, 20309, 12, 298, 87, 531, 465, 312, 26, 686, 198, 1045, 1551, 8, 589, 14, 11142, 63, 7101, 556, 8250, 12, 298, 87, 531, 465, 312, 63, 18872, 26, 1585, 198, 3, 314, 2569, 1318, 367, 6057, 30544, 4079, 641, 699, 640, 11379, 424, 2464, 1159, 1585, 198, 3, 1177, 2348, 26, 221, 4178, 921, 1544, 14, 4492, 941, 4291, 14, 1308, 15, 80, 15, 26072, 15, 1585, 198, 667, 1661, 275, 334, 88, 59, 17, 61, 367, 671, 315, 20371, 8, 70, 12, 2400, 1004, 26, 1004, 59, 16, 61, 508, 15281, 2237, 1585, 198, 509, 1406, 315, 1433, 1661, 26, 1871, 198, 3, 5978, 314, 28192, 1871, 198, 1291, 63, 344, 275, 1406, 14, 2184, 3430, 17, 11455, 1913, 342, 1871, 198, 3, 4263, 1006, 3414, 2385, 370, 1373, 14, 1871, 198, 3610, 275, 10587, 904, 8, 83, 14, 1913, 342, 367, 308, 315, 1433, 1661, 14, 2184, 1012, 1871, 198, 2981, 63, 552, 275, 822, 8, 3610, 9, 1871, 198, 2981, 63, 78, 275, 2338, 63, 78, 8, 3610, 9, 1871, 198, 3, 11639, 3414, 1871, 198, 1222, 63, 3610, 275, 11639, 63, 4041, 8, 4671, 198, 3610, 12, 12690, 63, 8726, 63, 2738, 12, 9483, 63, 8726, 63, 2738, 12, 12690, 63, 4617, 63, 2738, 12, 4671, 198, 1521, 63, 4617, 63, 2738, 12, 12690, 63, 827, 63, 78, 12, 9483, 63, 827, 63, 78, 9, 1871, 198, 692, 892, 63, 3610, 365, 440, 488, 26, 4671, 198, 1222, 63, 552, 275, 822, 8, 1222, 63, 3610, 9, 4671, 198, 692, 892, 63, 552, 2356, 1249, 14, 10700, 63, 1267, 26, 5264, 198, 1222, 63, 78, 275, 2338, 63, 78, 8, 1222, 63, 3610, 9, 6319, 7542, 198, 3, 6990, 30544, 2777, 5264, 198, 79, 14, 952, 19651, 24423, 78, 1674, 908, 8, 1291, 63, 344, 430, 5264, 198, 1267, 275, 822, 8, 1222, 63, 3610, 9, 5264, 198, 692, 4816, 365, 440, 488, 26, 11674, 198, 509, 284, 315, 1425, 8, 16, 12, 2582, 12, 4816, 304, 22680, 198, 79, 14, 952, 8, 1222, 63, 3610, 59, 73, 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,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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 ]
emccode/HeliosBurn
heliosburn/hbcli/controllers/testplan.py
1
3747
import argparse import sys import re import json import requests from models import auth import pprint def create(config, args): pp = pprint.PrettyPrinter() url = config['url'] + "/api/testplan/" data = { "name": args['name'], "description": args['description'], } token = auth.get_token(config) r = requests.post(url, data=json.dumps(data), headers={"X-Auth-Token": token}) if r.status_code != 200: print("API returned status code %s" % (r.status_code)) sys.exit(1) else: pp.pprint(json.loads(r.content)) def read(config, args): pp = pprint.PrettyPrinter() url = config['url'] + "/api/testplan/" if (args['all'] is False) and (args['testplan'] is None): print("No testplan(s) specified to read. Use -h to see usage.") return elif args['testplan'] is not None: url += args['testplan'] + "/" token = auth.get_token(config) r = requests.get(url, headers={"X-Auth-Token": token}) if r.status_code != 200: print("API returned status code %s" % (r.status_code)) sys.exit(1) else: testplans = json.loads(r.content) pp.pprint(testplans) def update(config, args): url = config['url'] + "/api/testplan/" + args['testplan'] + "/" data = {} if args['name'] is not None: data['name'] = args['name'] if args['description'] is not None: data['description'] = args['description'] token = auth.get_token(config) r = requests.put(url, data=json.dumps(data), headers={"X-Auth-Token": token}) print("API returned status code %s" % (r.status_code)) def delete(config, args): url = config['url'] + "/api/testplan/" + args['testplan'] + "/" token = auth.get_token(config) r = requests.delete(url, headers={"X-Auth-Token": token}) print("API returned status code %s" % (r.status_code)) def main(config, args): description = "Interact with testplan objects." m = re.match(r'^.*\.(.*)$', __name__) controller_name = m.groups()[0] del sys.argv[1] parser = argparse.ArgumentParser(prog="%s %s" % (sys.argv[0], controller_name), description=description) subparsers = parser.add_subparsers(dest="action") # create create_parser = subparsers.add_parser("create", help="create testplan object") create_parser_required = create_parser.add_argument_group("required arguments") create_parser_required.add_argument("--name", type=str, required=True) create_parser.add_argument("--description", type=str) # read read_parser = subparsers.add_parser("read", help="read testplan object(s)") read_parser.add_argument("--all", action="store_const", const=True, default=False, help="read all testplans") read_parser.add_argument("--testplan", type=str, help="ID of testplan to read") # update update_parser = subparsers.add_parser("update", help="update existing testplan object") update_parser_required = update_parser.add_argument_group("required arguments") update_parser_required.add_argument("--testplan", type=str, required=True, help="testplan id to update") update_parser.add_argument("--name", type=str) update_parser.add_argument("--description", type=str) # delete delete_parser = subparsers.add_parser("delete", help="delete testplan object") delete_parser_required = delete_parser.add_argument_group("required arguments") delete_parser_required.add_argument("--testplan", type=str, required=True, help="testplan id to delete") args = vars(parser.parse_args()) action_map = { "create": create, "read": read, "update": update, "delete": delete, } action_map[args['action']](config, args)
mit
[ 646, 7534, 199, 646, 984, 199, 646, 295, 199, 646, 2022, 199, 646, 4145, 199, 504, 1709, 492, 1790, 199, 646, 10933, 421, 199, 318, 1218, 8, 888, 12, 1249, 304, 272, 11618, 275, 10933, 14, 27153, 14131, 342, 272, 1166, 275, 1101, 459, 633, 418, 435, 3286, 1246, 15, 396, 5140, 6687, 339, 666, 275, 469, 2126, 298, 354, 582, 1249, 459, 354, 995, 267, 298, 1802, 582, 1249, 459, 1802, 995, 272, 789, 339, 1526, 275, 1790, 14, 362, 63, 1418, 8, 888, 9, 272, 519, 275, 4145, 14, 1932, 8, 633, 12, 666, 29, 1001, 14, 4180, 8, 576, 395, 2323, 8871, 56, 13, 2817, 13, 3264, 582, 1526, 1552, 272, 340, 519, 14, 1205, 63, 600, 1137, 1926, 26, 267, 870, 480, 3735, 2138, 2004, 1233, 450, 83, 2, 450, 334, 82, 14, 1205, 63, 600, 430, 267, 984, 14, 2224, 8, 17, 9, 272, 587, 26, 267, 11618, 14, 15380, 8, 1001, 14, 3640, 8, 82, 14, 1317, 430, 421, 199, 318, 1586, 8, 888, 12, 1249, 304, 272, 11618, 275, 10933, 14, 27153, 14131, 342, 272, 1166, 275, 1101, 459, 633, 418, 435, 3286, 1246, 15, 396, 5140, 6687, 339, 340, 334, 589, 459, 452, 418, 365, 756, 9, 436, 334, 589, 459, 396, 5140, 418, 365, 488, 304, 267, 870, 480, 1944, 511, 5140, 8, 83, 9, 2013, 370, 1586, 14, 3645, 446, 72, 370, 1937, 4503, 2685, 267, 372, 272, 916, 1249, 459, 396, 5140, 418, 365, 440, 488, 26, 267, 1166, 847, 1249, 459, 396, 5140, 418, 435, 10609, 339, 1526, 275, 1790, 14, 362, 63, 1418, 8, 888, 9, 272, 519, 275, 4145, 14, 362, 8, 633, 12, 2323, 8871, 56, 13, 2817, 13, 3264, 582, 1526, 1552, 272, 340, 519, 14, 1205, 63, 600, 1137, 1926, 26, 267, 870, 480, 3735, 2138, 2004, 1233, 450, 83, 2, 450, 334, 82, 14, 1205, 63, 600, 430, 267, 984, 14, 2224, 8, 17, 9, 272, 587, 26, 267, 511, 1168, 796, 275, 2022, 14, 3640, 8, 82, 14, 1317, 9, 267, 11618, 14, 15380, 8, 396, 1168, 796, 9, 421, 199, 318, 1678, 8, 888, 12, 1249, 304, 272, 1166, 275, 1101, 459, 633, 418, 435, 3286, 1246, 15, 396, 5140, 6687, 435, 1249, 459, 396, 5140, 418, 435, 10609, 339, 666, 275, 1052, 339, 340, 1249, 459, 354, 418, 365, 440, 488, 26, 267, 666, 459, 354, 418, 275, 1249, 459, 354, 418, 339, 340, 1249, 459, 1802, 418, 365, 440, 488, 26, 267, 666, 459, 1802, 418, 275, 1249, 459, 1802, 418, 339, 1526, 275, 1790, 14, 362, 63, 1418, 8, 888, 9, 272, 519, 275, 4145, 14, 524, 8, 633, 12, 666, 29, 1001, 14, 4180, 8, 576, 395, 2323, 8871, 56, 13, 2817, 13, 3264, 582, 1526, 1552, 272, 870, 480, 3735, 2138, 2004, 1233, 450, 83, 2, 450, 334, 82, 14, 1205, 63, 600, 430, 421, 199, 318, 3145, 8, 888, 12, 1249, 304, 272, 1166, 275, 1101, 459, 633, 418, 435, 3286, 1246, 15, 396, 5140, 6687, 435, 1249, 459, 396, 5140, 418, 435, 10609, 272, 1526, 275, 1790, 14, 362, 63, 1418, 8, 888, 9, 272, 519, 275, 4145, 14, 1807, 8, 633, 12, 2323, 8871, 56, 13, 2817, 13, 3264, 582, 1526, 1552, 272, 870, 480, 3735, 2138, 2004, 1233, 450, 83, 2, 450, 334, 82, 14, 1205, 63, 600, 430, 421, 199, 318, 2446, 8, 888, 12, 1249, 304, 272, 1369, 275, 298, 8309, 1957, 543, 511, 5140, 2251, 2122, 272, 333, 275, 295, 14, 1431, 8, 82, 4289, 24736, 8, 12432, 4268, 636, 354, 3368, 272, 7614, 63, 354, 275, 333, 14, 2634, 3430, 16, 61, 272, 2150, 984, 14, 3020, 59, 17, 61, 272, 1798, 275, 7534, 14, 10730, 8, 6595, 5961, 83, 450, 83, 2, 450, 334, 1274, 14, 3020, 59, 16, 467, 7614, 63, 354, 395, 1369, 29, 1802, 9, 272, 26763, 275, 1798, 14, 525, 63, 954, 11531, 8, 2614, 628, 1287, 531, 339, 327, 1218, 272, 1218, 63, 2087, 275, 26763, 14, 525, 63, 2087, 480, 981, 401, 1720, 628, 981, 511, 5140, 909, 531, 272, 1218, 63, 2087, 63, 2427, 275, 1218, 63, 2087, 14, 525, 63, 2094, 63, 923, 480, 2427, 2368, 531, 272, 1218, 63, 2087, 63, 2427, 14, 525, 63, 2094, 6739, 354, 401, 730, 29, 495, 12, 1415, 29, 549, 9, 272, 1218, 63, 2087, 14, 525, 63, 2094, 6739, 1802, 401, 730, 29, 495, 9, 339, 327, 1586, 272, 1586, 63, 2087, 275, 26763, 14, 525, 63, 2087, 480, 739, 401, 1720, 628, 739, 511, 5140, 909, 8, 83, 6320, 272, 1586, 63, 2087, 14, 525, 63, 2094, 6739, 452, 401, 1595, 628, 1617, 63, 1297, 401, 950, 29, 549, 12, 849, 29, 797, 12, 1720, 628, 739, 1006, 511, 1168, 796, 531, 272, 1586, 63, 2087, 14, 525, 63, 2094, 6739, 396, 5140, 401, 730, 29, 495, 12, 1720, 628, 998, 402, 511, 5140, 370, 1586, 531, 339, 327, 1678, 272, 1678, 63, 2087, 275, 26763, 14, 525, 63, 2087, 480, 873, 401, 1720, 628, 873, 3411, 511, 5140, 909, 531, 272, 1678, 63, 2087, 63, 2427, 275, 1678, 63, 2087, 14, 525, 63, 2094, 63, 923, 480, 2427, 2368, 531, 272, 1678, 63, 2087, 63, 2427, 14, 525, 63, 2094, 6739, 396, 5140, 401, 730, 29, 495, 12, 1415, 29, 549, 12, 1720, 628, 396, 5140, 1305, 370, 1678, 531, 272, 1678, 63, 2087, 14, 525, 63, 2094, 6739, 354, 401, 730, 29, 495, 9, 272, 1678, 63, 2087, 14, 525, 63, 2094, 6739, 1802, 401, 730, 29, 495, 9, 339, 327, 3145, 272, 3145, 63, 2087, 275, 26763, 14, 525, 63, 2087, 480, 1807, 401, 1720, 628, 1807, 511, 5140, 909, 531, 272, 3145, 63, 2087, 63, 2427, 275, 3145, 63, 2087, 14, 525, 63, 2094, 63, 923, 480, 2427, 2368, 531, 272, 3145, 63, 2087, 63, 2427, 14, 525, 63, 2094, 6739, 396, 5140, 401, 730, 29, 495, 12, 1415, 29, 549, 12, 1720, 628, 396, 5140, 1305, 370, 3145, 531, 339, 1249, 275, 6802, 8, 2087, 14, 1122, 63, 589, 1012, 272, 1595, 63, 1130, 275, 469, 267, 298, 981, 582, 1218, 12, 267, 298, 739, 582, 1586, 12 ]
[ 7534, 199, 646, 984, 199, 646, 295, 199, 646, 2022, 199, 646, 4145, 199, 504, 1709, 492, 1790, 199, 646, 10933, 421, 199, 318, 1218, 8, 888, 12, 1249, 304, 272, 11618, 275, 10933, 14, 27153, 14131, 342, 272, 1166, 275, 1101, 459, 633, 418, 435, 3286, 1246, 15, 396, 5140, 6687, 339, 666, 275, 469, 2126, 298, 354, 582, 1249, 459, 354, 995, 267, 298, 1802, 582, 1249, 459, 1802, 995, 272, 789, 339, 1526, 275, 1790, 14, 362, 63, 1418, 8, 888, 9, 272, 519, 275, 4145, 14, 1932, 8, 633, 12, 666, 29, 1001, 14, 4180, 8, 576, 395, 2323, 8871, 56, 13, 2817, 13, 3264, 582, 1526, 1552, 272, 340, 519, 14, 1205, 63, 600, 1137, 1926, 26, 267, 870, 480, 3735, 2138, 2004, 1233, 450, 83, 2, 450, 334, 82, 14, 1205, 63, 600, 430, 267, 984, 14, 2224, 8, 17, 9, 272, 587, 26, 267, 11618, 14, 15380, 8, 1001, 14, 3640, 8, 82, 14, 1317, 430, 421, 199, 318, 1586, 8, 888, 12, 1249, 304, 272, 11618, 275, 10933, 14, 27153, 14131, 342, 272, 1166, 275, 1101, 459, 633, 418, 435, 3286, 1246, 15, 396, 5140, 6687, 339, 340, 334, 589, 459, 452, 418, 365, 756, 9, 436, 334, 589, 459, 396, 5140, 418, 365, 488, 304, 267, 870, 480, 1944, 511, 5140, 8, 83, 9, 2013, 370, 1586, 14, 3645, 446, 72, 370, 1937, 4503, 2685, 267, 372, 272, 916, 1249, 459, 396, 5140, 418, 365, 440, 488, 26, 267, 1166, 847, 1249, 459, 396, 5140, 418, 435, 10609, 339, 1526, 275, 1790, 14, 362, 63, 1418, 8, 888, 9, 272, 519, 275, 4145, 14, 362, 8, 633, 12, 2323, 8871, 56, 13, 2817, 13, 3264, 582, 1526, 1552, 272, 340, 519, 14, 1205, 63, 600, 1137, 1926, 26, 267, 870, 480, 3735, 2138, 2004, 1233, 450, 83, 2, 450, 334, 82, 14, 1205, 63, 600, 430, 267, 984, 14, 2224, 8, 17, 9, 272, 587, 26, 267, 511, 1168, 796, 275, 2022, 14, 3640, 8, 82, 14, 1317, 9, 267, 11618, 14, 15380, 8, 396, 1168, 796, 9, 421, 199, 318, 1678, 8, 888, 12, 1249, 304, 272, 1166, 275, 1101, 459, 633, 418, 435, 3286, 1246, 15, 396, 5140, 6687, 435, 1249, 459, 396, 5140, 418, 435, 10609, 339, 666, 275, 1052, 339, 340, 1249, 459, 354, 418, 365, 440, 488, 26, 267, 666, 459, 354, 418, 275, 1249, 459, 354, 418, 339, 340, 1249, 459, 1802, 418, 365, 440, 488, 26, 267, 666, 459, 1802, 418, 275, 1249, 459, 1802, 418, 339, 1526, 275, 1790, 14, 362, 63, 1418, 8, 888, 9, 272, 519, 275, 4145, 14, 524, 8, 633, 12, 666, 29, 1001, 14, 4180, 8, 576, 395, 2323, 8871, 56, 13, 2817, 13, 3264, 582, 1526, 1552, 272, 870, 480, 3735, 2138, 2004, 1233, 450, 83, 2, 450, 334, 82, 14, 1205, 63, 600, 430, 421, 199, 318, 3145, 8, 888, 12, 1249, 304, 272, 1166, 275, 1101, 459, 633, 418, 435, 3286, 1246, 15, 396, 5140, 6687, 435, 1249, 459, 396, 5140, 418, 435, 10609, 272, 1526, 275, 1790, 14, 362, 63, 1418, 8, 888, 9, 272, 519, 275, 4145, 14, 1807, 8, 633, 12, 2323, 8871, 56, 13, 2817, 13, 3264, 582, 1526, 1552, 272, 870, 480, 3735, 2138, 2004, 1233, 450, 83, 2, 450, 334, 82, 14, 1205, 63, 600, 430, 421, 199, 318, 2446, 8, 888, 12, 1249, 304, 272, 1369, 275, 298, 8309, 1957, 543, 511, 5140, 2251, 2122, 272, 333, 275, 295, 14, 1431, 8, 82, 4289, 24736, 8, 12432, 4268, 636, 354, 3368, 272, 7614, 63, 354, 275, 333, 14, 2634, 3430, 16, 61, 272, 2150, 984, 14, 3020, 59, 17, 61, 272, 1798, 275, 7534, 14, 10730, 8, 6595, 5961, 83, 450, 83, 2, 450, 334, 1274, 14, 3020, 59, 16, 467, 7614, 63, 354, 395, 1369, 29, 1802, 9, 272, 26763, 275, 1798, 14, 525, 63, 954, 11531, 8, 2614, 628, 1287, 531, 339, 327, 1218, 272, 1218, 63, 2087, 275, 26763, 14, 525, 63, 2087, 480, 981, 401, 1720, 628, 981, 511, 5140, 909, 531, 272, 1218, 63, 2087, 63, 2427, 275, 1218, 63, 2087, 14, 525, 63, 2094, 63, 923, 480, 2427, 2368, 531, 272, 1218, 63, 2087, 63, 2427, 14, 525, 63, 2094, 6739, 354, 401, 730, 29, 495, 12, 1415, 29, 549, 9, 272, 1218, 63, 2087, 14, 525, 63, 2094, 6739, 1802, 401, 730, 29, 495, 9, 339, 327, 1586, 272, 1586, 63, 2087, 275, 26763, 14, 525, 63, 2087, 480, 739, 401, 1720, 628, 739, 511, 5140, 909, 8, 83, 6320, 272, 1586, 63, 2087, 14, 525, 63, 2094, 6739, 452, 401, 1595, 628, 1617, 63, 1297, 401, 950, 29, 549, 12, 849, 29, 797, 12, 1720, 628, 739, 1006, 511, 1168, 796, 531, 272, 1586, 63, 2087, 14, 525, 63, 2094, 6739, 396, 5140, 401, 730, 29, 495, 12, 1720, 628, 998, 402, 511, 5140, 370, 1586, 531, 339, 327, 1678, 272, 1678, 63, 2087, 275, 26763, 14, 525, 63, 2087, 480, 873, 401, 1720, 628, 873, 3411, 511, 5140, 909, 531, 272, 1678, 63, 2087, 63, 2427, 275, 1678, 63, 2087, 14, 525, 63, 2094, 63, 923, 480, 2427, 2368, 531, 272, 1678, 63, 2087, 63, 2427, 14, 525, 63, 2094, 6739, 396, 5140, 401, 730, 29, 495, 12, 1415, 29, 549, 12, 1720, 628, 396, 5140, 1305, 370, 1678, 531, 272, 1678, 63, 2087, 14, 525, 63, 2094, 6739, 354, 401, 730, 29, 495, 9, 272, 1678, 63, 2087, 14, 525, 63, 2094, 6739, 1802, 401, 730, 29, 495, 9, 339, 327, 3145, 272, 3145, 63, 2087, 275, 26763, 14, 525, 63, 2087, 480, 1807, 401, 1720, 628, 1807, 511, 5140, 909, 531, 272, 3145, 63, 2087, 63, 2427, 275, 3145, 63, 2087, 14, 525, 63, 2094, 63, 923, 480, 2427, 2368, 531, 272, 3145, 63, 2087, 63, 2427, 14, 525, 63, 2094, 6739, 396, 5140, 401, 730, 29, 495, 12, 1415, 29, 549, 12, 1720, 628, 396, 5140, 1305, 370, 3145, 531, 339, 1249, 275, 6802, 8, 2087, 14, 1122, 63, 589, 1012, 272, 1595, 63, 1130, 275, 469, 267, 298, 981, 582, 1218, 12, 267, 298, 739, 582, 1586, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
potsmaster/cinder
cinder/backup/api.py
4
16756
# Copyright (C) 2012 Hewlett-Packard Development Company, L.P. # Copyright (c) 2014 TrilioData, Inc # Copyright (c) 2015 EMC Corporation # 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. """ Handles all requests relating to the volume backups service. """ from eventlet import greenthread from oslo_config import cfg from oslo_log import log as logging from oslo_utils import excutils from oslo_utils import strutils from cinder.backup import rpcapi as backup_rpcapi from cinder import context from cinder.db import base from cinder import exception from cinder.i18n import _, _LI, _LW from cinder import objects import cinder.policy from cinder import quota from cinder import utils import cinder.volume from cinder.volume import utils as volume_utils CONF = cfg.CONF LOG = logging.getLogger(__name__) QUOTAS = quota.QUOTAS def check_policy(context, action): target = { 'project_id': context.project_id, 'user_id': context.user_id, } _action = 'backup:%s' % action cinder.policy.enforce(context, _action, target) class API(base.Base): """API for interacting with the volume backup manager.""" def __init__(self, db_driver=None): self.backup_rpcapi = backup_rpcapi.BackupAPI() self.volume_api = cinder.volume.API() super(API, self).__init__(db_driver) def get(self, context, backup_id): check_policy(context, 'get') return objects.Backup.get_by_id(context, backup_id) def _check_support_to_force_delete(self, context, backup_host): result = self.backup_rpcapi.check_support_to_force_delete(context, backup_host) return result def delete(self, context, backup, force=False): """Make the RPC call to delete a volume backup. Call backup manager to execute backup delete or force delete operation. :param context: running context :param backup: the dict of backup that is got from DB. :param force: indicate force delete or not :raises: InvalidBackup :raises: BackupDriverException """ check_policy(context, 'delete') if not force and backup.status not in ['available', 'error']: msg = _('Backup status must be available or error') raise exception.InvalidBackup(reason=msg) if force and not self._check_support_to_force_delete(context, backup.host): msg = _('force delete') raise exception.NotSupportedOperation(operation=msg) # Don't allow backup to be deleted if there are incremental # backups dependent on it. deltas = self.get_all(context, {'parent_id': backup.id}) if deltas and len(deltas): msg = _('Incremental backups exist for this backup.') raise exception.InvalidBackup(reason=msg) backup.status = 'deleting' backup.save() self.backup_rpcapi.delete_backup(context, backup) def get_all(self, context, search_opts=None): check_policy(context, 'get_all') search_opts = search_opts or {} all_tenants = search_opts.pop('all_tenants', '0') if not utils.is_valid_boolstr(all_tenants): msg = _("all_tenants must be a boolean, got '%s'.") % all_tenants raise exception.InvalidParameterValue(err=msg) if context.is_admin and strutils.bool_from_string(all_tenants): backups = objects.BackupList.get_all(context, filters=search_opts) else: backups = objects.BackupList.get_all_by_project( context, context.project_id, filters=search_opts ) return backups def _is_backup_service_enabled(self, volume, volume_host): """Check if there is a backup service available.""" topic = CONF.backup_topic ctxt = context.get_admin_context() services = self.db.service_get_all_by_topic(ctxt, topic, disabled=False) for srv in services: if (srv['availability_zone'] == volume['availability_zone'] and srv['host'] == volume_host and utils.service_is_up(srv)): return True return False def _list_backup_services(self): """List all enabled backup services. :returns: list -- hosts for services that are enabled for backup. """ topic = CONF.backup_topic ctxt = context.get_admin_context() services = self.db.service_get_all_by_topic(ctxt, topic) return [srv['host'] for srv in services if not srv['disabled']] def create(self, context, name, description, volume_id, container, incremental=False, availability_zone=None, force=False): """Make the RPC call to create a volume backup.""" check_policy(context, 'create') volume = self.volume_api.get(context, volume_id) if volume['status'] not in ["available", "in-use"]: msg = (_('Volume to be backed up must be available ' 'or in-use, but the current status is "%s".') % volume['status']) raise exception.InvalidVolume(reason=msg) elif volume['status'] in ["in-use"] and not force: msg = _('Backing up an in-use volume must use ' 'the force flag.') raise exception.InvalidVolume(reason=msg) previous_status = volume['status'] volume_host = volume_utils.extract_host(volume['host'], 'host') if not self._is_backup_service_enabled(volume, volume_host): raise exception.ServiceNotFound(service_id='cinder-backup') # do quota reserver before setting volume status and backup status try: reserve_opts = {'backups': 1, 'backup_gigabytes': volume['size']} reservations = QUOTAS.reserve(context, **reserve_opts) except exception.OverQuota as e: overs = e.kwargs['overs'] usages = e.kwargs['usages'] quotas = e.kwargs['quotas'] def _consumed(resource_name): return (usages[resource_name]['reserved'] + usages[resource_name]['in_use']) for over in overs: if 'gigabytes' in over: msg = _LW("Quota exceeded for %(s_pid)s, tried to create " "%(s_size)sG backup (%(d_consumed)dG of " "%(d_quota)dG already consumed)") LOG.warning(msg, {'s_pid': context.project_id, 's_size': volume['size'], 'd_consumed': _consumed(over), 'd_quota': quotas[over]}) raise exception.VolumeBackupSizeExceedsAvailableQuota( requested=volume['size'], consumed=_consumed('backup_gigabytes'), quota=quotas['backup_gigabytes']) elif 'backups' in over: msg = _LW("Quota exceeded for %(s_pid)s, tried to create " "backups (%(d_consumed)d backups " "already consumed)") LOG.warning(msg, {'s_pid': context.project_id, 'd_consumed': _consumed(over)}) raise exception.BackupLimitExceeded( allowed=quotas[over]) # Find the latest backup of the volume and use it as the parent # backup to do an incremental backup. latest_backup = None if incremental: backups = objects.BackupList.get_all_by_volume(context.elevated(), volume_id) if backups.objects: latest_backup = max(backups.objects, key=lambda x: x['created_at']) else: msg = _('No backups available to do an incremental backup.') raise exception.InvalidBackup(reason=msg) parent_id = None if latest_backup: parent_id = latest_backup.id if latest_backup['status'] != "available": msg = _('The parent backup must be available for ' 'incremental backup.') raise exception.InvalidBackup(reason=msg) self.db.volume_update(context, volume_id, {'status': 'backing-up', 'previous_status': previous_status}) try: kwargs = { 'user_id': context.user_id, 'project_id': context.project_id, 'display_name': name, 'display_description': description, 'volume_id': volume_id, 'status': 'creating', 'container': container, 'parent_id': parent_id, 'size': volume['size'], 'host': volume_host, } backup = objects.Backup(context=context, **kwargs) backup.create() QUOTAS.commit(context, reservations) except Exception: with excutils.save_and_reraise_exception(): try: backup.destroy() finally: QUOTAS.rollback(context, reservations) # TODO(DuncanT): In future, when we have a generic local attach, # this can go via the scheduler, which enables # better load balancing and isolation of services self.backup_rpcapi.create_backup(context, backup) return backup def restore(self, context, backup_id, volume_id=None, name=None): """Make the RPC call to restore a volume backup.""" check_policy(context, 'restore') backup = self.get(context, backup_id) if backup['status'] != 'available': msg = _('Backup status must be available') raise exception.InvalidBackup(reason=msg) size = backup['size'] if size is None: msg = _('Backup to be restored has invalid size') raise exception.InvalidBackup(reason=msg) # Create a volume if none specified. If a volume is specified check # it is large enough for the backup if volume_id is None: if name is None: name = 'restore_backup_%s' % backup_id description = 'auto-created_from_restore_from_backup' LOG.info(_LI("Creating volume of %(size)s GB for restore of " "backup %(backup_id)s."), {'size': size, 'backup_id': backup_id}, context=context) volume = self.volume_api.create(context, size, name, description) volume_id = volume['id'] while True: volume = self.volume_api.get(context, volume_id) if volume['status'] != 'creating': break greenthread.sleep(1) else: volume = self.volume_api.get(context, volume_id) if volume['status'] != "available": msg = _('Volume to be restored to must be available') raise exception.InvalidVolume(reason=msg) LOG.debug('Checking backup size %(bs)s against volume size %(vs)s', {'bs': size, 'vs': volume['size']}) if size > volume['size']: msg = (_('volume size %(volume_size)d is too small to restore ' 'backup of size %(size)d.') % {'volume_size': volume['size'], 'size': size}) raise exception.InvalidVolume(reason=msg) LOG.info(_LI("Overwriting volume %(volume_id)s with restore of " "backup %(backup_id)s"), {'volume_id': volume_id, 'backup_id': backup_id}, context=context) # Setting the status here rather than setting at start and unrolling # for each error condition, it should be a very small window backup.status = 'restoring' backup.save() volume_host = volume_utils.extract_host(volume['host'], 'host') self.db.volume_update(context, volume_id, {'status': 'restoring-backup'}) self.backup_rpcapi.restore_backup(context, volume_host, backup, volume_id) d = {'backup_id': backup_id, 'volume_id': volume_id, 'volume_name': volume['display_name'], } return d def reset_status(self, context, backup_id, status): """Make the RPC call to reset a volume backup's status. Call backup manager to execute backup status reset operation. :param context: running context :param backup_id: which backup's status to be reset :parma status: backup's status to be reset :raises: InvalidBackup """ # get backup info backup = self.get(context, backup_id) # send to manager to do reset operation self.backup_rpcapi.reset_status(ctxt=context, backup=backup, status=status) def export_record(self, context, backup_id): """Make the RPC call to export a volume backup. Call backup manager to execute backup export. :param context: running context :param backup_id: backup id to export :returns: dictionary -- a description of how to import the backup :returns: contains 'backup_url' and 'backup_service' :raises: InvalidBackup """ check_policy(context, 'backup-export') backup = self.get(context, backup_id) if backup['status'] != 'available': msg = (_('Backup status must be available and not %s.') % backup['status']) raise exception.InvalidBackup(reason=msg) LOG.debug("Calling RPCAPI with context: " "%(ctx)s, host: %(host)s, backup: %(id)s.", {'ctx': context, 'host': backup['host'], 'id': backup['id']}) export_data = self.backup_rpcapi.export_record(context, backup) return export_data def import_record(self, context, backup_service, backup_url): """Make the RPC call to import a volume backup. :param context: running context :param backup_service: backup service name :param backup_url: backup description to be used by the backup driver :raises: InvalidBackup :raises: ServiceNotFound """ check_policy(context, 'backup-import') # NOTE(ronenkat): since we don't have a backup-scheduler # we need to find a host that support the backup service # that was used to create the backup. # We send it to the first backup service host, and the backup manager # on that host will forward it to other hosts on the hosts list if it # cannot support correct service itself. hosts = self._list_backup_services() if len(hosts) == 0: raise exception.ServiceNotFound(service_id=backup_service) kwargs = { 'user_id': context.user_id, 'project_id': context.project_id, 'volume_id': '0000-0000-0000-0000', 'status': 'creating', } backup = objects.Backup(context=context, **kwargs) backup.create() first_host = hosts.pop() self.backup_rpcapi.import_record(context, first_host, backup, backup_service, backup_url, hosts) return backup
apache-2.0
[ 3, 1898, 334, 35, 9, 6029, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 1898, 334, 67, 9, 6927, 12480, 14437, 1451, 12, 3277, 199, 3, 1898, 334, 67, 9, 6900, 662, 7608, 11098, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 199, 23555, 1006, 4145, 4668, 1958, 370, 314, 3301, 6902, 83, 2435, 14, 199, 624, 421, 199, 504, 21819, 492, 12431, 2671, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 504, 11258, 63, 1208, 492, 32763, 199, 504, 11258, 63, 1208, 492, 620, 1208, 199, 199, 504, 13069, 14, 5751, 492, 8985, 1246, 465, 6902, 63, 20776, 199, 504, 13069, 492, 1067, 199, 504, 13069, 14, 697, 492, 1300, 199, 504, 13069, 492, 1919, 199, 504, 13069, 14, 73, 1085, 78, 492, 5501, 485, 2673, 12, 485, 20145, 199, 504, 13069, 492, 2251, 199, 646, 13069, 14, 3185, 199, 504, 13069, 492, 12132, 199, 504, 13069, 492, 3778, 199, 646, 13069, 14, 2405, 199, 504, 13069, 14, 2405, 492, 3778, 465, 3301, 63, 1208, 199, 199, 3103, 275, 4810, 14, 3103, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 18654, 1179, 275, 12132, 14, 18654, 1179, 421, 199, 318, 1104, 63, 3185, 8, 1100, 12, 1595, 304, 272, 1347, 275, 469, 267, 283, 1715, 63, 344, 356, 1067, 14, 1715, 63, 344, 12, 267, 283, 751, 63, 344, 356, 1067, 14, 751, 63, 344, 12, 272, 789, 272, 485, 1287, 275, 283, 5751, 2689, 83, 7, 450, 1595, 272, 13069, 14, 3185, 14, 19817, 8, 1100, 12, 485, 1287, 12, 1347, 9, 421, 199, 533, 3261, 8, 1095, 14, 1563, 304, 272, 408, 3735, 367, 17232, 316, 543, 314, 3301, 6902, 5256, 1041, 339, 347, 636, 826, 721, 277, 12, 1592, 63, 3090, 29, 403, 304, 267, 291, 14, 5751, 63, 20776, 275, 6902, 63, 20776, 14, 16559, 3735, 342, 267, 291, 14, 2405, 63, 1246, 275, 13069, 14, 2405, 14, 3735, 342, 267, 1613, 8, 3735, 12, 291, 2843, 826, 721, 697, 63, 3090, 9, 339, 347, 664, 8, 277, 12, 1067, 12, 6902, 63, 344, 304, 267, 1104, 63, 3185, 8, 1100, 12, 283, 362, 358, 267, 372, 2251, 14, 16559, 14, 362, 63, 991, 63, 344, 8, 1100, 12, 6902, 63, 344, 9, 339, 347, 485, 1074, 63, 4058, 63, 475, 63, 3990, 63, 1807, 8, 277, 12, 1067, 12, 6902, 63, 1102, 304, 267, 754, 275, 291, 14, 5751, 63, 20776, 14, 1074, 63, 4058, 63, 475, 63, 3990, 63, 1807, 8, 1100, 12, 25404, 6902, 63, 1102, 9, 267, 372, 754, 339, 347, 3145, 8, 277, 12, 1067, 12, 6902, 12, 3542, 29, 797, 304, 267, 408, 5483, 314, 11785, 1240, 370, 3145, 282, 3301, 6902, 14, 398, 6523, 6902, 5256, 370, 5341, 6902, 3145, 503, 3542, 3145, 3439, 14, 267, 520, 635, 1067, 26, 3879, 1067, 267, 520, 635, 6902, 26, 314, 1211, 402, 6902, 626, 365, 4788, 687, 6249, 14, 267, 520, 635, 3542, 26, 6623, 3542, 3145, 503, 440, 267, 520, 3536, 26, 6378, 16559, 267, 520, 3536, 26, 10257, 384, 6158, 1726, 267, 408, 267, 1104, 63, 3185, 8, 1100, 12, 283, 1807, 358, 267, 340, 440, 3542, 436, 6902, 14, 1205, 440, 315, 788, 4561, 297, 283, 705, 2565, 288, 1499, 275, 4018, 16559, 2004, 1471, 506, 2808, 503, 1125, 358, 288, 746, 1919, 14, 3364, 16559, 8, 5764, 29, 1328, 9, 267, 340, 3542, 436, 440, 291, 423, 1074, 63, 4058, 63, 475, 63, 3990, 63, 1807, 8, 1100, 12, 18193, 6902, 14, 1102, 304, 288, 1499, 275, 4018, 3990, 3145, 358, 288, 746, 1919, 14, 26077, 6044, 8, 5735, 29, 1328, 9, 398, 327, 7529, 1133, 2040, 6902, 370, 506, 5463, 340, 2337, 787, 16316, 267, 327, 6902, 83, 11410, 641, 652, 14, 267, 27446, 275, 291, 14, 362, 63, 452, 8, 1100, 12, 791, 1708, 63, 344, 356, 6902, 14, 344, 1552, 267, 340, 27446, 436, 822, 8, 25446, 304, 288, 1499, 275, 4018, 10287, 6902, 83, 2187, 367, 642, 6902, 2659, 288, 746, 1919, 14, 3364, 16559, 8, 5764, 29, 1328, 9, 398, 6902, 14, 1205, 275, 283, 7346, 1337, 7, 267, 6902, 14, 2117, 342, 267, 291, 14, 5751, 63, 20776, 14, 1807, 63, 5751, 8, 1100, 12, 6902, 9, 339, 347, 664, 63, 452, 8, 277, 12, 1067, 12, 2754, 63, 3291, 29, 403, 304, 267, 1104, 63, 3185, 8, 1100, 12, 283, 362, 63, 452, 358, 398, 2754, 63, 3291, 275, 2754, 63, 3291, 503, 1052, 398, 1006, 63, 25021, 275, 2754, 63, 3291, 14, 1935, 360, 452, 63, 25021, 297, 283, 16, 358, 267, 340, 440, 3778, 14, 374, 63, 1078, 63, 2245, 495, 8, 452, 63, 25021, 304, 288, 1499, 275, 3824, 452, 63, 25021, 1471, 506, 282, 5046, 12, 4788, 1543, 83, 29435, 450, 1006, 63, 25021, 288, 746, 1919, 14, 3364, 24637, 8, 1508, 29, 1328, 9, 398, 340, 1067, 14, 374, 63, 2113, 436, 620, 1208, 14, 2245, 63, 504, 63, 875, 8, 452, 63, 25021, 304, 288, 6902, 83, 275, 2251, 14, 16559, 1296, 14, 362, 63, 452, 8, 1100, 12, 4766, 29, 1733, 63, 3291, 9, 267, 587, 26, 288, 6902, 83, 275, 2251, 14, 16559, 1296, 14, 362, 63, 452, 63, 991, 63, 1715, 8, 355, 1067, 12, 355, 1067, 14, 1715 ]
[ 1898, 334, 35, 9, 6029, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 1898, 334, 67, 9, 6927, 12480, 14437, 1451, 12, 3277, 199, 3, 1898, 334, 67, 9, 6900, 662, 7608, 11098, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 199, 23555, 1006, 4145, 4668, 1958, 370, 314, 3301, 6902, 83, 2435, 14, 199, 624, 421, 199, 504, 21819, 492, 12431, 2671, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 504, 11258, 63, 1208, 492, 32763, 199, 504, 11258, 63, 1208, 492, 620, 1208, 199, 199, 504, 13069, 14, 5751, 492, 8985, 1246, 465, 6902, 63, 20776, 199, 504, 13069, 492, 1067, 199, 504, 13069, 14, 697, 492, 1300, 199, 504, 13069, 492, 1919, 199, 504, 13069, 14, 73, 1085, 78, 492, 5501, 485, 2673, 12, 485, 20145, 199, 504, 13069, 492, 2251, 199, 646, 13069, 14, 3185, 199, 504, 13069, 492, 12132, 199, 504, 13069, 492, 3778, 199, 646, 13069, 14, 2405, 199, 504, 13069, 14, 2405, 492, 3778, 465, 3301, 63, 1208, 199, 199, 3103, 275, 4810, 14, 3103, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 18654, 1179, 275, 12132, 14, 18654, 1179, 421, 199, 318, 1104, 63, 3185, 8, 1100, 12, 1595, 304, 272, 1347, 275, 469, 267, 283, 1715, 63, 344, 356, 1067, 14, 1715, 63, 344, 12, 267, 283, 751, 63, 344, 356, 1067, 14, 751, 63, 344, 12, 272, 789, 272, 485, 1287, 275, 283, 5751, 2689, 83, 7, 450, 1595, 272, 13069, 14, 3185, 14, 19817, 8, 1100, 12, 485, 1287, 12, 1347, 9, 421, 199, 533, 3261, 8, 1095, 14, 1563, 304, 272, 408, 3735, 367, 17232, 316, 543, 314, 3301, 6902, 5256, 1041, 339, 347, 636, 826, 721, 277, 12, 1592, 63, 3090, 29, 403, 304, 267, 291, 14, 5751, 63, 20776, 275, 6902, 63, 20776, 14, 16559, 3735, 342, 267, 291, 14, 2405, 63, 1246, 275, 13069, 14, 2405, 14, 3735, 342, 267, 1613, 8, 3735, 12, 291, 2843, 826, 721, 697, 63, 3090, 9, 339, 347, 664, 8, 277, 12, 1067, 12, 6902, 63, 344, 304, 267, 1104, 63, 3185, 8, 1100, 12, 283, 362, 358, 267, 372, 2251, 14, 16559, 14, 362, 63, 991, 63, 344, 8, 1100, 12, 6902, 63, 344, 9, 339, 347, 485, 1074, 63, 4058, 63, 475, 63, 3990, 63, 1807, 8, 277, 12, 1067, 12, 6902, 63, 1102, 304, 267, 754, 275, 291, 14, 5751, 63, 20776, 14, 1074, 63, 4058, 63, 475, 63, 3990, 63, 1807, 8, 1100, 12, 25404, 6902, 63, 1102, 9, 267, 372, 754, 339, 347, 3145, 8, 277, 12, 1067, 12, 6902, 12, 3542, 29, 797, 304, 267, 408, 5483, 314, 11785, 1240, 370, 3145, 282, 3301, 6902, 14, 398, 6523, 6902, 5256, 370, 5341, 6902, 3145, 503, 3542, 3145, 3439, 14, 267, 520, 635, 1067, 26, 3879, 1067, 267, 520, 635, 6902, 26, 314, 1211, 402, 6902, 626, 365, 4788, 687, 6249, 14, 267, 520, 635, 3542, 26, 6623, 3542, 3145, 503, 440, 267, 520, 3536, 26, 6378, 16559, 267, 520, 3536, 26, 10257, 384, 6158, 1726, 267, 408, 267, 1104, 63, 3185, 8, 1100, 12, 283, 1807, 358, 267, 340, 440, 3542, 436, 6902, 14, 1205, 440, 315, 788, 4561, 297, 283, 705, 2565, 288, 1499, 275, 4018, 16559, 2004, 1471, 506, 2808, 503, 1125, 358, 288, 746, 1919, 14, 3364, 16559, 8, 5764, 29, 1328, 9, 267, 340, 3542, 436, 440, 291, 423, 1074, 63, 4058, 63, 475, 63, 3990, 63, 1807, 8, 1100, 12, 18193, 6902, 14, 1102, 304, 288, 1499, 275, 4018, 3990, 3145, 358, 288, 746, 1919, 14, 26077, 6044, 8, 5735, 29, 1328, 9, 398, 327, 7529, 1133, 2040, 6902, 370, 506, 5463, 340, 2337, 787, 16316, 267, 327, 6902, 83, 11410, 641, 652, 14, 267, 27446, 275, 291, 14, 362, 63, 452, 8, 1100, 12, 791, 1708, 63, 344, 356, 6902, 14, 344, 1552, 267, 340, 27446, 436, 822, 8, 25446, 304, 288, 1499, 275, 4018, 10287, 6902, 83, 2187, 367, 642, 6902, 2659, 288, 746, 1919, 14, 3364, 16559, 8, 5764, 29, 1328, 9, 398, 6902, 14, 1205, 275, 283, 7346, 1337, 7, 267, 6902, 14, 2117, 342, 267, 291, 14, 5751, 63, 20776, 14, 1807, 63, 5751, 8, 1100, 12, 6902, 9, 339, 347, 664, 63, 452, 8, 277, 12, 1067, 12, 2754, 63, 3291, 29, 403, 304, 267, 1104, 63, 3185, 8, 1100, 12, 283, 362, 63, 452, 358, 398, 2754, 63, 3291, 275, 2754, 63, 3291, 503, 1052, 398, 1006, 63, 25021, 275, 2754, 63, 3291, 14, 1935, 360, 452, 63, 25021, 297, 283, 16, 358, 267, 340, 440, 3778, 14, 374, 63, 1078, 63, 2245, 495, 8, 452, 63, 25021, 304, 288, 1499, 275, 3824, 452, 63, 25021, 1471, 506, 282, 5046, 12, 4788, 1543, 83, 29435, 450, 1006, 63, 25021, 288, 746, 1919, 14, 3364, 24637, 8, 1508, 29, 1328, 9, 398, 340, 1067, 14, 374, 63, 2113, 436, 620, 1208, 14, 2245, 63, 504, 63, 875, 8, 452, 63, 25021, 304, 288, 6902, 83, 275, 2251, 14, 16559, 1296, 14, 362, 63, 452, 8, 1100, 12, 4766, 29, 1733, 63, 3291, 9, 267, 587, 26, 288, 6902, 83, 275, 2251, 14, 16559, 1296, 14, 362, 63, 452, 63, 991, 63, 1715, 8,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
HydrelioxGitHub/home-assistant
homeassistant/components/cover/myq.py
4
3260
""" Support for MyQ-Enabled Garage Doors. For more details about this platform, please refer to the documentation https://home-assistant.io/components/cover.myq/ """ import logging import voluptuous as vol from homeassistant.components.cover import ( PLATFORM_SCHEMA, SUPPORT_CLOSE, SUPPORT_OPEN, CoverDevice) from homeassistant.const import ( CONF_PASSWORD, CONF_TYPE, CONF_USERNAME, STATE_CLOSED, STATE_CLOSING, STATE_OPEN, STATE_OPENING) from homeassistant.helpers import aiohttp_client, config_validation as cv REQUIREMENTS = ['pymyq==1.1.0'] _LOGGER = logging.getLogger(__name__) MYQ_TO_HASS = { 'closed': STATE_CLOSED, 'closing': STATE_CLOSING, 'open': STATE_OPEN, 'opening': STATE_OPENING } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_TYPE): cv.string, vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string }) async def async_setup_platform( hass, config, async_add_entities, discovery_info=None): """Set up the platform.""" from pymyq import login from pymyq.errors import MyQError, UnsupportedBrandError websession = aiohttp_client.async_get_clientsession(hass) username = config[CONF_USERNAME] password = config[CONF_PASSWORD] brand = config[CONF_TYPE] try: myq = await login(username, password, brand, websession) except UnsupportedBrandError: _LOGGER.error('Unsupported brand: %s', brand) return except MyQError as err: _LOGGER.error('There was an error while logging in: %s', err) return devices = await myq.get_devices() async_add_entities([MyQDevice(device) for device in devices], True) class MyQDevice(CoverDevice): """Representation of a MyQ cover.""" def __init__(self, device): """Initialize with API object, device id.""" self._device = device @property def device_class(self): """Define this cover as a garage door.""" return 'garage' @property def name(self): """Return the name of the garage door if any.""" return self._device.name @property def is_closed(self): """Return true if cover is closed, else False.""" return MYQ_TO_HASS.get(self._device.state) == STATE_CLOSED @property def is_closing(self): """Return if the cover is closing or not.""" return MYQ_TO_HASS.get(self._device.state) == STATE_CLOSING @property def is_opening(self): """Return if the cover is opening or not.""" return MYQ_TO_HASS.get(self._device.state) == STATE_OPENING @property def supported_features(self): """Flag supported features.""" return SUPPORT_OPEN | SUPPORT_CLOSE @property def unique_id(self): """Return a unique, HASS-friendly identifier for this entity.""" return self._device.device_id async def async_close_cover(self, **kwargs): """Issue close command to cover.""" await self._device.close() async def async_open_cover(self, **kwargs): """Issue open command to cover.""" await self._device.open() async def async_update(self): """Update status of cover.""" await self._device.update()
apache-2.0
[ 624, 199, 11532, 367, 4932, 49, 13, 6589, 598, 285, 474, 4226, 1384, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 5899, 14, 1662, 81, 15, 199, 624, 199, 646, 2050, 199, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 4608, 14, 5899, 492, 334, 272, 21966, 63, 10926, 12, 13756, 63, 18219, 12, 13756, 63, 9935, 12, 1849, 422, 2510, 9, 199, 504, 8846, 14, 1297, 492, 334, 272, 6392, 63, 9032, 12, 6392, 63, 2711, 12, 6392, 63, 11958, 12, 11377, 63, 26270, 12, 11377, 63, 10353, 12567, 12, 272, 11377, 63, 9935, 12, 11377, 63, 9935, 1206, 9, 199, 504, 8846, 14, 7546, 492, 30274, 63, 1258, 12, 1101, 63, 6136, 465, 6277, 199, 199, 29168, 20967, 275, 788, 647, 1662, 81, 389, 17, 14, 17, 14, 16, 418, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 12339, 49, 63, 2566, 63, 40, 3755, 275, 469, 272, 283, 5938, 356, 11377, 63, 26270, 12, 272, 283, 11707, 356, 11377, 63, 10353, 12567, 12, 272, 283, 1490, 356, 11377, 63, 9935, 12, 272, 283, 21849, 356, 11377, 63, 9935, 1206, 199, 93, 199, 199, 17805, 63, 10926, 275, 21966, 63, 10926, 14, 2880, 2561, 272, 5236, 14, 8030, 8, 3103, 63, 2711, 304, 6277, 14, 875, 12, 272, 5236, 14, 8030, 8, 3103, 63, 11958, 304, 6277, 14, 875, 12, 272, 5236, 14, 8030, 8, 3103, 63, 9032, 304, 6277, 14, 875, 199, 1552, 421, 199, 4146, 347, 5316, 63, 2758, 63, 3246, 8, 267, 6298, 12, 1101, 12, 5316, 63, 525, 63, 8327, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 1084, 1536, 314, 4298, 1041, 272, 687, 1134, 1662, 81, 492, 4676, 272, 687, 1134, 1662, 81, 14, 2550, 492, 4932, 49, 547, 12, 19022, 34, 3759, 547, 339, 3330, 1730, 275, 30274, 63, 1258, 14, 4146, 63, 362, 63, 1258, 1730, 8, 5387, 9, 339, 3434, 275, 1101, 59, 3103, 63, 11958, 61, 272, 2505, 275, 1101, 59, 3103, 63, 9032, 61, 272, 32159, 275, 1101, 59, 3103, 63, 2711, 61, 339, 862, 26, 267, 3002, 81, 275, 5517, 4676, 8, 2473, 12, 2505, 12, 32159, 12, 3330, 1730, 9, 272, 871, 19022, 34, 3759, 547, 26, 267, 485, 10186, 14, 705, 360, 12647, 32159, 26, 450, 83, 297, 32159, 9, 267, 372, 272, 871, 4932, 49, 547, 465, 2329, 26, 267, 485, 10186, 14, 705, 360, 10924, 1990, 376, 1125, 1830, 2050, 315, 26, 450, 83, 297, 2329, 9, 267, 372, 339, 7256, 275, 5517, 3002, 81, 14, 362, 63, 6410, 342, 272, 5316, 63, 525, 63, 8327, 779, 5713, 49, 2510, 8, 1782, 9, 367, 2243, 315, 7256, 467, 715, 9, 421, 199, 533, 4932, 49, 2510, 8, 31048, 2510, 304, 272, 408, 20609, 402, 282, 4932, 49, 8486, 1041, 339, 347, 636, 826, 721, 277, 12, 2243, 304, 267, 408, 9345, 543, 3261, 909, 12, 2243, 1305, 1041, 267, 291, 423, 1782, 275, 2243, 339, 768, 1829, 272, 347, 2243, 63, 533, 8, 277, 304, 267, 408, 16213, 642, 8486, 465, 282, 486, 285, 474, 886, 269, 1041, 267, 372, 283, 23909, 474, 7, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 486, 285, 474, 886, 269, 340, 1263, 1041, 267, 372, 291, 423, 1782, 14, 354, 339, 768, 1829, 272, 347, 365, 63, 5938, 8, 277, 304, 267, 408, 1767, 2549, 340, 8486, 365, 6876, 12, 587, 756, 1041, 267, 372, 603, 57, 49, 63, 2566, 63, 40, 3755, 14, 362, 8, 277, 423, 1782, 14, 929, 9, 508, 11377, 63, 26270, 339, 768, 1829, 272, 347, 365, 63, 11707, 8, 277, 304, 267, 408, 1767, 340, 314, 8486, 365, 11261, 503, 440, 1041, 267, 372, 603, 57, 49, 63, 2566, 63, 40, 3755, 14, 362, 8, 277, 423, 1782, 14, 929, 9, 508, 11377, 63, 10353, 12567, 339, 768, 1829, 272, 347, 365, 63, 21849, 8, 277, 304, 267, 408, 1767, 340, 314, 8486, 365, 13618, 503, 440, 1041, 267, 372, 603, 57, 49, 63, 2566, 63, 40, 3755, 14, 362, 8, 277, 423, 1782, 14, 929, 9, 508, 11377, 63, 9935, 1206, 339, 768, 1829, 272, 347, 3748, 63, 3179, 8, 277, 304, 267, 408, 5318, 3748, 4534, 1041, 267, 372, 13756, 63, 9935, 1204, 13756, 63, 18219, 339, 768, 1829, 272, 347, 3747, 63, 344, 8, 277, 304, 267, 408, 1767, 282, 3747, 12, 869, 3755, 13, 17317, 5148, 367, 642, 4642, 1041, 267, 372, 291, 423, 1782, 14, 1782, 63, 344, 339, 5316, 347, 5316, 63, 1600, 63, 5899, 8, 277, 12, 1011, 958, 304, 267, 408, 17106, 4002, 1414, 370, 8486, 1041, 267, 5517, 291, 423, 1782, 14, 1600, 342, 339, 5316, 347, 5316, 63, 1490, 63, 5899, 8, 277, 12, 1011, 958, 304, 267, 408, 17106, 1551, 1414, 370, 8486, 1041, 267, 5517, 291, 423, 1782, 14, 1490, 342, 339, 5316, 347, 5316, 63, 873, 8, 277, 304, 267, 408, 4152, 2004, 402, 8486, 1041, 267, 5517, 291, 423, 1782, 14, 873, 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 ]
[ 199, 11532, 367, 4932, 49, 13, 6589, 598, 285, 474, 4226, 1384, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 5899, 14, 1662, 81, 15, 199, 624, 199, 646, 2050, 199, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 4608, 14, 5899, 492, 334, 272, 21966, 63, 10926, 12, 13756, 63, 18219, 12, 13756, 63, 9935, 12, 1849, 422, 2510, 9, 199, 504, 8846, 14, 1297, 492, 334, 272, 6392, 63, 9032, 12, 6392, 63, 2711, 12, 6392, 63, 11958, 12, 11377, 63, 26270, 12, 11377, 63, 10353, 12567, 12, 272, 11377, 63, 9935, 12, 11377, 63, 9935, 1206, 9, 199, 504, 8846, 14, 7546, 492, 30274, 63, 1258, 12, 1101, 63, 6136, 465, 6277, 199, 199, 29168, 20967, 275, 788, 647, 1662, 81, 389, 17, 14, 17, 14, 16, 418, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 12339, 49, 63, 2566, 63, 40, 3755, 275, 469, 272, 283, 5938, 356, 11377, 63, 26270, 12, 272, 283, 11707, 356, 11377, 63, 10353, 12567, 12, 272, 283, 1490, 356, 11377, 63, 9935, 12, 272, 283, 21849, 356, 11377, 63, 9935, 1206, 199, 93, 199, 199, 17805, 63, 10926, 275, 21966, 63, 10926, 14, 2880, 2561, 272, 5236, 14, 8030, 8, 3103, 63, 2711, 304, 6277, 14, 875, 12, 272, 5236, 14, 8030, 8, 3103, 63, 11958, 304, 6277, 14, 875, 12, 272, 5236, 14, 8030, 8, 3103, 63, 9032, 304, 6277, 14, 875, 199, 1552, 421, 199, 4146, 347, 5316, 63, 2758, 63, 3246, 8, 267, 6298, 12, 1101, 12, 5316, 63, 525, 63, 8327, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 1084, 1536, 314, 4298, 1041, 272, 687, 1134, 1662, 81, 492, 4676, 272, 687, 1134, 1662, 81, 14, 2550, 492, 4932, 49, 547, 12, 19022, 34, 3759, 547, 339, 3330, 1730, 275, 30274, 63, 1258, 14, 4146, 63, 362, 63, 1258, 1730, 8, 5387, 9, 339, 3434, 275, 1101, 59, 3103, 63, 11958, 61, 272, 2505, 275, 1101, 59, 3103, 63, 9032, 61, 272, 32159, 275, 1101, 59, 3103, 63, 2711, 61, 339, 862, 26, 267, 3002, 81, 275, 5517, 4676, 8, 2473, 12, 2505, 12, 32159, 12, 3330, 1730, 9, 272, 871, 19022, 34, 3759, 547, 26, 267, 485, 10186, 14, 705, 360, 12647, 32159, 26, 450, 83, 297, 32159, 9, 267, 372, 272, 871, 4932, 49, 547, 465, 2329, 26, 267, 485, 10186, 14, 705, 360, 10924, 1990, 376, 1125, 1830, 2050, 315, 26, 450, 83, 297, 2329, 9, 267, 372, 339, 7256, 275, 5517, 3002, 81, 14, 362, 63, 6410, 342, 272, 5316, 63, 525, 63, 8327, 779, 5713, 49, 2510, 8, 1782, 9, 367, 2243, 315, 7256, 467, 715, 9, 421, 199, 533, 4932, 49, 2510, 8, 31048, 2510, 304, 272, 408, 20609, 402, 282, 4932, 49, 8486, 1041, 339, 347, 636, 826, 721, 277, 12, 2243, 304, 267, 408, 9345, 543, 3261, 909, 12, 2243, 1305, 1041, 267, 291, 423, 1782, 275, 2243, 339, 768, 1829, 272, 347, 2243, 63, 533, 8, 277, 304, 267, 408, 16213, 642, 8486, 465, 282, 486, 285, 474, 886, 269, 1041, 267, 372, 283, 23909, 474, 7, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 486, 285, 474, 886, 269, 340, 1263, 1041, 267, 372, 291, 423, 1782, 14, 354, 339, 768, 1829, 272, 347, 365, 63, 5938, 8, 277, 304, 267, 408, 1767, 2549, 340, 8486, 365, 6876, 12, 587, 756, 1041, 267, 372, 603, 57, 49, 63, 2566, 63, 40, 3755, 14, 362, 8, 277, 423, 1782, 14, 929, 9, 508, 11377, 63, 26270, 339, 768, 1829, 272, 347, 365, 63, 11707, 8, 277, 304, 267, 408, 1767, 340, 314, 8486, 365, 11261, 503, 440, 1041, 267, 372, 603, 57, 49, 63, 2566, 63, 40, 3755, 14, 362, 8, 277, 423, 1782, 14, 929, 9, 508, 11377, 63, 10353, 12567, 339, 768, 1829, 272, 347, 365, 63, 21849, 8, 277, 304, 267, 408, 1767, 340, 314, 8486, 365, 13618, 503, 440, 1041, 267, 372, 603, 57, 49, 63, 2566, 63, 40, 3755, 14, 362, 8, 277, 423, 1782, 14, 929, 9, 508, 11377, 63, 9935, 1206, 339, 768, 1829, 272, 347, 3748, 63, 3179, 8, 277, 304, 267, 408, 5318, 3748, 4534, 1041, 267, 372, 13756, 63, 9935, 1204, 13756, 63, 18219, 339, 768, 1829, 272, 347, 3747, 63, 344, 8, 277, 304, 267, 408, 1767, 282, 3747, 12, 869, 3755, 13, 17317, 5148, 367, 642, 4642, 1041, 267, 372, 291, 423, 1782, 14, 1782, 63, 344, 339, 5316, 347, 5316, 63, 1600, 63, 5899, 8, 277, 12, 1011, 958, 304, 267, 408, 17106, 4002, 1414, 370, 8486, 1041, 267, 5517, 291, 423, 1782, 14, 1600, 342, 339, 5316, 347, 5316, 63, 1490, 63, 5899, 8, 277, 12, 1011, 958, 304, 267, 408, 17106, 1551, 1414, 370, 8486, 1041, 267, 5517, 291, 423, 1782, 14, 1490, 342, 339, 5316, 347, 5316, 63, 873, 8, 277, 304, 267, 408, 4152, 2004, 402, 8486, 1041, 267, 5517, 291, 423, 1782, 14, 873, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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