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
efajardo/osg-test
osgtest/tests/test_590_gsiopenssh.py
1
2254
import os import pwd import shutil import socket import tempfile from osgtest.library import core from osgtest.library import osgunittest SOURCE_PATH = '/usr/share/osg-test/test_gridftp_data.txt' class TestGSIOpenSSH(osgunittest.OSGTestCase): hostname = socket.getfqdn() temp_dir = None remote_path = None local_path = None port = None def setUp(self): core.skip_ok_unless_installed('gsi-openssh-server', 'gsi-openssh-clients') self.skip_ok_unless(core.state['gsisshd.can-run'], "Couldn't run gsisshd (see above)") self.skip_ok_unless(core.state['proxy.valid'] or core.state['voms.got-proxy'], 'no proxy') self.skip_bad_unless(core.state['gsisshd.started-service'], 'gsisshd service not running') self.port = core.config['gsisshd.port'] def test_00_setup(self): if not TestGSIOpenSSH.temp_dir or not os.path.isdir(TestGSIOpenSSH.temp_dir): TestGSIOpenSSH.temp_dir = tempfile.mkdtemp() uid, gid = pwd.getpwnam(core.options.username)[2:4] os.chown(TestGSIOpenSSH.temp_dir, uid, gid) TestGSIOpenSSH.remote_path = TestGSIOpenSSH.temp_dir + '/gsissh_put_copied_file.txt' TestGSIOpenSSH.local_path = TestGSIOpenSSH.temp_dir + '/gsissh_get_copied_file.txt' def test_01_ssh_to_host(self): command = ['gsissh', '-p', self.port, self.hostname, 'echo', 'SUCCESS'] stdout, _, fail = core.check_system(command, 'SSH to host', user=True, stdin="") self.assert_('SUCCESS' in stdout, fail) def test_02_scp_local_to_remote(self): command = ['gsiscp', '-P', self.port, SOURCE_PATH, self.hostname + ':' + self.remote_path] stdout, _, fail = core.check_system(command, 'SCP to host', user=True, stdin="") self.assert_(os.path.exists(self.remote_path), 'Copied file missing') def test_03_scp_remote_to_local(self): command = ['gsiscp', '-P', self.port, self.hostname + ':' + self.remote_path, self.local_path] stdout, _, fail = core.check_system(command, 'SCP from host', user=True, stdin="") self.assert_(os.path.exists(self.local_path), 'Copied file missing') def test_99_cleanup(self): shutil.rmtree(TestGSIOpenSSH.temp_dir)
apache-2.0
[ 646, 747, 199, 646, 14374, 199, 646, 5145, 199, 646, 2838, 199, 646, 5549, 199, 199, 504, 747, 8385, 14, 4342, 492, 6170, 199, 504, 747, 8385, 14, 4342, 492, 28316, 2796, 421, 199, 10187, 63, 3243, 275, 1994, 2647, 15, 6251, 15, 21593, 13, 396, 15, 396, 63, 7928, 1587, 683, 63, 576, 14, 2424, 7, 421, 199, 533, 1379, 8021, 2090, 897, 13716, 8, 21593, 2796, 14, 3100, 39, 1746, 304, 272, 6246, 275, 2838, 14, 362, 18364, 342, 272, 2388, 63, 694, 275, 488, 272, 3982, 63, 515, 275, 488, 272, 2257, 63, 515, 275, 488, 272, 1844, 275, 488, 339, 347, 3613, 8, 277, 304, 267, 6170, 14, 2759, 63, 745, 63, 18447, 63, 7657, 360, 71, 338, 13, 1490, 5510, 13, 1000, 297, 283, 71, 338, 13, 1490, 5510, 13, 14555, 358, 267, 291, 14, 2759, 63, 745, 63, 18447, 8, 1018, 14, 929, 459, 71, 338, 5510, 68, 14, 2425, 13, 1065, 995, 298, 20485, 1133, 1255, 486, 338, 5510, 68, 334, 3239, 3432, 6320, 267, 291, 14, 2759, 63, 745, 63, 18447, 8, 1018, 14, 929, 459, 3280, 14, 1078, 418, 503, 6170, 14, 929, 459, 86, 22491, 14, 7808, 13, 3280, 995, 283, 889, 4566, 358, 267, 291, 14, 2759, 63, 4087, 63, 18447, 8, 1018, 14, 929, 459, 71, 338, 5510, 68, 14, 8924, 13, 1364, 995, 283, 71, 338, 5510, 68, 2435, 440, 3879, 358, 267, 291, 14, 719, 275, 6170, 14, 888, 459, 71, 338, 5510, 68, 14, 719, 418, 339, 347, 511, 63, 383, 63, 2758, 8, 277, 304, 267, 340, 440, 1379, 8021, 2090, 897, 13716, 14, 808, 63, 694, 503, 440, 747, 14, 515, 14, 6027, 8, 774, 8021, 2090, 897, 13716, 14, 808, 63, 694, 304, 288, 1379, 8021, 2090, 897, 13716, 14, 808, 63, 694, 275, 5549, 14, 11983, 342, 288, 1747, 12, 15122, 275, 14374, 14, 362, 80, 3501, 455, 8, 1018, 14, 1419, 14, 2473, 2788, 18, 26, 20, 61, 288, 747, 14, 20933, 8, 774, 8021, 2090, 897, 13716, 14, 808, 63, 694, 12, 1747, 12, 15122, 9, 288, 1379, 8021, 2090, 897, 13716, 14, 3846, 63, 515, 275, 1379, 8021, 2090, 897, 13716, 14, 808, 63, 694, 435, 1994, 71, 338, 5510, 63, 524, 63, 23581, 63, 493, 14, 2424, 7, 288, 1379, 8021, 2090, 897, 13716, 14, 1832, 63, 515, 275, 1379, 8021, 2090, 897, 13716, 14, 808, 63, 694, 435, 1994, 71, 338, 5510, 63, 362, 63, 23581, 63, 493, 14, 2424, 7, 339, 347, 511, 63, 614, 63, 5510, 63, 475, 63, 1102, 8, 277, 304, 267, 1414, 275, 788, 71, 338, 5510, 297, 2475, 80, 297, 291, 14, 719, 12, 291, 14, 4269, 12, 283, 7878, 297, 283, 12779, 418, 267, 3839, 12, 5501, 2449, 275, 6170, 14, 1074, 63, 2253, 8, 1531, 12, 283, 13716, 370, 1591, 297, 922, 29, 549, 12, 9009, 18413, 398, 291, 14, 479, 11252, 12779, 7, 315, 3839, 12, 2449, 9, 339, 347, 511, 63, 996, 63, 17124, 63, 1832, 63, 475, 63, 3846, 8, 277, 304, 267, 1414, 275, 788, 71, 338, 17124, 297, 2475, 48, 297, 291, 14, 719, 12, 25470, 63, 3243, 12, 291, 14, 4269, 435, 10871, 435, 291, 14, 3846, 63, 515, 61, 267, 3839, 12, 5501, 2449, 275, 6170, 14, 1074, 63, 2253, 8, 1531, 12, 283, 51, 2890, 370, 1591, 297, 922, 29, 549, 12, 9009, 18413, 398, 291, 14, 479, 2531, 736, 14, 515, 14, 2444, 8, 277, 14, 3846, 63, 515, 395, 283, 18268, 5299, 570, 4124, 358, 339, 347, 511, 63, 1644, 63, 17124, 63, 3846, 63, 475, 63, 1832, 8, 277, 304, 267, 1414, 275, 788, 71, 338, 17124, 297, 2475, 48, 297, 291, 14, 719, 12, 291, 14, 4269, 435, 10871, 435, 291, 14, 3846, 63, 515, 12, 291, 14, 1832, 63, 515, 61, 267, 3839, 12, 5501, 2449, 275, 6170, 14, 1074, 63, 2253, 8, 1531, 12, 283, 51, 2890, 687, 1591, 297, 922, 29, 549, 12, 9009, 18413, 398, 291, 14, 479, 2531, 736, 14, 515, 14, 2444, 8, 277, 14, 1832, 63, 515, 395, 283, 18268, 5299, 570, 4124, 358, 339, 347, 511, 63, 1020, 63, 7661, 8, 277, 304, 267, 5145, 14, 9242, 8, 774, 8021, 2090, 897, 13716, 14, 808, 63, 694, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 747, 199, 646, 14374, 199, 646, 5145, 199, 646, 2838, 199, 646, 5549, 199, 199, 504, 747, 8385, 14, 4342, 492, 6170, 199, 504, 747, 8385, 14, 4342, 492, 28316, 2796, 421, 199, 10187, 63, 3243, 275, 1994, 2647, 15, 6251, 15, 21593, 13, 396, 15, 396, 63, 7928, 1587, 683, 63, 576, 14, 2424, 7, 421, 199, 533, 1379, 8021, 2090, 897, 13716, 8, 21593, 2796, 14, 3100, 39, 1746, 304, 272, 6246, 275, 2838, 14, 362, 18364, 342, 272, 2388, 63, 694, 275, 488, 272, 3982, 63, 515, 275, 488, 272, 2257, 63, 515, 275, 488, 272, 1844, 275, 488, 339, 347, 3613, 8, 277, 304, 267, 6170, 14, 2759, 63, 745, 63, 18447, 63, 7657, 360, 71, 338, 13, 1490, 5510, 13, 1000, 297, 283, 71, 338, 13, 1490, 5510, 13, 14555, 358, 267, 291, 14, 2759, 63, 745, 63, 18447, 8, 1018, 14, 929, 459, 71, 338, 5510, 68, 14, 2425, 13, 1065, 995, 298, 20485, 1133, 1255, 486, 338, 5510, 68, 334, 3239, 3432, 6320, 267, 291, 14, 2759, 63, 745, 63, 18447, 8, 1018, 14, 929, 459, 3280, 14, 1078, 418, 503, 6170, 14, 929, 459, 86, 22491, 14, 7808, 13, 3280, 995, 283, 889, 4566, 358, 267, 291, 14, 2759, 63, 4087, 63, 18447, 8, 1018, 14, 929, 459, 71, 338, 5510, 68, 14, 8924, 13, 1364, 995, 283, 71, 338, 5510, 68, 2435, 440, 3879, 358, 267, 291, 14, 719, 275, 6170, 14, 888, 459, 71, 338, 5510, 68, 14, 719, 418, 339, 347, 511, 63, 383, 63, 2758, 8, 277, 304, 267, 340, 440, 1379, 8021, 2090, 897, 13716, 14, 808, 63, 694, 503, 440, 747, 14, 515, 14, 6027, 8, 774, 8021, 2090, 897, 13716, 14, 808, 63, 694, 304, 288, 1379, 8021, 2090, 897, 13716, 14, 808, 63, 694, 275, 5549, 14, 11983, 342, 288, 1747, 12, 15122, 275, 14374, 14, 362, 80, 3501, 455, 8, 1018, 14, 1419, 14, 2473, 2788, 18, 26, 20, 61, 288, 747, 14, 20933, 8, 774, 8021, 2090, 897, 13716, 14, 808, 63, 694, 12, 1747, 12, 15122, 9, 288, 1379, 8021, 2090, 897, 13716, 14, 3846, 63, 515, 275, 1379, 8021, 2090, 897, 13716, 14, 808, 63, 694, 435, 1994, 71, 338, 5510, 63, 524, 63, 23581, 63, 493, 14, 2424, 7, 288, 1379, 8021, 2090, 897, 13716, 14, 1832, 63, 515, 275, 1379, 8021, 2090, 897, 13716, 14, 808, 63, 694, 435, 1994, 71, 338, 5510, 63, 362, 63, 23581, 63, 493, 14, 2424, 7, 339, 347, 511, 63, 614, 63, 5510, 63, 475, 63, 1102, 8, 277, 304, 267, 1414, 275, 788, 71, 338, 5510, 297, 2475, 80, 297, 291, 14, 719, 12, 291, 14, 4269, 12, 283, 7878, 297, 283, 12779, 418, 267, 3839, 12, 5501, 2449, 275, 6170, 14, 1074, 63, 2253, 8, 1531, 12, 283, 13716, 370, 1591, 297, 922, 29, 549, 12, 9009, 18413, 398, 291, 14, 479, 11252, 12779, 7, 315, 3839, 12, 2449, 9, 339, 347, 511, 63, 996, 63, 17124, 63, 1832, 63, 475, 63, 3846, 8, 277, 304, 267, 1414, 275, 788, 71, 338, 17124, 297, 2475, 48, 297, 291, 14, 719, 12, 25470, 63, 3243, 12, 291, 14, 4269, 435, 10871, 435, 291, 14, 3846, 63, 515, 61, 267, 3839, 12, 5501, 2449, 275, 6170, 14, 1074, 63, 2253, 8, 1531, 12, 283, 51, 2890, 370, 1591, 297, 922, 29, 549, 12, 9009, 18413, 398, 291, 14, 479, 2531, 736, 14, 515, 14, 2444, 8, 277, 14, 3846, 63, 515, 395, 283, 18268, 5299, 570, 4124, 358, 339, 347, 511, 63, 1644, 63, 17124, 63, 3846, 63, 475, 63, 1832, 8, 277, 304, 267, 1414, 275, 788, 71, 338, 17124, 297, 2475, 48, 297, 291, 14, 719, 12, 291, 14, 4269, 435, 10871, 435, 291, 14, 3846, 63, 515, 12, 291, 14, 1832, 63, 515, 61, 267, 3839, 12, 5501, 2449, 275, 6170, 14, 1074, 63, 2253, 8, 1531, 12, 283, 51, 2890, 687, 1591, 297, 922, 29, 549, 12, 9009, 18413, 398, 291, 14, 479, 2531, 736, 14, 515, 14, 2444, 8, 277, 14, 1832, 63, 515, 395, 283, 18268, 5299, 570, 4124, 358, 339, 347, 511, 63, 1020, 63, 7661, 8, 277, 304, 267, 5145, 14, 9242, 8, 774, 8021, 2090, 897, 13716, 14, 808, 63, 694, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
opencord/cord
scripts/imagebuilder.py
1
50939
#!/usr/bin/env python # Copyright 2017-present Open Networking 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. # imagebuilder.py # rebuilds/fetches docker container images per their git status in repo # in addition to docker, needs `sudo apt-get install python-git` import argparse import datetime import git import json import logging import os import re import string import sys import tarfile import tempfile import time import xml.etree.ElementTree as ET import yaml global args global conf global build_tag global buildable_images global pull_only_images DOCKER_PY_VERSION = 0 def setup_logging(name=None, logfile=False): global args if name: log = logging.getLogger("-".join([__name__, name])) else: log = logging.getLogger(__name__) slh = logging.StreamHandler(sys.stdout) slh.setFormatter(logging.Formatter(logging.BASIC_FORMAT)) slh.setLevel(logging.DEBUG) log.addHandler(slh) # secondary logging to a file, always DEBUG level if logfile: fn = os.path.join(conf.logdir, "%s.log" % name) flh = logging.FileHandler(fn) flh.setFormatter(logging.Formatter(logging.BASIC_FORMAT)) flh.setLevel(logging.DEBUG) log.addHandler(flh) return log LOG = setup_logging() def parse_args(): global args parser = argparse.ArgumentParser() parser.add_argument('-c', '--container_list', default='docker_images.yml', type=argparse.FileType('r'), help="YAML Config and master container list") # -f is optional, so using type=argparse.FileType is problematic parser.add_argument('-f', '--filter_images', default=None, action='store', help="YAML file restricting images to build/fetch") parser.add_argument('-a', '--actions_taken', default=None, help="Save a YAML file with actions taken during run") group = parser.add_mutually_exclusive_group() group.add_argument('-b', '--build', action="store_true", default=False, help="Build (don't fetch) all internal images, nocache") group.add_argument('-p', '--pull', action="store_true", default=False, help="Only pull containers, fail if build required") parser.add_argument('-d', '--dry_run', action="store_true", help="Don't build/fetch anything") parser.add_argument('-g', '--graph', default=None, help="Filename for DOT graph file of image dependency") parser.add_argument('-l', '--build_log_dir', action="store", help="Log build output to this dir if set") parser.add_argument('-r', '--repo_root', default="..", action="store", help="Repo root directory") parser.add_argument('-t', '--build_tag', default=None, action="store", help="tag all images built/pulled using this tag") parser.add_argument('-v', '--verbosity', action='count', default=1, help="Repeat to increase log level") parser.add_argument('-x', '--force', action="store_true", help="Force removal of tags (may delete images)") args = parser.parse_args() if args.verbosity > 1: LOG.setLevel(logging.DEBUG) else: LOG.setLevel(logging.INFO) def load_config(): global args global conf global buildable_images global pull_only_images global build_tag try: cl_abs = os.path.abspath(args.container_list.name) LOG.info("Master container list file: %s" % cl_abs) conf = yaml.safe_load(args.container_list) except yaml.YAMLError: LOG.exception("Problem loading container list file") sys.exit(1) if args.build_tag: build_tag = args.build_tag else: build_tag = conf['docker_build_tag'] if args.filter_images is None: buildable_images = conf['buildable_images'] pull_only_images = conf['pull_only_images'] else: fi_abs = os.path.abspath(args.filter_images) LOG.info("Filtering image list per 'docker_image_whitelist' in: %s" % fi_abs) try: fi_fh = open(fi_abs, 'r') filter_list = yaml.safe_load(fi_fh) fi_fh.close() if 'docker_image_whitelist' not in filter_list: LOG.error("No 'docker_image_whitelist' defined in: %s" % fi_abs) sys.exit(1) # fail if pull_only_images in docker_images.yml doesn't have tags for i in conf['pull_only_images']: (name, tag) = split_name(i) if not tag: LOG.error("Images in docker_images.yml must be tagged") sys.exit(1) buildable_images = [img for img in conf['buildable_images'] if split_name(img['name'])[0] in filter_list['docker_image_whitelist']] pull_only_images = [img for img in conf['pull_only_images'] if split_name(img)[0] in map(lambda x: split_name(x)[0], filter_list['docker_image_whitelist'])] pull_only_images = map(override_tags( filter_list['docker_image_whitelist']), pull_only_images) except KeyError: LOG.exception("Problem with filter list file") sys.exit(1) def override_tags(image_list_with_tags): untagged_whitelist = map(lambda x: split_name(x)[0], image_list_with_tags) def inner(i): img_name = split_name(i)[0] tag_override = split_name(image_list_with_tags[ untagged_whitelist.index(img_name)])[1] if tag_override: return "%s:%s" % (img_name, tag_override) return i return inner def split_name(input_name): """ split a docker image name in the 'name:tag' format into components """ name = input_name tag = None # split name:tag if given in combined format name_tag_split = string.split(input_name, ":") if len(name_tag_split) > 1: # has tag, return separated version name = name_tag_split[0] tag = name_tag_split[1] return (name, tag) class RepoRepo(): """ git repo managed by repo tool""" def __init__(self, name, path, remote_url, remote_branch, short_branch): self.name = name self.path = path self.git_url = "%s%s" % (remote_url, name) self.remote_branch = remote_branch self.short_branch = short_branch self.git_tags = [] try: self.git_repo_o = git.Repo(self.abspath()) LOG.debug("Repo - %s, path: %s" % (name, path)) self.head_commit = self.git_repo_o.head.commit.hexsha LOG.debug(" head commit: %s" % self.head_commit) commit_t = time.gmtime(self.git_repo_o.head.commit.committed_date) self.head_commit_t = time.strftime("%Y-%m-%dT%H:%M:%SZ", commit_t) LOG.debug(" commit date: %s" % self.head_commit_t) for tag in self.git_repo_o.tags: if tag.commit == self.git_repo_o.head.commit: self.git_tags.append(str(tag)) if self.git_tags: LOG.debug(" tags referring to this commit: %s" % ", ".join(self.git_tags)) else: LOG.debug(" No git tags refer to this commit") self.clean = not self.git_repo_o.is_dirty(untracked_files=True) LOG.debug(" clean: %s" % self.clean) # list of untracked files (expensive operation) self.untracked_files = self.git_repo_o.untracked_files for u_file in self.untracked_files: LOG.debug(" Untracked: %s" % u_file) except Exception: LOG.exception("Error with git repo: %s" % name) sys.exit(1) def abspath(self): global args return os.path.abspath(os.path.join(args.repo_root, self.path)) def path_clean(self, test_path, branch=""): """ Is working tree on branch and no untracked files in path? """ global conf if not branch: branch = self.remote_branch LOG.debug(" Looking for changes in path: %s" % test_path) p_clean = True # diff between branch head and working tree (None) branch_head = self.git_repo_o.commit(branch) diff = branch_head.diff(None, paths=test_path) if diff: p_clean = False for diff_obj in diff: LOG.debug(" file not on branch: %s" % diff_obj) # remove . to compare paths using .startswith() if test_path == ".": test_path = "" for u_file in self.untracked_files: if u_file.startswith(test_path): LOG.debug(" untracked file in path: %s" % u_file) p_clean = False return p_clean class RepoManifest(): """ parses manifest XML file used by repo tool""" def __init__(self): global args global conf self.manifest_xml = {} self.repos = {} self.branch = "" self.manifest_file = os.path.abspath( os.path.join(args.repo_root, ".repo/manifest.xml")) LOG.info("Loading manifest file: %s" % self.manifest_file) try: tree = ET.parse(self.manifest_file) self.manifest_xml = tree.getroot() except Exception: LOG.exception("Error loading repo manifest") sys.exit(1) # Find the branch names default = self.manifest_xml.find('default') self.short_branch = default.attrib['revision'] self.remote_branch = "%s/%s" % (default.attrib['remote'], default.attrib['revision']) # Find the remote URL for these repos remote = self.manifest_xml.find('remote') self.remote_url = remote.attrib['review'] LOG.info("Manifest is on remote branch '%s' with remote url '%s'" % (self.remote_branch, self.remote_url)) project_repos = {} for project in self.manifest_xml.iter('project'): repo_name = project.attrib['name'] rel_path = project.attrib['path'] abs_path = os.path.abspath(os.path.join(args.repo_root, project.attrib['path'])) if os.path.isdir(abs_path): project_repos[repo_name] = rel_path else: LOG.debug("Repo in manifest but not checked out: %s" % repo_name) for repo_name, repo_path in project_repos.iteritems(): self.repos[repo_name] = RepoRepo(repo_name, repo_path, self.remote_url, self.remote_branch, self.short_branch) def get_repo(self, repo_name): return self.repos[repo_name] # DockerImage Status Constants DI_UNKNOWN = 'unknown' # unknown status DI_EXISTS = 'exists' # already exists in docker, has an image_id DI_BUILD = 'build' # needs to be built DI_FETCH = 'fetch' # needs to be fetched (pulled) DI_ERROR = 'error' # build or other fatal failure class DockerImage(): def __init__(self, name, repo_name=None, repo_d=None, path=".", context=".", dockerfile='Dockerfile', labels=None, tags=None, image_id=None, components=None, status=DI_UNKNOWN): LOG.debug("New DockerImage object from name: %s" % name) # name to pull as, usually what is provided on creation. # May be changed by create_tags self.raw_name = name # Python's mutable defaults is a landmine if labels is None: self.labels = {} else: self.labels = labels self.repo_name = repo_name self.repo_d = repo_d self.path = path self.context = context self.dockerfile = dockerfile self.tags = [] # tags are added to this later in __init__ self.image_id = image_id self.components = components self.status = status self.parent_names = [] # names of parents from _find_parent_names() self.parents = [] # list of parent DockerImage object self.children = [] # list of child DockerImage objects # split name:tag if given in combined format (image_name, image_tag) = split_name(name) if image_tag: # has tag self.name = image_name self.tags.append(image_tag) else: # no tag self.name = image_name # Add the build tag if exists if build_tag not in self.tags: self.tags.append(build_tag) # split names from tag list if tags is not None: for tag in tags: thistag = "" (tag_name, tag_tag) = split_name(tag) if tag_tag: # has name also, use just tag thistag = tag_tag else: # just a bare tag thistag = tag_name if thistag not in self.tags: # don't duplicate tags self.tags.append(thistag) # self.clean only applies to this container self.clean = self._context_clean() self._find_parent_names() def __str__(self): return self.name def buildable(self): """ Can this image be built from a Dockerfile? """ if self.repo_name: # has a git repo to be built from return True return False def _context_clean(self): """ Determine if this is repo and context is clean """ if self.buildable(): # check if on master branch repo_clean = self.repo_d.clean # only check the Docker context for cleanliness context_path = os.path.normpath( os.path.join(self.path, self.context)) context_clean = self.repo_d.path_clean(context_path) # check of subcomponents are clean components_clean = self.components_clean() LOG.debug(" Build Context Cleanliness - " "repo: %s, context: %s, components: %s" % (repo_clean, context_clean, components_clean)) if context_clean and repo_clean and components_clean: return True else: return False return True # unbuildable images are clean def parents_clean(self): """ Returns true if self and all parents are clean """ if self.buildable(): if not self.clean: return False else: for parent in self.parents: if not parent.parents_clean(): return False else: return True return True # unbuildable images are clean def compare_labels(self, other_labels): """ Returns True if image label-schema.org labels match dict """ comparable_labels_re = [ r".*name$", r".*vcs-url$", r".*vcs-ref$", r".*version$", ] for clr in comparable_labels_re: # loop on all comparable labels for label in self.labels: # loop on all labels if re.match(clr, label) is not None: # if label matches re # and label exists in other, and values are same if label in other_labels and \ self.labels[label] == other_labels[label]: pass # continue through loop else: LOG.info("Non-matching label: %s" % label) return False # False when first difference found LOG.debug(" All labels matched") return True # only when every label matches def same_name(self, other_name): """ compare image name (possibly with tag) against image name/tag """ (o_name, o_tag) = split_name(other_name) if o_tag is None and self.name == o_name: return True elif self.name == o_name and o_tag in self.tags: return True return False def components_clean(self): if self.buildable() and self.components is not None: for component in self.components: if not component['repo_d'].clean or \ not component['repo_d'].path_clean(component['path']): return False return True def component_labels(self): """ returns a dict of labels for subcomponents """ if self.buildable() and self.components is not None: comp_l = {} for component in self.components: LOG.debug(" component %s generating child labels" % component['repo_name']) prefix = "org.opencord.component.%s." % component['repo_name'] comp_l[prefix + "vcs-url"] = component['repo_d'].git_url if component['repo_d'].clean and \ component['repo_d'].path_clean(component['path']): clean = True else: clean = False if clean: comp_l[prefix + "version"] = "%s-%s" % \ (self.repo_d.short_branch, self.repo_d.head_commit) comp_l[prefix + "vcs-ref"] = \ component['repo_d'].head_commit else: comp_l[prefix + "version"] = "dirty" comp_l[prefix + "vcs-ref"] = "" return comp_l return None def child_labels(self, repo_list=None): """ return a dict of labels to apply to child images """ LOG.debug(" Generating child labels from parent: %s" % self.name) # only create labels when they haven't already been created if repo_list is None: repo_list = [] LOG.debug(" Already labeled with: %s" % ", ".join(repo_list)) cl = {} if self.buildable() and self.repo_name not in repo_list: LOG.debug(" Adding parent labels from repo: %s" % self.repo_name) prefix = "org.opencord.component.%s." % self.repo_name cl[prefix + "vcs-url"] = self.repo_d.git_url if self.clean: cl[prefix + "version"] = "%s-%s" % (self.repo_d.short_branch, self.repo_d.head_commit) cl[prefix + "vcs-ref"] = self.repo_d.head_commit else: cl[prefix + "version"] = "dirty" cl[prefix + "vcs-ref"] = "" repo_list.append(self.repo_name) # include component labels if present if self.components is not None: cl.update(self.component_labels()) # recursively find labels up the parent chain if self.parents is not None: for parent in self.parents: cl.update(parent.child_labels(repo_list)) return cl def create_labels(self): """ Create label-schema.org labels for image """ if self.buildable(): LOG.debug("Creating labels for: %s" % self.name) self.labels['org.label-schema.name'] = self.name self.labels['org.label-schema.schema-version'] = "1.0" # org.label-schema.build-date time_now = datetime.datetime.utcnow() build_date = time_now.strftime("%Y-%m-%dT%H:%M:%SZ") self.labels['org.label-schema.build-date'] = build_date # git version related labels self.labels['org.label-schema.vcs-url'] = self.repo_d.git_url if self.clean: self.labels['org.label-schema.version'] = \ "%s-%s" % (self.repo_d.short_branch, self.repo_d.head_commit) self.labels['org.label-schema.vcs-ref'] = \ self.repo_d.head_commit self.labels['org.opencord.vcs-commit-date'] = \ self.repo_d.head_commit_t else: self.labels['org.label-schema.version'] = "dirty" self.labels['org.label-schema.vcs-ref'] = "" # include component labels if present if self.components is not None: self.labels.update(self.component_labels()) def create_tags(self): """ Create docker tags as needed """ if self.buildable(): LOG.debug("Creating tags for image: %s" % self.name) # if clean and parents clean, add tags for branch/commit if self.parents_clean(): # add build tag if build_tag not in self.tags: self.tags.append(build_tag) # add branch tag branch_tag = self.repo_d.short_branch if branch_tag not in self.tags: self.tags.append(branch_tag) # Add <branch>-<commit> tag, which is used to pull commit_tag = "%s-%s" % (self.repo_d.short_branch, self.repo_d.head_commit) if commit_tag not in self.tags: self.tags.append(commit_tag) # this is most specific tag, so pull using it self.raw_name = "%s:%s" % (self.name, commit_tag) # add all tags in git that point at the commit for gt in self.repo_d.git_tags: if gt not in self.tags: self.tags.append(gt) LOG.debug("All tags: %s" % ", ".join(self.tags)) def _find_parent_names(self): """ set self.parent_names using Dockerfile FROM lines """ if self.buildable(): # read contents of Dockerfile into df with open(self.dockerfile_abspath()) as dfh: dfl = dfh.readlines() parent_names = [] frompatt = re.compile(r'^FROM\s+([\w/_:.-]+)', re.MULTILINE) for line in dfl: fromline = re.search(frompatt, line) if fromline: parent_names.append(fromline.group(1)) self.parent_names = parent_names # may have tag LOG.debug(" Parents: %s" % ", ".join(self.parent_names)) def dockerfile_abspath(self): """ returns absolute path to Dockerfile for this image """ if self.buildable(): return os.path.join(self.repo_d.abspath(), self.path, self.dockerfile) else: return None def dockerfile_rel_path(self): """ returns the path relative to the context of the Dockerfile """ if self.buildable(): if self.context is ".": return self.dockerfile else: return os.path.normpath(os.path.join(self.path, self.dockerfile)) else: return None def context_tarball(self): """ returns a filehandle to a tarball (tempfile) for the image """ if self.buildable(): context_path = os.path.normpath( os.path.join(self.repo_d.abspath(), self.path, self.context)) LOG.info("Creating context tarball of path: %s" % context_path) t_fh = tempfile.NamedTemporaryFile() t = tarfile.open(mode='w', fileobj=t_fh, dereference=True) # exclude git directories anywhere in the context exclusion_list = ['**/.git'] docker_ignore = os.path.join(context_path, '.dockerignore') if os.path.exists(docker_ignore): for line in open(docker_ignore).readlines(): # slightly out of spec, we allow whitespace before comments # https://docs.docker.com/engine/reference/builder/#dockerignore-file if line.strip()[0] is not '#': exclusion_list.append(line.strip().rstrip('\/')) LOG.debug("Exclusion list: %s" % exclusion_list) # see docker-py source for context for path in sorted( DockerUtils.exclude_paths(context_path, exclusion_list)): t.add(os.path.join(context_path, path), arcname=path, recursive=False) # add sub-components to tarball if required if self.components is not None: for component in self.components: c_ctx_p = os.path.normpath( os.path.join(component['repo_d'].abspath(), component['path'])) LOG.info("Adding component %s at context %s" % (component['repo_name'], c_ctx_p)) # walk component source path for path in sorted( DockerUtils.exclude_paths(c_ctx_p, exclusion_list)): # path to where to put files in the archive cf_dest = os.path.normpath( os.path.join(component['dest'], path)) t.add(os.path.join(c_ctx_p, path), arcname=cf_dest, recursive=False) # t.list() # prints all files in tarball t.close() t_fh.seek(0) return t_fh else: return None def buildargs(self): """ returns array of labels in docker buildargs compliant format """ ba_a = {} for label_k in self.labels: ba_re = re.compile(r'\W') # non alpha/num/_ chars ba_label = ba_re.sub('_', label_k) ba_a[ba_label] = self.labels[label_k] return ba_a class DockerBuilder(): def __init__(self, repo_manifest): global buildable_images global pull_only_images self.rm = repo_manifest self.dc = None # Docker Client object self.images = [] # arrays of images, used for write_actions self.preexisting = [] self.obsolete = [] self.pulled = [] self.failed_pull = [] self.obsolete_pull = [] self.built = [] self.failed_build = [] # create dict of images, setting defaults for image in buildable_images: repo_d = self.rm.get_repo(image['repo']) if "components" in image: components = [] for component in image['components']: comp = {} comp['repo_name'] = component['repo'] comp['repo_d'] = self.rm.get_repo(component['repo']) comp['dest'] = component['dest'] comp['path'] = component.get('path', '.') components.append(comp) else: components = None # set the full name in case this is pulled full_name = "%s:%s" % (image['name'], build_tag) img_o = DockerImage(full_name, image['repo'], repo_d, image.get('path', '.'), image.get('context', '.'), image.get('dockerfile', 'Dockerfile'), components=components) self.images.append(img_o) # add misc images for misc_image in pull_only_images: img_o = DockerImage(misc_image) self.images.append(img_o) if not args.dry_run: self._docker_connect() self.create_dependency() if not args.build: # if forcing build, don't use preexisting self.find_preexisting() if args.graph is not None: self.dependency_graph(args.graph) self.process_images() if args.actions_taken is not None: self.write_actions_file(args.actions_taken) def _docker_connect(self): """ Connect to docker daemon """ try: # get a "high level" Docker object with conf from the environment hl_dc = docker.from_env() # use the low level APIClient (same as the 1.x API) self.dc = hl_dc.api except requests.ConnectionError: LOG.debug("Docker connection not available") sys.exit(1) if self.dc.ping(): LOG.debug("Docker server is responding") else: LOG.error("Unable to ping docker server") sys.exit(1) def find_preexisting(self): """ find images that already exist in Docker and mark """ if self.dc: LOG.debug("Evaluating already built/fetched Docker images") # get list of images from docker pe_images = self.dc.images() for pe_image in pe_images: raw_tags = pe_image['RepoTags'] if raw_tags: LOG.info("Preexisting Image - ID: %s, tags: %s" % (pe_image['Id'], ",".join(raw_tags))) has_build_tag = False for tag in raw_tags: if build_tag in tag: LOG.debug(" image has build_tag: %s" % build_tag) has_build_tag = True base_name = raw_tags[0].split(":")[0] image = self.find_image(base_name) # only evaluate images in the list of desired images if image is not None: good_labels = image.compare_labels(pe_image['Labels']) if good_labels: if has_build_tag: LOG.info(" Image %s has up-to-date labels and" " build_tag" % pe_image['Id']) else: LOG.info(" Image %s has up-to-date labels but" " missing build_tag. Tagging image" " with build_tag: %s" % (pe_image['Id'], build_tag)) self.dc.tag(pe_image['Id'], image.name, tag=build_tag) self.preexisting.append({ 'id': pe_image['Id'], 'tags': raw_tags, 'base': image.name.split(":")[0], }) image.image_id = pe_image['Id'] image.status = DI_EXISTS else: # doesn't have good labels # if it has a build_tag, and a good image hasn't # already been tagged if has_build_tag and (image.status != DI_EXISTS): LOG.info(" Image %s has obsolete labels and" " build_tag, remove" % pe_image['Id']) # remove build_tag from image name_bt = "%s:%s" % (base_name, build_tag) self.dc.remove_image(name_bt, args.force, True) else: LOG.info(" Image %s has obsolete labels, lacks" " build_tag, ignore" % pe_image['Id']) self.obsolete.append({ 'id': pe_image['Id'], 'tags': raw_tags, }) def find_image(self, image_name): """ return image object matching name """ LOG.debug(" attempting to find image for: %s" % image_name) for image in self.images: if image.same_name(image_name): LOG.debug(" found a match: %s" % image.raw_name) return image return None def create_dependency(self): """ set parent/child links for images """ # List of lists of parents images. Done in two steps for clarity lol_of_parents = [img.parent_names for img in self.images if img.parent_names is not []] # flat list of all parent image names, with dupes parents_with_dupes = [parent for parent_sublist in lol_of_parents for parent in parent_sublist] # remove duplicates parents = list(set(parents_with_dupes)) LOG.info("All parent images: %s" % ", ".join(parents)) # list of "external parents", ones not built internally external_parents = [] for parent_name in parents: LOG.debug("Evaluating parent image: %s" % parent_name) internal_parent = False # match on p_name, without tag (p_name, p_tag) = split_name(parent_name) for image in self.images: if image.same_name(p_name): # internal image is a parent internal_parent = True LOG.debug(" Internal parent: %s" % image.name) break if not internal_parent: # parent is external LOG.debug(" External parent: %s" % parent_name) external_parents.append(parent_name) # add unique external parents to image list for e_p_name in set(external_parents): LOG.debug(" Creating external parent image object: %s" % e_p_name) img_o = DockerImage(e_p_name) self.images.append(img_o) # now that all images (including parents) are in list, associate them for image in filter(lambda img: img.parent_names is not [], self.images): LOG.debug("Associating image: %s" % image.name) for parent_name in image.parent_names: parent = self.find_image(parent_name) image.parents.append(parent) if parent is not None: LOG.debug(" internal image '%s' is parent of '%s'" % (parent.name, image.name)) parent.children.append(image) else: LOG.debug(" external image '%s' is parent of '%s'" % (image.parent_name, image.name)) # loop again now that parents are linked to create labels for image in self.images: image.create_labels() image.create_tags() # if image has parent, get labels from parent(s) if image.parents is not None: for parent in image.parents: LOG.debug("Adding parent labels from %s to child %s" % (parent.name, image.name)) # don't create component labels for same repo as image repo_list = [image.repo_name] image.labels.update(parent.child_labels(repo_list)) def dependency_graph(self, graph_fn): """ save a DOT dependency graph to a file """ graph_fn_abs = os.path.abspath(graph_fn) LOG.info("Saving DOT dependency graph to: %s" % graph_fn_abs) try: import graphviz except ImportError: LOG.error('graphviz pip module not found') raise dg = graphviz.Digraph(comment='Image Dependency Graph', graph_attr={'rankdir': 'LR'}) component_nodes = [] # Use raw names, so they match with what's in Dockerfiles # delete colons as python graphviz module breaks with them for image in self.images: name_g = image.raw_name.replace(':', '\n') dg.node(name_g) if image.parents is not None: for parent in image.parents: name_p = parent.raw_name.replace(':', '\n') dg.edge(name_p, name_g) if image.components is not None: for component in image.components: name_c = "component - %s" % component['repo_name'] if name_c not in component_nodes: dg.node(name_c) component_nodes.append(name_c) dg.edge(name_c, name_g, "", {'style': 'dashed'}) with open(graph_fn_abs, 'w') as g_fh: g_fh.write(dg.source) def write_actions_file(self, actions_fn): actions_fn_abs = os.path.abspath(actions_fn) LOG.info("Saving actions as YAML to: %s" % actions_fn_abs) actions = { "ib_pulled": self.pulled, "ib_built": self.built, "ib_preexisting_images": self.preexisting, "ib_obsolete_images": self.obsolete, "ib_failed_pull": self.failed_pull, "ib_obsolete_pull": self.obsolete_pull, "ib_failed_build": self.failed_build, } with open(actions_fn_abs, 'w') as a_fh: yaml.safe_dump(actions, a_fh) LOG.debug(yaml.safe_dump(actions)) def process_images(self): """ determine whether to build/fetch images """ # upstream images (have no parents), must be fetched must_fetch_a = filter(lambda img: not img.parents, self.images) for image in must_fetch_a: if image.status is not DI_EXISTS: image.status = DI_FETCH # images that can be built or fetched (have parents) b_or_f_a = filter(lambda img: img.parents, self.images) for image in b_or_f_a: if not image.parents_clean() or args.build: # must be built if not clean image.status = DI_BUILD elif image.status is not DI_EXISTS: # try to fetch if clean and doesn't exist image.status = DI_FETCH # otherwise, image is clean and exists (image.status == DI_EXISTS) c_and_e_a = filter(lambda img: img.status is DI_EXISTS, self.images) LOG.info("Preexisting and clean images: %s" % ", ".join(c.name for c in c_and_e_a)) upstream_a = filter(lambda img: (img.status is DI_FETCH and not img.parents), self.images) LOG.info("Upstream images that must be fetched: %s" % ", ".join(u.raw_name for u in upstream_a)) fetch_a = filter(lambda img: (img.status is DI_FETCH and img.parents), self.images) LOG.info("Clean, buildable images to attempt to fetch: %s" % ", ".join(f.raw_name for f in fetch_a)) build_a = filter(lambda img: img.status is DI_BUILD, self.images) LOG.info("Buildable images, due to unclean context or parents: %s" % ", ".join(b.raw_name for b in build_a)) # OK to fetch upstream in any case as they should reduce number of # layers pulled/built later for image in upstream_a: if not self._fetch_image(image): LOG.error("Unable to fetch upstream image: %s" % image.raw_name) sys.exit(1) # fetch if not forcing the build of all images if not args.build: fetch_sort = sorted(fetch_a, key=(lambda img: len(img.children)), reverse=True) for image in fetch_sort: if not self._fetch_image(image): # if didn't fetch, build image.status = DI_BUILD while True: buildable_images = self.get_buildable() if buildable_images and args.pull: LOG.error("Images must be built, but --pull is specified") exit(1) if buildable_images: for image in buildable_images: self._build_image(image) else: LOG.debug("No more images to build, ending build loop") break def get_buildable(self): """ Returns list of images that can be built""" buildable = [] for image in filter(lambda img: img.status is DI_BUILD, self.images): for parent in image.parents: if parent.status is DI_EXISTS: if image not in buildable: # build once if two parents buildable.append(image) LOG.debug("Buildable images: %s" % ', '.join(image.name for image in buildable)) return buildable def tag_image(self, image): """ Applies tags to an image """ for tag in image.tags: LOG.info("Tagging id: '%s', repo: '%s', tag: '%s'" % (image.image_id, image.name, tag)) if self.dc is not None: self.dc.tag(image.image_id, image.name, tag=tag) def _fetch_image(self, image): LOG.info("Attempting to fetch docker image: %s" % image.raw_name) if self.dc is not None: try: for stat_json in self.dc.pull(image.raw_name, stream=True): # sometimes Docker's JSON is dirty, per: # https://github.com/docker/docker-py/pull/1081/ stat_s = stat_json.strip() stat_list = stat_s.split("\r\n") for s_j in stat_list: stat_d = json.loads(s_j) if 'stream' in stat_d: for stat_l in stat_d['stream'].split('\n'): LOG.debug(stat_l) if 'status' in stat_d: for stat_l in stat_d['status'].split('\n'): noisy = ["Extracting", "Downloading", "Waiting", "Download complete", "Pulling fs layer", "Pull complete", "Verifying Checksum", "Already exists"] if stat_l in noisy: LOG.debug(stat_l) else: LOG.info(stat_l) if 'error' in stat_d: LOG.error(stat_d['error']) sys.exit(1) except (DockerErrors.NotFound, DockerErrors.ImageNotFound) as e: LOG.warning("Image could not be pulled: %s" % e) self.failed_pull.append({ "tags": [image.raw_name, ], }) if not image.parents: LOG.error("Pulled image required to build, not available!") sys.exit(1) return False except: LOG.exception("Error pulling docker image") self.failed_pull.append({ "tags": [image.raw_name, ], }) return False # obtain the image_id by inspecting the pulled image. Seems unusual # that the Docker API `pull` method doesn't provide it when the # `build` method does pulled_image = self.dc.inspect_image(image.raw_name) # check to make sure that image that was downloaded has the labels # that we expect it to have, otherwise return false, trigger build if not image.compare_labels( pulled_image['ContainerConfig']['Labels']): LOG.info("Tried fetching image %s, but labels didn't match" % image.raw_name) self.obsolete_pull.append({ "id": pulled_image['Id'], "tags": pulled_image['RepoTags'], }) return False image.image_id = pulled_image['Id'] LOG.info("Fetched image %s, id: %s" % (image.raw_name, image.image_id)) self.pulled.append({ "id": pulled_image['Id'], "tags": pulled_image['RepoTags'], "base": image.name.split(":")[0], }) self.tag_image(image) image.status = DI_EXISTS return True def _build_image(self, image): global build_tag LOG.info("Building docker image for %s" % image.raw_name) if self.dc is not None: image_build_tag = "%s:%s" % (image.name, build_tag) buildargs = image.buildargs() context_tar = image.context_tarball() dockerfile = image.dockerfile_rel_path() for key, val in buildargs.iteritems(): LOG.debug("Buildarg - %s : %s" % (key, val)) bl_path = "" start_time = datetime.datetime.utcnow() if(args.build_log_dir): bl_name = "%s_%s" % (start_time.strftime("%Y%m%dT%H%M%SZ"), re.sub(r'\W', '_', image.name)) bl_path = os.path.abspath( os.path.join(args.build_log_dir, bl_name)) LOG.info("Build log: %s" % bl_path) bl_fh = open(bl_path, 'w+', 0) # 0 = unbuffered writes else: bl_fh = None try: LOG.info("Building image: %s" % image) buildparams = dict( tag=image_build_tag, buildargs=buildargs, nocache=args.build, custom_context=True, fileobj=context_tar, dockerfile=dockerfile, rm=True, forcerm=True, pull=False, decode=True ) if DOCKER_PY_VERSION == 2: buildparams['stream'] = True for stat_d in self.dc.build(**buildparams): if 'stream' in stat_d: if bl_fh: bl_fh.write(stat_d['stream'].encode('utf-8')) for stat_l in stat_d['stream'].split('\n'): if(stat_l): LOG.debug(stat_l) if stat_d['stream'].startswith("Successfully built "): siid = stat_d['stream'].split(' ')[2] short_image_id = siid.strip() LOG.debug("Short Image ID: %s" % short_image_id) if 'status' in stat_d: for stat_l in stat_d['status'].split('\n'): if(stat_l): LOG.info(stat_l) if 'error' in stat_d: LOG.error(stat_d['error']) image.status = DI_ERROR sys.exit(1) except: LOG.exception("Error building docker image") self.failed_build.append({ "tags": [image_build_tag, ], }) return finally: if(bl_fh): bl_fh.close() # the image ID given by output isn't the full SHA256 id, so find # and set it to the full one built_image = self.dc.inspect_image(short_image_id) image.image_id = built_image['Id'] end_time = datetime.datetime.utcnow() duration = end_time - start_time # duration is a timedelta LOG.info("Built Image: %s, duration: %s, id: %s" % (image.name, duration, image.image_id)) self.tag_image(image) # don't push the build_tag to dockerhub built_tags = list(image.tags) built_tags.remove(build_tag) self.built.append({ "id": image.image_id, "tags": built_tags, "build_log": bl_path, "duration": duration.total_seconds(), "base": image.name.split(":")[0], }) image.status = DI_EXISTS if __name__ == "__main__": parse_args() load_config() # only include docker module if not a dry run if not args.dry_run: try: import requests from distutils.version import LooseVersion from docker import __version__ as docker_version # handle the docker-py v1 to v2 API differences if LooseVersion(docker_version) < LooseVersion('2.0.0'): LOG.error("Unsupported python docker module - " "remove docker-py 1.x, install docker 2.x") sys.exit(1) DOCKER_PY_VERSION = 2 if LooseVersion(docker_version) >= LooseVersion('3.0.0'): DOCKER_PY_VERSION = 3 import docker from docker import utils as DockerUtils from docker import errors as DockerErrors except ImportError: LOG.error("Unable to load python docker module (dry run?)") sys.exit(1) rm = RepoManifest() db = DockerBuilder(rm)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 9708, 13, 1881, 3232, 7220, 316, 2752, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 3, 1834, 5649, 14, 647, 199, 3, 295, 10838, 15, 3535, 397, 12424, 3970, 5935, 1126, 3932, 6135, 2004, 315, 3831, 199, 3, 315, 10234, 370, 12424, 12, 4839, 658, 12095, 20932, 13, 362, 3907, 2366, 13, 3187, 64, 199, 199, 646, 7534, 199, 646, 2197, 199, 646, 6135, 199, 646, 2022, 199, 646, 2050, 199, 646, 747, 199, 646, 295, 199, 646, 1059, 199, 646, 984, 199, 646, 13608, 199, 646, 5549, 199, 646, 900, 199, 646, 2748, 14, 9464, 14, 15325, 465, 12265, 199, 646, 8864, 199, 199, 2966, 1249, 199, 2966, 3743, 199, 2966, 1900, 63, 1450, 199, 2966, 1900, 461, 63, 4782, 199, 2966, 10299, 63, 2118, 63, 4782, 199, 199, 29953, 63, 4521, 63, 4612, 275, 378, 421, 199, 318, 3272, 63, 4806, 8, 354, 29, 403, 12, 17251, 29, 797, 304, 272, 2288, 1249, 339, 340, 536, 26, 267, 943, 275, 2050, 14, 5572, 6096, 1674, 904, 779, 363, 354, 3108, 536, 2459, 272, 587, 26, 267, 943, 275, 2050, 14, 5572, 3460, 354, 3368, 339, 5340, 72, 275, 2050, 14, 22482, 8, 1274, 14, 2703, 9, 272, 5340, 72, 14, 26076, 8, 4806, 14, 7772, 8, 4806, 14, 27271, 63, 4807, 430, 272, 5340, 72, 14, 13548, 8, 4806, 14, 5287, 9, 339, 943, 14, 18826, 8, 2482, 72, 9, 339, 327, 13851, 2050, 370, 282, 570, 12, 3544, 10990, 2166, 272, 340, 17251, 26, 267, 4325, 275, 747, 14, 515, 14, 904, 8, 2190, 14, 22222, 12, 2071, 83, 14, 793, 2, 450, 536, 9, 267, 2717, 72, 275, 2050, 14, 21982, 8, 2324, 9, 267, 2717, 72, 14, 26076, 8, 4806, 14, 7772, 8, 4806, 14, 27271, 63, 4807, 430, 267, 2717, 72, 14, 13548, 8, 4806, 14, 5287, 9, 267, 943, 14, 18826, 8, 2327, 72, 9, 339, 372, 943, 421, 199, 4947, 275, 3272, 63, 4806, 342, 421, 199, 318, 2198, 63, 589, 837, 272, 2288, 1249, 339, 1798, 275, 7534, 14, 10730, 342, 339, 1798, 14, 525, 63, 2094, 3654, 67, 297, 2850, 3600, 63, 513, 297, 849, 534, 9991, 63, 4782, 14, 11714, 297, 717, 730, 29, 18978, 14, 20683, 360, 82, 659, 717, 1720, 628, 23103, 4094, 436, 5288, 3970, 769, 531, 339, 327, 446, 70, 365, 2716, 12, 880, 1808, 730, 29, 18978, 14, 20683, 365, 557, 31197, 272, 1798, 14, 525, 63, 2094, 3654, 70, 297, 2850, 1541, 63, 4782, 297, 849, 29, 403, 12, 1595, 534, 1617, 297, 717, 1720, 628, 23103, 570, 18152, 316, 5935, 370, 1900, 15, 3535, 531, 339, 1798, 14, 525, 63, 2094, 3654, 65, 297, 2850, 3723, 63, 28549, 297, 849, 29, 403, 12, 717, 1720, 628, 8229, 282, 18916, 570, 543, 5445, 9394, 5309, 1255, 531, 339, 1572, 275, 1798, 14, 525, 63, 25024, 63, 12730, 63, 923, 342, 272, 1572, 14, 525, 63, 2094, 3654, 66, 297, 2850, 1506, 297, 1595, 628, 1617, 63, 2052, 401, 849, 29, 797, 12, 2432, 1720, 628, 3425, 334, 13196, 1133, 5267, 9, 1006, 5007, 5935, 12, 302, 679, 21481, 531, 272, 1572, 14, 525, 63, 2094, 3654, 80, 297, 2850, 9302, 297, 1595, 628, 1617, 63, 2052, 401, 849, 29, 797, 12, 2432, 1720, 628, 5903, 10299, 15333, 12, 2449, 340, 1900, 1415, 531, 339, 1798, 14, 525, 63, 2094, 3654, 68, 297, 2850, 10481, 63, 1065, 297, 1595, 628, 1617, 63, 2052, 401, 717, 1720, 628, 16932, 1133, 1900, 15, 3535, 7003, 531, 339, 1798, 14, 525, 63, 2094, 3654, 71, 297, 2850, 2180, 297, 849, 29, 403, 12, 717, 1720, 628, 8117, 367, 15854, 3343, 570, 402, 1834, 5936, 531, 339, 1798, 14, 525, 63, 2094, 3654, 76, 297, 2850, 1506, 63, 793, 63, 694, 297, 1595, 628, 1617, 401, 717, 1720, 628, 2445, 1900, 1072, 370, 642, 2935, 340, 663, 531, 339, 1798, 14, 525, 63, 2094, 3654, 82, 297, 2850, 3417, 63, 1231, 297, 849, 628, 703, 401, 1595, 628, 1617, 401, 717, 1720, 628, 11334, 1738, 2082, 531, 339, 1798, 14, 525, 63, 2094, 3654, 84, 297, 2850, 1506, 63, 1450, 297, 849, 29, 403, 12, 1595, 628, 1617, 401, 717, 1720, 628, 1450, 1006, 5935, 6137, 15, 80, 348, 1146, 1808, 642, 1947, 531, 339, 1798, 14, 525, 63, 2094, 3654, 86, 297, 2850, 9833, 297, 1595, 534, 835, 297, 849, 29, 17, 12, 717, 1720, 628, 27600, 370, 19781, 943, 2166, 531, 339, 1798, 14, 525, 63, 2094, 3654, 88, 297, 2850, 3990, 297, 1595, 628, 1617, 63, 2052, 401, 717, 1720, 628, 13606, 20055, 402, 3762, 334, 7551, 3145, 5935, 6320, 339, 1249, 275, 1798, 14, 1122, 63, 589, 342, 339, 340, 1249, 14, 9833, 690, 413, 26, 267, 5051, 14, 13548, 8, 4806, 14, 5287, 9, 272, 587, 26, 267, 5051, 14, 13548, 8, 4806, 14, 4531, 9, 421, 199, 318, 2248, 63, 888, 837, 272, 2288, 1249, 272, 2288, 3743, 272, 2288, 1900, 461, 63, 4782, 272, 2288, 10299, 63, 2118, 63, 4782, 272, 2288, 1900, 63, 1450, 339, 862, 26, 267, 824, 63, 2101, 275, 747, 14, 515, 14, 4832, 8, 589, 14, 3600, 63, 513, 14, 354, 9, 267, 5051, 14, 815, 480, 12288, 3970, 769, 570, 26, 450, 83, 2, 450, 824, 63, 2101, 9, 398, 3743, 275, 8864, 14, 3489, 63, 912, 8, 589, 14, 3600, 63, 513, 9 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 9708, 13, 1881, 3232, 7220, 316, 2752, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 3, 1834, 5649, 14, 647, 199, 3, 295, 10838, 15, 3535, 397, 12424, 3970, 5935, 1126, 3932, 6135, 2004, 315, 3831, 199, 3, 315, 10234, 370, 12424, 12, 4839, 658, 12095, 20932, 13, 362, 3907, 2366, 13, 3187, 64, 199, 199, 646, 7534, 199, 646, 2197, 199, 646, 6135, 199, 646, 2022, 199, 646, 2050, 199, 646, 747, 199, 646, 295, 199, 646, 1059, 199, 646, 984, 199, 646, 13608, 199, 646, 5549, 199, 646, 900, 199, 646, 2748, 14, 9464, 14, 15325, 465, 12265, 199, 646, 8864, 199, 199, 2966, 1249, 199, 2966, 3743, 199, 2966, 1900, 63, 1450, 199, 2966, 1900, 461, 63, 4782, 199, 2966, 10299, 63, 2118, 63, 4782, 199, 199, 29953, 63, 4521, 63, 4612, 275, 378, 421, 199, 318, 3272, 63, 4806, 8, 354, 29, 403, 12, 17251, 29, 797, 304, 272, 2288, 1249, 339, 340, 536, 26, 267, 943, 275, 2050, 14, 5572, 6096, 1674, 904, 779, 363, 354, 3108, 536, 2459, 272, 587, 26, 267, 943, 275, 2050, 14, 5572, 3460, 354, 3368, 339, 5340, 72, 275, 2050, 14, 22482, 8, 1274, 14, 2703, 9, 272, 5340, 72, 14, 26076, 8, 4806, 14, 7772, 8, 4806, 14, 27271, 63, 4807, 430, 272, 5340, 72, 14, 13548, 8, 4806, 14, 5287, 9, 339, 943, 14, 18826, 8, 2482, 72, 9, 339, 327, 13851, 2050, 370, 282, 570, 12, 3544, 10990, 2166, 272, 340, 17251, 26, 267, 4325, 275, 747, 14, 515, 14, 904, 8, 2190, 14, 22222, 12, 2071, 83, 14, 793, 2, 450, 536, 9, 267, 2717, 72, 275, 2050, 14, 21982, 8, 2324, 9, 267, 2717, 72, 14, 26076, 8, 4806, 14, 7772, 8, 4806, 14, 27271, 63, 4807, 430, 267, 2717, 72, 14, 13548, 8, 4806, 14, 5287, 9, 267, 943, 14, 18826, 8, 2327, 72, 9, 339, 372, 943, 421, 199, 4947, 275, 3272, 63, 4806, 342, 421, 199, 318, 2198, 63, 589, 837, 272, 2288, 1249, 339, 1798, 275, 7534, 14, 10730, 342, 339, 1798, 14, 525, 63, 2094, 3654, 67, 297, 2850, 3600, 63, 513, 297, 849, 534, 9991, 63, 4782, 14, 11714, 297, 717, 730, 29, 18978, 14, 20683, 360, 82, 659, 717, 1720, 628, 23103, 4094, 436, 5288, 3970, 769, 531, 339, 327, 446, 70, 365, 2716, 12, 880, 1808, 730, 29, 18978, 14, 20683, 365, 557, 31197, 272, 1798, 14, 525, 63, 2094, 3654, 70, 297, 2850, 1541, 63, 4782, 297, 849, 29, 403, 12, 1595, 534, 1617, 297, 717, 1720, 628, 23103, 570, 18152, 316, 5935, 370, 1900, 15, 3535, 531, 339, 1798, 14, 525, 63, 2094, 3654, 65, 297, 2850, 3723, 63, 28549, 297, 849, 29, 403, 12, 717, 1720, 628, 8229, 282, 18916, 570, 543, 5445, 9394, 5309, 1255, 531, 339, 1572, 275, 1798, 14, 525, 63, 25024, 63, 12730, 63, 923, 342, 272, 1572, 14, 525, 63, 2094, 3654, 66, 297, 2850, 1506, 297, 1595, 628, 1617, 63, 2052, 401, 849, 29, 797, 12, 2432, 1720, 628, 3425, 334, 13196, 1133, 5267, 9, 1006, 5007, 5935, 12, 302, 679, 21481, 531, 272, 1572, 14, 525, 63, 2094, 3654, 80, 297, 2850, 9302, 297, 1595, 628, 1617, 63, 2052, 401, 849, 29, 797, 12, 2432, 1720, 628, 5903, 10299, 15333, 12, 2449, 340, 1900, 1415, 531, 339, 1798, 14, 525, 63, 2094, 3654, 68, 297, 2850, 10481, 63, 1065, 297, 1595, 628, 1617, 63, 2052, 401, 717, 1720, 628, 16932, 1133, 1900, 15, 3535, 7003, 531, 339, 1798, 14, 525, 63, 2094, 3654, 71, 297, 2850, 2180, 297, 849, 29, 403, 12, 717, 1720, 628, 8117, 367, 15854, 3343, 570, 402, 1834, 5936, 531, 339, 1798, 14, 525, 63, 2094, 3654, 76, 297, 2850, 1506, 63, 793, 63, 694, 297, 1595, 628, 1617, 401, 717, 1720, 628, 2445, 1900, 1072, 370, 642, 2935, 340, 663, 531, 339, 1798, 14, 525, 63, 2094, 3654, 82, 297, 2850, 3417, 63, 1231, 297, 849, 628, 703, 401, 1595, 628, 1617, 401, 717, 1720, 628, 11334, 1738, 2082, 531, 339, 1798, 14, 525, 63, 2094, 3654, 84, 297, 2850, 1506, 63, 1450, 297, 849, 29, 403, 12, 1595, 628, 1617, 401, 717, 1720, 628, 1450, 1006, 5935, 6137, 15, 80, 348, 1146, 1808, 642, 1947, 531, 339, 1798, 14, 525, 63, 2094, 3654, 86, 297, 2850, 9833, 297, 1595, 534, 835, 297, 849, 29, 17, 12, 717, 1720, 628, 27600, 370, 19781, 943, 2166, 531, 339, 1798, 14, 525, 63, 2094, 3654, 88, 297, 2850, 3990, 297, 1595, 628, 1617, 63, 2052, 401, 717, 1720, 628, 13606, 20055, 402, 3762, 334, 7551, 3145, 5935, 6320, 339, 1249, 275, 1798, 14, 1122, 63, 589, 342, 339, 340, 1249, 14, 9833, 690, 413, 26, 267, 5051, 14, 13548, 8, 4806, 14, 5287, 9, 272, 587, 26, 267, 5051, 14, 13548, 8, 4806, 14, 4531, 9, 421, 199, 318, 2248, 63, 888, 837, 272, 2288, 1249, 272, 2288, 3743, 272, 2288, 1900, 461, 63, 4782, 272, 2288, 10299, 63, 2118, 63, 4782, 272, 2288, 1900, 63, 1450, 339, 862, 26, 267, 824, 63, 2101, 275, 747, 14, 515, 14, 4832, 8, 589, 14, 3600, 63, 513, 14, 354, 9, 267, 5051, 14, 815, 480, 12288, 3970, 769, 570, 26, 450, 83, 2, 450, 824, 63, 2101, 9, 398, 3743, 275, 8864, 14, 3489, 63, 912, 8, 589, 14, 3600, 63, 513, 9, 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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django.contrib.auth.models import Group from actstream.models import Action from actstream.compat import get_user_model from actstream.tests.base import LTE class GFKManagerTestCase(TestCase): def setUp(self): User = get_user_model() self.user_ct = ContentType.objects.get_for_model(User) self.group_ct = ContentType.objects.get_for_model(Group) self.group, _ = Group.objects.get_or_create(name='CoolGroup') self.user1, _ = User.objects.get_or_create(username='admin') self.user2, _ = User.objects.get_or_create(username='Two') self.user3, _ = User.objects.get_or_create(username='Three') self.user4, _ = User.objects.get_or_create(username='Four') Action.objects.get_or_create( actor_content_type=self.user_ct, actor_object_id=self.user1.id, verb='followed', target_content_type=self.user_ct, target_object_id=self.user2.id ) Action.objects.get_or_create( actor_content_type=self.user_ct, actor_object_id=self.user1.id, verb='followed', target_content_type=self.user_ct, target_object_id=self.user3.id ) Action.objects.get_or_create( actor_content_type=self.user_ct, actor_object_id=self.user1.id, verb='followed', target_content_type=self.user_ct, target_object_id=self.user4.id ) Action.objects.get_or_create( actor_content_type=self.user_ct, actor_object_id=self.user1.id, verb='joined', target_content_type=self.group_ct, target_object_id=self.group.id ) def test_fetch_generic_relations(self): # baseline without fetch_generic_relations _actions = Action.objects.filter(actor_content_type=self.user_ct, actor_object_id=self.user1.id) actions = lambda: _actions._clone() num_content_types = len(set(actions().values_list( 'target_content_type_id', flat=True))) n = actions().count() # compare to fetching only 1 generic relation full, generic = actions(), actions().fetch_generic_relations('target') self.assertNumQueries(LTE(n + 1), lambda: [a.target for a in full]) self.assertNumQueries(LTE(num_content_types + 2), lambda: [a.target for a in generic]) action_targets = [(a.id, a.target) for a in actions()] action_targets_fetch_generic = [ (a.id, a.target) for a in actions().fetch_generic_relations('target')] self.assertEqual(action_targets, action_targets_fetch_generic) # compare to fetching all generic relations num_content_types = len(set(sum(actions().values_list( 'actor_content_type_id', 'target_content_type_id'), ()))) full, generic = actions(), actions().fetch_generic_relations() self.assertNumQueries(LTE(2 * n + 1), lambda: [(a.actor, a.target) for a in full]) self.assertNumQueries(LTE(num_content_types + 2), lambda: [(a.actor, a.target) for a in generic]) action_actor_targets = [(a.id, a.actor, a.target) for a in actions()] action_actor_targets_fetch_generic_all = [ (a.id, a.actor, a.target) for a in actions().fetch_generic_relations()] self.assertEqual(action_actor_targets, action_actor_targets_fetch_generic_all) # fetch only 1 generic relation, but access both gfks generic = lambda: actions().fetch_generic_relations('target') self.assertNumQueries(LTE(n + num_content_types + 2), lambda: [ (a.actor, a.target) for a in generic()]) action_actor_targets_fetch_generic_target = [ (a.id, a.actor, a.target) for a in generic()] self.assertEqual(action_actor_targets, action_actor_targets_fetch_generic_target)
bsd-3-clause
[ 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 5611, 199, 199, 504, 2454, 1745, 14, 992, 492, 10033, 199, 504, 2454, 1745, 14, 5819, 492, 664, 63, 751, 63, 1238, 199, 504, 2454, 1745, 14, 2219, 14, 1095, 492, 491, 3727, 421, 199, 533, 598, 21490, 2988, 1746, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 2876, 275, 664, 63, 751, 63, 1238, 342, 267, 291, 14, 751, 63, 319, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 1899, 9, 267, 291, 14, 923, 63, 319, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 2448, 9, 267, 291, 14, 923, 12, 485, 275, 5611, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 354, 534, 967, 393, 2448, 358, 267, 291, 14, 751, 17, 12, 485, 275, 2876, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 2473, 534, 2113, 358, 267, 291, 14, 751, 18, 12, 485, 275, 2876, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 2473, 534, 11467, 358, 267, 291, 14, 751, 19, 12, 485, 275, 2876, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 2473, 534, 21485, 358, 267, 291, 14, 751, 20, 12, 485, 275, 2876, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 2473, 534, 24766, 358, 267, 10033, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 288, 20318, 63, 1317, 63, 466, 29, 277, 14, 751, 63, 319, 12, 288, 20318, 63, 785, 63, 344, 29, 277, 14, 751, 17, 14, 344, 12, 288, 16041, 534, 7207, 379, 297, 288, 1347, 63, 1317, 63, 466, 29, 277, 14, 751, 63, 319, 12, 288, 1347, 63, 785, 63, 344, 29, 277, 14, 751, 18, 14, 344, 267, 776, 267, 10033, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 288, 20318, 63, 1317, 63, 466, 29, 277, 14, 751, 63, 319, 12, 288, 20318, 63, 785, 63, 344, 29, 277, 14, 751, 17, 14, 344, 12, 288, 16041, 534, 7207, 379, 297, 288, 1347, 63, 1317, 63, 466, 29, 277, 14, 751, 63, 319, 12, 288, 1347, 63, 785, 63, 344, 29, 277, 14, 751, 19, 14, 344, 267, 776, 267, 10033, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 288, 20318, 63, 1317, 63, 466, 29, 277, 14, 751, 63, 319, 12, 288, 20318, 63, 785, 63, 344, 29, 277, 14, 751, 17, 14, 344, 12, 288, 16041, 534, 7207, 379, 297, 288, 1347, 63, 1317, 63, 466, 29, 277, 14, 751, 63, 319, 12, 288, 1347, 63, 785, 63, 344, 29, 277, 14, 751, 20, 14, 344, 267, 776, 267, 10033, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 288, 20318, 63, 1317, 63, 466, 29, 277, 14, 751, 63, 319, 12, 288, 20318, 63, 785, 63, 344, 29, 277, 14, 751, 17, 14, 344, 12, 288, 16041, 534, 11806, 297, 288, 1347, 63, 1317, 63, 466, 29, 277, 14, 923, 63, 319, 12, 288, 1347, 63, 785, 63, 344, 29, 277, 14, 923, 14, 344, 267, 776, 339, 347, 511, 63, 3535, 63, 6767, 63, 15741, 8, 277, 304, 267, 327, 18828, 1928, 5267, 63, 6767, 63, 15741, 267, 485, 3723, 275, 10033, 14, 1462, 14, 1541, 8, 5021, 63, 1317, 63, 466, 29, 277, 14, 751, 63, 319, 12, 1460, 20318, 63, 785, 63, 344, 29, 277, 14, 751, 17, 14, 344, 9, 267, 5445, 275, 2400, 26, 485, 3723, 423, 6311, 342, 267, 1967, 63, 1317, 63, 1313, 275, 822, 8, 409, 8, 3723, 1252, 1459, 63, 513, 8, 288, 283, 1375, 63, 1317, 63, 466, 63, 344, 297, 6829, 29, 549, 1724, 267, 302, 275, 5445, 1252, 835, 342, 398, 327, 6540, 370, 21239, 1454, 413, 7809, 5850, 267, 2615, 12, 7809, 275, 5445, 1062, 5445, 1252, 3535, 63, 6767, 63, 15741, 360, 1375, 358, 267, 291, 14, 16463, 8, 44, 3727, 8, 78, 435, 413, 395, 2892, 2400, 26, 359, 65, 14, 1375, 367, 282, 315, 2615, 566, 267, 291, 14, 16463, 8, 44, 3727, 8, 1507, 63, 1317, 63, 1313, 435, 499, 395, 2892, 2400, 26, 359, 65, 14, 1375, 367, 282, 315, 7809, 566, 398, 1595, 63, 4684, 275, 3842, 65, 14, 344, 12, 282, 14, 1375, 9, 367, 282, 315, 5445, 5106, 267, 1595, 63, 4684, 63, 3535, 63, 6767, 275, 359, 288, 334, 65, 14, 344, 12, 282, 14, 1375, 9, 288, 367, 282, 315, 5445, 1252, 3535, 63, 6767, 63, 15741, 360, 1375, 5440, 267, 291, 14, 629, 8, 1287, 63, 4684, 12, 1595, 63, 4684, 63, 3535, 63, 6767, 9, 398, 327, 6540, 370, 21239, 1006, 7809, 16109, 267, 1967, 63, 1317, 63, 1313, 275, 822, 8, 409, 8, 1838, 8, 3723, 1252, 1459, 63, 513, 8, 288, 283, 5021, 63, 1317, 63, 466, 63, 344, 297, 283, 1375, 63, 1317, 63, 466, 63, 344, 659, 334, 7845, 267, 2615, 12, 7809, 275, 5445, 1062, 5445, 1252, 3535, 63, 6767, 63, 15741, 342, 267, 291, 14, 16463, 8, 44, 3727, 8, 18, 627, 302, 435, 413, 395, 2892, 2400, 26, 3842, 65, 14, 5021, 12, 282, 14, 1375, 9, 367, 282, 315, 2615, 566, 267, 291, 14, 16463, 8, 44, 3727, 8, 1507, 63, 1317, 63, 1313, 435, 499, 395, 2892, 2400, 26, 3842, 65, 14, 5021, 12, 282, 14, 1375, 9, 367, 282, 315, 7809, 566, 398, 1595, 63, 5021, 63, 4684, 275, 3842, 65, 14, 344, 12, 282, 14, 5021, 12, 282, 14, 1375, 9, 367, 282, 315, 5445, 5106, 267, 1595, 63, 5021, 63, 4684, 63, 3535, 63, 6767, 63, 452, 275, 359, 288, 334, 65, 14, 344, 12, 282, 14, 5021, 12, 282, 14, 1375, 9, 288, 367, 282, 315, 5445, 1252, 3535, 63, 6767, 63, 15741, 5106, 267, 291, 14, 629, 8, 1287, 63, 5021, 63, 4684, 12, 586, 1595, 63, 5021, 63, 4684, 63, 3535, 63, 6767, 63, 452, 9, 398, 327, 5267, 1454, 413, 7809, 5850, 12, 1325, 2879, 3865, 15719, 6080, 267, 7809, 275, 2400, 26, 5445, 1252, 3535, 63, 6767, 63, 15741, 360, 1375, 358, 267, 291, 14, 16463, 8, 44, 3727 ]
[ 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 5611, 199, 199, 504, 2454, 1745, 14, 992, 492, 10033, 199, 504, 2454, 1745, 14, 5819, 492, 664, 63, 751, 63, 1238, 199, 504, 2454, 1745, 14, 2219, 14, 1095, 492, 491, 3727, 421, 199, 533, 598, 21490, 2988, 1746, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 2876, 275, 664, 63, 751, 63, 1238, 342, 267, 291, 14, 751, 63, 319, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 1899, 9, 267, 291, 14, 923, 63, 319, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 2448, 9, 267, 291, 14, 923, 12, 485, 275, 5611, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 354, 534, 967, 393, 2448, 358, 267, 291, 14, 751, 17, 12, 485, 275, 2876, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 2473, 534, 2113, 358, 267, 291, 14, 751, 18, 12, 485, 275, 2876, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 2473, 534, 11467, 358, 267, 291, 14, 751, 19, 12, 485, 275, 2876, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 2473, 534, 21485, 358, 267, 291, 14, 751, 20, 12, 485, 275, 2876, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 2473, 534, 24766, 358, 267, 10033, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 288, 20318, 63, 1317, 63, 466, 29, 277, 14, 751, 63, 319, 12, 288, 20318, 63, 785, 63, 344, 29, 277, 14, 751, 17, 14, 344, 12, 288, 16041, 534, 7207, 379, 297, 288, 1347, 63, 1317, 63, 466, 29, 277, 14, 751, 63, 319, 12, 288, 1347, 63, 785, 63, 344, 29, 277, 14, 751, 18, 14, 344, 267, 776, 267, 10033, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 288, 20318, 63, 1317, 63, 466, 29, 277, 14, 751, 63, 319, 12, 288, 20318, 63, 785, 63, 344, 29, 277, 14, 751, 17, 14, 344, 12, 288, 16041, 534, 7207, 379, 297, 288, 1347, 63, 1317, 63, 466, 29, 277, 14, 751, 63, 319, 12, 288, 1347, 63, 785, 63, 344, 29, 277, 14, 751, 19, 14, 344, 267, 776, 267, 10033, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 288, 20318, 63, 1317, 63, 466, 29, 277, 14, 751, 63, 319, 12, 288, 20318, 63, 785, 63, 344, 29, 277, 14, 751, 17, 14, 344, 12, 288, 16041, 534, 7207, 379, 297, 288, 1347, 63, 1317, 63, 466, 29, 277, 14, 751, 63, 319, 12, 288, 1347, 63, 785, 63, 344, 29, 277, 14, 751, 20, 14, 344, 267, 776, 267, 10033, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 288, 20318, 63, 1317, 63, 466, 29, 277, 14, 751, 63, 319, 12, 288, 20318, 63, 785, 63, 344, 29, 277, 14, 751, 17, 14, 344, 12, 288, 16041, 534, 11806, 297, 288, 1347, 63, 1317, 63, 466, 29, 277, 14, 923, 63, 319, 12, 288, 1347, 63, 785, 63, 344, 29, 277, 14, 923, 14, 344, 267, 776, 339, 347, 511, 63, 3535, 63, 6767, 63, 15741, 8, 277, 304, 267, 327, 18828, 1928, 5267, 63, 6767, 63, 15741, 267, 485, 3723, 275, 10033, 14, 1462, 14, 1541, 8, 5021, 63, 1317, 63, 466, 29, 277, 14, 751, 63, 319, 12, 1460, 20318, 63, 785, 63, 344, 29, 277, 14, 751, 17, 14, 344, 9, 267, 5445, 275, 2400, 26, 485, 3723, 423, 6311, 342, 267, 1967, 63, 1317, 63, 1313, 275, 822, 8, 409, 8, 3723, 1252, 1459, 63, 513, 8, 288, 283, 1375, 63, 1317, 63, 466, 63, 344, 297, 6829, 29, 549, 1724, 267, 302, 275, 5445, 1252, 835, 342, 398, 327, 6540, 370, 21239, 1454, 413, 7809, 5850, 267, 2615, 12, 7809, 275, 5445, 1062, 5445, 1252, 3535, 63, 6767, 63, 15741, 360, 1375, 358, 267, 291, 14, 16463, 8, 44, 3727, 8, 78, 435, 413, 395, 2892, 2400, 26, 359, 65, 14, 1375, 367, 282, 315, 2615, 566, 267, 291, 14, 16463, 8, 44, 3727, 8, 1507, 63, 1317, 63, 1313, 435, 499, 395, 2892, 2400, 26, 359, 65, 14, 1375, 367, 282, 315, 7809, 566, 398, 1595, 63, 4684, 275, 3842, 65, 14, 344, 12, 282, 14, 1375, 9, 367, 282, 315, 5445, 5106, 267, 1595, 63, 4684, 63, 3535, 63, 6767, 275, 359, 288, 334, 65, 14, 344, 12, 282, 14, 1375, 9, 288, 367, 282, 315, 5445, 1252, 3535, 63, 6767, 63, 15741, 360, 1375, 5440, 267, 291, 14, 629, 8, 1287, 63, 4684, 12, 1595, 63, 4684, 63, 3535, 63, 6767, 9, 398, 327, 6540, 370, 21239, 1006, 7809, 16109, 267, 1967, 63, 1317, 63, 1313, 275, 822, 8, 409, 8, 1838, 8, 3723, 1252, 1459, 63, 513, 8, 288, 283, 5021, 63, 1317, 63, 466, 63, 344, 297, 283, 1375, 63, 1317, 63, 466, 63, 344, 659, 334, 7845, 267, 2615, 12, 7809, 275, 5445, 1062, 5445, 1252, 3535, 63, 6767, 63, 15741, 342, 267, 291, 14, 16463, 8, 44, 3727, 8, 18, 627, 302, 435, 413, 395, 2892, 2400, 26, 3842, 65, 14, 5021, 12, 282, 14, 1375, 9, 367, 282, 315, 2615, 566, 267, 291, 14, 16463, 8, 44, 3727, 8, 1507, 63, 1317, 63, 1313, 435, 499, 395, 2892, 2400, 26, 3842, 65, 14, 5021, 12, 282, 14, 1375, 9, 367, 282, 315, 7809, 566, 398, 1595, 63, 5021, 63, 4684, 275, 3842, 65, 14, 344, 12, 282, 14, 5021, 12, 282, 14, 1375, 9, 367, 282, 315, 5445, 5106, 267, 1595, 63, 5021, 63, 4684, 63, 3535, 63, 6767, 63, 452, 275, 359, 288, 334, 65, 14, 344, 12, 282, 14, 5021, 12, 282, 14, 1375, 9, 288, 367, 282, 315, 5445, 1252, 3535, 63, 6767, 63, 15741, 5106, 267, 291, 14, 629, 8, 1287, 63, 5021, 63, 4684, 12, 586, 1595, 63, 5021, 63, 4684, 63, 3535, 63, 6767, 63, 452, 9, 398, 327, 5267, 1454, 413, 7809, 5850, 12, 1325, 2879, 3865, 15719, 6080, 267, 7809, 275, 2400, 26, 5445, 1252, 3535, 63, 6767, 63, 15741, 360, 1375, 358, 267, 291, 14, 16463, 8, 44, 3727, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ArvisP/Rubix
tmp/bs4_test.py
2
1126
from bs4 import BeautifulSoup from urllib.request import urlopen import sys r = urlopen("https://www.worldcubeassociation.org/competitions") soup = BeautifulSoup(r, "html.parser") date_box = soup.find_all('span', attrs={'class': 'date'}) title_box = soup.find_all('p', attrs={'class': 'competition-link'}) location_box = soup.find_all('p', attrs={'class': 'location'}) venue_box = soup.find_all('div', attrs={'class': 'venue-link'}) # date = date_box.text.strip() # title = title_box.text.strip() # location = location_box.text.strip() # venue = venue_box.text.strip() date_set = [] title_set = [] location_set = [] venue_set = [] for date in date_box: date_set.append(date.text.strip()) for title in title_box: title_set.append(title.text.strip()) for location in location_box: location_set.append(location.text.strip()) for venue in venue_box: venue_set.append(venue.text.strip()) # sys.stdout = open("out2.txt", "w") print(date_set[0:3]) print(title_set[0:3]) print(location_set[0:3]) print(venue_set[0:3]) # print(date_box, title_box, location_box, venue_box) # print(date, title, location, venue)
mit
[ 504, 9922, 20, 492, 17132, 199, 504, 4011, 14, 1069, 492, 18279, 199, 646, 984, 199, 199, 82, 275, 18279, 480, 2859, 921, 1544, 14, 7617, 11477, 20252, 14, 1308, 15, 863, 69, 7752, 531, 199, 199, 9317, 275, 17132, 8, 82, 12, 298, 1360, 14, 2087, 531, 199, 199, 602, 63, 1977, 275, 9108, 14, 1623, 63, 452, 360, 3751, 297, 3290, 3713, 533, 356, 283, 602, 3071, 199, 1213, 63, 1977, 275, 9108, 14, 1623, 63, 452, 360, 80, 297, 3290, 3713, 533, 356, 283, 863, 69, 3348, 13, 1073, 3071, 199, 1985, 63, 1977, 275, 9108, 14, 1623, 63, 452, 360, 80, 297, 3290, 3713, 533, 356, 283, 1985, 3071, 199, 24728, 63, 1977, 275, 9108, 14, 1623, 63, 452, 360, 3015, 297, 3290, 3713, 533, 356, 283, 24728, 13, 1073, 3071, 421, 199, 3, 1434, 275, 1434, 63, 1977, 14, 505, 14, 1913, 342, 199, 3, 2538, 275, 2538, 63, 1977, 14, 505, 14, 1913, 342, 199, 3, 2909, 275, 2909, 63, 1977, 14, 505, 14, 1913, 342, 199, 3, 373, 287, 310, 275, 373, 287, 310, 63, 1977, 14, 505, 14, 1913, 342, 199, 602, 63, 409, 275, 942, 199, 1213, 63, 409, 275, 942, 199, 1985, 63, 409, 275, 942, 199, 24728, 63, 409, 275, 942, 199, 509, 1434, 315, 1434, 63, 1977, 26, 523, 1434, 63, 409, 14, 740, 8, 602, 14, 505, 14, 1913, 1012, 2043, 199, 509, 2538, 315, 2538, 63, 1977, 26, 523, 2538, 63, 409, 14, 740, 8, 1213, 14, 505, 14, 1913, 1012, 199, 199, 509, 2909, 315, 2909, 63, 1977, 26, 523, 2909, 63, 409, 14, 740, 8, 1985, 14, 505, 14, 1913, 1012, 199, 199, 509, 373, 287, 310, 315, 373, 287, 310, 63, 1977, 26, 523, 373, 287, 310, 63, 409, 14, 740, 8, 24728, 14, 505, 14, 1913, 1012, 2043, 199, 3, 984, 14, 2703, 275, 1551, 480, 548, 18, 14, 2424, 401, 298, 87, 531, 199, 1361, 8, 602, 63, 409, 59, 16, 26, 19, 566, 199, 1361, 8, 1213, 63, 409, 59, 16, 26, 19, 566, 199, 1361, 8, 1985, 63, 409, 59, 16, 26, 19, 566, 199, 1361, 8, 24728, 63, 409, 59, 16, 26, 19, 566, 2043, 199, 199, 3, 870, 8, 602, 63, 1977, 12, 2538, 63, 1977, 12, 2909, 63, 1977, 12, 373, 287, 310, 63, 1977, 9, 199, 3, 870, 8, 602, 12, 2538, 12, 2909, 12, 373, 287, 310, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 9922, 20, 492, 17132, 199, 504, 4011, 14, 1069, 492, 18279, 199, 646, 984, 199, 199, 82, 275, 18279, 480, 2859, 921, 1544, 14, 7617, 11477, 20252, 14, 1308, 15, 863, 69, 7752, 531, 199, 199, 9317, 275, 17132, 8, 82, 12, 298, 1360, 14, 2087, 531, 199, 199, 602, 63, 1977, 275, 9108, 14, 1623, 63, 452, 360, 3751, 297, 3290, 3713, 533, 356, 283, 602, 3071, 199, 1213, 63, 1977, 275, 9108, 14, 1623, 63, 452, 360, 80, 297, 3290, 3713, 533, 356, 283, 863, 69, 3348, 13, 1073, 3071, 199, 1985, 63, 1977, 275, 9108, 14, 1623, 63, 452, 360, 80, 297, 3290, 3713, 533, 356, 283, 1985, 3071, 199, 24728, 63, 1977, 275, 9108, 14, 1623, 63, 452, 360, 3015, 297, 3290, 3713, 533, 356, 283, 24728, 13, 1073, 3071, 421, 199, 3, 1434, 275, 1434, 63, 1977, 14, 505, 14, 1913, 342, 199, 3, 2538, 275, 2538, 63, 1977, 14, 505, 14, 1913, 342, 199, 3, 2909, 275, 2909, 63, 1977, 14, 505, 14, 1913, 342, 199, 3, 373, 287, 310, 275, 373, 287, 310, 63, 1977, 14, 505, 14, 1913, 342, 199, 602, 63, 409, 275, 942, 199, 1213, 63, 409, 275, 942, 199, 1985, 63, 409, 275, 942, 199, 24728, 63, 409, 275, 942, 199, 509, 1434, 315, 1434, 63, 1977, 26, 523, 1434, 63, 409, 14, 740, 8, 602, 14, 505, 14, 1913, 1012, 2043, 199, 509, 2538, 315, 2538, 63, 1977, 26, 523, 2538, 63, 409, 14, 740, 8, 1213, 14, 505, 14, 1913, 1012, 199, 199, 509, 2909, 315, 2909, 63, 1977, 26, 523, 2909, 63, 409, 14, 740, 8, 1985, 14, 505, 14, 1913, 1012, 199, 199, 509, 373, 287, 310, 315, 373, 287, 310, 63, 1977, 26, 523, 373, 287, 310, 63, 409, 14, 740, 8, 24728, 14, 505, 14, 1913, 1012, 2043, 199, 3, 984, 14, 2703, 275, 1551, 480, 548, 18, 14, 2424, 401, 298, 87, 531, 199, 1361, 8, 602, 63, 409, 59, 16, 26, 19, 566, 199, 1361, 8, 1213, 63, 409, 59, 16, 26, 19, 566, 199, 1361, 8, 1985, 63, 409, 59, 16, 26, 19, 566, 199, 1361, 8, 24728, 63, 409, 59, 16, 26, 19, 566, 2043, 199, 199, 3, 870, 8, 602, 63, 1977, 12, 2538, 63, 1977, 12, 2909, 63, 1977, 12, 373, 287, 310, 63, 1977, 9, 199, 3, 870, 8, 602, 12, 2538, 12, 2909, 12, 373, 287, 310, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
mheap/ansible
test/runner/lib/cloud/nios.py
7
5273
"""NIOS plugin for integration tests.""" from __future__ import absolute_import, print_function import os from . import ( CloudProvider, CloudEnvironment, ) from ..util import ( find_executable, display, ) from ..docker_util import ( docker_run, docker_rm, docker_inspect, docker_pull, get_docker_container_id, ) class NiosProvider(CloudProvider): """Nios plugin. Sets up NIOS mock server for tests. """ DOCKER_SIMULATOR_NAME = 'nios-simulator' DOCKER_IMAGE = 'quay.io/ansible/nios-test-container:1.0.0' """Default image to run the nios simulator. The simulator must be pinned to a specific version to guarantee CI passes with the version used. It's source source itself resides at: https://github.com/ansible/nios-test-container """ def __init__(self, args): """Set up container references for provider. :type args: TestConfig """ super(NiosProvider, self).__init__(args) self.__container_from_env = os.getenv('ANSIBLE_NIOSSIM_CONTAINER') """Overrides target container, might be used for development. Use ANSIBLE_NIOSSIM_CONTAINER=whatever_you_want if you want to use other image. Omit/empty otherwise. """ self.image = self.__container_from_env or self.DOCKER_IMAGE self.container_name = '' def filter(self, targets, exclude): """Filter out the tests with the necessary config and res unavailable. :type targets: tuple[TestTarget] :type exclude: list[str] """ docker_cmd = 'docker' docker = find_executable(docker_cmd, required=False) if docker: return skip = 'cloud/%s/' % self.platform skipped = [target.name for target in targets if skip in target.aliases] if skipped: exclude.append(skip) display.warning( 'Excluding tests marked "%s" ' 'which require the "%s" command: %s' % (skip.rstrip('/'), docker_cmd, ', '.join(skipped)) ) def setup(self): """Setup cloud resource before delegation and reg cleanup callback.""" super(NiosProvider, self).setup() if self._use_static_config(): self._setup_static() else: self._setup_dynamic() def get_docker_run_options(self): """Get additional options needed when delegating tests to a container. :rtype: list[str] """ return ['--link', self.DOCKER_SIMULATOR_NAME] if self.managed else [] def cleanup(self): """Clean up the resource and temporary configs files after tests.""" if self.container_name: docker_rm(self.args, self.container_name) super(NiosProvider, self).cleanup() def _setup_dynamic(self): """Spawn a NIOS simulator within docker container.""" nios_port = 443 container_id = get_docker_container_id() if container_id: display.info( 'Running in docker container: %s' % container_id, verbosity=1, ) self.container_name = self.DOCKER_SIMULATOR_NAME results = docker_inspect(self.args, self.container_name) if results and not results[0].get('State', {}).get('Running'): docker_rm(self.args, self.container_name) results = [] display.info( '%s NIOS simulator docker container.' % ('Using the existing' if results else 'Starting a new'), verbosity=1, ) if not results: if self.args.docker or container_id: publish_ports = [] else: # publish the simulator ports when not running inside docker publish_ports = [ '-p', ':'.join((str(nios_port), ) * 2), ] if not self.__container_from_env: docker_pull(self.args, self.image) docker_run( self.args, self.image, ['-d', '--name', self.container_name] + publish_ports, ) if self.args.docker: nios_host = self.DOCKER_SIMULATOR_NAME elif container_id: nios_host = self._get_simulator_address() display.info( 'Found NIOS simulator container address: %s' % nios_host, verbosity=1 ) else: nios_host = 'localhost' self._set_cloud_config('NIOS_HOST', nios_host) def _get_simulator_address(self): results = docker_inspect(self.args, self.container_name) ip_address = results[0]['NetworkSettings']['IPAddress'] return ip_address def _setup_static(self): raise NotImplementedError class NiosEnvironment(CloudEnvironment): """NIOS environment plugin. Updates integration test environment after delegation. """ def configure_environment(self, env, cmd): """ :type env: dict[str, str] :type cmd: list[str] """ # Send the container IP down to the integration test(s) env['NIOS_HOST'] = self._get_cloud_config('NIOS_HOST')
gpl-3.0
[ 624, 46, 13532, 3589, 367, 13150, 2295, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 747, 199, 199, 504, 1275, 492, 334, 272, 8142, 6663, 12, 272, 8142, 8263, 12, 199, 9, 199, 199, 504, 2508, 1974, 492, 334, 272, 2342, 63, 5904, 12, 272, 2929, 12, 199, 9, 199, 199, 504, 2508, 9991, 63, 1974, 492, 334, 272, 12424, 63, 1065, 12, 272, 12424, 63, 5682, 12, 272, 12424, 63, 10955, 12, 272, 12424, 63, 9302, 12, 272, 664, 63, 9991, 63, 3600, 63, 344, 12, 199, 9, 421, 199, 533, 653, 9207, 6663, 8, 9089, 6663, 304, 272, 408, 46, 9207, 3589, 14, 339, 10729, 1536, 653, 13532, 1683, 1654, 367, 2295, 14, 272, 408, 339, 3506, 2504, 540, 63, 16590, 1293, 6467, 63, 2339, 275, 283, 8445, 736, 13, 20125, 7, 339, 3506, 2504, 540, 63, 9438, 275, 283, 392, 1187, 14, 2308, 15, 4853, 15, 8445, 736, 13, 396, 13, 3600, 26, 17, 14, 16, 14, 16, 7, 272, 408, 2698, 1834, 370, 1255, 314, 302, 9207, 15797, 14, 339, 710, 15797, 1471, 506, 10713, 7439, 370, 282, 2488, 1015, 272, 370, 24197, 445, 41, 14933, 543, 314, 1015, 1202, 14, 339, 2779, 1159, 1350, 1350, 6337, 295, 19564, 737, 26, 272, 4178, 921, 5031, 14, 957, 15, 4853, 15, 8445, 736, 13, 396, 13, 3600, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1249, 304, 267, 408, 1084, 1536, 3970, 6941, 367, 5022, 14, 398, 520, 466, 1249, 26, 1379, 2028, 267, 408, 267, 1613, 8, 46, 9207, 6663, 12, 291, 2843, 826, 721, 589, 9, 398, 291, 855, 3600, 63, 504, 63, 1813, 275, 747, 14, 12959, 360, 8490, 63, 46, 2090, 2300, 1469, 63, 31250, 358, 267, 408, 27586, 1347, 3970, 12, 5594, 506, 1202, 367, 16367, 14, 398, 3645, 32271, 7187, 63, 46, 2090, 2300, 1469, 63, 31250, 29, 26517, 63, 13297, 63, 7051, 340, 1265, 2934, 267, 370, 675, 1163, 1834, 14, 593, 1147, 15, 1667, 4257, 14, 267, 408, 398, 291, 14, 1569, 275, 291, 855, 3600, 63, 504, 63, 1813, 503, 291, 14, 29953, 63, 9438, 267, 291, 14, 3600, 63, 354, 275, 2125, 339, 347, 2457, 8, 277, 12, 4545, 12, 5760, 304, 267, 408, 4131, 734, 314, 2295, 543, 314, 5784, 1101, 436, 522, 18735, 14, 398, 520, 466, 4545, 26, 2008, 59, 774, 4277, 61, 267, 520, 466, 5760, 26, 769, 59, 495, 61, 267, 408, 267, 12424, 63, 1760, 275, 283, 9991, 7, 267, 12424, 275, 2342, 63, 5904, 8, 9991, 63, 1760, 12, 1415, 29, 797, 9, 398, 340, 12424, 26, 288, 372, 398, 3372, 275, 283, 4091, 3149, 83, 4805, 450, 291, 14, 3246, 267, 9645, 275, 359, 1375, 14, 354, 367, 1347, 315, 4545, 340, 3372, 315, 1347, 14, 8602, 61, 398, 340, 9645, 26, 288, 5760, 14, 740, 8, 2759, 9, 288, 2929, 14, 3764, 8, 355, 283, 920, 4923, 2295, 11584, 2071, 83, 2, 283, 355, 283, 6777, 4409, 314, 2071, 83, 2, 1414, 26, 450, 83, 7, 355, 450, 334, 2759, 14, 6735, 2336, 659, 12424, 63, 1760, 12, 1656, 1987, 904, 8, 11962, 430, 288, 776, 339, 347, 3272, 8, 277, 304, 267, 408, 8555, 8002, 2073, 2544, 18703, 425, 436, 1295, 9058, 3233, 1041, 267, 1613, 8, 46, 9207, 6663, 12, 291, 680, 2758, 342, 398, 340, 291, 423, 1180, 63, 1986, 63, 888, 837, 288, 291, 423, 2758, 63, 1986, 342, 267, 587, 26, 288, 291, 423, 2758, 63, 7764, 342, 339, 347, 664, 63, 9991, 63, 1065, 63, 1419, 8, 277, 304, 267, 408, 1002, 4722, 1511, 4346, 1380, 18703, 1958, 2295, 370, 282, 3970, 14, 398, 520, 4500, 26, 769, 59, 495, 61, 267, 408, 267, 372, 14574, 1073, 297, 291, 14, 29953, 63, 16590, 1293, 6467, 63, 2339, 61, 340, 291, 14, 11122, 587, 942, 339, 347, 9058, 8, 277, 304, 267, 408, 6580, 1536, 314, 2073, 436, 7937, 11585, 1584, 2410, 2295, 1041, 267, 340, 291, 14, 3600, 63, 354, 26, 288, 12424, 63, 5682, 8, 277, 14, 589, 12, 291, 14, 3600, 63, 354, 9, 398, 1613, 8, 46, 9207, 6663, 12, 291, 680, 7661, 342, 339, 347, 485, 2758, 63, 7764, 8, 277, 304, 267, 408, 12739, 3501, 282, 653, 13532, 15797, 4453, 12424, 3970, 1041, 267, 302, 9207, 63, 719, 275, 23865, 267, 3970, 63, 344, 275, 664, 63, 9991, 63, 3600, 63, 344, 342, 398, 340, 3970, 63, 344, 26, 288, 2929, 14, 815, 8, 355, 283, 9602, 315, 12424, 3970, 26, 450, 83, 7, 450, 3970, 63, 344, 12, 355, 8661, 29, 17, 12, 288, 776, 398, 291, 14, 3600, 63, 354, 275, 291, 14, 29953, 63, 16590, 1293, 6467, 63, 2339, 398, 2058, 275, 12424, 63, 10955, 8, 277, 14, 589, 12, 291, 14, 3600, 63, 354, 9, 398, 340, 2058, 436, 440, 2058, 59, 16, 1055, 362, 360, 2223, 297, 13056, 362, 360, 9602, 735, 288, 12424, 63, 5682, 8, 277, 14, 589, 12, 291, 14, 3600, 63, 354, 9, 288, 2058, 275, 942, 398, 2929, 14, 815, 8, 288, 1543, 83, 653, 13532, 15797, 12424, 3970, 3530, 288, 450, 661, 10369, 314, 3411, 7, 340, 2058, 587, 283, 14139, 282, 892, 659, 288, 8661, 29, 17, 12, 267, 776, 398, 340, 440, 2058, 26, 288, 340, 291, 14, 589, 14, 9991, 503, 3970, 63, 344, 26, 355, 2780, 63, 5203, 275, 942, 288, 587, 26, 355, 327, 2780, 314, 15797, 8873, 1380, 440, 3879, 6272, 12424, 355, 2780, 63, 5203, 275, 359, 490, 2475, 80, 297, 29010, 904, 1332, 495, 8, 8445, 736, 63, 719, 395, 776, 627, 499, 395, 355, 1622, 953, 340, 440, 291, 855, 3600, 63, 504, 63, 1813, 26, 355, 12424, 63, 9302, 8, 277, 14, 589, 12, 291, 14, 1569, 9, 953, 12424, 63, 1065, 8, 355, 291, 14, 589, 12, 355, 291, 14, 1569, 12, 355, 11573, 68, 297, 2850, 354, 297, 291, 14, 3600, 63, 354, 61, 435, 2780, 63, 5203, 12, 288, 776, 398, 340, 291, 14, 589, 14, 9991, 26, 288, 302, 9207, 63, 1102, 275, 291, 14, 29953, 63, 16590, 1293, 6467, 63, 2339, 267, 916, 3970 ]
[ 46, 13532, 3589, 367, 13150, 2295, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 747, 199, 199, 504, 1275, 492, 334, 272, 8142, 6663, 12, 272, 8142, 8263, 12, 199, 9, 199, 199, 504, 2508, 1974, 492, 334, 272, 2342, 63, 5904, 12, 272, 2929, 12, 199, 9, 199, 199, 504, 2508, 9991, 63, 1974, 492, 334, 272, 12424, 63, 1065, 12, 272, 12424, 63, 5682, 12, 272, 12424, 63, 10955, 12, 272, 12424, 63, 9302, 12, 272, 664, 63, 9991, 63, 3600, 63, 344, 12, 199, 9, 421, 199, 533, 653, 9207, 6663, 8, 9089, 6663, 304, 272, 408, 46, 9207, 3589, 14, 339, 10729, 1536, 653, 13532, 1683, 1654, 367, 2295, 14, 272, 408, 339, 3506, 2504, 540, 63, 16590, 1293, 6467, 63, 2339, 275, 283, 8445, 736, 13, 20125, 7, 339, 3506, 2504, 540, 63, 9438, 275, 283, 392, 1187, 14, 2308, 15, 4853, 15, 8445, 736, 13, 396, 13, 3600, 26, 17, 14, 16, 14, 16, 7, 272, 408, 2698, 1834, 370, 1255, 314, 302, 9207, 15797, 14, 339, 710, 15797, 1471, 506, 10713, 7439, 370, 282, 2488, 1015, 272, 370, 24197, 445, 41, 14933, 543, 314, 1015, 1202, 14, 339, 2779, 1159, 1350, 1350, 6337, 295, 19564, 737, 26, 272, 4178, 921, 5031, 14, 957, 15, 4853, 15, 8445, 736, 13, 396, 13, 3600, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1249, 304, 267, 408, 1084, 1536, 3970, 6941, 367, 5022, 14, 398, 520, 466, 1249, 26, 1379, 2028, 267, 408, 267, 1613, 8, 46, 9207, 6663, 12, 291, 2843, 826, 721, 589, 9, 398, 291, 855, 3600, 63, 504, 63, 1813, 275, 747, 14, 12959, 360, 8490, 63, 46, 2090, 2300, 1469, 63, 31250, 358, 267, 408, 27586, 1347, 3970, 12, 5594, 506, 1202, 367, 16367, 14, 398, 3645, 32271, 7187, 63, 46, 2090, 2300, 1469, 63, 31250, 29, 26517, 63, 13297, 63, 7051, 340, 1265, 2934, 267, 370, 675, 1163, 1834, 14, 593, 1147, 15, 1667, 4257, 14, 267, 408, 398, 291, 14, 1569, 275, 291, 855, 3600, 63, 504, 63, 1813, 503, 291, 14, 29953, 63, 9438, 267, 291, 14, 3600, 63, 354, 275, 2125, 339, 347, 2457, 8, 277, 12, 4545, 12, 5760, 304, 267, 408, 4131, 734, 314, 2295, 543, 314, 5784, 1101, 436, 522, 18735, 14, 398, 520, 466, 4545, 26, 2008, 59, 774, 4277, 61, 267, 520, 466, 5760, 26, 769, 59, 495, 61, 267, 408, 267, 12424, 63, 1760, 275, 283, 9991, 7, 267, 12424, 275, 2342, 63, 5904, 8, 9991, 63, 1760, 12, 1415, 29, 797, 9, 398, 340, 12424, 26, 288, 372, 398, 3372, 275, 283, 4091, 3149, 83, 4805, 450, 291, 14, 3246, 267, 9645, 275, 359, 1375, 14, 354, 367, 1347, 315, 4545, 340, 3372, 315, 1347, 14, 8602, 61, 398, 340, 9645, 26, 288, 5760, 14, 740, 8, 2759, 9, 288, 2929, 14, 3764, 8, 355, 283, 920, 4923, 2295, 11584, 2071, 83, 2, 283, 355, 283, 6777, 4409, 314, 2071, 83, 2, 1414, 26, 450, 83, 7, 355, 450, 334, 2759, 14, 6735, 2336, 659, 12424, 63, 1760, 12, 1656, 1987, 904, 8, 11962, 430, 288, 776, 339, 347, 3272, 8, 277, 304, 267, 408, 8555, 8002, 2073, 2544, 18703, 425, 436, 1295, 9058, 3233, 1041, 267, 1613, 8, 46, 9207, 6663, 12, 291, 680, 2758, 342, 398, 340, 291, 423, 1180, 63, 1986, 63, 888, 837, 288, 291, 423, 2758, 63, 1986, 342, 267, 587, 26, 288, 291, 423, 2758, 63, 7764, 342, 339, 347, 664, 63, 9991, 63, 1065, 63, 1419, 8, 277, 304, 267, 408, 1002, 4722, 1511, 4346, 1380, 18703, 1958, 2295, 370, 282, 3970, 14, 398, 520, 4500, 26, 769, 59, 495, 61, 267, 408, 267, 372, 14574, 1073, 297, 291, 14, 29953, 63, 16590, 1293, 6467, 63, 2339, 61, 340, 291, 14, 11122, 587, 942, 339, 347, 9058, 8, 277, 304, 267, 408, 6580, 1536, 314, 2073, 436, 7937, 11585, 1584, 2410, 2295, 1041, 267, 340, 291, 14, 3600, 63, 354, 26, 288, 12424, 63, 5682, 8, 277, 14, 589, 12, 291, 14, 3600, 63, 354, 9, 398, 1613, 8, 46, 9207, 6663, 12, 291, 680, 7661, 342, 339, 347, 485, 2758, 63, 7764, 8, 277, 304, 267, 408, 12739, 3501, 282, 653, 13532, 15797, 4453, 12424, 3970, 1041, 267, 302, 9207, 63, 719, 275, 23865, 267, 3970, 63, 344, 275, 664, 63, 9991, 63, 3600, 63, 344, 342, 398, 340, 3970, 63, 344, 26, 288, 2929, 14, 815, 8, 355, 283, 9602, 315, 12424, 3970, 26, 450, 83, 7, 450, 3970, 63, 344, 12, 355, 8661, 29, 17, 12, 288, 776, 398, 291, 14, 3600, 63, 354, 275, 291, 14, 29953, 63, 16590, 1293, 6467, 63, 2339, 398, 2058, 275, 12424, 63, 10955, 8, 277, 14, 589, 12, 291, 14, 3600, 63, 354, 9, 398, 340, 2058, 436, 440, 2058, 59, 16, 1055, 362, 360, 2223, 297, 13056, 362, 360, 9602, 735, 288, 12424, 63, 5682, 8, 277, 14, 589, 12, 291, 14, 3600, 63, 354, 9, 288, 2058, 275, 942, 398, 2929, 14, 815, 8, 288, 1543, 83, 653, 13532, 15797, 12424, 3970, 3530, 288, 450, 661, 10369, 314, 3411, 7, 340, 2058, 587, 283, 14139, 282, 892, 659, 288, 8661, 29, 17, 12, 267, 776, 398, 340, 440, 2058, 26, 288, 340, 291, 14, 589, 14, 9991, 503, 3970, 63, 344, 26, 355, 2780, 63, 5203, 275, 942, 288, 587, 26, 355, 327, 2780, 314, 15797, 8873, 1380, 440, 3879, 6272, 12424, 355, 2780, 63, 5203, 275, 359, 490, 2475, 80, 297, 29010, 904, 1332, 495, 8, 8445, 736, 63, 719, 395, 776, 627, 499, 395, 355, 1622, 953, 340, 440, 291, 855, 3600, 63, 504, 63, 1813, 26, 355, 12424, 63, 9302, 8, 277, 14, 589, 12, 291, 14, 1569, 9, 953, 12424, 63, 1065, 8, 355, 291, 14, 589, 12, 355, 291, 14, 1569, 12, 355, 11573, 68, 297, 2850, 354, 297, 291, 14, 3600, 63, 354, 61, 435, 2780, 63, 5203, 12, 288, 776, 398, 340, 291, 14, 589, 14, 9991, 26, 288, 302, 9207, 63, 1102, 275, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
kaplun/Invenio-OpenAIRE
modules/websubmit/lib/functions/Retrieve_Data.py
35
1426
## This file is part of Invenio. ## Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2011 CERN. ## ## Invenio 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. ## ## Invenio 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 Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. __revision__ = "$Id$" ## Description: function Get_Field ## This function returns the value of the specified field ## from the specified document ## Author: T.Baron ## ## PARAMETERS: fieldname: marc21 code ## bibrec: system number of the bibliographic record import string from invenio.search_engine import print_record def Get_Field(fieldname,bibrec): """ This function returns the value of the specified field from the specified document """ value = string.strip(print_record(int(bibrec),'tm',[fieldname])) return value
gpl-2.0
[ 309, 961, 570, 365, 1777, 402, 12235, 14, 199, 309, 1898, 334, 35, 9, 8353, 12, 11811, 12, 8315, 12, 10219, 12, 9079, 12, 7129, 12, 7760, 24354, 14, 199, 309, 199, 309, 12235, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 309, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 309, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 309, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 309, 199, 309, 12235, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 309, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 309, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 309, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 309, 199, 309, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 309, 3180, 543, 12235, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 309, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 363, 5792, 363, 275, 7880, 1304, 17351, 8410, 925, 11994, 26, 257, 805, 2372, 63, 792, 2043, 925, 4483, 961, 805, 2529, 314, 574, 402, 314, 2013, 901, 2043, 925, 3777, 687, 314, 2013, 2213, 2043, 925, 6529, 26, 260, 377, 14, 5281, 265, 2043, 925, 2043, 925, 23710, 26, 259, 18887, 26, 7557, 67, 2025, 1233, 2043, 925, 4483, 11314, 2761, 26, 2656, 1329, 402, 314, 11314, 24623, 2777, 199, 199, 646, 1059, 199, 199, 504, 13640, 14, 1733, 63, 3908, 492, 870, 63, 3059, 199, 199, 318, 2372, 63, 792, 8, 13646, 12, 31547, 304, 272, 408, 272, 961, 805, 2529, 314, 574, 402, 314, 2013, 901, 272, 687, 314, 2013, 2213, 272, 408, 272, 574, 275, 1059, 14, 1913, 8, 1361, 63, 3059, 8, 442, 8, 31547, 26582, 7574, 23993, 13646, 2459, 272, 372, 574, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 961, 570, 365, 1777, 402, 12235, 14, 199, 309, 1898, 334, 35, 9, 8353, 12, 11811, 12, 8315, 12, 10219, 12, 9079, 12, 7129, 12, 7760, 24354, 14, 199, 309, 199, 309, 12235, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 309, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 309, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 309, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 309, 199, 309, 12235, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 309, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 309, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 309, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 309, 199, 309, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 309, 3180, 543, 12235, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 309, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 363, 5792, 363, 275, 7880, 1304, 17351, 8410, 925, 11994, 26, 257, 805, 2372, 63, 792, 2043, 925, 4483, 961, 805, 2529, 314, 574, 402, 314, 2013, 901, 2043, 925, 3777, 687, 314, 2013, 2213, 2043, 925, 6529, 26, 260, 377, 14, 5281, 265, 2043, 925, 2043, 925, 23710, 26, 259, 18887, 26, 7557, 67, 2025, 1233, 2043, 925, 4483, 11314, 2761, 26, 2656, 1329, 402, 314, 11314, 24623, 2777, 199, 199, 646, 1059, 199, 199, 504, 13640, 14, 1733, 63, 3908, 492, 870, 63, 3059, 199, 199, 318, 2372, 63, 792, 8, 13646, 12, 31547, 304, 272, 408, 272, 961, 805, 2529, 314, 574, 402, 314, 2013, 901, 272, 687, 314, 2013, 2213, 272, 408, 272, 574, 275, 1059, 14, 1913, 8, 1361, 63, 3059, 8, 442, 8, 31547, 26582, 7574, 23993, 13646, 2459, 272, 372, 574, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
BizzCloud/PosBox
addons/project_timesheet/__openerp__.py
62
2234
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## { 'name': 'Bill Time on Tasks', 'version': '1.0', 'category': 'Project Management', 'description': """ Synchronization of project task work entries with timesheet entries. ==================================================================== This module lets you transfer the entries under tasks defined for Project Management to the Timesheet line entries for particular date and particular user with the effect of creating, editing and deleting either ways. """, 'author': 'OpenERP SA', 'website': 'http://www.openerp.com', 'images': ['images/invoice_task_work.jpeg', 'images/my_timesheet.jpeg', 'images/working_hour.jpeg'], 'depends': ['resource', 'project', 'hr_timesheet_sheet', 'hr_timesheet_invoice', 'account_analytic_analysis', 'procurement'], 'data': [ 'security/ir.model.access.csv', 'security/project_timesheet_security.xml', 'report/task_report_view.xml', 'project_timesheet_view.xml', ], 'demo': ['project_timesheet_demo.xml'], 'test': [ 'test/worktask_entry_to_timesheetline_entry.yml', 'test/work_timesheet.yml', ], 'installable': True, 'auto_install': True, } # 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, 91, 272, 283, 354, 356, 283, 34, 778, 4703, 641, 8495, 83, 297, 272, 283, 1023, 356, 283, 17, 14, 16, 297, 272, 283, 3710, 356, 283, 4761, 8259, 297, 272, 283, 1802, 356, 408, 199, 21814, 2072, 402, 2199, 2120, 1736, 4811, 543, 900, 5069, 4811, 14, 199, 5695, 532, 199, 199, 2765, 859, 19083, 1265, 9307, 314, 4811, 1334, 6527, 3247, 367, 7290, 199, 14552, 370, 314, 4703, 5069, 1004, 4811, 367, 6770, 1434, 436, 6770, 922, 199, 1045, 314, 7763, 402, 6425, 12, 20401, 436, 13794, 1902, 15217, 14, 272, 10327, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 7360, 356, 283, 1014, 921, 1544, 14, 11267, 14, 957, 297, 272, 283, 4782, 356, 788, 4782, 15, 5404, 63, 1765, 63, 800, 14, 14230, 297, 283, 4782, 15, 1662, 63, 17739, 14, 14230, 297, 283, 4782, 15, 9818, 63, 5180, 14, 14230, 995, 272, 283, 8912, 356, 788, 1927, 297, 283, 1715, 297, 283, 6271, 63, 17739, 63, 5069, 297, 283, 6271, 63, 17739, 63, 5404, 297, 283, 2048, 63, 9782, 63, 10466, 297, 283, 18546, 995, 272, 283, 576, 356, 359, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 4416, 15, 1715, 63, 17739, 63, 4416, 14, 1652, 297, 267, 283, 3070, 15, 1765, 63, 3070, 63, 1345, 14, 1652, 297, 267, 283, 1715, 63, 17739, 63, 1345, 14, 1652, 297, 272, 2156, 272, 283, 8768, 356, 788, 1715, 63, 17739, 63, 8768, 14, 1652, 995, 272, 283, 396, 356, 359, 267, 283, 396, 15, 800, 1765, 63, 2373, 63, 475, 63, 17739, 604, 63, 2373, 14, 11714, 297, 267, 283, 396, 15, 800, 63, 17739, 14, 11714, 297, 272, 2156, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 715, 12, 199, 93, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 91, 272, 283, 354, 356, 283, 34, 778, 4703, 641, 8495, 83, 297, 272, 283, 1023, 356, 283, 17, 14, 16, 297, 272, 283, 3710, 356, 283, 4761, 8259, 297, 272, 283, 1802, 356, 408, 199, 21814, 2072, 402, 2199, 2120, 1736, 4811, 543, 900, 5069, 4811, 14, 199, 5695, 532, 199, 199, 2765, 859, 19083, 1265, 9307, 314, 4811, 1334, 6527, 3247, 367, 7290, 199, 14552, 370, 314, 4703, 5069, 1004, 4811, 367, 6770, 1434, 436, 6770, 922, 199, 1045, 314, 7763, 402, 6425, 12, 20401, 436, 13794, 1902, 15217, 14, 272, 10327, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 7360, 356, 283, 1014, 921, 1544, 14, 11267, 14, 957, 297, 272, 283, 4782, 356, 788, 4782, 15, 5404, 63, 1765, 63, 800, 14, 14230, 297, 283, 4782, 15, 1662, 63, 17739, 14, 14230, 297, 283, 4782, 15, 9818, 63, 5180, 14, 14230, 995, 272, 283, 8912, 356, 788, 1927, 297, 283, 1715, 297, 283, 6271, 63, 17739, 63, 5069, 297, 283, 6271, 63, 17739, 63, 5404, 297, 283, 2048, 63, 9782, 63, 10466, 297, 283, 18546, 995, 272, 283, 576, 356, 359, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 4416, 15, 1715, 63, 17739, 63, 4416, 14, 1652, 297, 267, 283, 3070, 15, 1765, 63, 3070, 63, 1345, 14, 1652, 297, 267, 283, 1715, 63, 17739, 63, 1345, 14, 1652, 297, 272, 2156, 272, 283, 8768, 356, 788, 1715, 63, 17739, 63, 8768, 14, 1652, 995, 272, 283, 396, 356, 359, 267, 283, 396, 15, 800, 1765, 63, 2373, 63, 475, 63, 17739, 604, 63, 2373, 14, 11714, 297, 267, 283, 396, 15, 800, 63, 17739, 14, 11714, 297, 272, 2156, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 715, 12, 199, 93, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
gutomaia/Meta
setup.py
2
1629
# Copyright (c) 2008-2011 by Enthought, Inc. # All rights reserved. from setuptools import setup, find_packages try: long_description = open('README.rst').read() except IOError as err: long_description = str(err) try: version_str = open('version.txt').read() except IOError as err: version_str = '???' setup( name='meta', version=version_str, author='Sean Ross-Ross, Enthought Inc.', author_email='srossross@enthought.com', maintainer='Sean Ross-Ross', maintainer_email='enthought-dev@enthought.com', url='http://srossross.github.com/Meta', classifiers=[c.strip() for c in """\ Development Status :: 5 - Production/Stable Intended Audience :: Developers License :: OSI Approved :: BSD License Operating System :: MacOS Operating System :: Microsoft :: Windows Operating System :: OS Independent Operating System :: POSIX Operating System :: Unix Programming Language :: Python Topic :: Scientific/Engineering Topic :: Software Development Topic :: Software Development :: Libraries """.splitlines() if len(c.strip()) > 0], description='Byte-code and ast programming tools', long_description=long_description, include_package_data=True, license='BSD', packages=find_packages(), platforms=["Windows", "Linux", "Mac OS-X", "Unix", "Solaris"], entry_points={ 'console_scripts': [ 'depyc = meta.scripts.depyc:main', ], } )
bsd-3-clause
[ 3, 1898, 334, 67, 9, 9079, 13, 8128, 701, 3447, 273, 20816, 12, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 199, 504, 9116, 492, 3272, 12, 2342, 63, 5154, 199, 199, 893, 26, 272, 1846, 63, 1802, 275, 1551, 360, 18195, 14, 8332, 1959, 739, 342, 199, 2590, 5925, 465, 2329, 26, 272, 1846, 63, 1802, 275, 620, 8, 1508, 9, 199, 199, 893, 26, 272, 1015, 63, 495, 275, 1551, 360, 1023, 14, 2424, 1959, 739, 342, 199, 2590, 5925, 465, 2329, 26, 272, 1015, 63, 495, 275, 8720, 10674, 7, 421, 199, 2758, 8, 272, 536, 534, 2024, 297, 272, 1015, 29, 1023, 63, 495, 12, 272, 4132, 534, 1513, 290, 6848, 385, 13, 3863, 385, 12, 3447, 273, 20816, 3277, 3130, 272, 4132, 63, 2123, 534, 83, 3685, 3685, 32, 287, 273, 20816, 14, 957, 297, 272, 11075, 281, 534, 1513, 290, 6848, 385, 13, 3863, 385, 297, 272, 11075, 281, 63, 2123, 534, 287, 273, 20816, 13, 2374, 32, 287, 273, 20816, 14, 957, 297, 272, 1166, 534, 1014, 921, 83, 3685, 3685, 14, 5031, 14, 957, 15, 3396, 297, 2286, 19137, 1524, 67, 14, 1913, 342, 367, 286, 315, 9638, 267, 15290, 9795, 3800, 959, 446, 24114, 15, 933, 461, 267, 1010, 6943, 23975, 3800, 23493, 267, 844, 3800, 25718, 26330, 3800, 6289, 844, 267, 6654, 1958, 6187, 3800, 10444, 3100, 267, 6654, 1958, 6187, 3800, 15332, 3800, 5417, 267, 6654, 1958, 6187, 3800, 4403, 1010, 7106, 267, 6654, 1958, 6187, 3800, 18169, 267, 6654, 1958, 6187, 3800, 13074, 267, 2165, 9258, 8466, 3800, 2018, 267, 32166, 3800, 16578, 23509, 15, 8524, 15663, 267, 32166, 3800, 2290, 15290, 267, 32166, 3800, 2290, 15290, 3800, 31454, 267, 30512, 7644, 342, 340, 822, 8, 67, 14, 1913, 1012, 690, 378, 467, 272, 1369, 534, 4861, 13, 600, 436, 6073, 31768, 7249, 297, 272, 1846, 63, 1802, 29, 2809, 63, 1802, 12, 272, 2387, 63, 2491, 63, 576, 29, 549, 12, 272, 4190, 534, 15400, 297, 272, 6117, 29, 1623, 63, 5154, 1062, 272, 10677, 6270, 8647, 401, 298, 14091, 401, 298, 3399, 4403, 13, 56, 401, 298, 21607, 401, 298, 27262, 4663, 2255, 272, 2397, 63, 3438, 3126, 490, 283, 6614, 63, 6429, 356, 359, 3147, 283, 271, 11357, 275, 3404, 14, 6429, 14, 271, 11357, 26, 973, 297, 3147, 2156, 490, 789, 199, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 9079, 13, 8128, 701, 3447, 273, 20816, 12, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 199, 504, 9116, 492, 3272, 12, 2342, 63, 5154, 199, 199, 893, 26, 272, 1846, 63, 1802, 275, 1551, 360, 18195, 14, 8332, 1959, 739, 342, 199, 2590, 5925, 465, 2329, 26, 272, 1846, 63, 1802, 275, 620, 8, 1508, 9, 199, 199, 893, 26, 272, 1015, 63, 495, 275, 1551, 360, 1023, 14, 2424, 1959, 739, 342, 199, 2590, 5925, 465, 2329, 26, 272, 1015, 63, 495, 275, 8720, 10674, 7, 421, 199, 2758, 8, 272, 536, 534, 2024, 297, 272, 1015, 29, 1023, 63, 495, 12, 272, 4132, 534, 1513, 290, 6848, 385, 13, 3863, 385, 12, 3447, 273, 20816, 3277, 3130, 272, 4132, 63, 2123, 534, 83, 3685, 3685, 32, 287, 273, 20816, 14, 957, 297, 272, 11075, 281, 534, 1513, 290, 6848, 385, 13, 3863, 385, 297, 272, 11075, 281, 63, 2123, 534, 287, 273, 20816, 13, 2374, 32, 287, 273, 20816, 14, 957, 297, 272, 1166, 534, 1014, 921, 83, 3685, 3685, 14, 5031, 14, 957, 15, 3396, 297, 2286, 19137, 1524, 67, 14, 1913, 342, 367, 286, 315, 9638, 267, 15290, 9795, 3800, 959, 446, 24114, 15, 933, 461, 267, 1010, 6943, 23975, 3800, 23493, 267, 844, 3800, 25718, 26330, 3800, 6289, 844, 267, 6654, 1958, 6187, 3800, 10444, 3100, 267, 6654, 1958, 6187, 3800, 15332, 3800, 5417, 267, 6654, 1958, 6187, 3800, 4403, 1010, 7106, 267, 6654, 1958, 6187, 3800, 18169, 267, 6654, 1958, 6187, 3800, 13074, 267, 2165, 9258, 8466, 3800, 2018, 267, 32166, 3800, 16578, 23509, 15, 8524, 15663, 267, 32166, 3800, 2290, 15290, 267, 32166, 3800, 2290, 15290, 3800, 31454, 267, 30512, 7644, 342, 340, 822, 8, 67, 14, 1913, 1012, 690, 378, 467, 272, 1369, 534, 4861, 13, 600, 436, 6073, 31768, 7249, 297, 272, 1846, 63, 1802, 29, 2809, 63, 1802, 12, 272, 2387, 63, 2491, 63, 576, 29, 549, 12, 272, 4190, 534, 15400, 297, 272, 6117, 29, 1623, 63, 5154, 1062, 272, 10677, 6270, 8647, 401, 298, 14091, 401, 298, 3399, 4403, 13, 56, 401, 298, 21607, 401, 298, 27262, 4663, 2255, 272, 2397, 63, 3438, 3126, 490, 283, 6614, 63, 6429, 356, 359, 3147, 283, 271, 11357, 275, 3404, 14, 6429, 14, 271, 11357, 26, 973, 297, 3147, 2156, 490, 789, 199, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
kenshay/ImageScripter
ProgramData/SystemFiles/Python/Lib/site-packages/tests/contrib/test_dictionary_storage.py
21
3487
# Copyright 2016 Google Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Unit tests for oauth2client.contrib.dictionary_storage""" import unittest import oauth2client from oauth2client import client from oauth2client.contrib import dictionary_storage def _generate_credentials(scopes=None): return client.OAuth2Credentials( 'access_tokenz', 'client_idz', 'client_secretz', 'refresh_tokenz', '3600', oauth2client.GOOGLE_TOKEN_URI, 'Test', id_token={ 'sub': '123', 'email': 'user@example.com' }, scopes=scopes) class DictionaryStorageTests(unittest.TestCase): def test_constructor_defaults(self): dictionary = {} key = 'test-key' storage = dictionary_storage.DictionaryStorage(dictionary, key) self.assertEqual(dictionary, storage._dictionary) self.assertEqual(key, storage._key) self.assertIsNone(storage._lock) def test_constructor_explicit(self): dictionary = {} key = 'test-key' storage = dictionary_storage.DictionaryStorage(dictionary, key) lock = object() storage = dictionary_storage.DictionaryStorage( dictionary, key, lock=lock) self.assertEqual(storage._lock, lock) def test_get(self): credentials = _generate_credentials() dictionary = {} key = 'credentials' storage = dictionary_storage.DictionaryStorage(dictionary, key) self.assertIsNone(storage.get()) dictionary[key] = credentials.to_json() returned = storage.get() self.assertIsNotNone(returned) self.assertEqual(returned.access_token, credentials.access_token) self.assertEqual(returned.id_token, credentials.id_token) self.assertEqual(returned.refresh_token, credentials.refresh_token) self.assertEqual(returned.client_id, credentials.client_id) def test_put(self): credentials = _generate_credentials() dictionary = {} key = 'credentials' storage = dictionary_storage.DictionaryStorage(dictionary, key) storage.put(credentials) returned = storage.get() self.assertIn(key, dictionary) self.assertIsNotNone(returned) self.assertEqual(returned.access_token, credentials.access_token) self.assertEqual(returned.id_token, credentials.id_token) self.assertEqual(returned.refresh_token, credentials.refresh_token) self.assertEqual(returned.client_id, credentials.client_id) def test_delete(self): credentials = _generate_credentials() dictionary = {} key = 'credentials' storage = dictionary_storage.DictionaryStorage(dictionary, key) storage.put(credentials) self.assertIn(key, dictionary) storage.delete() self.assertNotIn(key, dictionary) self.assertIsNone(storage.get())
gpl-3.0
[ 3, 1898, 7800, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 5072, 2295, 367, 9725, 18, 1258, 14, 2828, 14, 9086, 63, 3494, 624, 199, 199, 646, 2882, 199, 199, 646, 9725, 18, 1258, 199, 504, 9725, 18, 1258, 492, 1890, 199, 504, 9725, 18, 1258, 14, 2828, 492, 2600, 63, 3494, 421, 199, 318, 485, 4208, 63, 6942, 8, 14129, 29, 403, 304, 272, 372, 1890, 14, 12906, 18, 13428, 8, 267, 283, 2732, 63, 1418, 90, 297, 267, 283, 1258, 63, 344, 90, 297, 267, 283, 1258, 63, 4731, 90, 297, 267, 283, 6635, 63, 1418, 90, 297, 267, 283, 11035, 297, 267, 9725, 18, 1258, 14, 24243, 63, 8803, 63, 7639, 12, 267, 283, 774, 297, 267, 1305, 63, 1418, 3126, 288, 283, 954, 356, 283, 4288, 297, 288, 283, 2123, 356, 283, 751, 32, 2694, 14, 957, 7, 267, 1660, 267, 14570, 29, 14129, 9, 421, 199, 533, 11932, 6408, 2925, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 1880, 63, 4322, 8, 277, 304, 267, 2600, 275, 1052, 267, 790, 275, 283, 396, 13, 498, 7, 267, 4887, 275, 2600, 63, 3494, 14, 11728, 6408, 8, 9086, 12, 790, 9, 398, 291, 14, 629, 8, 9086, 12, 4887, 423, 9086, 9, 267, 291, 14, 629, 8, 498, 12, 4887, 423, 498, 9, 267, 291, 14, 7702, 8, 3494, 423, 831, 9, 339, 347, 511, 63, 1880, 63, 10306, 8, 277, 304, 267, 2600, 275, 1052, 267, 790, 275, 283, 396, 13, 498, 7, 267, 4887, 275, 2600, 63, 3494, 14, 11728, 6408, 8, 9086, 12, 790, 9, 398, 4650, 275, 909, 342, 267, 4887, 275, 2600, 63, 3494, 14, 11728, 6408, 8, 288, 2600, 12, 790, 12, 4650, 29, 831, 9, 267, 291, 14, 629, 8, 3494, 423, 831, 12, 4650, 9, 339, 347, 511, 63, 362, 8, 277, 304, 267, 6235, 275, 485, 4208, 63, 6942, 342, 267, 2600, 275, 1052, 267, 790, 275, 283, 6942, 7, 267, 4887, 275, 2600, 63, 3494, 14, 11728, 6408, 8, 9086, 12, 790, 9, 398, 291, 14, 7702, 8, 3494, 14, 362, 1012, 398, 2600, 59, 498, 61, 275, 6235, 14, 475, 63, 1001, 342, 267, 2138, 275, 4887, 14, 362, 342, 398, 291, 14, 10389, 8, 19065, 9, 267, 291, 14, 629, 8, 19065, 14, 2732, 63, 1418, 12, 6235, 14, 2732, 63, 1418, 9, 267, 291, 14, 629, 8, 19065, 14, 344, 63, 1418, 12, 6235, 14, 344, 63, 1418, 9, 267, 291, 14, 629, 8, 19065, 14, 6635, 63, 1418, 12, 6235, 14, 6635, 63, 1418, 9, 267, 291, 14, 629, 8, 19065, 14, 1258, 63, 344, 12, 6235, 14, 1258, 63, 344, 9, 339, 347, 511, 63, 524, 8, 277, 304, 267, 6235, 275, 485, 4208, 63, 6942, 342, 267, 2600, 275, 1052, 267, 790, 275, 283, 6942, 7, 267, 4887, 275, 2600, 63, 3494, 14, 11728, 6408, 8, 9086, 12, 790, 9, 398, 4887, 14, 524, 8, 6942, 9, 267, 2138, 275, 4887, 14, 362, 342, 398, 291, 14, 4080, 8, 498, 12, 2600, 9, 267, 291, 14, 10389, 8, 19065, 9, 267, 291, 14, 629, 8, 19065, 14, 2732, 63, 1418, 12, 6235, 14, 2732, 63, 1418, 9, 267, 291, 14, 629, 8, 19065, 14, 344, 63, 1418, 12, 6235, 14, 344, 63, 1418, 9, 267, 291, 14, 629, 8, 19065, 14, 6635, 63, 1418, 12, 6235, 14, 6635, 63, 1418, 9, 267, 291, 14, 629, 8, 19065, 14, 1258, 63, 344, 12, 6235, 14, 1258, 63, 344, 9, 339, 347, 511, 63, 1807, 8, 277, 304, 267, 6235, 275, 485, 4208, 63, 6942, 342, 267, 2600, 275, 1052, 267, 790, 275, 283, 6942, 7, 267, 4887, 275, 2600, 63, 3494, 14, 11728, 6408, 8, 9086, 12, 790, 9, 398, 4887, 14, 524, 8, 6942, 9, 398, 291, 14, 4080, 8, 498, 12, 2600, 9, 398, 4887, 14, 1807, 342, 398, 291, 14, 8795, 8, 498, 12, 2600, 9, 267, 291, 14, 7702, 8, 3494, 14, 362, 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 ]
[ 1898, 7800, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 5072, 2295, 367, 9725, 18, 1258, 14, 2828, 14, 9086, 63, 3494, 624, 199, 199, 646, 2882, 199, 199, 646, 9725, 18, 1258, 199, 504, 9725, 18, 1258, 492, 1890, 199, 504, 9725, 18, 1258, 14, 2828, 492, 2600, 63, 3494, 421, 199, 318, 485, 4208, 63, 6942, 8, 14129, 29, 403, 304, 272, 372, 1890, 14, 12906, 18, 13428, 8, 267, 283, 2732, 63, 1418, 90, 297, 267, 283, 1258, 63, 344, 90, 297, 267, 283, 1258, 63, 4731, 90, 297, 267, 283, 6635, 63, 1418, 90, 297, 267, 283, 11035, 297, 267, 9725, 18, 1258, 14, 24243, 63, 8803, 63, 7639, 12, 267, 283, 774, 297, 267, 1305, 63, 1418, 3126, 288, 283, 954, 356, 283, 4288, 297, 288, 283, 2123, 356, 283, 751, 32, 2694, 14, 957, 7, 267, 1660, 267, 14570, 29, 14129, 9, 421, 199, 533, 11932, 6408, 2925, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 1880, 63, 4322, 8, 277, 304, 267, 2600, 275, 1052, 267, 790, 275, 283, 396, 13, 498, 7, 267, 4887, 275, 2600, 63, 3494, 14, 11728, 6408, 8, 9086, 12, 790, 9, 398, 291, 14, 629, 8, 9086, 12, 4887, 423, 9086, 9, 267, 291, 14, 629, 8, 498, 12, 4887, 423, 498, 9, 267, 291, 14, 7702, 8, 3494, 423, 831, 9, 339, 347, 511, 63, 1880, 63, 10306, 8, 277, 304, 267, 2600, 275, 1052, 267, 790, 275, 283, 396, 13, 498, 7, 267, 4887, 275, 2600, 63, 3494, 14, 11728, 6408, 8, 9086, 12, 790, 9, 398, 4650, 275, 909, 342, 267, 4887, 275, 2600, 63, 3494, 14, 11728, 6408, 8, 288, 2600, 12, 790, 12, 4650, 29, 831, 9, 267, 291, 14, 629, 8, 3494, 423, 831, 12, 4650, 9, 339, 347, 511, 63, 362, 8, 277, 304, 267, 6235, 275, 485, 4208, 63, 6942, 342, 267, 2600, 275, 1052, 267, 790, 275, 283, 6942, 7, 267, 4887, 275, 2600, 63, 3494, 14, 11728, 6408, 8, 9086, 12, 790, 9, 398, 291, 14, 7702, 8, 3494, 14, 362, 1012, 398, 2600, 59, 498, 61, 275, 6235, 14, 475, 63, 1001, 342, 267, 2138, 275, 4887, 14, 362, 342, 398, 291, 14, 10389, 8, 19065, 9, 267, 291, 14, 629, 8, 19065, 14, 2732, 63, 1418, 12, 6235, 14, 2732, 63, 1418, 9, 267, 291, 14, 629, 8, 19065, 14, 344, 63, 1418, 12, 6235, 14, 344, 63, 1418, 9, 267, 291, 14, 629, 8, 19065, 14, 6635, 63, 1418, 12, 6235, 14, 6635, 63, 1418, 9, 267, 291, 14, 629, 8, 19065, 14, 1258, 63, 344, 12, 6235, 14, 1258, 63, 344, 9, 339, 347, 511, 63, 524, 8, 277, 304, 267, 6235, 275, 485, 4208, 63, 6942, 342, 267, 2600, 275, 1052, 267, 790, 275, 283, 6942, 7, 267, 4887, 275, 2600, 63, 3494, 14, 11728, 6408, 8, 9086, 12, 790, 9, 398, 4887, 14, 524, 8, 6942, 9, 267, 2138, 275, 4887, 14, 362, 342, 398, 291, 14, 4080, 8, 498, 12, 2600, 9, 267, 291, 14, 10389, 8, 19065, 9, 267, 291, 14, 629, 8, 19065, 14, 2732, 63, 1418, 12, 6235, 14, 2732, 63, 1418, 9, 267, 291, 14, 629, 8, 19065, 14, 344, 63, 1418, 12, 6235, 14, 344, 63, 1418, 9, 267, 291, 14, 629, 8, 19065, 14, 6635, 63, 1418, 12, 6235, 14, 6635, 63, 1418, 9, 267, 291, 14, 629, 8, 19065, 14, 1258, 63, 344, 12, 6235, 14, 1258, 63, 344, 9, 339, 347, 511, 63, 1807, 8, 277, 304, 267, 6235, 275, 485, 4208, 63, 6942, 342, 267, 2600, 275, 1052, 267, 790, 275, 283, 6942, 7, 267, 4887, 275, 2600, 63, 3494, 14, 11728, 6408, 8, 9086, 12, 790, 9, 398, 4887, 14, 524, 8, 6942, 9, 398, 291, 14, 4080, 8, 498, 12, 2600, 9, 398, 4887, 14, 1807, 342, 398, 291, 14, 8795, 8, 498, 12, 2600, 9, 267, 291, 14, 7702, 8, 3494, 14, 362, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
goulu/networkx
networkx/algorithms/tree/tests/test_recognition.py
10
4069
from nose.tools import * import networkx as nx class TestTreeRecognition(object): graph = nx.Graph multigraph = nx.MultiGraph def setUp(self): self.T1 = self.graph() self.T2 = self.graph() self.T2.add_node(1) self.T3 = self.graph() self.T3.add_nodes_from(range(5)) edges = [(i,i+1) for i in range(4)] self.T3.add_edges_from(edges) self.T5 = self.multigraph() self.T5.add_nodes_from(range(5)) edges = [(i,i+1) for i in range(4)] self.T5.add_edges_from(edges) self.T6 = self.graph() self.T6.add_nodes_from([6,7]) self.T6.add_edge(6,7) self.F1 = nx.compose(self.T6, self.T3) self.N4 = self.graph() self.N4.add_node(1) self.N4.add_edge(1,1) self.N5 = self.graph() self.N5.add_nodes_from(range(5)) self.N6 = self.graph() self.N6.add_nodes_from(range(3)) self.N6.add_edges_from([(0,1),(1,2),(2,0)]) self.NF1 = nx.compose(self.T6,self.N6) @raises(nx.NetworkXPointlessConcept) def test_null_tree(self): nx.is_tree(self.graph()) nx.is_tree(self.multigraph()) @raises(nx.NetworkXPointlessConcept) def test_null_forest(self): nx.is_forest(self.graph()) nx.is_forest(self.multigraph()) def test_is_tree(self): assert_true(nx.is_tree(self.T2)) assert_true(nx.is_tree(self.T3)) assert_true(nx.is_tree(self.T5)) def test_is_not_tree(self): assert_false(nx.is_tree(self.N4)) assert_false(nx.is_tree(self.N5)) assert_false(nx.is_tree(self.N6)) def test_is_forest(self): assert_true(nx.is_forest(self.T2)) assert_true(nx.is_forest(self.T3)) assert_true(nx.is_forest(self.T5)) assert_true(nx.is_forest(self.F1)) assert_true(nx.is_forest(self.N5)) def test_is_not_forest(self): assert_false(nx.is_forest(self.N4)) assert_false(nx.is_forest(self.N6)) assert_false(nx.is_forest(self.NF1)) class TestDirectedTreeRecognition(TestTreeRecognition): graph = nx.DiGraph multigraph = nx.MultiDiGraph def test_disconnected_graph(): # https://github.com/networkx/networkx/issues/1144 G = nx.Graph() G.add_edges_from([(0, 1), (1, 2), (2, 0), (3, 4)]) assert_false(nx.is_tree(G)) G = nx.DiGraph() G.add_edges_from([(0, 1), (1, 2), (2, 0), (3, 4)]) assert_false(nx.is_tree(G)) def test_dag_nontree(): G = nx.DiGraph() G.add_edges_from([(0,1), (0,2), (1,2)]) assert_false(nx.is_tree(G)) assert_true(nx.is_directed_acyclic_graph(G)) def test_multicycle(): G = nx.MultiDiGraph() G.add_edges_from([(0,1), (0,1)]) assert_false(nx.is_tree(G)) assert_true(nx.is_directed_acyclic_graph(G)) def test_emptybranch(): G = nx.DiGraph() G.add_nodes_from(range(10)) assert_true(nx.is_branching(G)) assert_false(nx.is_arborescence(G)) def test_path(): G = nx.DiGraph() nx.add_path(G, range(5)) assert_true(nx.is_branching(G)) assert_true(nx.is_arborescence(G)) def test_notbranching1(): # Acyclic violation. G = nx.MultiDiGraph() G.add_nodes_from(range(10)) G.add_edges_from([(0,1),(1,0)]) assert_false(nx.is_branching(G)) assert_false(nx.is_arborescence(G)) def test_notbranching2(): # In-degree violation. G = nx.MultiDiGraph() G.add_nodes_from(range(10)) G.add_edges_from([(0,1),(0,2),(3,2)]) assert_false(nx.is_branching(G)) assert_false(nx.is_arborescence(G)) def test_notarborescence1(): # Not an arborescence due to not spanning. G = nx.MultiDiGraph() G.add_nodes_from(range(10)) G.add_edges_from([(0,1),(0,2),(1,3),(5,6)]) assert_true(nx.is_branching(G)) assert_false(nx.is_arborescence(G)) def test_notarborescence2(): # Not an arborescence due to in-degree violation. G = nx.MultiDiGraph() nx.add_path(G, range(5)) G.add_edge(6, 4) assert_false(nx.is_branching(G)) assert_false(nx.is_arborescence(G))
bsd-3-clause
[ 199, 504, 11354, 14, 2537, 492, 627, 199, 646, 24313, 465, 8484, 421, 199, 533, 1379, 3987, 497, 6862, 15415, 8, 785, 304, 339, 3343, 275, 8484, 14, 4578, 272, 3510, 2180, 275, 8484, 14, 3947, 4578, 339, 347, 3613, 8, 277, 304, 398, 291, 14, 52, 17, 275, 291, 14, 2180, 342, 398, 291, 14, 52, 18, 275, 291, 14, 2180, 342, 267, 291, 14, 52, 18, 14, 525, 63, 932, 8, 17, 9, 398, 291, 14, 52, 19, 275, 291, 14, 2180, 342, 267, 291, 14, 52, 19, 14, 525, 63, 2415, 63, 504, 8, 1842, 8, 21, 430, 267, 8207, 275, 3842, 73, 12, 73, 11, 17, 9, 367, 284, 315, 1425, 8, 20, 1874, 267, 291, 14, 52, 19, 14, 525, 63, 6929, 63, 504, 8, 6929, 9, 398, 291, 14, 52, 21, 275, 291, 14, 3029, 2180, 342, 267, 291, 14, 52, 21, 14, 525, 63, 2415, 63, 504, 8, 1842, 8, 21, 430, 267, 8207, 275, 3842, 73, 12, 73, 11, 17, 9, 367, 284, 315, 1425, 8, 20, 1874, 267, 291, 14, 52, 21, 14, 525, 63, 6929, 63, 504, 8, 6929, 9, 398, 291, 14, 52, 22, 275, 291, 14, 2180, 342, 267, 291, 14, 52, 22, 14, 525, 63, 2415, 63, 504, 779, 22, 12, 23, 566, 267, 291, 14, 52, 22, 14, 525, 63, 5173, 8, 22, 12, 23, 9, 398, 291, 14, 38, 17, 275, 8484, 14, 12607, 8, 277, 14, 52, 22, 12, 291, 14, 52, 19, 9, 398, 291, 14, 46, 20, 275, 291, 14, 2180, 342, 267, 291, 14, 46, 20, 14, 525, 63, 932, 8, 17, 9, 267, 291, 14, 46, 20, 14, 525, 63, 5173, 8, 17, 12, 17, 9, 398, 291, 14, 46, 21, 275, 291, 14, 2180, 342, 267, 291, 14, 46, 21, 14, 525, 63, 2415, 63, 504, 8, 1842, 8, 21, 430, 398, 291, 14, 46, 22, 275, 291, 14, 2180, 342, 267, 291, 14, 46, 22, 14, 525, 63, 2415, 63, 504, 8, 1842, 8, 19, 430, 267, 291, 14, 46, 22, 14, 525, 63, 6929, 63, 504, 7694, 16, 12, 17, 11865, 17, 12, 18, 11865, 18, 12, 16, 3948, 398, 291, 14, 19749, 17, 275, 8484, 14, 12607, 8, 277, 14, 52, 22, 12, 277, 14, 46, 22, 9, 339, 768, 3536, 8, 7343, 14, 4491, 56, 3428, 2003, 32209, 9, 272, 347, 511, 63, 2307, 63, 2350, 8, 277, 304, 267, 8484, 14, 374, 63, 2350, 8, 277, 14, 2180, 1012, 267, 8484, 14, 374, 63, 2350, 8, 277, 14, 3029, 2180, 1012, 339, 768, 3536, 8, 7343, 14, 4491, 56, 3428, 2003, 32209, 9, 272, 347, 511, 63, 2307, 63, 25736, 8, 277, 304, 267, 8484, 14, 374, 63, 25736, 8, 277, 14, 2180, 1012, 267, 8484, 14, 374, 63, 25736, 8, 277, 14, 3029, 2180, 1012, 339, 347, 511, 63, 374, 63, 2350, 8, 277, 304, 267, 702, 63, 2052, 8, 7343, 14, 374, 63, 2350, 8, 277, 14, 52, 18, 430, 267, 702, 63, 2052, 8, 7343, 14, 374, 63, 2350, 8, 277, 14, 52, 19, 430, 267, 702, 63, 2052, 8, 7343, 14, 374, 63, 2350, 8, 277, 14, 52, 21, 430, 339, 347, 511, 63, 374, 63, 1397, 63, 2350, 8, 277, 304, 267, 702, 63, 3910, 8, 7343, 14, 374, 63, 2350, 8, 277, 14, 46, 20, 430, 267, 702, 63, 3910, 8, 7343, 14, 374, 63, 2350, 8, 277, 14, 46, 21, 430, 267, 702, 63, 3910, 8, 7343, 14, 374, 63, 2350, 8, 277, 14, 46, 22, 430, 339, 347, 511, 63, 374, 63, 25736, 8, 277, 304, 267, 702, 63, 2052, 8, 7343, 14, 374, 63, 25736, 8, 277, 14, 52, 18, 430, 267, 702, 63, 2052, 8, 7343, 14, 374, 63, 25736, 8, 277, 14, 52, 19, 430, 267, 702, 63, 2052, 8, 7343, 14, 374, 63, 25736, 8, 277, 14, 52, 21, 430, 267, 702, 63, 2052, 8, 7343, 14, 374, 63, 25736, 8, 277, 14, 38, 17, 430, 267, 702, 63, 2052, 8, 7343, 14, 374, 63, 25736, 8, 277, 14, 46, 21, 430, 339, 347, 511, 63, 374, 63, 1397, 63, 25736, 8, 277, 304, 267, 702, 63, 3910, 8, 7343, 14, 374, 63, 25736, 8, 277, 14, 46, 20, 430, 267, 702, 63, 3910, 8, 7343, 14, 374, 63, 25736, 8, 277, 14, 46, 22, 430, 267, 702, 63, 3910, 8, 7343, 14, 374, 63, 25736, 8, 277, 14, 19749, 17, 430, 199, 199, 533, 1379, 1341, 7983, 3987, 497, 6862, 15415, 8, 774, 3987, 497, 6862, 15415, 304, 272, 3343, 275, 8484, 14, 23208, 272, 3510, 2180, 275, 8484, 14, 3947, 23208, 199, 199, 318, 511, 63, 27476, 63, 2180, 837, 272, 327, 4178, 921, 5031, 14, 957, 15, 1200, 88, 15, 1200, 88, 15, 10115, 15, 845, 1602, 272, 598, 275, 8484, 14, 4578, 342, 272, 598, 14, 525, 63, 6929, 63, 504, 7694, 16, 12, 413, 395, 334, 17, 12, 499, 395, 334, 18, 12, 378, 395, 334, 19, 12, 841, 3948, 272, 702, 63, 3910, 8, 7343, 14, 374, 63, 2350, 8, 39, 430, 339, 598, 275, 8484, 14, 23208, 342, 272, 598, 14, 525, 63, 6929, 63, 504, 7694, 16, 12, 413, 395, 334, 17, 12, 499, 395, 334, 18, 12, 378, 395, 334, 19, 12, 841, 3948, 272, 702, 63, 3910, 8, 7343, 14, 374, 63, 2350, 8, 39, 430, 199, 199, 318, 511, 63, 7406, 63, 78, 1888, 850, 837, 272, 598, 275, 8484, 14, 23208, 342, 272, 598, 14, 525, 63, 6929, 63, 504, 7694, 16, 12, 17, 395, 334, 16, 12, 18, 395, 334, 17, 12, 18, 3948, 272, 702, 63, 3910, 8, 7343, 14, 374, 63, 2350, 8, 39, 430, 272, 702, 63, 2052, 8, 7343, 14, 374, 63, 12080, 63, 4085, 17542, 63, 2180, 8, 39, 430, 199, 199, 318, 511, 63, 3703, 764, 89, 2265, 837, 272, 598, 275, 8484, 14, 3947, 23208, 342, 272, 598, 14, 525, 63, 6929, 63, 504, 7694, 16, 12, 17, 395, 334, 16, 12, 17, 3948, 272, 702, 63, 3910, 8, 7343, 14, 374, 63, 2350, 8, 39, 430, 272, 702, 63, 2052, 8, 7343, 14, 374, 63 ]
[ 504, 11354, 14, 2537, 492, 627, 199, 646, 24313, 465, 8484, 421, 199, 533, 1379, 3987, 497, 6862, 15415, 8, 785, 304, 339, 3343, 275, 8484, 14, 4578, 272, 3510, 2180, 275, 8484, 14, 3947, 4578, 339, 347, 3613, 8, 277, 304, 398, 291, 14, 52, 17, 275, 291, 14, 2180, 342, 398, 291, 14, 52, 18, 275, 291, 14, 2180, 342, 267, 291, 14, 52, 18, 14, 525, 63, 932, 8, 17, 9, 398, 291, 14, 52, 19, 275, 291, 14, 2180, 342, 267, 291, 14, 52, 19, 14, 525, 63, 2415, 63, 504, 8, 1842, 8, 21, 430, 267, 8207, 275, 3842, 73, 12, 73, 11, 17, 9, 367, 284, 315, 1425, 8, 20, 1874, 267, 291, 14, 52, 19, 14, 525, 63, 6929, 63, 504, 8, 6929, 9, 398, 291, 14, 52, 21, 275, 291, 14, 3029, 2180, 342, 267, 291, 14, 52, 21, 14, 525, 63, 2415, 63, 504, 8, 1842, 8, 21, 430, 267, 8207, 275, 3842, 73, 12, 73, 11, 17, 9, 367, 284, 315, 1425, 8, 20, 1874, 267, 291, 14, 52, 21, 14, 525, 63, 6929, 63, 504, 8, 6929, 9, 398, 291, 14, 52, 22, 275, 291, 14, 2180, 342, 267, 291, 14, 52, 22, 14, 525, 63, 2415, 63, 504, 779, 22, 12, 23, 566, 267, 291, 14, 52, 22, 14, 525, 63, 5173, 8, 22, 12, 23, 9, 398, 291, 14, 38, 17, 275, 8484, 14, 12607, 8, 277, 14, 52, 22, 12, 291, 14, 52, 19, 9, 398, 291, 14, 46, 20, 275, 291, 14, 2180, 342, 267, 291, 14, 46, 20, 14, 525, 63, 932, 8, 17, 9, 267, 291, 14, 46, 20, 14, 525, 63, 5173, 8, 17, 12, 17, 9, 398, 291, 14, 46, 21, 275, 291, 14, 2180, 342, 267, 291, 14, 46, 21, 14, 525, 63, 2415, 63, 504, 8, 1842, 8, 21, 430, 398, 291, 14, 46, 22, 275, 291, 14, 2180, 342, 267, 291, 14, 46, 22, 14, 525, 63, 2415, 63, 504, 8, 1842, 8, 19, 430, 267, 291, 14, 46, 22, 14, 525, 63, 6929, 63, 504, 7694, 16, 12, 17, 11865, 17, 12, 18, 11865, 18, 12, 16, 3948, 398, 291, 14, 19749, 17, 275, 8484, 14, 12607, 8, 277, 14, 52, 22, 12, 277, 14, 46, 22, 9, 339, 768, 3536, 8, 7343, 14, 4491, 56, 3428, 2003, 32209, 9, 272, 347, 511, 63, 2307, 63, 2350, 8, 277, 304, 267, 8484, 14, 374, 63, 2350, 8, 277, 14, 2180, 1012, 267, 8484, 14, 374, 63, 2350, 8, 277, 14, 3029, 2180, 1012, 339, 768, 3536, 8, 7343, 14, 4491, 56, 3428, 2003, 32209, 9, 272, 347, 511, 63, 2307, 63, 25736, 8, 277, 304, 267, 8484, 14, 374, 63, 25736, 8, 277, 14, 2180, 1012, 267, 8484, 14, 374, 63, 25736, 8, 277, 14, 3029, 2180, 1012, 339, 347, 511, 63, 374, 63, 2350, 8, 277, 304, 267, 702, 63, 2052, 8, 7343, 14, 374, 63, 2350, 8, 277, 14, 52, 18, 430, 267, 702, 63, 2052, 8, 7343, 14, 374, 63, 2350, 8, 277, 14, 52, 19, 430, 267, 702, 63, 2052, 8, 7343, 14, 374, 63, 2350, 8, 277, 14, 52, 21, 430, 339, 347, 511, 63, 374, 63, 1397, 63, 2350, 8, 277, 304, 267, 702, 63, 3910, 8, 7343, 14, 374, 63, 2350, 8, 277, 14, 46, 20, 430, 267, 702, 63, 3910, 8, 7343, 14, 374, 63, 2350, 8, 277, 14, 46, 21, 430, 267, 702, 63, 3910, 8, 7343, 14, 374, 63, 2350, 8, 277, 14, 46, 22, 430, 339, 347, 511, 63, 374, 63, 25736, 8, 277, 304, 267, 702, 63, 2052, 8, 7343, 14, 374, 63, 25736, 8, 277, 14, 52, 18, 430, 267, 702, 63, 2052, 8, 7343, 14, 374, 63, 25736, 8, 277, 14, 52, 19, 430, 267, 702, 63, 2052, 8, 7343, 14, 374, 63, 25736, 8, 277, 14, 52, 21, 430, 267, 702, 63, 2052, 8, 7343, 14, 374, 63, 25736, 8, 277, 14, 38, 17, 430, 267, 702, 63, 2052, 8, 7343, 14, 374, 63, 25736, 8, 277, 14, 46, 21, 430, 339, 347, 511, 63, 374, 63, 1397, 63, 25736, 8, 277, 304, 267, 702, 63, 3910, 8, 7343, 14, 374, 63, 25736, 8, 277, 14, 46, 20, 430, 267, 702, 63, 3910, 8, 7343, 14, 374, 63, 25736, 8, 277, 14, 46, 22, 430, 267, 702, 63, 3910, 8, 7343, 14, 374, 63, 25736, 8, 277, 14, 19749, 17, 430, 199, 199, 533, 1379, 1341, 7983, 3987, 497, 6862, 15415, 8, 774, 3987, 497, 6862, 15415, 304, 272, 3343, 275, 8484, 14, 23208, 272, 3510, 2180, 275, 8484, 14, 3947, 23208, 199, 199, 318, 511, 63, 27476, 63, 2180, 837, 272, 327, 4178, 921, 5031, 14, 957, 15, 1200, 88, 15, 1200, 88, 15, 10115, 15, 845, 1602, 272, 598, 275, 8484, 14, 4578, 342, 272, 598, 14, 525, 63, 6929, 63, 504, 7694, 16, 12, 413, 395, 334, 17, 12, 499, 395, 334, 18, 12, 378, 395, 334, 19, 12, 841, 3948, 272, 702, 63, 3910, 8, 7343, 14, 374, 63, 2350, 8, 39, 430, 339, 598, 275, 8484, 14, 23208, 342, 272, 598, 14, 525, 63, 6929, 63, 504, 7694, 16, 12, 413, 395, 334, 17, 12, 499, 395, 334, 18, 12, 378, 395, 334, 19, 12, 841, 3948, 272, 702, 63, 3910, 8, 7343, 14, 374, 63, 2350, 8, 39, 430, 199, 199, 318, 511, 63, 7406, 63, 78, 1888, 850, 837, 272, 598, 275, 8484, 14, 23208, 342, 272, 598, 14, 525, 63, 6929, 63, 504, 7694, 16, 12, 17, 395, 334, 16, 12, 18, 395, 334, 17, 12, 18, 3948, 272, 702, 63, 3910, 8, 7343, 14, 374, 63, 2350, 8, 39, 430, 272, 702, 63, 2052, 8, 7343, 14, 374, 63, 12080, 63, 4085, 17542, 63, 2180, 8, 39, 430, 199, 199, 318, 511, 63, 3703, 764, 89, 2265, 837, 272, 598, 275, 8484, 14, 3947, 23208, 342, 272, 598, 14, 525, 63, 6929, 63, 504, 7694, 16, 12, 17, 395, 334, 16, 12, 17, 3948, 272, 702, 63, 3910, 8, 7343, 14, 374, 63, 2350, 8, 39, 430, 272, 702, 63, 2052, 8, 7343, 14, 374, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """This file is deprecated. Use tensorflow.python.training.session_run_hook.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.python.training import session_run_hook # pylint: disable=invalid-name SessionRunHook = session_run_hook.SessionRunHook SessionRunArgs = session_run_hook.SessionRunArgs SessionRunContext = session_run_hook.SessionRunContext SessionRunValues = session_run_hook.SessionRunValues # pylint: enable=invalid-name
mit
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2765, 570, 365, 5906, 14, 3645, 3228, 14, 1548, 14, 7588, 14, 1730, 63, 1065, 63, 3664, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 1548, 14, 7588, 492, 2351, 63, 1065, 63, 3664, 199, 199, 3, 4287, 26, 3507, 29, 3197, 13, 354, 199, 4434, 2540, 8481, 275, 2351, 63, 1065, 63, 3664, 14, 4434, 2540, 8481, 199, 4434, 2540, 6213, 275, 2351, 63, 1065, 63, 3664, 14, 4434, 2540, 6213, 199, 4434, 2540, 2998, 275, 2351, 63, 1065, 63, 3664, 14, 4434, 2540, 2998, 199, 4434, 2540, 6550, 275, 2351, 63, 1065, 63, 3664, 14, 4434, 2540, 6550, 199, 3, 4287, 26, 4756, 29, 3197, 13, 354, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 2765, 570, 365, 5906, 14, 3645, 3228, 14, 1548, 14, 7588, 14, 1730, 63, 1065, 63, 3664, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 1548, 14, 7588, 492, 2351, 63, 1065, 63, 3664, 199, 199, 3, 4287, 26, 3507, 29, 3197, 13, 354, 199, 4434, 2540, 8481, 275, 2351, 63, 1065, 63, 3664, 14, 4434, 2540, 8481, 199, 4434, 2540, 6213, 275, 2351, 63, 1065, 63, 3664, 14, 4434, 2540, 6213, 199, 4434, 2540, 2998, 275, 2351, 63, 1065, 63, 3664, 14, 4434, 2540, 2998, 199, 4434, 2540, 6550, 275, 2351, 63, 1065, 63, 3664, 14, 4434, 2540, 6550, 199, 3, 4287, 26, 4756, 29, 3197, 13, 354, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
Eureka22/ASM_xf
PythonD/lib/python2.4/encodings/zlib_codec.py
16
1793
""" Python 'zlib_codec' Codec - zlib compression encoding Unlike most of the other codecs which target Unicode, this codec will return Python string objects for both encode and decode. 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'): """ Encodes the object input and returns a tuple (output object, length consumed). errors defines the error handling to apply. It defaults to 'strict' handling which is the only currently supported error handling for this codec. """ assert errors == 'strict' output = zlib.compress(input) return (output, len(input)) def zlib_decode(input,errors='strict'): """ Decodes the object input and returns a tuple (output object, length consumed). input must be an object which provides the bf_getreadbuf buffer slot. Python strings, buffer objects and memory mapped files are examples of objects providing this slot. errors defines the error handling to apply. It defaults to 'strict' handling which is the only currently supported error handling for this codec. """ assert errors == 'strict' output = zlib.decompress(input) return (output, 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 StreamWriter(Codec,codecs.StreamWriter): pass class StreamReader(Codec,codecs.StreamReader): pass ### encodings module API def getregentry(): return (zlib_encode,zlib_decode,StreamReader,StreamWriter)
gpl-2.0
[ 624, 2018, 283, 15371, 63, 9276, 7, 13732, 446, 12472, 10291, 2644, 339, 25059, 4750, 402, 314, 1163, 6010, 1314, 1347, 6140, 12, 642, 9076, 272, 911, 372, 2018, 1059, 2251, 367, 3865, 3752, 436, 4849, 14, 339, 27694, 701, 603, 9912, 13, 3325, 264, 7005, 32649, 334, 2174, 32, 274, 32649, 14, 957, 680, 199, 199, 624, 199, 646, 6010, 199, 646, 12472, 327, 642, 9076, 4839, 314, 2716, 12472, 859, 8546, 199, 199, 5680, 13732, 15913, 199, 199, 318, 12472, 63, 2143, 8, 1210, 12, 2550, 534, 4768, 735, 339, 408, 3447, 6021, 314, 909, 1324, 436, 2529, 282, 2008, 334, 1199, 267, 909, 12, 2582, 16949, 680, 398, 2552, 7890, 314, 1125, 7252, 370, 4838, 14, 2779, 4243, 370, 267, 283, 4768, 7, 7252, 1314, 365, 314, 1454, 5544, 3748, 267, 1125, 7252, 367, 642, 9076, 14, 339, 408, 272, 702, 2552, 508, 283, 4768, 7, 272, 1072, 275, 12472, 14, 6447, 8, 1210, 9, 272, 372, 334, 1199, 12, 822, 8, 1210, 430, 199, 199, 318, 12472, 63, 2708, 8, 1210, 12, 2550, 534, 4768, 735, 339, 408, 1487, 6021, 314, 909, 1324, 436, 2529, 282, 2008, 334, 1199, 267, 909, 12, 2582, 16949, 680, 398, 1324, 1471, 506, 376, 909, 1314, 6571, 314, 18839, 63, 362, 739, 1436, 267, 3335, 9348, 14, 2018, 3326, 12, 3335, 2251, 436, 4402, 267, 9994, 1584, 787, 7251, 402, 2251, 13070, 642, 9348, 14, 398, 2552, 7890, 314, 1125, 7252, 370, 4838, 14, 2779, 4243, 370, 267, 283, 4768, 7, 7252, 1314, 365, 314, 1454, 5544, 3748, 267, 1125, 7252, 367, 642, 9076, 14, 339, 408, 272, 702, 2552, 508, 283, 4768, 7, 272, 1072, 275, 12472, 14, 14954, 8, 1210, 9, 272, 372, 334, 1199, 12, 822, 8, 1210, 430, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 339, 347, 3752, 8, 277, 12, 1324, 12, 2552, 534, 4768, 735, 267, 372, 12472, 63, 2143, 8, 1210, 12, 2552, 9, 272, 347, 4849, 8, 277, 12, 1324, 12, 2552, 534, 4768, 735, 267, 372, 12472, 63, 2708, 8, 1210, 12, 2552, 9, 199, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 272, 986, 199, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 272, 986, 199, 199, 5680, 14134, 859, 3261, 199, 199, 318, 26116, 837, 339, 372, 334, 15371, 63, 2143, 12, 15371, 63, 2708, 12, 16132, 12, 16551, 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 ]
[ 2018, 283, 15371, 63, 9276, 7, 13732, 446, 12472, 10291, 2644, 339, 25059, 4750, 402, 314, 1163, 6010, 1314, 1347, 6140, 12, 642, 9076, 272, 911, 372, 2018, 1059, 2251, 367, 3865, 3752, 436, 4849, 14, 339, 27694, 701, 603, 9912, 13, 3325, 264, 7005, 32649, 334, 2174, 32, 274, 32649, 14, 957, 680, 199, 199, 624, 199, 646, 6010, 199, 646, 12472, 327, 642, 9076, 4839, 314, 2716, 12472, 859, 8546, 199, 199, 5680, 13732, 15913, 199, 199, 318, 12472, 63, 2143, 8, 1210, 12, 2550, 534, 4768, 735, 339, 408, 3447, 6021, 314, 909, 1324, 436, 2529, 282, 2008, 334, 1199, 267, 909, 12, 2582, 16949, 680, 398, 2552, 7890, 314, 1125, 7252, 370, 4838, 14, 2779, 4243, 370, 267, 283, 4768, 7, 7252, 1314, 365, 314, 1454, 5544, 3748, 267, 1125, 7252, 367, 642, 9076, 14, 339, 408, 272, 702, 2552, 508, 283, 4768, 7, 272, 1072, 275, 12472, 14, 6447, 8, 1210, 9, 272, 372, 334, 1199, 12, 822, 8, 1210, 430, 199, 199, 318, 12472, 63, 2708, 8, 1210, 12, 2550, 534, 4768, 735, 339, 408, 1487, 6021, 314, 909, 1324, 436, 2529, 282, 2008, 334, 1199, 267, 909, 12, 2582, 16949, 680, 398, 1324, 1471, 506, 376, 909, 1314, 6571, 314, 18839, 63, 362, 739, 1436, 267, 3335, 9348, 14, 2018, 3326, 12, 3335, 2251, 436, 4402, 267, 9994, 1584, 787, 7251, 402, 2251, 13070, 642, 9348, 14, 398, 2552, 7890, 314, 1125, 7252, 370, 4838, 14, 2779, 4243, 370, 267, 283, 4768, 7, 7252, 1314, 365, 314, 1454, 5544, 3748, 267, 1125, 7252, 367, 642, 9076, 14, 339, 408, 272, 702, 2552, 508, 283, 4768, 7, 272, 1072, 275, 12472, 14, 14954, 8, 1210, 9, 272, 372, 334, 1199, 12, 822, 8, 1210, 430, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 339, 347, 3752, 8, 277, 12, 1324, 12, 2552, 534, 4768, 735, 267, 372, 12472, 63, 2143, 8, 1210, 12, 2552, 9, 272, 347, 4849, 8, 277, 12, 1324, 12, 2552, 534, 4768, 735, 267, 372, 12472, 63, 2708, 8, 1210, 12, 2552, 9, 199, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 272, 986, 199, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 272, 986, 199, 199, 5680, 14134, 859, 3261, 199, 199, 318, 26116, 837, 339, 372, 334, 15371, 63, 2143, 12, 15371, 63, 2708, 12, 16132, 12, 16551, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
MeirKriheli/Open-Knesset
committees/migrations/0024_auto__chg_field_protocolpart_body__chg_field_protocolpart_header__chg_.py
5
28085
# -*- 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): # Changing field 'ProtocolPart.body' db.alter_column(u'committees_protocolpart', 'body', self.gf('django.db.models.fields.TextField')(null=True)) # Changing field 'ProtocolPart.header' db.alter_column(u'committees_protocolpart', 'header', self.gf('django.db.models.fields.TextField')(null=True)) # Changing field 'ProtocolPart.type' db.alter_column(u'committees_protocolpart', 'type', self.gf('django.db.models.fields.TextField')(max_length=20, null=True)) def backwards(self, orm): # Changing field 'ProtocolPart.body' db.alter_column(u'committees_protocolpart', 'body', self.gf('django.db.models.fields.TextField')(default='')) # Changing field 'ProtocolPart.header' db.alter_column(u'committees_protocolpart', 'header', self.gf('django.db.models.fields.TextField')(default='')) # Changing field 'ProtocolPart.type' db.alter_column(u'committees_protocolpart', 'type', self.gf('django.db.models.fields.TextField')(default='', max_length=20)) models = { 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'committees.committee': { 'Meta': {'object_name': 'Committee'}, 'aliases': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'chairpersons': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'chaired_committees'", 'blank': 'True', 'to': u"orm['mks.Member']"}), 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'end_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'hide': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'knesset_description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'knesset_description_arb': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'knesset_description_eng': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'knesset_id': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'knesset_note': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'knesset_note_eng': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'knesset_parent_id': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'knesset_portal_link': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'knesset_type_id': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'last_scrape_time': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'members': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'committees'", 'blank': 'True', 'to': u"orm['mks.Member']"}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '256'}), 'name_arb': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}), 'name_eng': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}), 'portal_knesset_broadcasts_url': ('django.db.models.fields.URLField', [], {'max_length': '1000', 'blank': 'True'}), 'protocol_not_published': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'replacements': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'replacing_in_committees'", 'blank': 'True', 'to': u"orm['mks.Member']"}), 'start_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'type': ('django.db.models.fields.CharField', [], {'default': "'committee'", 'max_length': '10', 'db_index': 'True'}) }, u'committees.committeemeeting': { 'Meta': {'ordering': "('-date',)", 'object_name': 'CommitteeMeeting'}, 'committee': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'meetings'", 'to': u"orm['committees.Committee']"}), 'date': ('django.db.models.fields.DateField', [], {'db_index': 'True'}), 'date_string': ('django.db.models.fields.CharField', [], {'max_length': '256'}), 'datetime': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'knesset_id': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'lobbyist_corporations_mentioned': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'committee_meetings'", 'blank': 'True', 'to': u"orm['lobbyists.LobbyistCorporation']"}), 'lobbyists_mentioned': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'committee_meetings'", 'blank': 'True', 'to': u"orm['lobbyists.Lobbyist']"}), 'mks_attended': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'committee_meetings'", 'symmetrical': 'False', 'to': u"orm['mks.Member']"}), 'protocol_parts_update_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'protocol_text': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'protocol_text_update_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'src_url': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), 'topics': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'votes_mentioned': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'committee_meetings'", 'blank': 'True', 'to': "orm['laws.Vote']"}) }, u'committees.protocolpart': { 'Meta': {'ordering': "('order', 'id')", 'object_name': 'ProtocolPart'}, 'body': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'header': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'meeting': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'parts'", 'to': u"orm['committees.CommitteeMeeting']"}), 'order': ('django.db.models.fields.IntegerField', [], {}), 'speaker': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'protocol_parts'", 'null': 'True', 'to': u"orm['persons.Person']"}), 'type': ('django.db.models.fields.TextField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}) }, u'committees.topic': { 'Meta': {'object_name': 'Topic'}, 'committees': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['committees.Committee']", 'symmetrical': 'False'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'creator': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"}), 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'editors': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'editing_topics'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['auth.User']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'log': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}), 'meetings': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': u"orm['committees.CommitteeMeeting']", 'null': 'True', 'blank': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'rating_score': ('django.db.models.fields.IntegerField', [], {'default': '0', 'blank': 'True'}), 'rating_votes': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'blank': 'True'}), 'status': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '256'}) }, 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'}) }, 'laws.vote': { 'Meta': {'ordering': "('-time', '-id')", 'object_name': 'Vote'}, 'abstain_votes_count': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'against_coalition': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'against_opposition': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'against_own_bill': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'against_party': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'against_votes_count': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'controversy': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'for_votes_count': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'full_text': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'full_text_url': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'importance': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'meeting_number': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'src_id': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'src_url': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), 'summary': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'time': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'}), 'time_string': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}), 'vote_number': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'vote_type': ('django.db.models.fields.CharField', [], {'max_length': '32', 'blank': 'True'}), 'votes': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'votes'", 'blank': 'True', 'through': "orm['laws.VoteAction']", 'to': u"orm['mks.Member']"}), 'votes_count': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}) }, 'laws.voteaction': { 'Meta': {'object_name': 'VoteAction'}, 'against_coalition': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'against_opposition': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'against_own_bill': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'against_party': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'member': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['mks.Member']"}), 'party': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['mks.Party']"}), 'type': ('django.db.models.fields.CharField', [], {'max_length': '10'}), 'vote': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'actions'", 'to': "orm['laws.Vote']"}) }, u'lobbyists.lobbyist': { 'Meta': {'object_name': 'Lobbyist'}, 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'image_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), 'large_image_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), 'person': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'lobbyist'", 'null': 'True', 'to': u"orm['persons.Person']"}), 'source_id': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}) }, u'lobbyists.lobbyistcorporation': { 'Meta': {'object_name': 'LobbyistCorporation'}, 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), 'source_id': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}) }, u'mks.knesset': { 'Meta': {'object_name': 'Knesset'}, 'end_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'number': ('django.db.models.fields.IntegerField', [], {'primary_key': 'True'}), 'start_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}) }, u'mks.member': { 'Meta': {'ordering': "['name']", 'object_name': 'Member'}, 'area_of_residence': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), 'average_monthly_committee_presence': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'average_weekly_presence_hours': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'backlinks_enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'bills_stats_approved': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'bills_stats_first': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'bills_stats_pre': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'bills_stats_proposed': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'blog': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['planet.Blog']", 'unique': 'True', 'null': 'True', 'blank': 'True'}), 'current_party': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'members'", 'null': 'True', 'to': u"orm['mks.Party']"}), 'current_position': ('django.db.models.fields.PositiveIntegerField', [], {'default': '999', 'blank': 'True'}), 'current_role_descriptions': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), 'date_of_birth': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'date_of_death': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}), 'end_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'family_status': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), 'fax': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}), 'gender': ('django.db.models.fields.CharField', [], {'max_length': '1', 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.IntegerField', [], {'primary_key': 'True'}), 'img_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}), 'is_current': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}), 'number_of_children': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'parties': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'all_members'", 'symmetrical': 'False', 'through': u"orm['mks.Membership']", 'to': u"orm['mks.Party']"}), 'phone': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}), 'place_of_birth': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), 'place_of_residence': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), 'place_of_residence_lat': ('django.db.models.fields.CharField', [], {'max_length': '16', 'null': 'True', 'blank': 'True'}), 'place_of_residence_lon': ('django.db.models.fields.CharField', [], {'max_length': '16', 'null': 'True', 'blank': 'True'}), 'residence_centrality': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'residence_economy': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'start_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'blank': 'True'}), 'website': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), 'year_of_aliyah': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}) }, u'mks.membership': { 'Meta': {'object_name': 'Membership'}, 'end_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'member': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['mks.Member']"}), 'party': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['mks.Party']"}), 'position': ('django.db.models.fields.PositiveIntegerField', [], {'default': '999', 'blank': 'True'}), 'start_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}) }, u'mks.party': { 'Meta': {'ordering': "('-number_of_seats',)", 'unique_together': "(('knesset', 'name'),)", 'object_name': 'Party'}, 'end_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_coalition': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'knesset': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'parties'", 'null': 'True', 'to': u"orm['mks.Knesset']"}), 'logo': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}), 'number_of_members': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'number_of_seats': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'split_from': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['mks.Party']", 'null': 'True', 'blank': 'True'}), 'start_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}) }, u'persons.person': { 'Meta': {'ordering': "('name',)", 'object_name': 'Person'}, 'area_of_residence': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), 'calendar_sync_token': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), 'calendar_url': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), 'date_of_birth': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'date_of_death': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}), 'family_status': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), 'fax': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}), 'gender': ('django.db.models.fields.CharField', [], {'max_length': '1', 'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'img_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}), 'mk': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'person'", 'null': 'True', 'to': u"orm['mks.Member']"}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}), 'number_of_children': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'phone': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}), 'place_of_birth': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), 'place_of_residence': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), 'place_of_residence_lat': ('django.db.models.fields.CharField', [], {'max_length': '16', 'null': 'True', 'blank': 'True'}), 'place_of_residence_lon': ('django.db.models.fields.CharField', [], {'max_length': '16', 'null': 'True', 'blank': 'True'}), 'residence_centrality': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'residence_economy': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'titles': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'persons'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['persons.Title']"}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'blank': 'True'}), 'year_of_aliyah': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}) }, u'persons.title': { 'Meta': {'object_name': 'Title'}, u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}) }, u'planet.blog': { 'Meta': {'ordering': "('title', 'url')", 'object_name': 'Blog'}, 'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'title': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'blank': 'True'}), 'url': ('django.db.models.fields.URLField', [], {'unique': 'True', 'max_length': '1024', 'db_index': 'True'}) } } complete_apps = ['committees']
bsd-3-clause
[ 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, 398, 327, 27854, 901, 283, 3658, 8416, 14, 2030, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 3543, 266, 397, 63, 3922, 2064, 297, 283, 2030, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2307, 29, 549, 430, 398, 327, 27854, 901, 283, 3658, 8416, 14, 1291, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 3543, 266, 397, 63, 3922, 2064, 297, 283, 1291, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2307, 29, 549, 430, 398, 327, 27854, 901, 283, 3658, 8416, 14, 466, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 3543, 266, 397, 63, 3922, 2064, 297, 283, 466, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 988, 63, 1267, 29, 1165, 12, 2973, 29, 549, 430, 339, 347, 8552, 8, 277, 12, 9813, 304, 398, 327, 27854, 901, 283, 3658, 8416, 14, 2030, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 3543, 266, 397, 63, 3922, 2064, 297, 283, 2030, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 885, 534, 1333, 398, 327, 27854, 901, 283, 3658, 8416, 14, 1291, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 3543, 266, 397, 63, 3922, 2064, 297, 283, 1291, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 885, 534, 1333, 398, 327, 27854, 901, 283, 3658, 8416, 14, 466, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 3543, 266, 397, 63, 3922, 2064, 297, 283, 466, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 885, 4581, 1390, 63, 1267, 29, 1165, 430, 339, 1709, 275, 469, 267, 399, 7, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 399, 7, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 7340, 85, 7, 1317, 63, 466, 363, 571, 63, 1302, 297, 399, 7, 1317, 63, 466, 363, 1238, 297, 399, 7, 11879, 18106, 283, 3235, 63, 6314, 356, 298, 1332, 85, 7, 1317, 63, 466, 297, 399, 7, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 10778, 14, 11282, 6097, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 399, 7, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 10247, 356, 283, 797, 297, 283, 2407, 63, 354, 356, 298, 85, 7, 751, 63, 409, 4662, 283, 2500, 356, 283, 549, 297, 283, 475, 356, 399, 2, 1025, 459, 1178, 14, 2448, 6097, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 10247, 356, 283, 797, 297, 283, 2407, 63, 354, 356, 298, 85, 7, 751 ]
[ 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, 398, 327, 27854, 901, 283, 3658, 8416, 14, 2030, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 3543, 266, 397, 63, 3922, 2064, 297, 283, 2030, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2307, 29, 549, 430, 398, 327, 27854, 901, 283, 3658, 8416, 14, 1291, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 3543, 266, 397, 63, 3922, 2064, 297, 283, 1291, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2307, 29, 549, 430, 398, 327, 27854, 901, 283, 3658, 8416, 14, 466, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 3543, 266, 397, 63, 3922, 2064, 297, 283, 466, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 988, 63, 1267, 29, 1165, 12, 2973, 29, 549, 430, 339, 347, 8552, 8, 277, 12, 9813, 304, 398, 327, 27854, 901, 283, 3658, 8416, 14, 2030, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 3543, 266, 397, 63, 3922, 2064, 297, 283, 2030, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 885, 534, 1333, 398, 327, 27854, 901, 283, 3658, 8416, 14, 1291, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 3543, 266, 397, 63, 3922, 2064, 297, 283, 1291, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 885, 534, 1333, 398, 327, 27854, 901, 283, 3658, 8416, 14, 466, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 3543, 266, 397, 63, 3922, 2064, 297, 283, 466, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 885, 4581, 1390, 63, 1267, 29, 1165, 430, 339, 1709, 275, 469, 267, 399, 7, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 399, 7, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 7340, 85, 7, 1317, 63, 466, 363, 571, 63, 1302, 297, 399, 7, 1317, 63, 466, 363, 1238, 297, 399, 7, 11879, 18106, 283, 3235, 63, 6314, 356, 298, 1332, 85, 7, 1317, 63, 466, 297, 399, 7, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 10778, 14, 11282, 6097, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 399, 7, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 10247, 356, 283, 797, 297, 283, 2407, 63, 354, 356, 298, 85, 7, 751, 63, 409, 4662, 283, 2500, 356, 283, 549, 297, 283, 475, 356, 399, 2, 1025, 459, 1178, 14, 2448, 6097, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
jeffsilverm/presentation
whats_new_in_python_3.6/secrets_demo.py
1
2020
#! /usr/bin/python3.6 # -*- coding: utf-8 -*- # # secrets.py - a demonstration of the secrets module new in python 3.6 # secrets implements a cryptographically secure random number generator # PEP-506 describes the motivation for CSPRNG https://www.python.org/dev/peps/pep-0506/ import tempfile import secrets import sys print(sys.version_info, sys.version) # Generate a ten-character alphanumeric password with at least one lowercase character, at least one uppercase # character, and at least three digits. # This works by generating a password from the string of characters and numbers, then testing to see if the password # meets the criteria. If not, then loop until you find one that does. import string cntr = 0 alphabet = string.ascii_letters + string.digits while True: cntr += 1 password = ''.join(secrets.choice(alphabet) for i in range(10)) print("cntr={:d} password is {}".format(cntr, password)) if (any(c.islower() for c in password) and any(c.isupper() for c in password) and sum(c.isdigit() for c in password) >= 3): break print(password) with tempfile.NamedTemporaryFile(delete=False) as f: tempfile_name = f.name encoded_tempfile_name = tempfile_name+"_base64_encoded.txt" decoded_tempfile_name = tempfile_name + "_decoded" random_buffer = secrets.token_bytes(1024) f.write( random_buffer ) with open(encoded_tempfile_name, "w+b") as o: # See https://docs.python.org/3/library/base64.html?highlight=base64#module-base64 secrets.base64.encode(f, o ) with tempfile.NamedTemporaryFile(delete=True) as f: with open(encoded_tempfile_name, mode="r+b") as encoded: secrets.base64.decode(encoded, f) retreived_random_buffer = f.read(1024) if secrets.compare_digest(random_buffer, retreived_random_buffer): print("Successfully recovered a token using a random file {}".format(tempfile_name)) else : print("FAILED to recover a token using a random file {}".format(tempfile_name))
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1548, 19, 14, 22, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 25563, 14, 647, 446, 282, 23789, 270, 1754, 402, 314, 25563, 859, 892, 315, 2366, 650, 14, 22, 199, 3, 25563, 9031, 282, 13230, 25537, 11153, 2196, 1329, 4306, 199, 199, 3, 13663, 13, 13725, 23369, 314, 1303, 280, 4255, 367, 17447, 3311, 12259, 4178, 921, 1544, 14, 1548, 14, 1308, 15, 2374, 15, 321, 1190, 15, 12636, 13, 16, 13725, 15, 199, 199, 646, 5549, 199, 646, 25563, 199, 646, 984, 199, 1361, 8, 1274, 14, 1023, 63, 815, 12, 984, 14, 1023, 9, 421, 199, 3, 7958, 282, 16685, 13, 10856, 27964, 2505, 543, 737, 5210, 1373, 12141, 4528, 12, 737, 5210, 1373, 22681, 199, 3, 4528, 12, 436, 737, 5210, 7795, 7576, 14, 199, 3, 961, 5419, 701, 12999, 282, 2505, 687, 314, 1059, 402, 4110, 436, 5579, 12, 2066, 5343, 370, 1937, 340, 314, 2505, 199, 3, 562, 8716, 314, 15647, 14, 221, 982, 440, 12, 2066, 4438, 5133, 1265, 2342, 1373, 626, 1630, 14, 199, 199, 646, 1059, 199, 6507, 82, 275, 378, 199, 31884, 275, 1059, 14, 4371, 63, 16415, 435, 1059, 14, 7022, 199, 6710, 715, 26, 272, 12703, 82, 847, 413, 272, 2505, 275, 6522, 904, 8, 16153, 14, 5095, 8, 31884, 9, 367, 284, 315, 1425, 8, 709, 430, 272, 870, 480, 6507, 82, 3126, 26, 68, 93, 2505, 365, 8352, 908, 8, 6507, 82, 12, 2505, 430, 272, 340, 334, 1629, 8, 67, 14, 374, 2325, 342, 367, 286, 315, 2505, 9, 288, 436, 1263, 8, 67, 14, 374, 4142, 342, 367, 286, 315, 2505, 9, 288, 436, 3089, 8, 67, 14, 13896, 342, 367, 286, 315, 2505, 9, 2356, 650, 304, 267, 2059, 199, 1361, 8, 2060, 9, 199, 199, 1045, 5549, 14, 19320, 8, 1807, 29, 797, 9, 465, 289, 26, 272, 5549, 63, 354, 275, 289, 14, 354, 272, 5737, 63, 17336, 63, 354, 275, 5549, 63, 354, 30056, 1095, 772, 63, 8167, 14, 2424, 2, 272, 11203, 63, 17336, 63, 354, 275, 5549, 63, 354, 435, 2668, 16167, 2, 272, 2196, 63, 2738, 275, 25563, 14, 1418, 63, 2394, 8, 7727, 9, 272, 289, 14, 952, 8, 2196, 63, 2738, 776, 272, 543, 1551, 8, 8167, 63, 17336, 63, 354, 12, 298, 87, 11, 66, 531, 465, 312, 26, 199, 3, 1666, 4178, 921, 4757, 14, 1548, 14, 1308, 15, 19, 15, 4342, 15, 1095, 772, 14, 1360, 31, 14337, 29, 1095, 772, 3, 578, 13, 1095, 772, 267, 25563, 14, 1095, 772, 14, 2143, 8, 70, 12, 312, 776, 421, 199, 1045, 5549, 14, 19320, 8, 1807, 29, 549, 9, 465, 289, 26, 272, 543, 1551, 8, 8167, 63, 17336, 63, 354, 12, 818, 628, 82, 11, 66, 531, 465, 5737, 26, 267, 25563, 14, 1095, 772, 14, 2708, 8, 8167, 12, 289, 9, 272, 2203, 264, 12905, 63, 2355, 63, 2738, 275, 289, 14, 739, 8, 7727, 9, 272, 340, 25563, 14, 5785, 63, 5671, 8, 2355, 63, 2738, 12, 2203, 264, 12905, 63, 2355, 63, 2738, 304, 267, 870, 480, 25001, 295, 13560, 282, 1526, 1808, 282, 2196, 570, 8352, 908, 8, 17336, 63, 354, 430, 272, 587, 520, 267, 870, 480, 12299, 370, 22803, 282, 1526, 1808, 282, 2196, 570, 8352, 908, 8, 17336, 63, 354, 430, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1182, 2647, 15, 1393, 15, 1548, 19, 14, 22, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 25563, 14, 647, 446, 282, 23789, 270, 1754, 402, 314, 25563, 859, 892, 315, 2366, 650, 14, 22, 199, 3, 25563, 9031, 282, 13230, 25537, 11153, 2196, 1329, 4306, 199, 199, 3, 13663, 13, 13725, 23369, 314, 1303, 280, 4255, 367, 17447, 3311, 12259, 4178, 921, 1544, 14, 1548, 14, 1308, 15, 2374, 15, 321, 1190, 15, 12636, 13, 16, 13725, 15, 199, 199, 646, 5549, 199, 646, 25563, 199, 646, 984, 199, 1361, 8, 1274, 14, 1023, 63, 815, 12, 984, 14, 1023, 9, 421, 199, 3, 7958, 282, 16685, 13, 10856, 27964, 2505, 543, 737, 5210, 1373, 12141, 4528, 12, 737, 5210, 1373, 22681, 199, 3, 4528, 12, 436, 737, 5210, 7795, 7576, 14, 199, 3, 961, 5419, 701, 12999, 282, 2505, 687, 314, 1059, 402, 4110, 436, 5579, 12, 2066, 5343, 370, 1937, 340, 314, 2505, 199, 3, 562, 8716, 314, 15647, 14, 221, 982, 440, 12, 2066, 4438, 5133, 1265, 2342, 1373, 626, 1630, 14, 199, 199, 646, 1059, 199, 6507, 82, 275, 378, 199, 31884, 275, 1059, 14, 4371, 63, 16415, 435, 1059, 14, 7022, 199, 6710, 715, 26, 272, 12703, 82, 847, 413, 272, 2505, 275, 6522, 904, 8, 16153, 14, 5095, 8, 31884, 9, 367, 284, 315, 1425, 8, 709, 430, 272, 870, 480, 6507, 82, 3126, 26, 68, 93, 2505, 365, 8352, 908, 8, 6507, 82, 12, 2505, 430, 272, 340, 334, 1629, 8, 67, 14, 374, 2325, 342, 367, 286, 315, 2505, 9, 288, 436, 1263, 8, 67, 14, 374, 4142, 342, 367, 286, 315, 2505, 9, 288, 436, 3089, 8, 67, 14, 13896, 342, 367, 286, 315, 2505, 9, 2356, 650, 304, 267, 2059, 199, 1361, 8, 2060, 9, 199, 199, 1045, 5549, 14, 19320, 8, 1807, 29, 797, 9, 465, 289, 26, 272, 5549, 63, 354, 275, 289, 14, 354, 272, 5737, 63, 17336, 63, 354, 275, 5549, 63, 354, 30056, 1095, 772, 63, 8167, 14, 2424, 2, 272, 11203, 63, 17336, 63, 354, 275, 5549, 63, 354, 435, 2668, 16167, 2, 272, 2196, 63, 2738, 275, 25563, 14, 1418, 63, 2394, 8, 7727, 9, 272, 289, 14, 952, 8, 2196, 63, 2738, 776, 272, 543, 1551, 8, 8167, 63, 17336, 63, 354, 12, 298, 87, 11, 66, 531, 465, 312, 26, 199, 3, 1666, 4178, 921, 4757, 14, 1548, 14, 1308, 15, 19, 15, 4342, 15, 1095, 772, 14, 1360, 31, 14337, 29, 1095, 772, 3, 578, 13, 1095, 772, 267, 25563, 14, 1095, 772, 14, 2143, 8, 70, 12, 312, 776, 421, 199, 1045, 5549, 14, 19320, 8, 1807, 29, 549, 9, 465, 289, 26, 272, 543, 1551, 8, 8167, 63, 17336, 63, 354, 12, 818, 628, 82, 11, 66, 531, 465, 5737, 26, 267, 25563, 14, 1095, 772, 14, 2708, 8, 8167, 12, 289, 9, 272, 2203, 264, 12905, 63, 2355, 63, 2738, 275, 289, 14, 739, 8, 7727, 9, 272, 340, 25563, 14, 5785, 63, 5671, 8, 2355, 63, 2738, 12, 2203, 264, 12905, 63, 2355, 63, 2738, 304, 267, 870, 480, 25001, 295, 13560, 282, 1526, 1808, 282, 2196, 570, 8352, 908, 8, 17336, 63, 354, 430, 272, 587, 520, 267, 870, 480, 12299, 370, 22803, 282, 1526, 1808, 282, 2196, 570, 8352, 908, 8, 17336, 63, 354, 430, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
josiah-wolf-oberholtzer/supriya
tests/nonrealtime/test_nonrealtime_Node_set_duration.py
2
9037
import pytest import uqbar.strings import supriya.assets.synthdefs import supriya.nonrealtime def test_basic(): session = supriya.nonrealtime.Session() with session.at(0): node = session.add_group(duration=20) assert session.to_strings() == uqbar.strings.normalize( """ 0.0: NODE TREE 0 group 1000 group 20.0: NODE TREE 0 group """ ) assert session.to_lists() == [ [0.0, [["/g_new", 1000, 0, 0]]], [20.0, [["/n_free", 1000], [0]]], ] node.set_duration(30) assert session.to_strings() == uqbar.strings.normalize( """ 0.0: NODE TREE 0 group 1000 group 30.0: NODE TREE 0 group """ ) assert session.to_lists() == [ [0.0, [["/g_new", 1000, 0, 0]]], [30.0, [["/n_free", 1000], [0]]], ] node.set_duration(10) assert session.to_strings() == uqbar.strings.normalize( """ 0.0: NODE TREE 0 group 1000 group 10.0: NODE TREE 0 group """ ) assert session.to_lists() == [ [0.0, [["/g_new", 1000, 0, 0]]], [10.0, [["/n_free", 1000], [0]]], ] def test_contained(): session = supriya.nonrealtime.Session() with session.at(0): group_one = session.add_group(duration=30) group_two = group_one.add_group(duration=20) group_three = group_two.add_group(duration=10) assert session.to_strings() == uqbar.strings.normalize( """ 0.0: NODE TREE 0 group 1000 group 1001 group 1002 group 10.0: NODE TREE 0 group 1000 group 1001 group 20.0: NODE TREE 0 group 1000 group 30.0: NODE TREE 0 group """ ) assert session.to_lists() == [ [ 0.0, [ ["/g_new", 1000, 0, 0], ["/g_new", 1001, 0, 1000], ["/g_new", 1002, 0, 1001], ], ], [10.0, [["/n_free", 1002]]], [20.0, [["/n_free", 1001]]], [30.0, [["/n_free", 1000], [0]]], ] group_three.set_duration(20) assert session.to_strings() == uqbar.strings.normalize( """ 0.0: NODE TREE 0 group 1000 group 1001 group 1002 group 20.0: NODE TREE 0 group 1000 group 30.0: NODE TREE 0 group """ ) assert session.to_lists() == [ [ 0.0, [ ["/g_new", 1000, 0, 0], ["/g_new", 1001, 0, 1000], ["/g_new", 1002, 0, 1001], ], ], [20.0, [["/n_free", 1001, 1002]]], [30.0, [["/n_free", 1000], [0]]], ] group_three.set_duration(25) assert session.to_strings() == uqbar.strings.normalize( """ 0.0: NODE TREE 0 group 1000 group 1001 group 1002 group 20.0: NODE TREE 0 group 1000 group 1002 group 25.0: NODE TREE 0 group 1000 group 30.0: NODE TREE 0 group """ ) assert session.to_lists() == [ [ 0.0, [ ["/g_new", 1000, 0, 0], ["/g_new", 1001, 0, 1000], ["/g_new", 1002, 0, 1001], ], ], [20.0, [["/n_before", 1002, 1001], ["/n_free", 1001]]], [25.0, [["/n_free", 1002]]], [30.0, [["/n_free", 1000], [0]]], ] group_three.set_duration(30) assert session.to_strings() == uqbar.strings.normalize( """ 0.0: NODE TREE 0 group 1000 group 1001 group 1002 group 20.0: NODE TREE 0 group 1000 group 1002 group 30.0: NODE TREE 0 group """ ) assert session.to_lists() == [ [ 0.0, [ ["/g_new", 1000, 0, 0], ["/g_new", 1001, 0, 1000], ["/g_new", 1002, 0, 1001], ], ], [20.0, [["/n_before", 1002, 1001], ["/n_free", 1001]]], [30.0, [["/n_free", 1000, 1002], [0]]], ] group_three.set_duration(35) assert session.to_strings() == uqbar.strings.normalize( """ 0.0: NODE TREE 0 group 1000 group 1001 group 1002 group 20.0: NODE TREE 0 group 1000 group 1002 group 30.0: NODE TREE 0 group 1002 group 35.0: NODE TREE 0 group """ ) assert session.to_lists() == [ [ 0.0, [ ["/g_new", 1000, 0, 0], ["/g_new", 1001, 0, 1000], ["/g_new", 1002, 0, 1001], ], ], [20.0, [["/n_before", 1002, 1001], ["/n_free", 1001]]], [30.0, [["/n_before", 1002, 1000], ["/n_free", 1000]]], [35.0, [["/n_free", 1002], [0]]], ] def test_pbus(): session = supriya.nonrealtime.Session() with session.at(0): group = session.add_group() synth = group.add_synth(add_action="ADD_AFTER") group.add_synth(duration=10) assert session.to_strings() == uqbar.strings.normalize( """ 0.0: NODE TREE 0 group 1000 group 1002 default 1001 default 10.0: NODE TREE 0 group 1000 group 1001 default inf: NODE TREE 0 group """ ) synth.set_duration(15) assert session.to_strings() == uqbar.strings.normalize( """ 0.0: NODE TREE 0 group 1000 group 1002 default 1001 default 10.0: NODE TREE 0 group 1000 group 1001 default 15.0: NODE TREE 0 group 1000 group inf: NODE TREE 0 group """ ) group.set_duration(15) assert session.to_strings() == uqbar.strings.normalize( """ 0.0: NODE TREE 0 group 1000 group 1002 default 1001 default 10.0: NODE TREE 0 group 1000 group 1001 default 15.0: NODE TREE 0 group """ ) d_recv_commands = pytest.helpers.build_d_recv_commands( [supriya.assets.synthdefs.default] ) assert session.to_lists() == [ [ 0.0, [ *d_recv_commands, ["/g_new", 1000, 0, 0], ["/s_new", "da0982184cc8fa54cf9d288a0fe1f6ca", 1001, 3, 1000], ["/s_new", "da0982184cc8fa54cf9d288a0fe1f6ca", 1002, 0, 1000], ], ], [10.0, [["/n_set", 1002, "gate", 0]]], [15.0, [["/n_free", 1000], ["/n_set", 1001, "gate", 0], [0]]], ] def test_clip_children(): session = supriya.nonrealtime.Session() with session.at(0): outer_group = session.add_group(duration=20) inner_group = outer_group.add_group(duration=20) inner_group.add_synth(duration=20) outer_group.add_group(duration=20) session.add_group(duration=20) assert session.to_strings(include_timespans=True) == uqbar.strings.normalize( """ 0.0: NODE TREE 0 group (timespan: [-inf, inf]) 1004 group (timespan: [0.0, 20.0]) 1000 group (timespan: [0.0, 20.0]) 1003 group (timespan: [0.0, 20.0]) 1001 group (timespan: [0.0, 20.0]) 1002 default (timespan: [0.0, 20.0]) 20.0: NODE TREE 0 group (timespan: [-inf, inf]) """ ) outer_group.set_duration(10, clip_children=True) assert session.to_strings(include_timespans=True) == uqbar.strings.normalize( """ 0.0: NODE TREE 0 group (timespan: [-inf, inf]) 1004 group (timespan: [0.0, 20.0]) 1000 group (timespan: [0.0, 10.0]) 1003 group (timespan: [0.0, 10.0]) 1001 group (timespan: [0.0, 10.0]) 1002 default (timespan: [0.0, 10.0]) 10.0: NODE TREE 0 group (timespan: [-inf, inf]) 1004 group (timespan: [0.0, 20.0]) 20.0: NODE TREE 0 group (timespan: [-inf, inf]) """ )
mit
[ 646, 4613, 199, 646, 399, 81, 1700, 14, 5465, 199, 199, 646, 1029, 322, 11552, 14, 12186, 14, 9466, 273, 8710, 199, 646, 1029, 322, 11552, 14, 2865, 3093, 521, 421, 199, 318, 511, 63, 4316, 837, 272, 2351, 275, 1029, 322, 11552, 14, 2865, 3093, 521, 14, 4434, 342, 272, 543, 2351, 14, 292, 8, 16, 304, 267, 1031, 275, 2351, 14, 525, 63, 923, 8, 5553, 29, 1165, 9, 272, 702, 2351, 14, 475, 63, 5465, 342, 508, 399, 81, 1700, 14, 5465, 14, 7721, 8, 267, 408, 267, 378, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 267, 3388, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 267, 408, 272, 776, 272, 702, 2351, 14, 475, 63, 6717, 342, 508, 359, 267, 359, 16, 14, 16, 12, 24212, 15, 71, 63, 1222, 401, 5198, 12, 378, 12, 378, 15559, 267, 359, 1165, 14, 16, 12, 24212, 15, 78, 63, 4624, 401, 5198, 467, 359, 16, 15559, 272, 1622, 272, 1031, 14, 409, 63, 5553, 8, 1216, 9, 272, 702, 2351, 14, 475, 63, 5465, 342, 508, 399, 81, 1700, 14, 5465, 14, 7721, 8, 267, 408, 267, 378, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 267, 4233, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 267, 408, 272, 776, 272, 702, 2351, 14, 475, 63, 6717, 342, 508, 359, 267, 359, 16, 14, 16, 12, 24212, 15, 71, 63, 1222, 401, 5198, 12, 378, 12, 378, 15559, 267, 359, 1216, 14, 16, 12, 24212, 15, 78, 63, 4624, 401, 5198, 467, 359, 16, 15559, 272, 1622, 272, 1031, 14, 409, 63, 5553, 8, 709, 9, 272, 702, 2351, 14, 475, 63, 5465, 342, 508, 399, 81, 1700, 14, 5465, 14, 7721, 8, 267, 408, 267, 378, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 267, 1616, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 267, 408, 272, 776, 272, 702, 2351, 14, 475, 63, 6717, 342, 508, 359, 267, 359, 16, 14, 16, 12, 24212, 15, 71, 63, 1222, 401, 5198, 12, 378, 12, 378, 15559, 267, 359, 709, 14, 16, 12, 24212, 15, 78, 63, 4624, 401, 5198, 467, 359, 16, 15559, 272, 1622, 421, 199, 318, 511, 63, 30288, 837, 272, 2351, 275, 1029, 322, 11552, 14, 2865, 3093, 521, 14, 4434, 342, 272, 543, 2351, 14, 292, 8, 16, 304, 267, 1572, 63, 368, 275, 2351, 14, 525, 63, 923, 8, 5553, 29, 1216, 9, 267, 1572, 63, 5601, 275, 1572, 63, 368, 14, 525, 63, 923, 8, 5553, 29, 1165, 9, 267, 1572, 63, 10480, 275, 1572, 63, 5601, 14, 525, 63, 923, 8, 5553, 29, 709, 9, 272, 702, 2351, 14, 475, 63, 5465, 342, 508, 399, 81, 1700, 14, 5465, 14, 7721, 8, 267, 408, 267, 378, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 490, 2948, 17, 1572, 717, 2948, 18, 1572, 267, 1616, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 490, 2948, 17, 1572, 267, 3388, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 267, 4233, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 267, 408, 272, 776, 272, 702, 2351, 14, 475, 63, 6717, 342, 508, 359, 267, 359, 288, 378, 14, 16, 12, 288, 359, 355, 2097, 15, 71, 63, 1222, 401, 5198, 12, 378, 12, 378, 467, 355, 2097, 15, 71, 63, 1222, 401, 2948, 17, 12, 378, 12, 5198, 467, 355, 2097, 15, 71, 63, 1222, 401, 2948, 18, 12, 378, 12, 2948, 17, 467, 288, 2156, 267, 2156, 267, 359, 709, 14, 16, 12, 24212, 15, 78, 63, 4624, 401, 2948, 18, 15559, 267, 359, 1165, 14, 16, 12, 24212, 15, 78, 63, 4624, 401, 2948, 17, 15559, 267, 359, 1216, 14, 16, 12, 24212, 15, 78, 63, 4624, 401, 5198, 467, 359, 16, 15559, 272, 1622, 339, 1572, 63, 10480, 14, 409, 63, 5553, 8, 1165, 9, 272, 702, 2351, 14, 475, 63, 5465, 342, 508, 399, 81, 1700, 14, 5465, 14, 7721, 8, 267, 408, 267, 378, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 490, 2948, 17, 1572, 717, 2948, 18, 1572, 267, 3388, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 267, 4233, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 267, 408, 272, 776, 272, 702, 2351, 14, 475, 63, 6717, 342, 508, 359, 267, 359, 288, 378, 14, 16, 12, 288, 359, 355, 2097, 15, 71, 63, 1222, 401, 5198, 12, 378, 12, 378, 467, 355, 2097, 15, 71, 63, 1222, 401, 2948, 17, 12, 378, 12, 5198, 467, 355, 2097, 15, 71, 63, 1222, 401, 2948, 18, 12, 378, 12, 2948, 17, 467, 288, 2156, 267, 2156, 267, 359, 1165, 14, 16, 12, 24212, 15, 78, 63, 4624, 401, 2948, 17, 12, 2948, 18, 15559, 267, 359, 1216, 14, 16, 12, 24212, 15, 78, 63, 4624, 401, 5198, 467, 359, 16, 15559, 272, 1622, 339, 1572, 63, 10480, 14, 409, 63, 5553, 8, 821, 9, 272, 702, 2351, 14, 475, 63, 5465, 342, 508, 399, 81, 1700, 14, 5465, 14, 7721, 8, 267, 408, 267, 378, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 490, 2948, 17, 1572, 717, 2948, 18, 1572, 267, 3388, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 490, 2948, 18, 1572, 267, 5661, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 267, 4233, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 267, 408, 272, 776, 272, 702, 2351, 14, 475, 63, 6717, 342, 508, 359, 267, 359, 288, 378, 14, 16, 12, 288, 359, 355, 2097, 15, 71, 63, 1222, 401, 5198, 12, 378, 12, 378, 467, 355, 2097, 15, 71, 63, 1222, 401, 2948, 17, 12, 378, 12, 5198, 467, 355, 2097, 15, 71, 63, 1222, 401, 2948, 18, 12, 378, 12, 2948, 17, 467, 288, 2156, 267, 2156, 267, 359, 1165, 14, 16, 12, 24212 ]
[ 4613, 199, 646, 399, 81, 1700, 14, 5465, 199, 199, 646, 1029, 322, 11552, 14, 12186, 14, 9466, 273, 8710, 199, 646, 1029, 322, 11552, 14, 2865, 3093, 521, 421, 199, 318, 511, 63, 4316, 837, 272, 2351, 275, 1029, 322, 11552, 14, 2865, 3093, 521, 14, 4434, 342, 272, 543, 2351, 14, 292, 8, 16, 304, 267, 1031, 275, 2351, 14, 525, 63, 923, 8, 5553, 29, 1165, 9, 272, 702, 2351, 14, 475, 63, 5465, 342, 508, 399, 81, 1700, 14, 5465, 14, 7721, 8, 267, 408, 267, 378, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 267, 3388, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 267, 408, 272, 776, 272, 702, 2351, 14, 475, 63, 6717, 342, 508, 359, 267, 359, 16, 14, 16, 12, 24212, 15, 71, 63, 1222, 401, 5198, 12, 378, 12, 378, 15559, 267, 359, 1165, 14, 16, 12, 24212, 15, 78, 63, 4624, 401, 5198, 467, 359, 16, 15559, 272, 1622, 272, 1031, 14, 409, 63, 5553, 8, 1216, 9, 272, 702, 2351, 14, 475, 63, 5465, 342, 508, 399, 81, 1700, 14, 5465, 14, 7721, 8, 267, 408, 267, 378, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 267, 4233, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 267, 408, 272, 776, 272, 702, 2351, 14, 475, 63, 6717, 342, 508, 359, 267, 359, 16, 14, 16, 12, 24212, 15, 71, 63, 1222, 401, 5198, 12, 378, 12, 378, 15559, 267, 359, 1216, 14, 16, 12, 24212, 15, 78, 63, 4624, 401, 5198, 467, 359, 16, 15559, 272, 1622, 272, 1031, 14, 409, 63, 5553, 8, 709, 9, 272, 702, 2351, 14, 475, 63, 5465, 342, 508, 399, 81, 1700, 14, 5465, 14, 7721, 8, 267, 408, 267, 378, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 267, 1616, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 267, 408, 272, 776, 272, 702, 2351, 14, 475, 63, 6717, 342, 508, 359, 267, 359, 16, 14, 16, 12, 24212, 15, 71, 63, 1222, 401, 5198, 12, 378, 12, 378, 15559, 267, 359, 709, 14, 16, 12, 24212, 15, 78, 63, 4624, 401, 5198, 467, 359, 16, 15559, 272, 1622, 421, 199, 318, 511, 63, 30288, 837, 272, 2351, 275, 1029, 322, 11552, 14, 2865, 3093, 521, 14, 4434, 342, 272, 543, 2351, 14, 292, 8, 16, 304, 267, 1572, 63, 368, 275, 2351, 14, 525, 63, 923, 8, 5553, 29, 1216, 9, 267, 1572, 63, 5601, 275, 1572, 63, 368, 14, 525, 63, 923, 8, 5553, 29, 1165, 9, 267, 1572, 63, 10480, 275, 1572, 63, 5601, 14, 525, 63, 923, 8, 5553, 29, 709, 9, 272, 702, 2351, 14, 475, 63, 5465, 342, 508, 399, 81, 1700, 14, 5465, 14, 7721, 8, 267, 408, 267, 378, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 490, 2948, 17, 1572, 717, 2948, 18, 1572, 267, 1616, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 490, 2948, 17, 1572, 267, 3388, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 267, 4233, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 267, 408, 272, 776, 272, 702, 2351, 14, 475, 63, 6717, 342, 508, 359, 267, 359, 288, 378, 14, 16, 12, 288, 359, 355, 2097, 15, 71, 63, 1222, 401, 5198, 12, 378, 12, 378, 467, 355, 2097, 15, 71, 63, 1222, 401, 2948, 17, 12, 378, 12, 5198, 467, 355, 2097, 15, 71, 63, 1222, 401, 2948, 18, 12, 378, 12, 2948, 17, 467, 288, 2156, 267, 2156, 267, 359, 709, 14, 16, 12, 24212, 15, 78, 63, 4624, 401, 2948, 18, 15559, 267, 359, 1165, 14, 16, 12, 24212, 15, 78, 63, 4624, 401, 2948, 17, 15559, 267, 359, 1216, 14, 16, 12, 24212, 15, 78, 63, 4624, 401, 5198, 467, 359, 16, 15559, 272, 1622, 339, 1572, 63, 10480, 14, 409, 63, 5553, 8, 1165, 9, 272, 702, 2351, 14, 475, 63, 5465, 342, 508, 399, 81, 1700, 14, 5465, 14, 7721, 8, 267, 408, 267, 378, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 490, 2948, 17, 1572, 717, 2948, 18, 1572, 267, 3388, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 267, 4233, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 267, 408, 272, 776, 272, 702, 2351, 14, 475, 63, 6717, 342, 508, 359, 267, 359, 288, 378, 14, 16, 12, 288, 359, 355, 2097, 15, 71, 63, 1222, 401, 5198, 12, 378, 12, 378, 467, 355, 2097, 15, 71, 63, 1222, 401, 2948, 17, 12, 378, 12, 5198, 467, 355, 2097, 15, 71, 63, 1222, 401, 2948, 18, 12, 378, 12, 2948, 17, 467, 288, 2156, 267, 2156, 267, 359, 1165, 14, 16, 12, 24212, 15, 78, 63, 4624, 401, 2948, 17, 12, 2948, 18, 15559, 267, 359, 1216, 14, 16, 12, 24212, 15, 78, 63, 4624, 401, 5198, 467, 359, 16, 15559, 272, 1622, 339, 1572, 63, 10480, 14, 409, 63, 5553, 8, 821, 9, 272, 702, 2351, 14, 475, 63, 5465, 342, 508, 399, 81, 1700, 14, 5465, 14, 7721, 8, 267, 408, 267, 378, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 490, 2948, 17, 1572, 717, 2948, 18, 1572, 267, 3388, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 490, 2948, 18, 1572, 267, 5661, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 355, 5198, 1572, 267, 4233, 14, 16, 26, 288, 4825, 1093, 377, 5271, 378, 1572, 267, 408, 272, 776, 272, 702, 2351, 14, 475, 63, 6717, 342, 508, 359, 267, 359, 288, 378, 14, 16, 12, 288, 359, 355, 2097, 15, 71, 63, 1222, 401, 5198, 12, 378, 12, 378, 467, 355, 2097, 15, 71, 63, 1222, 401, 2948, 17, 12, 378, 12, 5198, 467, 355, 2097, 15, 71, 63, 1222, 401, 2948, 18, 12, 378, 12, 2948, 17, 467, 288, 2156, 267, 2156, 267, 359, 1165, 14, 16, 12, 24212, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
matt-kwong/grpc
test/cpp/qps/gen_build_yaml.py
9
4165
#!/usr/bin/env python2.7 # Copyright 2015 gRPC authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import json import pipes import shutil import sys import os import yaml run_tests_root = os.path.abspath(os.path.join( os.path.dirname(sys.argv[0]), '../../../tools/run_tests')) sys.path.append(run_tests_root) import performance.scenario_config as scenario_config configs_from_yaml = yaml.load(open(os.path.join(os.path.dirname(sys.argv[0]), '../../../build.yaml')))['configs'].keys() def mutate_scenario(scenario_json, is_tsan): # tweak parameters to get fast test times scenario_json = dict(scenario_json) scenario_json['warmup_seconds'] = 0 scenario_json['benchmark_seconds'] = 1 outstanding_rpcs_divisor = 1 if is_tsan and ( scenario_json['client_config']['client_type'] == 'SYNC_CLIENT' or scenario_json['server_config']['server_type'] == 'SYNC_SERVER'): outstanding_rpcs_divisor = 10 scenario_json['client_config']['outstanding_rpcs_per_channel'] = max(1, int(scenario_json['client_config']['outstanding_rpcs_per_channel'] / outstanding_rpcs_divisor)) return scenario_json def _scenario_json_string(scenario_json, is_tsan): scenarios_json = {'scenarios': [scenario_config.remove_nonproto_fields(mutate_scenario(scenario_json, is_tsan))]} return json.dumps(scenarios_json) def threads_required(scenario_json, where, is_tsan): scenario_json = mutate_scenario(scenario_json, is_tsan) if scenario_json['%s_config' % where]['%s_type' % where] == 'ASYNC_%s' % where.upper(): return scenario_json['%s_config' % where].get('async_%s_threads' % where, 0) return scenario_json['client_config']['outstanding_rpcs_per_channel'] * scenario_json['client_config']['client_channels'] def guess_cpu(scenario_json, is_tsan): client = threads_required(scenario_json, 'client', is_tsan) server = threads_required(scenario_json, 'server', is_tsan) # make an arbitrary guess if set to auto-detect # about the size of the jenkins instances we have for unit tests if client == 0 or server == 0: return 'capacity' return (scenario_json['num_clients'] * client + scenario_json['num_servers'] * server) print yaml.dump({ 'tests': [ { 'name': 'json_run_localhost', 'shortname': 'json_run_localhost:%s' % scenario_json['name'], 'args': ['--scenarios_json', _scenario_json_string(scenario_json, False)], 'ci_platforms': ['linux'], 'platforms': ['linux'], 'flaky': False, 'language': 'c++', 'boringssl': True, 'defaults': 'boringssl', 'cpu_cost': guess_cpu(scenario_json, False), 'exclude_configs': ['tsan', 'asan'], 'timeout_seconds': 6*60, 'excluded_poll_engines': scenario_json.get('EXCLUDED_POLL_ENGINES', []) } for scenario_json in scenario_config.CXXLanguage().scenarios() if 'scalable' in scenario_json.get('CATEGORIES', []) ] + [ { 'name': 'json_run_localhost', 'shortname': 'json_run_localhost:%s_low_thread_count' % scenario_json['name'], 'args': ['--scenarios_json', _scenario_json_string(scenario_json, True)], 'ci_platforms': ['linux'], 'platforms': ['linux'], 'flaky': False, 'language': 'c++', 'boringssl': True, 'defaults': 'boringssl', 'cpu_cost': guess_cpu(scenario_json, True), 'exclude_configs': sorted(c for c in configs_from_yaml if c not in ('tsan', 'asan')), 'timeout_seconds': 6*60, 'excluded_poll_engines': scenario_json.get('EXCLUDED_POLL_ENGINES', []) } for scenario_json in scenario_config.CXXLanguage().scenarios() if 'scalable' in scenario_json.get('CATEGORIES', []) ] })
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 14, 23, 199, 199, 3, 1898, 6900, 30700, 11462, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 2022, 199, 646, 20988, 199, 646, 5145, 199, 646, 984, 199, 646, 747, 199, 646, 8864, 199, 199, 1065, 63, 2219, 63, 1231, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 272, 747, 14, 515, 14, 3475, 8, 1274, 14, 3020, 59, 16, 2522, 272, 283, 29866, 2537, 15, 1065, 63, 2219, 1333, 199, 1274, 14, 515, 14, 740, 8, 1065, 63, 2219, 63, 1231, 9, 199, 199, 646, 10238, 14, 13444, 63, 888, 465, 15728, 63, 888, 199, 199, 7532, 63, 504, 63, 5963, 275, 8864, 14, 912, 8, 1490, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 1274, 14, 3020, 59, 16, 2522, 283, 29866, 1506, 14, 5963, 7058, 459, 7532, 2278, 1612, 342, 199, 199, 318, 31173, 63, 13444, 8, 13444, 63, 1001, 12, 365, 63, 1086, 290, 304, 523, 327, 32464, 2633, 370, 664, 7377, 511, 5431, 523, 15728, 63, 1001, 275, 1211, 8, 13444, 63, 1001, 9, 523, 15728, 63, 1001, 459, 10669, 384, 63, 4515, 418, 275, 378, 523, 15728, 63, 1001, 459, 11861, 63, 4515, 418, 275, 413, 523, 734, 18126, 63, 4599, 1259, 63, 3015, 374, 269, 275, 413, 523, 340, 365, 63, 1086, 290, 436, 334, 489, 15728, 63, 1001, 459, 1258, 63, 888, 2545, 1258, 63, 466, 418, 508, 283, 22012, 63, 9901, 7, 503, 489, 15728, 63, 1001, 459, 1000, 63, 888, 2545, 1000, 63, 466, 418, 508, 283, 22012, 63, 6613, 735, 272, 734, 18126, 63, 4599, 1259, 63, 3015, 374, 269, 275, 1616, 523, 15728, 63, 1001, 459, 1258, 63, 888, 2545, 548, 18126, 63, 4599, 1259, 63, 529, 63, 2775, 418, 275, 1390, 8, 17, 12, 489, 1109, 8, 13444, 63, 1001, 459, 1258, 63, 888, 2545, 548, 18126, 63, 4599, 1259, 63, 529, 63, 2775, 418, 1182, 734, 18126, 63, 4599, 1259, 63, 3015, 374, 269, 430, 523, 372, 15728, 63, 1001, 199, 199, 318, 485, 13444, 63, 1001, 63, 875, 8, 13444, 63, 1001, 12, 365, 63, 1086, 290, 304, 523, 28444, 63, 1001, 275, 791, 32225, 356, 359, 13444, 63, 888, 14, 2168, 63, 2865, 2625, 63, 955, 8, 6552, 323, 63, 13444, 8, 13444, 63, 1001, 12, 365, 63, 1086, 290, 430, 9420, 523, 372, 2022, 14, 4180, 8, 32225, 63, 1001, 9, 199, 199, 318, 7183, 63, 2427, 8, 13444, 63, 1001, 12, 2382, 12, 365, 63, 1086, 290, 304, 523, 15728, 63, 1001, 275, 31173, 63, 13444, 8, 13444, 63, 1001, 12, 365, 63, 1086, 290, 9, 523, 340, 15728, 63, 1001, 13890, 83, 63, 888, 7, 450, 2382, 2733, 5, 83, 63, 466, 7, 450, 2382, 61, 508, 283, 26222, 6389, 4970, 83, 7, 450, 2382, 14, 4142, 837, 272, 372, 15728, 63, 1001, 13890, 83, 63, 888, 7, 450, 2382, 1055, 362, 360, 4146, 4970, 83, 63, 6962, 7, 450, 2382, 12, 378, 9, 523, 372, 15728, 63, 1001, 459, 1258, 63, 888, 2545, 548, 18126, 63, 4599, 1259, 63, 529, 63, 2775, 418, 627, 15728, 63, 1001, 459, 1258, 63, 888, 2545, 1258, 63, 6324, 418, 199, 199, 318, 9519, 63, 3541, 8, 13444, 63, 1001, 12, 365, 63, 1086, 290, 304, 523, 1890, 275, 7183, 63, 2427, 8, 13444, 63, 1001, 12, 283, 1258, 297, 365, 63, 1086, 290, 9, 523, 1654, 275, 7183, 63, 2427, 8, 13444, 63, 1001, 12, 283, 1000, 297, 365, 63, 1086, 290, 9, 523, 327, 1852, 376, 9697, 9519, 340, 663, 370, 2599, 13, 13552, 523, 327, 3595, 314, 1568, 402, 314, 29537, 4454, 781, 1172, 367, 4137, 2295, 523, 340, 1890, 508, 378, 503, 1654, 508, 378, 26, 372, 283, 10457, 7, 523, 372, 334, 13444, 63, 1001, 459, 1507, 63, 14555, 418, 627, 1890, 435, 881, 15728, 63, 1001, 459, 1507, 63, 5871, 418, 627, 1654, 9, 199, 199, 1361, 8864, 14, 2724, 2561, 523, 283, 2219, 356, 359, 272, 469, 489, 283, 354, 356, 283, 1001, 63, 1065, 63, 5967, 297, 489, 283, 3612, 354, 356, 283, 1001, 63, 1065, 63, 5967, 2689, 83, 7, 450, 15728, 63, 1001, 459, 354, 995, 489, 283, 589, 356, 14574, 32225, 63, 1001, 297, 485, 13444, 63, 1001, 63, 875, 8, 13444, 63, 1001, 12, 756, 4360, 489, 283, 559, 63, 19601, 356, 788, 5135, 995, 489, 283, 19601, 356, 788, 5135, 995, 489, 283, 14163, 10562, 356, 756, 12, 489, 283, 3671, 356, 283, 67, 31249, 489, 283, 66, 6854, 4266, 356, 715, 12, 489, 283, 4322, 356, 283, 66, 6854, 4266, 297, 489, 283, 3541, 63, 6336, 356, 9519, 63, 3541, 8, 13444, 63, 1001, 12, 756, 395, 489, 283, 5473, 63, 7532, 356, 788, 1086, 290, 297, 283, 305, 290, 995, 489, 283, 2593, 63, 4515, 356, 1227, 10, 2259, 12, 489, 283, 12144, 63, 6843, 63, 30378, 356, 15728, 63, 1001, 14, 362, 360, 29647, 53, 8280, 63, 16428, 63, 742, 39, 568, 654, 297, 3073, 272, 789, 272, 367, 15728, 63, 1001, 315, 15728, 63, 888, 14, 12206, 8493, 1252, 32225, 342, 272, 340, 283, 4732, 461, 7, 315, 15728, 63, 1001, 14, 362, 360, 35, 12649, 28743, 297, 3073, 523, 1622, 435, 359, 272, 469, 489, 283, 354, 356, 283, 1001, 63, 1065, 63, 5967, 297, 489, 283, 3612, 354, 356, 283, 1001, 63, 1065, 63 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 14, 23, 199, 199, 3, 1898, 6900, 30700, 11462, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 2022, 199, 646, 20988, 199, 646, 5145, 199, 646, 984, 199, 646, 747, 199, 646, 8864, 199, 199, 1065, 63, 2219, 63, 1231, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 272, 747, 14, 515, 14, 3475, 8, 1274, 14, 3020, 59, 16, 2522, 272, 283, 29866, 2537, 15, 1065, 63, 2219, 1333, 199, 1274, 14, 515, 14, 740, 8, 1065, 63, 2219, 63, 1231, 9, 199, 199, 646, 10238, 14, 13444, 63, 888, 465, 15728, 63, 888, 199, 199, 7532, 63, 504, 63, 5963, 275, 8864, 14, 912, 8, 1490, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 1274, 14, 3020, 59, 16, 2522, 283, 29866, 1506, 14, 5963, 7058, 459, 7532, 2278, 1612, 342, 199, 199, 318, 31173, 63, 13444, 8, 13444, 63, 1001, 12, 365, 63, 1086, 290, 304, 523, 327, 32464, 2633, 370, 664, 7377, 511, 5431, 523, 15728, 63, 1001, 275, 1211, 8, 13444, 63, 1001, 9, 523, 15728, 63, 1001, 459, 10669, 384, 63, 4515, 418, 275, 378, 523, 15728, 63, 1001, 459, 11861, 63, 4515, 418, 275, 413, 523, 734, 18126, 63, 4599, 1259, 63, 3015, 374, 269, 275, 413, 523, 340, 365, 63, 1086, 290, 436, 334, 489, 15728, 63, 1001, 459, 1258, 63, 888, 2545, 1258, 63, 466, 418, 508, 283, 22012, 63, 9901, 7, 503, 489, 15728, 63, 1001, 459, 1000, 63, 888, 2545, 1000, 63, 466, 418, 508, 283, 22012, 63, 6613, 735, 272, 734, 18126, 63, 4599, 1259, 63, 3015, 374, 269, 275, 1616, 523, 15728, 63, 1001, 459, 1258, 63, 888, 2545, 548, 18126, 63, 4599, 1259, 63, 529, 63, 2775, 418, 275, 1390, 8, 17, 12, 489, 1109, 8, 13444, 63, 1001, 459, 1258, 63, 888, 2545, 548, 18126, 63, 4599, 1259, 63, 529, 63, 2775, 418, 1182, 734, 18126, 63, 4599, 1259, 63, 3015, 374, 269, 430, 523, 372, 15728, 63, 1001, 199, 199, 318, 485, 13444, 63, 1001, 63, 875, 8, 13444, 63, 1001, 12, 365, 63, 1086, 290, 304, 523, 28444, 63, 1001, 275, 791, 32225, 356, 359, 13444, 63, 888, 14, 2168, 63, 2865, 2625, 63, 955, 8, 6552, 323, 63, 13444, 8, 13444, 63, 1001, 12, 365, 63, 1086, 290, 430, 9420, 523, 372, 2022, 14, 4180, 8, 32225, 63, 1001, 9, 199, 199, 318, 7183, 63, 2427, 8, 13444, 63, 1001, 12, 2382, 12, 365, 63, 1086, 290, 304, 523, 15728, 63, 1001, 275, 31173, 63, 13444, 8, 13444, 63, 1001, 12, 365, 63, 1086, 290, 9, 523, 340, 15728, 63, 1001, 13890, 83, 63, 888, 7, 450, 2382, 2733, 5, 83, 63, 466, 7, 450, 2382, 61, 508, 283, 26222, 6389, 4970, 83, 7, 450, 2382, 14, 4142, 837, 272, 372, 15728, 63, 1001, 13890, 83, 63, 888, 7, 450, 2382, 1055, 362, 360, 4146, 4970, 83, 63, 6962, 7, 450, 2382, 12, 378, 9, 523, 372, 15728, 63, 1001, 459, 1258, 63, 888, 2545, 548, 18126, 63, 4599, 1259, 63, 529, 63, 2775, 418, 627, 15728, 63, 1001, 459, 1258, 63, 888, 2545, 1258, 63, 6324, 418, 199, 199, 318, 9519, 63, 3541, 8, 13444, 63, 1001, 12, 365, 63, 1086, 290, 304, 523, 1890, 275, 7183, 63, 2427, 8, 13444, 63, 1001, 12, 283, 1258, 297, 365, 63, 1086, 290, 9, 523, 1654, 275, 7183, 63, 2427, 8, 13444, 63, 1001, 12, 283, 1000, 297, 365, 63, 1086, 290, 9, 523, 327, 1852, 376, 9697, 9519, 340, 663, 370, 2599, 13, 13552, 523, 327, 3595, 314, 1568, 402, 314, 29537, 4454, 781, 1172, 367, 4137, 2295, 523, 340, 1890, 508, 378, 503, 1654, 508, 378, 26, 372, 283, 10457, 7, 523, 372, 334, 13444, 63, 1001, 459, 1507, 63, 14555, 418, 627, 1890, 435, 881, 15728, 63, 1001, 459, 1507, 63, 5871, 418, 627, 1654, 9, 199, 199, 1361, 8864, 14, 2724, 2561, 523, 283, 2219, 356, 359, 272, 469, 489, 283, 354, 356, 283, 1001, 63, 1065, 63, 5967, 297, 489, 283, 3612, 354, 356, 283, 1001, 63, 1065, 63, 5967, 2689, 83, 7, 450, 15728, 63, 1001, 459, 354, 995, 489, 283, 589, 356, 14574, 32225, 63, 1001, 297, 485, 13444, 63, 1001, 63, 875, 8, 13444, 63, 1001, 12, 756, 4360, 489, 283, 559, 63, 19601, 356, 788, 5135, 995, 489, 283, 19601, 356, 788, 5135, 995, 489, 283, 14163, 10562, 356, 756, 12, 489, 283, 3671, 356, 283, 67, 31249, 489, 283, 66, 6854, 4266, 356, 715, 12, 489, 283, 4322, 356, 283, 66, 6854, 4266, 297, 489, 283, 3541, 63, 6336, 356, 9519, 63, 3541, 8, 13444, 63, 1001, 12, 756, 395, 489, 283, 5473, 63, 7532, 356, 788, 1086, 290, 297, 283, 305, 290, 995, 489, 283, 2593, 63, 4515, 356, 1227, 10, 2259, 12, 489, 283, 12144, 63, 6843, 63, 30378, 356, 15728, 63, 1001, 14, 362, 360, 29647, 53, 8280, 63, 16428, 63, 742, 39, 568, 654, 297, 3073, 272, 789, 272, 367, 15728, 63, 1001, 315, 15728, 63, 888, 14, 12206, 8493, 1252, 32225, 342, 272, 340, 283, 4732, 461, 7, 315, 15728, 63, 1001, 14, 362, 360, 35, 12649, 28743, 297, 3073, 523, 1622, 435, 359, 272, 469, 489, 283, 354, 356, 283, 1001, 63, 1065, 63, 5967, 297, 489, 283, 3612, 354, 356, 283, 1001, 63, 1065, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
barseghyanartur/python-social-auth
social/tests/backends/test_skyrock.py
92
1343
import json from social.p3 import urlencode from social.tests.backends.oauth import OAuth1Test class SkyrockOAuth1Test(OAuth1Test): backend_path = 'social.backends.skyrock.SkyrockOAuth' user_data_url = 'https://api.skyrock.com/v2/user/get.json' expected_username = 'foobar' access_token_body = json.dumps({ 'access_token': 'foobar', 'token_type': 'bearer' }) request_token_body = urlencode({ 'oauth_token_secret': 'foobar-secret', 'oauth_token': 'foobar', }) user_data_body = json.dumps({ 'locale': 'en_US', 'city': '', 'has_blog': False, 'web_messager_enabled': True, 'email': 'foo@bar.com', 'username': 'foobar', 'firstname': 'Foo', 'user_url': '', 'address1': '', 'address2': '', 'has_profile': False, 'allow_messages_from': 'everybody', 'is_online': False, 'postalcode': '', 'lang': 'en', 'id_user': 10101010, 'name': 'Bar', 'gender': 0, 'avatar_url': 'http://www.skyrock.com/img/avatars/default-0.jpg', 'nb_friends': 0, 'country': 'US', 'birth_date': '1980-06-10' }) def test_login(self): self.do_login() def test_partial_pipeline(self): self.do_partial_pipeline()
bsd-3-clause
[ 646, 2022, 199, 199, 504, 20295, 14, 80, 19, 492, 16511, 199, 504, 20295, 14, 2219, 14, 7765, 14, 6126, 492, 11715, 17, 774, 421, 199, 533, 428, 10562, 24892, 12906, 17, 774, 8, 12906, 17, 774, 304, 272, 4865, 63, 515, 275, 283, 13574, 14, 7765, 14, 12267, 24892, 14, 51, 10562, 24892, 12906, 7, 272, 922, 63, 576, 63, 633, 275, 283, 2859, 921, 1246, 14, 12267, 24892, 14, 957, 15, 86, 18, 15, 751, 15, 362, 14, 1001, 7, 272, 1420, 63, 2473, 275, 283, 9664, 7, 272, 2879, 63, 1418, 63, 2030, 275, 2022, 14, 4180, 2561, 267, 283, 2732, 63, 1418, 356, 283, 9664, 297, 267, 283, 1418, 63, 466, 356, 283, 1235, 21462, 7, 272, 3828, 272, 1056, 63, 1418, 63, 2030, 275, 16511, 2561, 267, 283, 6126, 63, 1418, 63, 4731, 356, 283, 9664, 13, 4731, 297, 267, 283, 6126, 63, 1418, 356, 283, 9664, 297, 272, 3828, 272, 922, 63, 576, 63, 2030, 275, 2022, 14, 4180, 2561, 267, 283, 5508, 356, 283, 287, 63, 1668, 297, 267, 283, 3690, 356, 3260, 267, 283, 1989, 63, 11486, 356, 756, 12, 267, 283, 2520, 63, 17091, 1456, 63, 3827, 356, 715, 12, 267, 283, 2123, 356, 283, 1421, 32, 1700, 14, 957, 297, 267, 283, 2473, 356, 283, 9664, 297, 267, 283, 25603, 356, 283, 5686, 297, 267, 283, 751, 63, 633, 356, 3260, 267, 283, 1562, 17, 356, 3260, 267, 283, 1562, 18, 356, 3260, 267, 283, 1989, 63, 2913, 356, 756, 12, 267, 283, 3306, 63, 3431, 63, 504, 356, 283, 14287, 2030, 297, 267, 283, 374, 63, 15178, 356, 756, 12, 267, 283, 31580, 600, 356, 3260, 267, 283, 4159, 356, 283, 287, 297, 267, 283, 344, 63, 751, 356, 413, 11502, 9523, 12, 267, 283, 354, 356, 283, 5281, 297, 267, 283, 15791, 356, 378, 12, 267, 283, 14584, 63, 633, 356, 283, 1014, 921, 1544, 14, 12267, 24892, 14, 957, 15, 4060, 15, 1214, 292, 4291, 15, 885, 13, 16, 14, 8476, 297, 267, 283, 4994, 63, 18024, 356, 378, 12, 267, 283, 6063, 356, 283, 1668, 297, 267, 283, 10907, 63, 602, 356, 283, 26981, 13, 1690, 13, 709, 7, 272, 3828, 339, 347, 511, 63, 2886, 8, 277, 304, 267, 291, 14, 1117, 63, 2886, 342, 339, 347, 511, 63, 6672, 63, 7379, 8, 277, 304, 267, 291, 14, 1117, 63, 6672, 63, 7379, 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 ]
[ 2022, 199, 199, 504, 20295, 14, 80, 19, 492, 16511, 199, 504, 20295, 14, 2219, 14, 7765, 14, 6126, 492, 11715, 17, 774, 421, 199, 533, 428, 10562, 24892, 12906, 17, 774, 8, 12906, 17, 774, 304, 272, 4865, 63, 515, 275, 283, 13574, 14, 7765, 14, 12267, 24892, 14, 51, 10562, 24892, 12906, 7, 272, 922, 63, 576, 63, 633, 275, 283, 2859, 921, 1246, 14, 12267, 24892, 14, 957, 15, 86, 18, 15, 751, 15, 362, 14, 1001, 7, 272, 1420, 63, 2473, 275, 283, 9664, 7, 272, 2879, 63, 1418, 63, 2030, 275, 2022, 14, 4180, 2561, 267, 283, 2732, 63, 1418, 356, 283, 9664, 297, 267, 283, 1418, 63, 466, 356, 283, 1235, 21462, 7, 272, 3828, 272, 1056, 63, 1418, 63, 2030, 275, 16511, 2561, 267, 283, 6126, 63, 1418, 63, 4731, 356, 283, 9664, 13, 4731, 297, 267, 283, 6126, 63, 1418, 356, 283, 9664, 297, 272, 3828, 272, 922, 63, 576, 63, 2030, 275, 2022, 14, 4180, 2561, 267, 283, 5508, 356, 283, 287, 63, 1668, 297, 267, 283, 3690, 356, 3260, 267, 283, 1989, 63, 11486, 356, 756, 12, 267, 283, 2520, 63, 17091, 1456, 63, 3827, 356, 715, 12, 267, 283, 2123, 356, 283, 1421, 32, 1700, 14, 957, 297, 267, 283, 2473, 356, 283, 9664, 297, 267, 283, 25603, 356, 283, 5686, 297, 267, 283, 751, 63, 633, 356, 3260, 267, 283, 1562, 17, 356, 3260, 267, 283, 1562, 18, 356, 3260, 267, 283, 1989, 63, 2913, 356, 756, 12, 267, 283, 3306, 63, 3431, 63, 504, 356, 283, 14287, 2030, 297, 267, 283, 374, 63, 15178, 356, 756, 12, 267, 283, 31580, 600, 356, 3260, 267, 283, 4159, 356, 283, 287, 297, 267, 283, 344, 63, 751, 356, 413, 11502, 9523, 12, 267, 283, 354, 356, 283, 5281, 297, 267, 283, 15791, 356, 378, 12, 267, 283, 14584, 63, 633, 356, 283, 1014, 921, 1544, 14, 12267, 24892, 14, 957, 15, 4060, 15, 1214, 292, 4291, 15, 885, 13, 16, 14, 8476, 297, 267, 283, 4994, 63, 18024, 356, 378, 12, 267, 283, 6063, 356, 283, 1668, 297, 267, 283, 10907, 63, 602, 356, 283, 26981, 13, 1690, 13, 709, 7, 272, 3828, 339, 347, 511, 63, 2886, 8, 277, 304, 267, 291, 14, 1117, 63, 2886, 342, 339, 347, 511, 63, 6672, 63, 7379, 8, 277, 304, 267, 291, 14, 1117, 63, 6672, 63, 7379, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sejust/pykit
proc/proc.py
2
3298
#!/usr/bin/env python2 # coding: utf-8 import errno import logging import os import subprocess32 logger = logging.getLogger(__name__) class ProcError(Exception): def __init__(self, returncode, out, err, cmd, arguments, options): super(ProcError, self).__init__(returncode, out, err, cmd, arguments, options) self.returncode = returncode self.out = out self.err = err self.command = cmd self.arguments = arguments self.options = options def command(cmd, *arguments, **options): close_fds = options.get('close_fds', True) cwd = options.get('cwd', None) shell = options.get('shell', False) env = options.get('env', None) if env is not None: env = dict(os.environ, **env) stdin = options.get('stdin', None) subproc = subprocess32.Popen([cmd] + list(arguments), close_fds=close_fds, shell=shell, cwd=cwd, env=env, stdin=subprocess32.PIPE, stdout=subprocess32.PIPE, stderr=subprocess32.PIPE, ) out, err = subproc.communicate(input=stdin) subproc.wait() return (subproc.returncode, out, err) def command_ex(cmd, *arguments, **options): returncode, out, err = command(cmd, *arguments, **options) if returncode != 0: raise ProcError(returncode, out, err, cmd, arguments, options) return returncode, out, err def shell_script(script_str, **options): options['stdin'] = script_str return command('sh', **options) def _waitpid(pid): while True: try: os.waitpid(pid, 0) break except OSError as e: # In case we encountered an OSError due to EINTR (which is # caused by a SIGINT or SIGTERM signal during # os.waitpid()), we simply ignore it and enter the next # iteration of the loop, waiting for the child to end. In # any other case, this is some other unexpected OS error, # which we don't want to catch, so we re-raise those ones. if e.errno != errno.EINTR: raise def _close_fds(): try: max_fd = os.sysconf("SC_OPEN_MAX") except ValueError: max_fd = 65536 for i in range(max_fd): try: os.close(i) except OSError: pass def start_process(cmd, target, env, *args): try: pid = os.fork() except OSError as e: logger.error(repr(e) + ' while fork') raise if pid == 0: _close_fds() args = list(args) env = dict(os.environ, **env) args.append(env) try: os.execlpe(cmd, cmd, target, *args) except Exception: # we can do nothing when error in execlpe # don't logger here, logger need get GIL lock # children process may dead lock pass else: _waitpid(pid)
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 2803, 26, 2774, 13, 24, 199, 199, 646, 7554, 199, 646, 2050, 199, 646, 747, 199, 199, 646, 3873, 708, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 29625, 547, 8, 1726, 304, 339, 347, 636, 826, 721, 277, 12, 17630, 12, 734, 12, 2329, 12, 2088, 12, 2368, 12, 1511, 304, 398, 1613, 8, 15019, 547, 12, 291, 2843, 826, 721, 9913, 12, 3147, 734, 12, 3147, 2329, 12, 3147, 2088, 12, 3147, 2368, 12, 3147, 1511, 9, 398, 291, 14, 9913, 275, 17630, 267, 291, 14, 548, 275, 734, 267, 291, 14, 1508, 275, 2329, 267, 291, 14, 1531, 275, 2088, 267, 291, 14, 4958, 275, 2368, 267, 291, 14, 1419, 275, 1511, 421, 199, 318, 1414, 8, 1760, 12, 627, 4958, 12, 1011, 1419, 304, 339, 4002, 63, 14240, 275, 1511, 14, 362, 360, 1600, 63, 14240, 297, 715, 9, 272, 8288, 275, 1511, 14, 362, 360, 6525, 297, 488, 9, 272, 5218, 275, 1511, 14, 362, 360, 5641, 297, 756, 9, 272, 2589, 275, 1511, 14, 362, 360, 1813, 297, 488, 9, 272, 340, 2589, 365, 440, 488, 26, 267, 2589, 275, 1211, 8, 736, 14, 2314, 12, 1011, 1813, 9, 272, 9009, 275, 1511, 14, 362, 360, 6626, 297, 488, 9, 339, 1007, 4687, 275, 3873, 708, 14, 7942, 779, 1760, 61, 435, 769, 8, 4958, 395, 639, 4002, 63, 14240, 29, 1600, 63, 14240, 12, 639, 5218, 29, 5641, 12, 639, 8288, 29, 6525, 12, 639, 2589, 29, 1813, 12, 639, 9009, 29, 5781, 708, 14, 6089, 12, 639, 3839, 29, 5781, 708, 14, 6089, 12, 639, 4635, 29, 5781, 708, 14, 6089, 12, 776, 339, 734, 12, 2329, 275, 1007, 4687, 14, 10664, 8, 1210, 29, 6626, 9, 339, 1007, 4687, 14, 2573, 342, 339, 372, 334, 954, 4687, 14, 9913, 12, 734, 12, 2329, 9, 421, 199, 318, 1414, 63, 476, 8, 1760, 12, 627, 4958, 12, 1011, 1419, 304, 272, 17630, 12, 734, 12, 2329, 275, 1414, 8, 1760, 12, 627, 4958, 12, 1011, 1419, 9, 272, 340, 17630, 1137, 378, 26, 267, 746, 29625, 547, 8, 9913, 12, 734, 12, 2329, 12, 2088, 12, 2368, 12, 1511, 9, 339, 372, 17630, 12, 734, 12, 2329, 421, 199, 318, 5218, 63, 1579, 8, 1579, 63, 495, 12, 1011, 1419, 304, 272, 1511, 459, 6626, 418, 275, 2884, 63, 495, 272, 372, 1414, 360, 609, 297, 1011, 1419, 9, 421, 199, 318, 485, 2573, 3150, 8, 3150, 304, 272, 1830, 715, 26, 267, 862, 26, 288, 747, 14, 2573, 3150, 8, 3150, 12, 378, 9, 288, 2059, 267, 871, 6440, 465, 325, 26, 288, 327, 1010, 1930, 781, 14556, 376, 6440, 7037, 370, 662, 19652, 334, 6777, 365, 288, 327, 18104, 701, 282, 15522, 2919, 503, 15522, 16718, 4673, 5309, 288, 327, 747, 14, 2573, 3150, 4000, 781, 9329, 3686, 652, 436, 9509, 314, 2163, 288, 327, 8494, 402, 314, 4438, 12, 10923, 367, 314, 1982, 370, 1284, 14, 221, 1010, 288, 327, 1263, 1163, 1930, 12, 642, 365, 2005, 1163, 10537, 4403, 1125, 12, 288, 327, 1314, 781, 2793, 1133, 2934, 370, 8579, 12, 880, 781, 295, 13, 3730, 5204, 7869, 14, 288, 340, 325, 14, 7931, 1137, 7554, 14, 37, 19652, 26, 355, 746, 421, 199, 318, 485, 1600, 63, 14240, 837, 272, 862, 26, 267, 1390, 63, 2592, 275, 747, 14, 1274, 2190, 480, 5153, 63, 9935, 63, 4283, 531, 272, 871, 1722, 26, 267, 1390, 63, 2592, 275, 25980, 339, 367, 284, 315, 1425, 8, 988, 63, 2592, 304, 267, 862, 26, 288, 747, 14, 1600, 8, 73, 9, 267, 871, 6440, 26, 288, 986, 421, 199, 318, 1343, 63, 1412, 8, 1760, 12, 1347, 12, 2589, 12, 627, 589, 304, 339, 862, 26, 267, 4422, 275, 747, 14, 11796, 342, 272, 871, 6440, 465, 325, 26, 267, 2512, 14, 705, 8, 2722, 8, 69, 9, 435, 283, 1830, 14926, 358, 267, 746, 339, 340, 4422, 508, 378, 26, 267, 485, 1600, 63, 14240, 342, 267, 1249, 275, 769, 8, 589, 9, 267, 2589, 275, 1211, 8, 736, 14, 2314, 12, 1011, 1813, 9, 267, 1249, 14, 740, 8, 1813, 9, 267, 862, 26, 288, 747, 14, 5803, 429, 321, 8, 1760, 12, 2088, 12, 1347, 12, 627, 589, 9, 267, 871, 2186, 26, 288, 327, 781, 883, 886, 6548, 1380, 1125, 315, 14778, 429, 321, 288, 327, 2793, 1133, 2512, 2348, 12, 2512, 1929, 664, 598, 1193, 4650, 288, 327, 4978, 2112, 1443, 12314, 4650, 288, 986, 272, 587, 26, 267, 485, 2573, 3150, 8, 3150, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 2803, 26, 2774, 13, 24, 199, 199, 646, 7554, 199, 646, 2050, 199, 646, 747, 199, 199, 646, 3873, 708, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 29625, 547, 8, 1726, 304, 339, 347, 636, 826, 721, 277, 12, 17630, 12, 734, 12, 2329, 12, 2088, 12, 2368, 12, 1511, 304, 398, 1613, 8, 15019, 547, 12, 291, 2843, 826, 721, 9913, 12, 3147, 734, 12, 3147, 2329, 12, 3147, 2088, 12, 3147, 2368, 12, 3147, 1511, 9, 398, 291, 14, 9913, 275, 17630, 267, 291, 14, 548, 275, 734, 267, 291, 14, 1508, 275, 2329, 267, 291, 14, 1531, 275, 2088, 267, 291, 14, 4958, 275, 2368, 267, 291, 14, 1419, 275, 1511, 421, 199, 318, 1414, 8, 1760, 12, 627, 4958, 12, 1011, 1419, 304, 339, 4002, 63, 14240, 275, 1511, 14, 362, 360, 1600, 63, 14240, 297, 715, 9, 272, 8288, 275, 1511, 14, 362, 360, 6525, 297, 488, 9, 272, 5218, 275, 1511, 14, 362, 360, 5641, 297, 756, 9, 272, 2589, 275, 1511, 14, 362, 360, 1813, 297, 488, 9, 272, 340, 2589, 365, 440, 488, 26, 267, 2589, 275, 1211, 8, 736, 14, 2314, 12, 1011, 1813, 9, 272, 9009, 275, 1511, 14, 362, 360, 6626, 297, 488, 9, 339, 1007, 4687, 275, 3873, 708, 14, 7942, 779, 1760, 61, 435, 769, 8, 4958, 395, 639, 4002, 63, 14240, 29, 1600, 63, 14240, 12, 639, 5218, 29, 5641, 12, 639, 8288, 29, 6525, 12, 639, 2589, 29, 1813, 12, 639, 9009, 29, 5781, 708, 14, 6089, 12, 639, 3839, 29, 5781, 708, 14, 6089, 12, 639, 4635, 29, 5781, 708, 14, 6089, 12, 776, 339, 734, 12, 2329, 275, 1007, 4687, 14, 10664, 8, 1210, 29, 6626, 9, 339, 1007, 4687, 14, 2573, 342, 339, 372, 334, 954, 4687, 14, 9913, 12, 734, 12, 2329, 9, 421, 199, 318, 1414, 63, 476, 8, 1760, 12, 627, 4958, 12, 1011, 1419, 304, 272, 17630, 12, 734, 12, 2329, 275, 1414, 8, 1760, 12, 627, 4958, 12, 1011, 1419, 9, 272, 340, 17630, 1137, 378, 26, 267, 746, 29625, 547, 8, 9913, 12, 734, 12, 2329, 12, 2088, 12, 2368, 12, 1511, 9, 339, 372, 17630, 12, 734, 12, 2329, 421, 199, 318, 5218, 63, 1579, 8, 1579, 63, 495, 12, 1011, 1419, 304, 272, 1511, 459, 6626, 418, 275, 2884, 63, 495, 272, 372, 1414, 360, 609, 297, 1011, 1419, 9, 421, 199, 318, 485, 2573, 3150, 8, 3150, 304, 272, 1830, 715, 26, 267, 862, 26, 288, 747, 14, 2573, 3150, 8, 3150, 12, 378, 9, 288, 2059, 267, 871, 6440, 465, 325, 26, 288, 327, 1010, 1930, 781, 14556, 376, 6440, 7037, 370, 662, 19652, 334, 6777, 365, 288, 327, 18104, 701, 282, 15522, 2919, 503, 15522, 16718, 4673, 5309, 288, 327, 747, 14, 2573, 3150, 4000, 781, 9329, 3686, 652, 436, 9509, 314, 2163, 288, 327, 8494, 402, 314, 4438, 12, 10923, 367, 314, 1982, 370, 1284, 14, 221, 1010, 288, 327, 1263, 1163, 1930, 12, 642, 365, 2005, 1163, 10537, 4403, 1125, 12, 288, 327, 1314, 781, 2793, 1133, 2934, 370, 8579, 12, 880, 781, 295, 13, 3730, 5204, 7869, 14, 288, 340, 325, 14, 7931, 1137, 7554, 14, 37, 19652, 26, 355, 746, 421, 199, 318, 485, 1600, 63, 14240, 837, 272, 862, 26, 267, 1390, 63, 2592, 275, 747, 14, 1274, 2190, 480, 5153, 63, 9935, 63, 4283, 531, 272, 871, 1722, 26, 267, 1390, 63, 2592, 275, 25980, 339, 367, 284, 315, 1425, 8, 988, 63, 2592, 304, 267, 862, 26, 288, 747, 14, 1600, 8, 73, 9, 267, 871, 6440, 26, 288, 986, 421, 199, 318, 1343, 63, 1412, 8, 1760, 12, 1347, 12, 2589, 12, 627, 589, 304, 339, 862, 26, 267, 4422, 275, 747, 14, 11796, 342, 272, 871, 6440, 465, 325, 26, 267, 2512, 14, 705, 8, 2722, 8, 69, 9, 435, 283, 1830, 14926, 358, 267, 746, 339, 340, 4422, 508, 378, 26, 267, 485, 1600, 63, 14240, 342, 267, 1249, 275, 769, 8, 589, 9, 267, 2589, 275, 1211, 8, 736, 14, 2314, 12, 1011, 1813, 9, 267, 1249, 14, 740, 8, 1813, 9, 267, 862, 26, 288, 747, 14, 5803, 429, 321, 8, 1760, 12, 2088, 12, 1347, 12, 627, 589, 9, 267, 871, 2186, 26, 288, 327, 781, 883, 886, 6548, 1380, 1125, 315, 14778, 429, 321, 288, 327, 2793, 1133, 2512, 2348, 12, 2512, 1929, 664, 598, 1193, 4650, 288, 327, 4978, 2112, 1443, 12314, 4650, 288, 986, 272, 587, 26, 267, 485, 2573, 3150, 8, 3150, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Awayet/twitter_ebooks
log.py
1
2954
#!/usr/bin/env python # -*- coding: UTF-8 -*- import sys import escape from time import gmtime, strftime, time import sqlite3 from traceback import format_exc import config import os htime = strftime("%a %Y-%m-%d %H:%M:%S%z",gmtime()) utime = int(time()) def print_message(_body, _section, _level, _time=""): try: if _time: _time = _time + " " _stdmsg = "{0}{4}{1} - {2}: \"{3}\"" + escape.ansi_reset + "\n" if _level == "debug": sys.stderr.write(_stdmsg.format(escape.ansi_fg_blue, _section, _level, _body, _time)) elif _level == "info": sys.stderr.write(_stdmsg.format(escape.ansi_fg_cyan, _section, _level, _body, _time)) elif _level == "warning": sys.stderr.write(_stdmsg.format(escape.ansi_fg_hiyellow, _section, _level, _body, _time)) elif _level == "error": sys.stderr.write(_stdmsg.format((escape.ansi_bg_black+escape.ansi_fg_red), _section, _level, _body, _time)) elif _level == "critical": sys.stderr.write(_stdmsg.format((escape.ansi_fg_hiyellow+escape.ansi_bg_red), _section, _level, _body, _time)) else: sys.stderr.write(_stdmsg.format(escape.ansi_fg_hiyellow, _section, ("Nonstandard level: " + _level), _body, _time)) except: log("Could not print from log", "log.print_message", "error") def log(_body, _section="none", _level="info"): try: print_message(_body, _section, _level) import db db.c.execute("insert into log values (?, ?, ?, ?, ?)", (utime, htime, _section, _body, _level)) db.dbase.commit() except: try: _log = open(os.path.join(config.path, "aux.log"), "at") _log.write("{}: {} - {}: \"{}\"\n".format(htime, _section, _level, _body)) _log.write("log.log - critical: Could not log \"{}\" to \"{}\".\nTraceback:\n{}\n".format(_body, _section, format_exc())) _log.close() sys.stderr.write("{}Could not log \"{}\" from \"{}\" to SQLite log.\n{}{} -- Written to auxillary log.{}\n".format(escape.ansi_fg_red, _body, _section, format_exc(), escape.ansi_fg_yellow, escape.ansi_reset)) except: sys.stderr.write("{}Could not log \"{}\" to \"{}\".\n{}\nAdditionally, the auxillary log could not be written to!{}\n".format(escape.ansi_fg_red, _body, _section, format_exc(), escape.ansi_reset)) def log_print(_format="plain"): try: if format == "csv": print "udate,hdate,name,data,level" import db db.c.execute("select * from log order by udate") for _row in db.c: _udate = _row[0] _hdate = _row[1] _section = _row[2] _body = _row[3] _level = _row[4] if _format == "csv": print "{},{},{},{},{}\n".format(str(_udate),_hdate,_name,_data,_level) else: print_message(_body, _section, _level, _hdate) except: log("Log could not be printed.\n{}".format(format_exc()), "log.log_print", "warning") def log_delete(): try: db.c.execute("delete from log") log("Log cleared", _name="clog", _level="information", _quiet=False) except: log("Log could not be cleared.\n{}".format(format_exc()), "log.log_delete", "error")
bsd-2-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 9094, 13, 24, 1882, 199, 199, 646, 984, 199, 646, 4772, 199, 504, 900, 492, 486, 8180, 12, 14053, 12, 900, 199, 646, 11723, 19, 199, 504, 5190, 492, 1475, 63, 2804, 199, 646, 1101, 199, 646, 747, 199, 199, 72, 521, 275, 14053, 3647, 65, 450, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 5, 90, 401, 22227, 1012, 199, 24043, 275, 1109, 8, 521, 1012, 199, 199, 318, 870, 63, 1188, 1547, 2030, 12, 485, 2792, 12, 485, 1896, 12, 485, 521, 17364, 507, 198, 893, 26, 686, 198, 692, 485, 521, 26, 1585, 198, 63, 521, 275, 485, 521, 435, 298, 298, 686, 198, 63, 1516, 1328, 275, 5310, 16, 8847, 20, 8847, 17, 93, 446, 469, 18, 9160, 8441, 91, 19, 4988, 341, 435, 4772, 14, 22204, 63, 3958, 435, 1867, 78, 2, 686, 198, 692, 221, 485, 1896, 508, 298, 1757, 582, 984, 14, 3083, 14, 952, 1547, 1516, 1328, 14, 908, 8, 3765, 14, 22204, 63, 9681, 63, 6304, 12, 485, 2792, 12, 485, 1896, 12, 485, 2030, 12, 485, 521, 430, 686, 198, 4164, 221, 485, 1896, 508, 298, 815, 582, 984, 14, 3083, 14, 952, 1547, 1516, 1328, 14, 908, 8, 3765, 14, 22204, 63, 9681, 63, 28291, 12, 485, 2792, 12, 485, 1896, 12, 485, 2030, 12, 485, 521, 430, 686, 198, 4164, 221, 485, 1896, 508, 298, 3764, 582, 984, 14, 3083, 14, 952, 1547, 1516, 1328, 14, 908, 8, 3765, 14, 22204, 63, 9681, 63, 5812, 14514, 12, 485, 2792, 12, 485, 1896, 12, 485, 2030, 12, 485, 521, 430, 686, 198, 4164, 221, 485, 1896, 508, 298, 705, 582, 984, 14, 3083, 14, 952, 1547, 1516, 1328, 14, 908, 1332, 3765, 14, 22204, 63, 6856, 63, 8399, 11, 3765, 14, 22204, 63, 9681, 63, 581, 395, 485, 2792, 12, 485, 1896, 12, 485, 2030, 12, 485, 521, 430, 686, 198, 4164, 221, 485, 1896, 508, 298, 13138, 582, 984, 14, 3083, 14, 952, 1547, 1516, 1328, 14, 908, 1332, 3765, 14, 22204, 63, 9681, 63, 5812, 14514, 11, 3765, 14, 22204, 63, 6856, 63, 581, 395, 485, 2792, 12, 485, 1896, 12, 485, 2030, 12, 485, 521, 430, 686, 198, 2836, 26, 984, 14, 3083, 14, 952, 1547, 1516, 1328, 14, 908, 8, 3765, 14, 22204, 63, 9681, 63, 5812, 14514, 12, 485, 2792, 12, 1689, 6932, 6807, 2166, 26, 298, 435, 485, 1896, 395, 485, 2030, 12, 485, 521, 430, 507, 198, 2590, 26, 686, 198, 793, 480, 6531, 440, 870, 687, 943, 401, 298, 793, 14, 1361, 63, 1188, 401, 298, 705, 531, 199, 199, 318, 943, 1547, 2030, 12, 485, 2792, 628, 3592, 401, 485, 1896, 628, 815, 2349, 199, 198, 893, 26, 507, 198, 1361, 63, 1188, 1547, 2030, 12, 485, 2792, 12, 485, 1896, 9, 507, 198, 646, 1592, 507, 198, 697, 14, 67, 14, 2526, 480, 3176, 1901, 943, 1338, 7558, 12, 21259, 21259, 21259, 5805, 4186, 334, 24043, 12, 394, 521, 12, 485, 2792, 12, 485, 2030, 12, 485, 1896, 430, 507, 198, 697, 14, 697, 482, 14, 3543, 342, 199, 198, 2590, 26, 507, 198, 893, 26, 686, 198, 63, 793, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 888, 14, 515, 12, 298, 10962, 14, 793, 1288, 298, 292, 531, 686, 198, 63, 793, 14, 952, 20794, 26, 1052, 446, 24702, 8441, 2440, 13356, 78, 1674, 908, 8, 72, 521, 12, 485, 2792, 12, 485, 1896, 12, 485, 2030, 430, 686, 198, 63, 793, 14, 952, 480, 793, 14, 793, 446, 19698, 26, 18615, 440, 943, 8441, 2440, 4451, 370, 8441, 24423, 1674, 60, 78, 15905, 3427, 78, 24423, 78, 1674, 908, 1547, 2030, 12, 485, 2792, 12, 1475, 63, 2804, 4059, 686, 198, 63, 793, 14, 1600, 342, 686, 198, 1274, 14, 3083, 14, 952, 20794, 6531, 440, 943, 8441, 2440, 4451, 687, 8441, 2440, 4451, 370, 19245, 943, 3134, 78, 2440, 2440, 1553, 27694, 370, 11593, 778, 695, 943, 14, 24423, 78, 1674, 908, 8, 3765, 14, 22204, 63, 9681, 63, 581, 12, 485, 2030, 12, 485, 2792, 12, 1475, 63, 2804, 1062, 4772, 14, 22204, 63, 9681, 63, 14514, 12, 4772, 14, 22204, 63, 3958, 430, 507, 198, 2590, 26, 686, 198, 1274, 14, 3083, 14, 952, 20794, 6531, 440, 943, 8441, 2440, 4451, 370, 8441, 24423, 1674, 60, 78, 24423, 78, 2767, 22565, 12, 314, 11593, 778, 695, 943, 4293, 440, 506, 5313, 370, 1, 24423, 78, 1674, 908, 8, 3765, 14, 22204, 63, 9681, 63, 581, 12, 485, 2030, 12, 485, 2792, 12, 1475, 63, 2804, 1062, 4772, 14, 22204, 63, 3958, 430, 199, 199, 318, 943, 63, 1361, 1547, 908, 628, 6104, 2349, 199, 198, 893, 26, 507, 198, 692, 1475, 508, 298, 4737, 582, 686, 198, 1361, 298, 85, 602, 12, 72, 602, 12, 354, 12, 576, 12, 1896, 2, 507, 198, 646, 1592, 507, 198, 697, 14, 67, 14, 2526, 480, 2416, 627, 687, 943, 1865, 701, 399, 602, 531, 507, 198, 509, 485, 1143, 315, 1592, 14, 67, 26, 686, 198, 63, 85, 602, 275, 485, 1143, 59, 16, 61, 686, 198, 63, 72, 602, 275, 485, 1143, 59, 17, 61, 686, 198, 63, 2792, 275, 485, 1143, 59, 18, 61, 686, 198, 63, 2030, 275, 485, 1143, 59, 19, 61, 686, 198, 63, 1896, 275, 485, 1143, 59, 20, 61, 686, 198, 692, 485, 908, 508, 298, 4737, 582, 1585, 198, 1361, 5310, 1386, 27125, 27125, 27125, 24423, 78, 1674, 908, 8, 495, 1547, 85, 602, 395, 63, 72, 602, 16987, 354, 16987, 576, 16987, 1896, 9, 686, 198, 2836, 26, 1585, 198, 1361, 63, 1188, 1547, 2030, 12, 485, 2792, 12, 485, 1896, 12, 485, 72, 602, 9, 421, 198, 2590, 26, 507, 198, 793, 480, 2445, 4293, 440, 506, 12487, 3134, 78, 13536, 908, 8, 908, 63, 2804, 4000, 298, 793, 14, 793, 63, 1361, 401, 298, 3764, 531, 199, 199, 318, 943, 63, 1807, 837, 199, 198, 893, 26, 507, 198, 697, 14, 67, 14, 2526, 480, 1807, 687, 943, 531, 507, 198, 793, 480, 2445, 20518, 401, 485, 354, 628, 67, 793, 401 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 9094, 13, 24, 1882, 199, 199, 646, 984, 199, 646, 4772, 199, 504, 900, 492, 486, 8180, 12, 14053, 12, 900, 199, 646, 11723, 19, 199, 504, 5190, 492, 1475, 63, 2804, 199, 646, 1101, 199, 646, 747, 199, 199, 72, 521, 275, 14053, 3647, 65, 450, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 5, 90, 401, 22227, 1012, 199, 24043, 275, 1109, 8, 521, 1012, 199, 199, 318, 870, 63, 1188, 1547, 2030, 12, 485, 2792, 12, 485, 1896, 12, 485, 521, 17364, 507, 198, 893, 26, 686, 198, 692, 485, 521, 26, 1585, 198, 63, 521, 275, 485, 521, 435, 298, 298, 686, 198, 63, 1516, 1328, 275, 5310, 16, 8847, 20, 8847, 17, 93, 446, 469, 18, 9160, 8441, 91, 19, 4988, 341, 435, 4772, 14, 22204, 63, 3958, 435, 1867, 78, 2, 686, 198, 692, 221, 485, 1896, 508, 298, 1757, 582, 984, 14, 3083, 14, 952, 1547, 1516, 1328, 14, 908, 8, 3765, 14, 22204, 63, 9681, 63, 6304, 12, 485, 2792, 12, 485, 1896, 12, 485, 2030, 12, 485, 521, 430, 686, 198, 4164, 221, 485, 1896, 508, 298, 815, 582, 984, 14, 3083, 14, 952, 1547, 1516, 1328, 14, 908, 8, 3765, 14, 22204, 63, 9681, 63, 28291, 12, 485, 2792, 12, 485, 1896, 12, 485, 2030, 12, 485, 521, 430, 686, 198, 4164, 221, 485, 1896, 508, 298, 3764, 582, 984, 14, 3083, 14, 952, 1547, 1516, 1328, 14, 908, 8, 3765, 14, 22204, 63, 9681, 63, 5812, 14514, 12, 485, 2792, 12, 485, 1896, 12, 485, 2030, 12, 485, 521, 430, 686, 198, 4164, 221, 485, 1896, 508, 298, 705, 582, 984, 14, 3083, 14, 952, 1547, 1516, 1328, 14, 908, 1332, 3765, 14, 22204, 63, 6856, 63, 8399, 11, 3765, 14, 22204, 63, 9681, 63, 581, 395, 485, 2792, 12, 485, 1896, 12, 485, 2030, 12, 485, 521, 430, 686, 198, 4164, 221, 485, 1896, 508, 298, 13138, 582, 984, 14, 3083, 14, 952, 1547, 1516, 1328, 14, 908, 1332, 3765, 14, 22204, 63, 9681, 63, 5812, 14514, 11, 3765, 14, 22204, 63, 6856, 63, 581, 395, 485, 2792, 12, 485, 1896, 12, 485, 2030, 12, 485, 521, 430, 686, 198, 2836, 26, 984, 14, 3083, 14, 952, 1547, 1516, 1328, 14, 908, 8, 3765, 14, 22204, 63, 9681, 63, 5812, 14514, 12, 485, 2792, 12, 1689, 6932, 6807, 2166, 26, 298, 435, 485, 1896, 395, 485, 2030, 12, 485, 521, 430, 507, 198, 2590, 26, 686, 198, 793, 480, 6531, 440, 870, 687, 943, 401, 298, 793, 14, 1361, 63, 1188, 401, 298, 705, 531, 199, 199, 318, 943, 1547, 2030, 12, 485, 2792, 628, 3592, 401, 485, 1896, 628, 815, 2349, 199, 198, 893, 26, 507, 198, 1361, 63, 1188, 1547, 2030, 12, 485, 2792, 12, 485, 1896, 9, 507, 198, 646, 1592, 507, 198, 697, 14, 67, 14, 2526, 480, 3176, 1901, 943, 1338, 7558, 12, 21259, 21259, 21259, 5805, 4186, 334, 24043, 12, 394, 521, 12, 485, 2792, 12, 485, 2030, 12, 485, 1896, 430, 507, 198, 697, 14, 697, 482, 14, 3543, 342, 199, 198, 2590, 26, 507, 198, 893, 26, 686, 198, 63, 793, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 888, 14, 515, 12, 298, 10962, 14, 793, 1288, 298, 292, 531, 686, 198, 63, 793, 14, 952, 20794, 26, 1052, 446, 24702, 8441, 2440, 13356, 78, 1674, 908, 8, 72, 521, 12, 485, 2792, 12, 485, 1896, 12, 485, 2030, 430, 686, 198, 63, 793, 14, 952, 480, 793, 14, 793, 446, 19698, 26, 18615, 440, 943, 8441, 2440, 4451, 370, 8441, 24423, 1674, 60, 78, 15905, 3427, 78, 24423, 78, 1674, 908, 1547, 2030, 12, 485, 2792, 12, 1475, 63, 2804, 4059, 686, 198, 63, 793, 14, 1600, 342, 686, 198, 1274, 14, 3083, 14, 952, 20794, 6531, 440, 943, 8441, 2440, 4451, 687, 8441, 2440, 4451, 370, 19245, 943, 3134, 78, 2440, 2440, 1553, 27694, 370, 11593, 778, 695, 943, 14, 24423, 78, 1674, 908, 8, 3765, 14, 22204, 63, 9681, 63, 581, 12, 485, 2030, 12, 485, 2792, 12, 1475, 63, 2804, 1062, 4772, 14, 22204, 63, 9681, 63, 14514, 12, 4772, 14, 22204, 63, 3958, 430, 507, 198, 2590, 26, 686, 198, 1274, 14, 3083, 14, 952, 20794, 6531, 440, 943, 8441, 2440, 4451, 370, 8441, 24423, 1674, 60, 78, 24423, 78, 2767, 22565, 12, 314, 11593, 778, 695, 943, 4293, 440, 506, 5313, 370, 1, 24423, 78, 1674, 908, 8, 3765, 14, 22204, 63, 9681, 63, 581, 12, 485, 2030, 12, 485, 2792, 12, 1475, 63, 2804, 1062, 4772, 14, 22204, 63, 3958, 430, 199, 199, 318, 943, 63, 1361, 1547, 908, 628, 6104, 2349, 199, 198, 893, 26, 507, 198, 692, 1475, 508, 298, 4737, 582, 686, 198, 1361, 298, 85, 602, 12, 72, 602, 12, 354, 12, 576, 12, 1896, 2, 507, 198, 646, 1592, 507, 198, 697, 14, 67, 14, 2526, 480, 2416, 627, 687, 943, 1865, 701, 399, 602, 531, 507, 198, 509, 485, 1143, 315, 1592, 14, 67, 26, 686, 198, 63, 85, 602, 275, 485, 1143, 59, 16, 61, 686, 198, 63, 72, 602, 275, 485, 1143, 59, 17, 61, 686, 198, 63, 2792, 275, 485, 1143, 59, 18, 61, 686, 198, 63, 2030, 275, 485, 1143, 59, 19, 61, 686, 198, 63, 1896, 275, 485, 1143, 59, 20, 61, 686, 198, 692, 485, 908, 508, 298, 4737, 582, 1585, 198, 1361, 5310, 1386, 27125, 27125, 27125, 24423, 78, 1674, 908, 8, 495, 1547, 85, 602, 395, 63, 72, 602, 16987, 354, 16987, 576, 16987, 1896, 9, 686, 198, 2836, 26, 1585, 198, 1361, 63, 1188, 1547, 2030, 12, 485, 2792, 12, 485, 1896, 12, 485, 72, 602, 9, 421, 198, 2590, 26, 507, 198, 793, 480, 2445, 4293, 440, 506, 12487, 3134, 78, 13536, 908, 8, 908, 63, 2804, 4000, 298, 793, 14, 793, 63, 1361, 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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 ]
auready/django
tests/gis_tests/test_measure.py
35
7398
""" Distance and Area objects to allow for sensible and convenient calculation and conversions. Here are some tests. """ import unittest from django.contrib.gis.measure import A, Area, D, Distance class DistanceTest(unittest.TestCase): "Testing the Distance object" def testInit(self): "Testing initialization from valid units" d = Distance(m=100) self.assertEqual(d.m, 100) d1, d2, d3 = D(m=100), D(meter=100), D(metre=100) for d in (d1, d2, d3): self.assertEqual(d.m, 100) d = D(nm=100) self.assertEqual(d.m, 185200) y1, y2, y3 = D(yd=100), D(yard=100), D(Yard=100) for d in (y1, y2, y3): self.assertEqual(d.yd, 100) mm1, mm2 = D(millimeter=1000), D(MiLLiMeTeR=1000) for d in (mm1, mm2): self.assertEqual(d.m, 1.0) self.assertEqual(d.mm, 1000.0) def testInitInvalid(self): "Testing initialization from invalid units" with self.assertRaises(AttributeError): D(banana=100) def testAccess(self): "Testing access in different units" d = D(m=100) self.assertEqual(d.km, 0.1) self.assertAlmostEqual(d.ft, 328.084, 3) def testAccessInvalid(self): "Testing access in invalid units" d = D(m=100) self.assertFalse(hasattr(d, 'banana')) def testAddition(self): "Test addition & subtraction" d1 = D(m=100) d2 = D(m=200) d3 = d1 + d2 self.assertEqual(d3.m, 300) d3 += d1 self.assertEqual(d3.m, 400) d4 = d1 - d2 self.assertEqual(d4.m, -100) d4 -= d1 self.assertEqual(d4.m, -200) with self.assertRaises(TypeError): d1 + 1 with self.assertRaises(TypeError): d1 - 1 with self.assertRaises(TypeError): d1 += 1 with self.assertRaises(TypeError): d1 -= 1 def testMultiplication(self): "Test multiplication & division" d1 = D(m=100) d3 = d1 * 2 self.assertEqual(d3.m, 200) d3 = 2 * d1 self.assertEqual(d3.m, 200) d3 *= 5 self.assertEqual(d3.m, 1000) d4 = d1 / 2 self.assertEqual(d4.m, 50) d4 /= 5 self.assertEqual(d4.m, 10) d5 = d1 / D(m=2) self.assertEqual(d5, 50) a5 = d1 * D(m=10) self.assertIsInstance(a5, Area) self.assertEqual(a5.sq_m, 100 * 10) with self.assertRaises(TypeError): d1 *= D(m=1) with self.assertRaises(TypeError): d1 /= D(m=1) def testUnitConversions(self): "Testing default units during maths" d1 = D(m=100) d2 = D(km=1) d3 = d1 + d2 self.assertEqual(d3._default_unit, 'm') d4 = d2 + d1 self.assertEqual(d4._default_unit, 'km') d5 = d1 * 2 self.assertEqual(d5._default_unit, 'm') d6 = d1 / 2 self.assertEqual(d6._default_unit, 'm') def testComparisons(self): "Testing comparisons" d1 = D(m=100) d2 = D(km=1) d3 = D(km=0) self.assertGreater(d2, d1) self.assertEqual(d1, d1) self.assertLess(d1, d2) self.assertFalse(d3) def testUnitsStr(self): "Testing conversion to strings" d1 = D(m=100) d2 = D(km=3.5) self.assertEqual(str(d1), '100.0 m') self.assertEqual(str(d2), '3.5 km') self.assertEqual(repr(d1), 'Distance(m=100.0)') self.assertEqual(repr(d2), 'Distance(km=3.5)') def testUnitAttName(self): "Testing the `unit_attname` class method" unit_tuple = [('Yard', 'yd'), ('Nautical Mile', 'nm'), ('German legal metre', 'german_m'), ('Indian yard', 'indian_yd'), ('Chain (Sears)', 'chain_sears'), ('Chain', 'chain')] for nm, att in unit_tuple: self.assertEqual(att, D.unit_attname(nm)) class AreaTest(unittest.TestCase): "Testing the Area object" def testInit(self): "Testing initialization from valid units" a = Area(sq_m=100) self.assertEqual(a.sq_m, 100) a = A(sq_m=100) self.assertEqual(a.sq_m, 100) a = A(sq_mi=100) self.assertEqual(a.sq_m, 258998811.0336) def testInitInvaliA(self): "Testing initialization from invalid units" with self.assertRaises(AttributeError): A(banana=100) def testAccess(self): "Testing access in different units" a = A(sq_m=100) self.assertEqual(a.sq_km, 0.0001) self.assertAlmostEqual(a.sq_ft, 1076.391, 3) def testAccessInvaliA(self): "Testing access in invalid units" a = A(sq_m=100) self.assertFalse(hasattr(a, 'banana')) def testAddition(self): "Test addition & subtraction" a1 = A(sq_m=100) a2 = A(sq_m=200) a3 = a1 + a2 self.assertEqual(a3.sq_m, 300) a3 += a1 self.assertEqual(a3.sq_m, 400) a4 = a1 - a2 self.assertEqual(a4.sq_m, -100) a4 -= a1 self.assertEqual(a4.sq_m, -200) with self.assertRaises(TypeError): a1 + 1 with self.assertRaises(TypeError): a1 - 1 with self.assertRaises(TypeError): a1 += 1 with self.assertRaises(TypeError): a1 -= 1 def testMultiplication(self): "Test multiplication & division" a1 = A(sq_m=100) a3 = a1 * 2 self.assertEqual(a3.sq_m, 200) a3 = 2 * a1 self.assertEqual(a3.sq_m, 200) a3 *= 5 self.assertEqual(a3.sq_m, 1000) a4 = a1 / 2 self.assertEqual(a4.sq_m, 50) a4 /= 5 self.assertEqual(a4.sq_m, 10) with self.assertRaises(TypeError): a1 * A(sq_m=1) with self.assertRaises(TypeError): a1 *= A(sq_m=1) with self.assertRaises(TypeError): a1 / A(sq_m=1) with self.assertRaises(TypeError): a1 /= A(sq_m=1) def testUnitConversions(self): "Testing default units during maths" a1 = A(sq_m=100) a2 = A(sq_km=1) a3 = a1 + a2 self.assertEqual(a3._default_unit, 'sq_m') a4 = a2 + a1 self.assertEqual(a4._default_unit, 'sq_km') a5 = a1 * 2 self.assertEqual(a5._default_unit, 'sq_m') a6 = a1 / 2 self.assertEqual(a6._default_unit, 'sq_m') def testComparisons(self): "Testing comparisons" a1 = A(sq_m=100) a2 = A(sq_km=1) a3 = A(sq_km=0) self.assertGreater(a2, a1) self.assertEqual(a1, a1) self.assertLess(a1, a2) self.assertFalse(a3) def testUnitsStr(self): "Testing conversion to strings" a1 = A(sq_m=100) a2 = A(sq_km=3.5) self.assertEqual(str(a1), '100.0 sq_m') self.assertEqual(str(a2), '3.5 sq_km') self.assertEqual(repr(a1), 'Area(sq_m=100.0)') self.assertEqual(repr(a2), 'Area(sq_km=3.5)') def suite(): s = unittest.TestSuite() s.addTest(unittest.makeSuite(DistanceTest)) s.addTest(unittest.makeSuite(AreaTest)) return s def run(verbosity=2): unittest.TextTestRunner(verbosity=verbosity).run(suite()) if __name__ == "__main__": run()
bsd-3-clause
[ 624, 199, 10076, 436, 26280, 2251, 370, 2040, 367, 27962, 436, 22700, 15232, 199, 460, 24796, 14, 11842, 787, 2005, 2295, 14, 199, 624, 199, 199, 646, 2882, 199, 199, 504, 1639, 14, 2828, 14, 5668, 14, 9580, 492, 437, 12, 26280, 12, 577, 12, 21892, 421, 199, 533, 21892, 774, 8, 2796, 14, 1746, 304, 272, 298, 9029, 314, 21892, 909, 2, 339, 347, 511, 9346, 8, 277, 304, 267, 298, 9029, 11097, 687, 1686, 6204, 2, 267, 366, 275, 21892, 8, 77, 29, 1960, 9, 267, 291, 14, 629, 8, 68, 14, 77, 12, 2948, 9, 398, 366, 17, 12, 366, 18, 12, 366, 19, 275, 577, 8, 77, 29, 1960, 395, 577, 8, 10011, 29, 1960, 395, 577, 8, 10207, 264, 29, 1960, 9, 267, 367, 366, 315, 334, 68, 17, 12, 366, 18, 12, 366, 19, 304, 288, 291, 14, 629, 8, 68, 14, 77, 12, 2948, 9, 398, 366, 275, 577, 8, 10756, 29, 1960, 9, 267, 291, 14, 629, 8, 68, 14, 77, 12, 413, 2426, 1840, 9, 398, 612, 17, 12, 612, 18, 12, 612, 19, 275, 577, 8, 24503, 29, 1960, 395, 577, 8, 89, 1005, 29, 1960, 395, 577, 8, 57, 1005, 29, 1960, 9, 267, 367, 366, 315, 334, 89, 17, 12, 612, 18, 12, 612, 19, 304, 288, 291, 14, 629, 8, 68, 14, 24503, 12, 2948, 9, 398, 8562, 17, 12, 8562, 18, 275, 577, 8, 19579, 10011, 29, 5279, 395, 577, 8, 14738, 4464, 73, 1352, 6301, 50, 29, 5279, 9, 267, 367, 366, 315, 334, 596, 17, 12, 8562, 18, 304, 288, 291, 14, 629, 8, 68, 14, 77, 12, 413, 14, 16, 9, 288, 291, 14, 629, 8, 68, 14, 596, 12, 5198, 14, 16, 9, 339, 347, 511, 9346, 3364, 8, 277, 304, 267, 298, 9029, 11097, 687, 3866, 6204, 2, 267, 543, 291, 14, 1855, 8, 10227, 304, 288, 577, 8, 13206, 6738, 29, 1960, 9, 339, 347, 511, 3946, 8, 277, 304, 267, 298, 9029, 2879, 315, 3365, 6204, 2, 267, 366, 275, 577, 8, 77, 29, 1960, 9, 267, 291, 14, 629, 8, 68, 14, 14595, 12, 378, 14, 17, 9, 267, 291, 14, 7904, 8, 68, 14, 856, 12, 650, 1651, 14, 26107, 12, 650, 9, 339, 347, 511, 3946, 3364, 8, 277, 304, 267, 298, 9029, 2879, 315, 3866, 6204, 2, 267, 366, 275, 577, 8, 77, 29, 1960, 9, 267, 291, 14, 3334, 8, 11161, 8, 68, 12, 283, 13206, 6738, 1333, 339, 347, 511, 2767, 1671, 8, 277, 304, 267, 298, 774, 10234, 1253, 1007, 26137, 2, 267, 366, 17, 275, 577, 8, 77, 29, 1960, 9, 267, 366, 18, 275, 577, 8, 77, 29, 1840, 9, 398, 366, 19, 275, 366, 17, 435, 366, 18, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 9601, 9, 267, 366, 19, 847, 366, 17, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 8290, 9, 398, 366, 20, 275, 366, 17, 446, 366, 18, 267, 291, 14, 629, 8, 68, 20, 14, 77, 12, 446, 1960, 9, 267, 366, 20, 4862, 366, 17, 267, 291, 14, 629, 8, 68, 20, 14, 77, 12, 446, 1840, 9, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 435, 413, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 446, 413, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 847, 413, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 4862, 413, 339, 347, 511, 25314, 1863, 8, 277, 304, 267, 298, 774, 24638, 1253, 4629, 2, 267, 366, 17, 275, 577, 8, 77, 29, 1960, 9, 398, 366, 19, 275, 366, 17, 627, 499, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 1926, 9, 267, 366, 19, 275, 499, 627, 366, 17, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 1926, 9, 267, 366, 19, 9000, 959, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 5198, 9, 398, 366, 20, 275, 366, 17, 1182, 499, 267, 291, 14, 629, 8, 68, 20, 14, 77, 12, 5238, 9, 267, 366, 20, 12257, 959, 267, 291, 14, 629, 8, 68, 20, 14, 77, 12, 1616, 9, 267, 366, 21, 275, 366, 17, 1182, 577, 8, 77, 29, 18, 9, 267, 291, 14, 629, 8, 68, 21, 12, 5238, 9, 398, 282, 21, 275, 366, 17, 627, 577, 8, 77, 29, 709, 9, 267, 291, 14, 6926, 8, 65, 21, 12, 26280, 9, 267, 291, 14, 629, 8, 65, 21, 14, 3526, 63, 77, 12, 2948, 627, 1616, 9, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 9000, 577, 8, 77, 29, 17, 9, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 12257, 577, 8, 77, 29, 17, 9, 339, 347, 511, 5072, 714, 6234, 8, 277, 304, 267, 298, 9029, 849, 6204, 5309, 3473, 83, 2, 267, 366, 17, 275, 577, 8, 77, 29, 1960, 9, 267, 366, 18, 275, 577, 8, 14595, 29, 17, 9, 398, 366, 19, 275, 366, 17, 435, 366, 18, 267, 291, 14, 629, 8, 68, 19, 423, 885, 63, 3248, 12, 283, 77, 358, 267, 366, 20, 275, 366, 18, 435, 366, 17, 267, 291, 14, 629, 8, 68, 20, 423, 885, 63, 3248, 12, 283, 14595, 358, 267, 366, 21, 275, 366, 17, 627, 499, 267, 291, 14, 629, 8, 68, 21, 423, 885, 63, 3248, 12, 283, 77, 358, 267, 366, 22, 275, 366, 17, 1182, 499, 267, 291, 14, 629, 8, 68, 22, 423, 885, 63, 3248, 12, 283, 77, 358, 339, 347, 511, 2404, 15864, 8, 277, 304, 267, 298, 9029, 20448, 2, 267, 366, 17, 275, 577, 8, 77, 29, 1960, 9, 267, 366, 18, 275, 577, 8, 14595, 29, 17, 9, 267, 366, 19, 275, 577, 8, 14595, 29, 16, 9, 398, 291, 14, 15070, 8, 68, 18, 12, 366, 17, 9, 267, 291, 14, 629, 8, 68, 17, 12, 366, 17, 9, 267, 291, 14, 15625, 8, 68, 17, 12, 366, 18, 9, 267, 291, 14, 3334, 8, 68, 19, 9, 339, 347, 511, 15121, 2848, 8, 277, 304, 267 ]
[ 199, 10076, 436, 26280, 2251, 370, 2040, 367, 27962, 436, 22700, 15232, 199, 460, 24796, 14, 11842, 787, 2005, 2295, 14, 199, 624, 199, 199, 646, 2882, 199, 199, 504, 1639, 14, 2828, 14, 5668, 14, 9580, 492, 437, 12, 26280, 12, 577, 12, 21892, 421, 199, 533, 21892, 774, 8, 2796, 14, 1746, 304, 272, 298, 9029, 314, 21892, 909, 2, 339, 347, 511, 9346, 8, 277, 304, 267, 298, 9029, 11097, 687, 1686, 6204, 2, 267, 366, 275, 21892, 8, 77, 29, 1960, 9, 267, 291, 14, 629, 8, 68, 14, 77, 12, 2948, 9, 398, 366, 17, 12, 366, 18, 12, 366, 19, 275, 577, 8, 77, 29, 1960, 395, 577, 8, 10011, 29, 1960, 395, 577, 8, 10207, 264, 29, 1960, 9, 267, 367, 366, 315, 334, 68, 17, 12, 366, 18, 12, 366, 19, 304, 288, 291, 14, 629, 8, 68, 14, 77, 12, 2948, 9, 398, 366, 275, 577, 8, 10756, 29, 1960, 9, 267, 291, 14, 629, 8, 68, 14, 77, 12, 413, 2426, 1840, 9, 398, 612, 17, 12, 612, 18, 12, 612, 19, 275, 577, 8, 24503, 29, 1960, 395, 577, 8, 89, 1005, 29, 1960, 395, 577, 8, 57, 1005, 29, 1960, 9, 267, 367, 366, 315, 334, 89, 17, 12, 612, 18, 12, 612, 19, 304, 288, 291, 14, 629, 8, 68, 14, 24503, 12, 2948, 9, 398, 8562, 17, 12, 8562, 18, 275, 577, 8, 19579, 10011, 29, 5279, 395, 577, 8, 14738, 4464, 73, 1352, 6301, 50, 29, 5279, 9, 267, 367, 366, 315, 334, 596, 17, 12, 8562, 18, 304, 288, 291, 14, 629, 8, 68, 14, 77, 12, 413, 14, 16, 9, 288, 291, 14, 629, 8, 68, 14, 596, 12, 5198, 14, 16, 9, 339, 347, 511, 9346, 3364, 8, 277, 304, 267, 298, 9029, 11097, 687, 3866, 6204, 2, 267, 543, 291, 14, 1855, 8, 10227, 304, 288, 577, 8, 13206, 6738, 29, 1960, 9, 339, 347, 511, 3946, 8, 277, 304, 267, 298, 9029, 2879, 315, 3365, 6204, 2, 267, 366, 275, 577, 8, 77, 29, 1960, 9, 267, 291, 14, 629, 8, 68, 14, 14595, 12, 378, 14, 17, 9, 267, 291, 14, 7904, 8, 68, 14, 856, 12, 650, 1651, 14, 26107, 12, 650, 9, 339, 347, 511, 3946, 3364, 8, 277, 304, 267, 298, 9029, 2879, 315, 3866, 6204, 2, 267, 366, 275, 577, 8, 77, 29, 1960, 9, 267, 291, 14, 3334, 8, 11161, 8, 68, 12, 283, 13206, 6738, 1333, 339, 347, 511, 2767, 1671, 8, 277, 304, 267, 298, 774, 10234, 1253, 1007, 26137, 2, 267, 366, 17, 275, 577, 8, 77, 29, 1960, 9, 267, 366, 18, 275, 577, 8, 77, 29, 1840, 9, 398, 366, 19, 275, 366, 17, 435, 366, 18, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 9601, 9, 267, 366, 19, 847, 366, 17, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 8290, 9, 398, 366, 20, 275, 366, 17, 446, 366, 18, 267, 291, 14, 629, 8, 68, 20, 14, 77, 12, 446, 1960, 9, 267, 366, 20, 4862, 366, 17, 267, 291, 14, 629, 8, 68, 20, 14, 77, 12, 446, 1840, 9, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 435, 413, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 446, 413, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 847, 413, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 4862, 413, 339, 347, 511, 25314, 1863, 8, 277, 304, 267, 298, 774, 24638, 1253, 4629, 2, 267, 366, 17, 275, 577, 8, 77, 29, 1960, 9, 398, 366, 19, 275, 366, 17, 627, 499, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 1926, 9, 267, 366, 19, 275, 499, 627, 366, 17, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 1926, 9, 267, 366, 19, 9000, 959, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 5198, 9, 398, 366, 20, 275, 366, 17, 1182, 499, 267, 291, 14, 629, 8, 68, 20, 14, 77, 12, 5238, 9, 267, 366, 20, 12257, 959, 267, 291, 14, 629, 8, 68, 20, 14, 77, 12, 1616, 9, 267, 366, 21, 275, 366, 17, 1182, 577, 8, 77, 29, 18, 9, 267, 291, 14, 629, 8, 68, 21, 12, 5238, 9, 398, 282, 21, 275, 366, 17, 627, 577, 8, 77, 29, 709, 9, 267, 291, 14, 6926, 8, 65, 21, 12, 26280, 9, 267, 291, 14, 629, 8, 65, 21, 14, 3526, 63, 77, 12, 2948, 627, 1616, 9, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 9000, 577, 8, 77, 29, 17, 9, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 12257, 577, 8, 77, 29, 17, 9, 339, 347, 511, 5072, 714, 6234, 8, 277, 304, 267, 298, 9029, 849, 6204, 5309, 3473, 83, 2, 267, 366, 17, 275, 577, 8, 77, 29, 1960, 9, 267, 366, 18, 275, 577, 8, 14595, 29, 17, 9, 398, 366, 19, 275, 366, 17, 435, 366, 18, 267, 291, 14, 629, 8, 68, 19, 423, 885, 63, 3248, 12, 283, 77, 358, 267, 366, 20, 275, 366, 18, 435, 366, 17, 267, 291, 14, 629, 8, 68, 20, 423, 885, 63, 3248, 12, 283, 14595, 358, 267, 366, 21, 275, 366, 17, 627, 499, 267, 291, 14, 629, 8, 68, 21, 423, 885, 63, 3248, 12, 283, 77, 358, 267, 366, 22, 275, 366, 17, 1182, 499, 267, 291, 14, 629, 8, 68, 22, 423, 885, 63, 3248, 12, 283, 77, 358, 339, 347, 511, 2404, 15864, 8, 277, 304, 267, 298, 9029, 20448, 2, 267, 366, 17, 275, 577, 8, 77, 29, 1960, 9, 267, 366, 18, 275, 577, 8, 14595, 29, 17, 9, 267, 366, 19, 275, 577, 8, 14595, 29, 16, 9, 398, 291, 14, 15070, 8, 68, 18, 12, 366, 17, 9, 267, 291, 14, 629, 8, 68, 17, 12, 366, 17, 9, 267, 291, 14, 15625, 8, 68, 17, 12, 366, 18, 9, 267, 291, 14, 3334, 8, 68, 19, 9, 339, 347, 511, 15121, 2848, 8, 277, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
MERegistro/meregistro
meregistro/apps/oferta_nacional/views.py
1
3879
# -*- coding: UTF-8 -*- from django.http import HttpResponseRedirect, HttpResponse from datetime import datetime from django.core.urlresolvers import reverse from meregistro.shortcuts import my_render from apps.seguridad.decorators import login_required, credential_required from apps.seguridad.models import Usuario, Perfil from apps.oferta_nacional.forms import OfertaNacionalFormFilters from apps.registro.models import Jurisdiccion, Establecimiento from apps.titulos.models import Carrera from apps.reportes.views.oferta_nacional import oferta_nacional as reporte_oferta_nacional from apps.reportes.models import Reporte from django.core.paginator import Paginator import simplejson as json from django.core import serializers ITEMS_PER_PAGE = 50 ANIOS_DISPONIBLES = [2017] def index(request, anio): if int(anio) not in ANIOS_DISPONIBLES: raise Exception('Año no disponible para consulta') """ Consulta de títulos """ if request.method == 'GET': form_filter = OfertaNacionalFormFilters(request.GET, anio=anio) else: form_filter = OfertaNacionalFormFilters(anio=anio) q = build_query(form_filter, 1, request) """ try: if request.GET['export'] == '1': return reporte_oferta_nacional(request, q, anio) except KeyError: pass """ import itertools paginator = Paginator(list(itertools.chain(q[0], q[1], q[2])), ITEMS_PER_PAGE) try: page_number = int(request.GET['page']) except (KeyError, ValueError): page_number = 1 # chequear los límites if page_number < 1: page_number = 1 elif page_number > paginator.num_pages: page_number = paginator.num_pages page = paginator.page(page_number) objects = page.object_list return my_render(request, 'oferta_nacional/index.html', { 'anio': anio, 'form_filters': form_filter, 'objects': objects, 'paginator': paginator, 'page': page, 'page_number': page_number, 'pages_range': range(1, paginator.num_pages + 1), 'next_page': page_number + 1, 'prev_page': page_number - 1, 'export_url': Reporte.build_export_url(request.build_absolute_uri()), }) def build_query(filters, page, request): """ Construye el query de búsqueda a partir de los filtros. """ q = filters.buildQuery() #q = return q def ajax_get_establecimientos_por_jurisdiccion(request, jurisdiccion_id): if int(jurisdiccion_id) > 0: establecimientos = Establecimiento.objects.filter(dependencia_funcional__jurisdiccion__id=jurisdiccion_id) else: establecimientos = Establecimiento.objects.all() establecimientos.order_by('nombre') establecimientos_dict = [{'pk':e.pk, 'establecimiento':e.cue + " - " +e.nombre} for e in establecimientos] return HttpResponse(json.dumps(establecimientos_dict), mimetype="application/javascript") def ajax_get_carreras_por_jurisdiccion(request, jurisdiccion_id): if int(jurisdiccion_id) > 0: carreras = Carrera.objects.filter(carrerajurisdiccional__jurisdiccion__id=jurisdiccion_id).distinct() else: carreras = Carrera.objects.all() carreras.order_by('nombre') carreras_dict = [{'pk':c.pk, 'carrera':c.nombre} for c in carreras] return HttpResponse(json.dumps(carreras_dict), mimetype="application/javascript") def ajax_get_carreras_por_establecimiento(request, establecimiento_id): if int(establecimiento_id) > 0: carreras = Carrera.objects.filter(carrerajurisdiccional__cohortes__establecimientos__id=establecimiento_id) else: carreras = Carrera.objects.all() carreras.order_by('nombre') carreras_dict = [{'pk':c.pk, 'carrera':c.nombre} for c in carreras] return HttpResponse(json.dumps(carreras_dict), mimetype="application/javascript")
bsd-3-clause
[ 3, 1882, 2803, 26, 9094, 13, 24, 1882, 199, 199, 504, 1639, 14, 1014, 492, 14935, 12, 6183, 199, 504, 2197, 492, 2197, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 562, 18724, 293, 14, 17469, 492, 3002, 63, 3352, 199, 504, 8686, 14, 8359, 300, 344, 350, 14, 11582, 492, 4676, 63, 2427, 12, 16338, 63, 2427, 199, 504, 8686, 14, 8359, 300, 344, 350, 14, 992, 492, 738, 9648, 6936, 12, 3492, 1289, 199, 504, 8686, 14, 1618, 281, 502, 63, 3540, 559, 8125, 14, 3351, 492, 593, 2412, 502, 8565, 559, 8125, 2821, 18053, 199, 504, 8686, 14, 18724, 293, 14, 992, 492, 1603, 17656, 5000, 9718, 12, 662, 11989, 559, 2664, 287, 475, 199, 504, 8686, 14, 6403, 85, 11560, 14, 992, 492, 14243, 264, 345, 199, 504, 8686, 14, 1155, 269, 744, 14, 4196, 14, 1618, 281, 502, 63, 3540, 559, 8125, 492, 402, 281, 502, 63, 3540, 559, 8125, 465, 1833, 269, 266, 63, 1618, 281, 502, 63, 3540, 559, 8125, 199, 504, 8686, 14, 1155, 269, 744, 14, 992, 492, 799, 7314, 266, 199, 504, 1639, 14, 1018, 14, 22073, 492, 28006, 8566, 199, 646, 13804, 465, 2022, 199, 504, 1639, 14, 1018, 492, 12506, 421, 199, 10439, 51, 63, 4227, 63, 12898, 275, 5238, 199, 879, 13532, 63, 6178, 48, 615, 2100, 11344, 275, 359, 10680, 61, 421, 199, 318, 1478, 8, 1069, 12, 376, 2308, 304, 272, 340, 1109, 8, 290, 2308, 9, 440, 315, 1261, 13532, 63, 6178, 48, 615, 2100, 11344, 26, 267, 746, 2186, 360, 33, 22692, 79, 949, 2153, 678, 7247, 12665, 13447, 427, 65, 358, 272, 408, 272, 1448, 83, 427, 65, 477, 307, 13676, 10963, 11560, 272, 408, 272, 340, 1056, 14, 765, 508, 283, 2970, 356, 267, 1824, 63, 1541, 275, 593, 2412, 502, 8565, 559, 8125, 2821, 18053, 8, 1069, 14, 2970, 12, 376, 2308, 29, 290, 2308, 9, 272, 587, 26, 267, 1824, 63, 1541, 275, 593, 2412, 502, 8565, 559, 8125, 2821, 18053, 8, 290, 2308, 29, 290, 2308, 9, 339, 1894, 275, 1900, 63, 1131, 8, 964, 63, 1541, 12, 413, 12, 1056, 9, 272, 408, 272, 862, 26, 267, 340, 1056, 14, 2970, 459, 3790, 418, 508, 283, 17, 356, 288, 372, 1833, 269, 266, 63, 1618, 281, 502, 63, 3540, 559, 8125, 8, 1069, 12, 1894, 12, 376, 2308, 9, 272, 871, 4067, 26, 267, 986, 272, 408, 339, 492, 7975, 272, 21398, 275, 28006, 8566, 8, 513, 8, 17691, 14, 4429, 8, 81, 59, 16, 467, 1894, 59, 17, 467, 1894, 59, 18, 12884, 473, 22057, 51, 63, 4227, 63, 12898, 9, 339, 862, 26, 267, 2034, 63, 1955, 275, 1109, 8, 1069, 14, 2970, 459, 1606, 1105, 272, 871, 334, 10230, 12, 1722, 304, 267, 2034, 63, 1955, 275, 413, 272, 327, 17546, 544, 285, 16406, 634, 13676, 2664, 744, 272, 340, 2034, 63, 1955, 665, 413, 26, 267, 2034, 63, 1955, 275, 413, 272, 916, 2034, 63, 1955, 690, 21398, 14, 1507, 63, 5856, 26, 267, 2034, 63, 1955, 275, 21398, 14, 1507, 63, 5856, 339, 2034, 275, 21398, 14, 1606, 8, 1606, 63, 1955, 9, 272, 2251, 275, 2034, 14, 785, 63, 513, 339, 372, 3002, 63, 3352, 8, 1069, 12, 283, 1618, 281, 502, 63, 3540, 559, 8125, 15, 1080, 14, 1360, 297, 469, 267, 283, 290, 2308, 356, 376, 2308, 12, 267, 283, 964, 63, 4273, 356, 1824, 63, 1541, 12, 267, 283, 1462, 356, 2251, 12, 267, 283, 22073, 356, 21398, 12, 267, 283, 1606, 356, 2034, 12, 267, 283, 1606, 63, 1955, 356, 2034, 63, 1955, 12, 267, 283, 5856, 63, 1842, 356, 1425, 8, 17, 12, 21398, 14, 1507, 63, 5856, 435, 413, 395, 267, 283, 2184, 63, 1606, 356, 2034, 63, 1955, 435, 413, 12, 267, 283, 5701, 63, 1606, 356, 2034, 63, 1955, 446, 413, 12, 267, 283, 3790, 63, 633, 356, 799, 7314, 266, 14, 1506, 63, 3790, 63, 633, 8, 1069, 14, 1506, 63, 6116, 63, 2302, 4000, 272, 3828, 421, 199, 318, 1900, 63, 1131, 8, 4273, 12, 2034, 12, 1056, 304, 272, 408, 272, 1448, 1281, 8048, 579, 1827, 477, 330, 24602, 83, 544, 983, 282, 623, 280, 82, 477, 16406, 1794, 1374, 83, 14, 272, 408, 272, 1894, 275, 4766, 14, 1506, 3227, 342, 272, 327, 81, 275, 272, 372, 1894, 421, 199, 318, 25930, 63, 362, 63, 597, 461, 559, 2664, 287, 14543, 63, 7314, 63, 74, 17656, 5000, 9718, 8, 1069, 12, 1335, 17656, 5000, 9718, 63, 344, 304, 272, 340, 1109, 8, 74, 17656, 5000, 9718, 63, 344, 9, 690, 378, 26, 267, 4347, 461, 559, 2664, 287, 14543, 275, 662, 11989, 559, 2664, 287, 475, 14, 1462, 14, 1541, 8, 271, 2230, 16521, 63, 7036, 559, 8125, 363, 74, 17656, 5000, 9718, 363, 344, 29, 74, 17656, 5000, 9718, 63, 344, 9, 272, 587, 26, 267, 4347, 461, 559, 2664, 287, 14543, 275, 662, 11989, 559, 2664, 287, 475, 14, 1462, 14, 452, 342, 339, 4347, 461, 559, 2664, 287, 14543, 14, 1648, 63, 991, 360, 15998, 10205, 358, 339, 4347, 461, 559, 2664, 287, 14543, 63, 807, 275, 9016, 2051, 356, 69, 14, 2051, 12, 283, 597, 461, 559, 2664, 287, 475, 356, 69, 14, 14932, 435, 298, 446, 298, 435, 69, 14, 15998, 10205, 93, 367, 325, 315, 4347, 461, 559, 2664, 287, 14543, 61, 272, 372, 6183, 8, 1001, 14, 4180, 8, 597, 461, 559, 2664, 287, 14543, 63, 807, 395, 12200, 628, 3578, 15, 9554, 531, 421, 199, 318, 25930, 63, 362, 63, 7007, 3859, 305, 63, 7314, 63, 74, 17656, 5000, 9718, 8, 1069, 12, 1335, 17656, 5000, 9718, 63, 344, 304, 272, 340, 1109, 8, 74, 17656, 5000, 9718, 63, 344, 9, 690, 378, 26, 267, 9590, 3859, 305, 275, 14243, 264, 345, 14, 1462, 14, 1541, 8, 7007, 264, 345, 74, 17656, 5000, 559, 8125, 363, 74, 17656, 5000, 9718, 363, 344, 29, 74, 17656, 5000, 9718, 63, 344, 680, 12926, 342, 272, 587, 26, 267, 9590, 3859, 305, 275, 14243, 264, 345, 14, 1462, 14, 452, 342, 339, 9590, 3859, 305, 14, 1648, 63, 991, 360, 15998, 10205, 358, 339, 9590 ]
[ 1882, 2803, 26, 9094, 13, 24, 1882, 199, 199, 504, 1639, 14, 1014, 492, 14935, 12, 6183, 199, 504, 2197, 492, 2197, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 562, 18724, 293, 14, 17469, 492, 3002, 63, 3352, 199, 504, 8686, 14, 8359, 300, 344, 350, 14, 11582, 492, 4676, 63, 2427, 12, 16338, 63, 2427, 199, 504, 8686, 14, 8359, 300, 344, 350, 14, 992, 492, 738, 9648, 6936, 12, 3492, 1289, 199, 504, 8686, 14, 1618, 281, 502, 63, 3540, 559, 8125, 14, 3351, 492, 593, 2412, 502, 8565, 559, 8125, 2821, 18053, 199, 504, 8686, 14, 18724, 293, 14, 992, 492, 1603, 17656, 5000, 9718, 12, 662, 11989, 559, 2664, 287, 475, 199, 504, 8686, 14, 6403, 85, 11560, 14, 992, 492, 14243, 264, 345, 199, 504, 8686, 14, 1155, 269, 744, 14, 4196, 14, 1618, 281, 502, 63, 3540, 559, 8125, 492, 402, 281, 502, 63, 3540, 559, 8125, 465, 1833, 269, 266, 63, 1618, 281, 502, 63, 3540, 559, 8125, 199, 504, 8686, 14, 1155, 269, 744, 14, 992, 492, 799, 7314, 266, 199, 504, 1639, 14, 1018, 14, 22073, 492, 28006, 8566, 199, 646, 13804, 465, 2022, 199, 504, 1639, 14, 1018, 492, 12506, 421, 199, 10439, 51, 63, 4227, 63, 12898, 275, 5238, 199, 879, 13532, 63, 6178, 48, 615, 2100, 11344, 275, 359, 10680, 61, 421, 199, 318, 1478, 8, 1069, 12, 376, 2308, 304, 272, 340, 1109, 8, 290, 2308, 9, 440, 315, 1261, 13532, 63, 6178, 48, 615, 2100, 11344, 26, 267, 746, 2186, 360, 33, 22692, 79, 949, 2153, 678, 7247, 12665, 13447, 427, 65, 358, 272, 408, 272, 1448, 83, 427, 65, 477, 307, 13676, 10963, 11560, 272, 408, 272, 340, 1056, 14, 765, 508, 283, 2970, 356, 267, 1824, 63, 1541, 275, 593, 2412, 502, 8565, 559, 8125, 2821, 18053, 8, 1069, 14, 2970, 12, 376, 2308, 29, 290, 2308, 9, 272, 587, 26, 267, 1824, 63, 1541, 275, 593, 2412, 502, 8565, 559, 8125, 2821, 18053, 8, 290, 2308, 29, 290, 2308, 9, 339, 1894, 275, 1900, 63, 1131, 8, 964, 63, 1541, 12, 413, 12, 1056, 9, 272, 408, 272, 862, 26, 267, 340, 1056, 14, 2970, 459, 3790, 418, 508, 283, 17, 356, 288, 372, 1833, 269, 266, 63, 1618, 281, 502, 63, 3540, 559, 8125, 8, 1069, 12, 1894, 12, 376, 2308, 9, 272, 871, 4067, 26, 267, 986, 272, 408, 339, 492, 7975, 272, 21398, 275, 28006, 8566, 8, 513, 8, 17691, 14, 4429, 8, 81, 59, 16, 467, 1894, 59, 17, 467, 1894, 59, 18, 12884, 473, 22057, 51, 63, 4227, 63, 12898, 9, 339, 862, 26, 267, 2034, 63, 1955, 275, 1109, 8, 1069, 14, 2970, 459, 1606, 1105, 272, 871, 334, 10230, 12, 1722, 304, 267, 2034, 63, 1955, 275, 413, 272, 327, 17546, 544, 285, 16406, 634, 13676, 2664, 744, 272, 340, 2034, 63, 1955, 665, 413, 26, 267, 2034, 63, 1955, 275, 413, 272, 916, 2034, 63, 1955, 690, 21398, 14, 1507, 63, 5856, 26, 267, 2034, 63, 1955, 275, 21398, 14, 1507, 63, 5856, 339, 2034, 275, 21398, 14, 1606, 8, 1606, 63, 1955, 9, 272, 2251, 275, 2034, 14, 785, 63, 513, 339, 372, 3002, 63, 3352, 8, 1069, 12, 283, 1618, 281, 502, 63, 3540, 559, 8125, 15, 1080, 14, 1360, 297, 469, 267, 283, 290, 2308, 356, 376, 2308, 12, 267, 283, 964, 63, 4273, 356, 1824, 63, 1541, 12, 267, 283, 1462, 356, 2251, 12, 267, 283, 22073, 356, 21398, 12, 267, 283, 1606, 356, 2034, 12, 267, 283, 1606, 63, 1955, 356, 2034, 63, 1955, 12, 267, 283, 5856, 63, 1842, 356, 1425, 8, 17, 12, 21398, 14, 1507, 63, 5856, 435, 413, 395, 267, 283, 2184, 63, 1606, 356, 2034, 63, 1955, 435, 413, 12, 267, 283, 5701, 63, 1606, 356, 2034, 63, 1955, 446, 413, 12, 267, 283, 3790, 63, 633, 356, 799, 7314, 266, 14, 1506, 63, 3790, 63, 633, 8, 1069, 14, 1506, 63, 6116, 63, 2302, 4000, 272, 3828, 421, 199, 318, 1900, 63, 1131, 8, 4273, 12, 2034, 12, 1056, 304, 272, 408, 272, 1448, 1281, 8048, 579, 1827, 477, 330, 24602, 83, 544, 983, 282, 623, 280, 82, 477, 16406, 1794, 1374, 83, 14, 272, 408, 272, 1894, 275, 4766, 14, 1506, 3227, 342, 272, 327, 81, 275, 272, 372, 1894, 421, 199, 318, 25930, 63, 362, 63, 597, 461, 559, 2664, 287, 14543, 63, 7314, 63, 74, 17656, 5000, 9718, 8, 1069, 12, 1335, 17656, 5000, 9718, 63, 344, 304, 272, 340, 1109, 8, 74, 17656, 5000, 9718, 63, 344, 9, 690, 378, 26, 267, 4347, 461, 559, 2664, 287, 14543, 275, 662, 11989, 559, 2664, 287, 475, 14, 1462, 14, 1541, 8, 271, 2230, 16521, 63, 7036, 559, 8125, 363, 74, 17656, 5000, 9718, 363, 344, 29, 74, 17656, 5000, 9718, 63, 344, 9, 272, 587, 26, 267, 4347, 461, 559, 2664, 287, 14543, 275, 662, 11989, 559, 2664, 287, 475, 14, 1462, 14, 452, 342, 339, 4347, 461, 559, 2664, 287, 14543, 14, 1648, 63, 991, 360, 15998, 10205, 358, 339, 4347, 461, 559, 2664, 287, 14543, 63, 807, 275, 9016, 2051, 356, 69, 14, 2051, 12, 283, 597, 461, 559, 2664, 287, 475, 356, 69, 14, 14932, 435, 298, 446, 298, 435, 69, 14, 15998, 10205, 93, 367, 325, 315, 4347, 461, 559, 2664, 287, 14543, 61, 272, 372, 6183, 8, 1001, 14, 4180, 8, 597, 461, 559, 2664, 287, 14543, 63, 807, 395, 12200, 628, 3578, 15, 9554, 531, 421, 199, 318, 25930, 63, 362, 63, 7007, 3859, 305, 63, 7314, 63, 74, 17656, 5000, 9718, 8, 1069, 12, 1335, 17656, 5000, 9718, 63, 344, 304, 272, 340, 1109, 8, 74, 17656, 5000, 9718, 63, 344, 9, 690, 378, 26, 267, 9590, 3859, 305, 275, 14243, 264, 345, 14, 1462, 14, 1541, 8, 7007, 264, 345, 74, 17656, 5000, 559, 8125, 363, 74, 17656, 5000, 9718, 363, 344, 29, 74, 17656, 5000, 9718, 63, 344, 680, 12926, 342, 272, 587, 26, 267, 9590, 3859, 305, 275, 14243, 264, 345, 14, 1462, 14, 452, 342, 339, 9590, 3859, 305, 14, 1648, 63, 991, 360, 15998, 10205, 358, 339, 9590, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
takis/django
tests/i18n/patterns/tests.py
256
14326
from __future__ import unicode_literals import os from django.core.exceptions import ImproperlyConfigured from django.core.urlresolvers import clear_url_caches, reverse, translate_url from django.http import HttpResponsePermanentRedirect from django.middleware.locale import LocaleMiddleware from django.template import Context, Template from django.test import SimpleTestCase, override_settings from django.test.utils import override_script_prefix from django.utils import translation from django.utils._os import upath class PermanentRedirectLocaleMiddleWare(LocaleMiddleware): response_redirect_class = HttpResponsePermanentRedirect @override_settings( USE_I18N=True, LOCALE_PATHS=[ os.path.join(os.path.dirname(upath(__file__)), 'locale'), ], LANGUAGE_CODE='en-us', LANGUAGES=[ ('nl', 'Dutch'), ('en', 'English'), ('pt-br', 'Brazilian Portuguese'), ], MIDDLEWARE_CLASSES=[ 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', ], ROOT_URLCONF='i18n.patterns.urls.default', TEMPLATES=[{ 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(os.path.dirname(upath(__file__)), 'templates')], 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.i18n', ], }, }], ) class URLTestCaseBase(SimpleTestCase): """ TestCase base-class for the URL tests. """ def setUp(self): # Make sure the cache is empty before we are doing our tests. clear_url_caches() def tearDown(self): # Make sure we will leave an empty cache for other testcases. clear_url_caches() class URLPrefixTests(URLTestCaseBase): """ Tests if the `i18n_patterns` is adding the prefix correctly. """ def test_not_prefixed(self): with translation.override('en'): self.assertEqual(reverse('not-prefixed'), '/not-prefixed/') self.assertEqual(reverse('not-prefixed-included-url'), '/not-prefixed-include/foo/') with translation.override('nl'): self.assertEqual(reverse('not-prefixed'), '/not-prefixed/') self.assertEqual(reverse('not-prefixed-included-url'), '/not-prefixed-include/foo/') def test_prefixed(self): with translation.override('en'): self.assertEqual(reverse('prefixed'), '/en/prefixed/') with translation.override('nl'): self.assertEqual(reverse('prefixed'), '/nl/prefixed/') @override_settings(ROOT_URLCONF='i18n.patterns.urls.wrong') def test_invalid_prefix_use(self): self.assertRaises(ImproperlyConfigured, lambda: reverse('account:register')) @override_settings(ROOT_URLCONF='i18n.patterns.urls.disabled') class URLDisabledTests(URLTestCaseBase): @override_settings(USE_I18N=False) def test_prefixed_i18n_disabled(self): with translation.override('en'): self.assertEqual(reverse('prefixed'), '/prefixed/') with translation.override('nl'): self.assertEqual(reverse('prefixed'), '/prefixed/') @override_settings(ROOT_URLCONF='i18n.patterns.urls.path_unused') class PathUnusedTests(URLTestCaseBase): """ Check that if no i18n_patterns is used in root urlconfs, then no language activation happens based on url prefix. """ def test_no_lang_activate(self): response = self.client.get('/nl/foo/') self.assertEqual(response.status_code, 200) self.assertEqual(response['content-language'], 'en') self.assertEqual(response.context['LANGUAGE_CODE'], 'en') class URLTranslationTests(URLTestCaseBase): """ Tests if the pattern-strings are translated correctly (within the `i18n_patterns` and the normal `patterns` function). """ def test_no_prefix_translated(self): with translation.override('en'): self.assertEqual(reverse('no-prefix-translated'), '/translated/') self.assertEqual(reverse('no-prefix-translated-slug', kwargs={'slug': 'yeah'}), '/translated/yeah/') with translation.override('nl'): self.assertEqual(reverse('no-prefix-translated'), '/vertaald/') self.assertEqual(reverse('no-prefix-translated-slug', kwargs={'slug': 'yeah'}), '/vertaald/yeah/') with translation.override('pt-br'): self.assertEqual(reverse('no-prefix-translated'), '/traduzidos/') self.assertEqual(reverse('no-prefix-translated-slug', kwargs={'slug': 'yeah'}), '/traduzidos/yeah/') def test_users_url(self): with translation.override('en'): self.assertEqual(reverse('users'), '/en/users/') with translation.override('nl'): self.assertEqual(reverse('users'), '/nl/gebruikers/') self.assertEqual(reverse('prefixed_xml'), '/nl/prefixed.xml') with translation.override('pt-br'): self.assertEqual(reverse('users'), '/pt-br/usuarios/') def test_translate_url_utility(self): with translation.override('en'): self.assertEqual(translate_url('/en/non-existent/', 'nl'), '/en/non-existent/') self.assertEqual(translate_url('/en/users/', 'nl'), '/nl/gebruikers/') # Namespaced URL self.assertEqual(translate_url('/en/account/register/', 'nl'), '/nl/profiel/registeren/') self.assertEqual(translation.get_language(), 'en') with translation.override('nl'): self.assertEqual(translate_url('/nl/gebruikers/', 'en'), '/en/users/') self.assertEqual(translation.get_language(), 'nl') class URLNamespaceTests(URLTestCaseBase): """ Tests if the translations are still working within namespaces. """ def test_account_register(self): with translation.override('en'): self.assertEqual(reverse('account:register'), '/en/account/register/') with translation.override('nl'): self.assertEqual(reverse('account:register'), '/nl/profiel/registeren/') class URLRedirectTests(URLTestCaseBase): """ Tests if the user gets redirected to the right URL when there is no language-prefix in the request URL. """ def test_no_prefix_response(self): response = self.client.get('/not-prefixed/') self.assertEqual(response.status_code, 200) def test_en_redirect(self): response = self.client.get('/account/register/', HTTP_ACCEPT_LANGUAGE='en') self.assertRedirects(response, '/en/account/register/') response = self.client.get(response['location']) self.assertEqual(response.status_code, 200) def test_en_redirect_wrong_url(self): response = self.client.get('/profiel/registeren/', HTTP_ACCEPT_LANGUAGE='en') self.assertEqual(response.status_code, 404) def test_nl_redirect(self): response = self.client.get('/profiel/registeren/', HTTP_ACCEPT_LANGUAGE='nl') self.assertRedirects(response, '/nl/profiel/registeren/') response = self.client.get(response['location']) self.assertEqual(response.status_code, 200) def test_nl_redirect_wrong_url(self): response = self.client.get('/account/register/', HTTP_ACCEPT_LANGUAGE='nl') self.assertEqual(response.status_code, 404) def test_pt_br_redirect(self): response = self.client.get('/conta/registre-se/', HTTP_ACCEPT_LANGUAGE='pt-br') self.assertRedirects(response, '/pt-br/conta/registre-se/') response = self.client.get(response['location']) self.assertEqual(response.status_code, 200) def test_pl_pl_redirect(self): # language from outside of the supported LANGUAGES list response = self.client.get('/account/register/', HTTP_ACCEPT_LANGUAGE='pl-pl') self.assertRedirects(response, '/en/account/register/') response = self.client.get(response['location']) self.assertEqual(response.status_code, 200) @override_settings( MIDDLEWARE_CLASSES=[ 'i18n.patterns.tests.PermanentRedirectLocaleMiddleWare', 'django.middleware.common.CommonMiddleware', ], ) def test_custom_redirect_class(self): response = self.client.get('/account/register/', HTTP_ACCEPT_LANGUAGE='en') self.assertRedirects(response, '/en/account/register/', 301) class URLVaryAcceptLanguageTests(URLTestCaseBase): """ Tests that 'Accept-Language' is not added to the Vary header when using prefixed URLs. """ def test_no_prefix_response(self): response = self.client.get('/not-prefixed/') self.assertEqual(response.status_code, 200) self.assertEqual(response.get('Vary'), 'Accept-Language') def test_en_redirect(self): response = self.client.get('/account/register/', HTTP_ACCEPT_LANGUAGE='en') self.assertRedirects(response, '/en/account/register/') self.assertFalse(response.get('Vary')) response = self.client.get(response['location']) self.assertEqual(response.status_code, 200) self.assertFalse(response.get('Vary')) class URLRedirectWithoutTrailingSlashTests(URLTestCaseBase): """ Tests the redirect when the requested URL doesn't end with a slash (`settings.APPEND_SLASH=True`). """ def test_not_prefixed_redirect(self): response = self.client.get('/not-prefixed', HTTP_ACCEPT_LANGUAGE='en') self.assertRedirects(response, '/not-prefixed/', 301) def test_en_redirect(self): response = self.client.get('/account/register', HTTP_ACCEPT_LANGUAGE='en', follow=True) # We only want one redirect, bypassing CommonMiddleware self.assertListEqual(response.redirect_chain, [('/en/account/register/', 302)]) self.assertRedirects(response, '/en/account/register/', 302) response = self.client.get('/prefixed.xml', HTTP_ACCEPT_LANGUAGE='en', follow=True) self.assertRedirects(response, '/en/prefixed.xml', 302) class URLRedirectWithoutTrailingSlashSettingTests(URLTestCaseBase): """ Tests the redirect when the requested URL doesn't end with a slash (`settings.APPEND_SLASH=False`). """ @override_settings(APPEND_SLASH=False) def test_not_prefixed_redirect(self): response = self.client.get('/not-prefixed', HTTP_ACCEPT_LANGUAGE='en') self.assertEqual(response.status_code, 404) @override_settings(APPEND_SLASH=False) def test_en_redirect(self): response = self.client.get('/account/register-without-slash', HTTP_ACCEPT_LANGUAGE='en') self.assertRedirects(response, '/en/account/register-without-slash', 302) response = self.client.get(response['location']) self.assertEqual(response.status_code, 200) class URLResponseTests(URLTestCaseBase): """ Tests if the response has the right language-code. """ def test_not_prefixed_with_prefix(self): response = self.client.get('/en/not-prefixed/') self.assertEqual(response.status_code, 404) def test_en_url(self): response = self.client.get('/en/account/register/') self.assertEqual(response.status_code, 200) self.assertEqual(response['content-language'], 'en') self.assertEqual(response.context['LANGUAGE_CODE'], 'en') def test_nl_url(self): response = self.client.get('/nl/profiel/registeren/') self.assertEqual(response.status_code, 200) self.assertEqual(response['content-language'], 'nl') self.assertEqual(response.context['LANGUAGE_CODE'], 'nl') def test_wrong_en_prefix(self): response = self.client.get('/en/profiel/registeren/') self.assertEqual(response.status_code, 404) def test_wrong_nl_prefix(self): response = self.client.get('/nl/account/register/') self.assertEqual(response.status_code, 404) def test_pt_br_url(self): response = self.client.get('/pt-br/conta/registre-se/') self.assertEqual(response.status_code, 200) self.assertEqual(response['content-language'], 'pt-br') self.assertEqual(response.context['LANGUAGE_CODE'], 'pt-br') class URLRedirectWithScriptAliasTests(URLTestCaseBase): """ #21579 - LocaleMiddleware should respect the script prefix. """ def test_language_prefix_with_script_prefix(self): prefix = '/script_prefix' with override_script_prefix(prefix): response = self.client.get('/prefixed/', HTTP_ACCEPT_LANGUAGE='en', SCRIPT_NAME=prefix) self.assertRedirects(response, '%s/en/prefixed/' % prefix, target_status_code=404) class URLTagTests(URLTestCaseBase): """ Test if the language tag works. """ def test_strings_only(self): t = Template("""{% load i18n %} {% language 'nl' %}{% url 'no-prefix-translated' %}{% endlanguage %} {% language 'pt-br' %}{% url 'no-prefix-translated' %}{% endlanguage %}""") self.assertEqual(t.render(Context({})).strip().split(), ['/vertaald/', '/traduzidos/']) def test_context(self): ctx = Context({'lang1': 'nl', 'lang2': 'pt-br'}) tpl = Template("""{% load i18n %} {% language lang1 %}{% url 'no-prefix-translated' %}{% endlanguage %} {% language lang2 %}{% url 'no-prefix-translated' %}{% endlanguage %}""") self.assertEqual(tpl.render(ctx).strip().split(), ['/vertaald/', '/traduzidos/']) def test_args(self): tpl = Template("""{% load i18n %} {% language 'nl' %}{% url 'no-prefix-translated-slug' 'apo' %}{% endlanguage %} {% language 'pt-br' %}{% url 'no-prefix-translated-slug' 'apo' %}{% endlanguage %}""") self.assertEqual(tpl.render(Context({})).strip().split(), ['/vertaald/apo/', '/traduzidos/apo/']) def test_kwargs(self): tpl = Template("""{% load i18n %} {% language 'nl' %}{% url 'no-prefix-translated-slug' slug='apo' %}{% endlanguage %} {% language 'pt-br' %}{% url 'no-prefix-translated-slug' slug='apo' %}{% endlanguage %}""") self.assertEqual(tpl.render(Context({})).strip().split(), ['/vertaald/apo/', '/traduzidos/apo/'])
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 747, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1018, 14, 16522, 492, 5436, 63, 633, 63, 17595, 12, 3837, 12, 9028, 63, 633, 199, 504, 1639, 14, 1014, 492, 6183, 31776, 7071, 199, 504, 1639, 14, 5754, 14, 5508, 492, 28298, 6608, 199, 504, 1639, 14, 1160, 492, 9470, 12, 5458, 199, 504, 1639, 14, 396, 492, 24424, 12, 4278, 63, 1751, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1579, 63, 1861, 199, 504, 1639, 14, 1208, 492, 7761, 199, 504, 1639, 14, 1208, 423, 736, 492, 1536, 1619, 421, 199, 533, 3492, 11433, 7071, 20342, 30734, 55, 1530, 8, 20342, 6608, 304, 272, 1177, 63, 4876, 63, 533, 275, 6183, 31776, 7071, 421, 199, 32, 4415, 63, 1751, 8, 272, 4815, 63, 41, 1085, 46, 29, 549, 12, 272, 20639, 37, 63, 20202, 1524, 267, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 384, 1619, 3460, 493, 22159, 283, 5508, 659, 272, 2156, 272, 30508, 2962, 63, 6012, 534, 287, 13, 527, 297, 272, 30508, 5383, 1524, 267, 661, 7530, 297, 283, 36, 337, 335, 659, 267, 661, 287, 297, 283, 19410, 659, 267, 661, 541, 13, 3289, 297, 283, 17171, 90, 1638, 290, 10977, 1518, 310, 261, 659, 272, 2156, 272, 30718, 63, 13748, 1524, 267, 283, 1176, 14, 5754, 14, 5508, 14, 20342, 6608, 297, 267, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 272, 2156, 272, 16547, 63, 18125, 534, 73, 1085, 78, 14, 7435, 14, 3603, 14, 885, 297, 272, 377, 9358, 16601, 1524, 91, 267, 283, 18145, 356, 283, 1176, 14, 1160, 14, 7765, 14, 1176, 14, 9323, 17969, 297, 267, 283, 14455, 356, 359, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 384, 1619, 3460, 493, 22159, 283, 5876, 2665, 267, 283, 8808, 356, 469, 288, 283, 1100, 63, 10547, 356, 359, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 73, 1085, 78, 297, 288, 2156, 267, 1660, 272, 19971, 199, 9, 199, 533, 2851, 1746, 1563, 8, 17968, 304, 272, 408, 272, 7640, 1300, 13, 533, 367, 314, 2851, 2295, 14, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 327, 4155, 3238, 314, 2581, 365, 2701, 2544, 781, 787, 9689, 4154, 2295, 14, 267, 5436, 63, 633, 63, 17595, 342, 339, 347, 6766, 8, 277, 304, 267, 327, 4155, 3238, 781, 911, 10137, 376, 2701, 2581, 367, 1163, 511, 9403, 14, 267, 5436, 63, 633, 63, 17595, 342, 421, 199, 533, 2851, 4793, 2925, 8, 2632, 1746, 1563, 304, 272, 408, 272, 6496, 340, 314, 658, 73, 1085, 78, 63, 7435, 64, 365, 7791, 314, 2403, 6657, 14, 272, 408, 272, 347, 511, 63, 1397, 63, 27833, 8, 277, 304, 267, 543, 7761, 14, 4415, 360, 287, 735, 288, 291, 14, 629, 8, 4471, 360, 1397, 13, 27833, 659, 1994, 1397, 13, 27833, 6217, 288, 291, 14, 629, 8, 4471, 360, 1397, 13, 27833, 13, 12409, 13, 633, 659, 1994, 1397, 13, 27833, 13, 2613, 15, 1421, 6217, 267, 543, 7761, 14, 4415, 360, 7530, 735, 288, 291, 14, 629, 8, 4471, 360, 1397, 13, 27833, 659, 1994, 1397, 13, 27833, 6217, 288, 291, 14, 629, 8, 4471, 360, 1397, 13, 27833, 13, 12409, 13, 633, 659, 1994, 1397, 13, 27833, 13, 2613, 15, 1421, 6217, 339, 347, 511, 63, 27833, 8, 277, 304, 267, 543, 7761, 14, 4415, 360, 287, 735, 288, 291, 14, 629, 8, 4471, 360, 27833, 659, 1994, 287, 15, 27833, 6217, 267, 543, 7761, 14, 4415, 360, 7530, 735, 288, 291, 14, 629, 8, 4471, 360, 27833, 659, 1994, 7530, 15, 27833, 6217, 339, 768, 4415, 63, 1751, 8, 5441, 63, 18125, 534, 73, 1085, 78, 14, 7435, 14, 3603, 14, 10603, 358, 272, 347, 511, 63, 3197, 63, 1861, 63, 1180, 8, 277, 304, 267, 291, 14, 1855, 8, 8499, 10951, 12, 2400, 26, 3837, 360, 2048, 26, 2683, 1333, 421, 199, 32, 4415, 63, 1751, 8, 5441, 63, 18125, 534, 73, 1085, 78, 14, 7435, 14, 3603, 14, 7011, 358, 199, 533, 2851, 15049, 2925, 8, 2632, 1746, 1563, 304, 339, 768, 4415, 63, 1751, 8, 4701, 63, 41, 1085, 46, 29, 797, 9, 272, 347, 511, 63, 27833, 63, 73, 1085, 78, 63, 7011, 8, 277, 304, 267, 543, 7761, 14, 4415, 360, 287, 735, 288, 291, 14, 629, 8, 4471, 360, 27833, 659, 1994, 27833, 6217, 267, 543, 7761, 14, 4415, 360, 7530, 735, 288, 291, 14, 629, 8, 4471, 360, 27833, 659, 1994, 27833, 6217, 421, 199, 32, 4415, 63, 1751, 8, 5441, 63, 18125, 534, 73, 1085, 78, 14, 7435, 14, 3603, 14, 515, 63, 8618, 358, 199, 533, 6912, 20782, 2925, 8, 2632, 1746, 1563, 304, 272, 408, 272, 2670, 626, 340, 949, 284, 1085, 78, 63, 7435, 365, 1202, 315, 1738, 30009, 83, 12, 2066, 949, 272, 2637, 10361, 10986, 4079, 641, 1166, 2403, 14, 272, 408, 339, 347, 511, 63, 889, 63, 4159, 63, 8222, 8, 277, 304, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 7530, 15, 1421, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 629, 8, 1310, 459, 1317, 13, 3671, 995, 283, 287, 358, 267, 291, 14, 629, 8, 1310, 14, 1100, 459, 13947, 63, 6012, 995, 283, 287, 358, 421, 199, 533, 2851, 18483, 2925, 8, 2632, 1746, 1563, 304, 272, 408, 272, 6496, 340, 314, 3851, 13, 5465, 787, 14598, 6657, 334, 12541, 314, 272, 658, 73, 1085, 78, 63, 7435, 64, 436, 314, 3293, 658, 7435, 64, 805, 680, 272, 408, 272, 347, 511, 63, 889, 63, 1861, 63, 18065, 8, 277, 304, 267, 543, 7761, 14, 4415, 360, 287, 735, 288, 291, 14, 629, 8, 4471, 360, 889, 13, 1861, 13, 18065, 659, 1994, 18065, 6217, 288, 291, 14, 629, 8, 4471, 360, 889, 13, 1861, 13, 18065, 13, 5464, 297, 2074, 3713, 5464, 356, 283, 89, 4489, 72, 1604, 1994, 18065, 15, 89, 4489, 72, 6217, 398, 543, 7761, 14, 4415, 360, 7530, 735, 288, 291, 14, 629, 8 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 747, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1018, 14, 16522, 492, 5436, 63, 633, 63, 17595, 12, 3837, 12, 9028, 63, 633, 199, 504, 1639, 14, 1014, 492, 6183, 31776, 7071, 199, 504, 1639, 14, 5754, 14, 5508, 492, 28298, 6608, 199, 504, 1639, 14, 1160, 492, 9470, 12, 5458, 199, 504, 1639, 14, 396, 492, 24424, 12, 4278, 63, 1751, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1579, 63, 1861, 199, 504, 1639, 14, 1208, 492, 7761, 199, 504, 1639, 14, 1208, 423, 736, 492, 1536, 1619, 421, 199, 533, 3492, 11433, 7071, 20342, 30734, 55, 1530, 8, 20342, 6608, 304, 272, 1177, 63, 4876, 63, 533, 275, 6183, 31776, 7071, 421, 199, 32, 4415, 63, 1751, 8, 272, 4815, 63, 41, 1085, 46, 29, 549, 12, 272, 20639, 37, 63, 20202, 1524, 267, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 384, 1619, 3460, 493, 22159, 283, 5508, 659, 272, 2156, 272, 30508, 2962, 63, 6012, 534, 287, 13, 527, 297, 272, 30508, 5383, 1524, 267, 661, 7530, 297, 283, 36, 337, 335, 659, 267, 661, 287, 297, 283, 19410, 659, 267, 661, 541, 13, 3289, 297, 283, 17171, 90, 1638, 290, 10977, 1518, 310, 261, 659, 272, 2156, 272, 30718, 63, 13748, 1524, 267, 283, 1176, 14, 5754, 14, 5508, 14, 20342, 6608, 297, 267, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 272, 2156, 272, 16547, 63, 18125, 534, 73, 1085, 78, 14, 7435, 14, 3603, 14, 885, 297, 272, 377, 9358, 16601, 1524, 91, 267, 283, 18145, 356, 283, 1176, 14, 1160, 14, 7765, 14, 1176, 14, 9323, 17969, 297, 267, 283, 14455, 356, 359, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 384, 1619, 3460, 493, 22159, 283, 5876, 2665, 267, 283, 8808, 356, 469, 288, 283, 1100, 63, 10547, 356, 359, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 73, 1085, 78, 297, 288, 2156, 267, 1660, 272, 19971, 199, 9, 199, 533, 2851, 1746, 1563, 8, 17968, 304, 272, 408, 272, 7640, 1300, 13, 533, 367, 314, 2851, 2295, 14, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 327, 4155, 3238, 314, 2581, 365, 2701, 2544, 781, 787, 9689, 4154, 2295, 14, 267, 5436, 63, 633, 63, 17595, 342, 339, 347, 6766, 8, 277, 304, 267, 327, 4155, 3238, 781, 911, 10137, 376, 2701, 2581, 367, 1163, 511, 9403, 14, 267, 5436, 63, 633, 63, 17595, 342, 421, 199, 533, 2851, 4793, 2925, 8, 2632, 1746, 1563, 304, 272, 408, 272, 6496, 340, 314, 658, 73, 1085, 78, 63, 7435, 64, 365, 7791, 314, 2403, 6657, 14, 272, 408, 272, 347, 511, 63, 1397, 63, 27833, 8, 277, 304, 267, 543, 7761, 14, 4415, 360, 287, 735, 288, 291, 14, 629, 8, 4471, 360, 1397, 13, 27833, 659, 1994, 1397, 13, 27833, 6217, 288, 291, 14, 629, 8, 4471, 360, 1397, 13, 27833, 13, 12409, 13, 633, 659, 1994, 1397, 13, 27833, 13, 2613, 15, 1421, 6217, 267, 543, 7761, 14, 4415, 360, 7530, 735, 288, 291, 14, 629, 8, 4471, 360, 1397, 13, 27833, 659, 1994, 1397, 13, 27833, 6217, 288, 291, 14, 629, 8, 4471, 360, 1397, 13, 27833, 13, 12409, 13, 633, 659, 1994, 1397, 13, 27833, 13, 2613, 15, 1421, 6217, 339, 347, 511, 63, 27833, 8, 277, 304, 267, 543, 7761, 14, 4415, 360, 287, 735, 288, 291, 14, 629, 8, 4471, 360, 27833, 659, 1994, 287, 15, 27833, 6217, 267, 543, 7761, 14, 4415, 360, 7530, 735, 288, 291, 14, 629, 8, 4471, 360, 27833, 659, 1994, 7530, 15, 27833, 6217, 339, 768, 4415, 63, 1751, 8, 5441, 63, 18125, 534, 73, 1085, 78, 14, 7435, 14, 3603, 14, 10603, 358, 272, 347, 511, 63, 3197, 63, 1861, 63, 1180, 8, 277, 304, 267, 291, 14, 1855, 8, 8499, 10951, 12, 2400, 26, 3837, 360, 2048, 26, 2683, 1333, 421, 199, 32, 4415, 63, 1751, 8, 5441, 63, 18125, 534, 73, 1085, 78, 14, 7435, 14, 3603, 14, 7011, 358, 199, 533, 2851, 15049, 2925, 8, 2632, 1746, 1563, 304, 339, 768, 4415, 63, 1751, 8, 4701, 63, 41, 1085, 46, 29, 797, 9, 272, 347, 511, 63, 27833, 63, 73, 1085, 78, 63, 7011, 8, 277, 304, 267, 543, 7761, 14, 4415, 360, 287, 735, 288, 291, 14, 629, 8, 4471, 360, 27833, 659, 1994, 27833, 6217, 267, 543, 7761, 14, 4415, 360, 7530, 735, 288, 291, 14, 629, 8, 4471, 360, 27833, 659, 1994, 27833, 6217, 421, 199, 32, 4415, 63, 1751, 8, 5441, 63, 18125, 534, 73, 1085, 78, 14, 7435, 14, 3603, 14, 515, 63, 8618, 358, 199, 533, 6912, 20782, 2925, 8, 2632, 1746, 1563, 304, 272, 408, 272, 2670, 626, 340, 949, 284, 1085, 78, 63, 7435, 365, 1202, 315, 1738, 30009, 83, 12, 2066, 949, 272, 2637, 10361, 10986, 4079, 641, 1166, 2403, 14, 272, 408, 339, 347, 511, 63, 889, 63, 4159, 63, 8222, 8, 277, 304, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 7530, 15, 1421, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 629, 8, 1310, 459, 1317, 13, 3671, 995, 283, 287, 358, 267, 291, 14, 629, 8, 1310, 14, 1100, 459, 13947, 63, 6012, 995, 283, 287, 358, 421, 199, 533, 2851, 18483, 2925, 8, 2632, 1746, 1563, 304, 272, 408, 272, 6496, 340, 314, 3851, 13, 5465, 787, 14598, 6657, 334, 12541, 314, 272, 658, 73, 1085, 78, 63, 7435, 64, 436, 314, 3293, 658, 7435, 64, 805, 680, 272, 408, 272, 347, 511, 63, 889, 63, 1861, 63, 18065, 8, 277, 304, 267, 543, 7761, 14, 4415, 360, 287, 735, 288, 291, 14, 629, 8, 4471, 360, 889, 13, 1861, 13, 18065, 659, 1994, 18065, 6217, 288, 291, 14, 629, 8, 4471, 360, 889, 13, 1861, 13, 18065, 13, 5464, 297, 2074, 3713, 5464, 356, 283, 89, 4489, 72, 1604, 1994, 18065, 15, 89, 4489, 72, 6217, 398, 543, 7761, 14, 4415, 360, 7530, 735, 288, 291, 14, 629, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
joelddiaz/openshift-tools
openshift/installer/vendored/openshift-ansible-3.7.42-1/roles/lib_openshift/library/oc_adm_registry.py
3
94326
#!/usr/bin/env python # pylint: disable=missing-docstring # flake8: noqa: T001 # ___ ___ _ _ ___ ___ _ _____ ___ ___ # / __| __| \| | __| _ \ /_\_ _| __| \ # | (_ | _|| .` | _|| / / _ \| | | _|| |) | # \___|___|_|\_|___|_|_\/_/_\_\_|_|___|___/_ _____ # | \ / _ \ | \| |/ _ \_ _| | __| \_ _|_ _| # | |) | (_) | | .` | (_) || | | _|| |) | | | | # |___/ \___/ |_|\_|\___/ |_| |___|___/___| |_| # # Copyright 2016 Red Hat, Inc. and/or its affiliates # and other contributors as indicated by the @author tags. # # 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. # # -*- -*- -*- Begin included fragment: lib/import.py -*- -*- -*- ''' OpenShiftCLI class that wraps the oc commands in a subprocess ''' # pylint: disable=too-many-lines from __future__ import print_function import atexit import copy import json import os import re import shutil import subprocess import tempfile # pylint: disable=import-error try: import ruamel.yaml as yaml except ImportError: import yaml from ansible.module_utils.basic import AnsibleModule # -*- -*- -*- End included fragment: lib/import.py -*- -*- -*- # -*- -*- -*- Begin included fragment: doc/registry -*- -*- -*- DOCUMENTATION = ''' --- module: oc_adm_registry short_description: Module to manage openshift registry description: - Manage openshift registry programmatically. options: state: description: - The desired action when managing openshift registry - present - update or create the registry - absent - tear down the registry service and deploymentconfig - list - returns the current representiation of a registry required: false default: False aliases: [] kubeconfig: description: - The path for the kubeconfig file to use for authentication required: false default: /etc/origin/master/admin.kubeconfig aliases: [] debug: description: - Turn on debug output. required: false default: False aliases: [] name: description: - The name of the registry required: false default: None aliases: [] namespace: description: - The selector when filtering on node labels required: false default: None aliases: [] images: description: - The image to base this registry on - ${component} will be replaced with --type required: 'openshift3/ose-${component}:${version}' default: None aliases: [] latest_images: description: - If true, attempt to use the latest image for the registry instead of the latest release. required: false default: False aliases: [] labels: description: - A set of labels to uniquely identify the registry and its components. required: false default: None aliases: [] enforce_quota: description: - If set, the registry will refuse to write blobs if they exceed quota limits required: False default: False aliases: [] mount_host: description: - If set, the registry volume will be created as a host-mount at this path. required: False default: False aliases: [] ports: description: - A comma delimited list of ports or port pairs to expose on the registry pod. The default is set for 5000. required: False default: [5000] aliases: [] replicas: description: - The replication factor of the registry; commonly 2 when high availability is desired. required: False default: 1 aliases: [] selector: description: - Selector used to filter nodes on deployment. Used to run registries on a specific set of nodes. required: False default: None aliases: [] service_account: description: - Name of the service account to use to run the registry pod. required: False default: 'registry' aliases: [] tls_certificate: description: - An optional path to a PEM encoded certificate (which may contain the private key) for serving over TLS required: false default: None aliases: [] tls_key: description: - An optional path to a PEM encoded private key for serving over TLS required: false default: None aliases: [] volume_mounts: description: - The volume mounts for the registry. required: false default: None aliases: [] daemonset: description: - Use a daemonset instead of a deployment config. required: false default: False aliases: [] edits: description: - A list of modifications to make on the deploymentconfig required: false default: None aliases: [] env_vars: description: - A dictionary of modifications to make on the deploymentconfig. e.g. FOO: BAR required: false default: None aliases: [] force: description: - Force a registry update. required: false default: False aliases: [] author: - "Kenny Woodson <kwoodson@redhat.com>" extends_documentation_fragment: [] ''' EXAMPLES = ''' - name: create a secure registry oc_adm_registry: name: docker-registry service_account: registry replicas: 2 namespace: default selector: type=infra images: "registry.ops.openshift.com/openshift3/ose-${component}:${version}" env_vars: REGISTRY_CONFIGURATION_PATH: /etc/registryconfig/config.yml REGISTRY_HTTP_TLS_CERTIFICATE: /etc/secrets/registry.crt REGISTRY_HTTP_TLS_KEY: /etc/secrets/registry.key REGISTRY_HTTP_SECRET: supersecret volume_mounts: - path: /etc/secrets name: dockercerts type: secret secret_name: registry-secret - path: /etc/registryconfig name: dockersecrets type: secret secret_name: docker-registry-config edits: - key: spec.template.spec.containers[0].livenessProbe.httpGet.scheme value: HTTPS action: put - key: spec.template.spec.containers[0].readinessProbe.httpGet.scheme value: HTTPS action: put - key: spec.strategy.rollingParams value: intervalSeconds: 1 maxSurge: 50% maxUnavailable: 50% timeoutSeconds: 600 updatePeriodSeconds: 1 action: put - key: spec.template.spec.containers[0].resources.limits.memory value: 2G action: update - key: spec.template.spec.containers[0].resources.requests.memory value: 1G action: update register: registryout ''' # -*- -*- -*- End included fragment: doc/registry -*- -*- -*- # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z{}/_-]+)" com_sep = set(['.', '#', '|', ':']) # pylint: disable=too-many-arguments def __init__(self, filename=None, content=None, content_type='yaml', separator='.', backup=False): self.content = content self._separator = separator self.filename = filename self.__yaml_dict = content self.content_type = content_type self.backup = backup self.load(content_type=self.content_type) if self.__yaml_dict is None: self.__yaml_dict = {} @property def separator(self): ''' getter method for separator ''' return self._separator @separator.setter def separator(self, inc_sep): ''' setter method for separator ''' self._separator = inc_sep @property def yaml_dict(self): ''' getter method for yaml_dict ''' return self.__yaml_dict @yaml_dict.setter def yaml_dict(self, value): ''' setter method for yaml_dict ''' self.__yaml_dict = value @staticmethod def parse_key(key, sep='.'): '''parse the key allowing the appropriate separator''' common_separators = list(Yedit.com_sep - set([sep])) return re.findall(Yedit.re_key.format(''.join(common_separators)), key) @staticmethod def valid_key(key, sep='.'): '''validate the incoming key''' common_separators = list(Yedit.com_sep - set([sep])) if not re.match(Yedit.re_valid_key.format(''.join(common_separators)), key): return False return True @staticmethod def remove_entry(data, key, sep='.'): ''' remove data at location key ''' if key == '' and isinstance(data, dict): data.clear() return True elif key == '' and isinstance(data, list): del data[:] return True if not (key and Yedit.valid_key(key, sep)) and \ isinstance(data, (list, dict)): return None key_indexes = Yedit.parse_key(key, sep) for arr_ind, dict_key in key_indexes[:-1]: if dict_key and isinstance(data, dict): data = data.get(dict_key) elif (arr_ind and isinstance(data, list) and int(arr_ind) <= len(data) - 1): data = data[int(arr_ind)] else: return None # process last index for remove # expected list entry if key_indexes[-1][0]: if isinstance(data, list) and int(key_indexes[-1][0]) <= len(data) - 1: # noqa: E501 del data[int(key_indexes[-1][0])] return True # expected dict entry elif key_indexes[-1][1]: if isinstance(data, dict): del data[key_indexes[-1][1]] return True @staticmethod def add_entry(data, key, item=None, sep='.'): ''' Get an item from a dictionary with key notation a.b.c d = {'a': {'b': 'c'}}} key = a#b return c ''' if key == '': pass elif (not (key and Yedit.valid_key(key, sep)) and isinstance(data, (list, dict))): return None key_indexes = Yedit.parse_key(key, sep) for arr_ind, dict_key in key_indexes[:-1]: if dict_key: if isinstance(data, dict) and dict_key in data and data[dict_key]: # noqa: E501 data = data[dict_key] continue elif data and not isinstance(data, dict): raise YeditException("Unexpected item type found while going through key " + "path: {} (at key: {})".format(key, dict_key)) data[dict_key] = {} data = data[dict_key] elif (arr_ind and isinstance(data, list) and int(arr_ind) <= len(data) - 1): data = data[int(arr_ind)] else: raise YeditException("Unexpected item type found while going through key path: {}".format(key)) if key == '': data = item # process last index for add # expected list entry elif key_indexes[-1][0] and isinstance(data, list) and int(key_indexes[-1][0]) <= len(data) - 1: # noqa: E501 data[int(key_indexes[-1][0])] = item # expected dict entry elif key_indexes[-1][1] and isinstance(data, dict): data[key_indexes[-1][1]] = item # didn't add/update to an existing list, nor add/update key to a dict # so we must have been provided some syntax like a.b.c[<int>] = "data" for a # non-existent array else: raise YeditException("Error adding to object at path: {}".format(key)) return data @staticmethod def get_entry(data, key, sep='.'): ''' Get an item from a dictionary with key notation a.b.c d = {'a': {'b': 'c'}}} key = a.b return c ''' if key == '': pass elif (not (key and Yedit.valid_key(key, sep)) and isinstance(data, (list, dict))): return None key_indexes = Yedit.parse_key(key, sep) for arr_ind, dict_key in key_indexes: if dict_key and isinstance(data, dict): data = data.get(dict_key) elif (arr_ind and isinstance(data, list) and int(arr_ind) <= len(data) - 1): data = data[int(arr_ind)] else: return None return data @staticmethod def _write(filename, contents): ''' Actually write the file contents to disk. This helps with mocking. ''' tmp_filename = filename + '.yedit' with open(tmp_filename, 'w') as yfd: yfd.write(contents) os.rename(tmp_filename, filename) def write(self): ''' write to file ''' if not self.filename: raise YeditException('Please specify a filename.') if self.backup and self.file_exists(): shutil.copy(self.filename, self.filename + '.orig') # Try to set format attributes if supported try: self.yaml_dict.fa.set_block_style() except AttributeError: pass # Try to use RoundTripDumper if supported. try: Yedit._write(self.filename, yaml.dump(self.yaml_dict, Dumper=yaml.RoundTripDumper)) except AttributeError: Yedit._write(self.filename, yaml.safe_dump(self.yaml_dict, default_flow_style=False)) return (True, self.yaml_dict) def read(self): ''' read from file ''' # check if it exists if self.filename is None or not self.file_exists(): return None contents = None with open(self.filename) as yfd: contents = yfd.read() return contents def file_exists(self): ''' return whether file exists ''' if os.path.exists(self.filename): return True return False def load(self, content_type='yaml'): ''' return yaml file ''' contents = self.read() if not contents and not self.content: return None if self.content: if isinstance(self.content, dict): self.yaml_dict = self.content return self.yaml_dict elif isinstance(self.content, str): contents = self.content # check if it is yaml try: if content_type == 'yaml' and contents: # Try to set format attributes if supported try: self.yaml_dict.fa.set_block_style() except AttributeError: pass # Try to use RoundTripLoader if supported. try: self.yaml_dict = yaml.safe_load(contents, yaml.RoundTripLoader) except AttributeError: self.yaml_dict = yaml.safe_load(contents) # Try to set format attributes if supported try: self.yaml_dict.fa.set_block_style() except AttributeError: pass elif content_type == 'json' and contents: self.yaml_dict = json.loads(contents) except yaml.YAMLError as err: # Error loading yaml or json raise YeditException('Problem with loading yaml file. {}'.format(err)) return self.yaml_dict def get(self, key): ''' get a specified key''' try: entry = Yedit.get_entry(self.yaml_dict, key, self.separator) except KeyError: entry = None return entry def pop(self, path, key_or_item): ''' remove a key, value pair from a dict or an item for a list''' try: entry = Yedit.get_entry(self.yaml_dict, path, self.separator) except KeyError: entry = None if entry is None: return (False, self.yaml_dict) if isinstance(entry, dict): # AUDIT:maybe-no-member makes sense due to fuzzy types # pylint: disable=maybe-no-member if key_or_item in entry: entry.pop(key_or_item) return (True, self.yaml_dict) return (False, self.yaml_dict) elif isinstance(entry, list): # AUDIT:maybe-no-member makes sense due to fuzzy types # pylint: disable=maybe-no-member ind = None try: ind = entry.index(key_or_item) except ValueError: return (False, self.yaml_dict) entry.pop(ind) return (True, self.yaml_dict) return (False, self.yaml_dict) def delete(self, path): ''' remove path from a dict''' try: entry = Yedit.get_entry(self.yaml_dict, path, self.separator) except KeyError: entry = None if entry is None: return (False, self.yaml_dict) result = Yedit.remove_entry(self.yaml_dict, path, self.separator) if not result: return (False, self.yaml_dict) return (True, self.yaml_dict) def exists(self, path, value): ''' check if value exists at path''' try: entry = Yedit.get_entry(self.yaml_dict, path, self.separator) except KeyError: entry = None if isinstance(entry, list): if value in entry: return True return False elif isinstance(entry, dict): if isinstance(value, dict): rval = False for key, val in value.items(): if entry[key] != val: rval = False break else: rval = True return rval return value in entry return entry == value def append(self, path, value): '''append value to a list''' try: entry = Yedit.get_entry(self.yaml_dict, path, self.separator) except KeyError: entry = None if entry is None: self.put(path, []) entry = Yedit.get_entry(self.yaml_dict, path, self.separator) if not isinstance(entry, list): return (False, self.yaml_dict) # AUDIT:maybe-no-member makes sense due to loading data from # a serialized format. # pylint: disable=maybe-no-member entry.append(value) return (True, self.yaml_dict) # pylint: disable=too-many-arguments def update(self, path, value, index=None, curr_value=None): ''' put path, value into a dict ''' try: entry = Yedit.get_entry(self.yaml_dict, path, self.separator) except KeyError: entry = None if isinstance(entry, dict): # AUDIT:maybe-no-member makes sense due to fuzzy types # pylint: disable=maybe-no-member if not isinstance(value, dict): raise YeditException('Cannot replace key, value entry in dict with non-dict type. ' + 'value=[{}] type=[{}]'.format(value, type(value))) entry.update(value) return (True, self.yaml_dict) elif isinstance(entry, list): # AUDIT:maybe-no-member makes sense due to fuzzy types # pylint: disable=maybe-no-member ind = None if curr_value: try: ind = entry.index(curr_value) except ValueError: return (False, self.yaml_dict) elif index is not None: ind = index if ind is not None and entry[ind] != value: entry[ind] = value return (True, self.yaml_dict) # see if it exists in the list try: ind = entry.index(value) except ValueError: # doesn't exist, append it entry.append(value) return (True, self.yaml_dict) # already exists, return if ind is not None: return (False, self.yaml_dict) return (False, self.yaml_dict) def put(self, path, value): ''' put path, value into a dict ''' try: entry = Yedit.get_entry(self.yaml_dict, path, self.separator) except KeyError: entry = None if entry == value: return (False, self.yaml_dict) # deepcopy didn't work # Try to use ruamel.yaml and fallback to pyyaml try: tmp_copy = yaml.load(yaml.round_trip_dump(self.yaml_dict, default_flow_style=False), yaml.RoundTripLoader) except AttributeError: tmp_copy = copy.deepcopy(self.yaml_dict) # set the format attributes if available try: tmp_copy.fa.set_block_style() except AttributeError: pass result = Yedit.add_entry(tmp_copy, path, value, self.separator) if result is None: return (False, self.yaml_dict) # When path equals "" it is a special case. # "" refers to the root of the document # Only update the root path (entire document) when its a list or dict if path == '': if isinstance(result, list) or isinstance(result, dict): self.yaml_dict = result return (True, self.yaml_dict) return (False, self.yaml_dict) self.yaml_dict = tmp_copy return (True, self.yaml_dict) def create(self, path, value): ''' create a yaml file ''' if not self.file_exists(): # deepcopy didn't work # Try to use ruamel.yaml and fallback to pyyaml try: tmp_copy = yaml.load(yaml.round_trip_dump(self.yaml_dict, default_flow_style=False), yaml.RoundTripLoader) except AttributeError: tmp_copy = copy.deepcopy(self.yaml_dict) # set the format attributes if available try: tmp_copy.fa.set_block_style() except AttributeError: pass result = Yedit.add_entry(tmp_copy, path, value, self.separator) if result is not None: self.yaml_dict = tmp_copy return (True, self.yaml_dict) return (False, self.yaml_dict) @staticmethod def get_curr_value(invalue, val_type): '''return the current value''' if invalue is None: return None curr_value = invalue if val_type == 'yaml': curr_value = yaml.load(invalue) elif val_type == 'json': curr_value = json.loads(invalue) return curr_value @staticmethod def parse_value(inc_value, vtype=''): '''determine value type passed''' true_bools = ['y', 'Y', 'yes', 'Yes', 'YES', 'true', 'True', 'TRUE', 'on', 'On', 'ON', ] false_bools = ['n', 'N', 'no', 'No', 'NO', 'false', 'False', 'FALSE', 'off', 'Off', 'OFF'] # It came in as a string but you didn't specify value_type as string # we will convert to bool if it matches any of the above cases if isinstance(inc_value, str) and 'bool' in vtype: if inc_value not in true_bools and inc_value not in false_bools: raise YeditException('Not a boolean type. str=[{}] vtype=[{}]'.format(inc_value, vtype)) elif isinstance(inc_value, bool) and 'str' in vtype: inc_value = str(inc_value) # There is a special case where '' will turn into None after yaml loading it so skip if isinstance(inc_value, str) and inc_value == '': pass # If vtype is not str then go ahead and attempt to yaml load it. elif isinstance(inc_value, str) and 'str' not in vtype: try: inc_value = yaml.safe_load(inc_value) except Exception: raise YeditException('Could not determine type of incoming value. ' + 'value=[{}] vtype=[{}]'.format(type(inc_value), vtype)) return inc_value @staticmethod def process_edits(edits, yamlfile): '''run through a list of edits and process them one-by-one''' results = [] for edit in edits: value = Yedit.parse_value(edit['value'], edit.get('value_type', '')) if edit.get('action') == 'update': # pylint: disable=line-too-long curr_value = Yedit.get_curr_value( Yedit.parse_value(edit.get('curr_value')), edit.get('curr_value_format')) rval = yamlfile.update(edit['key'], value, edit.get('index'), curr_value) elif edit.get('action') == 'append': rval = yamlfile.append(edit['key'], value) else: rval = yamlfile.put(edit['key'], value) if rval[0]: results.append({'key': edit['key'], 'edit': rval[1]}) return {'changed': len(results) > 0, 'results': results} # pylint: disable=too-many-return-statements,too-many-branches @staticmethod def run_ansible(params): '''perform the idempotent crud operations''' yamlfile = Yedit(filename=params['src'], backup=params['backup'], separator=params['separator']) state = params['state'] if params['src']: rval = yamlfile.load() if yamlfile.yaml_dict is None and state != 'present': return {'failed': True, 'msg': 'Error opening file [{}]. Verify that the '.format(params['src']) + 'file exists, that it is has correct permissions, and is valid yaml.'} if state == 'list': if params['content']: content = Yedit.parse_value(params['content'], params['content_type']) yamlfile.yaml_dict = content if params['key']: rval = yamlfile.get(params['key']) return {'changed': False, 'result': rval, 'state': state} elif state == 'absent': if params['content']: content = Yedit.parse_value(params['content'], params['content_type']) yamlfile.yaml_dict = content if params['update']: rval = yamlfile.pop(params['key'], params['value']) else: rval = yamlfile.delete(params['key']) if rval[0] and params['src']: yamlfile.write() return {'changed': rval[0], 'result': rval[1], 'state': state} elif state == 'present': # check if content is different than what is in the file if params['content']: content = Yedit.parse_value(params['content'], params['content_type']) # We had no edits to make and the contents are the same if yamlfile.yaml_dict == content and \ params['value'] is None: return {'changed': False, 'result': yamlfile.yaml_dict, 'state': state} yamlfile.yaml_dict = content # If we were passed a key, value then # we enapsulate it in a list and process it # Key, Value passed to the module : Converted to Edits list # edits = [] _edit = {} if params['value'] is not None: _edit['value'] = params['value'] _edit['value_type'] = params['value_type'] _edit['key'] = params['key'] if params['update']: _edit['action'] = 'update' _edit['curr_value'] = params['curr_value'] _edit['curr_value_format'] = params['curr_value_format'] _edit['index'] = params['index'] elif params['append']: _edit['action'] = 'append' edits.append(_edit) elif params['edits'] is not None: edits = params['edits'] if edits: results = Yedit.process_edits(edits, yamlfile) # if there were changes and a src provided to us we need to write if results['changed'] and params['src']: yamlfile.write() return {'changed': results['changed'], 'result': results['results'], 'state': state} # no edits to make if params['src']: # pylint: disable=redefined-variable-type rval = yamlfile.write() return {'changed': rval[0], 'result': rval[1], 'state': state} # We were passed content but no src, key or value, or edits. Return contents in memory return {'changed': False, 'result': yamlfile.yaml_dict, 'state': state} return {'failed': True, 'msg': 'Unkown state passed'} # -*- -*- -*- End included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- # -*- -*- -*- Begin included fragment: lib/base.py -*- -*- -*- # pylint: disable=too-many-lines # noqa: E301,E302,E303,T001 class OpenShiftCLIError(Exception): '''Exception class for openshiftcli''' pass ADDITIONAL_PATH_LOOKUPS = ['/usr/local/bin', os.path.expanduser('~/bin')] def locate_oc_binary(): ''' Find and return oc binary file ''' # https://github.com/openshift/openshift-ansible/issues/3410 # oc can be in /usr/local/bin in some cases, but that may not # be in $PATH due to ansible/sudo paths = os.environ.get("PATH", os.defpath).split(os.pathsep) + ADDITIONAL_PATH_LOOKUPS oc_binary = 'oc' # Use shutil.which if it is available, otherwise fallback to a naive path search try: which_result = shutil.which(oc_binary, path=os.pathsep.join(paths)) if which_result is not None: oc_binary = which_result except AttributeError: for path in paths: if os.path.exists(os.path.join(path, oc_binary)): oc_binary = os.path.join(path, oc_binary) break return oc_binary # pylint: disable=too-few-public-methods class OpenShiftCLI(object): ''' Class to wrap the command line tools ''' def __init__(self, namespace, kubeconfig='/etc/origin/master/admin.kubeconfig', verbose=False, all_namespaces=False): ''' Constructor for OpenshiftCLI ''' self.namespace = namespace self.verbose = verbose self.kubeconfig = Utils.create_tmpfile_copy(kubeconfig) self.all_namespaces = all_namespaces self.oc_binary = locate_oc_binary() # Pylint allows only 5 arguments to be passed. # pylint: disable=too-many-arguments def _replace_content(self, resource, rname, content, force=False, sep='.'): ''' replace the current object with the content ''' res = self._get(resource, rname) if not res['results']: return res fname = Utils.create_tmpfile(rname + '-') yed = Yedit(fname, res['results'][0], separator=sep) changes = [] for key, value in content.items(): changes.append(yed.put(key, value)) if any([change[0] for change in changes]): yed.write() atexit.register(Utils.cleanup, [fname]) return self._replace(fname, force) return {'returncode': 0, 'updated': False} def _replace(self, fname, force=False): '''replace the current object with oc replace''' # We are removing the 'resourceVersion' to handle # a race condition when modifying oc objects yed = Yedit(fname) results = yed.delete('metadata.resourceVersion') if results[0]: yed.write() cmd = ['replace', '-f', fname] if force: cmd.append('--force') return self.openshift_cmd(cmd) def _create_from_content(self, rname, content): '''create a temporary file and then call oc create on it''' fname = Utils.create_tmpfile(rname + '-') yed = Yedit(fname, content=content) yed.write() atexit.register(Utils.cleanup, [fname]) return self._create(fname) def _create(self, fname): '''call oc create on a filename''' return self.openshift_cmd(['create', '-f', fname]) def _delete(self, resource, name=None, selector=None): '''call oc delete on a resource''' cmd = ['delete', resource] if selector is not None: cmd.append('--selector={}'.format(selector)) elif name is not None: cmd.append(name) else: raise OpenShiftCLIError('Either name or selector is required when calling delete.') return self.openshift_cmd(cmd) def _process(self, template_name, create=False, params=None, template_data=None): # noqa: E501 '''process a template template_name: the name of the template to process create: whether to send to oc create after processing params: the parameters for the template template_data: the incoming template's data; instead of a file ''' cmd = ['process'] if template_data: cmd.extend(['-f', '-']) else: cmd.append(template_name) if params: param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()] cmd.append('-v') cmd.extend(param_str) results = self.openshift_cmd(cmd, output=True, input_data=template_data) if results['returncode'] != 0 or not create: return results fname = Utils.create_tmpfile(template_name + '-') yed = Yedit(fname, results['results']) yed.write() atexit.register(Utils.cleanup, [fname]) return self.openshift_cmd(['create', '-f', fname]) def _get(self, resource, name=None, selector=None): '''return a resource by name ''' cmd = ['get', resource] if selector is not None: cmd.append('--selector={}'.format(selector)) elif name is not None: cmd.append(name) cmd.extend(['-o', 'json']) rval = self.openshift_cmd(cmd, output=True) # Ensure results are retuned in an array if 'items' in rval: rval['results'] = rval['items'] elif not isinstance(rval['results'], list): rval['results'] = [rval['results']] return rval def _schedulable(self, node=None, selector=None, schedulable=True): ''' perform oadm manage-node scheduable ''' cmd = ['manage-node'] if node: cmd.extend(node) else: cmd.append('--selector={}'.format(selector)) cmd.append('--schedulable={}'.format(schedulable)) return self.openshift_cmd(cmd, oadm=True, output=True, output_type='raw') # noqa: E501 def _list_pods(self, node=None, selector=None, pod_selector=None): ''' perform oadm list pods node: the node in which to list pods selector: the label selector filter if provided pod_selector: the pod selector filter if provided ''' cmd = ['manage-node'] if node: cmd.extend(node) else: cmd.append('--selector={}'.format(selector)) if pod_selector: cmd.append('--pod-selector={}'.format(pod_selector)) cmd.extend(['--list-pods', '-o', 'json']) return self.openshift_cmd(cmd, oadm=True, output=True, output_type='raw') # pylint: disable=too-many-arguments def _evacuate(self, node=None, selector=None, pod_selector=None, dry_run=False, grace_period=None, force=False): ''' perform oadm manage-node evacuate ''' cmd = ['manage-node'] if node: cmd.extend(node) else: cmd.append('--selector={}'.format(selector)) if dry_run: cmd.append('--dry-run') if pod_selector: cmd.append('--pod-selector={}'.format(pod_selector)) if grace_period: cmd.append('--grace-period={}'.format(int(grace_period))) if force: cmd.append('--force') cmd.append('--evacuate') return self.openshift_cmd(cmd, oadm=True, output=True, output_type='raw') def _version(self): ''' return the openshift version''' return self.openshift_cmd(['version'], output=True, output_type='raw') def _import_image(self, url=None, name=None, tag=None): ''' perform image import ''' cmd = ['import-image'] image = '{0}'.format(name) if tag: image += ':{0}'.format(tag) cmd.append(image) if url: cmd.append('--from={0}/{1}'.format(url, image)) cmd.append('-n{0}'.format(self.namespace)) cmd.append('--confirm') return self.openshift_cmd(cmd) def _run(self, cmds, input_data): ''' Actually executes the command. This makes mocking easier. ''' curr_env = os.environ.copy() curr_env.update({'KUBECONFIG': self.kubeconfig}) proc = subprocess.Popen(cmds, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=curr_env) stdout, stderr = proc.communicate(input_data) return proc.returncode, stdout.decode('utf-8'), stderr.decode('utf-8') # pylint: disable=too-many-arguments,too-many-branches def openshift_cmd(self, cmd, oadm=False, output=False, output_type='json', input_data=None): '''Base command for oc ''' cmds = [self.oc_binary] if oadm: cmds.append('adm') cmds.extend(cmd) if self.all_namespaces: cmds.extend(['--all-namespaces']) elif self.namespace is not None and self.namespace.lower() not in ['none', 'emtpy']: # E501 cmds.extend(['-n', self.namespace]) if self.verbose: print(' '.join(cmds)) try: returncode, stdout, stderr = self._run(cmds, input_data) except OSError as ex: returncode, stdout, stderr = 1, '', 'Failed to execute {}: {}'.format(subprocess.list2cmdline(cmds), ex) rval = {"returncode": returncode, "cmd": ' '.join(cmds)} if output_type == 'json': rval['results'] = {} if output and stdout: try: rval['results'] = json.loads(stdout) except ValueError as verr: if "No JSON object could be decoded" in verr.args: rval['err'] = verr.args elif output_type == 'raw': rval['results'] = stdout if output else '' if self.verbose: print("STDOUT: {0}".format(stdout)) print("STDERR: {0}".format(stderr)) if 'err' in rval or returncode != 0: rval.update({"stderr": stderr, "stdout": stdout}) return rval class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod def _write(filename, contents): ''' Actually write the file contents to disk. This helps with mocking. ''' with open(filename, 'w') as sfd: sfd.write(str(contents)) @staticmethod def create_tmp_file_from_contents(rname, data, ftype='yaml'): ''' create a file in tmp with name and contents''' tmp = Utils.create_tmpfile(prefix=rname) if ftype == 'yaml': # AUDIT:no-member makes sense here due to ruamel.YAML/PyYAML usage # pylint: disable=no-member if hasattr(yaml, 'RoundTripDumper'): Utils._write(tmp, yaml.dump(data, Dumper=yaml.RoundTripDumper)) else: Utils._write(tmp, yaml.safe_dump(data, default_flow_style=False)) elif ftype == 'json': Utils._write(tmp, json.dumps(data)) else: Utils._write(tmp, data) # Register cleanup when module is done atexit.register(Utils.cleanup, [tmp]) return tmp @staticmethod def create_tmpfile_copy(inc_file): '''create a temporary copy of a file''' tmpfile = Utils.create_tmpfile('lib_openshift-') Utils._write(tmpfile, open(inc_file).read()) # Cleanup the tmpfile atexit.register(Utils.cleanup, [tmpfile]) return tmpfile @staticmethod def create_tmpfile(prefix='tmp'): ''' Generates and returns a temporary file name ''' with tempfile.NamedTemporaryFile(prefix=prefix, delete=False) as tmp: return tmp.name @staticmethod def create_tmp_files_from_contents(content, content_type=None): '''Turn an array of dict: filename, content into a files array''' if not isinstance(content, list): content = [content] files = [] for item in content: path = Utils.create_tmp_file_from_contents(item['path'] + '-', item['data'], ftype=content_type) files.append({'name': os.path.basename(item['path']), 'path': path}) return files @staticmethod def cleanup(files): '''Clean up on exit ''' for sfile in files: if os.path.exists(sfile): if os.path.isdir(sfile): shutil.rmtree(sfile) elif os.path.isfile(sfile): os.remove(sfile) @staticmethod def exists(results, _name): ''' Check to see if the results include the name ''' if not results: return False if Utils.find_result(results, _name): return True return False @staticmethod def find_result(results, _name): ''' Find the specified result by name''' rval = None for result in results: if 'metadata' in result and result['metadata']['name'] == _name: rval = result break return rval @staticmethod def get_resource_file(sfile, sfile_type='yaml'): ''' return the service file ''' contents = None with open(sfile) as sfd: contents = sfd.read() if sfile_type == 'yaml': # AUDIT:no-member makes sense here due to ruamel.YAML/PyYAML usage # pylint: disable=no-member if hasattr(yaml, 'RoundTripLoader'): contents = yaml.load(contents, yaml.RoundTripLoader) else: contents = yaml.safe_load(contents) elif sfile_type == 'json': contents = json.loads(contents) return contents @staticmethod def filter_versions(stdout): ''' filter the oc version output ''' version_dict = {} version_search = ['oc', 'openshift', 'kubernetes'] for line in stdout.strip().split('\n'): for term in version_search: if not line: continue if line.startswith(term): version_dict[term] = line.split()[-1] # horrible hack to get openshift version in Openshift 3.2 # By default "oc version in 3.2 does not return an "openshift" version if "openshift" not in version_dict: version_dict["openshift"] = version_dict["oc"] return version_dict @staticmethod def add_custom_versions(versions): ''' create custom versions strings ''' versions_dict = {} for tech, version in versions.items(): # clean up "-" from version if "-" in version: version = version.split("-")[0] if version.startswith('v'): version = version[1:] # Remove the 'v' prefix versions_dict[tech + '_numeric'] = version.split('+')[0] # "3.3.0.33" is what we have, we want "3.3" versions_dict[tech + '_short'] = "{}.{}".format(*version.split('.')) return versions_dict @staticmethod def openshift_installed(): ''' check if openshift is installed ''' import rpm transaction_set = rpm.TransactionSet() rpmquery = transaction_set.dbMatch("name", "atomic-openshift") return rpmquery.count() > 0 # Disabling too-many-branches. This is a yaml dictionary comparison function # pylint: disable=too-many-branches,too-many-return-statements,too-many-statements @staticmethod def check_def_equal(user_def, result_def, skip_keys=None, debug=False): ''' Given a user defined definition, compare it with the results given back by our query. ''' # Currently these values are autogenerated and we do not need to check them skip = ['metadata', 'status'] if skip_keys: skip.extend(skip_keys) for key, value in result_def.items(): if key in skip: continue # Both are lists if isinstance(value, list): if key not in user_def: if debug: print('User data does not have key [%s]' % key) print('User data: %s' % user_def) return False if not isinstance(user_def[key], list): if debug: print('user_def[key] is not a list key=[%s] user_def[key]=%s' % (key, user_def[key])) return False if len(user_def[key]) != len(value): if debug: print("List lengths are not equal.") print("key=[%s]: user_def[%s] != value[%s]" % (key, len(user_def[key]), len(value))) print("user_def: %s" % user_def[key]) print("value: %s" % value) return False for values in zip(user_def[key], value): if isinstance(values[0], dict) and isinstance(values[1], dict): if debug: print('sending list - list') print(type(values[0])) print(type(values[1])) result = Utils.check_def_equal(values[0], values[1], skip_keys=skip_keys, debug=debug) if not result: print('list compare returned false') return False elif value != user_def[key]: if debug: print('value should be identical') print(user_def[key]) print(value) return False # recurse on a dictionary elif isinstance(value, dict): if key not in user_def: if debug: print("user_def does not have key [%s]" % key) return False if not isinstance(user_def[key], dict): if debug: print("dict returned false: not instance of dict") return False # before passing ensure keys match api_values = set(value.keys()) - set(skip) user_values = set(user_def[key].keys()) - set(skip) if api_values != user_values: if debug: print("keys are not equal in dict") print(user_values) print(api_values) return False result = Utils.check_def_equal(user_def[key], value, skip_keys=skip_keys, debug=debug) if not result: if debug: print("dict returned false") print(result) return False # Verify each key, value pair is the same else: if key not in user_def or value != user_def[key]: if debug: print("value not equal; user_def does not have key") print(key) print(value) if key in user_def: print(user_def[key]) return False if debug: print('returning true') return True class OpenShiftCLIConfig(object): '''Generic Config''' def __init__(self, rname, namespace, kubeconfig, options): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace self._options = options @property def config_options(self): ''' return config options ''' return self._options def to_option_list(self, ascommalist=''): '''return all options as a string if ascommalist is set to the name of a key, and the value of that key is a dict, format the dict as a list of comma delimited key=value pairs''' return self.stringify(ascommalist) def stringify(self, ascommalist=''): ''' return the options hash as cli params in a string if ascommalist is set to the name of a key, and the value of that key is a dict, format the dict as a list of comma delimited key=value pairs ''' rval = [] for key in sorted(self.config_options.keys()): data = self.config_options[key] if data['include'] \ and (data['value'] is not None or isinstance(data['value'], int)): if key == ascommalist: val = ','.join(['{}={}'.format(kk, vv) for kk, vv in sorted(data['value'].items())]) else: val = data['value'] rval.append('--{}={}'.format(key.replace('_', '-'), val)) return rval # -*- -*- -*- End included fragment: lib/base.py -*- -*- -*- # -*- -*- -*- Begin included fragment: lib/deploymentconfig.py -*- -*- -*- # pylint: disable=too-many-public-methods class DeploymentConfig(Yedit): ''' Class to model an openshift DeploymentConfig''' default_deployment_config = ''' apiVersion: v1 kind: DeploymentConfig metadata: name: default_dc namespace: default spec: replicas: 0 selector: default_dc: default_dc strategy: resources: {} rollingParams: intervalSeconds: 1 maxSurge: 0 maxUnavailable: 25% timeoutSeconds: 600 updatePercent: -25 updatePeriodSeconds: 1 type: Rolling template: metadata: spec: containers: - env: - name: default value: default image: default imagePullPolicy: IfNotPresent name: default_dc ports: - containerPort: 8000 hostPort: 8000 protocol: TCP name: default_port resources: {} terminationMessagePath: /dev/termination-log dnsPolicy: ClusterFirst hostNetwork: true nodeSelector: type: compute restartPolicy: Always securityContext: {} serviceAccount: default serviceAccountName: default terminationGracePeriodSeconds: 30 triggers: - type: ConfigChange ''' replicas_path = "spec.replicas" env_path = "spec.template.spec.containers[0].env" volumes_path = "spec.template.spec.volumes" container_path = "spec.template.spec.containers" volume_mounts_path = "spec.template.spec.containers[0].volumeMounts" def __init__(self, content=None): ''' Constructor for deploymentconfig ''' if not content: content = DeploymentConfig.default_deployment_config super(DeploymentConfig, self).__init__(content=content) def add_env_value(self, key, value): ''' add key, value pair to env array ''' rval = False env = self.get_env_vars() if env: env.append({'name': key, 'value': value}) rval = True else: result = self.put(DeploymentConfig.env_path, {'name': key, 'value': value}) rval = result[0] return rval def exists_env_value(self, key, value): ''' return whether a key, value pair exists ''' results = self.get_env_vars() if not results: return False for result in results: if result['name'] == key and result['value'] == value: return True return False def exists_env_key(self, key): ''' return whether a key, value pair exists ''' results = self.get_env_vars() if not results: return False for result in results: if result['name'] == key: return True return False def get_env_var(self, key): '''return a environment variables ''' results = self.get(DeploymentConfig.env_path) or [] if not results: return None for env_var in results: if env_var['name'] == key: return env_var return None def get_env_vars(self): '''return a environment variables ''' return self.get(DeploymentConfig.env_path) or [] def delete_env_var(self, keys): '''delete a list of keys ''' if not isinstance(keys, list): keys = [keys] env_vars_array = self.get_env_vars() modified = False idx = None for key in keys: for env_idx, env_var in enumerate(env_vars_array): if env_var['name'] == key: idx = env_idx break if idx: modified = True del env_vars_array[idx] if modified: return True return False def update_env_var(self, key, value): '''place an env in the env var list''' env_vars_array = self.get_env_vars() idx = None for env_idx, env_var in enumerate(env_vars_array): if env_var['name'] == key: idx = env_idx break if idx: env_vars_array[idx]['value'] = value else: self.add_env_value(key, value) return True def exists_volume_mount(self, volume_mount): ''' return whether a volume mount exists ''' exist_volume_mounts = self.get_volume_mounts() if not exist_volume_mounts: return False volume_mount_found = False for exist_volume_mount in exist_volume_mounts: if exist_volume_mount['name'] == volume_mount['name']: volume_mount_found = True break return volume_mount_found def exists_volume(self, volume): ''' return whether a volume exists ''' exist_volumes = self.get_volumes() volume_found = False for exist_volume in exist_volumes: if exist_volume['name'] == volume['name']: volume_found = True break return volume_found def find_volume_by_name(self, volume, mounts=False): ''' return the index of a volume ''' volumes = [] if mounts: volumes = self.get_volume_mounts() else: volumes = self.get_volumes() for exist_volume in volumes: if exist_volume['name'] == volume['name']: return exist_volume return None def get_replicas(self): ''' return replicas setting ''' return self.get(DeploymentConfig.replicas_path) def get_volume_mounts(self): '''return volume mount information ''' return self.get_volumes(mounts=True) def get_volumes(self, mounts=False): '''return volume mount information ''' if mounts: return self.get(DeploymentConfig.volume_mounts_path) or [] return self.get(DeploymentConfig.volumes_path) or [] def delete_volume_by_name(self, volume): '''delete a volume ''' modified = False exist_volume_mounts = self.get_volume_mounts() exist_volumes = self.get_volumes() del_idx = None for idx, exist_volume in enumerate(exist_volumes): if 'name' in exist_volume and exist_volume['name'] == volume['name']: del_idx = idx break if del_idx != None: del exist_volumes[del_idx] modified = True del_idx = None for idx, exist_volume_mount in enumerate(exist_volume_mounts): if 'name' in exist_volume_mount and exist_volume_mount['name'] == volume['name']: del_idx = idx break if del_idx != None: del exist_volume_mounts[idx] modified = True return modified def add_volume_mount(self, volume_mount): ''' add a volume or volume mount to the proper location ''' exist_volume_mounts = self.get_volume_mounts() if not exist_volume_mounts and volume_mount: self.put(DeploymentConfig.volume_mounts_path, [volume_mount]) else: exist_volume_mounts.append(volume_mount) def add_volume(self, volume): ''' add a volume or volume mount to the proper location ''' exist_volumes = self.get_volumes() if not volume: return if not exist_volumes: self.put(DeploymentConfig.volumes_path, [volume]) else: exist_volumes.append(volume) def update_replicas(self, replicas): ''' update replicas value ''' self.put(DeploymentConfig.replicas_path, replicas) def update_volume(self, volume): '''place an env in the env var list''' exist_volumes = self.get_volumes() if not volume: return False # update the volume update_idx = None for idx, exist_vol in enumerate(exist_volumes): if exist_vol['name'] == volume['name']: update_idx = idx break if update_idx != None: exist_volumes[update_idx] = volume else: self.add_volume(volume) return True def update_volume_mount(self, volume_mount): '''place an env in the env var list''' modified = False exist_volume_mounts = self.get_volume_mounts() if not volume_mount: return False # update the volume mount for exist_vol_mount in exist_volume_mounts: if exist_vol_mount['name'] == volume_mount['name']: if 'mountPath' in exist_vol_mount and \ str(exist_vol_mount['mountPath']) != str(volume_mount['mountPath']): exist_vol_mount['mountPath'] = volume_mount['mountPath'] modified = True break if not modified: self.add_volume_mount(volume_mount) modified = True return modified def needs_update_volume(self, volume, volume_mount): ''' verify a volume update is needed ''' exist_volume = self.find_volume_by_name(volume) exist_volume_mount = self.find_volume_by_name(volume, mounts=True) results = [] results.append(exist_volume['name'] == volume['name']) if 'secret' in volume: results.append('secret' in exist_volume) results.append(exist_volume['secret']['secretName'] == volume['secret']['secretName']) results.append(exist_volume_mount['name'] == volume_mount['name']) results.append(exist_volume_mount['mountPath'] == volume_mount['mountPath']) elif 'emptyDir' in volume: results.append(exist_volume_mount['name'] == volume['name']) results.append(exist_volume_mount['mountPath'] == volume_mount['mountPath']) elif 'persistentVolumeClaim' in volume: pvc = 'persistentVolumeClaim' results.append(pvc in exist_volume) if results[-1]: results.append(exist_volume[pvc]['claimName'] == volume[pvc]['claimName']) if 'claimSize' in volume[pvc]: results.append(exist_volume[pvc]['claimSize'] == volume[pvc]['claimSize']) elif 'hostpath' in volume: results.append('hostPath' in exist_volume) results.append(exist_volume['hostPath']['path'] == volume_mount['mountPath']) return not all(results) def needs_update_replicas(self, replicas): ''' verify whether a replica update is needed ''' current_reps = self.get(DeploymentConfig.replicas_path) return not current_reps == replicas # -*- -*- -*- End included fragment: lib/deploymentconfig.py -*- -*- -*- # -*- -*- -*- Begin included fragment: lib/secret.py -*- -*- -*- # pylint: disable=too-many-instance-attributes class SecretConfig(object): ''' Handle secret options ''' # pylint: disable=too-many-arguments def __init__(self, sname, namespace, kubeconfig, secrets=None, stype=None, annotations=None): ''' constructor for handling secret options ''' self.kubeconfig = kubeconfig self.name = sname self.type = stype self.namespace = namespace self.secrets = secrets self.annotations = annotations self.data = {} self.create_dict() def create_dict(self): ''' assign the correct properties for a secret dict ''' self.data['apiVersion'] = 'v1' self.data['kind'] = 'Secret' self.data['type'] = self.type self.data['metadata'] = {} self.data['metadata']['name'] = self.name self.data['metadata']['namespace'] = self.namespace self.data['data'] = {} if self.secrets: for key, value in self.secrets.items(): self.data['data'][key] = value if self.annotations: self.data['metadata']['annotations'] = self.annotations # pylint: disable=too-many-instance-attributes class Secret(Yedit): ''' Class to wrap the oc command line tools ''' secret_path = "data" kind = 'secret' def __init__(self, content): '''secret constructor''' super(Secret, self).__init__(content=content) self._secrets = None @property def secrets(self): '''secret property getter''' if self._secrets is None: self._secrets = self.get_secrets() return self._secrets @secrets.setter def secrets(self): '''secret property setter''' if self._secrets is None: self._secrets = self.get_secrets() return self._secrets def get_secrets(self): ''' returns all of the defined secrets ''' return self.get(Secret.secret_path) or {} def add_secret(self, key, value): ''' add a secret ''' if self.secrets: self.secrets[key] = value else: self.put(Secret.secret_path, {key: value}) return True def delete_secret(self, key): ''' delete secret''' try: del self.secrets[key] except KeyError as _: return False return True def find_secret(self, key): ''' find secret''' rval = None try: rval = self.secrets[key] except KeyError as _: return None return {'key': key, 'value': rval} def update_secret(self, key, value): ''' update a secret''' if key in self.secrets: self.secrets[key] = value else: self.add_secret(key, value) return True # -*- -*- -*- End included fragment: lib/secret.py -*- -*- -*- # -*- -*- -*- Begin included fragment: lib/service.py -*- -*- -*- # pylint: disable=too-many-instance-attributes class ServiceConfig(object): ''' Handle service options ''' # pylint: disable=too-many-arguments def __init__(self, sname, namespace, ports, annotations=None, selector=None, labels=None, cluster_ip=None, portal_ip=None, session_affinity=None, service_type=None, external_ips=None): ''' constructor for handling service options ''' self.name = sname self.namespace = namespace self.ports = ports self.annotations = annotations self.selector = selector self.labels = labels self.cluster_ip = cluster_ip self.portal_ip = portal_ip self.session_affinity = session_affinity self.service_type = service_type self.external_ips = external_ips self.data = {} self.create_dict() def create_dict(self): ''' instantiates a service dict ''' self.data['apiVersion'] = 'v1' self.data['kind'] = 'Service' self.data['metadata'] = {} self.data['metadata']['name'] = self.name self.data['metadata']['namespace'] = self.namespace if self.labels: self.data['metadata']['labels'] = {} for lab, lab_value in self.labels.items(): self.data['metadata']['labels'][lab] = lab_value if self.annotations: self.data['metadata']['annotations'] = self.annotations self.data['spec'] = {} if self.ports: self.data['spec']['ports'] = self.ports else: self.data['spec']['ports'] = [] if self.selector: self.data['spec']['selector'] = self.selector self.data['spec']['sessionAffinity'] = self.session_affinity or 'None' if self.cluster_ip: self.data['spec']['clusterIP'] = self.cluster_ip if self.portal_ip: self.data['spec']['portalIP'] = self.portal_ip if self.service_type: self.data['spec']['type'] = self.service_type if self.external_ips: self.data['spec']['externalIPs'] = self.external_ips # pylint: disable=too-many-instance-attributes,too-many-public-methods class Service(Yedit): ''' Class to model the oc service object ''' port_path = "spec.ports" portal_ip = "spec.portalIP" cluster_ip = "spec.clusterIP" selector_path = 'spec.selector' kind = 'Service' external_ips = "spec.externalIPs" def __init__(self, content): '''Service constructor''' super(Service, self).__init__(content=content) def get_ports(self): ''' get a list of ports ''' return self.get(Service.port_path) or [] def get_selector(self): ''' get the service selector''' return self.get(Service.selector_path) or {} def add_ports(self, inc_ports): ''' add a port object to the ports list ''' if not isinstance(inc_ports, list): inc_ports = [inc_ports] ports = self.get_ports() if not ports: self.put(Service.port_path, inc_ports) else: ports.extend(inc_ports) return True def find_ports(self, inc_port): ''' find a specific port ''' for port in self.get_ports(): if port['port'] == inc_port['port']: return port return None def delete_ports(self, inc_ports): ''' remove a port from a service ''' if not isinstance(inc_ports, list): inc_ports = [inc_ports] ports = self.get(Service.port_path) or [] if not ports: return True removed = False for inc_port in inc_ports: port = self.find_ports(inc_port) if port: ports.remove(port) removed = True return removed def add_cluster_ip(self, sip): '''add cluster ip''' self.put(Service.cluster_ip, sip) def add_portal_ip(self, pip): '''add cluster ip''' self.put(Service.portal_ip, pip) def get_external_ips(self): ''' get a list of external_ips ''' return self.get(Service.external_ips) or [] def add_external_ips(self, inc_external_ips): ''' add an external_ip to the external_ips list ''' if not isinstance(inc_external_ips, list): inc_external_ips = [inc_external_ips] external_ips = self.get_external_ips() if not external_ips: self.put(Service.external_ips, inc_external_ips) else: external_ips.extend(inc_external_ips) return True def find_external_ips(self, inc_external_ip): ''' find a specific external IP ''' val = None try: idx = self.get_external_ips().index(inc_external_ip) val = self.get_external_ips()[idx] except ValueError: pass return val def delete_external_ips(self, inc_external_ips): ''' remove an external IP from a service ''' if not isinstance(inc_external_ips, list): inc_external_ips = [inc_external_ips] external_ips = self.get(Service.external_ips) or [] if not external_ips: return True removed = False for inc_external_ip in inc_external_ips: external_ip = self.find_external_ips(inc_external_ip) if external_ip: external_ips.remove(external_ip) removed = True return removed # -*- -*- -*- End included fragment: lib/service.py -*- -*- -*- # -*- -*- -*- Begin included fragment: lib/volume.py -*- -*- -*- class Volume(object): ''' Class to represent an openshift volume object''' volume_mounts_path = {"pod": "spec.containers[0].volumeMounts", "dc": "spec.template.spec.containers[0].volumeMounts", "rc": "spec.template.spec.containers[0].volumeMounts", } volumes_path = {"pod": "spec.volumes", "dc": "spec.template.spec.volumes", "rc": "spec.template.spec.volumes", } @staticmethod def create_volume_structure(volume_info): ''' return a properly structured volume ''' volume_mount = None volume = {'name': volume_info['name']} volume_type = volume_info['type'].lower() if volume_type == 'secret': volume['secret'] = {} volume[volume_info['type']] = {'secretName': volume_info['secret_name']} volume_mount = {'mountPath': volume_info['path'], 'name': volume_info['name']} elif volume_type == 'emptydir': volume['emptyDir'] = {} volume_mount = {'mountPath': volume_info['path'], 'name': volume_info['name']} elif volume_type == 'pvc' or volume_type == 'persistentvolumeclaim': volume['persistentVolumeClaim'] = {} volume['persistentVolumeClaim']['claimName'] = volume_info['claimName'] volume['persistentVolumeClaim']['claimSize'] = volume_info['claimSize'] elif volume_type == 'hostpath': volume['hostPath'] = {} volume['hostPath']['path'] = volume_info['path'] elif volume_type == 'configmap': volume['configMap'] = {} volume['configMap']['name'] = volume_info['configmap_name'] volume_mount = {'mountPath': volume_info['path'], 'name': volume_info['name']} return (volume, volume_mount) # -*- -*- -*- End included fragment: lib/volume.py -*- -*- -*- # -*- -*- -*- Begin included fragment: class/oc_version.py -*- -*- -*- # pylint: disable=too-many-instance-attributes class OCVersion(OpenShiftCLI): ''' Class to wrap the oc command line tools ''' # pylint allows 5 # pylint: disable=too-many-arguments def __init__(self, config, debug): ''' Constructor for OCVersion ''' super(OCVersion, self).__init__(None, config) self.debug = debug def get(self): '''get and return version information ''' results = {} version_results = self._version() if version_results['returncode'] == 0: filtered_vers = Utils.filter_versions(version_results['results']) custom_vers = Utils.add_custom_versions(filtered_vers) results['returncode'] = version_results['returncode'] results.update(filtered_vers) results.update(custom_vers) return results raise OpenShiftCLIError('Problem detecting openshift version.') @staticmethod def run_ansible(params): '''run the idempotent ansible code''' oc_version = OCVersion(params['kubeconfig'], params['debug']) if params['state'] == 'list': #pylint: disable=protected-access result = oc_version.get() return {'state': params['state'], 'results': result, 'changed': False} # -*- -*- -*- End included fragment: class/oc_version.py -*- -*- -*- # -*- -*- -*- Begin included fragment: class/oc_adm_registry.py -*- -*- -*- class RegistryException(Exception): ''' Registry Exception Class ''' pass class RegistryConfig(OpenShiftCLIConfig): ''' RegistryConfig is a DTO for the registry. ''' def __init__(self, rname, namespace, kubeconfig, registry_options): super(RegistryConfig, self).__init__(rname, namespace, kubeconfig, registry_options) class Registry(OpenShiftCLI): ''' Class to wrap the oc command line tools ''' volume_mount_path = 'spec.template.spec.containers[0].volumeMounts' volume_path = 'spec.template.spec.volumes' env_path = 'spec.template.spec.containers[0].env' def __init__(self, registry_config, verbose=False): ''' Constructor for Registry a registry consists of 3 or more parts - dc/docker-registry - svc/docker-registry Parameters: :registry_config: :verbose: ''' super(Registry, self).__init__(registry_config.namespace, registry_config.kubeconfig, verbose) self.version = OCVersion(registry_config.kubeconfig, verbose) self.svc_ip = None self.portal_ip = None self.config = registry_config self.verbose = verbose self.registry_parts = [{'kind': 'dc', 'name': self.config.name}, {'kind': 'svc', 'name': self.config.name}, ] self.__prepared_registry = None self.volume_mounts = [] self.volumes = [] if self.config.config_options['volume_mounts']['value']: for volume in self.config.config_options['volume_mounts']['value']: volume_info = {'secret_name': volume.get('secret_name', None), 'name': volume.get('name', None), 'type': volume.get('type', None), 'path': volume.get('path', None), 'claimName': volume.get('claim_name', None), 'claimSize': volume.get('claim_size', None), } vol, vol_mount = Volume.create_volume_structure(volume_info) self.volumes.append(vol) self.volume_mounts.append(vol_mount) self.dconfig = None self.svc = None @property def deploymentconfig(self): ''' deploymentconfig property ''' return self.dconfig @deploymentconfig.setter def deploymentconfig(self, config): ''' setter for deploymentconfig property ''' self.dconfig = config @property def service(self): ''' service property ''' return self.svc @service.setter def service(self, config): ''' setter for service property ''' self.svc = config @property def prepared_registry(self): ''' prepared_registry property ''' if not self.__prepared_registry: results = self.prepare_registry() if not results or ('returncode' in results and results['returncode'] != 0): raise RegistryException('Could not perform registry preparation. {}'.format(results)) self.__prepared_registry = results return self.__prepared_registry @prepared_registry.setter def prepared_registry(self, data): ''' setter method for prepared_registry attribute ''' self.__prepared_registry = data def get(self): ''' return the self.registry_parts ''' self.deploymentconfig = None self.service = None rval = 0 for part in self.registry_parts: result = self._get(part['kind'], name=part['name']) if result['returncode'] == 0 and part['kind'] == 'dc': self.deploymentconfig = DeploymentConfig(result['results'][0]) elif result['returncode'] == 0 and part['kind'] == 'svc': self.service = Service(result['results'][0]) if result['returncode'] != 0: rval = result['returncode'] return {'returncode': rval, 'deploymentconfig': self.deploymentconfig, 'service': self.service} def exists(self): '''does the object exist?''' if self.deploymentconfig and self.service: return True return False def delete(self, complete=True): '''return all pods ''' parts = [] for part in self.registry_parts: if not complete and part['kind'] == 'svc': continue parts.append(self._delete(part['kind'], part['name'])) # Clean up returned results rval = 0 for part in parts: # pylint: disable=invalid-sequence-index if 'returncode' in part and part['returncode'] != 0: rval = part['returncode'] return {'returncode': rval, 'results': parts} def prepare_registry(self): ''' prepare a registry for instantiation ''' options = self.config.to_option_list(ascommalist='labels') cmd = ['registry'] cmd.extend(options) cmd.extend(['--dry-run=True', '-o', 'json']) results = self.openshift_cmd(cmd, oadm=True, output=True, output_type='json') # probably need to parse this # pylint thinks results is a string # pylint: disable=no-member if results['returncode'] != 0 and 'items' not in results['results']: raise RegistryException('Could not perform registry preparation. {}'.format(results)) service = None deploymentconfig = None # pylint: disable=invalid-sequence-index for res in results['results']['items']: if res['kind'] == 'DeploymentConfig': deploymentconfig = DeploymentConfig(res) elif res['kind'] == 'Service': service = Service(res) # Verify we got a service and a deploymentconfig if not service or not deploymentconfig: return results # results will need to get parsed here and modifications added deploymentconfig = DeploymentConfig(self.add_modifications(deploymentconfig)) # modify service ip if self.svc_ip: service.put('spec.clusterIP', self.svc_ip) if self.portal_ip: service.put('spec.portalIP', self.portal_ip) # the dry-run doesn't apply the selector correctly if self.service: service.put('spec.selector', self.service.get_selector()) # need to create the service and the deploymentconfig service_file = Utils.create_tmp_file_from_contents('service', service.yaml_dict) deployment_file = Utils.create_tmp_file_from_contents('deploymentconfig', deploymentconfig.yaml_dict) return {"service": service, "service_file": service_file, "service_update": False, "deployment": deploymentconfig, "deployment_file": deployment_file, "deployment_update": False} def create(self): '''Create a registry''' results = [] self.needs_update() # if the object is none, then we need to create it # if the object needs an update, then we should call replace # Handle the deploymentconfig if self.deploymentconfig is None: results.append(self._create(self.prepared_registry['deployment_file'])) elif self.prepared_registry['deployment_update']: results.append(self._replace(self.prepared_registry['deployment_file'])) # Handle the service if self.service is None: results.append(self._create(self.prepared_registry['service_file'])) elif self.prepared_registry['service_update']: results.append(self._replace(self.prepared_registry['service_file'])) # Clean up returned results rval = 0 for result in results: # pylint: disable=invalid-sequence-index if 'returncode' in result and result['returncode'] != 0: rval = result['returncode'] return {'returncode': rval, 'results': results} def update(self): '''run update for the registry. This performs a replace if required''' # Store the current service IP if self.service: svcip = self.service.get('spec.clusterIP') if svcip: self.svc_ip = svcip portip = self.service.get('spec.portalIP') if portip: self.portal_ip = portip results = [] if self.prepared_registry['deployment_update']: results.append(self._replace(self.prepared_registry['deployment_file'])) if self.prepared_registry['service_update']: results.append(self._replace(self.prepared_registry['service_file'])) # Clean up returned results rval = 0 for result in results: if result['returncode'] != 0: rval = result['returncode'] return {'returncode': rval, 'results': results} def add_modifications(self, deploymentconfig): ''' update a deployment config with changes ''' # The environment variable for REGISTRY_HTTP_SECRET is autogenerated # We should set the generated deploymentconfig to the in memory version # the following modifications will overwrite if needed if self.deploymentconfig: result = self.deploymentconfig.get_env_var('REGISTRY_HTTP_SECRET') if result: deploymentconfig.update_env_var('REGISTRY_HTTP_SECRET', result['value']) # Currently we know that our deployment of a registry requires a few extra modifications # Modification 1 # we need specific environment variables to be set for key, value in self.config.config_options['env_vars'].get('value', {}).items(): if not deploymentconfig.exists_env_key(key): deploymentconfig.add_env_value(key, value) else: deploymentconfig.update_env_var(key, value) # Modification 2 # we need specific volume variables to be set for volume in self.volumes: deploymentconfig.update_volume(volume) for vol_mount in self.volume_mounts: deploymentconfig.update_volume_mount(vol_mount) # Modification 3 # Edits edit_results = [] for edit in self.config.config_options['edits'].get('value', []): if edit['action'] == 'put': edit_results.append(deploymentconfig.put(edit['key'], edit['value'])) if edit['action'] == 'update': edit_results.append(deploymentconfig.update(edit['key'], edit['value'], edit.get('index', None), edit.get('curr_value', None))) if edit['action'] == 'append': edit_results.append(deploymentconfig.append(edit['key'], edit['value'])) if edit_results and not any([res[0] for res in edit_results]): return None return deploymentconfig.yaml_dict def needs_update(self): ''' check to see if we need to update ''' exclude_list = ['clusterIP', 'portalIP', 'type', 'protocol'] if self.service is None or \ not Utils.check_def_equal(self.prepared_registry['service'].yaml_dict, self.service.yaml_dict, exclude_list, debug=self.verbose): self.prepared_registry['service_update'] = True exclude_list = ['dnsPolicy', 'terminationGracePeriodSeconds', 'restartPolicy', 'timeoutSeconds', 'livenessProbe', 'readinessProbe', 'terminationMessagePath', 'securityContext', 'imagePullPolicy', 'protocol', # ports.portocol: TCP 'type', # strategy: {'type': 'rolling'} 'defaultMode', # added on secrets 'activeDeadlineSeconds', # added in 1.5 for timeouts ] if self.deploymentconfig is None or \ not Utils.check_def_equal(self.prepared_registry['deployment'].yaml_dict, self.deploymentconfig.yaml_dict, exclude_list, debug=self.verbose): self.prepared_registry['deployment_update'] = True return self.prepared_registry['deployment_update'] or self.prepared_registry['service_update'] or False # In the future, we would like to break out each ansible state into a function. # pylint: disable=too-many-branches,too-many-return-statements @staticmethod def run_ansible(params, check_mode): '''run idempotent ansible code''' registry_options = {'images': {'value': params['images'], 'include': True}, 'latest_images': {'value': params['latest_images'], 'include': True}, 'labels': {'value': params['labels'], 'include': True}, 'ports': {'value': ','.join(params['ports']), 'include': True}, 'replicas': {'value': params['replicas'], 'include': True}, 'selector': {'value': params['selector'], 'include': True}, 'service_account': {'value': params['service_account'], 'include': True}, 'mount_host': {'value': params['mount_host'], 'include': True}, 'env_vars': {'value': params['env_vars'], 'include': False}, 'volume_mounts': {'value': params['volume_mounts'], 'include': False}, 'edits': {'value': params['edits'], 'include': False}, 'tls_key': {'value': params['tls_key'], 'include': True}, 'tls_certificate': {'value': params['tls_certificate'], 'include': True}, } # Do not always pass the daemonset and enforce-quota parameters because they are not understood # by old versions of oc. # Default value is false. So, it's safe to not pass an explicit false value to oc versions which # understand these parameters. if params['daemonset']: registry_options['daemonset'] = {'value': params['daemonset'], 'include': True} if params['enforce_quota']: registry_options['enforce_quota'] = {'value': params['enforce_quota'], 'include': True} rconfig = RegistryConfig(params['name'], params['namespace'], params['kubeconfig'], registry_options) ocregistry = Registry(rconfig, params['debug']) api_rval = ocregistry.get() state = params['state'] ######## # get ######## if state == 'list': if api_rval['returncode'] != 0: return {'failed': True, 'msg': api_rval} return {'changed': False, 'results': api_rval, 'state': state} ######## # Delete ######## if state == 'absent': if not ocregistry.exists(): return {'changed': False, 'state': state} if check_mode: return {'changed': True, 'msg': 'CHECK_MODE: Would have performed a delete.'} # Unsure as to why this is angry with the return type. # pylint: disable=redefined-variable-type api_rval = ocregistry.delete() if api_rval['returncode'] != 0: return {'failed': True, 'msg': api_rval} return {'changed': True, 'results': api_rval, 'state': state} if state == 'present': ######## # Create ######## if not ocregistry.exists(): if check_mode: return {'changed': True, 'msg': 'CHECK_MODE: Would have performed a create.'} api_rval = ocregistry.create() if api_rval['returncode'] != 0: return {'failed': True, 'msg': api_rval} return {'changed': True, 'results': api_rval, 'state': state} ######## # Update ######## if not params['force'] and not ocregistry.needs_update(): return {'changed': False, 'state': state} if check_mode: return {'changed': True, 'msg': 'CHECK_MODE: Would have performed an update.'} api_rval = ocregistry.update() if api_rval['returncode'] != 0: return {'failed': True, 'msg': api_rval} return {'changed': True, 'results': api_rval, 'state': state} return {'failed': True, 'msg': 'Unknown state passed. %s' % state} # -*- -*- -*- End included fragment: class/oc_adm_registry.py -*- -*- -*- # -*- -*- -*- Begin included fragment: ansible/oc_adm_registry.py -*- -*- -*- def main(): ''' ansible oc module for registry ''' module = AnsibleModule( argument_spec=dict( state=dict(default='present', type='str', choices=['present', 'absent']), debug=dict(default=False, type='bool'), namespace=dict(default='default', type='str'), name=dict(default=None, required=True, type='str'), kubeconfig=dict(default='/etc/origin/master/admin.kubeconfig', type='str'), images=dict(default=None, type='str'), latest_images=dict(default=False, type='bool'), labels=dict(default=None, type='dict'), ports=dict(default=['5000'], type='list'), replicas=dict(default=1, type='int'), selector=dict(default=None, type='str'), service_account=dict(default='registry', type='str'), mount_host=dict(default=None, type='str'), volume_mounts=dict(default=None, type='list'), env_vars=dict(default={}, type='dict'), edits=dict(default=[], type='list'), enforce_quota=dict(default=False, type='bool'), force=dict(default=False, type='bool'), daemonset=dict(default=False, type='bool'), tls_key=dict(default=None, type='str'), tls_certificate=dict(default=None, type='str'), ), supports_check_mode=True, ) results = Registry.run_ansible(module.params, module.check_mode) if 'failed' in results: module.fail_json(**results) module.exit_json(**results) if __name__ == '__main__': main() # -*- -*- -*- End included fragment: ansible/oc_adm_registry.py -*- -*- -*-
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 4287, 26, 3507, 29, 4752, 13, 12485, 199, 3, 27510, 24, 26, 8151, 26, 377, 4587, 199, 3, 258, 31111, 31111, 485, 221, 485, 31111, 31111, 259, 485, 636, 8989, 31111, 31111, 199, 3, 259, 1182, 636, 92, 636, 92, 971, 92, 1204, 636, 92, 485, 971, 221, 1182, 18005, 63, 257, 485, 92, 636, 92, 257, 971, 199, 3, 257, 1204, 6110, 1204, 485, 10644, 1275, 64, 1204, 485, 10644, 257, 1182, 1182, 485, 971, 92, 1204, 1204, 485, 10644, 1204, 9, 1204, 199, 3, 259, 971, 8989, 92, 8989, 30007, 6113, 63, 92, 8989, 30007, 92, 18005, 15607, 15607, 60, 18005, 63, 30007, 92, 8989, 92, 8989, 15607, 636, 8989, 199, 3, 257, 1204, 257, 971, 1182, 485, 971, 221, 1204, 971, 92, 1204, 15, 485, 971, 63, 257, 485, 92, 1204, 636, 92, 257, 971, 63, 485, 30007, 257, 485, 92, 199, 3, 257, 1204, 1204, 9, 1204, 334, 4602, 1204, 1204, 1275, 64, 1204, 334, 4602, 12208, 1204, 257, 1204, 485, 10644, 1204, 9, 1204, 1204, 221, 1204, 1204, 199, 3, 257, 1204, 8989, 15, 971, 8989, 15, 221, 1204, 63, 6113, 63, 6113, 8989, 15, 1204, 63, 92, 257, 1204, 8989, 92, 8989, 15, 8989, 92, 1204, 63, 92, 199, 3, 199, 3, 1898, 7800, 9572, 13002, 12, 3277, 14, 436, 15, 269, 2399, 29172, 2335, 199, 3, 436, 1163, 8417, 465, 22141, 701, 314, 768, 2502, 3762, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 3, 1882, 1882, 1882, 25754, 5120, 7956, 26, 1973, 15, 646, 14, 647, 1882, 1882, 1882, 199, 2344, 2043, 3232, 14379, 7802, 1021, 626, 14018, 314, 4244, 3718, 315, 282, 3873, 199, 2344, 199, 3, 4287, 26, 3507, 29, 7354, 13, 3479, 13, 1278, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 19840, 199, 646, 1331, 199, 646, 2022, 199, 646, 747, 199, 646, 295, 199, 646, 5145, 199, 646, 3873, 199, 646, 5549, 199, 3, 4287, 26, 3507, 29, 646, 13, 705, 199, 893, 26, 272, 492, 519, 85, 14868, 14, 5963, 465, 8864, 199, 2590, 3545, 26, 272, 492, 8864, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 199, 3, 1882, 1882, 1882, 9599, 5120, 7956, 26, 1973, 15, 646, 14, 647, 1882, 1882, 1882, 199, 199, 3, 1882, 1882, 1882, 25754, 5120, 7956, 26, 1382, 15, 5189, 1882, 1882, 1882, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 4244, 63, 14464, 63, 5189, 199, 3612, 63, 1802, 26, 5673, 370, 9635, 1551, 4723, 7086, 199, 1802, 26, 523, 446, 14944, 1551, 4723, 7086, 2240, 17174, 14, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 272, 446, 710, 6387, 1595, 1380, 28453, 1551, 4723, 7086, 272, 446, 3451, 446, 1678, 503, 1218, 314, 7086, 272, 446, 9552, 446, 1565, 285, 3224, 314, 7086, 2435, 436, 14295, 888, 272, 446, 769, 446, 2529, 314, 1453, 295, 7732, 280, 425, 402, 282, 7086, 272, 1415, 26, 3055, 272, 849, 26, 756, 272, 5481, 26, 942, 523, 23091, 888, 26, 272, 1369, 26, 272, 446, 710, 931, 367, 314, 23091, 888, 570, 370, 675, 367, 6299, 272, 1415, 26, 3055, 272, 849, 26, 1182, 6839, 15, 6493, 15, 4133, 15, 2113, 14, 29192, 272, 5481, 26, 942, 523, 3105, 26, 272, 1369, 26, 272, 446, 16147, 641, 3105, 1072, 14, 272, 1415, 26, 3055, 272, 849, 26, 756, 272, 5481, 26, 942, 523, 536, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 7086, 272, 1415, 26, 3055, 272, 849, 26, 488, 272, 5481, 26, 942, 523, 3231, 26, 272, 1369, 26, 272, 446, 710, 9759, 1380, 14545, 641, 1031, 3628, 272, 1415, 26, 3055, 272, 849, 26, 488, 272, 5481, 26, 942, 523, 5935, 26, 272, 1369, 26, 272, 446, 710, 1834, 370, 1300, 642, 7086, 641, 446, 10839, 3173, 93, 911, 506, 8717, 543, 1553, 466, 272, 1415, 26, 283, 22858, 19, 15, 3362, 13, 10545, 3173, 9160, 10545, 1023, 6834, 272, 849, 26, 488, 272, 5481, 26, 942, 523, 8839, 63, 4782, 26, 272, 1369, 26, 272, 446, 982, 2549, 12, 7427, 370, 675, 314, 8839, 1834, 367, 314, 7086, 3140, 402, 314, 8839, 4683, 14, 272, 1415, 26, 3055, 272, 849, 26, 756, 272, 5481, 26, 942, 523, 3628, 26, 272, 1369, 26, 272, 446, 437, 663, 402, 3628, 370, 28727, 10405, 314, 7086, 436, 2399, 7323, 14, 272, 1415, 26, 3055, 272, 849, 26, 488, 272, 5481, 26, 942, 523, 15814, 63, 8848, 26, 272, 1369, 26, 272, 446, 982, 663, 12, 314, 7086, 911, 2984, 1180, 370, 2218, 9182, 83, 340, 2985, 24068, 12132, 10976, 272, 1415, 26, 756, 272, 849, 26, 756, 272, 5481, 26, 942, 523, 10760, 63, 1102, 26, 272, 1369, 26, 272, 446, 982, 663, 12, 314, 7086, 3301, 911, 506, 2737, 465, 282, 1591, 13, 3956, 737, 642, 931, 14, 272, 1415, 26, 756, 272, 849, 26, 756, 272, 5481, 26, 942, 523, 8873, 26, 272, 1369, 26, 272, 446, 437, 10029, 21941, 769, 402, 8873, 503, 1844, 6342, 370, 23705, 641, 314, 7086, 15329, 14, 221, 710, 849, 365, 663, 367, 22369, 14, 272, 1415, 26, 756, 272, 849, 26, 359, 13128, 61, 272, 5481, 26, 942, 523, 22413, 26, 272, 1369, 26, 272, 446, 710, 20797, 6535, 402, 314, 7086, 27, 28829, 499, 1380, 4721, 14962, 365, 6387, 14, 272, 1415 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 4287, 26, 3507, 29, 4752, 13, 12485, 199, 3, 27510, 24, 26, 8151, 26, 377, 4587, 199, 3, 258, 31111, 31111, 485, 221, 485, 31111, 31111, 259, 485, 636, 8989, 31111, 31111, 199, 3, 259, 1182, 636, 92, 636, 92, 971, 92, 1204, 636, 92, 485, 971, 221, 1182, 18005, 63, 257, 485, 92, 636, 92, 257, 971, 199, 3, 257, 1204, 6110, 1204, 485, 10644, 1275, 64, 1204, 485, 10644, 257, 1182, 1182, 485, 971, 92, 1204, 1204, 485, 10644, 1204, 9, 1204, 199, 3, 259, 971, 8989, 92, 8989, 30007, 6113, 63, 92, 8989, 30007, 92, 18005, 15607, 15607, 60, 18005, 63, 30007, 92, 8989, 92, 8989, 15607, 636, 8989, 199, 3, 257, 1204, 257, 971, 1182, 485, 971, 221, 1204, 971, 92, 1204, 15, 485, 971, 63, 257, 485, 92, 1204, 636, 92, 257, 971, 63, 485, 30007, 257, 485, 92, 199, 3, 257, 1204, 1204, 9, 1204, 334, 4602, 1204, 1204, 1275, 64, 1204, 334, 4602, 12208, 1204, 257, 1204, 485, 10644, 1204, 9, 1204, 1204, 221, 1204, 1204, 199, 3, 257, 1204, 8989, 15, 971, 8989, 15, 221, 1204, 63, 6113, 63, 6113, 8989, 15, 1204, 63, 92, 257, 1204, 8989, 92, 8989, 15, 8989, 92, 1204, 63, 92, 199, 3, 199, 3, 1898, 7800, 9572, 13002, 12, 3277, 14, 436, 15, 269, 2399, 29172, 2335, 199, 3, 436, 1163, 8417, 465, 22141, 701, 314, 768, 2502, 3762, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 3, 1882, 1882, 1882, 25754, 5120, 7956, 26, 1973, 15, 646, 14, 647, 1882, 1882, 1882, 199, 2344, 2043, 3232, 14379, 7802, 1021, 626, 14018, 314, 4244, 3718, 315, 282, 3873, 199, 2344, 199, 3, 4287, 26, 3507, 29, 7354, 13, 3479, 13, 1278, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 19840, 199, 646, 1331, 199, 646, 2022, 199, 646, 747, 199, 646, 295, 199, 646, 5145, 199, 646, 3873, 199, 646, 5549, 199, 3, 4287, 26, 3507, 29, 646, 13, 705, 199, 893, 26, 272, 492, 519, 85, 14868, 14, 5963, 465, 8864, 199, 2590, 3545, 26, 272, 492, 8864, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 199, 3, 1882, 1882, 1882, 9599, 5120, 7956, 26, 1973, 15, 646, 14, 647, 1882, 1882, 1882, 199, 199, 3, 1882, 1882, 1882, 25754, 5120, 7956, 26, 1382, 15, 5189, 1882, 1882, 1882, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 4244, 63, 14464, 63, 5189, 199, 3612, 63, 1802, 26, 5673, 370, 9635, 1551, 4723, 7086, 199, 1802, 26, 523, 446, 14944, 1551, 4723, 7086, 2240, 17174, 14, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 272, 446, 710, 6387, 1595, 1380, 28453, 1551, 4723, 7086, 272, 446, 3451, 446, 1678, 503, 1218, 314, 7086, 272, 446, 9552, 446, 1565, 285, 3224, 314, 7086, 2435, 436, 14295, 888, 272, 446, 769, 446, 2529, 314, 1453, 295, 7732, 280, 425, 402, 282, 7086, 272, 1415, 26, 3055, 272, 849, 26, 756, 272, 5481, 26, 942, 523, 23091, 888, 26, 272, 1369, 26, 272, 446, 710, 931, 367, 314, 23091, 888, 570, 370, 675, 367, 6299, 272, 1415, 26, 3055, 272, 849, 26, 1182, 6839, 15, 6493, 15, 4133, 15, 2113, 14, 29192, 272, 5481, 26, 942, 523, 3105, 26, 272, 1369, 26, 272, 446, 16147, 641, 3105, 1072, 14, 272, 1415, 26, 3055, 272, 849, 26, 756, 272, 5481, 26, 942, 523, 536, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 7086, 272, 1415, 26, 3055, 272, 849, 26, 488, 272, 5481, 26, 942, 523, 3231, 26, 272, 1369, 26, 272, 446, 710, 9759, 1380, 14545, 641, 1031, 3628, 272, 1415, 26, 3055, 272, 849, 26, 488, 272, 5481, 26, 942, 523, 5935, 26, 272, 1369, 26, 272, 446, 710, 1834, 370, 1300, 642, 7086, 641, 446, 10839, 3173, 93, 911, 506, 8717, 543, 1553, 466, 272, 1415, 26, 283, 22858, 19, 15, 3362, 13, 10545, 3173, 9160, 10545, 1023, 6834, 272, 849, 26, 488, 272, 5481, 26, 942, 523, 8839, 63, 4782, 26, 272, 1369, 26, 272, 446, 982, 2549, 12, 7427, 370, 675, 314, 8839, 1834, 367, 314, 7086, 3140, 402, 314, 8839, 4683, 14, 272, 1415, 26, 3055, 272, 849, 26, 756, 272, 5481, 26, 942, 523, 3628, 26, 272, 1369, 26, 272, 446, 437, 663, 402, 3628, 370, 28727, 10405, 314, 7086, 436, 2399, 7323, 14, 272, 1415, 26, 3055, 272, 849, 26, 488, 272, 5481, 26, 942, 523, 15814, 63, 8848, 26, 272, 1369, 26, 272, 446, 982, 663, 12, 314, 7086, 911, 2984, 1180, 370, 2218, 9182, 83, 340, 2985, 24068, 12132, 10976, 272, 1415, 26, 756, 272, 849, 26, 756, 272, 5481, 26, 942, 523, 10760, 63, 1102, 26, 272, 1369, 26, 272, 446, 982, 663, 12, 314, 7086, 3301, 911, 506, 2737, 465, 282, 1591, 13, 3956, 737, 642, 931, 14, 272, 1415, 26, 756, 272, 849, 26, 756, 272, 5481, 26, 942, 523, 8873, 26, 272, 1369, 26, 272, 446, 437, 10029, 21941, 769, 402, 8873, 503, 1844, 6342, 370, 23705, 641, 314, 7086, 15329, 14, 221, 710, 849, 365, 663, 367, 22369, 14, 272, 1415, 26, 756, 272, 849, 26, 359, 13128, 61, 272, 5481, 26, 942, 523, 22413, 26, 272, 1369, 26, 272, 446, 710, 20797, 6535, 402, 314, 7086, 27, 28829, 499, 1380, 4721, 14962, 365, 6387, 14, 272, 1415, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
iainr/fridgid
Fridge.py
1
9372
import RPi.GPIO as GPIO import datetime import time import pandas as pd import logging import logging.handlers import sys logger = logging.getLogger('fridge') handler = logging.StreamHandler() fHandler = logging.FileHandler('fridge.log') formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s", "%Y-%m-%d %H:%M:%S") handler.setFormatter(formatter) fHandler.setFormatter(formatter) logger.addHandler(handler) logger.addHandler(fHandler) logger.setLevel(logging.DEBUG) logging.captureWarnings(True) dataLog = logging.getLogger('fridge.data') dataFormatter = logging.Formatter("%(asctime)s, %(message)s", "%Y-%m-%d %H:%M:%S") dataFileName = 'fridge-' + str(datetime.datetime.now()) + '.data' dataHandler = logging.handlers.RotatingFileHandler(dataFileName, mode='w', maxBytes=10000, backupCount=2) dataHandler.setFormatter(dataFormatter) dataLog.addHandler(dataHandler) dataLog.setLevel(logging.INFO) class Fridge: def __init__(self, heaterGpio, coolerGpio, ambientTempSensorRomCode): self.initGpio(heaterGpio, coolerGpio) self.heater = TemperatureElement(heaterGpio, name='heater') self.cooler = TemperatureElement(coolerGpio, name='cooler') self.ambientTempSensor = DS18B20(ambientTempSensorRomCode, name='TempSens') self.resultPeriod = datetime.timedelta(minutes=10) self.maxResults = 1000 self.lastResultTime = None self.resultTime = datetime.datetime.now() self.resultsFile = 'results.txt' fo = open(self.resultsFile, 'w') fo.close() def initGpio(self, heaterGpioPin, coolerGpioPin): GPIO.setmode(GPIO.BCM) GPIO.setup(heaterGpioPin, GPIO.OUT) GPIO.setup(coolerGpioPin, GPIO.OUT) def updateResultsLog(self, dataFile): if datetime.datetime.now() >= self.resultTime: now = datetime.datetime.now() names = ['date', 'set', 'meas', 'heater', 'cooler'] d = pd.read_csv(dataFile, names=names) d['date'] = pd.to_datetime(d['date']) d['error'] = d.meas - d.set d['absError'] = d['error'].abs() if self.lastResultTime == None: dt = d else: start = self.lastResultTime end = self.resultTime mask = (d['date'] > start) & (d['date'] <= end) dt = d.loc[mask] mean = dt.meas.mean() maxErr = dt.error.max() minErr = dt.error.min() meanErr = dt.error.mean() meanAbsErr = dt.absError.mean() set = d['set'].iloc[-1] names = ['date', 'set', 'mean', 'maxErr', 'minErr', 'meanErr', 'meanAbsErr'] d_r = pd.read_csv(self.resultsFile, names=names) try: fi = open(self.resultsFile, 'r') resBefore = fi.read() resBefore = resBefore.split('\n') fi.close() except: whatever = 1000 fo = open(self.resultsFile, 'w') fo.write('{:11s}'.format('Date')) fo.write('{:9s}'.format('Time')) fo.write('{:5s}'.format('set')) fo.write('{:5s}'.format('mean')) fo.write('{:5s}'.format('maxE')) fo.write('{:5s}'.format('minE')) fo.write('{:6s}'.format('meanE')) fo.write('{:9s}'.format('meanAbsE') + '\n') fo.write( self.resultTime.strftime('%Y-%m-%d %H:%M:%S') + ' ' + '{:4.1f}'.format(set) + ' ' + '{:4.1f}'.format(mean) + ' ' + '{:4.1f}'.format(maxErr) + ' ' + '{:4.1f}'.format(minErr) + ' ' + '{:5.1f}'.format(meanErr) + ' ' + '{:8.1f}'.format(meanAbsErr) + '\n' ) if len(resBefore) >= 2: for i in xrange(1, len(resBefore)-1, 1): fo.write(resBefore[i] + '\n') if i > self.maxResults: break fo.close() self.lastResultTime = self.resultTime self.resultTime = now + self.resultPeriod class TemperatureElement: def __init__(self, bcmGpioNum, name='Name'): self.name = name self.gpioPin = bcmGpioNum self.on = None self.lastOnTime = None self.minOnTime = datetime.timedelta(minutes=1) self.minOffTime = datetime.timedelta(minutes=3) try: GPIO.output(self.gpioPin, False) self.lastOffTime = datetime.datetime.now() except: logger.error('Failed to switch off in temp el init') raise def isOn(self): if(GPIO.input(self.gpioPin)): return True else: return False def status(self): if(GPIO.input(self.gpioPin)): try: onFor = str(datetime.datetime.now()-self.lastOnTime).split('.')[0] except: onFor = 'No Last On Time' logger.debug(self.name + " been ON for " + onFor) return self.name + " ON for " + onFor else: try: offFor = str(datetime.datetime.now()-self.lastOffTime).split('.')[0] except: offFor = 'No Last Off Time' logger.debug(self.name +" been OFF for " + offFor) return self.name +" OFF for " + offFor def turnOff(self): now = datetime.datetime.now() switchOff = False #if not been on/off yet then can switch off if self.on == None: switchOff = True #if not been on yet, and not currently off then can switch off elif self.lastOnTime == None and self.on != False: switchOff = True #if on, and have been on for at least minOnTime then can switch off elif self.on == True: if (now - self.lastOnTime) > self.minOnTime: switchOff = True else: logger.debug(self.name + ' Unable to switch off. Min On Time not met' ) elif self.on == False: switchOff = False # Already off else: logger.debug(self.name + ' Unable to switch off. Valid condition not found.' ) #Switch on if have decided to if switchOff == True: try: GPIO.output(self.gpioPin, False) self.lastOffTime = now self.on = False logger.debug(self.name + ' Switched Off Return 1' ) return 1 except: logger.debug(self.name + ' Exception Return -1' ) raise return -1 else: logger.debug(self.name + ' No Change Return 0.' ) return 0 def turnOn(self): now = datetime.datetime.now() switchOn = False #if not been on/off yet then can switch on if self.on == None: switchOn = True #if not been off yet, and not currently on then can switch on elif self.lastOffTime == None and self.on != True: switchOn = True #if off, and have been off for at least minOffTime then can switch on elif self.on == False: if (now - self.lastOffTime) > self.minOffTime: switchOn = True else: logger.debug(self.name + ' Unable to switch on. Min Off Time not met' ) elif self.on == True: switchOn = False # Already off else: logger.debug(self.name + ' Unable to switch on. Valid condition not found.' ) #Switch on if have decided to if switchOn == True: try: GPIO.output(self.gpioPin, True) self.lastOnTime = now self.on = True logger.debug(self.name + ' Switched On Return 1' ) return 1 except: logger.debug(self.name + ' Exception Return -1' ) raise return -1 else: logger.debug(self.name + ' No Change Return 0' ) return 0 class DS18B20: def __init__(self, romCode, name='Name'): self.name = name self.romCode = romCode def getTemp(self): tempFile = open('/sys/bus/w1/devices/' + self.romCode + '/w1_slave') tempText = tempFile.read() tempFile.close() tempData = tempText.split("\n")[1].split(" ")[9] temp = float(tempData[2:]) / 1000 logger.debug(self.name + ' ' + str(temp)) return temp heaterGpio = 6 coolerGpio = 5 tempSensRomCode='28-0316027c72ff' fridge = Fridge(heaterGpio, coolerGpio, tempSensRomCode) fridge.heater.minOffTime=datetime.timedelta(seconds=1) fridge.heater.minOnTime=datetime.timedelta(seconds=1) fridge.cooler.minOffTime=datetime.timedelta(minutes=3) fridge.cooler.minOnTime=datetime.timedelta(minutes=1) fridge.ambientTempSensor.getTemp() samplePeriod = datetime.timedelta(seconds=10) setTemp = 21 heaterOnHyst = 0.2 #Amount below set temp that heater is asked to switch on at heaterOffHyst = 0.1 #Amount below set temp that heater is asked to switch off at coolerOnHyst = 1.5 #Amount above set temp that cooler is asked to switch on at coolerOffHyst = 1 #Amount above set temp that cooler is asked to switch off at i=0 while True: try: i=i+1 loopStartTime = datetime.datetime.now() temp = fridge.ambientTempSensor.getTemp() logger.debug('i=' + str(i) + ' Error=' + str(temp-setTemp) + ' Temp=' + str(temp) + ' Set temp=' + str(setTemp)) temp = fridge.ambientTempSensor.getTemp() fridge.heater.status() fridge.cooler.status() #Heater decision #If heater not on and temp is below set - heaterOnHyst then try to switch on if not fridge.heater.isOn(): if temp < (setTemp - heaterOnHyst): fridge.heater.turnOn() #If heater is on and temp above setTemp - heaetr OffHyst then try to switch off if fridge.heater.isOn(): if temp > (setTemp - heaterOffHyst): fridge.heater.turnOff() #Cooler decision #If cooler not on and temp is above set + coolerOnHyst then try to switch cooler on if not fridge.cooler.isOn(): if temp > (setTemp + coolerOnHyst): fridge.cooler.turnOn() #If cooler is on and temp below setTemp + coolerOffHyst then try to switch off if fridge.cooler.isOn(): if temp < (setTemp + coolerOffHyst): fridge.cooler.turnOff() dataLog.info('{}'.format(setTemp) + ', ' + '{}'.format(temp) + ', ' + str(fridge.heater.isOn()) + ', ' + '{}'.format(fridge.cooler.isOn()) ) fridge.updateResultsLog(dataFileName) while datetime.datetime.now() < (loopStartTime + samplePeriod): doNothing = 1 except KeyboardInterrupt: logger.info('Ctrl-c Exit.') fridge.heater.turnOff() fridge.cooler.turnOff() sys.exit()
lgpl-3.0
[ 646, 820, 10542, 14, 21071, 465, 20899, 199, 646, 2197, 199, 646, 900, 199, 646, 10634, 465, 6454, 199, 646, 2050, 199, 646, 2050, 14, 5586, 199, 646, 984, 199, 199, 2921, 275, 2050, 14, 5572, 360, 70, 5562, 358, 199, 2232, 275, 2050, 14, 22482, 342, 199, 70, 2461, 275, 2050, 14, 21982, 360, 70, 5562, 14, 793, 358, 199, 8911, 275, 2050, 14, 7772, 480, 2840, 18331, 9, 83, 259, 2818, 20056, 9, 83, 259, 2818, 1188, 9, 83, 401, 2071, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 199, 2232, 14, 26076, 8, 8911, 9, 199, 70, 2461, 14, 26076, 8, 8911, 9, 199, 2921, 14, 18826, 8, 2232, 9, 199, 2921, 14, 18826, 8, 70, 2461, 9, 199, 2921, 14, 13548, 8, 4806, 14, 5287, 9, 199, 4806, 14, 12685, 15921, 8, 549, 9, 199, 199, 576, 2445, 275, 2050, 14, 5572, 360, 70, 5562, 14, 576, 358, 199, 576, 7772, 275, 2050, 14, 7772, 480, 2840, 18331, 9, 83, 12, 2818, 1188, 9, 83, 401, 2071, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 199, 576, 7733, 275, 283, 70, 5562, 15668, 435, 620, 8, 2083, 14, 2083, 14, 2131, 1012, 435, 1987, 576, 7, 199, 576, 2461, 275, 2050, 14, 5586, 14, 14728, 1958, 21982, 8, 576, 7733, 12, 818, 534, 87, 297, 1390, 5571, 29, 9943, 12, 6902, 2353, 29, 18, 9, 199, 576, 2461, 14, 26076, 8, 576, 7772, 9, 199, 576, 2445, 14, 18826, 8, 576, 2461, 9, 199, 576, 2445, 14, 13548, 8, 4806, 14, 4531, 9, 199, 199, 533, 481, 5562, 26, 199, 198, 318, 636, 826, 721, 277, 12, 946, 6618, 39, 13937, 12, 512, 79, 1435, 39, 13937, 12, 16353, 6792, 6530, 10160, 50, 676, 3034, 304, 28550, 198, 277, 14, 826, 39, 13937, 8, 426, 6618, 39, 13937, 12, 512, 79, 1435, 39, 13937, 9, 9068, 198, 277, 14, 426, 6618, 275, 12540, 7899, 2162, 8, 426, 6618, 39, 13937, 12, 536, 534, 426, 6618, 358, 507, 198, 277, 14, 22684, 1435, 275, 12540, 7899, 2162, 8, 22684, 1435, 39, 13937, 12, 536, 534, 22684, 1435, 358, 507, 198, 277, 14, 455, 4492, 484, 6530, 10160, 275, 577, 51, 1085, 34, 1165, 8, 455, 4492, 484, 6530, 10160, 50, 676, 3034, 12, 536, 534, 6530, 51, 8764, 358, 1057, 9068, 198, 277, 14, 1099, 15518, 275, 2197, 14, 7473, 8, 10430, 29, 709, 9, 507, 198, 277, 14, 988, 6579, 275, 5198, 507, 198, 277, 14, 2019, 2889, 1366, 275, 488, 507, 198, 277, 14, 1099, 1366, 275, 2197, 14, 2083, 14, 2131, 342, 5264, 507, 198, 277, 14, 2604, 1173, 275, 283, 2604, 14, 2424, 7, 507, 198, 545, 275, 1551, 8, 277, 14, 2604, 1173, 12, 283, 87, 358, 507, 198, 545, 14, 1600, 342, 18118, 198, 318, 4205, 39, 13937, 8, 277, 12, 946, 6618, 39, 13937, 19909, 12, 512, 79, 1435, 39, 13937, 19909, 304, 507, 198, 21071, 14, 409, 632, 8, 21071, 14, 6265, 45, 9, 507, 198, 21071, 14, 2758, 8, 426, 6618, 39, 13937, 19909, 12, 20899, 14, 1877, 9, 507, 198, 21071, 14, 2758, 8, 22684, 1435, 39, 13937, 19909, 12, 20899, 14, 1877, 9, 18118, 198, 318, 1678, 6579, 2445, 8, 277, 12, 666, 1173, 304, 1057, 507, 198, 692, 2197, 14, 2083, 14, 2131, 342, 2356, 291, 14, 1099, 1366, 26, 686, 198, 2131, 275, 2197, 14, 2083, 14, 2131, 342, 686, 198, 1247, 275, 788, 602, 297, 283, 409, 297, 283, 19116, 297, 283, 426, 6618, 297, 283, 22684, 1435, 418, 686, 198, 68, 275, 6454, 14, 739, 63, 4737, 8, 576, 1173, 12, 1561, 29, 1247, 9, 686, 198, 68, 459, 602, 418, 275, 6454, 14, 475, 63, 2083, 8, 68, 459, 602, 1105, 686, 198, 68, 459, 705, 418, 275, 366, 14, 19116, 446, 366, 14, 409, 686, 198, 68, 459, 2101, 547, 418, 275, 366, 459, 705, 2278, 2101, 342, 686, 198, 692, 291, 14, 2019, 2889, 1366, 508, 488, 26, 1585, 198, 3583, 275, 366, 686, 198, 2836, 26, 1585, 198, 928, 275, 291, 14, 2019, 2889, 1366, 1585, 198, 500, 275, 291, 14, 1099, 1366, 1585, 198, 2629, 275, 334, 68, 459, 602, 418, 690, 1343, 9, 1253, 334, 68, 459, 602, 418, 2695, 1284, 9, 1585, 198, 3583, 275, 366, 14, 2102, 59, 2629, 61, 26140, 198, 3670, 275, 4487, 14, 19116, 14, 3670, 342, 686, 198, 988, 5432, 275, 4487, 14, 705, 14, 988, 342, 686, 198, 827, 5432, 275, 4487, 14, 705, 14, 827, 342, 686, 198, 3670, 5432, 275, 4487, 14, 705, 14, 3670, 342, 686, 198, 3670, 15447, 5432, 275, 4487, 14, 2101, 547, 14, 3670, 342, 26140, 198, 409, 275, 366, 459, 409, 2278, 21104, 1988, 17, 61, 26140, 198, 1247, 275, 788, 602, 297, 283, 409, 297, 283, 3670, 297, 283, 988, 5432, 297, 283, 827, 5432, 297, 283, 3670, 5432, 297, 283, 3670, 15447, 5432, 418, 686, 198, 68, 63, 82, 275, 6454, 14, 739, 63, 4737, 8, 277, 14, 2604, 1173, 12, 1561, 29, 1247, 9, 26140, 198, 893, 26, 1585, 198, 329, 275, 1551, 8, 277, 14, 2604, 1173, 12, 283, 82, 358, 1585, 198, 470, 13569, 275, 5883, 14, 739, 342, 1585, 198, 470, 13569, 275, 522, 13569, 14, 1294, 2258, 78, 358, 1585, 198, 329, 14, 1600, 342, 686, 198, 2590, 26, 1585, 198, 26517, 275, 5198, 26140, 198, 545, 275, 1551, 8, 277, 14, 2604, 1173, 12, 283, 87, 358, 26140, 198, 545, 14, 952, 11117, 26, 845, 83, 5285, 908, 360, 2506, 1333, 686, 198, 545, 14, 952, 11117, 26, 25, 83, 5285, 908, 360, 1366, 1333, 686, 198, 545, 14, 952, 11117, 26, 21, 83, 5285, 908, 360, 409, 1333, 686, 198, 545, 14, 952, 11117, 26, 21, 83, 5285, 908, 360, 3670, 1333, 686, 198, 545, 14, 952, 11117, 26, 21, 83, 5285, 908, 360, 988, 37, 1333, 686, 198, 545, 14, 952, 11117, 26, 21, 83, 5285, 908, 360, 827, 37, 1333, 686, 198, 545, 14, 952, 11117, 26, 22, 83, 5285, 908, 360, 3670, 37, 1333, 686, 198, 545, 14, 952, 11117, 26, 25, 83, 5285, 908, 360 ]
[ 820, 10542, 14, 21071, 465, 20899, 199, 646, 2197, 199, 646, 900, 199, 646, 10634, 465, 6454, 199, 646, 2050, 199, 646, 2050, 14, 5586, 199, 646, 984, 199, 199, 2921, 275, 2050, 14, 5572, 360, 70, 5562, 358, 199, 2232, 275, 2050, 14, 22482, 342, 199, 70, 2461, 275, 2050, 14, 21982, 360, 70, 5562, 14, 793, 358, 199, 8911, 275, 2050, 14, 7772, 480, 2840, 18331, 9, 83, 259, 2818, 20056, 9, 83, 259, 2818, 1188, 9, 83, 401, 2071, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 199, 2232, 14, 26076, 8, 8911, 9, 199, 70, 2461, 14, 26076, 8, 8911, 9, 199, 2921, 14, 18826, 8, 2232, 9, 199, 2921, 14, 18826, 8, 70, 2461, 9, 199, 2921, 14, 13548, 8, 4806, 14, 5287, 9, 199, 4806, 14, 12685, 15921, 8, 549, 9, 199, 199, 576, 2445, 275, 2050, 14, 5572, 360, 70, 5562, 14, 576, 358, 199, 576, 7772, 275, 2050, 14, 7772, 480, 2840, 18331, 9, 83, 12, 2818, 1188, 9, 83, 401, 2071, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 199, 576, 7733, 275, 283, 70, 5562, 15668, 435, 620, 8, 2083, 14, 2083, 14, 2131, 1012, 435, 1987, 576, 7, 199, 576, 2461, 275, 2050, 14, 5586, 14, 14728, 1958, 21982, 8, 576, 7733, 12, 818, 534, 87, 297, 1390, 5571, 29, 9943, 12, 6902, 2353, 29, 18, 9, 199, 576, 2461, 14, 26076, 8, 576, 7772, 9, 199, 576, 2445, 14, 18826, 8, 576, 2461, 9, 199, 576, 2445, 14, 13548, 8, 4806, 14, 4531, 9, 199, 199, 533, 481, 5562, 26, 199, 198, 318, 636, 826, 721, 277, 12, 946, 6618, 39, 13937, 12, 512, 79, 1435, 39, 13937, 12, 16353, 6792, 6530, 10160, 50, 676, 3034, 304, 28550, 198, 277, 14, 826, 39, 13937, 8, 426, 6618, 39, 13937, 12, 512, 79, 1435, 39, 13937, 9, 9068, 198, 277, 14, 426, 6618, 275, 12540, 7899, 2162, 8, 426, 6618, 39, 13937, 12, 536, 534, 426, 6618, 358, 507, 198, 277, 14, 22684, 1435, 275, 12540, 7899, 2162, 8, 22684, 1435, 39, 13937, 12, 536, 534, 22684, 1435, 358, 507, 198, 277, 14, 455, 4492, 484, 6530, 10160, 275, 577, 51, 1085, 34, 1165, 8, 455, 4492, 484, 6530, 10160, 50, 676, 3034, 12, 536, 534, 6530, 51, 8764, 358, 1057, 9068, 198, 277, 14, 1099, 15518, 275, 2197, 14, 7473, 8, 10430, 29, 709, 9, 507, 198, 277, 14, 988, 6579, 275, 5198, 507, 198, 277, 14, 2019, 2889, 1366, 275, 488, 507, 198, 277, 14, 1099, 1366, 275, 2197, 14, 2083, 14, 2131, 342, 5264, 507, 198, 277, 14, 2604, 1173, 275, 283, 2604, 14, 2424, 7, 507, 198, 545, 275, 1551, 8, 277, 14, 2604, 1173, 12, 283, 87, 358, 507, 198, 545, 14, 1600, 342, 18118, 198, 318, 4205, 39, 13937, 8, 277, 12, 946, 6618, 39, 13937, 19909, 12, 512, 79, 1435, 39, 13937, 19909, 304, 507, 198, 21071, 14, 409, 632, 8, 21071, 14, 6265, 45, 9, 507, 198, 21071, 14, 2758, 8, 426, 6618, 39, 13937, 19909, 12, 20899, 14, 1877, 9, 507, 198, 21071, 14, 2758, 8, 22684, 1435, 39, 13937, 19909, 12, 20899, 14, 1877, 9, 18118, 198, 318, 1678, 6579, 2445, 8, 277, 12, 666, 1173, 304, 1057, 507, 198, 692, 2197, 14, 2083, 14, 2131, 342, 2356, 291, 14, 1099, 1366, 26, 686, 198, 2131, 275, 2197, 14, 2083, 14, 2131, 342, 686, 198, 1247, 275, 788, 602, 297, 283, 409, 297, 283, 19116, 297, 283, 426, 6618, 297, 283, 22684, 1435, 418, 686, 198, 68, 275, 6454, 14, 739, 63, 4737, 8, 576, 1173, 12, 1561, 29, 1247, 9, 686, 198, 68, 459, 602, 418, 275, 6454, 14, 475, 63, 2083, 8, 68, 459, 602, 1105, 686, 198, 68, 459, 705, 418, 275, 366, 14, 19116, 446, 366, 14, 409, 686, 198, 68, 459, 2101, 547, 418, 275, 366, 459, 705, 2278, 2101, 342, 686, 198, 692, 291, 14, 2019, 2889, 1366, 508, 488, 26, 1585, 198, 3583, 275, 366, 686, 198, 2836, 26, 1585, 198, 928, 275, 291, 14, 2019, 2889, 1366, 1585, 198, 500, 275, 291, 14, 1099, 1366, 1585, 198, 2629, 275, 334, 68, 459, 602, 418, 690, 1343, 9, 1253, 334, 68, 459, 602, 418, 2695, 1284, 9, 1585, 198, 3583, 275, 366, 14, 2102, 59, 2629, 61, 26140, 198, 3670, 275, 4487, 14, 19116, 14, 3670, 342, 686, 198, 988, 5432, 275, 4487, 14, 705, 14, 988, 342, 686, 198, 827, 5432, 275, 4487, 14, 705, 14, 827, 342, 686, 198, 3670, 5432, 275, 4487, 14, 705, 14, 3670, 342, 686, 198, 3670, 15447, 5432, 275, 4487, 14, 2101, 547, 14, 3670, 342, 26140, 198, 409, 275, 366, 459, 409, 2278, 21104, 1988, 17, 61, 26140, 198, 1247, 275, 788, 602, 297, 283, 409, 297, 283, 3670, 297, 283, 988, 5432, 297, 283, 827, 5432, 297, 283, 3670, 5432, 297, 283, 3670, 15447, 5432, 418, 686, 198, 68, 63, 82, 275, 6454, 14, 739, 63, 4737, 8, 277, 14, 2604, 1173, 12, 1561, 29, 1247, 9, 26140, 198, 893, 26, 1585, 198, 329, 275, 1551, 8, 277, 14, 2604, 1173, 12, 283, 82, 358, 1585, 198, 470, 13569, 275, 5883, 14, 739, 342, 1585, 198, 470, 13569, 275, 522, 13569, 14, 1294, 2258, 78, 358, 1585, 198, 329, 14, 1600, 342, 686, 198, 2590, 26, 1585, 198, 26517, 275, 5198, 26140, 198, 545, 275, 1551, 8, 277, 14, 2604, 1173, 12, 283, 87, 358, 26140, 198, 545, 14, 952, 11117, 26, 845, 83, 5285, 908, 360, 2506, 1333, 686, 198, 545, 14, 952, 11117, 26, 25, 83, 5285, 908, 360, 1366, 1333, 686, 198, 545, 14, 952, 11117, 26, 21, 83, 5285, 908, 360, 409, 1333, 686, 198, 545, 14, 952, 11117, 26, 21, 83, 5285, 908, 360, 3670, 1333, 686, 198, 545, 14, 952, 11117, 26, 21, 83, 5285, 908, 360, 988, 37, 1333, 686, 198, 545, 14, 952, 11117, 26, 21, 83, 5285, 908, 360, 827, 37, 1333, 686, 198, 545, 14, 952, 11117, 26, 22, 83, 5285, 908, 360, 3670, 37, 1333, 686, 198, 545, 14, 952, 11117, 26, 25, 83, 5285, 908, 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, 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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 ]
chris4795/u-boot-novena
tools/rkmux.py
14
6095
#!/usr/bin/python # Script to create enums from datasheet register tables # # Usage: # # First, create a text file from the datasheet: # pdftotext -layout /path/to/rockchip-3288-trm.pdf /tmp/asc # # Then use this script to output the #defines for a particular register: # ./tools/rkmux.py GRF_GPIO4C_IOMUX # # It will create output suitable for putting in a header file, with SHIFT and # MASK values for each bitfield in the register. # # Note: this tool is not perfect and you may need to edit the resulting code. # But it should speed up the process. import csv import re import sys tab_to_col = 3 class RegField: def __init__(self, cols=None): if cols: self.bits, self.attr, self.reset_val, self.desc = ( [x.strip() for x in cols]) self.desc = [self.desc] else: self.bits = '' self.attr = '' self.reset_val = '' self.desc = [] def Setup(self, cols): self.bits, self.attr, self.reset_val = cols[0:3] if len(cols) > 3: self.desc.append(cols[3]) def AddDesc(self, desc): self.desc.append(desc) def Show(self): print self print self.__init__() def __str__(self): return '%s,%s,%s,%s' % (self.bits, self.attr, self.reset_val, '\n'.join(self.desc)) class Printer: def __init__(self, name): self.first = True self.name = name self.re_sel = re.compile("[1-9]'b([01]+): (.*)") def __enter__(self): return self def __exit__(self, type, value, traceback): if not self.first: self.output_footer() def output_header(self): print '/* %s */' % self.name print 'enum {' def output_footer(self): print '};'; def output_regfield(self, regfield): lines = regfield.desc field = lines[0] #print 'field:', field if field in ['reserved', 'reserve', 'write_enable', 'write_mask']: return if field.endswith('_sel') or field.endswith('_con'): field = field[:-4] elif field.endswith(' iomux'): field = field[:-6] elif field.endswith('_mode') or field.endswith('_mask'): field = field[:-5] #else: #print 'bad field %s' % field #return field = field.upper() if ':' in regfield.bits: bit_high, bit_low = [int(x) for x in regfield.bits.split(':')] else: bit_high = bit_low = int(regfield.bits) bit_width = bit_high - bit_low + 1 mask = (1 << bit_width) - 1 if self.first: self.first = False self.output_header() else: print out_enum(field, 'shift', bit_low) out_enum(field, 'mask', mask) next_val = -1 #print 'lines: %s', lines for line in lines: m = self.re_sel.match(line) if m: val, enum = int(m.group(1), 2), m.group(2) if enum not in ['reserved', 'reserve']: out_enum(field, enum, val, val == next_val) next_val = val + 1 def process_file(name, fd): field = RegField() reg = '' fields = [] def add_it(field): if field.bits: if reg == name: fields.append(field) field = RegField() return field def is_field_start(line): if '=' in line or '+' in line: return False if (line.startswith('gpio') or line.startswith('peri_') or line.endswith('_sel') or line.endswith('_con')): return True if not ' ' in line: # and '_' in line: return True return False for line in fd: line = line.rstrip() if line[:4] in ['GRF_', 'PMU_', 'CRU_']: field = add_it(field) reg = line do_this = name == reg elif not line or not line.startswith(' '): continue line = line.replace('\xe2\x80\x99', "'") leading = len(line) - len(line.lstrip()) line = line.lstrip() cols = re.split(' *', line, 3) if leading > 15 or (len(cols) > 3 and is_field_start(cols[3])): if is_field_start(line): field = add_it(field) field.AddDesc(line) else: if cols[0] == 'Bit' or len(cols) < 3: continue #print #print field field = add_it(field) field.Setup(cols) field = add_it(field) with Printer(name) as printer: for field in fields: #print field printer.output_regfield(field) #print def out_enum(field, suffix, value, skip_val=False): str = '%s_%s' % (field.upper(), suffix.upper()) if not skip_val: tabs = tab_to_col - len(str) / 8 if value > 9: val_str = '%#x' % value else: val_str = '%d' % value str += '%s= %s' % ('\t' * tabs, val_str) print '\t%s,' % str # Process a CSV file, e.g. from tabula def process_csv(name, fd): reader = csv.reader(fd) rows = [] field = RegField() for row in reader: #print field.desc if not row[0]: field.desc.append(row[3]) continue if field.bits: if field.bits != 'Bit': rows.append(field) #print row field = RegField(row) with Printer(name) as printer: for row in rows: #print field printer.output_regfield(row) #print fname = sys.argv[1] name = sys.argv[2] # Read output from pdftotext -layout if 1: with open(fname, 'r') as fd: process_file(name, fd) # Use tabula # It seems to be better at outputting text for an entire cell in one cell. # But it does not always work. E.g. GRF_GPIO7CH_IOMUX. # So there is no point in using it. if 0: with open(fname, 'r') as fd: process_csv(name, fd)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 3, 14914, 370, 1218, 28441, 687, 15012, 3797, 2274, 6716, 199, 3, 199, 3, 11028, 26, 199, 3, 199, 3, 7758, 12, 1218, 282, 1318, 570, 687, 314, 15012, 3797, 26, 199, 3, 259, 11249, 475, 505, 446, 4209, 1182, 515, 15, 475, 15, 24892, 28329, 13, 708, 1299, 13, 454, 77, 14, 5607, 1182, 2791, 15, 10125, 199, 3, 199, 3, 9442, 675, 642, 2884, 370, 1072, 314, 327, 14334, 367, 282, 6770, 2274, 26, 199, 3, 259, 16605, 2537, 15, 82, 14595, 2521, 14, 647, 598, 11778, 63, 21071, 20, 35, 63, 2090, 45, 14272, 199, 3, 199, 3, 2779, 911, 1218, 1072, 11233, 367, 32670, 315, 282, 1406, 570, 12, 543, 20754, 436, 199, 3, 603, 7946, 1338, 367, 1924, 4546, 698, 315, 314, 2274, 14, 199, 3, 199, 3, 3390, 26, 642, 4744, 365, 440, 23668, 436, 1265, 1443, 1929, 370, 5283, 314, 9183, 1233, 14, 199, 3, 11017, 652, 1077, 8112, 1536, 314, 2112, 14, 199, 199, 646, 7392, 199, 646, 295, 199, 646, 984, 199, 199, 2902, 63, 475, 63, 761, 275, 650, 199, 199, 533, 5044, 792, 26, 272, 347, 636, 826, 721, 277, 12, 8850, 29, 403, 304, 267, 340, 8850, 26, 288, 291, 14, 5609, 12, 291, 14, 962, 12, 291, 14, 3958, 63, 637, 12, 291, 14, 3257, 275, 334, 355, 359, 88, 14, 1913, 342, 367, 671, 315, 8850, 566, 288, 291, 14, 3257, 275, 359, 277, 14, 3257, 61, 267, 587, 26, 288, 291, 14, 5609, 275, 2125, 288, 291, 14, 962, 275, 2125, 288, 291, 14, 3958, 63, 637, 275, 2125, 288, 291, 14, 3257, 275, 942, 339, 347, 12439, 8, 277, 12, 8850, 304, 267, 291, 14, 5609, 12, 291, 14, 962, 12, 291, 14, 3958, 63, 637, 275, 8850, 59, 16, 26, 19, 61, 267, 340, 822, 8, 4574, 9, 690, 650, 26, 288, 291, 14, 3257, 14, 740, 8, 4574, 59, 19, 566, 339, 347, 2654, 9921, 8, 277, 12, 4328, 304, 267, 291, 14, 3257, 14, 740, 8, 3257, 9, 339, 347, 12968, 8, 277, 304, 267, 870, 291, 267, 870, 267, 291, 855, 826, 4533, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 83, 8719, 83, 8719, 83, 8719, 83, 7, 450, 334, 277, 14, 5609, 12, 291, 14, 962, 12, 291, 14, 3958, 63, 637, 12, 1816, 1557, 78, 1370, 904, 8, 277, 14, 3257, 430, 199, 199, 533, 25716, 1058, 26, 272, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 2246, 275, 715, 267, 291, 14, 354, 275, 536, 267, 291, 14, 264, 63, 5891, 275, 295, 14, 2014, 10994, 17, 13, 25, 6616, 66, 779, 614, 2807, 304, 334, 2795, 6320, 339, 347, 636, 4200, 721, 277, 304, 267, 372, 291, 339, 347, 636, 2224, 721, 277, 12, 730, 12, 574, 12, 5190, 304, 267, 340, 440, 291, 14, 2246, 26, 288, 291, 14, 1199, 63, 12781, 342, 339, 347, 1072, 63, 1291, 8, 277, 304, 267, 870, 1994, 10, 450, 83, 627, 4805, 450, 291, 14, 354, 267, 870, 283, 4869, 791, 339, 347, 1072, 63, 12781, 8, 277, 304, 267, 870, 28544, 8942, 27, 339, 347, 1072, 63, 1135, 698, 8, 277, 12, 1295, 698, 304, 267, 2385, 275, 1295, 698, 14, 3257, 267, 901, 275, 2385, 59, 16, 61, 267, 327, 1361, 283, 698, 6536, 901, 267, 340, 901, 315, 788, 10421, 297, 283, 19643, 297, 283, 952, 63, 4296, 297, 283, 952, 63, 2629, 2565, 288, 372, 267, 340, 901, 14, 4130, 6412, 5891, 358, 503, 901, 14, 4130, 6412, 388, 735, 288, 901, 275, 901, 4439, 20, 61, 267, 916, 901, 14, 4130, 360, 284, 676, 2521, 735, 288, 901, 275, 901, 4439, 22, 61, 267, 916, 901, 14, 4130, 6412, 632, 358, 503, 901, 14, 4130, 6412, 2629, 735, 288, 901, 275, 901, 4439, 21, 61, 267, 327, 2836, 26, 288, 327, 1361, 283, 4087, 901, 450, 83, 7, 450, 901, 288, 327, 1107, 267, 901, 275, 901, 14, 4142, 342, 267, 340, 10871, 315, 1295, 698, 14, 5609, 26, 288, 4546, 63, 6260, 12, 4546, 63, 674, 275, 359, 442, 8, 88, 9, 367, 671, 315, 1295, 698, 14, 5609, 14, 1294, 6176, 5440, 267, 587, 26, 288, 4546, 63, 6260, 275, 4546, 63, 674, 275, 1109, 8, 1135, 698, 14, 5609, 9, 267, 4546, 63, 2063, 275, 4546, 63, 6260, 446, 4546, 63, 674, 435, 413, 267, 3656, 275, 334, 17, 5213, 4546, 63, 2063, 9, 446, 413, 267, 340, 291, 14, 2246, 26, 288, 291, 14, 2246, 275, 756, 288, 291, 14, 1199, 63, 1291, 342, 267, 587, 26, 288, 870, 267, 734, 63, 4869, 8, 698, 12, 283, 4723, 297, 4546, 63, 674, 9, 267, 734, 63, 4869, 8, 698, 12, 283, 2629, 297, 3656, 9, 267, 2163, 63, 637, 275, 446, 17, 267, 327, 1361, 283, 1278, 26, 450, 83, 297, 2385, 267, 367, 1004, 315, 2385, 26, 288, 333, 275, 291, 14, 264, 63, 5891, 14, 1431, 8, 604, 9, 288, 340, 333, 26, 355, 1139, 12, 4952, 275, 1109, 8, 77, 14, 923, 8, 17, 395, 499, 395, 333, 14, 923, 8, 18, 9, 355, 340, 4952, 440, 315, 788, 10421, 297, 283, 19643, 2565, 490, 734, 63, 4869, 8, 698, 12, 4952, 12, 1139, 12, 1139, 508, 2163, 63, 637, 9, 490, 2163, 63, 637, 275, 1139, 435, 413, 421, 199, 318, 2112, 63, 493, 8, 354, 12, 6111, 304, 272, 901, 275, 5044, 792, 342, 272, 1295, 275, 2125, 339, 1504, 275, 942, 339, 347, 1050, 63, 390, 8, 698, 304, 267, 340, 901, 14, 5609, 26, 288, 340, 1295, 508, 536, 26, 355, 1504, 14, 740, 8, 698, 9, 288, 901, 275, 5044, 792, 342, 267, 372, 901, 339, 347, 365, 63, 698, 63, 928, 8, 604, 304, 2126, 340, 14051, 315, 1004, 503, 20246, 315, 1004, 26, 1779, 372, 756, 2126, 340, 334, 604, 14, 2460, 360, 21918, 358, 503, 1004, 14, 2460, 360, 5490, 15452, 503, 355, 1004, 14, 4130, 6412, 5891, 358, 503, 1004, 14, 4130, 6412, 388, 8109, 1779, 372, 715, 2126, 340, 440, 283, 283, 315, 1004, 26, 327 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 3, 14914, 370, 1218, 28441, 687, 15012, 3797, 2274, 6716, 199, 3, 199, 3, 11028, 26, 199, 3, 199, 3, 7758, 12, 1218, 282, 1318, 570, 687, 314, 15012, 3797, 26, 199, 3, 259, 11249, 475, 505, 446, 4209, 1182, 515, 15, 475, 15, 24892, 28329, 13, 708, 1299, 13, 454, 77, 14, 5607, 1182, 2791, 15, 10125, 199, 3, 199, 3, 9442, 675, 642, 2884, 370, 1072, 314, 327, 14334, 367, 282, 6770, 2274, 26, 199, 3, 259, 16605, 2537, 15, 82, 14595, 2521, 14, 647, 598, 11778, 63, 21071, 20, 35, 63, 2090, 45, 14272, 199, 3, 199, 3, 2779, 911, 1218, 1072, 11233, 367, 32670, 315, 282, 1406, 570, 12, 543, 20754, 436, 199, 3, 603, 7946, 1338, 367, 1924, 4546, 698, 315, 314, 2274, 14, 199, 3, 199, 3, 3390, 26, 642, 4744, 365, 440, 23668, 436, 1265, 1443, 1929, 370, 5283, 314, 9183, 1233, 14, 199, 3, 11017, 652, 1077, 8112, 1536, 314, 2112, 14, 199, 199, 646, 7392, 199, 646, 295, 199, 646, 984, 199, 199, 2902, 63, 475, 63, 761, 275, 650, 199, 199, 533, 5044, 792, 26, 272, 347, 636, 826, 721, 277, 12, 8850, 29, 403, 304, 267, 340, 8850, 26, 288, 291, 14, 5609, 12, 291, 14, 962, 12, 291, 14, 3958, 63, 637, 12, 291, 14, 3257, 275, 334, 355, 359, 88, 14, 1913, 342, 367, 671, 315, 8850, 566, 288, 291, 14, 3257, 275, 359, 277, 14, 3257, 61, 267, 587, 26, 288, 291, 14, 5609, 275, 2125, 288, 291, 14, 962, 275, 2125, 288, 291, 14, 3958, 63, 637, 275, 2125, 288, 291, 14, 3257, 275, 942, 339, 347, 12439, 8, 277, 12, 8850, 304, 267, 291, 14, 5609, 12, 291, 14, 962, 12, 291, 14, 3958, 63, 637, 275, 8850, 59, 16, 26, 19, 61, 267, 340, 822, 8, 4574, 9, 690, 650, 26, 288, 291, 14, 3257, 14, 740, 8, 4574, 59, 19, 566, 339, 347, 2654, 9921, 8, 277, 12, 4328, 304, 267, 291, 14, 3257, 14, 740, 8, 3257, 9, 339, 347, 12968, 8, 277, 304, 267, 870, 291, 267, 870, 267, 291, 855, 826, 4533, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 83, 8719, 83, 8719, 83, 8719, 83, 7, 450, 334, 277, 14, 5609, 12, 291, 14, 962, 12, 291, 14, 3958, 63, 637, 12, 1816, 1557, 78, 1370, 904, 8, 277, 14, 3257, 430, 199, 199, 533, 25716, 1058, 26, 272, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 2246, 275, 715, 267, 291, 14, 354, 275, 536, 267, 291, 14, 264, 63, 5891, 275, 295, 14, 2014, 10994, 17, 13, 25, 6616, 66, 779, 614, 2807, 304, 334, 2795, 6320, 339, 347, 636, 4200, 721, 277, 304, 267, 372, 291, 339, 347, 636, 2224, 721, 277, 12, 730, 12, 574, 12, 5190, 304, 267, 340, 440, 291, 14, 2246, 26, 288, 291, 14, 1199, 63, 12781, 342, 339, 347, 1072, 63, 1291, 8, 277, 304, 267, 870, 1994, 10, 450, 83, 627, 4805, 450, 291, 14, 354, 267, 870, 283, 4869, 791, 339, 347, 1072, 63, 12781, 8, 277, 304, 267, 870, 28544, 8942, 27, 339, 347, 1072, 63, 1135, 698, 8, 277, 12, 1295, 698, 304, 267, 2385, 275, 1295, 698, 14, 3257, 267, 901, 275, 2385, 59, 16, 61, 267, 327, 1361, 283, 698, 6536, 901, 267, 340, 901, 315, 788, 10421, 297, 283, 19643, 297, 283, 952, 63, 4296, 297, 283, 952, 63, 2629, 2565, 288, 372, 267, 340, 901, 14, 4130, 6412, 5891, 358, 503, 901, 14, 4130, 6412, 388, 735, 288, 901, 275, 901, 4439, 20, 61, 267, 916, 901, 14, 4130, 360, 284, 676, 2521, 735, 288, 901, 275, 901, 4439, 22, 61, 267, 916, 901, 14, 4130, 6412, 632, 358, 503, 901, 14, 4130, 6412, 2629, 735, 288, 901, 275, 901, 4439, 21, 61, 267, 327, 2836, 26, 288, 327, 1361, 283, 4087, 901, 450, 83, 7, 450, 901, 288, 327, 1107, 267, 901, 275, 901, 14, 4142, 342, 267, 340, 10871, 315, 1295, 698, 14, 5609, 26, 288, 4546, 63, 6260, 12, 4546, 63, 674, 275, 359, 442, 8, 88, 9, 367, 671, 315, 1295, 698, 14, 5609, 14, 1294, 6176, 5440, 267, 587, 26, 288, 4546, 63, 6260, 275, 4546, 63, 674, 275, 1109, 8, 1135, 698, 14, 5609, 9, 267, 4546, 63, 2063, 275, 4546, 63, 6260, 446, 4546, 63, 674, 435, 413, 267, 3656, 275, 334, 17, 5213, 4546, 63, 2063, 9, 446, 413, 267, 340, 291, 14, 2246, 26, 288, 291, 14, 2246, 275, 756, 288, 291, 14, 1199, 63, 1291, 342, 267, 587, 26, 288, 870, 267, 734, 63, 4869, 8, 698, 12, 283, 4723, 297, 4546, 63, 674, 9, 267, 734, 63, 4869, 8, 698, 12, 283, 2629, 297, 3656, 9, 267, 2163, 63, 637, 275, 446, 17, 267, 327, 1361, 283, 1278, 26, 450, 83, 297, 2385, 267, 367, 1004, 315, 2385, 26, 288, 333, 275, 291, 14, 264, 63, 5891, 14, 1431, 8, 604, 9, 288, 340, 333, 26, 355, 1139, 12, 4952, 275, 1109, 8, 77, 14, 923, 8, 17, 395, 499, 395, 333, 14, 923, 8, 18, 9, 355, 340, 4952, 440, 315, 788, 10421, 297, 283, 19643, 2565, 490, 734, 63, 4869, 8, 698, 12, 4952, 12, 1139, 12, 1139, 508, 2163, 63, 637, 9, 490, 2163, 63, 637, 275, 1139, 435, 413, 421, 199, 318, 2112, 63, 493, 8, 354, 12, 6111, 304, 272, 901, 275, 5044, 792, 342, 272, 1295, 275, 2125, 339, 1504, 275, 942, 339, 347, 1050, 63, 390, 8, 698, 304, 267, 340, 901, 14, 5609, 26, 288, 340, 1295, 508, 536, 26, 355, 1504, 14, 740, 8, 698, 9, 288, 901, 275, 5044, 792, 342, 267, 372, 901, 339, 347, 365, 63, 698, 63, 928, 8, 604, 304, 2126, 340, 14051, 315, 1004, 503, 20246, 315, 1004, 26, 1779, 372, 756, 2126, 340, 334, 604, 14, 2460, 360, 21918, 358, 503, 1004, 14, 2460, 360, 5490, 15452, 503, 355, 1004, 14, 4130, 6412, 5891, 358, 503, 1004, 14, 4130, 6412, 388, 8109, 1779, 372, 715, 2126, 340, 440, 283, 283, 315, 1004, 26, 327, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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mer # # Copyright (C) 2001-2012 NLTK Proejct # Algorithm: Kazem Taghva, Rania Elkhoury, and Jeffrey Coombs (2005) # Author: Hosam Algasaier <hosam_hme@yahoo.com> # URL: <http://www.nltk.org/> # For license information, see LICENSE.TXT """ ISRI Arabic Stemmer The algorithm for this stemmer is described in: Taghva, K., Elkoury, R., and Coombs, J. 2005. Arabic Stemming without a root dictionary. Information Science Research Institute. University of Nevada, Las Vegas, USA. The Information Science Research Institute’s (ISRI) Arabic stemmer shares many features with the Khoja stemmer. However, the main difference is that ISRI stemmer does not use root dictionary. Also, if a root is not found, ISRI stemmer returned normalized form, rather than returning the original unmodified word. Additional adjustments were made to improve the algorithm: 1- Adding 60 stop words. 2- Adding the pattern (تفاعيل) to ISRI pattern set. 3- The step 2 in the original algorithm was normalizing all hamza. This step is discarded because it increases the word ambiguities and changes the original root. """ from __future__ import unicode_literals import re class ISRIStemmer(object): ''' ISRI Arabic stemmer based on algorithm: Arabic Stemming without a root dictionary. Information Science Research Institute. University of Nevada, Las Vegas, USA. A few minor modifications have been made to ISRI basic algorithm. See the source code of this module for more information. isri.stem(token) returns Arabic root for the given token. The ISRI Stemmer requires that all tokens have Unicode string types. If you use Python IDLE on Arabic Windows you have to decode text first using Arabic '1256' coding. ''' def __init__(self): self.stm = 'defult none' self.p3 = ['\u0643\u0627\u0644', '\u0628\u0627\u0644', '\u0648\u0644\u0644', '\u0648\u0627\u0644'] # length three prefixes self.p2 = ['\u0627\u0644', '\u0644\u0644'] # length two prefixes self.p1 = ['\u0644', '\u0628', '\u0641', '\u0633', '\u0648', '\u064a', '\u062a', '\u0646', '\u0627'] # length one prefixes self.s3 = ['\u062a\u0645\u0644', '\u0647\u0645\u0644', '\u062a\u0627\u0646', '\u062a\u064a\u0646', '\u0643\u0645\u0644'] # length three suffixes self.s2 = ['\u0648\u0646', '\u0627\u062a', '\u0627\u0646', '\u064a\u0646', '\u062a\u0646', '\u0643\u0645', '\u0647\u0646', '\u0646\u0627', '\u064a\u0627', '\u0647\u0627', '\u062a\u0645', '\u0643\u0646', '\u0646\u064a', '\u0648\u0627', '\u0645\u0627', '\u0647\u0645'] # length two suffixes self.s1 = ['\u0629', '\u0647', '\u064a', '\u0643', '\u062a', '\u0627', '\u0646'] # length one suffixes self.pr4 = {0: ['\u0645'], 1:['\u0627'], 2: ['\u0627', '\u0648', '\u064A'], 3:['\u0629']} # groups of length four patterns self.pr53 = {0: ['\u0627', '\u062a'], 1: ['\u0627', '\u064a', '\u0648'], 2: ['\u0627', '\u062a', '\u0645'], 3: ['\u0645', '\u064a', '\u062a'], 4: ['\u0645', '\u062a'], 5: ['\u0627', '\u0648'], 6: ['\u0627', '\u0645']} # Groups of length five patterns and length three roots self.re_short_vowels = re.compile(r'[\u064B-\u0652]') self.re_hamza = re.compile(r'[\u0621\u0624\u0626]') self.re_intial_hamza = re.compile(r'^[\u0622\u0623\u0625]') self.stop_words = ['\u064a\u0643\u0648\u0646', '\u0648\u0644\u064a\u0633', '\u0648\u0643\u0627\u0646', '\u0643\u0630\u0644\u0643', '\u0627\u0644\u062a\u064a', '\u0648\u0628\u064a\u0646', '\u0639\u0644\u064a\u0647\u0627', '\u0645\u0633\u0627\u0621', '\u0627\u0644\u0630\u064a', '\u0648\u0643\u0627\u0646\u062a', '\u0648\u0644\u0643\u0646', '\u0648\u0627\u0644\u062a\u064a', '\u062a\u0643\u0648\u0646', '\u0627\u0644\u064a\u0648\u0645', '\u0627\u0644\u0644\u0630\u064a\u0646', '\u0639\u0644\u064a\u0647', '\u0643\u0627\u0646\u062a', '\u0644\u0630\u0644\u0643', '\u0623\u0645\u0627\u0645', '\u0647\u0646\u0627\u0643', '\u0645\u0646\u0647\u0627', '\u0645\u0627\u0632\u0627\u0644', '\u0644\u0627\u0632\u0627\u0644', '\u0644\u0627\u064a\u0632\u0627\u0644', '\u0645\u0627\u064a\u0632\u0627\u0644', '\u0627\u0635\u0628\u062d', '\u0623\u0635\u0628\u062d', '\u0623\u0645\u0633\u0649', '\u0627\u0645\u0633\u0649', '\u0623\u0636\u062d\u0649', '\u0627\u0636\u062d\u0649', '\u0645\u0627\u0628\u0631\u062d', '\u0645\u0627\u0641\u062a\u0626', '\u0645\u0627\u0627\u0646\u0641\u0643', '\u0644\u0627\u0633\u064a\u0645\u0627', '\u0648\u0644\u0627\u064a\u0632\u0627\u0644', '\u0627\u0644\u062d\u0627\u0644\u064a', '\u0627\u0644\u064a\u0647\u0627', '\u0627\u0644\u0630\u064a\u0646', '\u0641\u0627\u0646\u0647', '\u0648\u0627\u0644\u0630\u064a', '\u0648\u0647\u0630\u0627', '\u0644\u0647\u0630\u0627', '\u0641\u0643\u0627\u0646', '\u0633\u062a\u0643\u0648\u0646', '\u0627\u0644\u064a\u0647', '\u064a\u0645\u0643\u0646', '\u0628\u0647\u0630\u0627', '\u0627\u0644\u0630\u0649'] def stem(self, token): """ Stemming a word token using the ISRI stemmer. """ self.stm = token self.norm(1) # remove diacritics which representing Arabic short vowels if self.stm in self.stop_words: return self.stm # exclude stop words from being processed self.pre32() # remove length three and length two prefixes in this order self.suf32() # remove length three and length two suffixes in this order self.waw() # remove connective ‘و’ if it precedes a word beginning with ‘و’ self.norm(2) # normalize initial hamza to bare alif if len(self.stm) <= 3: return self.stm # return stem if less than or equal to three if len(self.stm) == 4: # length 4 word self.pro_w4() return self.stm elif len(self.stm) == 5: # length 5 word self.pro_w53() self.end_w5() return self.stm elif len(self.stm) == 6: # length 6 word self.pro_w6() self.end_w6() return self.stm elif len(self.stm) == 7: # length 7 word self.suf1() if len(self.stm) == 7: self.pre1() if len(self.stm) == 6: self.pro_w6() self.end_w6() return self.stm return self.stm # if word length >7 , then no stemming def norm(self, num): """ normalization: num=1 normalize diacritics num=2 normalize initial hamza num=3 both 1&2 """ self.k = num if self.k == 1: self.stm = self.re_short_vowels.sub('', self.stm) return self.stm elif self.k == 2: self.stm = self.re_intial_hamza.sub(r'\u0627', self.stm) return self.stm elif self.k == 3: self.stm = self.re_short_vowels.sub('', self.stm) self.stm = self.re_intial_hamza.sub(r'\u0627', self.stm) return self.stm def pre32(self): """remove length three and length two prefixes in this order""" if len(self.stm) >= 6: for pre3 in self.p3: if self.stm.startswith(pre3): self.stm = self.stm[3:] return self.stm elif len(self.stm) >= 5: for pre2 in self.p2: if self.stm.startswith(pre2): self.stm = self.stm[2:] return self.stm def suf32(self): """remove length three and length two suffixes in this order""" if len(self.stm) >= 6: for suf3 in self.s3: if self.stm.endswith(suf3): self.stm = self.stm[:-3] return self.stm elif len(self.stm) >= 5: for suf2 in self.s2: if self.stm.endswith(suf2): self.stm = self.stm[:-2] return self.stm def waw(self): """remove connective ‘و’ if it precedes a word beginning with ‘و’ """ if (len(self.stm) >= 4) & (self.stm[:2] == '\u0648\u0648'): self.stm = self.stm[1:] return self.stm def pro_w4(self): """process length four patterns and extract length three roots""" if self.stm[0] in self.pr4[0]: # مفعل self.stm = self.stm[1:] return self.stm elif self.stm[1] in self.pr4[1]: # فاعل self.stm = self.stm[0] + self.stm[2:] return self.stm elif self.stm[2] in self.pr4[2]: # فعال - فعول - فعيل self.stm = self.stm[:2] + self.stm[3] return self.stm elif self.stm[3] in self.pr4[3]: # فعلة self.stm = self.stm[:-1] return self.stm else: self.suf1() # do - normalize short sufix if len(self.stm) == 4: self.pre1() # do - normalize short prefix return self.stm def pro_w53(self): """process length five patterns and extract length three roots""" if ((self.stm[2] in self.pr53[0]) & (self.stm[0] == '\u0627')): # افتعل - افاعل self.stm = self.stm[1] + self.stm[3:] return self.stm elif ((self.stm[3] in self.pr53[1]) & (self.stm[0] == '\u0645')): # مفعول - مفعال - مفعيل self.stm = self.stm[1:3] + self.stm[4] return self.stm elif ((self.stm[0] in self.pr53[2]) & (self.stm[4] == '\u0629')): # مفعلة - تفعلة - افعلة self.stm = self.stm[1:4] return self.stm elif ((self.stm[0] in self.pr53[3]) & (self.stm[2] == '\u062a')): # مفتعل - يفتعل - تفتعل self.stm = self.stm[1] + self.stm[3:] return self.stm elif ((self.stm[0] in self.pr53[4]) & (self.stm[2] == '\u0627')): #مفاعل - تفاعل self.stm = self.stm[1] + self.stm[3:] return self.stm elif ((self.stm[2] in self.pr53[5]) & (self.stm[4] == '\u0629')): # فعولة - فعالة self.stm = self.stm[:2] + self.stm[3] return self.stm elif ((self.stm[0] in self.pr53[6]) & (self.stm[1] == '\u0646')): # انفعل - منفعل self.stm = self.stm[2:] return self.stm elif ((self.stm[3] == '\u0627') & (self.stm[0] == '\u0627')): # افعال self.stm = self.stm[1:3] + self.stm[4] return self.stm elif ((self.stm[4] == '\u0646') & (self.stm[3] == '\u0627')): # فعلان self.stm = self.stm[:3] return self.stm elif ((self.stm[3] == '\u064a') & (self.stm[0] == '\u062a')): # تفعيل self.stm = self.stm[1:3] + self.stm[4] return self.stm elif ((self.stm[3] == '\u0648') & (self.stm[1] == '\u0627')): # فاعول self.stm = self.stm[0] + self.stm[2] + self.stm[4] return self.stm elif ((self.stm[2] == '\u0627') & (self.stm[1] == '\u0648')): # فواعل self.stm = self.stm[0] + self.stm[3:] return self.stm elif ((self.stm[3] == '\u0626') & (self.stm[2] == '\u0627')): # فعائل self.stm = self.stm[:2] + self.stm[4] return self.stm elif ((self.stm[4] == '\u0629') & (self.stm[1] == '\u0627')): # فاعلة self.stm = self.stm[0] + self.stm[2:4] return self.stm elif ((self.stm[4] == '\u064a') & (self.stm[2] == '\u0627')): # فعالي self.stm = self.stm[:2] + self.stm[3] return self.stm else: self.suf1() # do - normalize short sufix if len(self.stm) == 5: self.pre1() # do - normalize short prefix return self.stm def pro_w54(self): """process length five patterns and extract length four roots""" if (self.stm[0] in self.pr53[2]): #تفعلل - افعلل - مفعلل self.stm = self.stm[1:] return self.stm elif (self.stm[4] == '\u0629'): # فعللة self.stm = self.stm[:4] return self.stm elif (self.stm[2] == '\u0627'): # فعالل self.stm = self.stm[:2] + self.stm[3:] return self.stm def end_w5(self): """ending step (word of length five)""" if len(self.stm) == 3: return self.stm elif len(self.stm) == 4: self.pro_w4() return self.stm elif len(self.stm) == 5: self.pro_w54() return self.stm def pro_w6(self): """process length six patterns and extract length three roots""" if ((self.stm.startswith('\u0627\u0633\u062a')) or (self.stm.startswith('\u0645\u0633\u062a'))): # مستفعل - استفعل self.stm = self.stm[3:] return self.stm elif (self.stm[0] == '\u0645' and self.stm[3] == '\u0627' and self.stm[5] == '\u0629'): # مفعالة self.stm = self.stm[1:3] + self.stm[4] return self.stm elif (self.stm[0] == '\u0627' and self.stm[2] == '\u062a' and self.stm[4] == '\u0627'): # افتعال self.stm = self.stm[1] + self.stm[3] + self.stm[5] return self.stm elif (self.stm[0] == '\u0627' and self.stm[3] == '\u0648' and self.stm[2] == self.stm[4]): # افعوعل self.stm = self.stm[1] + self.stm[4:] return self.stm elif (self.stm[0] == '\u062a' and self.stm[2] == '\u0627' and self.stm[4] == '\u064a'): # تفاعيل new pattern self.stm = self.stm[1] + self.stm[3] + self.stm[5] return self.stm else: self.suf1() # do - normalize short sufix if len(self.stm) == 6: self.pre1() # do - normalize short prefix return self.stm def pro_w64(self): """process length six patterns and extract length four roots""" if (self.stm[0] and self.stm[4]) == '\u0627': # افعلال self.stm = self.stm[1:4] + self.stm[5] return self.stm elif (self.stm.startswith('\u0645\u062a')): # متفعلل self.stm = self.stm[2:] return self.stm def end_w6(self): """ending step (word of length six)""" if len(self.stm) == 3: return self.stm elif len(self.stm) == 5: self.pro_w53() self.end_w5() return self.stm elif len (self.stm) == 6: self.pro_w64() return self.stm def suf1(self): """normalize short sufix""" for sf1 in self.s1: if self.stm.endswith(sf1): self.stm = self.stm[:-1] return self.stm def pre1(self): """normalize short prefix""" for sp1 in self.p1: if self.stm.startswith(sp1): self.stm = self.stm[1:] return self.stm
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 653, 292, 4889, 8466, 15650, 6065, 26, 710, 2281, 6129, 437, 24176, 428, 563, 2626, 199, 3, 199, 3, 1898, 334, 35, 9, 12521, 13, 7409, 24719, 15263, 2165, 69, 74, 319, 199, 3, 23823, 26, 1804, 65, 806, 77, 8053, 72, 3042, 12, 820, 290, 4674, 13096, 75, 5180, 89, 12, 436, 1603, 3609, 17885, 1849, 676, 1533, 334, 9397, 9, 199, 3, 6529, 26, 869, 736, 455, 4580, 24364, 65, 4446, 665, 526, 21660, 63, 72, 278, 32, 27231, 14, 957, 30, 199, 3, 2851, 26, 665, 1014, 921, 1544, 14, 7530, 2663, 14, 1308, 3133, 199, 3, 2104, 4190, 2556, 12, 1937, 5113, 14, 17715, 199, 199, 624, 199, 1311, 6129, 437, 24176, 428, 563, 2626, 199, 199, 1918, 5563, 367, 642, 17408, 2626, 365, 11736, 315, 26, 199, 199, 1931, 72, 3042, 12, 1804, 2020, 13096, 75, 567, 89, 12, 820, 2020, 436, 1849, 676, 1533, 12, 1603, 14, 11811, 14, 437, 24176, 428, 563, 14566, 1928, 282, 1738, 199, 9086, 14, 17064, 27491, 26993, 1010, 25585, 14, 15904, 402, 5612, 86, 10641, 12, 491, 305, 199, 54, 5902, 305, 12, 8217, 14, 199, 199, 1918, 17064, 27491, 26993, 1010, 25585, 21045, 83, 334, 1311, 6129, 9, 437, 24176, 17408, 2626, 25616, 5002, 199, 3179, 543, 314, 1804, 526, 3387, 17408, 2626, 14, 9738, 12, 314, 2446, 8865, 365, 626, 2281, 6129, 199, 18446, 2626, 1630, 440, 675, 1738, 2600, 14, 6121, 12, 340, 282, 1738, 365, 440, 1911, 12, 2281, 6129, 199, 18446, 2626, 2138, 9657, 1824, 12, 7830, 2419, 8152, 314, 3379, 199, 324, 5540, 4349, 14, 199, 199, 8824, 11311, 1470, 4898, 6326, 370, 19053, 314, 5563, 26, 199, 199, 17, 13, 12934, 5212, 3631, 5932, 14, 199, 199, 18, 13, 12934, 314, 3851, 334, 14276, 18570, 11321, 118, 15441, 8403, 9, 370, 2281, 6129, 3851, 663, 14, 199, 199, 19, 13, 710, 3650, 499, 315, 314, 3379, 5563, 1990, 3293, 9147, 1006, 24868, 8076, 14, 961, 3650, 365, 199, 6409, 12910, 2952, 652, 10035, 3274, 314, 4349, 16353, 528, 1907, 1417, 436, 4493, 314, 3379, 199, 1231, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 295, 421, 199, 533, 2281, 50, 1311, 563, 2626, 8, 785, 304, 272, 1449, 272, 2281, 6129, 437, 24176, 17408, 2626, 4079, 641, 5563, 26, 437, 24176, 428, 563, 14566, 1928, 282, 1738, 2600, 14, 272, 17064, 27491, 26993, 1010, 25585, 14, 15904, 402, 5612, 86, 10641, 12, 491, 305, 812, 5902, 305, 12, 8217, 14, 339, 437, 9284, 12612, 23070, 1172, 2757, 6326, 370, 2281, 6129, 5678, 5563, 14, 272, 1666, 314, 1350, 1233, 402, 642, 859, 367, 1655, 2556, 14, 339, 365, 322, 14, 18446, 8, 1418, 9, 2529, 437, 24176, 1738, 367, 314, 1627, 1526, 14, 339, 710, 2281, 6129, 428, 563, 2626, 5074, 626, 1006, 4645, 1172, 6140, 1059, 2943, 14, 272, 982, 1265, 675, 2018, 23240, 641, 437, 24176, 5417, 1265, 1172, 370, 4849, 1318, 1642, 272, 1808, 437, 24176, 283, 713, 1367, 7, 2803, 14, 272, 1449, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 270, 77, 275, 283, 318, 427, 7179, 7, 398, 291, 14, 80, 19, 275, 788, 60, 85, 16, 14637, 60, 85, 1690, 1465, 60, 85, 16, 10893, 297, 1557, 85, 1690, 1651, 60, 85, 1690, 1465, 60, 85, 16, 10893, 297, 673, 1557, 85, 16, 10552, 60, 85, 16, 10893, 60, 85, 16, 10893, 297, 1557, 85, 16, 10552, 60, 85, 1690, 1465, 60, 85, 16, 10893, 418, 259, 327, 2582, 7795, 13158, 267, 291, 14, 80, 18, 275, 788, 60, 85, 1690, 1465, 60, 85, 16, 10893, 297, 1557, 85, 16, 10893, 60, 85, 16, 10893, 418, 259, 327, 2582, 2877, 13158, 267, 291, 14, 80, 17, 275, 788, 60, 85, 16, 10893, 297, 1557, 85, 1690, 1651, 297, 1557, 85, 16, 15233, 297, 1557, 85, 1690, 1153, 297, 1557, 85, 16, 10552, 297, 673, 1557, 85, 17010, 65, 297, 1557, 85, 18789, 65, 297, 1557, 85, 16, 11387, 297, 1557, 85, 1690, 1465, 418, 257, 327, 2582, 1373, 13158, 398, 291, 14, 83, 19, 275, 788, 60, 85, 18789, 65, 60, 85, 16, 13067, 60, 85, 16, 10893, 297, 1557, 85, 16, 8557, 60, 85, 16, 13067, 60, 85, 16, 10893, 297, 490, 1557, 85, 18789, 65, 60, 85, 1690, 1465, 60, 85, 16, 11387, 297, 1557, 85, 18789, 65, 60, 85, 17010, 65, 60, 85, 16, 11387, 297, 490, 1557, 85, 16, 14637, 60, 85, 16, 13067, 60, 85, 16, 10893, 418, 221, 327, 2582, 7795, 19475, 267, 291, 14, 83, 18, 275, 788, 60, 85, 16, 10552, 60, 85, 16, 11387, 297, 1557, 85, 1690, 1465, 60, 85, 18789, 65, 297, 1557, 85, 1690, 1465, 60, 85, 16, 11387, 297, 673, 1557, 85, 17010, 65, 60, 85, 16, 11387, 297, 1557, 85, 18789, 65, 60, 85, 16, 11387, 297, 1557, 85, 16, 14637, 60, 85, 16, 13067, 297, 673, 1557, 85, 16, 8557, 60, 85, 16, 11387, 297, 1557, 85, 16, 11387, 60, 85, 1690, 1465, 297, 1557, 85, 17010, 65, 60, 85, 1690, 1465, 297, 673, 1557, 85, 16, 8557, 60, 85, 1690, 1465, 297, 1557, 85, 18789, 65, 60, 85, 16, 13067, 297, 1557, 85, 16, 14637, 60, 85, 16, 11387, 297, 673, 1557, 85, 16, 11387, 60, 85, 17010, 65, 297, 1557, 85, 16, 10552, 60, 85, 1690, 1465, 297, 1557, 85, 16, 13067, 60, 85, 1690, 1465, 297, 673, 1557, 85, 16, 8557, 60, 85, 16, 13067, 418, 257, 327, 2582, 2877, 19475, 267, 291, 14, 83, 17, 275, 788, 60, 85, 1690, 1398, 297, 1557, 85, 16, 8557, 297, 1557, 85, 17010, 65, 297, 1557, 85, 16, 14637, 297, 1557, 85, 18789, 65, 297, 673, 1557, 85, 1690, 1465, 297, 1557, 85, 16, 11387, 418, 257, 327, 2582, 1373, 19475, 398, 291, 14, 2700, 20, 275, 469, 16, 26, 788, 60, 85, 16, 13067, 995, 413, 26, 459, 60, 85, 1690, 1465, 995, 490, 499, 26, 788, 60, 85, 1690, 1465, 297, 1557, 85, 16, 10552, 297, 1557, 85, 17010, 33, 995, 650, 26, 459, 60, 85, 1690, 1398, 12074 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 653, 292, 4889, 8466, 15650, 6065, 26, 710, 2281, 6129, 437, 24176, 428, 563, 2626, 199, 3, 199, 3, 1898, 334, 35, 9, 12521, 13, 7409, 24719, 15263, 2165, 69, 74, 319, 199, 3, 23823, 26, 1804, 65, 806, 77, 8053, 72, 3042, 12, 820, 290, 4674, 13096, 75, 5180, 89, 12, 436, 1603, 3609, 17885, 1849, 676, 1533, 334, 9397, 9, 199, 3, 6529, 26, 869, 736, 455, 4580, 24364, 65, 4446, 665, 526, 21660, 63, 72, 278, 32, 27231, 14, 957, 30, 199, 3, 2851, 26, 665, 1014, 921, 1544, 14, 7530, 2663, 14, 1308, 3133, 199, 3, 2104, 4190, 2556, 12, 1937, 5113, 14, 17715, 199, 199, 624, 199, 1311, 6129, 437, 24176, 428, 563, 2626, 199, 199, 1918, 5563, 367, 642, 17408, 2626, 365, 11736, 315, 26, 199, 199, 1931, 72, 3042, 12, 1804, 2020, 13096, 75, 567, 89, 12, 820, 2020, 436, 1849, 676, 1533, 12, 1603, 14, 11811, 14, 437, 24176, 428, 563, 14566, 1928, 282, 1738, 199, 9086, 14, 17064, 27491, 26993, 1010, 25585, 14, 15904, 402, 5612, 86, 10641, 12, 491, 305, 199, 54, 5902, 305, 12, 8217, 14, 199, 199, 1918, 17064, 27491, 26993, 1010, 25585, 21045, 83, 334, 1311, 6129, 9, 437, 24176, 17408, 2626, 25616, 5002, 199, 3179, 543, 314, 1804, 526, 3387, 17408, 2626, 14, 9738, 12, 314, 2446, 8865, 365, 626, 2281, 6129, 199, 18446, 2626, 1630, 440, 675, 1738, 2600, 14, 6121, 12, 340, 282, 1738, 365, 440, 1911, 12, 2281, 6129, 199, 18446, 2626, 2138, 9657, 1824, 12, 7830, 2419, 8152, 314, 3379, 199, 324, 5540, 4349, 14, 199, 199, 8824, 11311, 1470, 4898, 6326, 370, 19053, 314, 5563, 26, 199, 199, 17, 13, 12934, 5212, 3631, 5932, 14, 199, 199, 18, 13, 12934, 314, 3851, 334, 14276, 18570, 11321, 118, 15441, 8403, 9, 370, 2281, 6129, 3851, 663, 14, 199, 199, 19, 13, 710, 3650, 499, 315, 314, 3379, 5563, 1990, 3293, 9147, 1006, 24868, 8076, 14, 961, 3650, 365, 199, 6409, 12910, 2952, 652, 10035, 3274, 314, 4349, 16353, 528, 1907, 1417, 436, 4493, 314, 3379, 199, 1231, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 295, 421, 199, 533, 2281, 50, 1311, 563, 2626, 8, 785, 304, 272, 1449, 272, 2281, 6129, 437, 24176, 17408, 2626, 4079, 641, 5563, 26, 437, 24176, 428, 563, 14566, 1928, 282, 1738, 2600, 14, 272, 17064, 27491, 26993, 1010, 25585, 14, 15904, 402, 5612, 86, 10641, 12, 491, 305, 812, 5902, 305, 12, 8217, 14, 339, 437, 9284, 12612, 23070, 1172, 2757, 6326, 370, 2281, 6129, 5678, 5563, 14, 272, 1666, 314, 1350, 1233, 402, 642, 859, 367, 1655, 2556, 14, 339, 365, 322, 14, 18446, 8, 1418, 9, 2529, 437, 24176, 1738, 367, 314, 1627, 1526, 14, 339, 710, 2281, 6129, 428, 563, 2626, 5074, 626, 1006, 4645, 1172, 6140, 1059, 2943, 14, 272, 982, 1265, 675, 2018, 23240, 641, 437, 24176, 5417, 1265, 1172, 370, 4849, 1318, 1642, 272, 1808, 437, 24176, 283, 713, 1367, 7, 2803, 14, 272, 1449, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 270, 77, 275, 283, 318, 427, 7179, 7, 398, 291, 14, 80, 19, 275, 788, 60, 85, 16, 14637, 60, 85, 1690, 1465, 60, 85, 16, 10893, 297, 1557, 85, 1690, 1651, 60, 85, 1690, 1465, 60, 85, 16, 10893, 297, 673, 1557, 85, 16, 10552, 60, 85, 16, 10893, 60, 85, 16, 10893, 297, 1557, 85, 16, 10552, 60, 85, 1690, 1465, 60, 85, 16, 10893, 418, 259, 327, 2582, 7795, 13158, 267, 291, 14, 80, 18, 275, 788, 60, 85, 1690, 1465, 60, 85, 16, 10893, 297, 1557, 85, 16, 10893, 60, 85, 16, 10893, 418, 259, 327, 2582, 2877, 13158, 267, 291, 14, 80, 17, 275, 788, 60, 85, 16, 10893, 297, 1557, 85, 1690, 1651, 297, 1557, 85, 16, 15233, 297, 1557, 85, 1690, 1153, 297, 1557, 85, 16, 10552, 297, 673, 1557, 85, 17010, 65, 297, 1557, 85, 18789, 65, 297, 1557, 85, 16, 11387, 297, 1557, 85, 1690, 1465, 418, 257, 327, 2582, 1373, 13158, 398, 291, 14, 83, 19, 275, 788, 60, 85, 18789, 65, 60, 85, 16, 13067, 60, 85, 16, 10893, 297, 1557, 85, 16, 8557, 60, 85, 16, 13067, 60, 85, 16, 10893, 297, 490, 1557, 85, 18789, 65, 60, 85, 1690, 1465, 60, 85, 16, 11387, 297, 1557, 85, 18789, 65, 60, 85, 17010, 65, 60, 85, 16, 11387, 297, 490, 1557, 85, 16, 14637, 60, 85, 16, 13067, 60, 85, 16, 10893, 418, 221, 327, 2582, 7795, 19475, 267, 291, 14, 83, 18, 275, 788, 60, 85, 16, 10552, 60, 85, 16, 11387, 297, 1557, 85, 1690, 1465, 60, 85, 18789, 65, 297, 1557, 85, 1690, 1465, 60, 85, 16, 11387, 297, 673, 1557, 85, 17010, 65, 60, 85, 16, 11387, 297, 1557, 85, 18789, 65, 60, 85, 16, 11387, 297, 1557, 85, 16, 14637, 60, 85, 16, 13067, 297, 673, 1557, 85, 16, 8557, 60, 85, 16, 11387, 297, 1557, 85, 16, 11387, 60, 85, 1690, 1465, 297, 1557, 85, 17010, 65, 60, 85, 1690, 1465, 297, 673, 1557, 85, 16, 8557, 60, 85, 1690, 1465, 297, 1557, 85, 18789, 65, 60, 85, 16, 13067, 297, 1557, 85, 16, 14637, 60, 85, 16, 11387, 297, 673, 1557, 85, 16, 11387, 60, 85, 17010, 65, 297, 1557, 85, 16, 10552, 60, 85, 1690, 1465, 297, 1557, 85, 16, 13067, 60, 85, 1690, 1465, 297, 673, 1557, 85, 16, 8557, 60, 85, 16, 13067, 418, 257, 327, 2582, 2877, 19475, 267, 291, 14, 83, 17, 275, 788, 60, 85, 1690, 1398, 297, 1557, 85, 16, 8557, 297, 1557, 85, 17010, 65, 297, 1557, 85, 16, 14637, 297, 1557, 85, 18789, 65, 297, 673, 1557, 85, 1690, 1465, 297, 1557, 85, 16, 11387, 418, 257, 327, 2582, 1373, 19475, 398, 291, 14, 2700, 20, 275, 469, 16, 26, 788, 60, 85, 16, 13067, 995, 413, 26, 459, 60, 85, 1690, 1465, 995, 490, 499, 26, 788, 60, 85, 1690, 1465, 297, 1557, 85, 16, 10552, 297, 1557, 85, 17010, 33, 995, 650, 26, 459, 60, 85, 1690, 1398, 12074, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
billyvg/piebot
piebot/modules/isup.py
1
1085
"""Checks isup.me to see if a website is up @package ppbot @syntax isup <word> """ import requests import re from piebot.modules import * class Isup(Module): def __init__(self, *args, **kwargs): """Constructor""" Module.__init__(self, kwargs=kwargs) self.url = "http://www.isup.me/%s" def _register_events(self): """Register module commands.""" self.add_command('isup') def isup(self, event): """Action to react/respond to user calls.""" if self.num_args == 1: domain = event['args'][0] try: r = requests.get(self.url % (domain)) if re.search('looks down from here', r.text): message = "%s is DOWN" % domain elif re.search('is up.', r.text): message = "%s is UP" % domain self.reply(message) except: import traceback traceback.print_exc() self.reply('Problem looking up "%s"' % domain) else: pass
mit
[ 624, 11834, 365, 384, 14, 278, 370, 1937, 340, 282, 10691, 365, 1536, 199, 32, 2491, 11618, 3018, 199, 199, 32, 7093, 365, 384, 665, 1027, 30, 199, 199, 624, 199, 646, 4145, 199, 646, 295, 199, 199, 504, 7708, 3018, 14, 3112, 492, 627, 199, 199, 533, 473, 1961, 8, 2377, 304, 2378, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 11447, 624, 267, 5673, 855, 826, 721, 277, 12, 2074, 29, 958, 9, 267, 291, 14, 633, 275, 298, 1014, 921, 1544, 14, 374, 384, 14, 278, 3149, 83, 2, 339, 347, 485, 2683, 63, 4368, 8, 277, 304, 267, 408, 7099, 859, 3718, 1041, 398, 291, 14, 525, 63, 1531, 360, 374, 384, 358, 339, 347, 365, 384, 8, 277, 12, 1566, 304, 267, 408, 3310, 370, 295, 2442, 15, 22720, 370, 922, 4882, 1041, 398, 340, 291, 14, 1507, 63, 589, 508, 413, 26, 288, 2881, 275, 1566, 459, 589, 3488, 16, 61, 953, 862, 26, 355, 519, 275, 4145, 14, 362, 8, 277, 14, 633, 450, 334, 2261, 430, 355, 340, 295, 14, 1733, 360, 11660, 83, 3224, 687, 2348, 297, 519, 14, 505, 304, 490, 1245, 275, 2071, 83, 365, 10163, 2, 450, 2881, 355, 916, 295, 14, 1733, 360, 374, 1536, 3130, 519, 14, 505, 304, 490, 1245, 275, 2071, 83, 365, 7215, 2, 450, 2881, 2234, 291, 14, 8102, 8, 1188, 9, 288, 871, 26, 355, 492, 5190, 355, 5190, 14, 1361, 63, 2804, 342, 355, 291, 14, 8102, 360, 16467, 10023, 1536, 2071, 83, 4507, 450, 2881, 9, 267, 587, 26, 288, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 11834, 365, 384, 14, 278, 370, 1937, 340, 282, 10691, 365, 1536, 199, 32, 2491, 11618, 3018, 199, 199, 32, 7093, 365, 384, 665, 1027, 30, 199, 199, 624, 199, 646, 4145, 199, 646, 295, 199, 199, 504, 7708, 3018, 14, 3112, 492, 627, 199, 199, 533, 473, 1961, 8, 2377, 304, 2378, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 11447, 624, 267, 5673, 855, 826, 721, 277, 12, 2074, 29, 958, 9, 267, 291, 14, 633, 275, 298, 1014, 921, 1544, 14, 374, 384, 14, 278, 3149, 83, 2, 339, 347, 485, 2683, 63, 4368, 8, 277, 304, 267, 408, 7099, 859, 3718, 1041, 398, 291, 14, 525, 63, 1531, 360, 374, 384, 358, 339, 347, 365, 384, 8, 277, 12, 1566, 304, 267, 408, 3310, 370, 295, 2442, 15, 22720, 370, 922, 4882, 1041, 398, 340, 291, 14, 1507, 63, 589, 508, 413, 26, 288, 2881, 275, 1566, 459, 589, 3488, 16, 61, 953, 862, 26, 355, 519, 275, 4145, 14, 362, 8, 277, 14, 633, 450, 334, 2261, 430, 355, 340, 295, 14, 1733, 360, 11660, 83, 3224, 687, 2348, 297, 519, 14, 505, 304, 490, 1245, 275, 2071, 83, 365, 10163, 2, 450, 2881, 355, 916, 295, 14, 1733, 360, 374, 1536, 3130, 519, 14, 505, 304, 490, 1245, 275, 2071, 83, 365, 7215, 2, 450, 2881, 2234, 291, 14, 8102, 8, 1188, 9, 288, 871, 26, 355, 492, 5190, 355, 5190, 14, 1361, 63, 2804, 342, 355, 291, 14, 8102, 360, 16467, 10023, 1536, 2071, 83, 4507, 450, 2881, 9, 267, 587, 26, 288, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
LLNL/spack
var/spack/repos/builtin/packages/simplemoc/package.py
5
1492
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack import * class Simplemoc(MakefilePackage): """The purpose of this mini-app is to demonstrate the performance characterterics and viability of the Method of Characteristics (MOC) for 3D neutron transport calculations in the context of full scale light water reactor simulation.""" homepage = "https://github.com/ANL-CESAR/SimpleMOC/" url = "https://github.com/ANL-CESAR/SimpleMOC/archive/v4.tar.gz" version('4', sha256='a39906014fdb234c43bf26e1919bdc8a13097788812e0b353a492b8e568816a6') tags = ['proxy-app'] variant('mpi', default=True, description='Build with MPI support') depends_on('mpi', when='+mpi') build_directory = 'src' @property def build_targets(self): targets = [] cflags = '-std=gnu99' ldflags = '-lm' if self.compiler.name == 'gcc' or self.compiler.name == 'intel': cflags += ' ' + self.compiler.openmp_flag if '+mpi' in self.spec: targets.append('CC={0}'.format(self.spec['mpi'].mpicc)) targets.append('CFLAGS={0}'.format(cflags)) targets.append('LDFLAGS={0}'.format(ldflags)) return targets def install(self, spec, prefix): mkdir(prefix.bin) install('src/SimpleMOC', prefix.bin)
lgpl-2.1
[ 3, 1898, 6171, 13, 13934, 7964, 29590, 491, 4380, 6878, 20548, 13863, 12, 20376, 436, 1163, 199, 3, 428, 1389, 7290, 23493, 14, 1666, 314, 2746, 13, 1896, 5877, 570, 367, 2436, 14, 199, 3, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 334, 28993, 13, 18, 14, 16, 1549, 10697, 9, 421, 199, 504, 308, 1389, 492, 627, 421, 199, 533, 5870, 573, 67, 8, 19878, 8599, 304, 272, 408, 1918, 12016, 402, 642, 20536, 13, 571, 365, 370, 23789, 18161, 314, 10238, 267, 4528, 6236, 1259, 436, 1321, 3616, 402, 314, 9075, 402, 6659, 29867, 334, 2679, 35, 9, 267, 367, 650, 36, 8224, 7773, 24258, 315, 314, 1067, 402, 2615, 4666, 267, 10540, 22834, 9655, 17625, 1041, 339, 26586, 275, 298, 2859, 921, 5031, 14, 957, 15, 879, 44, 13, 16734, 689, 15, 3184, 2679, 35, 6687, 272, 1166, 275, 298, 2859, 921, 5031, 14, 957, 15, 879, 44, 13, 16734, 689, 15, 3184, 2679, 35, 15, 6404, 15, 86, 20, 14, 5369, 14, 6838, 2, 339, 1015, 360, 20, 297, 7793, 3912, 534, 65, 10936, 1690, 10752, 29636, 5533, 67, 2824, 4361, 1479, 69, 1167, 1167, 3691, 67, 24, 65, 969, 1643, 1138, 13997, 713, 69, 16, 66, 15355, 65, 25722, 66, 24, 69, 1367, 1299, 975, 65, 22, 358, 339, 3762, 275, 788, 3280, 13, 571, 418, 339, 9854, 360, 13213, 297, 849, 29, 549, 12, 1369, 534, 3425, 543, 26024, 2291, 358, 339, 8350, 63, 265, 360, 13213, 297, 1380, 22078, 13213, 358, 339, 1900, 63, 3619, 275, 283, 2164, 7, 339, 768, 1829, 272, 347, 1900, 63, 4684, 8, 277, 304, 398, 4545, 275, 942, 398, 13426, 275, 2475, 1516, 29, 3689, 1020, 7, 267, 19585, 275, 2475, 14344, 7, 398, 340, 291, 14, 5772, 14, 354, 508, 283, 13112, 7, 503, 291, 14, 5772, 14, 354, 508, 283, 22264, 356, 288, 13426, 847, 283, 283, 435, 291, 14, 5772, 14, 1490, 311, 63, 4173, 267, 340, 6681, 13213, 7, 315, 291, 14, 1650, 26, 288, 4545, 14, 740, 360, 2571, 3126, 16, 5285, 908, 8, 277, 14, 1650, 459, 13213, 2278, 311, 530, 67, 430, 398, 4545, 14, 740, 360, 14804, 3126, 16, 5285, 908, 8, 14002, 430, 267, 4545, 14, 740, 360, 22328, 3126, 16, 5285, 908, 8, 25601, 430, 398, 372, 4545, 339, 347, 3907, 8, 277, 12, 3158, 12, 2403, 304, 267, 20366, 8, 1861, 14, 1393, 9, 267, 3907, 360, 2164, 15, 3184, 2679, 35, 297, 2403, 14, 1393, 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 ]
[ 1898, 6171, 13, 13934, 7964, 29590, 491, 4380, 6878, 20548, 13863, 12, 20376, 436, 1163, 199, 3, 428, 1389, 7290, 23493, 14, 1666, 314, 2746, 13, 1896, 5877, 570, 367, 2436, 14, 199, 3, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 334, 28993, 13, 18, 14, 16, 1549, 10697, 9, 421, 199, 504, 308, 1389, 492, 627, 421, 199, 533, 5870, 573, 67, 8, 19878, 8599, 304, 272, 408, 1918, 12016, 402, 642, 20536, 13, 571, 365, 370, 23789, 18161, 314, 10238, 267, 4528, 6236, 1259, 436, 1321, 3616, 402, 314, 9075, 402, 6659, 29867, 334, 2679, 35, 9, 267, 367, 650, 36, 8224, 7773, 24258, 315, 314, 1067, 402, 2615, 4666, 267, 10540, 22834, 9655, 17625, 1041, 339, 26586, 275, 298, 2859, 921, 5031, 14, 957, 15, 879, 44, 13, 16734, 689, 15, 3184, 2679, 35, 6687, 272, 1166, 275, 298, 2859, 921, 5031, 14, 957, 15, 879, 44, 13, 16734, 689, 15, 3184, 2679, 35, 15, 6404, 15, 86, 20, 14, 5369, 14, 6838, 2, 339, 1015, 360, 20, 297, 7793, 3912, 534, 65, 10936, 1690, 10752, 29636, 5533, 67, 2824, 4361, 1479, 69, 1167, 1167, 3691, 67, 24, 65, 969, 1643, 1138, 13997, 713, 69, 16, 66, 15355, 65, 25722, 66, 24, 69, 1367, 1299, 975, 65, 22, 358, 339, 3762, 275, 788, 3280, 13, 571, 418, 339, 9854, 360, 13213, 297, 849, 29, 549, 12, 1369, 534, 3425, 543, 26024, 2291, 358, 339, 8350, 63, 265, 360, 13213, 297, 1380, 22078, 13213, 358, 339, 1900, 63, 3619, 275, 283, 2164, 7, 339, 768, 1829, 272, 347, 1900, 63, 4684, 8, 277, 304, 398, 4545, 275, 942, 398, 13426, 275, 2475, 1516, 29, 3689, 1020, 7, 267, 19585, 275, 2475, 14344, 7, 398, 340, 291, 14, 5772, 14, 354, 508, 283, 13112, 7, 503, 291, 14, 5772, 14, 354, 508, 283, 22264, 356, 288, 13426, 847, 283, 283, 435, 291, 14, 5772, 14, 1490, 311, 63, 4173, 267, 340, 6681, 13213, 7, 315, 291, 14, 1650, 26, 288, 4545, 14, 740, 360, 2571, 3126, 16, 5285, 908, 8, 277, 14, 1650, 459, 13213, 2278, 311, 530, 67, 430, 398, 4545, 14, 740, 360, 14804, 3126, 16, 5285, 908, 8, 14002, 430, 267, 4545, 14, 740, 360, 22328, 3126, 16, 5285, 908, 8, 25601, 430, 398, 372, 4545, 339, 347, 3907, 8, 277, 12, 3158, 12, 2403, 304, 267, 20366, 8, 1861, 14, 1393, 9, 267, 3907, 360, 2164, 15, 3184, 2679, 35, 297, 2403, 14, 1393, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
MoKee/android_kernel_xiaomi_cancro
tools/perf/scripts/python/check-perf-trace.py
11214
2503
# perf script event handlers, generated by perf script -g python # (c) 2010, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # This script tests basic functionality such as flag and symbol # strings, common_xxx() calls back into perf, begin, end, unhandled # events, etc. Basically, if this script runs successfully and # displays expected results, Python scripting support should be ok. import os import sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from Core import * from perf_trace_context import * unhandled = autodict() def trace_begin(): print "trace_begin" pass def trace_end(): print_unhandled() def irq__softirq_entry(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, vec): print_header(event_name, common_cpu, common_secs, common_nsecs, common_pid, common_comm) print_uncommon(context) print "vec=%s\n" % \ (symbol_str("irq__softirq_entry", "vec", vec)), def kmem__kmalloc(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, call_site, ptr, bytes_req, bytes_alloc, gfp_flags): print_header(event_name, common_cpu, common_secs, common_nsecs, common_pid, common_comm) print_uncommon(context) print "call_site=%u, ptr=%u, bytes_req=%u, " \ "bytes_alloc=%u, gfp_flags=%s\n" % \ (call_site, ptr, bytes_req, bytes_alloc, flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)), def trace_unhandled(event_name, context, event_fields_dict): try: unhandled[event_name] += 1 except TypeError: unhandled[event_name] = 1 def print_header(event_name, cpu, secs, nsecs, pid, comm): print "%-20s %5u %05u.%09u %8u %-20s " % \ (event_name, cpu, secs, nsecs, pid, comm), # print trace fields not included in handler args def print_uncommon(context): print "common_preempt_count=%d, common_flags=%s, common_lock_depth=%d, " \ % (common_pc(context), trace_flag_str(common_flags(context)), \ common_lock_depth(context)) def print_unhandled(): keys = unhandled.keys() if not keys: return print "\nunhandled events:\n\n", print "%-40s %10s\n" % ("event", "count"), print "%-40s %10s\n" % ("----------------------------------------", \ "-----------"), for event_name in keys: print "%-40s %10d\n" % (event_name, unhandled[event_name])
gpl-2.0
[ 3, 8582, 2884, 1566, 8297, 12, 4046, 701, 8582, 2884, 446, 71, 2366, 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, 961, 2884, 2295, 5678, 9330, 4066, 465, 3305, 436, 5272, 199, 3, 3326, 12, 2863, 63, 10013, 342, 4882, 1771, 1901, 8582, 12, 5386, 12, 1284, 12, 23090, 199, 3, 4474, 12, 5423, 14, 221, 10082, 1183, 12, 340, 642, 2884, 7858, 8792, 436, 199, 3, 17561, 1420, 2058, 12, 2018, 2884, 316, 2291, 1077, 506, 4112, 14, 199, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 11672, 492, 627, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 199, 23648, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 3446, 63, 5037, 2, 199, 198, 1529, 199, 199, 318, 3307, 63, 500, 837, 267, 870, 63, 23648, 342, 199, 199, 318, 10476, 363, 18316, 63, 2373, 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, 6046, 304, 507, 198, 1361, 63, 1291, 8, 1430, 63, 354, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 198, 2330, 63, 3150, 12, 2863, 63, 1404, 9, 2234, 870, 63, 324, 2330, 8, 1100, 9, 2742, 198, 1361, 298, 6046, 2458, 83, 60, 78, 2, 450, 971, 507, 198, 8, 5155, 63, 495, 480, 7277, 363, 18316, 63, 2373, 401, 298, 6046, 401, 10782, 1826, 199, 199, 318, 1022, 5286, 363, 75, 23981, 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, 1250, 63, 2124, 12, 12448, 12, 2783, 63, 2103, 12, 2783, 63, 9373, 12, 199, 198, 71, 3997, 63, 2469, 304, 507, 198, 1361, 63, 1291, 8, 1430, 63, 354, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 198, 2330, 63, 3150, 12, 2863, 63, 1404, 9, 2234, 870, 63, 324, 2330, 8, 1100, 9, 2742, 198, 1361, 298, 1250, 63, 2124, 2458, 85, 12, 12448, 2458, 85, 12, 2783, 63, 2103, 2458, 85, 12, 298, 971, 507, 198, 2, 2394, 63, 9373, 2458, 85, 12, 486, 3997, 63, 2469, 2458, 83, 60, 78, 2, 450, 971, 507, 198, 8, 1250, 63, 2124, 12, 12448, 12, 2783, 63, 2103, 12, 2783, 63, 9373, 12, 2742, 198, 4173, 63, 495, 480, 75, 5286, 363, 75, 23981, 401, 298, 71, 3997, 63, 2469, 401, 486, 3997, 63, 2469, 1826, 199, 199, 318, 3307, 63, 23648, 8, 1430, 63, 354, 12, 1067, 12, 1566, 63, 955, 63, 807, 304, 272, 862, 26, 267, 23090, 59, 1430, 63, 354, 61, 847, 413, 272, 871, 3146, 26, 267, 23090, 59, 1430, 63, 354, 61, 275, 413, 199, 199, 318, 870, 63, 1291, 8, 1430, 63, 354, 12, 5033, 12, 20091, 12, 13781, 12, 4422, 12, 1923, 304, 199, 198, 1361, 18301, 1165, 83, 450, 21, 85, 450, 1717, 85, 4111, 1643, 85, 450, 24, 85, 19752, 1165, 83, 298, 450, 971, 199, 198, 8, 1430, 63, 354, 12, 5033, 12, 20091, 12, 13781, 12, 4422, 12, 1923, 395, 199, 199, 3, 870, 3307, 1504, 440, 5120, 315, 3016, 1249, 199, 318, 870, 63, 324, 2330, 8, 1100, 304, 272, 870, 298, 2330, 63, 657, 19046, 63, 835, 2458, 68, 12, 2863, 63, 2469, 2458, 83, 12, 2863, 63, 831, 63, 4631, 2458, 68, 12, 298, 971, 267, 450, 334, 2330, 63, 2352, 8, 1100, 395, 3307, 63, 4173, 63, 495, 8, 2330, 63, 2469, 8, 1100, 1826, 971, 2049, 2863, 63, 831, 63, 4631, 8, 1100, 430, 199, 199, 318, 870, 63, 23648, 837, 272, 2883, 275, 23090, 14, 1612, 342, 272, 340, 440, 2883, 26, 267, 372, 339, 870, 1867, 78, 23648, 4474, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 13715, 1288, 339, 367, 1566, 63, 354, 315, 2883, 26, 199, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 1430, 63, 354, 12, 23090, 59, 1430, 63, 354, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 8582, 2884, 1566, 8297, 12, 4046, 701, 8582, 2884, 446, 71, 2366, 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, 961, 2884, 2295, 5678, 9330, 4066, 465, 3305, 436, 5272, 199, 3, 3326, 12, 2863, 63, 10013, 342, 4882, 1771, 1901, 8582, 12, 5386, 12, 1284, 12, 23090, 199, 3, 4474, 12, 5423, 14, 221, 10082, 1183, 12, 340, 642, 2884, 7858, 8792, 436, 199, 3, 17561, 1420, 2058, 12, 2018, 2884, 316, 2291, 1077, 506, 4112, 14, 199, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 11672, 492, 627, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 199, 23648, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 3446, 63, 5037, 2, 199, 198, 1529, 199, 199, 318, 3307, 63, 500, 837, 267, 870, 63, 23648, 342, 199, 199, 318, 10476, 363, 18316, 63, 2373, 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, 6046, 304, 507, 198, 1361, 63, 1291, 8, 1430, 63, 354, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 198, 2330, 63, 3150, 12, 2863, 63, 1404, 9, 2234, 870, 63, 324, 2330, 8, 1100, 9, 2742, 198, 1361, 298, 6046, 2458, 83, 60, 78, 2, 450, 971, 507, 198, 8, 5155, 63, 495, 480, 7277, 363, 18316, 63, 2373, 401, 298, 6046, 401, 10782, 1826, 199, 199, 318, 1022, 5286, 363, 75, 23981, 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, 1250, 63, 2124, 12, 12448, 12, 2783, 63, 2103, 12, 2783, 63, 9373, 12, 199, 198, 71, 3997, 63, 2469, 304, 507, 198, 1361, 63, 1291, 8, 1430, 63, 354, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 198, 2330, 63, 3150, 12, 2863, 63, 1404, 9, 2234, 870, 63, 324, 2330, 8, 1100, 9, 2742, 198, 1361, 298, 1250, 63, 2124, 2458, 85, 12, 12448, 2458, 85, 12, 2783, 63, 2103, 2458, 85, 12, 298, 971, 507, 198, 2, 2394, 63, 9373, 2458, 85, 12, 486, 3997, 63, 2469, 2458, 83, 60, 78, 2, 450, 971, 507, 198, 8, 1250, 63, 2124, 12, 12448, 12, 2783, 63, 2103, 12, 2783, 63, 9373, 12, 2742, 198, 4173, 63, 495, 480, 75, 5286, 363, 75, 23981, 401, 298, 71, 3997, 63, 2469, 401, 486, 3997, 63, 2469, 1826, 199, 199, 318, 3307, 63, 23648, 8, 1430, 63, 354, 12, 1067, 12, 1566, 63, 955, 63, 807, 304, 272, 862, 26, 267, 23090, 59, 1430, 63, 354, 61, 847, 413, 272, 871, 3146, 26, 267, 23090, 59, 1430, 63, 354, 61, 275, 413, 199, 199, 318, 870, 63, 1291, 8, 1430, 63, 354, 12, 5033, 12, 20091, 12, 13781, 12, 4422, 12, 1923, 304, 199, 198, 1361, 18301, 1165, 83, 450, 21, 85, 450, 1717, 85, 4111, 1643, 85, 450, 24, 85, 19752, 1165, 83, 298, 450, 971, 199, 198, 8, 1430, 63, 354, 12, 5033, 12, 20091, 12, 13781, 12, 4422, 12, 1923, 395, 199, 199, 3, 870, 3307, 1504, 440, 5120, 315, 3016, 1249, 199, 318, 870, 63, 324, 2330, 8, 1100, 304, 272, 870, 298, 2330, 63, 657, 19046, 63, 835, 2458, 68, 12, 2863, 63, 2469, 2458, 83, 12, 2863, 63, 831, 63, 4631, 2458, 68, 12, 298, 971, 267, 450, 334, 2330, 63, 2352, 8, 1100, 395, 3307, 63, 4173, 63, 495, 8, 2330, 63, 2469, 8, 1100, 1826, 971, 2049, 2863, 63, 831, 63, 4631, 8, 1100, 430, 199, 199, 318, 870, 63, 23648, 837, 272, 2883, 275, 23090, 14, 1612, 342, 272, 340, 440, 2883, 26, 267, 372, 339, 870, 1867, 78, 23648, 4474, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 13715, 1288, 339, 367, 1566, 63, 354, 315, 2883, 26, 199, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 1430, 63, 354, 12, 23090, 59, 1430, 63, 354, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
vianuevm/Webparser
ENV/Lib/site-packages/pip/_vendor/html5lib/treebuilders/__init__.py
1730
3405
"""A collection of modules for building different kinds of tree from HTML documents. To create a treebuilder for a new type of tree, you need to do implement several things: 1) A set of classes for various types of elements: Document, Doctype, Comment, Element. These must implement the interface of _base.treebuilders.Node (although comment nodes have a different signature for their constructor, see treebuilders.etree.Comment) Textual content may also be implemented as another node type, or not, as your tree implementation requires. 2) A treebuilder object (called TreeBuilder by convention) that inherits from treebuilders._base.TreeBuilder. This has 4 required attributes: documentClass - the class to use for the bottommost node of a document elementClass - the class to use for HTML Elements commentClass - the class to use for comments doctypeClass - the class to use for doctypes It also has one required method: getDocument - Returns the root node of the complete document tree 3) If you wish to run the unit tests, you must also create a testSerializer method on your treebuilder which accepts a node and returns a string containing Node and its children serialized according to the format used in the unittests """ from __future__ import absolute_import, division, unicode_literals from ..utils import default_etree treeBuilderCache = {} def getTreeBuilder(treeType, implementation=None, **kwargs): """Get a TreeBuilder class for various types of tree with built-in support treeType - the name of the tree type required (case-insensitive). Supported values are: "dom" - A generic builder for DOM implementations, defaulting to a xml.dom.minidom based implementation. "etree" - A generic builder for tree implementations exposing an ElementTree-like interface, defaulting to xml.etree.cElementTree if available and xml.etree.ElementTree if not. "lxml" - A etree-based builder for lxml.etree, handling limitations of lxml's implementation. implementation - (Currently applies to the "etree" and "dom" tree types). A module implementing the tree type e.g. xml.etree.ElementTree or xml.etree.cElementTree.""" treeType = treeType.lower() if treeType not in treeBuilderCache: if treeType == "dom": from . import dom # Come up with a sane default (pref. from the stdlib) if implementation is None: from xml.dom import minidom implementation = minidom # NEVER cache here, caching is done in the dom submodule return dom.getDomModule(implementation, **kwargs).TreeBuilder elif treeType == "lxml": from . import etree_lxml treeBuilderCache[treeType] = etree_lxml.TreeBuilder elif treeType == "etree": from . import etree if implementation is None: implementation = default_etree # NEVER cache here, caching is done in the etree submodule return etree.getETreeModule(implementation, **kwargs).TreeBuilder else: raise ValueError("""Unrecognised treebuilder "%s" """ % treeType) return treeBuilderCache.get(treeType)
gpl-2.0
[ 624, 33, 3245, 402, 4621, 367, 10015, 3365, 24241, 402, 3123, 687, 199, 4943, 8247, 14, 199, 199, 1378, 1218, 282, 3123, 5649, 367, 282, 892, 730, 402, 3123, 12, 1265, 1929, 370, 886, 199, 21463, 9978, 7645, 26, 199, 199, 17, 9, 437, 663, 402, 3992, 367, 7750, 2943, 402, 4008, 26, 7543, 12, 4226, 3667, 12, 199, 7488, 12, 6566, 14, 5723, 1471, 5669, 314, 3217, 402, 199, 63, 1095, 14, 2350, 20968, 14, 1716, 334, 6130, 4937, 3721, 3380, 1172, 282, 3365, 199, 5233, 367, 3932, 3787, 12, 1937, 3123, 20968, 14, 9464, 14, 7488, 9, 199, 1872, 1061, 1564, 1443, 2597, 506, 6366, 465, 4573, 1031, 730, 12, 503, 440, 12, 465, 199, 12695, 3123, 4514, 5074, 14, 199, 199, 18, 9, 437, 3123, 5649, 909, 334, 3527, 12178, 6437, 701, 16129, 9, 626, 199, 20882, 687, 3123, 20968, 423, 1095, 14, 20437, 14, 961, 965, 841, 1415, 3004, 26, 199, 3554, 2543, 446, 314, 1021, 370, 675, 367, 314, 9048, 2786, 1031, 402, 282, 2213, 199, 2108, 2543, 446, 314, 1021, 370, 675, 367, 4163, 6566, 83, 199, 3349, 2543, 446, 314, 1021, 370, 675, 367, 6786, 199, 6356, 2543, 446, 314, 1021, 370, 675, 367, 886, 9798, 199, 7940, 2597, 965, 1373, 1415, 1083, 26, 199, 362, 5564, 446, 1803, 314, 1738, 1031, 402, 314, 4890, 2213, 3123, 199, 199, 19, 9, 982, 1265, 13809, 370, 1255, 314, 4137, 2295, 12, 1265, 1471, 2597, 1218, 282, 199, 396, 7299, 1083, 641, 2195, 3123, 5649, 1314, 11479, 282, 1031, 436, 199, 5808, 282, 1059, 3035, 5013, 436, 2399, 4978, 6380, 7182, 199, 475, 314, 1475, 1202, 315, 314, 2882, 83, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 199, 504, 2508, 1208, 492, 849, 63, 9464, 199, 199, 2350, 6437, 4437, 275, 1052, 421, 199, 318, 664, 20437, 8, 2350, 804, 12, 4514, 29, 403, 12, 1011, 958, 304, 272, 408, 1002, 282, 12178, 6437, 1021, 367, 7750, 2943, 402, 3123, 543, 6137, 13, 262, 2291, 339, 3123, 804, 446, 314, 536, 402, 314, 3123, 730, 1415, 334, 2546, 13, 15851, 680, 26167, 2049, 1338, 787, 26, 199, 2049, 298, 4556, 2, 446, 437, 7809, 6545, 367, 14316, 12591, 12, 849, 316, 370, 2432, 282, 2748, 14, 4556, 14, 21827, 4079, 4514, 14, 2049, 298, 9464, 2, 446, 437, 7809, 6545, 367, 3123, 12591, 444, 555, 1044, 376, 586, 13139, 13, 2930, 3217, 12, 849, 316, 370, 586, 2748, 14, 9464, 14, 67, 15325, 340, 2808, 436, 586, 2748, 14, 9464, 14, 15325, 340, 440, 14, 2049, 298, 22899, 2, 446, 437, 7559, 13, 6788, 6545, 367, 14490, 14, 9464, 12, 7252, 717, 4204, 402, 14490, 1159, 4514, 14, 339, 4514, 446, 334, 31499, 12966, 370, 314, 298, 9464, 2, 436, 298, 4556, 2, 3123, 2943, 680, 437, 1993, 859, 18234, 314, 3123, 730, 325, 14, 71, 14, 1993, 2748, 14, 9464, 14, 15325, 503, 2748, 14, 9464, 14, 67, 15325, 1041, 339, 3123, 804, 275, 3123, 804, 14, 2325, 342, 272, 340, 3123, 804, 440, 315, 3123, 6437, 4437, 26, 267, 340, 3123, 804, 508, 298, 4556, 582, 288, 687, 1275, 492, 8266, 288, 327, 445, 1377, 1536, 543, 282, 31648, 849, 334, 13829, 14, 687, 314, 26678, 9, 288, 340, 4514, 365, 488, 26, 355, 687, 2748, 14, 4556, 492, 19165, 355, 4514, 275, 19165, 288, 327, 7110, 2111, 2581, 2348, 12, 13627, 365, 4224, 315, 314, 8266, 22988, 288, 372, 8266, 14, 362, 20106, 2377, 8, 12236, 12, 1011, 958, 680, 20437, 267, 916, 3123, 804, 508, 298, 22899, 582, 288, 687, 1275, 492, 7559, 63, 22899, 288, 3123, 6437, 4437, 59, 2350, 804, 61, 275, 7559, 63, 22899, 14, 20437, 267, 916, 3123, 804, 508, 298, 9464, 582, 288, 687, 1275, 492, 7559, 288, 340, 4514, 365, 488, 26, 355, 4514, 275, 849, 63, 9464, 288, 327, 7110, 2111, 2581, 2348, 12, 13627, 365, 4224, 315, 314, 7559, 22988, 288, 372, 7559, 14, 362, 775, 850, 2377, 8, 12236, 12, 1011, 958, 680, 20437, 267, 587, 26, 288, 746, 1722, 4852, 1358, 29324, 9096, 3123, 5649, 2071, 83, 2, 408, 450, 3123, 804, 9, 272, 372, 3123, 6437, 4437, 14, 362, 8, 2350, 804, 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 ]
[ 33, 3245, 402, 4621, 367, 10015, 3365, 24241, 402, 3123, 687, 199, 4943, 8247, 14, 199, 199, 1378, 1218, 282, 3123, 5649, 367, 282, 892, 730, 402, 3123, 12, 1265, 1929, 370, 886, 199, 21463, 9978, 7645, 26, 199, 199, 17, 9, 437, 663, 402, 3992, 367, 7750, 2943, 402, 4008, 26, 7543, 12, 4226, 3667, 12, 199, 7488, 12, 6566, 14, 5723, 1471, 5669, 314, 3217, 402, 199, 63, 1095, 14, 2350, 20968, 14, 1716, 334, 6130, 4937, 3721, 3380, 1172, 282, 3365, 199, 5233, 367, 3932, 3787, 12, 1937, 3123, 20968, 14, 9464, 14, 7488, 9, 199, 1872, 1061, 1564, 1443, 2597, 506, 6366, 465, 4573, 1031, 730, 12, 503, 440, 12, 465, 199, 12695, 3123, 4514, 5074, 14, 199, 199, 18, 9, 437, 3123, 5649, 909, 334, 3527, 12178, 6437, 701, 16129, 9, 626, 199, 20882, 687, 3123, 20968, 423, 1095, 14, 20437, 14, 961, 965, 841, 1415, 3004, 26, 199, 3554, 2543, 446, 314, 1021, 370, 675, 367, 314, 9048, 2786, 1031, 402, 282, 2213, 199, 2108, 2543, 446, 314, 1021, 370, 675, 367, 4163, 6566, 83, 199, 3349, 2543, 446, 314, 1021, 370, 675, 367, 6786, 199, 6356, 2543, 446, 314, 1021, 370, 675, 367, 886, 9798, 199, 7940, 2597, 965, 1373, 1415, 1083, 26, 199, 362, 5564, 446, 1803, 314, 1738, 1031, 402, 314, 4890, 2213, 3123, 199, 199, 19, 9, 982, 1265, 13809, 370, 1255, 314, 4137, 2295, 12, 1265, 1471, 2597, 1218, 282, 199, 396, 7299, 1083, 641, 2195, 3123, 5649, 1314, 11479, 282, 1031, 436, 199, 5808, 282, 1059, 3035, 5013, 436, 2399, 4978, 6380, 7182, 199, 475, 314, 1475, 1202, 315, 314, 2882, 83, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 199, 504, 2508, 1208, 492, 849, 63, 9464, 199, 199, 2350, 6437, 4437, 275, 1052, 421, 199, 318, 664, 20437, 8, 2350, 804, 12, 4514, 29, 403, 12, 1011, 958, 304, 272, 408, 1002, 282, 12178, 6437, 1021, 367, 7750, 2943, 402, 3123, 543, 6137, 13, 262, 2291, 339, 3123, 804, 446, 314, 536, 402, 314, 3123, 730, 1415, 334, 2546, 13, 15851, 680, 26167, 2049, 1338, 787, 26, 199, 2049, 298, 4556, 2, 446, 437, 7809, 6545, 367, 14316, 12591, 12, 849, 316, 370, 2432, 282, 2748, 14, 4556, 14, 21827, 4079, 4514, 14, 2049, 298, 9464, 2, 446, 437, 7809, 6545, 367, 3123, 12591, 444, 555, 1044, 376, 586, 13139, 13, 2930, 3217, 12, 849, 316, 370, 586, 2748, 14, 9464, 14, 67, 15325, 340, 2808, 436, 586, 2748, 14, 9464, 14, 15325, 340, 440, 14, 2049, 298, 22899, 2, 446, 437, 7559, 13, 6788, 6545, 367, 14490, 14, 9464, 12, 7252, 717, 4204, 402, 14490, 1159, 4514, 14, 339, 4514, 446, 334, 31499, 12966, 370, 314, 298, 9464, 2, 436, 298, 4556, 2, 3123, 2943, 680, 437, 1993, 859, 18234, 314, 3123, 730, 325, 14, 71, 14, 1993, 2748, 14, 9464, 14, 15325, 503, 2748, 14, 9464, 14, 67, 15325, 1041, 339, 3123, 804, 275, 3123, 804, 14, 2325, 342, 272, 340, 3123, 804, 440, 315, 3123, 6437, 4437, 26, 267, 340, 3123, 804, 508, 298, 4556, 582, 288, 687, 1275, 492, 8266, 288, 327, 445, 1377, 1536, 543, 282, 31648, 849, 334, 13829, 14, 687, 314, 26678, 9, 288, 340, 4514, 365, 488, 26, 355, 687, 2748, 14, 4556, 492, 19165, 355, 4514, 275, 19165, 288, 327, 7110, 2111, 2581, 2348, 12, 13627, 365, 4224, 315, 314, 8266, 22988, 288, 372, 8266, 14, 362, 20106, 2377, 8, 12236, 12, 1011, 958, 680, 20437, 267, 916, 3123, 804, 508, 298, 22899, 582, 288, 687, 1275, 492, 7559, 63, 22899, 288, 3123, 6437, 4437, 59, 2350, 804, 61, 275, 7559, 63, 22899, 14, 20437, 267, 916, 3123, 804, 508, 298, 9464, 582, 288, 687, 1275, 492, 7559, 288, 340, 4514, 365, 488, 26, 355, 4514, 275, 849, 63, 9464, 288, 327, 7110, 2111, 2581, 2348, 12, 13627, 365, 4224, 315, 314, 7559, 22988, 288, 372, 7559, 14, 362, 775, 850, 2377, 8, 12236, 12, 1011, 958, 680, 20437, 267, 587, 26, 288, 746, 1722, 4852, 1358, 29324, 9096, 3123, 5649, 2071, 83, 2, 408, 450, 3123, 804, 9, 272, 372, 3123, 6437, 4437, 14, 362, 8, 2350, 804, 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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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
cryptapus/electrum-uno
gui/kivy/__init__.py
1
2137
#!/usr/bin/env python # # Electrum - lightweight Bitcoin client # Copyright (C) 2012 thomasv@gitorious # # 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. # # Kivy GUI import sys import os os.environ['KIVY_DATA_DIR'] = os.path.abspath(os.path.dirname(__file__)) + '/data/' try: sys.argv = [''] import kivy except ImportError: # This error ideally shouldn't raised with pre-built packages sys.exit("Error: Could not import kivy. Please install it using the" + \ "instructions mentioned here `http://kivy.org/#download` .") # minimum required version for kivy kivy.require('1.8.0') from kivy.logger import Logger from main_window import ElectrumWindow class ElectrumGui: def __init__(self, config, daemon, plugins): Logger.debug('ElectrumGUI: initialising') self.network = daemon.network self.config = config self.plugins = plugins def main(self): w = ElectrumWindow(config=self.config, network=self.network, plugins = self.plugins, gui_object=self) w.run()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 662, 1264, 28430, 446, 10540, 3463, 21158, 1890, 199, 3, 1898, 334, 35, 9, 6029, 294, 676, 305, 86, 32, 3187, 16039, 1785, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 199, 3, 12408, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 199, 3, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 199, 3, 5893, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 199, 3, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 199, 3, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 199, 3, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 199, 3, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 199, 3, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 199, 3, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 199, 3, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 199, 3, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 199, 3, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 199, 3, 4141, 14, 199, 3, 199, 3, 1804, 10241, 17160, 199, 199, 646, 984, 199, 646, 747, 199, 736, 14, 2314, 459, 43, 6882, 57, 63, 3998, 63, 3022, 418, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 3475, 3460, 493, 8964, 435, 1994, 576, 4805, 199, 199, 893, 26, 272, 984, 14, 3020, 275, 24506, 272, 492, 17227, 199, 2590, 3545, 26, 272, 327, 961, 1125, 9979, 1183, 9296, 1133, 4915, 543, 876, 13, 11730, 6117, 272, 984, 14, 2224, 480, 547, 26, 18615, 440, 492, 17227, 14, 7754, 3907, 652, 1808, 314, 2, 435, 971, 1467, 298, 20718, 26239, 2348, 658, 1014, 921, 16941, 14, 1308, 12645, 4249, 64, 1275, 531, 199, 199, 3, 7481, 1415, 1015, 367, 17227, 199, 16941, 14, 4365, 360, 17, 14, 24, 14, 16, 358, 199, 504, 17227, 14, 2921, 492, 15996, 199, 504, 2446, 63, 3806, 492, 662, 1264, 28430, 4301, 199, 199, 533, 662, 1264, 28430, 4324, 26, 339, 347, 636, 826, 721, 277, 12, 1101, 12, 11128, 12, 8963, 304, 267, 15996, 14, 1757, 360, 37, 1264, 28430, 14438, 26, 2536, 11136, 358, 267, 291, 14, 1200, 275, 11128, 14, 1200, 267, 291, 14, 888, 275, 1101, 267, 291, 14, 5265, 275, 8963, 339, 347, 2446, 8, 277, 304, 267, 336, 275, 662, 1264, 28430, 4301, 8, 888, 29, 277, 14, 888, 12, 2574, 2784, 29, 277, 14, 1200, 12, 2574, 8963, 275, 291, 14, 5265, 12, 2574, 11621, 63, 785, 29, 277, 9, 267, 336, 14, 1065, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 662, 1264, 28430, 446, 10540, 3463, 21158, 1890, 199, 3, 1898, 334, 35, 9, 6029, 294, 676, 305, 86, 32, 3187, 16039, 1785, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 199, 3, 12408, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 199, 3, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 199, 3, 5893, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 199, 3, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 199, 3, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 199, 3, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 199, 3, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 199, 3, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 199, 3, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 199, 3, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 199, 3, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 199, 3, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 199, 3, 4141, 14, 199, 3, 199, 3, 1804, 10241, 17160, 199, 199, 646, 984, 199, 646, 747, 199, 736, 14, 2314, 459, 43, 6882, 57, 63, 3998, 63, 3022, 418, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 3475, 3460, 493, 8964, 435, 1994, 576, 4805, 199, 199, 893, 26, 272, 984, 14, 3020, 275, 24506, 272, 492, 17227, 199, 2590, 3545, 26, 272, 327, 961, 1125, 9979, 1183, 9296, 1133, 4915, 543, 876, 13, 11730, 6117, 272, 984, 14, 2224, 480, 547, 26, 18615, 440, 492, 17227, 14, 7754, 3907, 652, 1808, 314, 2, 435, 971, 1467, 298, 20718, 26239, 2348, 658, 1014, 921, 16941, 14, 1308, 12645, 4249, 64, 1275, 531, 199, 199, 3, 7481, 1415, 1015, 367, 17227, 199, 16941, 14, 4365, 360, 17, 14, 24, 14, 16, 358, 199, 504, 17227, 14, 2921, 492, 15996, 199, 504, 2446, 63, 3806, 492, 662, 1264, 28430, 4301, 199, 199, 533, 662, 1264, 28430, 4324, 26, 339, 347, 636, 826, 721, 277, 12, 1101, 12, 11128, 12, 8963, 304, 267, 15996, 14, 1757, 360, 37, 1264, 28430, 14438, 26, 2536, 11136, 358, 267, 291, 14, 1200, 275, 11128, 14, 1200, 267, 291, 14, 888, 275, 1101, 267, 291, 14, 5265, 275, 8963, 339, 347, 2446, 8, 277, 304, 267, 336, 275, 662, 1264, 28430, 4301, 8, 888, 29, 277, 14, 888, 12, 2574, 2784, 29, 277, 14, 1200, 12, 2574, 8963, 275, 291, 14, 5265, 12, 2574, 11621, 63, 785, 29, 277, 9, 267, 336, 14, 1065, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
tinloaf/home-assistant
homeassistant/components/switch/hlk_sw16.py
2
1669
""" Support for HLK-SW16 switches. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/switch.hlk_sw16/ """ import logging from homeassistant.components.hlk_sw16 import ( SW16Device, DOMAIN as HLK_SW16, DATA_DEVICE_REGISTER) from homeassistant.components.switch import ( ToggleEntity) from homeassistant.const import CONF_NAME DEPENDENCIES = [HLK_SW16] _LOGGER = logging.getLogger(__name__) def devices_from_config(hass, domain_config): """Parse configuration and add HLK-SW16 switch devices.""" switches = domain_config[0] device_id = domain_config[1] device_client = hass.data[DATA_DEVICE_REGISTER][device_id] devices = [] for device_port, device_config in switches.items(): device_name = device_config.get(CONF_NAME, device_port) device = SW16Switch(device_name, device_port, device_id, device_client) devices.append(device) return devices async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the HLK-SW16 platform.""" async_add_entities(devices_from_config(hass, discovery_info)) class SW16Switch(SW16Device, ToggleEntity): """Representation of a HLK-SW16 switch.""" @property def is_on(self): """Return true if device is on.""" return self._is_on async def async_turn_on(self, **kwargs): """Turn the device on.""" await self._client.turn_on(self._device_port) async def async_turn_off(self, **kwargs): """Turn the device off.""" await self._client.turn_off(self._device_port)
apache-2.0
[ 624, 199, 11532, 367, 869, 44, 43, 13, 8745, 975, 24563, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 5656, 14, 15544, 75, 63, 3519, 975, 15, 199, 624, 199, 646, 2050, 199, 199, 504, 8846, 14, 4608, 14, 15544, 75, 63, 3519, 975, 492, 334, 272, 17548, 975, 2510, 12, 15265, 465, 869, 44, 43, 63, 8745, 975, 12, 272, 7126, 63, 10555, 63, 23986, 9, 199, 504, 8846, 14, 4608, 14, 5656, 492, 334, 272, 377, 19403, 7302, 9, 199, 504, 8846, 14, 1297, 492, 6392, 63, 2339, 199, 199, 25743, 9415, 2563, 275, 359, 29210, 43, 63, 8745, 975, 61, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 7256, 63, 504, 63, 888, 8, 5387, 12, 2881, 63, 888, 304, 272, 408, 4003, 2897, 436, 1050, 869, 44, 43, 13, 8745, 975, 6258, 7256, 1041, 272, 24563, 275, 2881, 63, 888, 59, 16, 61, 272, 2243, 63, 344, 275, 2881, 63, 888, 59, 17, 61, 272, 2243, 63, 1258, 275, 6298, 14, 576, 59, 3998, 63, 10555, 63, 23986, 1527, 1782, 63, 344, 61, 272, 7256, 275, 942, 272, 367, 2243, 63, 719, 12, 2243, 63, 888, 315, 24563, 14, 1744, 837, 267, 2243, 63, 354, 275, 2243, 63, 888, 14, 362, 8, 3103, 63, 2339, 12, 2243, 63, 719, 9, 267, 2243, 275, 17548, 975, 10167, 8, 1782, 63, 354, 12, 2243, 63, 719, 12, 2243, 63, 344, 12, 2243, 63, 1258, 9, 267, 7256, 14, 740, 8, 1782, 9, 272, 372, 7256, 421, 199, 4146, 347, 5316, 63, 2758, 63, 3246, 8, 5387, 12, 1101, 12, 5316, 63, 525, 63, 8327, 12, 3044, 13172, 63, 815, 29, 403, 304, 272, 408, 1084, 1536, 314, 869, 44, 43, 13, 8745, 975, 4298, 1041, 272, 5316, 63, 525, 63, 8327, 8, 6410, 63, 504, 63, 888, 8, 5387, 12, 13172, 63, 815, 430, 421, 199, 533, 17548, 975, 10167, 8, 8745, 975, 2510, 12, 377, 19403, 7302, 304, 272, 408, 20609, 402, 282, 869, 44, 43, 13, 8745, 975, 6258, 1041, 339, 768, 1829, 272, 347, 365, 63, 265, 8, 277, 304, 267, 408, 1767, 2549, 340, 2243, 365, 641, 1041, 267, 372, 291, 423, 374, 63, 265, 339, 5316, 347, 5316, 63, 353, 63, 265, 8, 277, 12, 1011, 958, 304, 267, 408, 16838, 314, 2243, 641, 1041, 267, 5517, 291, 423, 1258, 14, 353, 63, 265, 8, 277, 423, 1782, 63, 719, 9, 339, 5316, 347, 5316, 63, 353, 63, 1997, 8, 277, 12, 1011, 958, 304, 267, 408, 16838, 314, 2243, 2331, 1041, 267, 5517, 291, 423, 1258, 14, 353, 63, 1997, 8, 277, 423, 1782, 63, 719, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 869, 44, 43, 13, 8745, 975, 24563, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 5656, 14, 15544, 75, 63, 3519, 975, 15, 199, 624, 199, 646, 2050, 199, 199, 504, 8846, 14, 4608, 14, 15544, 75, 63, 3519, 975, 492, 334, 272, 17548, 975, 2510, 12, 15265, 465, 869, 44, 43, 63, 8745, 975, 12, 272, 7126, 63, 10555, 63, 23986, 9, 199, 504, 8846, 14, 4608, 14, 5656, 492, 334, 272, 377, 19403, 7302, 9, 199, 504, 8846, 14, 1297, 492, 6392, 63, 2339, 199, 199, 25743, 9415, 2563, 275, 359, 29210, 43, 63, 8745, 975, 61, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 7256, 63, 504, 63, 888, 8, 5387, 12, 2881, 63, 888, 304, 272, 408, 4003, 2897, 436, 1050, 869, 44, 43, 13, 8745, 975, 6258, 7256, 1041, 272, 24563, 275, 2881, 63, 888, 59, 16, 61, 272, 2243, 63, 344, 275, 2881, 63, 888, 59, 17, 61, 272, 2243, 63, 1258, 275, 6298, 14, 576, 59, 3998, 63, 10555, 63, 23986, 1527, 1782, 63, 344, 61, 272, 7256, 275, 942, 272, 367, 2243, 63, 719, 12, 2243, 63, 888, 315, 24563, 14, 1744, 837, 267, 2243, 63, 354, 275, 2243, 63, 888, 14, 362, 8, 3103, 63, 2339, 12, 2243, 63, 719, 9, 267, 2243, 275, 17548, 975, 10167, 8, 1782, 63, 354, 12, 2243, 63, 719, 12, 2243, 63, 344, 12, 2243, 63, 1258, 9, 267, 7256, 14, 740, 8, 1782, 9, 272, 372, 7256, 421, 199, 4146, 347, 5316, 63, 2758, 63, 3246, 8, 5387, 12, 1101, 12, 5316, 63, 525, 63, 8327, 12, 3044, 13172, 63, 815, 29, 403, 304, 272, 408, 1084, 1536, 314, 869, 44, 43, 13, 8745, 975, 4298, 1041, 272, 5316, 63, 525, 63, 8327, 8, 6410, 63, 504, 63, 888, 8, 5387, 12, 13172, 63, 815, 430, 421, 199, 533, 17548, 975, 10167, 8, 8745, 975, 2510, 12, 377, 19403, 7302, 304, 272, 408, 20609, 402, 282, 869, 44, 43, 13, 8745, 975, 6258, 1041, 339, 768, 1829, 272, 347, 365, 63, 265, 8, 277, 304, 267, 408, 1767, 2549, 340, 2243, 365, 641, 1041, 267, 372, 291, 423, 374, 63, 265, 339, 5316, 347, 5316, 63, 353, 63, 265, 8, 277, 12, 1011, 958, 304, 267, 408, 16838, 314, 2243, 641, 1041, 267, 5517, 291, 423, 1258, 14, 353, 63, 265, 8, 277, 423, 1782, 63, 719, 9, 339, 5316, 347, 5316, 63, 353, 63, 1997, 8, 277, 12, 1011, 958, 304, 267, 408, 16838, 314, 2243, 2331, 1041, 267, 5517, 291, 423, 1258, 14, 353, 63, 1997, 8, 277, 423, 1782, 63, 719, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Dingmatt/AMSA
Plug-ins/Amsa.bundle/Contents/Libraries/Shared/plex/client.py
3
2730
from plex.core.configuration import ConfigurationManager from plex.core.http import HttpClient from plex.helpers import has_attribute from plex.interfaces import construct_map from plex.interfaces.core.base import InterfaceProxy from plex.lib.six import add_metaclass from plex.objects.core.manager import ObjectManager import logging import socket log = logging.getLogger(__name__) class PlexClient(object): __interfaces = None def __init__(self): # Construct interfaces self.http = HttpClient(self) self.configuration = ConfigurationManager() self.__interfaces = construct_map(self) # Discover modules ObjectManager.construct() @property def base_url(self): host = self.configuration.get('server.host', '127.0.0.1') port = self.configuration.get('server.port', 32400) return 'http://%s:%s' % (host, port) def __getitem__(self, path): parts = path.strip('/').split('/') cur = self.__interfaces parameters = [] while parts and type(cur) is dict: key = parts.pop(0) if key == '*': key = None elif key not in cur: if None in cur: parameters.append(key) cur = cur[None] continue return None cur = cur[key] while type(cur) is dict: cur = cur.get(None) if parts: parameters.extend(parts) if parameters: return InterfaceProxy(cur, parameters) return cur def __getattr__(self, name): interface = self.__interfaces.get(None) if not interface: raise Exception("Root interface not found") return getattr(interface, name) class PlexMeta(type): @property def client(cls): if cls._client is None: cls.construct() return cls._client def __getattr__(self, name): if has_attribute(self, name): return super(PlexMeta, self).__getattribute__(name) if self.client is None: self.construct() return getattr(self.client, name) def __setattr__(self, name, value): if has_attribute(self, name): return super(PlexMeta, self).__setattr__(name, value) if self.client is None: self.construct() setattr(self.client, name, value) def __getitem__(self, key): if self.client is None: self.construct() return self.client[key] @add_metaclass(PlexMeta) class Plex(object): _client = None @classmethod def construct(cls): cls._client = PlexClient()
gpl-3.0
[ 504, 299, 3113, 14, 1018, 14, 4758, 492, 11595, 2988, 199, 504, 299, 3113, 14, 1018, 14, 1014, 492, 4760, 3041, 199, 504, 299, 3113, 14, 7546, 492, 965, 63, 3215, 199, 504, 299, 3113, 14, 7436, 492, 6982, 63, 1130, 199, 504, 299, 3113, 14, 7436, 14, 1018, 14, 1095, 492, 14816, 4936, 199, 504, 299, 3113, 14, 773, 14, 4174, 492, 1050, 63, 6577, 199, 504, 299, 3113, 14, 1462, 14, 1018, 14, 2609, 492, 6935, 2988, 199, 199, 646, 2050, 199, 646, 2838, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 510, 3113, 3041, 8, 785, 304, 272, 636, 7436, 275, 488, 339, 347, 636, 826, 721, 277, 304, 267, 327, 9215, 8386, 267, 291, 14, 1014, 275, 4760, 3041, 8, 277, 9, 267, 291, 14, 4758, 275, 11595, 2988, 342, 398, 291, 855, 7436, 275, 6982, 63, 1130, 8, 277, 9, 398, 327, 5289, 5899, 4621, 267, 6935, 2988, 14, 8514, 342, 339, 768, 1829, 272, 347, 1300, 63, 633, 8, 277, 304, 267, 1591, 275, 291, 14, 4758, 14, 362, 360, 1000, 14, 1102, 297, 283, 4195, 14, 16, 14, 16, 14, 17, 358, 267, 1844, 275, 291, 14, 4758, 14, 362, 360, 1000, 14, 719, 297, 650, 1194, 383, 9, 398, 372, 283, 1014, 13827, 83, 2689, 83, 7, 450, 334, 1102, 12, 1844, 9, 339, 347, 636, 6095, 721, 277, 12, 931, 304, 267, 4184, 275, 931, 14, 1913, 2336, 1959, 1294, 7825, 398, 1094, 275, 291, 855, 7436, 267, 2633, 275, 942, 398, 1830, 4184, 436, 730, 8, 895, 9, 365, 1211, 26, 288, 790, 275, 4184, 14, 1935, 8, 16, 9, 953, 340, 790, 508, 22969, 355, 790, 275, 488, 288, 916, 790, 440, 315, 1094, 26, 355, 340, 488, 315, 1094, 26, 490, 2633, 14, 740, 8, 498, 9, 4951, 1094, 275, 1094, 59, 403, 61, 490, 1980, 2234, 372, 488, 953, 1094, 275, 1094, 59, 498, 61, 398, 1830, 730, 8, 895, 9, 365, 1211, 26, 288, 1094, 275, 1094, 14, 362, 8, 403, 9, 398, 340, 4184, 26, 288, 2633, 14, 2880, 8, 4181, 9, 398, 340, 2633, 26, 288, 372, 14816, 4936, 8, 895, 12, 2633, 9, 398, 372, 1094, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 3217, 275, 291, 855, 7436, 14, 362, 8, 403, 9, 398, 340, 440, 3217, 26, 288, 746, 2186, 480, 6405, 3217, 440, 1911, 531, 398, 372, 2519, 8, 3266, 12, 536, 9, 421, 199, 533, 510, 3113, 3396, 8, 466, 304, 272, 768, 1829, 272, 347, 1890, 8, 1886, 304, 267, 340, 843, 423, 1258, 365, 488, 26, 288, 843, 14, 8514, 342, 398, 372, 843, 423, 1258, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 340, 965, 63, 3215, 8, 277, 12, 536, 304, 288, 372, 1613, 8, 48, 3113, 3396, 12, 291, 2843, 18480, 721, 354, 9, 398, 340, 291, 14, 1258, 365, 488, 26, 288, 291, 14, 8514, 342, 398, 372, 2519, 8, 277, 14, 1258, 12, 536, 9, 339, 347, 636, 10202, 721, 277, 12, 536, 12, 574, 304, 267, 340, 965, 63, 3215, 8, 277, 12, 536, 304, 288, 372, 1613, 8, 48, 3113, 3396, 12, 291, 2843, 10202, 721, 354, 12, 574, 9, 398, 340, 291, 14, 1258, 365, 488, 26, 288, 291, 14, 8514, 342, 398, 5371, 8, 277, 14, 1258, 12, 536, 12, 574, 9, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 340, 291, 14, 1258, 365, 488, 26, 288, 291, 14, 8514, 342, 398, 372, 291, 14, 1258, 59, 498, 61, 421, 199, 32, 525, 63, 6577, 8, 48, 3113, 3396, 9, 199, 533, 510, 3113, 8, 785, 304, 272, 485, 1258, 275, 488, 339, 768, 3744, 272, 347, 6982, 8, 1886, 304, 267, 843, 423, 1258, 275, 510, 3113, 3041, 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 ]
[ 299, 3113, 14, 1018, 14, 4758, 492, 11595, 2988, 199, 504, 299, 3113, 14, 1018, 14, 1014, 492, 4760, 3041, 199, 504, 299, 3113, 14, 7546, 492, 965, 63, 3215, 199, 504, 299, 3113, 14, 7436, 492, 6982, 63, 1130, 199, 504, 299, 3113, 14, 7436, 14, 1018, 14, 1095, 492, 14816, 4936, 199, 504, 299, 3113, 14, 773, 14, 4174, 492, 1050, 63, 6577, 199, 504, 299, 3113, 14, 1462, 14, 1018, 14, 2609, 492, 6935, 2988, 199, 199, 646, 2050, 199, 646, 2838, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 510, 3113, 3041, 8, 785, 304, 272, 636, 7436, 275, 488, 339, 347, 636, 826, 721, 277, 304, 267, 327, 9215, 8386, 267, 291, 14, 1014, 275, 4760, 3041, 8, 277, 9, 267, 291, 14, 4758, 275, 11595, 2988, 342, 398, 291, 855, 7436, 275, 6982, 63, 1130, 8, 277, 9, 398, 327, 5289, 5899, 4621, 267, 6935, 2988, 14, 8514, 342, 339, 768, 1829, 272, 347, 1300, 63, 633, 8, 277, 304, 267, 1591, 275, 291, 14, 4758, 14, 362, 360, 1000, 14, 1102, 297, 283, 4195, 14, 16, 14, 16, 14, 17, 358, 267, 1844, 275, 291, 14, 4758, 14, 362, 360, 1000, 14, 719, 297, 650, 1194, 383, 9, 398, 372, 283, 1014, 13827, 83, 2689, 83, 7, 450, 334, 1102, 12, 1844, 9, 339, 347, 636, 6095, 721, 277, 12, 931, 304, 267, 4184, 275, 931, 14, 1913, 2336, 1959, 1294, 7825, 398, 1094, 275, 291, 855, 7436, 267, 2633, 275, 942, 398, 1830, 4184, 436, 730, 8, 895, 9, 365, 1211, 26, 288, 790, 275, 4184, 14, 1935, 8, 16, 9, 953, 340, 790, 508, 22969, 355, 790, 275, 488, 288, 916, 790, 440, 315, 1094, 26, 355, 340, 488, 315, 1094, 26, 490, 2633, 14, 740, 8, 498, 9, 4951, 1094, 275, 1094, 59, 403, 61, 490, 1980, 2234, 372, 488, 953, 1094, 275, 1094, 59, 498, 61, 398, 1830, 730, 8, 895, 9, 365, 1211, 26, 288, 1094, 275, 1094, 14, 362, 8, 403, 9, 398, 340, 4184, 26, 288, 2633, 14, 2880, 8, 4181, 9, 398, 340, 2633, 26, 288, 372, 14816, 4936, 8, 895, 12, 2633, 9, 398, 372, 1094, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 3217, 275, 291, 855, 7436, 14, 362, 8, 403, 9, 398, 340, 440, 3217, 26, 288, 746, 2186, 480, 6405, 3217, 440, 1911, 531, 398, 372, 2519, 8, 3266, 12, 536, 9, 421, 199, 533, 510, 3113, 3396, 8, 466, 304, 272, 768, 1829, 272, 347, 1890, 8, 1886, 304, 267, 340, 843, 423, 1258, 365, 488, 26, 288, 843, 14, 8514, 342, 398, 372, 843, 423, 1258, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 340, 965, 63, 3215, 8, 277, 12, 536, 304, 288, 372, 1613, 8, 48, 3113, 3396, 12, 291, 2843, 18480, 721, 354, 9, 398, 340, 291, 14, 1258, 365, 488, 26, 288, 291, 14, 8514, 342, 398, 372, 2519, 8, 277, 14, 1258, 12, 536, 9, 339, 347, 636, 10202, 721, 277, 12, 536, 12, 574, 304, 267, 340, 965, 63, 3215, 8, 277, 12, 536, 304, 288, 372, 1613, 8, 48, 3113, 3396, 12, 291, 2843, 10202, 721, 354, 12, 574, 9, 398, 340, 291, 14, 1258, 365, 488, 26, 288, 291, 14, 8514, 342, 398, 5371, 8, 277, 14, 1258, 12, 536, 12, 574, 9, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 340, 291, 14, 1258, 365, 488, 26, 288, 291, 14, 8514, 342, 398, 372, 291, 14, 1258, 59, 498, 61, 421, 199, 32, 525, 63, 6577, 8, 48, 3113, 3396, 9, 199, 533, 510, 3113, 8, 785, 304, 272, 485, 1258, 275, 488, 339, 768, 3744, 272, 347, 6982, 8, 1886, 304, 267, 843, 423, 1258, 275, 510, 3113, 3041, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
MarkWh1te/xueqiu_predict
python3_env/lib/python3.4/site-packages/sqlalchemy/sql/compiler.py
17
107328
# sql/compiler.py # Copyright (C) 2005-2016 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 """Base SQL and DDL compiler implementations. Classes provided include: :class:`.compiler.SQLCompiler` - renders SQL strings :class:`.compiler.DDLCompiler` - renders DDL (data definition language) strings :class:`.compiler.GenericTypeCompiler` - renders type specification strings. To generate user-defined SQL strings, see :doc:`/ext/compiler`. """ import contextlib import re from . import schema, sqltypes, operators, functions, visitors, \ elements, selectable, crud from .. import util, exc import itertools RESERVED_WORDS = set([ 'all', 'analyse', 'analyze', 'and', 'any', 'array', 'as', 'asc', 'asymmetric', 'authorization', 'between', 'binary', 'both', 'case', 'cast', 'check', 'collate', 'column', 'constraint', 'create', 'cross', 'current_date', 'current_role', 'current_time', 'current_timestamp', 'current_user', 'default', 'deferrable', 'desc', 'distinct', 'do', 'else', 'end', 'except', 'false', 'for', 'foreign', 'freeze', 'from', 'full', 'grant', 'group', 'having', 'ilike', 'in', 'initially', 'inner', 'intersect', 'into', 'is', 'isnull', 'join', 'leading', 'left', 'like', 'limit', 'localtime', 'localtimestamp', 'natural', 'new', 'not', 'notnull', 'null', 'off', 'offset', 'old', 'on', 'only', 'or', 'order', 'outer', 'overlaps', 'placing', 'primary', 'references', 'right', 'select', 'session_user', 'set', 'similar', 'some', 'symmetric', 'table', 'then', 'to', 'trailing', 'true', 'union', 'unique', 'user', 'using', 'verbose', 'when', 'where']) LEGAL_CHARACTERS = re.compile(r'^[A-Z0-9_$]+$', re.I) ILLEGAL_INITIAL_CHARACTERS = set([str(x) for x in range(0, 10)]).union(['$']) BIND_PARAMS = re.compile(r'(?<![:\w\$\x5c]):([\w\$]+)(?![:\w\$])', re.UNICODE) BIND_PARAMS_ESC = re.compile(r'\x5c(:[\w\$]*)(?![:\w\$])', re.UNICODE) BIND_TEMPLATES = { 'pyformat': "%%(%(name)s)s", 'qmark': "?", 'format': "%%s", 'numeric': ":[_POSITION]", 'named': ":%(name)s" } OPERATORS = { # binary operators.and_: ' AND ', operators.or_: ' OR ', operators.add: ' + ', operators.mul: ' * ', operators.sub: ' - ', operators.div: ' / ', operators.mod: ' % ', operators.truediv: ' / ', operators.neg: '-', operators.lt: ' < ', operators.le: ' <= ', operators.ne: ' != ', operators.gt: ' > ', operators.ge: ' >= ', operators.eq: ' = ', operators.is_distinct_from: ' IS DISTINCT FROM ', operators.isnot_distinct_from: ' IS NOT DISTINCT FROM ', operators.concat_op: ' || ', operators.match_op: ' MATCH ', operators.notmatch_op: ' NOT MATCH ', operators.in_op: ' IN ', operators.notin_op: ' NOT IN ', operators.comma_op: ', ', operators.from_: ' FROM ', operators.as_: ' AS ', operators.is_: ' IS ', operators.isnot: ' IS NOT ', operators.collate: ' COLLATE ', # unary operators.exists: 'EXISTS ', operators.distinct_op: 'DISTINCT ', operators.inv: 'NOT ', operators.any_op: 'ANY ', operators.all_op: 'ALL ', # modifiers operators.desc_op: ' DESC', operators.asc_op: ' ASC', operators.nullsfirst_op: ' NULLS FIRST', operators.nullslast_op: ' NULLS LAST', } FUNCTIONS = { functions.coalesce: 'coalesce%(expr)s', functions.current_date: 'CURRENT_DATE', functions.current_time: 'CURRENT_TIME', functions.current_timestamp: 'CURRENT_TIMESTAMP', functions.current_user: 'CURRENT_USER', functions.localtime: 'LOCALTIME', functions.localtimestamp: 'LOCALTIMESTAMP', functions.random: 'random%(expr)s', functions.sysdate: 'sysdate', functions.session_user: 'SESSION_USER', functions.user: 'USER' } EXTRACT_MAP = { 'month': 'month', 'day': 'day', 'year': 'year', 'second': 'second', 'hour': 'hour', 'doy': 'doy', 'minute': 'minute', 'quarter': 'quarter', 'dow': 'dow', 'week': 'week', 'epoch': 'epoch', 'milliseconds': 'milliseconds', 'microseconds': 'microseconds', 'timezone_hour': 'timezone_hour', 'timezone_minute': 'timezone_minute' } COMPOUND_KEYWORDS = { selectable.CompoundSelect.UNION: 'UNION', selectable.CompoundSelect.UNION_ALL: 'UNION ALL', selectable.CompoundSelect.EXCEPT: 'EXCEPT', selectable.CompoundSelect.EXCEPT_ALL: 'EXCEPT ALL', selectable.CompoundSelect.INTERSECT: 'INTERSECT', selectable.CompoundSelect.INTERSECT_ALL: 'INTERSECT ALL' } class Compiled(object): """Represent a compiled SQL or DDL expression. The ``__str__`` method of the ``Compiled`` object should produce the actual text of the statement. ``Compiled`` objects are specific to their underlying database dialect, and also may or may not be specific to the columns referenced within a particular set of bind parameters. In no case should the ``Compiled`` object be dependent on the actual values of those bind parameters, even though it may reference those values as defaults. """ _cached_metadata = None execution_options = util.immutabledict() """ Execution options propagated from the statement. In some cases, sub-elements of the statement can modify these. """ def __init__(self, dialect, statement, bind=None, schema_translate_map=None, compile_kwargs=util.immutabledict()): """Construct a new :class:`.Compiled` object. :param dialect: :class:`.Dialect` to compile against. :param statement: :class:`.ClauseElement` to be compiled. :param bind: Optional Engine or Connection to compile this statement against. :param schema_translate_map: dictionary of schema names to be translated when forming the resultant SQL .. versionadded:: 1.1 .. seealso:: :ref:`schema_translating` :param compile_kwargs: additional kwargs that will be passed to the initial call to :meth:`.Compiled.process`. """ self.dialect = dialect self.bind = bind self.preparer = self.dialect.identifier_preparer if schema_translate_map: self.preparer = self.preparer._with_schema_translate( schema_translate_map) if statement is not None: self.statement = statement self.can_execute = statement.supports_execution if self.can_execute: self.execution_options = statement._execution_options self.string = self.process(self.statement, **compile_kwargs) @util.deprecated("0.7", ":class:`.Compiled` objects now compile " "within the constructor.") def compile(self): """Produce the internal string representation of this element. """ pass def _execute_on_connection(self, connection, multiparams, params): if self.can_execute: return connection._execute_compiled(self, multiparams, params) else: raise exc.ObjectNotExecutableError(self.statement) @property def sql_compiler(self): """Return a Compiled that is capable of processing SQL expressions. If this compiler is one, it would likely just return 'self'. """ raise NotImplementedError() def process(self, obj, **kwargs): return obj._compiler_dispatch(self, **kwargs) def __str__(self): """Return the string text of the generated SQL or DDL.""" return self.string or '' def construct_params(self, params=None): """Return the bind params for this compiled object. :param params: a dict of string/object pairs whose values will override bind values compiled in to the statement. """ raise NotImplementedError() @property def params(self): """Return the bind params for this compiled object.""" return self.construct_params() def execute(self, *multiparams, **params): """Execute this compiled object.""" e = self.bind if e is None: raise exc.UnboundExecutionError( "This Compiled object is not bound to any Engine " "or Connection.") return e._execute_compiled(self, multiparams, params) def scalar(self, *multiparams, **params): """Execute this compiled object and return the result's scalar value.""" return self.execute(*multiparams, **params).scalar() class TypeCompiler(util.with_metaclass(util.EnsureKWArgType, object)): """Produces DDL specification for TypeEngine objects.""" ensure_kwarg = 'visit_\w+' def __init__(self, dialect): self.dialect = dialect def process(self, type_, **kw): return type_._compiler_dispatch(self, **kw) class _CompileLabel(visitors.Visitable): """lightweight label object which acts as an expression.Label.""" __visit_name__ = 'label' __slots__ = 'element', 'name' def __init__(self, col, name, alt_names=()): self.element = col self.name = name self._alt_names = (col,) + alt_names @property def proxy_set(self): return self.element.proxy_set @property def type(self): return self.element.type def self_group(self, **kw): return self class SQLCompiler(Compiled): """Default implementation of :class:`.Compiled`. Compiles :class:`.ClauseElement` objects into SQL strings. """ extract_map = EXTRACT_MAP compound_keywords = COMPOUND_KEYWORDS isdelete = isinsert = isupdate = False """class-level defaults which can be set at the instance level to define if this Compiled instance represents INSERT/UPDATE/DELETE """ isplaintext = False returning = None """holds the "returning" collection of columns if the statement is CRUD and defines returning columns either implicitly or explicitly """ returning_precedes_values = False """set to True classwide to generate RETURNING clauses before the VALUES or WHERE clause (i.e. MSSQL) """ render_table_with_column_in_update_from = False """set to True classwide to indicate the SET clause in a multi-table UPDATE statement should qualify columns with the table name (i.e. MySQL only) """ ansi_bind_rules = False """SQL 92 doesn't allow bind parameters to be used in the columns clause of a SELECT, nor does it allow ambiguous expressions like "? = ?". A compiler subclass can set this flag to False if the target driver/DB enforces this """ _textual_ordered_columns = False """tell the result object that the column names as rendered are important, but they are also "ordered" vs. what is in the compiled object here. """ _ordered_columns = True """ if False, means we can't be sure the list of entries in _result_columns is actually the rendered order. Usually True unless using an unordered TextAsFrom. """ insert_prefetch = update_prefetch = () def __init__(self, dialect, statement, column_keys=None, inline=False, **kwargs): """Construct a new :class:`.SQLCompiler` object. :param dialect: :class:`.Dialect` to be used :param statement: :class:`.ClauseElement` to be compiled :param column_keys: a list of column names to be compiled into an INSERT or UPDATE statement. :param inline: whether to generate INSERT statements as "inline", e.g. not formatted to return any generated defaults :param kwargs: additional keyword arguments to be consumed by the superclass. """ self.column_keys = column_keys # compile INSERT/UPDATE defaults/sequences inlined (no pre- # execute) self.inline = inline or getattr(statement, 'inline', False) # a dictionary of bind parameter keys to BindParameter # instances. self.binds = {} # a dictionary of BindParameter instances to "compiled" names # that are actually present in the generated SQL self.bind_names = util.column_dict() # stack which keeps track of nested SELECT statements self.stack = [] # relates label names in the final SQL to a tuple of local # column/label name, ColumnElement object (if any) and # TypeEngine. ResultProxy uses this for type processing and # column targeting self._result_columns = [] # true if the paramstyle is positional self.positional = dialect.positional if self.positional: self.positiontup = [] self.bindtemplate = BIND_TEMPLATES[dialect.paramstyle] self.ctes = None self.label_length = dialect.label_length \ or dialect.max_identifier_length # a map which tracks "anonymous" identifiers that are created on # the fly here self.anon_map = util.PopulateDict(self._process_anon) # a map which tracks "truncated" names based on # dialect.label_length or dialect.max_identifier_length self.truncated_names = {} Compiled.__init__(self, dialect, statement, **kwargs) if ( self.isinsert or self.isupdate or self.isdelete ) and statement._returning: self.returning = statement._returning if self.positional and dialect.paramstyle == 'numeric': self._apply_numbered_params() @property def prefetch(self): return list(self.insert_prefetch + self.update_prefetch) @util.memoized_instancemethod def _init_cte_state(self): """Initialize collections related to CTEs only if a CTE is located, to save on the overhead of these collections otherwise. """ # collect CTEs to tack on top of a SELECT self.ctes = util.OrderedDict() self.ctes_by_name = {} self.ctes_recursive = False if self.positional: self.cte_positional = {} @contextlib.contextmanager def _nested_result(self): """special API to support the use case of 'nested result sets'""" result_columns, ordered_columns = ( self._result_columns, self._ordered_columns) self._result_columns, self._ordered_columns = [], False try: if self.stack: entry = self.stack[-1] entry['need_result_map_for_nested'] = True else: entry = None yield self._result_columns, self._ordered_columns finally: if entry: entry.pop('need_result_map_for_nested') self._result_columns, self._ordered_columns = ( result_columns, ordered_columns) def _apply_numbered_params(self): poscount = itertools.count(1) self.string = re.sub( r'\[_POSITION\]', lambda m: str(util.next(poscount)), self.string) @util.memoized_property def _bind_processors(self): return dict( (key, value) for key, value in ((self.bind_names[bindparam], bindparam.type._cached_bind_processor(self.dialect)) for bindparam in self.bind_names) if value is not None ) def is_subquery(self): return len(self.stack) > 1 @property def sql_compiler(self): return self def construct_params(self, params=None, _group_number=None, _check=True): """return a dictionary of bind parameter keys and values""" if params: pd = {} for bindparam in self.bind_names: name = self.bind_names[bindparam] if bindparam.key in params: pd[name] = params[bindparam.key] elif name in params: pd[name] = params[name] elif _check and bindparam.required: if _group_number: raise exc.InvalidRequestError( "A value is required for bind parameter %r, " "in parameter group %d" % (bindparam.key, _group_number)) else: raise exc.InvalidRequestError( "A value is required for bind parameter %r" % bindparam.key) elif bindparam.callable: pd[name] = bindparam.effective_value else: pd[name] = bindparam.value return pd else: pd = {} for bindparam in self.bind_names: if _check and bindparam.required: if _group_number: raise exc.InvalidRequestError( "A value is required for bind parameter %r, " "in parameter group %d" % (bindparam.key, _group_number)) else: raise exc.InvalidRequestError( "A value is required for bind parameter %r" % bindparam.key) if bindparam.callable: pd[self.bind_names[bindparam]] = bindparam.effective_value else: pd[self.bind_names[bindparam]] = bindparam.value return pd @property def params(self): """Return the bind param dictionary embedded into this compiled object, for those values that are present.""" return self.construct_params(_check=False) @util.dependencies("sqlalchemy.engine.result") def _create_result_map(self, result): """utility method used for unit tests only.""" return result.ResultMetaData._create_result_map(self._result_columns) def default_from(self): """Called when a SELECT statement has no froms, and no FROM clause is to be appended. Gives Oracle a chance to tack on a ``FROM DUAL`` to the string output. """ return "" def visit_grouping(self, grouping, asfrom=False, **kwargs): return "(" + grouping.element._compiler_dispatch(self, **kwargs) + ")" def visit_label_reference( self, element, within_columns_clause=False, **kwargs): if self.stack and self.dialect.supports_simple_order_by_label: selectable = self.stack[-1]['selectable'] with_cols, only_froms = selectable._label_resolve_dict if within_columns_clause: resolve_dict = only_froms else: resolve_dict = with_cols # this can be None in the case that a _label_reference() # were subject to a replacement operation, in which case # the replacement of the Label element may have changed # to something else like a ColumnClause expression. order_by_elem = element.element._order_by_label_element if order_by_elem is not None and order_by_elem.name in \ resolve_dict: kwargs['render_label_as_label'] = \ element.element._order_by_label_element return self.process( element.element, within_columns_clause=within_columns_clause, **kwargs) def visit_textual_label_reference( self, element, within_columns_clause=False, **kwargs): if not self.stack: # compiling the element outside of the context of a SELECT return self.process( element._text_clause ) selectable = self.stack[-1]['selectable'] with_cols, only_froms = selectable._label_resolve_dict try: if within_columns_clause: col = only_froms[element.element] else: col = with_cols[element.element] except KeyError: # treat it like text() util.warn_limited( "Can't resolve label reference %r; converting to text()", util.ellipses_string(element.element)) return self.process( element._text_clause ) else: kwargs['render_label_as_label'] = col return self.process( col, within_columns_clause=within_columns_clause, **kwargs) def visit_label(self, label, add_to_result_map=None, within_label_clause=False, within_columns_clause=False, render_label_as_label=None, **kw): # only render labels within the columns clause # or ORDER BY clause of a select. dialect-specific compilers # can modify this behavior. render_label_with_as = (within_columns_clause and not within_label_clause) render_label_only = render_label_as_label is label if render_label_only or render_label_with_as: if isinstance(label.name, elements._truncated_label): labelname = self._truncated_identifier("colident", label.name) else: labelname = label.name if render_label_with_as: if add_to_result_map is not None: add_to_result_map( labelname, label.name, (label, labelname, ) + label._alt_names, label.type ) return label.element._compiler_dispatch( self, within_columns_clause=True, within_label_clause=True, **kw) + \ OPERATORS[operators.as_] + \ self.preparer.format_label(label, labelname) elif render_label_only: return self.preparer.format_label(label, labelname) else: return label.element._compiler_dispatch( self, within_columns_clause=False, **kw) def _fallback_column_name(self, column): raise exc.CompileError("Cannot compile Column object until " "its 'name' is assigned.") def visit_column(self, column, add_to_result_map=None, include_table=True, **kwargs): name = orig_name = column.name if name is None: name = self._fallback_column_name(column) is_literal = column.is_literal if not is_literal and isinstance(name, elements._truncated_label): name = self._truncated_identifier("colident", name) if add_to_result_map is not None: add_to_result_map( name, orig_name, (column, name, column.key), column.type ) if is_literal: name = self.escape_literal_column(name) else: name = self.preparer.quote(name) table = column.table if table is None or not include_table or not table.named_with_column: return name else: effective_schema = self.preparer.schema_for_object(table) if effective_schema: schema_prefix = self.preparer.quote_schema( effective_schema) + '.' else: schema_prefix = '' tablename = table.name if isinstance(tablename, elements._truncated_label): tablename = self._truncated_identifier("alias", tablename) return schema_prefix + \ self.preparer.quote(tablename) + \ "." + name def escape_literal_column(self, text): """provide escaping for the literal_column() construct.""" # TODO: some dialects might need different behavior here return text.replace('%', '%%') def visit_fromclause(self, fromclause, **kwargs): return fromclause.name def visit_index(self, index, **kwargs): return index.name def visit_typeclause(self, typeclause, **kw): kw['type_expression'] = typeclause return self.dialect.type_compiler.process(typeclause.type, **kw) def post_process_text(self, text): return text def visit_textclause(self, textclause, **kw): def do_bindparam(m): name = m.group(1) if name in textclause._bindparams: return self.process(textclause._bindparams[name], **kw) else: return self.bindparam_string(name, **kw) if not self.stack: self.isplaintext = True # un-escape any \:params return BIND_PARAMS_ESC.sub( lambda m: m.group(1), BIND_PARAMS.sub( do_bindparam, self.post_process_text(textclause.text)) ) def visit_text_as_from(self, taf, compound_index=None, asfrom=False, parens=True, **kw): toplevel = not self.stack entry = self._default_stack_entry if toplevel else self.stack[-1] populate_result_map = toplevel or \ ( compound_index == 0 and entry.get( 'need_result_map_for_compound', False) ) or entry.get('need_result_map_for_nested', False) if populate_result_map: self._ordered_columns = \ self._textual_ordered_columns = taf.positional for c in taf.column_args: self.process(c, within_columns_clause=True, add_to_result_map=self._add_to_result_map) text = self.process(taf.element, **kw) if asfrom and parens: text = "(%s)" % text return text def visit_null(self, expr, **kw): return 'NULL' def visit_true(self, expr, **kw): if self.dialect.supports_native_boolean: return 'true' else: return "1" def visit_false(self, expr, **kw): if self.dialect.supports_native_boolean: return 'false' else: return "0" def visit_clauselist(self, clauselist, **kw): sep = clauselist.operator if sep is None: sep = " " else: sep = OPERATORS[clauselist.operator] return sep.join( s for s in ( c._compiler_dispatch(self, **kw) for c in clauselist.clauses) if s) def visit_case(self, clause, **kwargs): x = "CASE " if clause.value is not None: x += clause.value._compiler_dispatch(self, **kwargs) + " " for cond, result in clause.whens: x += "WHEN " + cond._compiler_dispatch( self, **kwargs ) + " THEN " + result._compiler_dispatch( self, **kwargs) + " " if clause.else_ is not None: x += "ELSE " + clause.else_._compiler_dispatch( self, **kwargs ) + " " x += "END" return x def visit_type_coerce(self, type_coerce, **kw): return type_coerce.typed_expression._compiler_dispatch(self, **kw) def visit_cast(self, cast, **kwargs): return "CAST(%s AS %s)" % \ (cast.clause._compiler_dispatch(self, **kwargs), cast.typeclause._compiler_dispatch(self, **kwargs)) def _format_frame_clause(self, range_, **kw): return '%s AND %s' % ( "UNBOUNDED PRECEDING" if range_[0] is elements.RANGE_UNBOUNDED else "CURRENT ROW" if range_[0] is elements.RANGE_CURRENT else "%s PRECEDING" % (self.process(range_[0], **kw), ), "UNBOUNDED FOLLOWING" if range_[1] is elements.RANGE_UNBOUNDED else "CURRENT ROW" if range_[1] is elements.RANGE_CURRENT else "%s FOLLOWING" % (self.process(range_[1], **kw), ) ) def visit_over(self, over, **kwargs): if over.range_: range_ = "RANGE BETWEEN %s" % self._format_frame_clause( over.range_, **kwargs) elif over.rows: range_ = "ROWS BETWEEN %s" % self._format_frame_clause( over.rows, **kwargs) else: range_ = None return "%s OVER (%s)" % ( over.element._compiler_dispatch(self, **kwargs), ' '.join([ '%s BY %s' % ( word, clause._compiler_dispatch(self, **kwargs) ) for word, clause in ( ('PARTITION', over.partition_by), ('ORDER', over.order_by) ) if clause is not None and len(clause) ] + ([range_] if range_ else []) ) ) def visit_withingroup(self, withingroup, **kwargs): return "%s WITHIN GROUP (ORDER BY %s)" % ( withingroup.element._compiler_dispatch(self, **kwargs), withingroup.order_by._compiler_dispatch(self, **kwargs) ) def visit_funcfilter(self, funcfilter, **kwargs): return "%s FILTER (WHERE %s)" % ( funcfilter.func._compiler_dispatch(self, **kwargs), funcfilter.criterion._compiler_dispatch(self, **kwargs) ) def visit_extract(self, extract, **kwargs): field = self.extract_map.get(extract.field, extract.field) return "EXTRACT(%s FROM %s)" % ( field, extract.expr._compiler_dispatch(self, **kwargs)) def visit_function(self, func, add_to_result_map=None, **kwargs): if add_to_result_map is not None: add_to_result_map( func.name, func.name, (), func.type ) disp = getattr(self, "visit_%s_func" % func.name.lower(), None) if disp: return disp(func, **kwargs) else: name = FUNCTIONS.get(func.__class__, func.name + "%(expr)s") return ".".join(list(func.packagenames) + [name]) % \ {'expr': self.function_argspec(func, **kwargs)} def visit_next_value_func(self, next_value, **kw): return self.visit_sequence(next_value.sequence) def visit_sequence(self, sequence): raise NotImplementedError( "Dialect '%s' does not support sequence increments." % self.dialect.name ) def function_argspec(self, func, **kwargs): return func.clause_expr._compiler_dispatch(self, **kwargs) def visit_compound_select(self, cs, asfrom=False, parens=True, compound_index=0, **kwargs): toplevel = not self.stack entry = self._default_stack_entry if toplevel else self.stack[-1] need_result_map = toplevel or \ (compound_index == 0 and entry.get('need_result_map_for_compound', False)) self.stack.append( { 'correlate_froms': entry['correlate_froms'], 'asfrom_froms': entry['asfrom_froms'], 'selectable': cs, 'need_result_map_for_compound': need_result_map }) keyword = self.compound_keywords.get(cs.keyword) text = (" " + keyword + " ").join( (c._compiler_dispatch(self, asfrom=asfrom, parens=False, compound_index=i, **kwargs) for i, c in enumerate(cs.selects)) ) group_by = cs._group_by_clause._compiler_dispatch( self, asfrom=asfrom, **kwargs) if group_by: text += " GROUP BY " + group_by text += self.order_by_clause(cs, **kwargs) text += (cs._limit_clause is not None or cs._offset_clause is not None) and \ self.limit_clause(cs, **kwargs) or "" if self.ctes and toplevel: text = self._render_cte_clause() + text self.stack.pop(-1) if asfrom and parens: return "(" + text + ")" else: return text def _get_operator_dispatch(self, operator_, qualifier1, qualifier2): attrname = "visit_%s_%s%s" % ( operator_.__name__, qualifier1, "_" + qualifier2 if qualifier2 else "") return getattr(self, attrname, None) def visit_unary(self, unary, **kw): if unary.operator: if unary.modifier: raise exc.CompileError( "Unary expression does not support operator " "and modifier simultaneously") disp = self._get_operator_dispatch( unary.operator, "unary", "operator") if disp: return disp(unary, unary.operator, **kw) else: return self._generate_generic_unary_operator( unary, OPERATORS[unary.operator], **kw) elif unary.modifier: disp = self._get_operator_dispatch( unary.modifier, "unary", "modifier") if disp: return disp(unary, unary.modifier, **kw) else: return self._generate_generic_unary_modifier( unary, OPERATORS[unary.modifier], **kw) else: raise exc.CompileError( "Unary expression has no operator or modifier") def visit_istrue_unary_operator(self, element, operator, **kw): if self.dialect.supports_native_boolean: return self.process(element.element, **kw) else: return "%s = 1" % self.process(element.element, **kw) def visit_isfalse_unary_operator(self, element, operator, **kw): if self.dialect.supports_native_boolean: return "NOT %s" % self.process(element.element, **kw) else: return "%s = 0" % self.process(element.element, **kw) def visit_notmatch_op_binary(self, binary, operator, **kw): return "NOT %s" % self.visit_binary( binary, override_operator=operators.match_op) def visit_binary(self, binary, override_operator=None, eager_grouping=False, **kw): # don't allow "? = ?" to render if self.ansi_bind_rules and \ isinstance(binary.left, elements.BindParameter) and \ isinstance(binary.right, elements.BindParameter): kw['literal_binds'] = True operator_ = override_operator or binary.operator disp = self._get_operator_dispatch(operator_, "binary", None) if disp: return disp(binary, operator_, **kw) else: try: opstring = OPERATORS[operator_] except KeyError: raise exc.UnsupportedCompilationError(self, operator_) else: return self._generate_generic_binary(binary, opstring, **kw) def visit_custom_op_binary(self, element, operator, **kw): kw['eager_grouping'] = operator.eager_grouping return self._generate_generic_binary( element, " " + operator.opstring + " ", **kw) def visit_custom_op_unary_operator(self, element, operator, **kw): return self._generate_generic_unary_operator( element, operator.opstring + " ", **kw) def visit_custom_op_unary_modifier(self, element, operator, **kw): return self._generate_generic_unary_modifier( element, " " + operator.opstring, **kw) def _generate_generic_binary( self, binary, opstring, eager_grouping=False, **kw): _in_binary = kw.get('_in_binary', False) kw['_in_binary'] = True text = binary.left._compiler_dispatch( self, eager_grouping=eager_grouping, **kw) + \ opstring + \ binary.right._compiler_dispatch( self, eager_grouping=eager_grouping, **kw) if _in_binary and eager_grouping: text = "(%s)" % text return text def _generate_generic_unary_operator(self, unary, opstring, **kw): return opstring + unary.element._compiler_dispatch(self, **kw) def _generate_generic_unary_modifier(self, unary, opstring, **kw): return unary.element._compiler_dispatch(self, **kw) + opstring @util.memoized_property def _like_percent_literal(self): return elements.literal_column("'%'", type_=sqltypes.STRINGTYPE) def visit_contains_op_binary(self, binary, operator, **kw): binary = binary._clone() percent = self._like_percent_literal binary.right = percent.__add__(binary.right).__add__(percent) return self.visit_like_op_binary(binary, operator, **kw) def visit_notcontains_op_binary(self, binary, operator, **kw): binary = binary._clone() percent = self._like_percent_literal binary.right = percent.__add__(binary.right).__add__(percent) return self.visit_notlike_op_binary(binary, operator, **kw) def visit_startswith_op_binary(self, binary, operator, **kw): binary = binary._clone() percent = self._like_percent_literal binary.right = percent.__radd__( binary.right ) return self.visit_like_op_binary(binary, operator, **kw) def visit_notstartswith_op_binary(self, binary, operator, **kw): binary = binary._clone() percent = self._like_percent_literal binary.right = percent.__radd__( binary.right ) return self.visit_notlike_op_binary(binary, operator, **kw) def visit_endswith_op_binary(self, binary, operator, **kw): binary = binary._clone() percent = self._like_percent_literal binary.right = percent.__add__(binary.right) return self.visit_like_op_binary(binary, operator, **kw) def visit_notendswith_op_binary(self, binary, operator, **kw): binary = binary._clone() percent = self._like_percent_literal binary.right = percent.__add__(binary.right) return self.visit_notlike_op_binary(binary, operator, **kw) def visit_like_op_binary(self, binary, operator, **kw): escape = binary.modifiers.get("escape", None) # TODO: use ternary here, not "and"/ "or" return '%s LIKE %s' % ( binary.left._compiler_dispatch(self, **kw), binary.right._compiler_dispatch(self, **kw)) \ + ( ' ESCAPE ' + self.render_literal_value(escape, sqltypes.STRINGTYPE) if escape else '' ) def visit_notlike_op_binary(self, binary, operator, **kw): escape = binary.modifiers.get("escape", None) return '%s NOT LIKE %s' % ( binary.left._compiler_dispatch(self, **kw), binary.right._compiler_dispatch(self, **kw)) \ + ( ' ESCAPE ' + self.render_literal_value(escape, sqltypes.STRINGTYPE) if escape else '' ) def visit_ilike_op_binary(self, binary, operator, **kw): escape = binary.modifiers.get("escape", None) return 'lower(%s) LIKE lower(%s)' % ( binary.left._compiler_dispatch(self, **kw), binary.right._compiler_dispatch(self, **kw)) \ + ( ' ESCAPE ' + self.render_literal_value(escape, sqltypes.STRINGTYPE) if escape else '' ) def visit_notilike_op_binary(self, binary, operator, **kw): escape = binary.modifiers.get("escape", None) return 'lower(%s) NOT LIKE lower(%s)' % ( binary.left._compiler_dispatch(self, **kw), binary.right._compiler_dispatch(self, **kw)) \ + ( ' ESCAPE ' + self.render_literal_value(escape, sqltypes.STRINGTYPE) if escape else '' ) def visit_between_op_binary(self, binary, operator, **kw): symmetric = binary.modifiers.get("symmetric", False) return self._generate_generic_binary( binary, " BETWEEN SYMMETRIC " if symmetric else " BETWEEN ", **kw) def visit_notbetween_op_binary(self, binary, operator, **kw): symmetric = binary.modifiers.get("symmetric", False) return self._generate_generic_binary( binary, " NOT BETWEEN SYMMETRIC " if symmetric else " NOT BETWEEN ", **kw) def visit_bindparam(self, bindparam, within_columns_clause=False, literal_binds=False, skip_bind_expression=False, **kwargs): if not skip_bind_expression and bindparam.type._has_bind_expression: bind_expression = bindparam.type.bind_expression(bindparam) return self.process(bind_expression, skip_bind_expression=True) if literal_binds or \ (within_columns_clause and self.ansi_bind_rules): if bindparam.value is None and bindparam.callable is None: raise exc.CompileError("Bind parameter '%s' without a " "renderable value not allowed here." % bindparam.key) return self.render_literal_bindparam( bindparam, within_columns_clause=True, **kwargs) name = self._truncate_bindparam(bindparam) if name in self.binds: existing = self.binds[name] if existing is not bindparam: if (existing.unique or bindparam.unique) and \ not existing.proxy_set.intersection( bindparam.proxy_set): raise exc.CompileError( "Bind parameter '%s' conflicts with " "unique bind parameter of the same name" % bindparam.key ) elif existing._is_crud or bindparam._is_crud: raise exc.CompileError( "bindparam() name '%s' is reserved " "for automatic usage in the VALUES or SET " "clause of this " "insert/update statement. Please use a " "name other than column name when using bindparam() " "with insert() or update() (for example, 'b_%s')." % (bindparam.key, bindparam.key) ) self.binds[bindparam.key] = self.binds[name] = bindparam return self.bindparam_string(name, **kwargs) def render_literal_bindparam(self, bindparam, **kw): value = bindparam.effective_value return self.render_literal_value(value, bindparam.type) def render_literal_value(self, value, type_): """Render the value of a bind parameter as a quoted literal. This is used for statement sections that do not accept bind parameters on the target driver/database. This should be implemented by subclasses using the quoting services of the DBAPI. """ processor = type_._cached_literal_processor(self.dialect) if processor: return processor(value) else: raise NotImplementedError( "Don't know how to literal-quote value %r" % value) def _truncate_bindparam(self, bindparam): if bindparam in self.bind_names: return self.bind_names[bindparam] bind_name = bindparam.key if isinstance(bind_name, elements._truncated_label): bind_name = self._truncated_identifier("bindparam", bind_name) # add to bind_names for translation self.bind_names[bindparam] = bind_name return bind_name def _truncated_identifier(self, ident_class, name): if (ident_class, name) in self.truncated_names: return self.truncated_names[(ident_class, name)] anonname = name.apply_map(self.anon_map) if len(anonname) > self.label_length - 6: counter = self.truncated_names.get(ident_class, 1) truncname = anonname[0:max(self.label_length - 6, 0)] + \ "_" + hex(counter)[2:] self.truncated_names[ident_class] = counter + 1 else: truncname = anonname self.truncated_names[(ident_class, name)] = truncname return truncname def _anonymize(self, name): return name % self.anon_map def _process_anon(self, key): (ident, derived) = key.split(' ', 1) anonymous_counter = self.anon_map.get(derived, 1) self.anon_map[derived] = anonymous_counter + 1 return derived + "_" + str(anonymous_counter) def bindparam_string(self, name, positional_names=None, **kw): if self.positional: if positional_names is not None: positional_names.append(name) else: self.positiontup.append(name) return self.bindtemplate % {'name': name} def visit_cte(self, cte, asfrom=False, ashint=False, fromhints=None, **kwargs): self._init_cte_state() if isinstance(cte.name, elements._truncated_label): cte_name = self._truncated_identifier("alias", cte.name) else: cte_name = cte.name if cte_name in self.ctes_by_name: existing_cte = self.ctes_by_name[cte_name] # we've generated a same-named CTE that we are enclosed in, # or this is the same CTE. just return the name. if cte in existing_cte._restates or cte is existing_cte: return self.preparer.format_alias(cte, cte_name) elif existing_cte in cte._restates: # we've generated a same-named CTE that is # enclosed in us - we take precedence, so # discard the text for the "inner". del self.ctes[existing_cte] else: raise exc.CompileError( "Multiple, unrelated CTEs found with " "the same name: %r" % cte_name) self.ctes_by_name[cte_name] = cte # look for embedded DML ctes and propagate autocommit if 'autocommit' in cte.element._execution_options and \ 'autocommit' not in self.execution_options: self.execution_options = self.execution_options.union( {"autocommit": cte.element._execution_options['autocommit']}) if cte._cte_alias is not None: orig_cte = cte._cte_alias if orig_cte not in self.ctes: self.visit_cte(orig_cte, **kwargs) cte_alias_name = cte._cte_alias.name if isinstance(cte_alias_name, elements._truncated_label): cte_alias_name = self._truncated_identifier( "alias", cte_alias_name) else: orig_cte = cte cte_alias_name = None if not cte_alias_name and cte not in self.ctes: if cte.recursive: self.ctes_recursive = True text = self.preparer.format_alias(cte, cte_name) if cte.recursive: if isinstance(cte.original, selectable.Select): col_source = cte.original elif isinstance(cte.original, selectable.CompoundSelect): col_source = cte.original.selects[0] else: assert False recur_cols = [c for c in util.unique_list(col_source.inner_columns) if c is not None] text += "(%s)" % (", ".join( self.preparer.format_column(ident) for ident in recur_cols)) if self.positional: kwargs['positional_names'] = self.cte_positional[cte] = [] text += " AS \n" + \ cte.original._compiler_dispatch( self, asfrom=True, **kwargs ) if cte._suffixes: text += " " + self._generate_prefixes( cte, cte._suffixes, **kwargs) self.ctes[cte] = text if asfrom: if cte_alias_name: text = self.preparer.format_alias(cte, cte_alias_name) text += self.get_render_as_alias_suffix(cte_name) else: return self.preparer.format_alias(cte, cte_name) return text def visit_alias(self, alias, asfrom=False, ashint=False, iscrud=False, fromhints=None, **kwargs): if asfrom or ashint: if isinstance(alias.name, elements._truncated_label): alias_name = self._truncated_identifier("alias", alias.name) else: alias_name = alias.name if ashint: return self.preparer.format_alias(alias, alias_name) elif asfrom: ret = alias.original._compiler_dispatch(self, asfrom=True, **kwargs) + \ self.get_render_as_alias_suffix( self.preparer.format_alias(alias, alias_name)) if fromhints and alias in fromhints: ret = self.format_from_hint_text(ret, alias, fromhints[alias], iscrud) return ret else: return alias.original._compiler_dispatch(self, **kwargs) def visit_lateral(self, lateral, **kw): kw['lateral'] = True return "LATERAL %s" % self.visit_alias(lateral, **kw) def visit_tablesample(self, tablesample, asfrom=False, **kw): text = "%s TABLESAMPLE %s" % ( self.visit_alias(tablesample, asfrom=True, **kw), tablesample._get_method()._compiler_dispatch(self, **kw)) if tablesample.seed is not None: text += " REPEATABLE (%s)" % ( tablesample.seed._compiler_dispatch(self, **kw)) return text def get_render_as_alias_suffix(self, alias_name_text): return " AS " + alias_name_text def _add_to_result_map(self, keyname, name, objects, type_): self._result_columns.append((keyname, name, objects, type_)) def _label_select_column(self, select, column, populate_result_map, asfrom, column_clause_args, name=None, within_columns_clause=True): """produce labeled columns present in a select().""" if column.type._has_column_expression and \ populate_result_map: col_expr = column.type.column_expression(column) add_to_result_map = lambda keyname, name, objects, type_: \ self._add_to_result_map( keyname, name, (column,) + objects, type_) else: col_expr = column if populate_result_map: add_to_result_map = self._add_to_result_map else: add_to_result_map = None if not within_columns_clause: result_expr = col_expr elif isinstance(column, elements.Label): if col_expr is not column: result_expr = _CompileLabel( col_expr, column.name, alt_names=(column.element,) ) else: result_expr = col_expr elif select is not None and name: result_expr = _CompileLabel( col_expr, name, alt_names=(column._key_label,) ) elif \ asfrom and \ isinstance(column, elements.ColumnClause) and \ not column.is_literal and \ column.table is not None and \ not isinstance(column.table, selectable.Select): result_expr = _CompileLabel(col_expr, elements._as_truncated(column.name), alt_names=(column.key,)) elif ( not isinstance(column, elements.TextClause) and ( not isinstance(column, elements.UnaryExpression) or column.wraps_column_expression ) and ( not hasattr(column, 'name') or isinstance(column, functions.Function) ) ): result_expr = _CompileLabel(col_expr, column.anon_label) elif col_expr is not column: # TODO: are we sure "column" has a .name and .key here ? # assert isinstance(column, elements.ColumnClause) result_expr = _CompileLabel(col_expr, elements._as_truncated(column.name), alt_names=(column.key,)) else: result_expr = col_expr column_clause_args.update( within_columns_clause=within_columns_clause, add_to_result_map=add_to_result_map ) return result_expr._compiler_dispatch( self, **column_clause_args ) def format_from_hint_text(self, sqltext, table, hint, iscrud): hinttext = self.get_from_hint_text(table, hint) if hinttext: sqltext += " " + hinttext return sqltext def get_select_hint_text(self, byfroms): return None def get_from_hint_text(self, table, text): return None def get_crud_hint_text(self, table, text): return None def get_statement_hint_text(self, hint_texts): return " ".join(hint_texts) def _transform_select_for_nested_joins(self, select): """Rewrite any "a JOIN (b JOIN c)" expression as "a JOIN (select * from b JOIN c) AS anon", to support databases that can't parse a parenthesized join correctly (i.e. sqlite < 3.7.16). """ cloned = {} column_translate = [{}] def visit(element, **kw): if element in column_translate[-1]: return column_translate[-1][element] elif element in cloned: return cloned[element] newelem = cloned[element] = element._clone() if newelem.is_selectable and newelem._is_join and \ isinstance(newelem.right, selectable.FromGrouping): newelem._reset_exported() newelem.left = visit(newelem.left, **kw) right = visit(newelem.right, **kw) selectable_ = selectable.Select( [right.element], use_labels=True).alias() for c in selectable_.c: c._key_label = c.key c._label = c.name translate_dict = dict( zip(newelem.right.element.c, selectable_.c) ) # translating from both the old and the new # because different select() structures will lead us # to traverse differently translate_dict[right.element.left] = selectable_ translate_dict[right.element.right] = selectable_ translate_dict[newelem.right.element.left] = selectable_ translate_dict[newelem.right.element.right] = selectable_ # propagate translations that we've gained # from nested visit(newelem.right) outwards # to the enclosing select here. this happens # only when we have more than one level of right # join nesting, i.e. "a JOIN (b JOIN (c JOIN d))" for k, v in list(column_translate[-1].items()): if v in translate_dict: # remarkably, no current ORM tests (May 2013) # hit this condition, only test_join_rewriting # does. column_translate[-1][k] = translate_dict[v] column_translate[-1].update(translate_dict) newelem.right = selectable_ newelem.onclause = visit(newelem.onclause, **kw) elif newelem._is_from_container: # if we hit an Alias, CompoundSelect or ScalarSelect, put a # marker in the stack. kw['transform_clue'] = 'select_container' newelem._copy_internals(clone=visit, **kw) elif newelem.is_selectable and newelem._is_select: barrier_select = kw.get('transform_clue', None) == \ 'select_container' # if we're still descended from an # Alias/CompoundSelect/ScalarSelect, we're # in a FROM clause, so start with a new translate collection if barrier_select: column_translate.append({}) kw['transform_clue'] = 'inside_select' newelem._copy_internals(clone=visit, **kw) if barrier_select: del column_translate[-1] else: newelem._copy_internals(clone=visit, **kw) return newelem return visit(select) def _transform_result_map_for_nested_joins( self, select, transformed_select): inner_col = dict((c._key_label, c) for c in transformed_select.inner_columns) d = dict( (inner_col[c._key_label], c) for c in select.inner_columns ) self._result_columns = [ (key, name, tuple([d.get(col, col) for col in objs]), typ) for key, name, objs, typ in self._result_columns ] _default_stack_entry = util.immutabledict([ ('correlate_froms', frozenset()), ('asfrom_froms', frozenset()) ]) def _display_froms_for_select(self, select, asfrom, lateral=False): # utility method to help external dialects # get the correct from list for a select. # specifically the oracle dialect needs this feature # right now. toplevel = not self.stack entry = self._default_stack_entry if toplevel else self.stack[-1] correlate_froms = entry['correlate_froms'] asfrom_froms = entry['asfrom_froms'] if asfrom and not lateral: froms = select._get_display_froms( explicit_correlate_froms=correlate_froms.difference( asfrom_froms), implicit_correlate_froms=()) else: froms = select._get_display_froms( explicit_correlate_froms=correlate_froms, implicit_correlate_froms=asfrom_froms) return froms def visit_select(self, select, asfrom=False, parens=True, fromhints=None, compound_index=0, nested_join_translation=False, select_wraps_for=None, lateral=False, **kwargs): needs_nested_translation = \ select.use_labels and \ not nested_join_translation and \ not self.stack and \ not self.dialect.supports_right_nested_joins if needs_nested_translation: transformed_select = self._transform_select_for_nested_joins( select) text = self.visit_select( transformed_select, asfrom=asfrom, parens=parens, fromhints=fromhints, compound_index=compound_index, nested_join_translation=True, **kwargs ) toplevel = not self.stack entry = self._default_stack_entry if toplevel else self.stack[-1] populate_result_map = toplevel or \ ( compound_index == 0 and entry.get( 'need_result_map_for_compound', False) ) or entry.get('need_result_map_for_nested', False) # this was first proposed as part of #3372; however, it is not # reached in current tests and could possibly be an assertion # instead. if not populate_result_map and 'add_to_result_map' in kwargs: del kwargs['add_to_result_map'] if needs_nested_translation: if populate_result_map: self._transform_result_map_for_nested_joins( select, transformed_select) return text froms = self._setup_select_stack(select, entry, asfrom, lateral) column_clause_args = kwargs.copy() column_clause_args.update({ 'within_label_clause': False, 'within_columns_clause': False }) text = "SELECT " # we're off to a good start ! if select._hints: hint_text, byfrom = self._setup_select_hints(select) if hint_text: text += hint_text + " " else: byfrom = None if select._prefixes: text += self._generate_prefixes( select, select._prefixes, **kwargs) text += self.get_select_precolumns(select, **kwargs) # the actual list of columns to print in the SELECT column list. inner_columns = [ c for c in [ self._label_select_column( select, column, populate_result_map, asfrom, column_clause_args, name=name) for name, column in select._columns_plus_names ] if c is not None ] if populate_result_map and select_wraps_for is not None: # if this select is a compiler-generated wrapper, # rewrite the targeted columns in the result map translate = dict( zip( [name for (key, name) in select._columns_plus_names], [name for (key, name) in select_wraps_for._columns_plus_names]) ) self._result_columns = [ (key, name, tuple(translate.get(o, o) for o in obj), type_) for key, name, obj, type_ in self._result_columns ] text = self._compose_select_body( text, select, inner_columns, froms, byfrom, kwargs) if select._statement_hints: per_dialect = [ ht for (dialect_name, ht) in select._statement_hints if dialect_name in ('*', self.dialect.name) ] if per_dialect: text += " " + self.get_statement_hint_text(per_dialect) if self.ctes and toplevel: text = self._render_cte_clause() + text if select._suffixes: text += " " + self._generate_prefixes( select, select._suffixes, **kwargs) self.stack.pop(-1) if (asfrom or lateral) and parens: return "(" + text + ")" else: return text def _setup_select_hints(self, select): byfrom = dict([ (from_, hinttext % { 'name': from_._compiler_dispatch( self, ashint=True) }) for (from_, dialect), hinttext in select._hints.items() if dialect in ('*', self.dialect.name) ]) hint_text = self.get_select_hint_text(byfrom) return hint_text, byfrom def _setup_select_stack(self, select, entry, asfrom, lateral): correlate_froms = entry['correlate_froms'] asfrom_froms = entry['asfrom_froms'] if asfrom and not lateral: froms = select._get_display_froms( explicit_correlate_froms=correlate_froms.difference( asfrom_froms), implicit_correlate_froms=()) else: froms = select._get_display_froms( explicit_correlate_froms=correlate_froms, implicit_correlate_froms=asfrom_froms) new_correlate_froms = set(selectable._from_objects(*froms)) all_correlate_froms = new_correlate_froms.union(correlate_froms) new_entry = { 'asfrom_froms': new_correlate_froms, 'correlate_froms': all_correlate_froms, 'selectable': select, } self.stack.append(new_entry) return froms def _compose_select_body( self, text, select, inner_columns, froms, byfrom, kwargs): text += ', '.join(inner_columns) if froms: text += " \nFROM " if select._hints: text += ', '.join( [f._compiler_dispatch(self, asfrom=True, fromhints=byfrom, **kwargs) for f in froms]) else: text += ', '.join( [f._compiler_dispatch(self, asfrom=True, **kwargs) for f in froms]) else: text += self.default_from() if select._whereclause is not None: t = select._whereclause._compiler_dispatch(self, **kwargs) if t: text += " \nWHERE " + t if select._group_by_clause.clauses: group_by = select._group_by_clause._compiler_dispatch( self, **kwargs) if group_by: text += " GROUP BY " + group_by if select._having is not None: t = select._having._compiler_dispatch(self, **kwargs) if t: text += " \nHAVING " + t if select._order_by_clause.clauses: text += self.order_by_clause(select, **kwargs) if (select._limit_clause is not None or select._offset_clause is not None): text += self.limit_clause(select, **kwargs) if select._for_update_arg is not None: text += self.for_update_clause(select, **kwargs) return text def _generate_prefixes(self, stmt, prefixes, **kw): clause = " ".join( prefix._compiler_dispatch(self, **kw) for prefix, dialect_name in prefixes if dialect_name is None or dialect_name == self.dialect.name ) if clause: clause += " " return clause def _render_cte_clause(self): if self.positional: self.positiontup = sum([ self.cte_positional[cte] for cte in self.ctes], []) + \ self.positiontup cte_text = self.get_cte_preamble(self.ctes_recursive) + " " cte_text += ", \n".join( [txt for txt in self.ctes.values()] ) cte_text += "\n " return cte_text def get_cte_preamble(self, recursive): if recursive: return "WITH RECURSIVE" else: return "WITH" def get_select_precolumns(self, select, **kw): """Called when building a ``SELECT`` statement, position is just before column list. """ return select._distinct and "DISTINCT " or "" def order_by_clause(self, select, **kw): order_by = select._order_by_clause._compiler_dispatch(self, **kw) if order_by: return " ORDER BY " + order_by else: return "" def for_update_clause(self, select, **kw): return " FOR UPDATE" def returning_clause(self, stmt, returning_cols): raise exc.CompileError( "RETURNING is not supported by this " "dialect's statement compiler.") def limit_clause(self, select, **kw): text = "" if select._limit_clause is not None: text += "\n LIMIT " + self.process(select._limit_clause, **kw) if select._offset_clause is not None: if select._limit_clause is None: text += "\n LIMIT -1" text += " OFFSET " + self.process(select._offset_clause, **kw) return text def visit_table(self, table, asfrom=False, iscrud=False, ashint=False, fromhints=None, use_schema=True, **kwargs): if asfrom or ashint: effective_schema = self.preparer.schema_for_object(table) if use_schema and effective_schema: ret = self.preparer.quote_schema(effective_schema) + \ "." + self.preparer.quote(table.name) else: ret = self.preparer.quote(table.name) if fromhints and table in fromhints: ret = self.format_from_hint_text(ret, table, fromhints[table], iscrud) return ret else: return "" def visit_join(self, join, asfrom=False, **kwargs): if join.full: join_type = " FULL OUTER JOIN " elif join.isouter: join_type = " LEFT OUTER JOIN " else: join_type = " JOIN " return ( join.left._compiler_dispatch(self, asfrom=True, **kwargs) + join_type + join.right._compiler_dispatch(self, asfrom=True, **kwargs) + " ON " + join.onclause._compiler_dispatch(self, **kwargs) ) def _setup_crud_hints(self, stmt, table_text): dialect_hints = dict([ (table, hint_text) for (table, dialect), hint_text in stmt._hints.items() if dialect in ('*', self.dialect.name) ]) if stmt.table in dialect_hints: table_text = self.format_from_hint_text( table_text, stmt.table, dialect_hints[stmt.table], True ) return dialect_hints, table_text def visit_insert(self, insert_stmt, asfrom=False, **kw): toplevel = not self.stack self.stack.append( {'correlate_froms': set(), "asfrom_froms": set(), "selectable": insert_stmt}) crud_params = crud._setup_crud_params( self, insert_stmt, crud.ISINSERT, **kw) if not crud_params and \ not self.dialect.supports_default_values and \ not self.dialect.supports_empty_insert: raise exc.CompileError("The '%s' dialect with current database " "version settings does not support empty " "inserts." % self.dialect.name) if insert_stmt._has_multi_parameters: if not self.dialect.supports_multivalues_insert: raise exc.CompileError( "The '%s' dialect with current database " "version settings does not support " "in-place multirow inserts." % self.dialect.name) crud_params_single = crud_params[0] else: crud_params_single = crud_params preparer = self.preparer supports_default_values = self.dialect.supports_default_values text = "INSERT " if insert_stmt._prefixes: text += self._generate_prefixes(insert_stmt, insert_stmt._prefixes, **kw) text += "INTO " table_text = preparer.format_table(insert_stmt.table) if insert_stmt._hints: dialect_hints, table_text = self._setup_crud_hints( insert_stmt, table_text) else: dialect_hints = None text += table_text if crud_params_single or not supports_default_values: text += " (%s)" % ', '.join([preparer.format_column(c[0]) for c in crud_params_single]) if self.returning or insert_stmt._returning: returning_clause = self.returning_clause( insert_stmt, self.returning or insert_stmt._returning) if self.returning_precedes_values: text += " " + returning_clause else: returning_clause = None if insert_stmt.select is not None: text += " %s" % self.process(self._insert_from_select, **kw) elif not crud_params and supports_default_values: text += " DEFAULT VALUES" elif insert_stmt._has_multi_parameters: text += " VALUES %s" % ( ", ".join( "(%s)" % ( ', '.join(c[1] for c in crud_param_set) ) for crud_param_set in crud_params ) ) else: text += " VALUES (%s)" % \ ', '.join([c[1] for c in crud_params]) if insert_stmt._post_values_clause is not None: post_values_clause = self.process( insert_stmt._post_values_clause, **kw) if post_values_clause: text += " " + post_values_clause if returning_clause and not self.returning_precedes_values: text += " " + returning_clause if self.ctes and toplevel: text = self._render_cte_clause() + text self.stack.pop(-1) if asfrom: return "(" + text + ")" else: return text def update_limit_clause(self, update_stmt): """Provide a hook for MySQL to add LIMIT to the UPDATE""" return None def update_tables_clause(self, update_stmt, from_table, extra_froms, **kw): """Provide a hook to override the initial table clause in an UPDATE statement. MySQL overrides this. """ kw['asfrom'] = True return from_table._compiler_dispatch(self, iscrud=True, **kw) def update_from_clause(self, update_stmt, from_table, extra_froms, from_hints, **kw): """Provide a hook to override the generation of an UPDATE..FROM clause. MySQL and MSSQL override this. """ return "FROM " + ', '.join( t._compiler_dispatch(self, asfrom=True, fromhints=from_hints, **kw) for t in extra_froms) def visit_update(self, update_stmt, asfrom=False, **kw): toplevel = not self.stack self.stack.append( {'correlate_froms': set([update_stmt.table]), "asfrom_froms": set([update_stmt.table]), "selectable": update_stmt}) extra_froms = update_stmt._extra_froms text = "UPDATE " if update_stmt._prefixes: text += self._generate_prefixes(update_stmt, update_stmt._prefixes, **kw) table_text = self.update_tables_clause(update_stmt, update_stmt.table, extra_froms, **kw) crud_params = crud._setup_crud_params( self, update_stmt, crud.ISUPDATE, **kw) if update_stmt._hints: dialect_hints, table_text = self._setup_crud_hints( update_stmt, table_text) else: dialect_hints = None text += table_text text += ' SET ' include_table = extra_froms and \ self.render_table_with_column_in_update_from text += ', '.join( c[0]._compiler_dispatch(self, include_table=include_table) + '=' + c[1] for c in crud_params ) if self.returning or update_stmt._returning: if self.returning_precedes_values: text += " " + self.returning_clause( update_stmt, self.returning or update_stmt._returning) if extra_froms: extra_from_text = self.update_from_clause( update_stmt, update_stmt.table, extra_froms, dialect_hints, **kw) if extra_from_text: text += " " + extra_from_text if update_stmt._whereclause is not None: t = self.process(update_stmt._whereclause, **kw) if t: text += " WHERE " + t limit_clause = self.update_limit_clause(update_stmt) if limit_clause: text += " " + limit_clause if (self.returning or update_stmt._returning) and \ not self.returning_precedes_values: text += " " + self.returning_clause( update_stmt, self.returning or update_stmt._returning) if self.ctes and toplevel: text = self._render_cte_clause() + text self.stack.pop(-1) if asfrom: return "(" + text + ")" else: return text @util.memoized_property def _key_getters_for_crud_column(self): return crud._key_getters_for_crud_column(self, self.statement) def visit_delete(self, delete_stmt, asfrom=False, **kw): toplevel = not self.stack self.stack.append({'correlate_froms': set([delete_stmt.table]), "asfrom_froms": set([delete_stmt.table]), "selectable": delete_stmt}) crud._setup_crud_params(self, delete_stmt, crud.ISDELETE, **kw) text = "DELETE " if delete_stmt._prefixes: text += self._generate_prefixes(delete_stmt, delete_stmt._prefixes, **kw) text += "FROM " table_text = delete_stmt.table._compiler_dispatch( self, asfrom=True, iscrud=True) if delete_stmt._hints: dialect_hints, table_text = self._setup_crud_hints( delete_stmt, table_text) text += table_text if delete_stmt._returning: if self.returning_precedes_values: text += " " + self.returning_clause( delete_stmt, delete_stmt._returning) if delete_stmt._whereclause is not None: t = delete_stmt._whereclause._compiler_dispatch(self, **kw) if t: text += " WHERE " + t if delete_stmt._returning and not self.returning_precedes_values: text += " " + self.returning_clause( delete_stmt, delete_stmt._returning) if self.ctes and toplevel: text = self._render_cte_clause() + text self.stack.pop(-1) if asfrom: return "(" + text + ")" else: return text def visit_savepoint(self, savepoint_stmt): return "SAVEPOINT %s" % self.preparer.format_savepoint(savepoint_stmt) def visit_rollback_to_savepoint(self, savepoint_stmt): return "ROLLBACK TO SAVEPOINT %s" % \ self.preparer.format_savepoint(savepoint_stmt) def visit_release_savepoint(self, savepoint_stmt): return "RELEASE SAVEPOINT %s" % \ self.preparer.format_savepoint(savepoint_stmt) class StrSQLCompiler(SQLCompiler): """"a compiler subclass with a few non-standard SQL features allowed. Used for stringification of SQL statements when a real dialect is not available. """ def _fallback_column_name(self, column): return "<name unknown>" def visit_getitem_binary(self, binary, operator, **kw): return "%s[%s]" % ( self.process(binary.left, **kw), self.process(binary.right, **kw) ) def visit_json_getitem_op_binary(self, binary, operator, **kw): return self.visit_getitem_binary(binary, operator, **kw) def visit_json_path_getitem_op_binary(self, binary, operator, **kw): return self.visit_getitem_binary(binary, operator, **kw) def returning_clause(self, stmt, returning_cols): columns = [ self._label_select_column(None, c, True, False, {}) for c in elements._select_iterables(returning_cols) ] return 'RETURNING ' + ', '.join(columns) class DDLCompiler(Compiled): @util.memoized_property def sql_compiler(self): return self.dialect.statement_compiler(self.dialect, None) @util.memoized_property def type_compiler(self): return self.dialect.type_compiler def construct_params(self, params=None): return None def visit_ddl(self, ddl, **kwargs): # table events can substitute table and schema name context = ddl.context if isinstance(ddl.target, schema.Table): context = context.copy() preparer = self.preparer path = preparer.format_table_seq(ddl.target) if len(path) == 1: table, sch = path[0], '' else: table, sch = path[-1], path[0] context.setdefault('table', table) context.setdefault('schema', sch) context.setdefault('fullname', preparer.format_table(ddl.target)) return self.sql_compiler.post_process_text(ddl.statement % context) def visit_create_schema(self, create): schema = self.preparer.format_schema(create.element) return "CREATE SCHEMA " + schema def visit_drop_schema(self, drop): schema = self.preparer.format_schema(drop.element) text = "DROP SCHEMA " + schema if drop.cascade: text += " CASCADE" return text def visit_create_table(self, create): table = create.element preparer = self.preparer text = "\nCREATE " if table._prefixes: text += " ".join(table._prefixes) + " " text += "TABLE " + preparer.format_table(table) + " " create_table_suffix = self.create_table_suffix(table) if create_table_suffix: text += create_table_suffix + " " text += "(" separator = "\n" # if only one primary key, specify it along with the column first_pk = False for create_column in create.columns: column = create_column.element try: processed = self.process(create_column, first_pk=column.primary_key and not first_pk) if processed is not None: text += separator separator = ", \n" text += "\t" + processed if column.primary_key: first_pk = True except exc.CompileError as ce: util.raise_from_cause( exc.CompileError( util.u("(in table '%s', column '%s'): %s") % (table.description, column.name, ce.args[0]) )) const = self.create_table_constraints( table, _include_foreign_key_constraints= # noqa create.include_foreign_key_constraints) if const: text += separator + "\t" + const text += "\n)%s\n\n" % self.post_create_table(table) return text def visit_create_column(self, create, first_pk=False): column = create.element if column.system: return None text = self.get_column_specification( column, first_pk=first_pk ) const = " ".join(self.process(constraint) for constraint in column.constraints) if const: text += " " + const return text def create_table_constraints( self, table, _include_foreign_key_constraints=None): # On some DB order is significant: visit PK first, then the # other constraints (engine.ReflectionTest.testbasic failed on FB2) constraints = [] if table.primary_key: constraints.append(table.primary_key) all_fkcs = table.foreign_key_constraints if _include_foreign_key_constraints is not None: omit_fkcs = all_fkcs.difference(_include_foreign_key_constraints) else: omit_fkcs = set() constraints.extend([c for c in table._sorted_constraints if c is not table.primary_key and c not in omit_fkcs]) return ", \n\t".join( p for p in (self.process(constraint) for constraint in constraints if ( constraint._create_rule is None or constraint._create_rule(self)) and ( not self.dialect.supports_alter or not getattr(constraint, 'use_alter', False) )) if p is not None ) def visit_drop_table(self, drop): return "\nDROP TABLE " + self.preparer.format_table(drop.element) def visit_drop_view(self, drop): return "\nDROP VIEW " + self.preparer.format_table(drop.element) def _verify_index_table(self, index): if index.table is None: raise exc.CompileError("Index '%s' is not associated " "with any table." % index.name) def visit_create_index(self, create, include_schema=False, include_table_schema=True): index = create.element self._verify_index_table(index) preparer = self.preparer text = "CREATE " if index.unique: text += "UNIQUE " text += "INDEX %s ON %s (%s)" \ % ( self._prepared_index_name(index, include_schema=include_schema), preparer.format_table(index.table, use_schema=include_table_schema), ', '.join( self.sql_compiler.process( expr, include_table=False, literal_binds=True) for expr in index.expressions) ) return text def visit_drop_index(self, drop): index = drop.element return "\nDROP INDEX " + self._prepared_index_name( index, include_schema=True) def _prepared_index_name(self, index, include_schema=False): if index.table is not None: effective_schema = self.preparer.schema_for_object(index.table) else: effective_schema = None if include_schema and effective_schema: schema_name = self.preparer.quote_schema(effective_schema) else: schema_name = None ident = index.name if isinstance(ident, elements._truncated_label): max_ = self.dialect.max_index_name_length or \ self.dialect.max_identifier_length if len(ident) > max_: ident = ident[0:max_ - 8] + \ "_" + util.md5_hex(ident)[-4:] else: self.dialect.validate_identifier(ident) index_name = self.preparer.quote(ident) if schema_name: index_name = schema_name + "." + index_name return index_name def visit_add_constraint(self, create): return "ALTER TABLE %s ADD %s" % ( self.preparer.format_table(create.element.table), self.process(create.element) ) def visit_create_sequence(self, create): text = "CREATE SEQUENCE %s" % \ self.preparer.format_sequence(create.element) if create.element.increment is not None: text += " INCREMENT BY %d" % create.element.increment if create.element.start is not None: text += " START WITH %d" % create.element.start if create.element.minvalue is not None: text += " MINVALUE %d" % create.element.minvalue if create.element.maxvalue is not None: text += " MAXVALUE %d" % create.element.maxvalue if create.element.nominvalue is not None: text += " NO MINVALUE" if create.element.nomaxvalue is not None: text += " NO MAXVALUE" if create.element.cycle is not None: text += " CYCLE" return text def visit_drop_sequence(self, drop): return "DROP SEQUENCE %s" % \ self.preparer.format_sequence(drop.element) def visit_drop_constraint(self, drop): constraint = drop.element if constraint.name is not None: formatted_name = self.preparer.format_constraint(constraint) else: formatted_name = None if formatted_name is None: raise exc.CompileError( "Can't emit DROP CONSTRAINT for constraint %r; " "it has no name" % drop.element) return "ALTER TABLE %s DROP CONSTRAINT %s%s" % ( self.preparer.format_table(drop.element.table), formatted_name, drop.cascade and " CASCADE" or "" ) def get_column_specification(self, column, **kwargs): colspec = self.preparer.format_column(column) + " " + \ self.dialect.type_compiler.process( column.type, type_expression=column) default = self.get_column_default_string(column) if default is not None: colspec += " DEFAULT " + default if not column.nullable: colspec += " NOT NULL" return colspec def create_table_suffix(self, table): return '' def post_create_table(self, table): return '' def get_column_default_string(self, column): if isinstance(column.server_default, schema.DefaultClause): if isinstance(column.server_default.arg, util.string_types): return self.sql_compiler.render_literal_value( column.server_default.arg, sqltypes.STRINGTYPE) else: return self.sql_compiler.process( column.server_default.arg, literal_binds=True) else: return None def visit_check_constraint(self, constraint): text = "" if constraint.name is not None: formatted_name = self.preparer.format_constraint(constraint) if formatted_name is not None: text += "CONSTRAINT %s " % formatted_name text += "CHECK (%s)" % self.sql_compiler.process(constraint.sqltext, include_table=False, literal_binds=True) text += self.define_constraint_deferrability(constraint) return text def visit_column_check_constraint(self, constraint): text = "" if constraint.name is not None: formatted_name = self.preparer.format_constraint(constraint) if formatted_name is not None: text += "CONSTRAINT %s " % formatted_name text += "CHECK (%s)" % constraint.sqltext text += self.define_constraint_deferrability(constraint) return text def visit_primary_key_constraint(self, constraint): if len(constraint) == 0: return '' text = "" if constraint.name is not None: formatted_name = self.preparer.format_constraint(constraint) if formatted_name is not None: text += "CONSTRAINT %s " % formatted_name text += "PRIMARY KEY " text += "(%s)" % ', '.join(self.preparer.quote(c.name) for c in (constraint.columns_autoinc_first if constraint._implicit_generated else constraint.columns)) text += self.define_constraint_deferrability(constraint) return text def visit_foreign_key_constraint(self, constraint): preparer = self.preparer text = "" if constraint.name is not None: formatted_name = self.preparer.format_constraint(constraint) if formatted_name is not None: text += "CONSTRAINT %s " % formatted_name remote_table = list(constraint.elements)[0].column.table text += "FOREIGN KEY(%s) REFERENCES %s (%s)" % ( ', '.join(preparer.quote(f.parent.name) for f in constraint.elements), self.define_constraint_remote_table( constraint, remote_table, preparer), ', '.join(preparer.quote(f.column.name) for f in constraint.elements) ) text += self.define_constraint_match(constraint) text += self.define_constraint_cascades(constraint) text += self.define_constraint_deferrability(constraint) return text def define_constraint_remote_table(self, constraint, table, preparer): """Format the remote table clause of a CREATE CONSTRAINT clause.""" return preparer.format_table(table) def visit_unique_constraint(self, constraint): if len(constraint) == 0: return '' text = "" if constraint.name is not None: formatted_name = self.preparer.format_constraint(constraint) text += "CONSTRAINT %s " % formatted_name text += "UNIQUE (%s)" % ( ', '.join(self.preparer.quote(c.name) for c in constraint)) text += self.define_constraint_deferrability(constraint) return text def define_constraint_cascades(self, constraint): text = "" if constraint.ondelete is not None: text += " ON DELETE %s" % constraint.ondelete if constraint.onupdate is not None: text += " ON UPDATE %s" % constraint.onupdate return text def define_constraint_deferrability(self, constraint): text = "" if constraint.deferrable is not None: if constraint.deferrable: text += " DEFERRABLE" else: text += " NOT DEFERRABLE" if constraint.initially is not None: text += " INITIALLY %s" % constraint.initially return text def define_constraint_match(self, constraint): text = "" if constraint.match is not None: text += " MATCH %s" % constraint.match return text class GenericTypeCompiler(TypeCompiler): def visit_FLOAT(self, type_, **kw): return "FLOAT" def visit_REAL(self, type_, **kw): return "REAL" def visit_NUMERIC(self, type_, **kw): if type_.precision is None: return "NUMERIC" elif type_.scale is None: return "NUMERIC(%(precision)s)" % \ {'precision': type_.precision} else: return "NUMERIC(%(precision)s, %(scale)s)" % \ {'precision': type_.precision, 'scale': type_.scale} def visit_DECIMAL(self, type_, **kw): if type_.precision is None: return "DECIMAL" elif type_.scale is None: return "DECIMAL(%(precision)s)" % \ {'precision': type_.precision} else: return "DECIMAL(%(precision)s, %(scale)s)" % \ {'precision': type_.precision, 'scale': type_.scale} def visit_INTEGER(self, type_, **kw): return "INTEGER" def visit_SMALLINT(self, type_, **kw): return "SMALLINT" def visit_BIGINT(self, type_, **kw): return "BIGINT" def visit_TIMESTAMP(self, type_, **kw): return 'TIMESTAMP' def visit_DATETIME(self, type_, **kw): return "DATETIME" def visit_DATE(self, type_, **kw): return "DATE" def visit_TIME(self, type_, **kw): return "TIME" def visit_CLOB(self, type_, **kw): return "CLOB" def visit_NCLOB(self, type_, **kw): return "NCLOB" def _render_string_type(self, type_, name): text = name if type_.length: text += "(%d)" % type_.length if type_.collation: text += ' COLLATE "%s"' % type_.collation return text def visit_CHAR(self, type_, **kw): return self._render_string_type(type_, "CHAR") def visit_NCHAR(self, type_, **kw): return self._render_string_type(type_, "NCHAR") def visit_VARCHAR(self, type_, **kw): return self._render_string_type(type_, "VARCHAR") def visit_NVARCHAR(self, type_, **kw): return self._render_string_type(type_, "NVARCHAR") def visit_TEXT(self, type_, **kw): return self._render_string_type(type_, "TEXT") def visit_BLOB(self, type_, **kw): return "BLOB" def visit_BINARY(self, type_, **kw): return "BINARY" + (type_.length and "(%d)" % type_.length or "") def visit_VARBINARY(self, type_, **kw): return "VARBINARY" + (type_.length and "(%d)" % type_.length or "") def visit_BOOLEAN(self, type_, **kw): return "BOOLEAN" def visit_large_binary(self, type_, **kw): return self.visit_BLOB(type_, **kw) def visit_boolean(self, type_, **kw): return self.visit_BOOLEAN(type_, **kw) def visit_time(self, type_, **kw): return self.visit_TIME(type_, **kw) def visit_datetime(self, type_, **kw): return self.visit_DATETIME(type_, **kw) def visit_date(self, type_, **kw): return self.visit_DATE(type_, **kw) def visit_big_integer(self, type_, **kw): return self.visit_BIGINT(type_, **kw) def visit_small_integer(self, type_, **kw): return self.visit_SMALLINT(type_, **kw) def visit_integer(self, type_, **kw): return self.visit_INTEGER(type_, **kw) def visit_real(self, type_, **kw): return self.visit_REAL(type_, **kw) def visit_float(self, type_, **kw): return self.visit_FLOAT(type_, **kw) def visit_numeric(self, type_, **kw): return self.visit_NUMERIC(type_, **kw) def visit_string(self, type_, **kw): return self.visit_VARCHAR(type_, **kw) def visit_unicode(self, type_, **kw): return self.visit_VARCHAR(type_, **kw) def visit_text(self, type_, **kw): return self.visit_TEXT(type_, **kw) def visit_unicode_text(self, type_, **kw): return self.visit_TEXT(type_, **kw) def visit_enum(self, type_, **kw): return self.visit_VARCHAR(type_, **kw) def visit_null(self, type_, **kw): raise exc.CompileError("Can't generate DDL for %r; " "did you forget to specify a " "type on this Column?" % type_) def visit_type_decorator(self, type_, **kw): return self.process(type_.type_engine(self.dialect), **kw) def visit_user_defined(self, type_, **kw): return type_.get_col_spec(**kw) class StrSQLTypeCompiler(GenericTypeCompiler): def __getattr__(self, key): if key.startswith("visit_"): return self._visit_unknown else: raise AttributeError(key) def _visit_unknown(self, type_, **kw): return "%s" % type_.__class__.__name__ class IdentifierPreparer(object): """Handle quoting and case-folding of identifiers based on options.""" reserved_words = RESERVED_WORDS legal_characters = LEGAL_CHARACTERS illegal_initial_characters = ILLEGAL_INITIAL_CHARACTERS schema_for_object = schema._schema_getter(None) def __init__(self, dialect, initial_quote='"', final_quote=None, escape_quote='"', omit_schema=False): """Construct a new ``IdentifierPreparer`` object. initial_quote Character that begins a delimited identifier. final_quote Character that ends a delimited identifier. Defaults to `initial_quote`. omit_schema Prevent prepending schema name. Useful for databases that do not support schemae. """ self.dialect = dialect self.initial_quote = initial_quote self.final_quote = final_quote or self.initial_quote self.escape_quote = escape_quote self.escape_to_quote = self.escape_quote * 2 self.omit_schema = omit_schema self._strings = {} def _with_schema_translate(self, schema_translate_map): prep = self.__class__.__new__(self.__class__) prep.__dict__.update(self.__dict__) prep.schema_for_object = schema._schema_getter(schema_translate_map) return prep def _escape_identifier(self, value): """Escape an identifier. Subclasses should override this to provide database-dependent escaping behavior. """ return value.replace(self.escape_quote, self.escape_to_quote) def _unescape_identifier(self, value): """Canonicalize an escaped identifier. Subclasses should override this to provide database-dependent unescaping behavior that reverses _escape_identifier. """ return value.replace(self.escape_to_quote, self.escape_quote) def quote_identifier(self, value): """Quote an identifier. Subclasses should override this to provide database-dependent quoting behavior. """ return self.initial_quote + \ self._escape_identifier(value) + \ self.final_quote def _requires_quotes(self, value): """Return True if the given identifier requires quoting.""" lc_value = value.lower() return (lc_value in self.reserved_words or value[0] in self.illegal_initial_characters or not self.legal_characters.match(util.text_type(value)) or (lc_value != value)) def quote_schema(self, schema, force=None): """Conditionally quote a schema. Subclasses can override this to provide database-dependent quoting behavior for schema names. the 'force' flag should be considered deprecated. """ return self.quote(schema, force) def quote(self, ident, force=None): """Conditionally quote an identifier. the 'force' flag should be considered deprecated. """ force = getattr(ident, "quote", None) if force is None: if ident in self._strings: return self._strings[ident] else: if self._requires_quotes(ident): self._strings[ident] = self.quote_identifier(ident) else: self._strings[ident] = ident return self._strings[ident] elif force: return self.quote_identifier(ident) else: return ident def format_sequence(self, sequence, use_schema=True): name = self.quote(sequence.name) effective_schema = self.schema_for_object(sequence) if (not self.omit_schema and use_schema and effective_schema is not None): name = self.quote_schema(effective_schema) + "." + name return name def format_label(self, label, name=None): return self.quote(name or label.name) def format_alias(self, alias, name=None): return self.quote(name or alias.name) def format_savepoint(self, savepoint, name=None): return self.quote(name or savepoint.ident) @util.dependencies("sqlalchemy.sql.naming") def format_constraint(self, naming, constraint): if isinstance(constraint.name, elements._defer_name): name = naming._constraint_name_for_table( constraint, constraint.table) if name: return self.quote(name) elif isinstance(constraint.name, elements._defer_none_name): return None return self.quote(constraint.name) def format_table(self, table, use_schema=True, name=None): """Prepare a quoted table and schema name.""" if name is None: name = table.name result = self.quote(name) effective_schema = self.schema_for_object(table) if not self.omit_schema and use_schema \ and effective_schema: result = self.quote_schema(effective_schema) + "." + result return result def format_schema(self, name, quote=None): """Prepare a quoted schema name.""" return self.quote(name, quote) def format_column(self, column, use_table=False, name=None, table_name=None): """Prepare a quoted column name.""" if name is None: name = column.name if not getattr(column, 'is_literal', False): if use_table: return self.format_table( column.table, use_schema=False, name=table_name) + "." + self.quote(name) else: return self.quote(name) else: # literal textual elements get stuck into ColumnClause a lot, # which shouldn't get quoted if use_table: return self.format_table( column.table, use_schema=False, name=table_name) + '.' + name else: return name def format_table_seq(self, table, use_schema=True): """Format table name and schema as a tuple.""" # Dialects with more levels in their fully qualified references # ('database', 'owner', etc.) could override this and return # a longer sequence. effective_schema = self.schema_for_object(table) if not self.omit_schema and use_schema and \ effective_schema: return (self.quote_schema(effective_schema), self.format_table(table, use_schema=False)) else: return (self.format_table(table, use_schema=False), ) @util.memoized_property def _r_identifiers(self): initial, final, escaped_final = \ [re.escape(s) for s in (self.initial_quote, self.final_quote, self._escape_identifier(self.final_quote))] r = re.compile( r'(?:' r'(?:%(initial)s((?:%(escaped)s|[^%(final)s])+)%(final)s' r'|([^\.]+))(?=\.|$))+' % {'initial': initial, 'final': final, 'escaped': escaped_final}) return r def unformat_identifiers(self, identifiers): """Unpack 'schema.table.column'-like strings into components.""" r = self._r_identifiers return [self._unescape_identifier(i) for i in [a or b for a, b in r.findall(identifiers)]]
mit
[ 3, 3875, 15, 5772, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 9261, 314, 14303, 11462, 436, 8417, 199, 3, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 14303, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 624, 1563, 5385, 436, 32078, 6365, 12591, 14, 199, 199, 15711, 2741, 2387, 26, 199, 199, 26, 533, 5026, 5772, 14, 4657, 9131, 64, 446, 3795, 83, 5385, 199, 5465, 199, 199, 26, 533, 5026, 5772, 14, 31868, 9131, 64, 446, 3795, 83, 32078, 199, 8, 576, 5492, 2637, 9, 3326, 199, 199, 26, 533, 5026, 5772, 14, 9417, 804, 9131, 64, 446, 3795, 83, 199, 466, 8929, 3326, 14, 199, 199, 1378, 3550, 922, 13, 4037, 5385, 3326, 12, 1937, 199, 26, 1301, 1705, 15, 832, 15, 5772, 2313, 199, 199, 624, 199, 199, 646, 15502, 199, 646, 295, 199, 504, 1275, 492, 4177, 12, 23111, 12, 10211, 12, 3423, 12, 5684, 1384, 12, 971, 272, 4008, 12, 23378, 12, 2467, 1181, 199, 504, 2508, 492, 4884, 12, 3178, 199, 646, 7975, 199, 199, 26933, 63, 19984, 275, 663, 779, 272, 283, 452, 297, 283, 26943, 297, 283, 21184, 297, 283, 460, 297, 283, 1629, 297, 283, 1144, 297, 272, 283, 305, 297, 283, 10125, 297, 283, 5660, 77, 5165, 297, 283, 15846, 297, 283, 13007, 297, 272, 283, 3008, 297, 283, 10727, 297, 283, 2546, 297, 283, 2931, 297, 283, 1074, 297, 283, 761, 750, 297, 272, 283, 2301, 297, 283, 5631, 297, 283, 981, 297, 283, 7925, 297, 283, 1818, 63, 602, 297, 272, 283, 1818, 63, 3756, 297, 283, 1818, 63, 521, 297, 283, 1818, 63, 3954, 297, 272, 283, 1818, 63, 751, 297, 283, 885, 297, 283, 11610, 6842, 297, 283, 3257, 297, 272, 283, 12926, 297, 283, 1117, 297, 283, 2836, 297, 283, 500, 297, 283, 2590, 297, 283, 3910, 297, 272, 283, 509, 297, 283, 6846, 297, 283, 18459, 297, 283, 504, 297, 283, 2861, 297, 283, 17362, 297, 272, 283, 923, 297, 283, 31569, 297, 283, 27774, 297, 283, 262, 297, 283, 2730, 9406, 297, 283, 5216, 297, 272, 283, 23149, 297, 283, 9924, 297, 283, 374, 297, 283, 15114, 297, 283, 904, 297, 283, 16812, 297, 272, 283, 3039, 297, 283, 2930, 297, 283, 3097, 297, 283, 15198, 297, 283, 1832, 3954, 297, 272, 283, 15759, 297, 283, 1222, 297, 283, 1397, 297, 283, 1397, 2307, 297, 283, 2307, 297, 283, 1997, 297, 283, 2743, 297, 272, 283, 1753, 297, 283, 265, 297, 283, 2118, 297, 283, 269, 297, 283, 1648, 297, 283, 7837, 297, 283, 20798, 297, 272, 283, 80, 13121, 297, 283, 3327, 297, 283, 12635, 297, 283, 1019, 297, 283, 2416, 297, 272, 283, 1730, 63, 751, 297, 283, 409, 297, 283, 23079, 297, 283, 3972, 297, 283, 18422, 297, 283, 1224, 297, 272, 283, 12726, 297, 283, 475, 297, 283, 15910, 297, 283, 2052, 297, 283, 8888, 297, 283, 3235, 297, 283, 751, 297, 272, 283, 4941, 297, 283, 3832, 297, 283, 6526, 297, 283, 4509, 1105, 199, 199, 25086, 748, 63, 5901, 3036, 3960, 275, 295, 14, 2014, 8, 82, 23811, 33, 13, 58, 16, 13, 25, 63, 4, 2807, 4268, 295, 14, 41, 9, 199, 1193, 25086, 748, 63, 13768, 63, 5901, 3036, 3960, 275, 663, 779, 495, 8, 88, 9, 367, 671, 315, 1425, 8, 16, 12, 1616, 3948, 14, 8888, 2941, 4, 1105, 199, 199, 15585, 63, 17978, 275, 295, 14, 2014, 8, 82, 10120, 11230, 1491, 60, 87, 60, 16827, 88, 21, 67, 4682, 16510, 87, 60, 4, 11896, 26313, 1491, 60, 87, 60, 4, 22206, 295, 14, 12819, 9, 199, 15585, 63, 17978, 63, 654, 35, 275, 295, 14, 2014, 8, 82, 1154, 88, 21, 67, 8, 26, 7023, 87, 60, 4, 3672, 18168, 1, 1491, 60, 87, 60, 4, 22206, 295, 14, 12819, 9, 199, 199, 15585, 63, 25437, 275, 469, 272, 283, 647, 908, 356, 2071, 2840, 2840, 354, 9, 83, 9, 83, 401, 272, 283, 81, 1657, 356, 298, 15583, 272, 283, 908, 356, 2071, 5, 83, 401, 272, 283, 6677, 356, 7244, 13040, 15717, 11472, 272, 283, 4579, 356, 298, 19648, 354, 9, 83, 2, 199, 93, 421, 199, 15598, 19033, 275, 469, 272, 327, 3366, 272, 10211, 14, 460, 10388, 283, 2401, 1656, 272, 10211, 14, 269, 10388, 283, 1549, 1656, 272, 10211, 14, 525, 26, 283, 435, 1656, 272, 10211, 14, 3703, 26, 283, 627, 1656, 272, 10211, 14, 954, 26, 283, 446, 1656, 272, 10211, 14, 3015, 26, 283, 1182, 1656, 272, 10211, 14, 1494, 26, 283, 450, 1656, 272, 10211, 14, 22062, 26, 283, 1182, 1656, 272, 10211, 14, 8705, 26, 17525, 272, 10211, 14, 4116, 26, 283, 665, 1656, 272, 10211, 14, 274, 26, 283, 2695, 1656, 272, 10211, 14, 685, 26, 283, 1137, 1656, 272, 10211, 14, 3308, 26, 283, 690, 1656, 272, 10211, 14, 303, 26, 283, 2356, 1656, 272, 10211, 14, 4077, 26, 283, 275, 1656, 272, 10211, 14, 374, 63, 12926, 63, 504, 26, 283, 2281, 28424, 28437, 4442, 1656, 272, 10211, 14, 374, 1397, 63, 12926, 63, 504, 26, 283, 2281, 2845, 28424, 28437, 4442, 1656, 272, 10211, 14, 9419, 63, 411, 26, 283, 12208, 1656, 272, 10211, 14, 1431, 63, 411, 26, 283, 603, 8078, 1656, 272, 10211, 14, 1397, 1431, 63, 411, 26, 283, 2845, 603, 8078, 1656, 272, 10211, 14, 262, 63, 411, 26, 283, 1621, 1656, 272, 10211, 14, 1397, 262, 63, 411, 26, 283, 2845, 1621, 1656, 272, 10211, 14, 13184, 63, 411, 26, 1656, 1656, 272, 10211, 14, 504, 10388, 283, 4442, 1656, 272, 10211, 14, 305, 10388, 283, 4319, 1656, 272, 10211, 14, 374, 10388, 283, 2281, 1656, 272, 10211, 14, 374, 1397, 26, 283, 2281, 2845, 1656, 272, 10211, 14, 761, 750, 26, 283, 13513, 30064, 1656, 339, 327, 21603, 272, 10211, 14, 2444, 26, 283, 23558, 1656, 272, 10211, 14, 12926, 63, 411, 26, 283, 13783, 28437, 1656, 272, 10211, 14, 5350, 26, 283, 4609, 1656, 272, 10211, 14, 1629, 63, 411, 26, 283, 8974, 1656, 272, 10211 ]
[ 3875, 15, 5772, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 9261, 314, 14303, 11462, 436, 8417, 199, 3, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 14303, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 624, 1563, 5385, 436, 32078, 6365, 12591, 14, 199, 199, 15711, 2741, 2387, 26, 199, 199, 26, 533, 5026, 5772, 14, 4657, 9131, 64, 446, 3795, 83, 5385, 199, 5465, 199, 199, 26, 533, 5026, 5772, 14, 31868, 9131, 64, 446, 3795, 83, 32078, 199, 8, 576, 5492, 2637, 9, 3326, 199, 199, 26, 533, 5026, 5772, 14, 9417, 804, 9131, 64, 446, 3795, 83, 199, 466, 8929, 3326, 14, 199, 199, 1378, 3550, 922, 13, 4037, 5385, 3326, 12, 1937, 199, 26, 1301, 1705, 15, 832, 15, 5772, 2313, 199, 199, 624, 199, 199, 646, 15502, 199, 646, 295, 199, 504, 1275, 492, 4177, 12, 23111, 12, 10211, 12, 3423, 12, 5684, 1384, 12, 971, 272, 4008, 12, 23378, 12, 2467, 1181, 199, 504, 2508, 492, 4884, 12, 3178, 199, 646, 7975, 199, 199, 26933, 63, 19984, 275, 663, 779, 272, 283, 452, 297, 283, 26943, 297, 283, 21184, 297, 283, 460, 297, 283, 1629, 297, 283, 1144, 297, 272, 283, 305, 297, 283, 10125, 297, 283, 5660, 77, 5165, 297, 283, 15846, 297, 283, 13007, 297, 272, 283, 3008, 297, 283, 10727, 297, 283, 2546, 297, 283, 2931, 297, 283, 1074, 297, 283, 761, 750, 297, 272, 283, 2301, 297, 283, 5631, 297, 283, 981, 297, 283, 7925, 297, 283, 1818, 63, 602, 297, 272, 283, 1818, 63, 3756, 297, 283, 1818, 63, 521, 297, 283, 1818, 63, 3954, 297, 272, 283, 1818, 63, 751, 297, 283, 885, 297, 283, 11610, 6842, 297, 283, 3257, 297, 272, 283, 12926, 297, 283, 1117, 297, 283, 2836, 297, 283, 500, 297, 283, 2590, 297, 283, 3910, 297, 272, 283, 509, 297, 283, 6846, 297, 283, 18459, 297, 283, 504, 297, 283, 2861, 297, 283, 17362, 297, 272, 283, 923, 297, 283, 31569, 297, 283, 27774, 297, 283, 262, 297, 283, 2730, 9406, 297, 283, 5216, 297, 272, 283, 23149, 297, 283, 9924, 297, 283, 374, 297, 283, 15114, 297, 283, 904, 297, 283, 16812, 297, 272, 283, 3039, 297, 283, 2930, 297, 283, 3097, 297, 283, 15198, 297, 283, 1832, 3954, 297, 272, 283, 15759, 297, 283, 1222, 297, 283, 1397, 297, 283, 1397, 2307, 297, 283, 2307, 297, 283, 1997, 297, 283, 2743, 297, 272, 283, 1753, 297, 283, 265, 297, 283, 2118, 297, 283, 269, 297, 283, 1648, 297, 283, 7837, 297, 283, 20798, 297, 272, 283, 80, 13121, 297, 283, 3327, 297, 283, 12635, 297, 283, 1019, 297, 283, 2416, 297, 272, 283, 1730, 63, 751, 297, 283, 409, 297, 283, 23079, 297, 283, 3972, 297, 283, 18422, 297, 283, 1224, 297, 272, 283, 12726, 297, 283, 475, 297, 283, 15910, 297, 283, 2052, 297, 283, 8888, 297, 283, 3235, 297, 283, 751, 297, 272, 283, 4941, 297, 283, 3832, 297, 283, 6526, 297, 283, 4509, 1105, 199, 199, 25086, 748, 63, 5901, 3036, 3960, 275, 295, 14, 2014, 8, 82, 23811, 33, 13, 58, 16, 13, 25, 63, 4, 2807, 4268, 295, 14, 41, 9, 199, 1193, 25086, 748, 63, 13768, 63, 5901, 3036, 3960, 275, 663, 779, 495, 8, 88, 9, 367, 671, 315, 1425, 8, 16, 12, 1616, 3948, 14, 8888, 2941, 4, 1105, 199, 199, 15585, 63, 17978, 275, 295, 14, 2014, 8, 82, 10120, 11230, 1491, 60, 87, 60, 16827, 88, 21, 67, 4682, 16510, 87, 60, 4, 11896, 26313, 1491, 60, 87, 60, 4, 22206, 295, 14, 12819, 9, 199, 15585, 63, 17978, 63, 654, 35, 275, 295, 14, 2014, 8, 82, 1154, 88, 21, 67, 8, 26, 7023, 87, 60, 4, 3672, 18168, 1, 1491, 60, 87, 60, 4, 22206, 295, 14, 12819, 9, 199, 199, 15585, 63, 25437, 275, 469, 272, 283, 647, 908, 356, 2071, 2840, 2840, 354, 9, 83, 9, 83, 401, 272, 283, 81, 1657, 356, 298, 15583, 272, 283, 908, 356, 2071, 5, 83, 401, 272, 283, 6677, 356, 7244, 13040, 15717, 11472, 272, 283, 4579, 356, 298, 19648, 354, 9, 83, 2, 199, 93, 421, 199, 15598, 19033, 275, 469, 272, 327, 3366, 272, 10211, 14, 460, 10388, 283, 2401, 1656, 272, 10211, 14, 269, 10388, 283, 1549, 1656, 272, 10211, 14, 525, 26, 283, 435, 1656, 272, 10211, 14, 3703, 26, 283, 627, 1656, 272, 10211, 14, 954, 26, 283, 446, 1656, 272, 10211, 14, 3015, 26, 283, 1182, 1656, 272, 10211, 14, 1494, 26, 283, 450, 1656, 272, 10211, 14, 22062, 26, 283, 1182, 1656, 272, 10211, 14, 8705, 26, 17525, 272, 10211, 14, 4116, 26, 283, 665, 1656, 272, 10211, 14, 274, 26, 283, 2695, 1656, 272, 10211, 14, 685, 26, 283, 1137, 1656, 272, 10211, 14, 3308, 26, 283, 690, 1656, 272, 10211, 14, 303, 26, 283, 2356, 1656, 272, 10211, 14, 4077, 26, 283, 275, 1656, 272, 10211, 14, 374, 63, 12926, 63, 504, 26, 283, 2281, 28424, 28437, 4442, 1656, 272, 10211, 14, 374, 1397, 63, 12926, 63, 504, 26, 283, 2281, 2845, 28424, 28437, 4442, 1656, 272, 10211, 14, 9419, 63, 411, 26, 283, 12208, 1656, 272, 10211, 14, 1431, 63, 411, 26, 283, 603, 8078, 1656, 272, 10211, 14, 1397, 1431, 63, 411, 26, 283, 2845, 603, 8078, 1656, 272, 10211, 14, 262, 63, 411, 26, 283, 1621, 1656, 272, 10211, 14, 1397, 262, 63, 411, 26, 283, 2845, 1621, 1656, 272, 10211, 14, 13184, 63, 411, 26, 1656, 1656, 272, 10211, 14, 504, 10388, 283, 4442, 1656, 272, 10211, 14, 305, 10388, 283, 4319, 1656, 272, 10211, 14, 374, 10388, 283, 2281, 1656, 272, 10211, 14, 374, 1397, 26, 283, 2281, 2845, 1656, 272, 10211, 14, 761, 750, 26, 283, 13513, 30064, 1656, 339, 327, 21603, 272, 10211, 14, 2444, 26, 283, 23558, 1656, 272, 10211, 14, 12926, 63, 411, 26, 283, 13783, 28437, 1656, 272, 10211, 14, 5350, 26, 283, 4609, 1656, 272, 10211, 14, 1629, 63, 411, 26, 283, 8974, 1656, 272, 10211, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
cernops/nova
nova/db/sqlalchemy/migrate_repo/versions/315_add_migration_progresss_detail.py
26
1230
# 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 sqlalchemy import BigInteger from sqlalchemy import Column from sqlalchemy import MetaData from sqlalchemy import Table def upgrade(migrate_engine): meta = MetaData(bind=migrate_engine) migrations = Table('migrations', meta, autoload=True) shadow_migrations = Table('shadow_migrations', meta, autoload=True) columns = ['memory_total', 'memory_processed', 'memory_remaining', 'disk_total', 'disk_processed', 'disk_remaining'] for column_name in columns: column = Column(column_name, BigInteger, nullable=True) migrations.create_column(column) shadow_migrations.create_column(column.copy())
apache-2.0
[ 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, 421, 199, 504, 8335, 492, 13123, 2674, 199, 504, 8335, 492, 4996, 199, 504, 8335, 492, 24905, 199, 504, 8335, 492, 6957, 421, 199, 318, 10754, 8, 8462, 63, 3908, 304, 272, 3404, 275, 24905, 8, 3409, 29, 8462, 63, 3908, 9, 272, 6180, 275, 6957, 360, 7685, 297, 3404, 12, 2599, 912, 29, 549, 9, 272, 15084, 63, 7685, 275, 6957, 360, 14714, 63, 7685, 297, 3404, 12, 2599, 912, 29, 549, 9, 339, 4362, 275, 788, 4844, 63, 2923, 297, 283, 4844, 63, 7292, 297, 283, 4844, 63, 11266, 297, 2049, 283, 4032, 63, 2923, 297, 283, 4032, 63, 7292, 297, 283, 4032, 63, 11266, 418, 272, 367, 2763, 63, 354, 315, 4362, 26, 267, 2763, 275, 4996, 8, 2301, 63, 354, 12, 13123, 2674, 12, 7854, 29, 549, 9, 267, 6180, 14, 981, 63, 2301, 8, 2301, 9, 267, 15084, 63, 7685, 14, 981, 63, 2301, 8, 2301, 14, 1574, 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 ]
[ 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, 421, 199, 504, 8335, 492, 13123, 2674, 199, 504, 8335, 492, 4996, 199, 504, 8335, 492, 24905, 199, 504, 8335, 492, 6957, 421, 199, 318, 10754, 8, 8462, 63, 3908, 304, 272, 3404, 275, 24905, 8, 3409, 29, 8462, 63, 3908, 9, 272, 6180, 275, 6957, 360, 7685, 297, 3404, 12, 2599, 912, 29, 549, 9, 272, 15084, 63, 7685, 275, 6957, 360, 14714, 63, 7685, 297, 3404, 12, 2599, 912, 29, 549, 9, 339, 4362, 275, 788, 4844, 63, 2923, 297, 283, 4844, 63, 7292, 297, 283, 4844, 63, 11266, 297, 2049, 283, 4032, 63, 2923, 297, 283, 4032, 63, 7292, 297, 283, 4032, 63, 11266, 418, 272, 367, 2763, 63, 354, 315, 4362, 26, 267, 2763, 275, 4996, 8, 2301, 63, 354, 12, 13123, 2674, 12, 7854, 29, 549, 9, 267, 6180, 14, 981, 63, 2301, 8, 2301, 9, 267, 15084, 63, 7685, 14, 981, 63, 2301, 8, 2301, 14, 1574, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
barbarubra/Don-t-know-What-i-m-doing.
python/src/Lib/test/test_gettext.py
58
17536
import os import base64 import shutil import gettext import unittest from test import test_support # TODO: # - Add new tests, for example for "dgettext" # - Remove dummy tests, for example testing for single and double quotes # has no sense, it would have if we were testing a parser (i.e. pygettext) # - Tests should have only one assert. GNU_MO_DATA = '''\ 3hIElQAAAAAGAAAAHAAAAEwAAAALAAAAfAAAAAAAAACoAAAAFQAAAKkAAAAjAAAAvwAAAKEAAADj AAAABwAAAIUBAAALAAAAjQEAAEUBAACZAQAAFgAAAN8CAAAeAAAA9gIAAKEAAAAVAwAABQAAALcD AAAJAAAAvQMAAAEAAAADAAAAAAAAAAAAAAAA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jb2Rpbmc6IHF1b3RlZC1wcmludGFi bGUKR2VuZXJhdGVkLUJ5OiBweWdldHRleHQucHkgMS4zCgA= ''' LOCALEDIR = os.path.join('xx', 'LC_MESSAGES') MOFILE = os.path.join(LOCALEDIR, 'gettext.mo') UMOFILE = os.path.join(LOCALEDIR, 'ugettext.mo') MMOFILE = os.path.join(LOCALEDIR, 'metadata.mo') try: LANG = os.environ['LANGUAGE'] except: LANG = 'en' class GettextBaseTest(unittest.TestCase): def setUp(self): if not os.path.isdir(LOCALEDIR): os.makedirs(LOCALEDIR) fp = open(MOFILE, 'wb') fp.write(base64.decodestring(GNU_MO_DATA)) fp.close() fp = open(UMOFILE, 'wb') fp.write(base64.decodestring(UMO_DATA)) fp.close() fp = open(MMOFILE, 'wb') fp.write(base64.decodestring(MMO_DATA)) fp.close() os.environ['LANGUAGE'] = 'xx' def tearDown(self): os.environ['LANGUAGE'] = LANG shutil.rmtree(os.path.split(LOCALEDIR)[0]) class GettextTestCase1(GettextBaseTest): def setUp(self): GettextBaseTest.setUp(self) self.localedir = os.curdir self.mofile = MOFILE gettext.install('gettext', self.localedir) def test_some_translations(self): eq = self.assertEqual # test some translations eq(_('albatross'), 'albatross') eq(_(u'mullusk'), 'bacon') eq(_(r'Raymond Luxury Yach-t'), 'Throatwobbler Mangrove') eq(_(ur'nudge nudge'), 'wink wink') def test_double_quotes(self): eq = self.assertEqual # double quotes eq(_("albatross"), 'albatross') eq(_(u"mullusk"), 'bacon') eq(_(r"Raymond Luxury Yach-t"), 'Throatwobbler Mangrove') eq(_(ur"nudge nudge"), 'wink wink') def test_triple_single_quotes(self): eq = self.assertEqual # triple single quotes eq(_('''albatross'''), 'albatross') eq(_(u'''mullusk'''), 'bacon') eq(_(r'''Raymond Luxury Yach-t'''), 'Throatwobbler Mangrove') eq(_(ur'''nudge nudge'''), 'wink wink') def test_triple_double_quotes(self): eq = self.assertEqual # triple double quotes eq(_("""albatross"""), 'albatross') eq(_(u"""mullusk"""), 'bacon') eq(_(r"""Raymond Luxury Yach-t"""), 'Throatwobbler Mangrove') eq(_(ur"""nudge nudge"""), 'wink wink') def test_multiline_strings(self): eq = self.assertEqual # multiline strings eq(_('''This module provides internationalization and localization support for your Python programs by providing an interface to the GNU gettext message catalog library.'''), '''Guvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH trggrkg zrffntr pngnybt yvoenel.''') def test_the_alternative_interface(self): eq = self.assertEqual # test the alternative interface fp = open(self.mofile, 'rb') t = gettext.GNUTranslations(fp) fp.close() # Install the translation object t.install() eq(_('nudge nudge'), 'wink wink') # Try unicode return type t.install(unicode=True) eq(_('mullusk'), 'bacon') # Test installation of other methods import __builtin__ t.install(unicode=True, names=["gettext", "lgettext"]) eq(_, t.ugettext) eq(__builtin__.gettext, t.ugettext) eq(lgettext, t.lgettext) del __builtin__.gettext del __builtin__.lgettext class GettextTestCase2(GettextBaseTest): def setUp(self): GettextBaseTest.setUp(self) self.localedir = os.curdir # Set up the bindings gettext.bindtextdomain('gettext', self.localedir) gettext.textdomain('gettext') # For convenience self._ = gettext.gettext def test_bindtextdomain(self): self.assertEqual(gettext.bindtextdomain('gettext'), self.localedir) def test_textdomain(self): self.assertEqual(gettext.textdomain(), 'gettext') def test_some_translations(self): eq = self.assertEqual # test some translations eq(self._('albatross'), 'albatross') eq(self._(u'mullusk'), 'bacon') eq(self._(r'Raymond Luxury Yach-t'), 'Throatwobbler Mangrove') eq(self._(ur'nudge nudge'), 'wink wink') def test_double_quotes(self): eq = self.assertEqual # double quotes eq(self._("albatross"), 'albatross') eq(self._(u"mullusk"), 'bacon') eq(self._(r"Raymond Luxury Yach-t"), 'Throatwobbler Mangrove') eq(self._(ur"nudge nudge"), 'wink wink') def test_triple_single_quotes(self): eq = self.assertEqual # triple single quotes eq(self._('''albatross'''), 'albatross') eq(self._(u'''mullusk'''), 'bacon') eq(self._(r'''Raymond Luxury Yach-t'''), 'Throatwobbler Mangrove') eq(self._(ur'''nudge nudge'''), 'wink wink') def test_triple_double_quotes(self): eq = self.assertEqual # triple double quotes eq(self._("""albatross"""), 'albatross') eq(self._(u"""mullusk"""), 'bacon') eq(self._(r"""Raymond Luxury Yach-t"""), 'Throatwobbler Mangrove') eq(self._(ur"""nudge nudge"""), 'wink wink') def test_multiline_strings(self): eq = self.assertEqual # multiline strings eq(self._('''This module provides internationalization and localization support for your Python programs by providing an interface to the GNU gettext message catalog library.'''), '''Guvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH trggrkg zrffntr pngnybt yvoenel.''') class PluralFormsTestCase(GettextBaseTest): def setUp(self): GettextBaseTest.setUp(self) self.mofile = MOFILE def test_plural_forms1(self): eq = self.assertEqual x = gettext.ngettext('There is %s file', 'There are %s files', 1) eq(x, 'Hay %s fichero') x = gettext.ngettext('There is %s file', 'There are %s files', 2) eq(x, 'Hay %s ficheros') def test_plural_forms2(self): eq = self.assertEqual fp = open(self.mofile, 'rb') t = gettext.GNUTranslations(fp) fp.close() x = t.ngettext('There is %s file', 'There are %s files', 1) eq(x, 'Hay %s fichero') x = t.ngettext('There is %s file', 'There are %s files', 2) eq(x, 'Hay %s ficheros') def test_hu(self): eq = self.assertEqual f = gettext.c2py('0') s = ''.join([ str(f(x)) for x in range(200) ]) eq(s, "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") def test_de(self): eq = self.assertEqual f = gettext.c2py('n != 1') s = ''.join([ str(f(x)) for x in range(200) ]) eq(s, "10111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111") def test_fr(self): eq = self.assertEqual f = gettext.c2py('n>1') s = ''.join([ str(f(x)) for x in range(200) ]) eq(s, "00111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111") def test_gd(self): eq = self.assertEqual f = gettext.c2py('n==1 ? 0 : n==2 ? 1 : 2') s = ''.join([ str(f(x)) for x in range(200) ]) eq(s, "20122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222") def test_gd2(self): eq = self.assertEqual # Tests the combination of parentheses and "?:" f = gettext.c2py('n==1 ? 0 : (n==2 ? 1 : 2)') s = ''.join([ str(f(x)) for x in range(200) ]) eq(s, "20122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222") def test_lt(self): eq = self.assertEqual f = gettext.c2py('n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2') s = ''.join([ str(f(x)) for x in range(200) ]) eq(s, "20111111112222222222201111111120111111112011111111201111111120111111112011111111201111111120111111112011111111222222222220111111112011111111201111111120111111112011111111201111111120111111112011111111") def test_ru(self): eq = self.assertEqual f = gettext.c2py('n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2') s = ''.join([ str(f(x)) for x in range(200) ]) eq(s, "20111222222222222222201112222220111222222011122222201112222220111222222011122222201112222220111222222011122222222222222220111222222011122222201112222220111222222011122222201112222220111222222011122222") def test_pl(self): eq = self.assertEqual f = gettext.c2py('n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2') s = ''.join([ str(f(x)) for x in range(200) ]) eq(s, "20111222222222222222221112222222111222222211122222221112222222111222222211122222221112222222111222222211122222222222222222111222222211122222221112222222111222222211122222221112222222111222222211122222") def test_sl(self): eq = self.assertEqual f = gettext.c2py('n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3') s = ''.join([ str(f(x)) for x in range(200) ]) eq(s, "30122333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333012233333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333") def test_security(self): raises = self.assertRaises # Test for a dangerous expression raises(ValueError, gettext.c2py, "os.chmod('/etc/passwd',0777)") class UnicodeTranslationsTest(GettextBaseTest): def setUp(self): GettextBaseTest.setUp(self) fp = open(UMOFILE, 'rb') try: self.t = gettext.GNUTranslations(fp) finally: fp.close() self._ = self.t.ugettext def test_unicode_msgid(self): unless = self.failUnless unless(isinstance(self._(''), unicode)) unless(isinstance(self._(u''), unicode)) def test_unicode_msgstr(self): eq = self.assertEqual eq(self._(u'ab\xde'), u'\xa4yz') class WeirdMetadataTest(GettextBaseTest): def setUp(self): GettextBaseTest.setUp(self) fp = open(MMOFILE, 'rb') try: try: self.t = gettext.GNUTranslations(fp) except: self.tearDown() raise finally: fp.close() def test_weird_metadata(self): info = self.t.info() self.assertEqual(info['last-translator'], 'John Doe <jdoe@example.com>\nJane Foobar <jfoobar@example.com>') def test_main(): test_support.run_unittest(__name__) if __name__ == '__main__': test_main() # For reference, here's the .po file used to created the GNU_MO_DATA above. # # The original version was automatically generated from the sources with # pygettext. Later it was manually modified to add plural forms support. ''' # Dummy translation for the Python test_gettext.py module. # Copyright (C) 2001 Python Software Foundation # Barry Warsaw <barry@python.org>, 2000. # msgid "" msgstr "" "Project-Id-Version: 2.0\n" "PO-Revision-Date: 2003-04-11 14:32-0400\n" "Last-Translator: J. David Ibanez <j-david@noos.fr>\n" "Language-Team: XX <python-dev@python.org>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=iso-8859-1\n" "Content-Transfer-Encoding: 8bit\n" "Generated-By: pygettext.py 1.1\n" "Plural-Forms: nplurals=2; plural=n!=1;\n" #: test_gettext.py:19 test_gettext.py:25 test_gettext.py:31 test_gettext.py:37 #: test_gettext.py:51 test_gettext.py:80 test_gettext.py:86 test_gettext.py:92 #: test_gettext.py:98 msgid "nudge nudge" msgstr "wink wink" #: test_gettext.py:16 test_gettext.py:22 test_gettext.py:28 test_gettext.py:34 #: test_gettext.py:77 test_gettext.py:83 test_gettext.py:89 test_gettext.py:95 msgid "albatross" msgstr "" #: test_gettext.py:18 test_gettext.py:24 test_gettext.py:30 test_gettext.py:36 #: test_gettext.py:79 test_gettext.py:85 test_gettext.py:91 test_gettext.py:97 msgid "Raymond Luxury Yach-t" msgstr "Throatwobbler Mangrove" #: test_gettext.py:17 test_gettext.py:23 test_gettext.py:29 test_gettext.py:35 #: test_gettext.py:56 test_gettext.py:78 test_gettext.py:84 test_gettext.py:90 #: test_gettext.py:96 msgid "mullusk" msgstr "bacon" #: test_gettext.py:40 test_gettext.py:101 msgid "" "This module provides internationalization and localization\n" "support for your Python programs by providing an interface to the GNU\n" "gettext message catalog library." msgstr "" "Guvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba\n" "fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH\n" "trggrkg zrffntr pngnybt yvoenel." # Manually added, as neither pygettext nor xgettext support plural forms # in Python. msgid "There is %s file" msgid_plural "There are %s files" msgstr[0] "Hay %s fichero" msgstr[1] "Hay %s ficheros" ''' # Here's the second example po file example, used to generate the UMO_DATA # containing utf-8 encoded Unicode strings ''' # Dummy translation for the Python test_gettext.py module. # Copyright (C) 2001 Python Software Foundation # Barry Warsaw <barry@python.org>, 2000. # msgid "" msgstr "" "Project-Id-Version: 2.0\n" "PO-Revision-Date: 2003-04-11 12:42-0400\n" "Last-Translator: Barry A. WArsaw <barry@python.org>\n" "Language-Team: XX <python-dev@python.org>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 7bit\n" "Generated-By: manually\n" #: nofile:0 msgid "ab\xc3\x9e" msgstr "\xc2\xa4yz" ''' # Here's the third example po file, used to generate MMO_DATA ''' msgid "" msgstr "" "Project-Id-Version: No Project 0.0\n" "POT-Creation-Date: Wed Dec 11 07:44:15 2002\n" "PO-Revision-Date: 2002-08-14 01:18:58+00:00\n" "Last-Translator: John Doe <jdoe@example.com>\n" "Jane Foobar <jfoobar@example.com>\n" "Language-Team: xx <xx@example.com>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=iso-8859-15\n" "Content-Transfer-Encoding: quoted-printable\n" "Generated-By: pygettext.py 1.3\n" '''
apache-2.0
[ 646, 747, 199, 646, 1300, 772, 199, 646, 5145, 199, 646, 9796, 199, 646, 2882, 199, 199, 504, 511, 492, 511, 63, 4058, 421, 199, 3, 3254, 26, 199, 3, 221, 446, 2654, 892, 2295, 12, 367, 2893, 367, 298, 68, 5152, 2, 199, 3, 221, 446, 5852, 7283, 2295, 12, 367, 2893, 5343, 367, 2849, 436, 4270, 9344, 199, 3, 259, 965, 949, 12249, 12, 652, 3955, 1172, 340, 781, 4898, 5343, 282, 1798, 334, 73, 14, 69, 14, 1134, 5152, 9, 199, 3, 221, 446, 6496, 1077, 1172, 1454, 1373, 702, 14, 199, 199, 17732, 63, 2679, 63, 3998, 275, 18087, 199, 19, 72, 4332, 76, 49, 6151, 1254, 6151, 40, 6151, 37, 87, 10985, 748, 6151, 70, 13709, 33, 967, 6151, 27629, 2276, 7872, 75, 6151, 74, 6151, 19665, 10985, 2430, 2276, 1554, 74, 199, 10985, 1217, 87, 2276, 7730, 2533, 2276, 748, 6151, 74, 31668, 2276, 37, 2533, 20768, 58, 20152, 2276, 38, 71, 2276, 879, 24, 35, 10985, 69, 6151, 25, 71, 41, 2276, 2430, 6151, 15162, 87, 33, 18984, 2276, 748, 67, 36, 199, 10985, 42, 6151, 86, 49, 2054, 2276, 37, 10985, 1554, 24961, 13709, 6151, 10985, 37, 10985, 18984, 6151, 57, 10985, 1348, 6151, 5699, 42, 72, 199, 69, 55, 17, 86, 12648, 49, 71, 2080, 54, 20, 31282, 42, 21, 4656, 25514, 57, 18, 71, 2076, 1217, 53, 65, 14876, 89, 58, 12463, 80, 1480, 2439, 1480, 34, 391, 55, 15455, 5699, 3863, 15473, 31182, 1277, 30559, 26697, 2439, 1480, 34, 391, 55, 88, 10181, 87, 2910, 199, 65, 17541, 90, 1277, 17, 86, 58, 16566, 30587, 12463, 87, 4400, 2942, 65, 6524, 76, 1480, 34, 3317, 78, 50, 76, 4400, 21, 7952, 39, 6371, 12648, 38, 2231, 56, 838, 28929, 6371, 4492, 34, 72, 12648, 49, 4908, 39, 25, 74, 20207, 88, 13102, 38, 16, 19098, 25, 85, 199, 35, 78, 46, 17, 67, 25262, 86, 6413, 49, 71, 26467, 25, 89, 19824, 6371, 31282, 27061, 53, 40, 76, 16, 65, 39, 25, 85, 19824, 2175, 66, 18, 8161, 20207, 17, 90, 1277, 42, 21, 19824, 2175, 66, 19, 58, 80, 26074, 10836, 58, 89, 34, 72, 4492, 34, 3317, 78, 50, 76, 4400, 12674, 199, 57, 18, 53, 7136, 39, 24, 7136, 39, 15544, 4332, 68, 30692, 49, 4812, 58, 12297, 16, 15473, 72, 16, 1277, 17, 10181, 19, 46, 72, 58, 18, 53, 71, 57, 18, 38, 16, 20207, 25466, 58, 89, 34, 2231, 55, 16608, 16936, 42, 21, 44, 71, 34, 2076, 55, 10515, 56, 46, 82, 1254, 2869, 199, 26074, 5030, 1277, 2869, 26074, 5030, 5699, 2175, 66, 18, 1168, 57, 19, 4238, 8745, 4238, 17402, 54, 29874, 18, 6371, 468, 974, 14738, 20, 87, 1968, 34, 2749, 54, 42, 1447, 757, 8076, 55, 25, 85, 44, 1230, 7952, 17188, 22, 28904, 87, 5127, 1271, 199, 5127, 3308, 20958, 9761, 5747, 41, 22, 5747, 5973, 5127, 49, 22, 5127, 7872, 6332, 38, 23670, 35, 17, 53, 4400, 38, 947, 18, 88, 7952, 39, 25, 89, 47, 17587, 43, 13009, 6773, 16936, 58, 80, 58, 9956, 42, 57, 83, 47, 8090, 23, 38, 274, 73, 33, 24, 5789, 17, 75, 199, 16936, 58, 80, 3687, 34, 456, 1398, 90, 23041, 58, 89, 48, 4927, 12339, 55, 21, 977, 55, 9656, 26697, 17, 53, 14324, 38, 84, 47, 73, 8285, 55, 3263, 24, 67, 40, 76, 16, 65, 39, 25, 85, 44, 6524, 1447, 75, 34, 1129, 12297, 2873, 1194, 456, 19, 42, 30035, 4927, 46, 199, 6195, 17, 3143, 54, 58, 76, 6413, 46, 3317, 11440, 11259, 85, 2054, 80, 8882, 7991, 14324, 1400, 18750, 50, 21, 67, 17188, 22, 41, 14784, 274, 27497, 6737, 39, 88, 2411, 55, 2417, 1277, 1944, 16936, 25620, 15473, 49, 25, 65, 56, 46, 86, 17090, 71, 20, 199, 12460, 5973, 14449, 80, 8882, 7991, 14324, 1400, 18750, 50, 89, 20207, 21, 90, 58, 25489, 89, 44, 15110, 85, 57, 1398, 7351, 55, 21, 78, 47, 17587, 456, 821, 76, 35, 75, 5030, 12648, 32098, 57, 12297, 76, 58, 35, 17, 24417, 52, 29238, 40, 6066, 58, 12297, 16, 199, 15473, 72, 16, 8940, 34, 21, 11259, 85, 14449, 80, 49, 66, 16566, 89, 20207, 9115, 31330, 25, 28564, 13901, 22, 1277, 21, 6603, 16566, 89, 20207, 19196, 4189, 41, 23, 19824, 34, 3893, 56, 42, 16168, 36, 17, 85, 649, 16, 88, 47, 2027, 6087, 39, 3577, 66, 18, 38, 16, 199, 68, 1398, 73, 57, 9457, 76, 559, 18273, 20207, 21, 78, 4400, 2942, 58, 49, 19419, 16936, 9761, 42, 13901, 71, 58, 757, 3387, 14876, 89, 12415, 19419, 16936, 9761, 42, 13901, 71, 58, 757, 3387, 14876, 28564, 19, 45, 689, 19, 54, 18, 58, 17587, 22, 57, 78, 15563, 199, 69, 56, 27061, 57, 18, 2201, 65, 56, 58, 1812, 77, 57, 71, 6428, 9656, 4400, 54, 16168, 1064, 18, 57, 77, 38, 310, 56, 58, 5842, 1064, 18, 57, 77, 37, 4908, 77, 38, 88, 19824, 606, 39, 1229, 6428, 17, 30127, 19, 22534, 57, 49, 80, 391, 15306, 74, 57, 25489, 78, 199, 19824, 20959, 58, 12463, 83, 57, 77, 15544, 41, 742, 30587, 19, 2201, 57, 12463, 74, 14324, 42, 16, 14324, 1367, 58, 17587, 18708, 9956, 74, 14324, 42, 80, 4272, 38, 18, 16936, 49, 4908, 77, 29496, 6428, 9656, 4400, 54, 90, 10472, 2175, 1277, 328, 1277, 68, 17, 199, 559, 2910, 2328, 71, 43, 68, 22313, 78, 58, 19, 42, 82, 58, 89, 34, 22, 4400, 58, 887, 78, 50, 89, 19824, 1713, 58, 2299, 57, 78, 49, 303, 56, 58, 86, 14324, 21, 6374, 35, 20, 3448, 77, 38, 26257, 1194, 2767, 18, 10836, 1187, 34, 19, 19098, 21, 82, 2276, 389, 199, 2344, 199, 199, 2639, 47, 63, 3998, 275, 18087, 199, 19, 72, 4332, 76, 49, 6151, 1348, 6151, 40, 10985, 1348, 87, 6151, 2078, 2276, 1282, 13709, 18984, 10985, 1217, 6151, 5100, 10985, 1282, 20152, 2276, 54, 71, 6151, 49, 31723, 77, 199, 20152, 10985, 49, 6151, 41, 24961, 6151, 3448, 55, 6533, 2753, 27383, 4400, 25, 81, 58, 3705, 16, 44, 18505, 75, 18750, 58, 76, 6413, 46, 3317, 11440, 28904, 85, 2054, 80, 19229, 89, 17, 51, 199, 15473 ]
[ 747, 199, 646, 1300, 772, 199, 646, 5145, 199, 646, 9796, 199, 646, 2882, 199, 199, 504, 511, 492, 511, 63, 4058, 421, 199, 3, 3254, 26, 199, 3, 221, 446, 2654, 892, 2295, 12, 367, 2893, 367, 298, 68, 5152, 2, 199, 3, 221, 446, 5852, 7283, 2295, 12, 367, 2893, 5343, 367, 2849, 436, 4270, 9344, 199, 3, 259, 965, 949, 12249, 12, 652, 3955, 1172, 340, 781, 4898, 5343, 282, 1798, 334, 73, 14, 69, 14, 1134, 5152, 9, 199, 3, 221, 446, 6496, 1077, 1172, 1454, 1373, 702, 14, 199, 199, 17732, 63, 2679, 63, 3998, 275, 18087, 199, 19, 72, 4332, 76, 49, 6151, 1254, 6151, 40, 6151, 37, 87, 10985, 748, 6151, 70, 13709, 33, 967, 6151, 27629, 2276, 7872, 75, 6151, 74, 6151, 19665, 10985, 2430, 2276, 1554, 74, 199, 10985, 1217, 87, 2276, 7730, 2533, 2276, 748, 6151, 74, 31668, 2276, 37, 2533, 20768, 58, 20152, 2276, 38, 71, 2276, 879, 24, 35, 10985, 69, 6151, 25, 71, 41, 2276, 2430, 6151, 15162, 87, 33, 18984, 2276, 748, 67, 36, 199, 10985, 42, 6151, 86, 49, 2054, 2276, 37, 10985, 1554, 24961, 13709, 6151, 10985, 37, 10985, 18984, 6151, 57, 10985, 1348, 6151, 5699, 42, 72, 199, 69, 55, 17, 86, 12648, 49, 71, 2080, 54, 20, 31282, 42, 21, 4656, 25514, 57, 18, 71, 2076, 1217, 53, 65, 14876, 89, 58, 12463, 80, 1480, 2439, 1480, 34, 391, 55, 15455, 5699, 3863, 15473, 31182, 1277, 30559, 26697, 2439, 1480, 34, 391, 55, 88, 10181, 87, 2910, 199, 65, 17541, 90, 1277, 17, 86, 58, 16566, 30587, 12463, 87, 4400, 2942, 65, 6524, 76, 1480, 34, 3317, 78, 50, 76, 4400, 21, 7952, 39, 6371, 12648, 38, 2231, 56, 838, 28929, 6371, 4492, 34, 72, 12648, 49, 4908, 39, 25, 74, 20207, 88, 13102, 38, 16, 19098, 25, 85, 199, 35, 78, 46, 17, 67, 25262, 86, 6413, 49, 71, 26467, 25, 89, 19824, 6371, 31282, 27061, 53, 40, 76, 16, 65, 39, 25, 85, 19824, 2175, 66, 18, 8161, 20207, 17, 90, 1277, 42, 21, 19824, 2175, 66, 19, 58, 80, 26074, 10836, 58, 89, 34, 72, 4492, 34, 3317, 78, 50, 76, 4400, 12674, 199, 57, 18, 53, 7136, 39, 24, 7136, 39, 15544, 4332, 68, 30692, 49, 4812, 58, 12297, 16, 15473, 72, 16, 1277, 17, 10181, 19, 46, 72, 58, 18, 53, 71, 57, 18, 38, 16, 20207, 25466, 58, 89, 34, 2231, 55, 16608, 16936, 42, 21, 44, 71, 34, 2076, 55, 10515, 56, 46, 82, 1254, 2869, 199, 26074, 5030, 1277, 2869, 26074, 5030, 5699, 2175, 66, 18, 1168, 57, 19, 4238, 8745, 4238, 17402, 54, 29874, 18, 6371, 468, 974, 14738, 20, 87, 1968, 34, 2749, 54, 42, 1447, 757, 8076, 55, 25, 85, 44, 1230, 7952, 17188, 22, 28904, 87, 5127, 1271, 199, 5127, 3308, 20958, 9761, 5747, 41, 22, 5747, 5973, 5127, 49, 22, 5127, 7872, 6332, 38, 23670, 35, 17, 53, 4400, 38, 947, 18, 88, 7952, 39, 25, 89, 47, 17587, 43, 13009, 6773, 16936, 58, 80, 58, 9956, 42, 57, 83, 47, 8090, 23, 38, 274, 73, 33, 24, 5789, 17, 75, 199, 16936, 58, 80, 3687, 34, 456, 1398, 90, 23041, 58, 89, 48, 4927, 12339, 55, 21, 977, 55, 9656, 26697, 17, 53, 14324, 38, 84, 47, 73, 8285, 55, 3263, 24, 67, 40, 76, 16, 65, 39, 25, 85, 44, 6524, 1447, 75, 34, 1129, 12297, 2873, 1194, 456, 19, 42, 30035, 4927, 46, 199, 6195, 17, 3143, 54, 58, 76, 6413, 46, 3317, 11440, 11259, 85, 2054, 80, 8882, 7991, 14324, 1400, 18750, 50, 21, 67, 17188, 22, 41, 14784, 274, 27497, 6737, 39, 88, 2411, 55, 2417, 1277, 1944, 16936, 25620, 15473, 49, 25, 65, 56, 46, 86, 17090, 71, 20, 199, 12460, 5973, 14449, 80, 8882, 7991, 14324, 1400, 18750, 50, 89, 20207, 21, 90, 58, 25489, 89, 44, 15110, 85, 57, 1398, 7351, 55, 21, 78, 47, 17587, 456, 821, 76, 35, 75, 5030, 12648, 32098, 57, 12297, 76, 58, 35, 17, 24417, 52, 29238, 40, 6066, 58, 12297, 16, 199, 15473, 72, 16, 8940, 34, 21, 11259, 85, 14449, 80, 49, 66, 16566, 89, 20207, 9115, 31330, 25, 28564, 13901, 22, 1277, 21, 6603, 16566, 89, 20207, 19196, 4189, 41, 23, 19824, 34, 3893, 56, 42, 16168, 36, 17, 85, 649, 16, 88, 47, 2027, 6087, 39, 3577, 66, 18, 38, 16, 199, 68, 1398, 73, 57, 9457, 76, 559, 18273, 20207, 21, 78, 4400, 2942, 58, 49, 19419, 16936, 9761, 42, 13901, 71, 58, 757, 3387, 14876, 89, 12415, 19419, 16936, 9761, 42, 13901, 71, 58, 757, 3387, 14876, 28564, 19, 45, 689, 19, 54, 18, 58, 17587, 22, 57, 78, 15563, 199, 69, 56, 27061, 57, 18, 2201, 65, 56, 58, 1812, 77, 57, 71, 6428, 9656, 4400, 54, 16168, 1064, 18, 57, 77, 38, 310, 56, 58, 5842, 1064, 18, 57, 77, 37, 4908, 77, 38, 88, 19824, 606, 39, 1229, 6428, 17, 30127, 19, 22534, 57, 49, 80, 391, 15306, 74, 57, 25489, 78, 199, 19824, 20959, 58, 12463, 83, 57, 77, 15544, 41, 742, 30587, 19, 2201, 57, 12463, 74, 14324, 42, 16, 14324, 1367, 58, 17587, 18708, 9956, 74, 14324, 42, 80, 4272, 38, 18, 16936, 49, 4908, 77, 29496, 6428, 9656, 4400, 54, 90, 10472, 2175, 1277, 328, 1277, 68, 17, 199, 559, 2910, 2328, 71, 43, 68, 22313, 78, 58, 19, 42, 82, 58, 89, 34, 22, 4400, 58, 887, 78, 50, 89, 19824, 1713, 58, 2299, 57, 78, 49, 303, 56, 58, 86, 14324, 21, 6374, 35, 20, 3448, 77, 38, 26257, 1194, 2767, 18, 10836, 1187, 34, 19, 19098, 21, 82, 2276, 389, 199, 2344, 199, 199, 2639, 47, 63, 3998, 275, 18087, 199, 19, 72, 4332, 76, 49, 6151, 1348, 6151, 40, 10985, 1348, 87, 6151, 2078, 2276, 1282, 13709, 18984, 10985, 1217, 6151, 5100, 10985, 1282, 20152, 2276, 54, 71, 6151, 49, 31723, 77, 199, 20152, 10985, 49, 6151, 41, 24961, 6151, 3448, 55, 6533, 2753, 27383, 4400, 25, 81, 58, 3705, 16, 44, 18505, 75, 18750, 58, 76, 6413, 46, 3317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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
SickGear/SickGear
lib/hachoir_py3/parser/misc/__init__.py
2
1121
from hachoir_py3.parser.misc.file_3do import File3do # noqa from hachoir_py3.parser.misc.file_3ds import File3ds # noqa from hachoir_py3.parser.misc.torrent import TorrentFile # noqa from hachoir_py3.parser.misc.ttf import TrueTypeFontFile # noqa from hachoir_py3.parser.misc.chm import ChmFile # noqa from hachoir_py3.parser.misc.lnk import LnkFile # noqa from hachoir_py3.parser.misc.pcf import PcfFile # noqa from hachoir_py3.parser.misc.ole2 import OLE2_File # noqa from hachoir_py3.parser.misc.pdf import PDFDocument # noqa from hachoir_py3.parser.misc.pifv import PIFVFile # noqa from hachoir_py3.parser.misc.hlp import HlpFile # noqa from hachoir_py3.parser.misc.gnome_keyring import GnomeKeyring # noqa from hachoir_py3.parser.misc.bplist import BPList # noqa from hachoir_py3.parser.misc.dsstore import DSStore # noqa from hachoir_py3.parser.misc.word_doc import WordDocumentParser # noqa from hachoir_py3.parser.misc.word_2 import Word2DocumentParser # noqa from hachoir_py3.parser.misc.mstask import MSTaskFile # noqa from hachoir_py3.parser.misc.mapsforge_map import MapsforgeMapFile # noqa
gpl-3.0
[ 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 493, 63, 19, 1117, 492, 3814, 19, 1117, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 493, 63, 19, 795, 492, 3814, 19, 795, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 14101, 492, 29659, 640, 1173, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 32264, 492, 715, 804, 6986, 1173, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 335, 77, 492, 2799, 77, 1173, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 6066, 75, 492, 491, 23175, 1173, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 80, 2177, 492, 510, 2177, 1173, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 16721, 18, 492, 593, 906, 18, 63, 1173, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 5607, 492, 15537, 5564, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 80, 692, 86, 492, 510, 4656, 54, 1173, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 72, 10343, 492, 869, 10343, 1173, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 784, 1377, 63, 30591, 492, 598, 29897, 1197, 5985, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 66, 10265, 492, 699, 48, 1296, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 795, 1617, 492, 577, 2300, 475, 264, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 1027, 63, 1301, 492, 14644, 5564, 2842, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 1027, 63, 18, 492, 14644, 18, 5564, 2842, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 77, 270, 813, 492, 603, 840, 813, 1173, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 8919, 16677, 63, 1130, 492, 23673, 16677, 2956, 1173, 221, 327, 8151, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 493, 63, 19, 1117, 492, 3814, 19, 1117, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 493, 63, 19, 795, 492, 3814, 19, 795, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 14101, 492, 29659, 640, 1173, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 32264, 492, 715, 804, 6986, 1173, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 335, 77, 492, 2799, 77, 1173, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 6066, 75, 492, 491, 23175, 1173, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 80, 2177, 492, 510, 2177, 1173, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 16721, 18, 492, 593, 906, 18, 63, 1173, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 5607, 492, 15537, 5564, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 80, 692, 86, 492, 510, 4656, 54, 1173, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 72, 10343, 492, 869, 10343, 1173, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 784, 1377, 63, 30591, 492, 598, 29897, 1197, 5985, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 66, 10265, 492, 699, 48, 1296, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 795, 1617, 492, 577, 2300, 475, 264, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 1027, 63, 1301, 492, 14644, 5564, 2842, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 1027, 63, 18, 492, 14644, 18, 5564, 2842, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 77, 270, 813, 492, 603, 840, 813, 1173, 221, 327, 8151, 199, 504, 394, 21301, 63, 647, 19, 14, 2087, 14, 9923, 14, 8919, 16677, 63, 1130, 492, 23673, 16677, 2956, 1173, 221, 327, 8151, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
zenners/angular-contacts
node_modules/firebase/node_modules/faye-websocket/node_modules/websocket-driver/node_modules/websocket-extensions/node_modules/jstest/node_modules/karma/node_modules/grunt-conventional-github-releaser/node_modules/grunt-contrib-nodeunit/node_modules/tap/node_modules/yamlish/yamlish-py/setup.py
160
1406
# coding: utf-8 from setuptools import setup requires_list = [ "PyYAML>=3.09" ] import os.path def read(fname): with open(os.path.join(os.path.dirname(__file__), fname)) as inf: return "\n" + inf.read().replace("\r\n", "\n") setup( name='yamlish', version="0.17.0", description='Python implementation of YAMLish', author='Matěj Cepl', author_email='mcepl@redhat.com', url='https://github.com/mcepl/yamlish/', py_modules=['yamlish'], long_description=read("README.rst"), keywords=['TAP', 'YAML', 'yamlish'], classifiers=[ "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: PyPy", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Information Technology", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Text Processing :: Markup", ], test_suite="test", install_requires=requires_list )
mit
[ 3, 2803, 26, 2774, 13, 24, 199, 504, 9116, 492, 3272, 199, 6537, 63, 513, 275, 359, 272, 298, 2713, 23103, 8119, 19, 14, 1643, 2, 199, 61, 199, 646, 747, 14, 515, 421, 199, 318, 1586, 8, 5252, 304, 272, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 6748, 430, 465, 10739, 26, 267, 372, 1867, 78, 2, 435, 10739, 14, 739, 1252, 1814, 4582, 82, 60, 78, 401, 1867, 78, 531, 199, 199, 2758, 8, 272, 536, 534, 89, 455, 1891, 297, 272, 1015, 628, 16, 14, 1196, 14, 16, 401, 272, 1369, 534, 4718, 4514, 402, 18916, 2453, 297, 272, 4132, 534, 14817, 129, 250, 74, 445, 69, 1168, 297, 272, 4132, 63, 2123, 534, 77, 301, 1168, 32, 17164, 14, 957, 297, 272, 1166, 534, 2859, 921, 5031, 14, 957, 15, 77, 301, 1168, 15, 89, 455, 1891, 3678, 272, 1134, 63, 3112, 2968, 89, 455, 1891, 995, 272, 1846, 63, 1802, 29, 739, 480, 18195, 14, 8332, 1288, 272, 7681, 2968, 52, 1282, 297, 283, 23103, 297, 283, 89, 455, 1891, 995, 272, 19137, 1524, 267, 298, 11411, 8466, 3800, 2018, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 499, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 499, 14, 22, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 650, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 24425, 3800, 1611, 2713, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 650, 14, 19, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 401, 267, 298, 23753, 9795, 3800, 959, 446, 24114, 15, 933, 461, 401, 267, 298, 8263, 3800, 19809, 401, 267, 298, 23910, 23975, 3800, 17064, 21580, 401, 267, 298, 3761, 3800, 25718, 26330, 3800, 10697, 844, 401, 267, 298, 23699, 6187, 3800, 4403, 1010, 7106, 401, 267, 298, 12157, 3800, 2290, 15290, 3800, 31454, 3800, 2018, 18167, 401, 267, 298, 12157, 3800, 4516, 20157, 3800, 17504, 401, 272, 2156, 272, 511, 63, 5768, 628, 396, 401, 272, 3907, 63, 6537, 29, 6537, 63, 513, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2803, 26, 2774, 13, 24, 199, 504, 9116, 492, 3272, 199, 6537, 63, 513, 275, 359, 272, 298, 2713, 23103, 8119, 19, 14, 1643, 2, 199, 61, 199, 646, 747, 14, 515, 421, 199, 318, 1586, 8, 5252, 304, 272, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 6748, 430, 465, 10739, 26, 267, 372, 1867, 78, 2, 435, 10739, 14, 739, 1252, 1814, 4582, 82, 60, 78, 401, 1867, 78, 531, 199, 199, 2758, 8, 272, 536, 534, 89, 455, 1891, 297, 272, 1015, 628, 16, 14, 1196, 14, 16, 401, 272, 1369, 534, 4718, 4514, 402, 18916, 2453, 297, 272, 4132, 534, 14817, 129, 250, 74, 445, 69, 1168, 297, 272, 4132, 63, 2123, 534, 77, 301, 1168, 32, 17164, 14, 957, 297, 272, 1166, 534, 2859, 921, 5031, 14, 957, 15, 77, 301, 1168, 15, 89, 455, 1891, 3678, 272, 1134, 63, 3112, 2968, 89, 455, 1891, 995, 272, 1846, 63, 1802, 29, 739, 480, 18195, 14, 8332, 1288, 272, 7681, 2968, 52, 1282, 297, 283, 23103, 297, 283, 89, 455, 1891, 995, 272, 19137, 1524, 267, 298, 11411, 8466, 3800, 2018, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 499, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 499, 14, 22, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 650, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 24425, 3800, 1611, 2713, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 650, 14, 19, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 401, 267, 298, 23753, 9795, 3800, 959, 446, 24114, 15, 933, 461, 401, 267, 298, 8263, 3800, 19809, 401, 267, 298, 23910, 23975, 3800, 17064, 21580, 401, 267, 298, 3761, 3800, 25718, 26330, 3800, 10697, 844, 401, 267, 298, 23699, 6187, 3800, 4403, 1010, 7106, 401, 267, 298, 12157, 3800, 2290, 15290, 3800, 31454, 3800, 2018, 18167, 401, 267, 298, 12157, 3800, 4516, 20157, 3800, 17504, 401, 272, 2156, 272, 511, 63, 5768, 628, 396, 401, 272, 3907, 63, 6537, 29, 6537, 63, 513, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
ClearwaterCore/gmock-upstream
test/gmock_output_test.py
986
5999
#!/usr/bin/env python # # Copyright 2008, 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 the text output of Google C++ Mocking Framework. SYNOPSIS gmock_output_test.py --build_dir=BUILD/DIR --gengolden # where BUILD/DIR contains the built gmock_output_test_ file. gmock_output_test.py --gengolden gmock_output_test.py """ __author__ = 'wan@google.com (Zhanyong Wan)' import os import re import sys import gmock_test_utils # The flag for generating the golden file GENGOLDEN_FLAG = '--gengolden' PROGRAM_PATH = gmock_test_utils.GetTestExecutablePath('gmock_output_test_') COMMAND = [PROGRAM_PATH, '--gtest_stack_trace_depth=0', '--gtest_print_time=0'] GOLDEN_NAME = 'gmock_output_test_golden.txt' GOLDEN_PATH = os.path.join(gmock_test_utils.GetSourceDir(), GOLDEN_NAME) def ToUnixLineEnding(s): """Changes all Windows/Mac line endings in s to UNIX line endings.""" return s.replace('\r\n', '\n').replace('\r', '\n') def RemoveReportHeaderAndFooter(output): """Removes Google Test result report's header and footer from the output.""" output = re.sub(r'.*gtest_main.*\n', '', output) output = re.sub(r'\[.*\d+ tests.*\n', '', output) output = re.sub(r'\[.* test environment .*\n', '', output) output = re.sub(r'\[=+\] \d+ tests .* ran.*', '', output) output = re.sub(r'.* FAILED TESTS\n', '', output) return output def RemoveLocations(output): """Removes all file location info from a Google Test program's output. Args: output: the output of a Google Test program. Returns: output with all file location info (in the form of 'DIRECTORY/FILE_NAME:LINE_NUMBER: 'or 'DIRECTORY\\FILE_NAME(LINE_NUMBER): ') replaced by 'FILE:#: '. """ return re.sub(r'.*[/\\](.+)(\:\d+|\(\d+\))\:', 'FILE:#:', output) def NormalizeErrorMarker(output): """Normalizes the error marker, which is different on Windows vs on Linux.""" return re.sub(r' error: ', ' Failure\n', output) def RemoveMemoryAddresses(output): """Removes memory addresses from the test output.""" return re.sub(r'@\w+', '@0x#', output) def RemoveTestNamesOfLeakedMocks(output): """Removes the test names of leaked mock objects from the test output.""" return re.sub(r'\(used in test .+\) ', '', output) def GetLeakyTests(output): """Returns a list of test names that leak mock objects.""" # findall() returns a list of all matches of the regex in output. # For example, if '(used in test FooTest.Bar)' is in output, the # list will contain 'FooTest.Bar'. return re.findall(r'\(used in test (.+)\)', output) def GetNormalizedOutputAndLeakyTests(output): """Normalizes the output of gmock_output_test_. Args: output: The test output. Returns: A tuple (the normalized test output, the list of test names that have leaked mocks). """ output = ToUnixLineEnding(output) output = RemoveReportHeaderAndFooter(output) output = NormalizeErrorMarker(output) output = RemoveLocations(output) output = RemoveMemoryAddresses(output) return (RemoveTestNamesOfLeakedMocks(output), GetLeakyTests(output)) def GetShellCommandOutput(cmd): """Runs a command in a sub-process, and returns its STDOUT in a string.""" return gmock_test_utils.Subprocess(cmd, capture_stderr=False).output def GetNormalizedCommandOutputAndLeakyTests(cmd): """Runs a command and returns its normalized output and a list of leaky tests. Args: cmd: the shell command. """ # Disables exception pop-ups on Windows. os.environ['GTEST_CATCH_EXCEPTIONS'] = '1' return GetNormalizedOutputAndLeakyTests(GetShellCommandOutput(cmd)) class GMockOutputTest(gmock_test_utils.TestCase): def testOutput(self): (output, leaky_tests) = GetNormalizedCommandOutputAndLeakyTests(COMMAND) golden_file = open(GOLDEN_PATH, 'rb') golden = golden_file.read() golden_file.close() # The normalized output should match the golden file. self.assertEquals(golden, output) # The raw output should contain 2 leaked mock object errors for # test GMockOutputTest.CatchesLeakedMocks. self.assertEquals(['GMockOutputTest.CatchesLeakedMocks', 'GMockOutputTest.CatchesLeakedMocks'], leaky_tests) if __name__ == '__main__': if sys.argv[1:] == [GENGOLDEN_FLAG]: (output, _) = GetNormalizedCommandOutputAndLeakyTests(COMMAND) golden_file = open(GOLDEN_PATH, 'wb') golden_file.write(output) golden_file.close() else: gmock_test_utils.Main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 9079, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 2925, 314, 1318, 1072, 402, 4475, 445, 4176, 4420, 316, 22545, 14, 199, 199, 31802, 21665, 1311, 2126, 486, 1805, 63, 1199, 63, 396, 14, 647, 1553, 1506, 63, 694, 29, 8248, 15, 3022, 1553, 2268, 19440, 268, 327, 2382, 22974, 15, 3022, 3509, 314, 6137, 486, 1805, 63, 1199, 63, 396, 63, 570, 14, 2126, 486, 1805, 63, 1199, 63, 396, 14, 647, 1553, 2268, 19440, 2126, 486, 1805, 63, 1199, 63, 396, 14, 647, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 20444, 32, 3098, 14, 957, 334, 12674, 1629, 951, 644, 290, 3171, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 199, 646, 486, 1805, 63, 396, 63, 1208, 421, 199, 3, 710, 3305, 367, 12999, 314, 17631, 570, 199, 9289, 39, 5104, 742, 63, 3719, 275, 2850, 2268, 19440, 7, 199, 199, 15605, 63, 3243, 275, 486, 1805, 63, 396, 63, 1208, 14, 28967, 27602, 360, 71, 1805, 63, 1199, 63, 396, 15452, 199, 10761, 275, 359, 15605, 63, 3243, 12, 2850, 8385, 63, 2340, 63, 3446, 63, 4631, 29, 16, 297, 2850, 8385, 63, 1361, 63, 521, 29, 16, 418, 199, 39, 5104, 742, 63, 2339, 275, 283, 71, 1805, 63, 1199, 63, 396, 63, 19440, 14, 2424, 7, 199, 39, 5104, 742, 63, 3243, 275, 747, 14, 515, 14, 904, 8, 71, 1805, 63, 396, 63, 1208, 14, 1002, 2980, 3567, 1062, 598, 5104, 742, 63, 2339, 9, 421, 199, 318, 4005, 21607, 3049, 3005, 316, 8, 83, 304, 523, 408, 13907, 1006, 5417, 15, 3399, 1004, 1284, 780, 315, 308, 370, 22242, 1004, 1284, 780, 1041, 819, 372, 308, 14, 1814, 2258, 82, 60, 78, 297, 1557, 78, 1959, 1814, 2258, 82, 297, 1557, 78, 358, 421, 199, 318, 5852, 7457, 2567, 3325, 5686, 351, 8, 1199, 304, 523, 408, 22948, 4475, 1379, 754, 3622, 1159, 1406, 436, 14178, 687, 314, 1072, 1041, 819, 1072, 275, 295, 14, 954, 8, 82, 24898, 8385, 63, 973, 17910, 78, 297, 3260, 1072, 9, 523, 1072, 275, 295, 14, 954, 8, 82, 30181, 17910, 68, 11, 2295, 17910, 78, 297, 3260, 1072, 9, 523, 1072, 275, 295, 14, 954, 8, 82, 30181, 2795, 511, 3734, 1275, 7590, 78, 297, 3260, 1072, 9, 523, 1072, 275, 295, 14, 954, 8, 82, 30181, 29, 7896, 61, 971, 68, 11, 2295, 23076, 21471, 16110, 3260, 1072, 9, 523, 1072, 275, 295, 14, 954, 8, 82, 24898, 26892, 7393, 51, 60, 78, 297, 3260, 1072, 9, 523, 372, 1072, 421, 199, 318, 5852, 27727, 8, 1199, 304, 523, 408, 22948, 1006, 570, 2909, 2256, 687, 282, 4475, 1379, 2240, 1159, 1072, 14, 819, 3033, 26, 2126, 1072, 26, 221, 314, 1072, 402, 282, 4475, 1379, 2240, 14, 819, 1803, 26, 2126, 1072, 543, 1006, 570, 2909, 2256, 334, 262, 314, 1824, 402, 2126, 283, 16436, 15, 3817, 63, 2339, 26, 6174, 63, 9190, 26, 283, 269, 2126, 283, 16436, 1103, 3817, 63, 2339, 8, 6174, 63, 9190, 304, 5320, 8717, 701, 2126, 283, 3817, 26, 12573, 1987, 523, 408, 819, 372, 295, 14, 954, 8, 82, 1370, 23033, 15, 1103, 8738, 6977, 10127, 3427, 68, 11, 6113, 2961, 68, 7896, 25105, 6536, 283, 3817, 15596, 6536, 1072, 9, 421, 199, 318, 21017, 547, 12825, 8, 1199, 304, 523, 408, 6241, 6491, 314, 1125, 3608, 12, 1314, 365, 3365, 641, 5417, 8118, 641, 10130, 1041, 819, 372, 295, 14, 954, 8, 82, 7, 1125, 26, 1656, 283, 20367, 60, 78, 297, 1072, 9, 421, 199, 318, 5852, 8628, 20826, 8, 1199, 304, 523, 408, 22948, 4402, 7149, 687, 314, 511, 1072, 1041, 819, 372, 295, 14, 954, 8, 82, 20812, 60, 87, 7386, 10267, 16, 88, 23470, 1072, 9, 421, 199, 318, 5852, 774, 5866, 3466, 2553, 16702, 3346, 83, 8, 1199, 304, 523, 408, 22948, 314, 511, 1561, 402, 1026, 16702, 1683, 2251, 687, 314, 511, 1072, 1041, 819, 372, 295, 14, 954, 8, 82, 1154, 8, 2972, 315, 511, 1275, 7896, 9, 1656, 3260, 1072, 9, 421, 199, 318, 2372, 2553, 1151, 89, 2925, 8, 1199, 304, 523, 408, 3407, 282, 769, 402, 511, 1561, 626, 25831, 1683, 2251, 1041, 819, 327, 2342, 452, 342, 2529 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 9079, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 2925, 314, 1318, 1072, 402, 4475, 445, 4176, 4420, 316, 22545, 14, 199, 199, 31802, 21665, 1311, 2126, 486, 1805, 63, 1199, 63, 396, 14, 647, 1553, 1506, 63, 694, 29, 8248, 15, 3022, 1553, 2268, 19440, 268, 327, 2382, 22974, 15, 3022, 3509, 314, 6137, 486, 1805, 63, 1199, 63, 396, 63, 570, 14, 2126, 486, 1805, 63, 1199, 63, 396, 14, 647, 1553, 2268, 19440, 2126, 486, 1805, 63, 1199, 63, 396, 14, 647, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 20444, 32, 3098, 14, 957, 334, 12674, 1629, 951, 644, 290, 3171, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 199, 646, 486, 1805, 63, 396, 63, 1208, 421, 199, 3, 710, 3305, 367, 12999, 314, 17631, 570, 199, 9289, 39, 5104, 742, 63, 3719, 275, 2850, 2268, 19440, 7, 199, 199, 15605, 63, 3243, 275, 486, 1805, 63, 396, 63, 1208, 14, 28967, 27602, 360, 71, 1805, 63, 1199, 63, 396, 15452, 199, 10761, 275, 359, 15605, 63, 3243, 12, 2850, 8385, 63, 2340, 63, 3446, 63, 4631, 29, 16, 297, 2850, 8385, 63, 1361, 63, 521, 29, 16, 418, 199, 39, 5104, 742, 63, 2339, 275, 283, 71, 1805, 63, 1199, 63, 396, 63, 19440, 14, 2424, 7, 199, 39, 5104, 742, 63, 3243, 275, 747, 14, 515, 14, 904, 8, 71, 1805, 63, 396, 63, 1208, 14, 1002, 2980, 3567, 1062, 598, 5104, 742, 63, 2339, 9, 421, 199, 318, 4005, 21607, 3049, 3005, 316, 8, 83, 304, 523, 408, 13907, 1006, 5417, 15, 3399, 1004, 1284, 780, 315, 308, 370, 22242, 1004, 1284, 780, 1041, 819, 372, 308, 14, 1814, 2258, 82, 60, 78, 297, 1557, 78, 1959, 1814, 2258, 82, 297, 1557, 78, 358, 421, 199, 318, 5852, 7457, 2567, 3325, 5686, 351, 8, 1199, 304, 523, 408, 22948, 4475, 1379, 754, 3622, 1159, 1406, 436, 14178, 687, 314, 1072, 1041, 819, 1072, 275, 295, 14, 954, 8, 82, 24898, 8385, 63, 973, 17910, 78, 297, 3260, 1072, 9, 523, 1072, 275, 295, 14, 954, 8, 82, 30181, 17910, 68, 11, 2295, 17910, 78, 297, 3260, 1072, 9, 523, 1072, 275, 295, 14, 954, 8, 82, 30181, 2795, 511, 3734, 1275, 7590, 78, 297, 3260, 1072, 9, 523, 1072, 275, 295, 14, 954, 8, 82, 30181, 29, 7896, 61, 971, 68, 11, 2295, 23076, 21471, 16110, 3260, 1072, 9, 523, 1072, 275, 295, 14, 954, 8, 82, 24898, 26892, 7393, 51, 60, 78, 297, 3260, 1072, 9, 523, 372, 1072, 421, 199, 318, 5852, 27727, 8, 1199, 304, 523, 408, 22948, 1006, 570, 2909, 2256, 687, 282, 4475, 1379, 2240, 1159, 1072, 14, 819, 3033, 26, 2126, 1072, 26, 221, 314, 1072, 402, 282, 4475, 1379, 2240, 14, 819, 1803, 26, 2126, 1072, 543, 1006, 570, 2909, 2256, 334, 262, 314, 1824, 402, 2126, 283, 16436, 15, 3817, 63, 2339, 26, 6174, 63, 9190, 26, 283, 269, 2126, 283, 16436, 1103, 3817, 63, 2339, 8, 6174, 63, 9190, 304, 5320, 8717, 701, 2126, 283, 3817, 26, 12573, 1987, 523, 408, 819, 372, 295, 14, 954, 8, 82, 1370, 23033, 15, 1103, 8738, 6977, 10127, 3427, 68, 11, 6113, 2961, 68, 7896, 25105, 6536, 283, 3817, 15596, 6536, 1072, 9, 421, 199, 318, 21017, 547, 12825, 8, 1199, 304, 523, 408, 6241, 6491, 314, 1125, 3608, 12, 1314, 365, 3365, 641, 5417, 8118, 641, 10130, 1041, 819, 372, 295, 14, 954, 8, 82, 7, 1125, 26, 1656, 283, 20367, 60, 78, 297, 1072, 9, 421, 199, 318, 5852, 8628, 20826, 8, 1199, 304, 523, 408, 22948, 4402, 7149, 687, 314, 511, 1072, 1041, 819, 372, 295, 14, 954, 8, 82, 20812, 60, 87, 7386, 10267, 16, 88, 23470, 1072, 9, 421, 199, 318, 5852, 774, 5866, 3466, 2553, 16702, 3346, 83, 8, 1199, 304, 523, 408, 22948, 314, 511, 1561, 402, 1026, 16702, 1683, 2251, 687, 314, 511, 1072, 1041, 819, 372, 295, 14, 954, 8, 82, 1154, 8, 2972, 315, 511, 1275, 7896, 9, 1656, 3260, 1072, 9, 421, 199, 318, 2372, 2553, 1151, 89, 2925, 8, 1199, 304, 523, 408, 3407, 282, 769, 402, 511, 1561, 626, 25831, 1683, 2251, 1041, 819, 327, 2342, 452, 342, 2529, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ColOfAbRiX/ansible
lib/ansible/modules/cloud/lxd/lxd_profile.py
18
12235
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2016, Hiroaki Nakamura <hnakamur@gmail.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. ANSIBLE_METADATA = {'status': ['preview'], 'supported_by': 'community', 'version': '1.0'} DOCUMENTATION = ''' --- module: lxd_profile short_description: Manage LXD profiles version_added: "2.2" description: - Management of LXD profiles author: "Hiroaki Nakamura (@hnakamur)" options: name: description: - Name of a profile. required: true config: description: - 'The config for the container (e.g. {"limits.memory": "4GB"}). See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#patch-3)' - If the profile already exists and its "config" value in metadata obtained from GET /1.0/profiles/<name> U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#get-19) are different, they this module tries to apply the configurations. - Not all config values are supported to apply the existing profile. Maybe you need to delete and recreate a profile. required: false devices: description: - 'The devices for the profile (e.g. {"rootfs": {"path": "/dev/kvm", "type": "unix-char"}). See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#patch-3)' required: false new_name: description: - A new name of a profile. - If this parameter is specified a profile will be renamed to this name. See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-11) required: false state: choices: - present - absent description: - Define the state of a profile. required: false default: present url: description: - The unix domain socket path or the https URL for the LXD server. required: false default: unix:/var/lib/lxd/unix.socket key_file: description: - The client certificate key file path. required: false default: '"{}/.config/lxc/client.key" .format(os.environ["HOME"])' cert_file: description: - The client certificate file path. required: false default: '"{}/.config/lxc/client.crt" .format(os.environ["HOME"])' trust_password: description: - The client trusted password. - You need to set this password on the LXD server before running this module using the following command. lxc config set core.trust_password <some random password> See U(https://www.stgraber.org/2016/04/18/lxd-api-direct-interaction/) - If trust_password is set, this module send a request for authentication before sending any requests. required: false notes: - Profiles must have a unique name. If you attempt to create a profile with a name that already existed in the users namespace the module will simply return as "unchanged". ''' EXAMPLES = ''' # An example for creating a profile - hosts: localhost connection: local tasks: - name: Create a profile lxd_profile: name: macvlan state: present config: {} description: my macvlan profile devices: eth0: nictype: macvlan parent: br0 type: nic # An example for creating a profile via http connection - hosts: localhost connection: local tasks: - name: create macvlan profile lxd_profile: url: https://127.0.0.1:8443 # These cert_file and key_file values are equal to the default values. #cert_file: "{{ lookup('env', 'HOME') }}/.config/lxc/client.crt" #key_file: "{{ lookup('env', 'HOME') }}/.config/lxc/client.key" trust_password: mypassword name: macvlan state: present config: {} description: my macvlan profile devices: eth0: nictype: macvlan parent: br0 type: nic # An example for deleting a profile - hosts: localhost connection: local tasks: - name: Delete a profile lxd_profile: name: macvlan state: absent # An example for renaming a profile - hosts: localhost connection: local tasks: - name: Rename a profile lxd_profile: name: macvlan new_name: macvlan2 state: present ''' RETURN=''' old_state: description: The old state of the profile returned: success type: string sample: "absent" logs: description: The logs of requests and responses. returned: when ansible-playbook is invoked with -vvvv. type: list sample: "(too long to be placed here)" actions: description: List of actions performed for the profile. returned: success type: list sample: '["create"]' ''' import os from ansible.module_utils.lxd import LXDClient, LXDClientException # PROFILE_STATES is a list for states supported PROFILES_STATES = [ 'present', 'absent' ] # CONFIG_PARAMS is a list of config attribute names. CONFIG_PARAMS = [ 'config', 'description', 'devices' ] class LXDProfileManagement(object): def __init__(self, module): """Management of LXC containers via Ansible. :param module: Processed Ansible Module. :type module: ``object`` """ self.module = module self.name = self.module.params['name'] self._build_config() self.state = self.module.params['state'] self.new_name = self.module.params.get('new_name', None) self.url = self.module.params['url'] self.key_file = self.module.params.get('key_file', None) self.cert_file = self.module.params.get('cert_file', None) self.debug = self.module._verbosity >= 4 try: self.client = LXDClient( self.url, key_file=self.key_file, cert_file=self.cert_file, debug=self.debug ) except LXDClientException as e: self.module.fail_json(msg=e.msg) self.trust_password = self.module.params.get('trust_password', None) self.actions = [] def _build_config(self): self.config = {} for attr in CONFIG_PARAMS: param_val = self.module.params.get(attr, None) if param_val is not None: self.config[attr] = param_val def _get_profile_json(self): return self.client.do( 'GET', '/1.0/profiles/{0}'.format(self.name), ok_error_codes=[404] ) @staticmethod def _profile_json_to_module_state(resp_json): if resp_json['type'] == 'error': return 'absent' return 'present' def _update_profile(self): if self.state == 'present': if self.old_state == 'absent': if self.new_name is None: self._create_profile() else: self.module.fail_json( msg='new_name must not be set when the profile does not exist and the specified state is present', changed=False) else: if self.new_name is not None and self.new_name != self.name: self._rename_profile() if self._needs_to_apply_profile_configs(): self._apply_profile_configs() elif self.state == 'absent': if self.old_state == 'present': if self.new_name is None: self._delete_profile() else: self.module.fail_json( msg='new_name must not be set when the profile exists and the specified state is absent', changed=False) def _create_profile(self): config = self.config.copy() config['name'] = self.name self.client.do('POST', '/1.0/profiles', config) self.actions.append('create') def _rename_profile(self): config = {'name': self.new_name} self.client.do('POST', '/1.0/profiles/{}'.format(self.name), config) self.actions.append('rename') self.name = self.new_name def _needs_to_change_profile_config(self, key): if key not in self.config: return False old_configs = self.old_profile_json['metadata'].get(key, None) return self.config[key] != old_configs def _needs_to_apply_profile_configs(self): return ( self._needs_to_change_profile_config('config') or self._needs_to_change_profile_config('description') or self._needs_to_change_profile_config('devices') ) def _apply_profile_configs(self): config = self.old_profile_json.copy() for k, v in self.config.items(): config[k] = v self.client.do('PUT', '/1.0/profiles/{}'.format(self.name), config) self.actions.append('apply_profile_configs') def _delete_profile(self): self.client.do('DELETE', '/1.0/profiles/{}'.format(self.name)) self.actions.append('delete') def run(self): """Run the main method.""" try: if self.trust_password is not None: self.client.authenticate(self.trust_password) self.old_profile_json = self._get_profile_json() self.old_state = self._profile_json_to_module_state(self.old_profile_json) self._update_profile() state_changed = len(self.actions) > 0 result_json = { 'changed': state_changed, 'old_state': self.old_state, 'actions': self.actions } if self.client.debug: result_json['logs'] = self.client.logs self.module.exit_json(**result_json) except LXDClientException as e: state_changed = len(self.actions) > 0 fail_params = { 'msg': e.msg, 'changed': state_changed, 'actions': self.actions } if self.client.debug: fail_params['logs'] = e.kwargs['logs'] self.module.fail_json(**fail_params) def main(): """Ansible Main module.""" module = AnsibleModule( argument_spec=dict( name=dict( type='str', required=True ), new_name=dict( type='str', ), config=dict( type='dict', ), description=dict( type='str', ), devices=dict( type='dict', ), state=dict( choices=PROFILES_STATES, default='present' ), url=dict( type='str', default='unix:/var/lib/lxd/unix.socket' ), key_file=dict( type='str', default='{}/.config/lxc/client.key'.format(os.environ['HOME']) ), cert_file=dict( type='str', default='{}/.config/lxc/client.crt'.format(os.environ['HOME']) ), trust_password=dict( type='str', ) ), supports_check_mode=False, ) lxd_manage = LXDProfileManagement(module=module) lxd_manage.run() # import module bits from ansible.module_utils.basic import * 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, 7800, 12, 869, 14352, 27387, 653, 1151, 455, 12417, 665, 6164, 1151, 455, 300, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 1023, 356, 283, 17, 14, 16, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 634, 2207, 63, 2913, 199, 3612, 63, 1802, 26, 14944, 491, 18184, 17390, 199, 1023, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 1802, 26, 523, 446, 8259, 402, 491, 18184, 17390, 199, 2502, 26, 298, 40, 14352, 27387, 653, 1151, 455, 12417, 8593, 6164, 1151, 455, 300, 2924, 199, 1419, 26, 272, 536, 26, 267, 1369, 26, 881, 446, 2812, 402, 282, 4690, 14, 267, 1415, 26, 2549, 272, 1101, 26, 267, 1369, 26, 881, 446, 283, 1918, 1101, 367, 314, 3970, 334, 69, 14, 71, 14, 2420, 9368, 14, 4844, 582, 298, 20, 6487, 3570, 680, 288, 1666, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 2068, 13, 19, 3171, 881, 446, 982, 314, 4690, 2575, 3495, 436, 2399, 298, 888, 2, 574, 315, 3341, 288, 15884, 687, 288, 9576, 1182, 17, 14, 16, 15, 11225, 8316, 354, 30, 288, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 362, 13, 1167, 9, 288, 787, 3365, 12, 2985, 642, 859, 11275, 370, 4838, 314, 13422, 14, 881, 446, 2832, 1006, 1101, 1338, 787, 3748, 370, 4838, 314, 3411, 4690, 14, 288, 23038, 1265, 1929, 370, 3145, 436, 23959, 282, 4690, 14, 267, 1415, 26, 3055, 272, 7256, 26, 267, 1369, 26, 881, 446, 283, 1918, 7256, 367, 314, 4690, 288, 334, 69, 14, 71, 14, 2420, 1231, 2319, 582, 2420, 515, 582, 3286, 2374, 15, 29272, 401, 298, 466, 582, 298, 11864, 13, 1560, 3570, 680, 288, 1666, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 2068, 13, 19, 3171, 267, 1415, 26, 3055, 272, 892, 63, 354, 26, 267, 1369, 26, 881, 446, 437, 892, 536, 402, 282, 4690, 14, 881, 446, 982, 642, 2725, 365, 2013, 282, 4690, 911, 506, 17864, 370, 642, 536, 14, 288, 1666, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 1932, 13, 845, 9, 267, 1415, 26, 3055, 272, 1174, 26, 267, 3415, 26, 881, 446, 3451, 881, 446, 9552, 267, 1369, 26, 881, 446, 13930, 314, 1174, 402, 282, 4690, 14, 267, 1415, 26, 3055, 267, 849, 26, 3451, 272, 1166, 26, 267, 1369, 26, 881, 446, 710, 16572, 2881, 2838, 931, 503, 314, 4178, 2851, 367, 314, 491, 18184, 1654, 14, 267, 1415, 26, 3055, 267, 849, 26, 16572, 11254, 1391, 15, 773, 15, 76, 2207, 15, 11864, 14, 3450, 272, 790, 63, 493, 26, 267, 1369, 26, 881, 446, 710, 1890, 5897, 790, 570, 931, 14, 267, 1415, 26, 3055, 267, 849, 26, 5522, 2440, 8083, 888, 15, 29357, 15, 1258, 14, 498, 2, 1275, 908, 8, 736, 14, 2314, 905, 9524, 3135, 7, 272, 6250, 63, 493, 26, 267, 1369, 26, 881, 446, 710, 1890, 5897, 570, 931, 14, 267, 1415, 26, 3055, 267, 849, 26, 5522, 2440, 8083, 888, 15, 29357, 15, 1258, 14, 16617, 2, 1275, 908, 8, 736, 14, 2314, 905, 9524, 3135, 7, 272, 16822, 63, 2060, 26, 267, 1369, 26, 881, 446, 710, 1890, 19427, 2505, 14, 881, 446, 2047, 1929, 370, 663, 642, 2505, 641, 314, 491, 18184, 1654, 2544, 288, 3879, 642, 859, 1808, 314, 2569, 1414, 14, 288, 634, 1812, 1101, 663, 6170, 14, 15756, 63, 2060, 665, 3972, 2196, 2505, 30, 288, 1666, 738, 8, 2859, 921, 1544, 14, 270, 926, 605, 14, 1308, 15, 9261, 15, 966, 15, 1085, 15, 76, 2207, 13, 1246, 13, 2275, 13, 21679, 24793, 881, 446, 982, 16822, 63, 2060, 365, 663, 12, 642, 859, 3222, 282, 1056, 367, 288, 6299, 2544, 10209, 1263, 4145, 14, 267, 1415, 26, 3055, 199, 5983, 26, 523, 446, 2165, 1725, 1471, 1172, 282, 3747, 536, 14, 982, 1265, 7427, 370, 1218, 282, 4690, 272, 543, 282, 536, 626, 2575, 30482, 315, 314, 4390, 3231, 314, 859, 911, 272, 9329, 372, 465, 298, 16914, 1674, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 1626, 2893, 367, 6425, 282, 4690, 199, 13, 7057, 26, 11667, 523, 1950, 26, 2257, 523, 6527, 26, 272, 446, 536, 26, 2790, 282, 4690, 489, 634, 2207, 63, 2913, 26, 267, 536, 26, 4497, 7175, 267, 1174, 26, 3451, 267, 1101, 26, 1052, 267, 1369, 26, 3002, 4497, 7175, 4690, 267, 7256, 26, 881, 16227, 16, 26, 288, 302, 73, 3667, 26, 4497, 7175, 288, 1676, 26, 11665, 16, 288, 730, 26, 14304, 199, 199, 3, 1626, 2893, 367, 6425, 282, 4690, 4799, 1455, 1950, 199, 13, 7057, 26 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 7800, 12, 869, 14352, 27387, 653, 1151, 455, 12417, 665, 6164, 1151, 455, 300, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 1023, 356, 283, 17, 14, 16, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 634, 2207, 63, 2913, 199, 3612, 63, 1802, 26, 14944, 491, 18184, 17390, 199, 1023, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 1802, 26, 523, 446, 8259, 402, 491, 18184, 17390, 199, 2502, 26, 298, 40, 14352, 27387, 653, 1151, 455, 12417, 8593, 6164, 1151, 455, 300, 2924, 199, 1419, 26, 272, 536, 26, 267, 1369, 26, 881, 446, 2812, 402, 282, 4690, 14, 267, 1415, 26, 2549, 272, 1101, 26, 267, 1369, 26, 881, 446, 283, 1918, 1101, 367, 314, 3970, 334, 69, 14, 71, 14, 2420, 9368, 14, 4844, 582, 298, 20, 6487, 3570, 680, 288, 1666, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 2068, 13, 19, 3171, 881, 446, 982, 314, 4690, 2575, 3495, 436, 2399, 298, 888, 2, 574, 315, 3341, 288, 15884, 687, 288, 9576, 1182, 17, 14, 16, 15, 11225, 8316, 354, 30, 288, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 362, 13, 1167, 9, 288, 787, 3365, 12, 2985, 642, 859, 11275, 370, 4838, 314, 13422, 14, 881, 446, 2832, 1006, 1101, 1338, 787, 3748, 370, 4838, 314, 3411, 4690, 14, 288, 23038, 1265, 1929, 370, 3145, 436, 23959, 282, 4690, 14, 267, 1415, 26, 3055, 272, 7256, 26, 267, 1369, 26, 881, 446, 283, 1918, 7256, 367, 314, 4690, 288, 334, 69, 14, 71, 14, 2420, 1231, 2319, 582, 2420, 515, 582, 3286, 2374, 15, 29272, 401, 298, 466, 582, 298, 11864, 13, 1560, 3570, 680, 288, 1666, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 2068, 13, 19, 3171, 267, 1415, 26, 3055, 272, 892, 63, 354, 26, 267, 1369, 26, 881, 446, 437, 892, 536, 402, 282, 4690, 14, 881, 446, 982, 642, 2725, 365, 2013, 282, 4690, 911, 506, 17864, 370, 642, 536, 14, 288, 1666, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 1932, 13, 845, 9, 267, 1415, 26, 3055, 272, 1174, 26, 267, 3415, 26, 881, 446, 3451, 881, 446, 9552, 267, 1369, 26, 881, 446, 13930, 314, 1174, 402, 282, 4690, 14, 267, 1415, 26, 3055, 267, 849, 26, 3451, 272, 1166, 26, 267, 1369, 26, 881, 446, 710, 16572, 2881, 2838, 931, 503, 314, 4178, 2851, 367, 314, 491, 18184, 1654, 14, 267, 1415, 26, 3055, 267, 849, 26, 16572, 11254, 1391, 15, 773, 15, 76, 2207, 15, 11864, 14, 3450, 272, 790, 63, 493, 26, 267, 1369, 26, 881, 446, 710, 1890, 5897, 790, 570, 931, 14, 267, 1415, 26, 3055, 267, 849, 26, 5522, 2440, 8083, 888, 15, 29357, 15, 1258, 14, 498, 2, 1275, 908, 8, 736, 14, 2314, 905, 9524, 3135, 7, 272, 6250, 63, 493, 26, 267, 1369, 26, 881, 446, 710, 1890, 5897, 570, 931, 14, 267, 1415, 26, 3055, 267, 849, 26, 5522, 2440, 8083, 888, 15, 29357, 15, 1258, 14, 16617, 2, 1275, 908, 8, 736, 14, 2314, 905, 9524, 3135, 7, 272, 16822, 63, 2060, 26, 267, 1369, 26, 881, 446, 710, 1890, 19427, 2505, 14, 881, 446, 2047, 1929, 370, 663, 642, 2505, 641, 314, 491, 18184, 1654, 2544, 288, 3879, 642, 859, 1808, 314, 2569, 1414, 14, 288, 634, 1812, 1101, 663, 6170, 14, 15756, 63, 2060, 665, 3972, 2196, 2505, 30, 288, 1666, 738, 8, 2859, 921, 1544, 14, 270, 926, 605, 14, 1308, 15, 9261, 15, 966, 15, 1085, 15, 76, 2207, 13, 1246, 13, 2275, 13, 21679, 24793, 881, 446, 982, 16822, 63, 2060, 365, 663, 12, 642, 859, 3222, 282, 1056, 367, 288, 6299, 2544, 10209, 1263, 4145, 14, 267, 1415, 26, 3055, 199, 5983, 26, 523, 446, 2165, 1725, 1471, 1172, 282, 3747, 536, 14, 982, 1265, 7427, 370, 1218, 282, 4690, 272, 543, 282, 536, 626, 2575, 30482, 315, 314, 4390, 3231, 314, 859, 911, 272, 9329, 372, 465, 298, 16914, 1674, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 1626, 2893, 367, 6425, 282, 4690, 199, 13, 7057, 26, 11667, 523, 1950, 26, 2257, 523, 6527, 26, 272, 446, 536, 26, 2790, 282, 4690, 489, 634, 2207, 63, 2913, 26, 267, 536, 26, 4497, 7175, 267, 1174, 26, 3451, 267, 1101, 26, 1052, 267, 1369,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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 ]
thomashaw/SecGen
modules/utilities/unix/labtainers/files/Labtainers-master/scripts/labtainer-student/lab_sys/sbin/mynotify.py
2
6741
#!/usr/bin/env python ''' This software was created by United States Government employees at The Center for the Information Systems Studies and Research (CISR) at the Naval Postgraduate School NPS. Please note that within the United States, copyright protection is not available for any works created by United States Government employees, pursuant to Title 17 United States Code Section 105. This software is in the public domain and is not subject to copyright. ''' import os import time import logging import subprocess from inotify_simple import INotify, flags ''' This runs as a service on the containers. It uses inotify to catch events defined in the .local/bin/notify file, and will invoke notify_cb.sh for when those events occur. We pass the file, the mode, the the first user in the system to notify_cb.sh The timestamped output is appended to any existing notify.stdout.... within 1 second of now. Alternately, the notify file can include an optional output filename. It dies without a wimper. Debug by manually running and generating inotify events. ''' logger = logging.getLogger('mynotify') hdlr = logging.FileHandler('/tmp/mynotify.log') formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') hdlr.setFormatter(formatter) logger.addHandler(hdlr) logger.setLevel(logging.DEBUG) class WatchType(): def __init__(self, path, flag, outfile=None): self.path = path self.flag = flag self.outfile = outfile def showMask(mask): if mask & flags.CREATE: print('CREATE') if mask & flags.ACCESS: print('ACCESS') if mask & flags.OPEN: print('OPEN') def get_flag(flag): if flag == 'CREATE': return flags.CREATE elif flag == 'ACCESS': return flags.ACCESS elif flag == 'OPEN': return flags.OPEN else: return None def get_first_user(): with open('/etc/passwd') as fh: for line in fh: parts = line.strip().split(':') if parts[2] == '1000': return parts[0] return None logger.debug('Start mynotify') watches = {} inotify = INotify() first_user = get_first_user() logger.debug('first user is %s' % first_user) notify_file = '/home/%s/.local/bin/notify' % first_user notify_cb = '/home/%s/.local/bin/notify_cb.sh' % first_user results = '/home/%s/.local/result' % first_user if not os.path.isfile(notify_file) and not os.path.isfile(notify_cb): logger.error('missing notify %s' % (notify_file)) exit(0) if not os.path.isfile(notify_cb): logger.debug("no notify_cb.sh, just ouput path & cmd") notify_cb = None ''' read in the notify file, set watches on file access as directed ''' with open(notify_file) as fh: for line in fh: if not line.strip().startswith('#'): parts = line.strip().split() outfile = None if len(parts) > 2: outfile = parts[2] watch = WatchType(parts[0], parts[1], outfile) flag = get_flag(watch.flag) try: wd = inotify.add_watch(watch.path, flag) watches[wd] = watch except: logger.debug('could not add watch for %s %s' % (watch.path, watch.flag)) # # forever loop responding to inotify events # while True: for event in inotify.read(): print(event) showMask(event.mask) watch = watches[event.wd] logger.debug('path: %s flag: %s' % (watch.path, watch.flag)) now = time.time() ts = time.strftime('%Y%m%d%H%M%S', time.localtime(now)) ''' use given outputfile name, if provided in the notify directive ''' if watch.outfile is None: notifyoutfile = os.path.join(results, 'notify.stdout') else: notifyoutfile = os.path.join(results, '%s.stdout' % (watch.outfile)) notifyoutfile_ts = '%s.%s' % (notifyoutfile, ts) #notifyoutfile = os.path.join(results, 'notify.stdin.%s' % ts) hist_file = '/home/%s/.bash_history' % first_user root_hist_file = '/root/.bash_history' if not (os.path.isfile(hist_file) or os.path.isfile(root_hist_file)): ''' no user yet, must be system startup, ignore ''' continue cmd_time_history = os.path.getmtime(hist_file) root_hist_file = '/root/.bash_history' cmd_user = first_user if os.path.isfile(root_hist_file): time_root_history = os.path.getmtime(root_hist_file) if cmd_time_history > time_root_history: cmd_time_history = time_root_history hist_file = root_hist_file cmd_user = 'root' cmd = None with open(hist_file) as fh: hist = fh.readlines() cmd = hist[-1].strip() if cmd.startswith('sudo'): cmd = cmd[5:] cmd_user = 'root' ''' determine if we should append to an existig output file ''' is_a_file = False if not os.path.isfile(notifyoutfile_ts): ''' no file, if from previous second, use that as hack to merge with output from command ''' now = now -1 ts = time.strftime('%Y%m%d%H%M%S', time.localtime(now)) tmpfile = '%s.%s' % (notifyoutfile, ts) if os.path.isfile(tmpfile): notifyoutfile_ts = tmpfile is_a_file = True else: is_a_file = True if is_a_file: ''' existing file, append to it ''' if notify_cb is not None: sys_cmd = '%s %s %s %s %s >> %s 2>/dev/null' % (notify_cb, watch.path, watch.flag, cmd_user, cmd, notifyoutfile_ts) os.system(sys_cmd) logger.debug('sys_cmd is %s' % sys_cmd) else: with open(notifyoutfile_ts, 'a') as fh: fh.write('path: %s cmd: %s user: %s' % (watch.path, cmd, cmd_user)) else: if notify_cb is not None: ''' only write to file if notify_cb generates output ''' sys_cmd = '%s %s %s %s "%s"' % (notify_cb, watch.path, watch.flag, cmd_user, cmd) logger.debug('sys_cmd is %s' % sys_cmd) child = subprocess.Popen(sys_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) output = child.communicate() if len(output[0]) > 0: with open(notifyoutfile_ts, 'w') as fh: fh.write(output[0]) else: with open(notifyoutfile_ts, 'a') as fh: fh.write('path: %s cmd: %s user: %s' % (watch.path, cmd, cmd_user))
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 2344, 199, 2765, 2032, 1990, 2737, 701, 1910, 5703, 24230, 598, 27639, 9052, 18149, 737, 221, 199, 1918, 24699, 367, 314, 17064, 15285, 1933, 14525, 397, 436, 26993, 334, 35, 1311, 50, 9, 221, 199, 292, 314, 11290, 637, 7711, 926, 2033, 323, 428, 15089, 653, 5067, 14, 221, 7754, 5317, 626, 4453, 314, 221, 199, 1358, 5703, 24230, 12, 4248, 23977, 365, 440, 2808, 367, 1263, 5419, 221, 199, 3966, 221, 701, 1910, 5703, 24230, 598, 27639, 9052, 18149, 12, 5861, 9648, 867, 370, 16881, 5557, 221, 199, 1358, 5703, 24230, 5495, 15247, 20462, 14, 257, 961, 2032, 365, 315, 314, 4575, 221, 199, 2261, 436, 365, 440, 5420, 370, 4248, 14, 221, 199, 2344, 199, 646, 747, 199, 646, 900, 199, 646, 2050, 199, 646, 3873, 199, 504, 315, 79, 3338, 63, 4129, 492, 1621, 79, 3338, 12, 3285, 199, 199, 2344, 199, 2765, 7858, 465, 282, 2435, 641, 314, 15333, 14, 2779, 4440, 315, 79, 3338, 199, 475, 8579, 4474, 3247, 315, 314, 1275, 1832, 15, 1393, 15, 6814, 570, 12, 221, 199, 460, 911, 12677, 11705, 63, 2894, 14, 609, 367, 1380, 5204, 4474, 4781, 14, 199, 6004, 986, 314, 570, 12, 314, 818, 12, 314, 314, 1642, 922, 315, 314, 2656, 370, 199, 6814, 63, 2894, 14, 609, 257, 710, 4913, 379, 1072, 365, 11544, 370, 1263, 199, 5952, 11705, 14, 2703, 4496, 4453, 413, 3499, 402, 3063, 14, 199, 19978, 13824, 12, 314, 11705, 570, 883, 2387, 376, 2716, 1072, 199, 1501, 14, 523, 199, 7940, 487, 397, 1928, 282, 336, 3236, 281, 14, 221, 14245, 701, 10250, 3879, 436, 12999, 199, 10175, 3338, 4474, 14, 199, 2344, 199, 2921, 275, 2050, 14, 5572, 360, 1662, 6814, 358, 199, 28738, 82, 275, 2050, 14, 21982, 2336, 2791, 15, 1662, 6814, 14, 793, 358, 199, 8911, 275, 2050, 14, 7772, 24713, 18331, 9, 83, 2818, 20056, 9, 83, 2818, 1188, 9, 83, 358, 199, 28738, 82, 14, 26076, 8, 8911, 9, 199, 2921, 14, 18826, 8, 28738, 82, 9, 221, 199, 2921, 14, 13548, 8, 4806, 14, 5287, 9, 421, 199, 533, 29075, 804, 837, 272, 347, 636, 826, 721, 277, 12, 931, 12, 3305, 12, 4386, 29, 403, 304, 267, 291, 14, 515, 275, 931, 267, 291, 14, 4173, 275, 3305, 267, 291, 14, 4984, 275, 4386, 199, 199, 318, 2498, 5144, 8, 2629, 304, 272, 340, 3656, 1253, 3285, 14, 8366, 26, 267, 870, 360, 8366, 358, 272, 340, 3656, 1253, 3285, 14, 11074, 26, 267, 870, 360, 11074, 358, 272, 340, 3656, 1253, 3285, 14, 9935, 26, 267, 870, 360, 9935, 358, 421, 199, 318, 664, 63, 4173, 8, 4173, 304, 272, 340, 3305, 508, 283, 8366, 356, 267, 372, 3285, 14, 8366, 272, 916, 3305, 508, 283, 11074, 356, 267, 372, 3285, 14, 11074, 272, 916, 3305, 508, 283, 9935, 356, 267, 372, 3285, 14, 9935, 272, 587, 26, 267, 372, 488, 199, 199, 318, 664, 63, 2246, 63, 751, 837, 272, 543, 1551, 2336, 6839, 15, 12671, 358, 465, 11155, 26, 267, 367, 1004, 315, 11155, 26, 288, 4184, 275, 1004, 14, 1913, 1252, 1294, 11633, 288, 340, 4184, 59, 18, 61, 508, 283, 5279, 356, 355, 372, 4184, 59, 16, 61, 272, 372, 488, 199, 199, 2921, 14, 1757, 360, 3162, 3002, 6814, 358, 199, 6821, 397, 275, 1052, 199, 199, 10175, 3338, 275, 1621, 79, 3338, 342, 199, 2246, 63, 751, 275, 664, 63, 2246, 63, 751, 342, 199, 2921, 14, 1757, 360, 2246, 922, 365, 450, 83, 7, 450, 1642, 63, 751, 9, 199, 6814, 63, 493, 275, 1994, 4219, 3149, 83, 8083, 1832, 15, 1393, 15, 6814, 7, 450, 1642, 63, 751, 199, 6814, 63, 2894, 275, 1994, 4219, 3149, 83, 8083, 1832, 15, 1393, 15, 6814, 63, 2894, 14, 609, 7, 450, 1642, 63, 751, 199, 2604, 275, 1994, 4219, 3149, 83, 8083, 1832, 15, 1099, 7, 450, 1642, 63, 751, 199, 199, 692, 440, 747, 14, 515, 14, 6292, 8, 6814, 63, 493, 9, 436, 440, 747, 14, 515, 14, 6292, 8, 6814, 63, 2894, 304, 272, 2512, 14, 705, 360, 4752, 11705, 450, 83, 7, 450, 334, 6814, 63, 493, 430, 272, 4458, 8, 16, 9, 199, 199, 692, 440, 747, 14, 515, 14, 6292, 8, 6814, 63, 2894, 304, 272, 2512, 14, 1757, 480, 889, 11705, 63, 2894, 14, 609, 12, 2951, 312, 384, 337, 931, 1253, 2088, 531, 272, 11705, 63, 2894, 275, 488, 199, 199, 2344, 1586, 315, 314, 11705, 570, 12, 663, 9626, 397, 641, 570, 2879, 465, 23667, 1449, 199, 1045, 1551, 8, 6814, 63, 493, 9, 465, 11155, 26, 272, 367, 1004, 315, 11155, 26, 267, 340, 440, 1004, 14, 1913, 1252, 2460, 7863, 735, 288, 4184, 275, 1004, 14, 1913, 1252, 1294, 342, 288, 4386, 275, 488, 288, 340, 822, 8, 4181, 9, 690, 499, 26, 355, 4386, 275, 4184, 59, 18, 61, 288, 9626, 275, 29075, 804, 8, 4181, 59, 16, 467, 4184, 59, 17, 467, 4386, 9, 288, 3305, 275, 664, 63, 4173, 8, 6821, 14, 4173, 9, 288, 862, 26, 355, 20792, 275, 315, 79, 3338, 14, 525, 63, 6821, 8, 6821, 14, 515, 12, 3305, 9, 355, 9626, 397, 59, 2989, 61, 275, 9626, 288, 871, 26, 355, 2512, 14, 1757, 360, 15153, 440, 1050, 9626, 367, 450, 83, 450, 83, 7, 450, 334, 6821, 14, 515, 12, 9626, 14, 4173, 430, 199, 3, 199, 3, 28688, 4438, 9163, 1098, 370, 315, 79, 3338, 4474, 199, 3, 199, 6710, 715, 26, 272, 367, 1566, 315, 315, 79, 3338, 14, 739, 837, 267, 870, 8, 1430, 9, 267, 2498, 5144, 8, 1430, 14, 2629, 9, 267, 9626, 275, 9626, 397, 59, 1430, 14, 2989, 61, 267, 2512, 14, 1757, 360, 515, 26, 450, 83, 3305, 26, 450, 83, 7, 450, 334, 6821, 14, 515, 12, 9626, 14, 4173, 430, 267, 3063, 275, 900, 14, 521, 342, 267, 6714, 275, 900, 14, 6205, 3508, 57, 5, 77, 5, 68, 5, 40, 5, 45, 5, 51, 297, 900, 14, 15198, 8, 2131, 430, 267, 1449, 675, 1627, 32513, 536, 12, 340, 2741, 315, 314, 11705, 13613, 1449, 267, 340, 9626, 14 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 2344, 199, 2765, 2032, 1990, 2737, 701, 1910, 5703, 24230, 598, 27639, 9052, 18149, 737, 221, 199, 1918, 24699, 367, 314, 17064, 15285, 1933, 14525, 397, 436, 26993, 334, 35, 1311, 50, 9, 221, 199, 292, 314, 11290, 637, 7711, 926, 2033, 323, 428, 15089, 653, 5067, 14, 221, 7754, 5317, 626, 4453, 314, 221, 199, 1358, 5703, 24230, 12, 4248, 23977, 365, 440, 2808, 367, 1263, 5419, 221, 199, 3966, 221, 701, 1910, 5703, 24230, 598, 27639, 9052, 18149, 12, 5861, 9648, 867, 370, 16881, 5557, 221, 199, 1358, 5703, 24230, 5495, 15247, 20462, 14, 257, 961, 2032, 365, 315, 314, 4575, 221, 199, 2261, 436, 365, 440, 5420, 370, 4248, 14, 221, 199, 2344, 199, 646, 747, 199, 646, 900, 199, 646, 2050, 199, 646, 3873, 199, 504, 315, 79, 3338, 63, 4129, 492, 1621, 79, 3338, 12, 3285, 199, 199, 2344, 199, 2765, 7858, 465, 282, 2435, 641, 314, 15333, 14, 2779, 4440, 315, 79, 3338, 199, 475, 8579, 4474, 3247, 315, 314, 1275, 1832, 15, 1393, 15, 6814, 570, 12, 221, 199, 460, 911, 12677, 11705, 63, 2894, 14, 609, 367, 1380, 5204, 4474, 4781, 14, 199, 6004, 986, 314, 570, 12, 314, 818, 12, 314, 314, 1642, 922, 315, 314, 2656, 370, 199, 6814, 63, 2894, 14, 609, 257, 710, 4913, 379, 1072, 365, 11544, 370, 1263, 199, 5952, 11705, 14, 2703, 4496, 4453, 413, 3499, 402, 3063, 14, 199, 19978, 13824, 12, 314, 11705, 570, 883, 2387, 376, 2716, 1072, 199, 1501, 14, 523, 199, 7940, 487, 397, 1928, 282, 336, 3236, 281, 14, 221, 14245, 701, 10250, 3879, 436, 12999, 199, 10175, 3338, 4474, 14, 199, 2344, 199, 2921, 275, 2050, 14, 5572, 360, 1662, 6814, 358, 199, 28738, 82, 275, 2050, 14, 21982, 2336, 2791, 15, 1662, 6814, 14, 793, 358, 199, 8911, 275, 2050, 14, 7772, 24713, 18331, 9, 83, 2818, 20056, 9, 83, 2818, 1188, 9, 83, 358, 199, 28738, 82, 14, 26076, 8, 8911, 9, 199, 2921, 14, 18826, 8, 28738, 82, 9, 221, 199, 2921, 14, 13548, 8, 4806, 14, 5287, 9, 421, 199, 533, 29075, 804, 837, 272, 347, 636, 826, 721, 277, 12, 931, 12, 3305, 12, 4386, 29, 403, 304, 267, 291, 14, 515, 275, 931, 267, 291, 14, 4173, 275, 3305, 267, 291, 14, 4984, 275, 4386, 199, 199, 318, 2498, 5144, 8, 2629, 304, 272, 340, 3656, 1253, 3285, 14, 8366, 26, 267, 870, 360, 8366, 358, 272, 340, 3656, 1253, 3285, 14, 11074, 26, 267, 870, 360, 11074, 358, 272, 340, 3656, 1253, 3285, 14, 9935, 26, 267, 870, 360, 9935, 358, 421, 199, 318, 664, 63, 4173, 8, 4173, 304, 272, 340, 3305, 508, 283, 8366, 356, 267, 372, 3285, 14, 8366, 272, 916, 3305, 508, 283, 11074, 356, 267, 372, 3285, 14, 11074, 272, 916, 3305, 508, 283, 9935, 356, 267, 372, 3285, 14, 9935, 272, 587, 26, 267, 372, 488, 199, 199, 318, 664, 63, 2246, 63, 751, 837, 272, 543, 1551, 2336, 6839, 15, 12671, 358, 465, 11155, 26, 267, 367, 1004, 315, 11155, 26, 288, 4184, 275, 1004, 14, 1913, 1252, 1294, 11633, 288, 340, 4184, 59, 18, 61, 508, 283, 5279, 356, 355, 372, 4184, 59, 16, 61, 272, 372, 488, 199, 199, 2921, 14, 1757, 360, 3162, 3002, 6814, 358, 199, 6821, 397, 275, 1052, 199, 199, 10175, 3338, 275, 1621, 79, 3338, 342, 199, 2246, 63, 751, 275, 664, 63, 2246, 63, 751, 342, 199, 2921, 14, 1757, 360, 2246, 922, 365, 450, 83, 7, 450, 1642, 63, 751, 9, 199, 6814, 63, 493, 275, 1994, 4219, 3149, 83, 8083, 1832, 15, 1393, 15, 6814, 7, 450, 1642, 63, 751, 199, 6814, 63, 2894, 275, 1994, 4219, 3149, 83, 8083, 1832, 15, 1393, 15, 6814, 63, 2894, 14, 609, 7, 450, 1642, 63, 751, 199, 2604, 275, 1994, 4219, 3149, 83, 8083, 1832, 15, 1099, 7, 450, 1642, 63, 751, 199, 199, 692, 440, 747, 14, 515, 14, 6292, 8, 6814, 63, 493, 9, 436, 440, 747, 14, 515, 14, 6292, 8, 6814, 63, 2894, 304, 272, 2512, 14, 705, 360, 4752, 11705, 450, 83, 7, 450, 334, 6814, 63, 493, 430, 272, 4458, 8, 16, 9, 199, 199, 692, 440, 747, 14, 515, 14, 6292, 8, 6814, 63, 2894, 304, 272, 2512, 14, 1757, 480, 889, 11705, 63, 2894, 14, 609, 12, 2951, 312, 384, 337, 931, 1253, 2088, 531, 272, 11705, 63, 2894, 275, 488, 199, 199, 2344, 1586, 315, 314, 11705, 570, 12, 663, 9626, 397, 641, 570, 2879, 465, 23667, 1449, 199, 1045, 1551, 8, 6814, 63, 493, 9, 465, 11155, 26, 272, 367, 1004, 315, 11155, 26, 267, 340, 440, 1004, 14, 1913, 1252, 2460, 7863, 735, 288, 4184, 275, 1004, 14, 1913, 1252, 1294, 342, 288, 4386, 275, 488, 288, 340, 822, 8, 4181, 9, 690, 499, 26, 355, 4386, 275, 4184, 59, 18, 61, 288, 9626, 275, 29075, 804, 8, 4181, 59, 16, 467, 4184, 59, 17, 467, 4386, 9, 288, 3305, 275, 664, 63, 4173, 8, 6821, 14, 4173, 9, 288, 862, 26, 355, 20792, 275, 315, 79, 3338, 14, 525, 63, 6821, 8, 6821, 14, 515, 12, 3305, 9, 355, 9626, 397, 59, 2989, 61, 275, 9626, 288, 871, 26, 355, 2512, 14, 1757, 360, 15153, 440, 1050, 9626, 367, 450, 83, 450, 83, 7, 450, 334, 6821, 14, 515, 12, 9626, 14, 4173, 430, 199, 3, 199, 3, 28688, 4438, 9163, 1098, 370, 315, 79, 3338, 4474, 199, 3, 199, 6710, 715, 26, 272, 367, 1566, 315, 315, 79, 3338, 14, 739, 837, 267, 870, 8, 1430, 9, 267, 2498, 5144, 8, 1430, 14, 2629, 9, 267, 9626, 275, 9626, 397, 59, 1430, 14, 2989, 61, 267, 2512, 14, 1757, 360, 515, 26, 450, 83, 3305, 26, 450, 83, 7, 450, 334, 6821, 14, 515, 12, 9626, 14, 4173, 430, 267, 3063, 275, 900, 14, 521, 342, 267, 6714, 275, 900, 14, 6205, 3508, 57, 5, 77, 5, 68, 5, 40, 5, 45, 5, 51, 297, 900, 14, 15198, 8, 2131, 430, 267, 1449, 675, 1627, 32513, 536, 12, 340, 2741, 315, 314, 11705, 13613, 1449, 267, 340, 9626, 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, 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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 ]
jquacinella/python-twitter
examples/twitter-to-xhtml.py
5
2756
#!/usr/bin/env python # Copyright 2007-2016 The Python-Twitter Developers # # 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. # ------------------------------------------------------------------------ # Load the latest update for a Twitter user and output it as an HTML fragment # from __future__ import print_function import codecs import sys import argparse import twitter from t import * __author__ = 'dewitt@google.com' TEMPLATE = """ <div> <a href="http://twitter.com/{user}">Twitter</a>: {user}<br> {tweet_text}<br> <a href="http://twitter.com/{user}/statuses/{status_id}">Posted {tweet_created}</a> </div> """ def main(**kwargs): api = twitter.Api(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_KEY, ACCESS_SECRET) if kwargs['user_id'] is not None: statuses = api.GetUserTimeline(user_id=kwargs['user_id']) elif kwargs['screenname'] is not None: statuses = api.GetUserTimeline(screen_name=kwargs['screenname']) if kwargs['output_file'] is not None: with open(kwargs['output_file'], 'w+') as f: for status in statuses: f.write(status) else: for status in statuses: print(TEMPLATE.format(user=status.user.screen_name, tweet_text=status.text, status_id=status.id, tweet_created=status.created_at)) if __name__ == "__main__": parser = argparse.ArgumentParser() group = parser.add_mutually_exclusive_group() group.add_argument('--user-id', help='User id for which to return timeline') group.add_argument('--screenname', help='Screenname for which to return timeline') parser.add_argument('--output-file', help='Write to file instead of stdout') args = parser.parse_args() if not (args.user_id or args.screenname): raise ValueError("You must specify one of user-id or screenname") if not all([CONSUMER_KEY, CONSUMER_SECRET, ACCESS_KEY, ACCESS_SECRET]): raise ValueError("You must define CONSUMER_KEY, CONSUMER_SECRET, ACCESS_KEY, ACCESS_SECRET in t.py") main(user_id=args.user_id, screenname=args.screenname, output_file=args.output_file)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 10219, 13, 9261, 710, 2018, 13, 24540, 23493, 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, 3, 5620, 518, 199, 3, 7190, 314, 8839, 1678, 367, 282, 19259, 922, 436, 1072, 652, 465, 376, 4163, 7956, 199, 3, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 6010, 199, 646, 984, 199, 646, 7534, 199, 199, 646, 15811, 199, 199, 504, 307, 492, 627, 199, 199, 363, 2502, 363, 275, 283, 271, 2503, 84, 32, 3098, 14, 957, 7, 199, 199, 7433, 275, 408, 199, 28, 3015, 30, 523, 665, 65, 4369, 628, 1014, 921, 13746, 14, 957, 5321, 751, 93, 1743, 24540, 1108, 65, 20020, 469, 751, 93, 28, 3289, 30, 523, 469, 23508, 63, 505, 93, 28, 3289, 30, 523, 665, 65, 4369, 628, 1014, 921, 13746, 14, 957, 5321, 751, 5995, 17084, 5321, 1205, 63, 344, 93, 1743, 6981, 471, 469, 23508, 63, 3966, 17890, 65, 30, 199, 1108, 3015, 30, 199, 624, 421, 199, 318, 2446, 3682, 958, 304, 272, 2986, 275, 15811, 14, 7394, 8, 1864, 13285, 540, 63, 3078, 12, 1993, 1868, 13285, 540, 63, 12961, 12, 1993, 437, 10203, 63, 3078, 12, 1993, 437, 10203, 63, 12961, 9, 339, 340, 2074, 459, 751, 63, 344, 418, 365, 440, 488, 26, 267, 24498, 275, 2986, 14, 1002, 1899, 27097, 8, 751, 63, 344, 29, 958, 459, 751, 63, 344, 1105, 272, 916, 2074, 459, 5410, 354, 418, 365, 440, 488, 26, 267, 24498, 275, 2986, 14, 1002, 1899, 27097, 8, 5410, 63, 354, 29, 958, 459, 5410, 354, 1105, 339, 340, 2074, 459, 1199, 63, 493, 418, 365, 440, 488, 26, 267, 543, 1551, 8, 958, 459, 1199, 63, 493, 995, 283, 87, 13854, 465, 289, 26, 288, 367, 2004, 315, 24498, 26, 355, 289, 14, 952, 8, 1205, 9, 272, 587, 26, 267, 367, 2004, 315, 24498, 26, 288, 870, 8, 7433, 14, 908, 8, 751, 29, 1205, 14, 751, 14, 5410, 63, 354, 12, 3303, 21217, 63, 505, 29, 1205, 14, 505, 12, 3303, 2004, 63, 344, 29, 1205, 14, 344, 12, 3303, 21217, 63, 3966, 29, 1205, 14, 3966, 63, 292, 430, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 1798, 275, 7534, 14, 10730, 342, 272, 1572, 275, 1798, 14, 525, 63, 25024, 63, 12730, 63, 923, 342, 272, 1572, 14, 525, 63, 2094, 4517, 751, 13, 344, 297, 1720, 534, 1899, 1305, 367, 1314, 370, 372, 20780, 358, 272, 1572, 14, 525, 63, 2094, 4517, 5410, 354, 297, 1720, 534, 9616, 354, 367, 1314, 370, 372, 20780, 358, 272, 1798, 14, 525, 63, 2094, 4517, 1199, 13, 493, 297, 1720, 534, 3534, 370, 570, 3140, 402, 3839, 358, 272, 1249, 275, 1798, 14, 1122, 63, 589, 342, 272, 340, 440, 334, 589, 14, 751, 63, 344, 503, 1249, 14, 5410, 354, 304, 267, 746, 1722, 480, 5556, 1471, 4165, 1373, 402, 922, 13, 344, 503, 6426, 354, 531, 272, 340, 440, 1006, 779, 1864, 13285, 540, 63, 3078, 12, 1868, 13285, 540, 63, 12961, 12, 437, 10203, 63, 3078, 12, 437, 10203, 63, 12961, 4682, 267, 746, 1722, 480, 5556, 1471, 5627, 1868, 13285, 540, 63, 3078, 12, 1868, 13285, 540, 63, 12961, 12, 437, 10203, 63, 3078, 12, 437, 10203, 63, 12961, 315, 307, 14, 647, 531, 272, 2446, 8, 751, 63, 344, 29, 589, 14, 751, 63, 344, 12, 6426, 354, 29, 589, 14, 5410, 354, 12, 1072, 63, 493, 29, 589, 14, 1199, 63, 493, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 10219, 13, 9261, 710, 2018, 13, 24540, 23493, 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, 3, 5620, 518, 199, 3, 7190, 314, 8839, 1678, 367, 282, 19259, 922, 436, 1072, 652, 465, 376, 4163, 7956, 199, 3, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 6010, 199, 646, 984, 199, 646, 7534, 199, 199, 646, 15811, 199, 199, 504, 307, 492, 627, 199, 199, 363, 2502, 363, 275, 283, 271, 2503, 84, 32, 3098, 14, 957, 7, 199, 199, 7433, 275, 408, 199, 28, 3015, 30, 523, 665, 65, 4369, 628, 1014, 921, 13746, 14, 957, 5321, 751, 93, 1743, 24540, 1108, 65, 20020, 469, 751, 93, 28, 3289, 30, 523, 469, 23508, 63, 505, 93, 28, 3289, 30, 523, 665, 65, 4369, 628, 1014, 921, 13746, 14, 957, 5321, 751, 5995, 17084, 5321, 1205, 63, 344, 93, 1743, 6981, 471, 469, 23508, 63, 3966, 17890, 65, 30, 199, 1108, 3015, 30, 199, 624, 421, 199, 318, 2446, 3682, 958, 304, 272, 2986, 275, 15811, 14, 7394, 8, 1864, 13285, 540, 63, 3078, 12, 1993, 1868, 13285, 540, 63, 12961, 12, 1993, 437, 10203, 63, 3078, 12, 1993, 437, 10203, 63, 12961, 9, 339, 340, 2074, 459, 751, 63, 344, 418, 365, 440, 488, 26, 267, 24498, 275, 2986, 14, 1002, 1899, 27097, 8, 751, 63, 344, 29, 958, 459, 751, 63, 344, 1105, 272, 916, 2074, 459, 5410, 354, 418, 365, 440, 488, 26, 267, 24498, 275, 2986, 14, 1002, 1899, 27097, 8, 5410, 63, 354, 29, 958, 459, 5410, 354, 1105, 339, 340, 2074, 459, 1199, 63, 493, 418, 365, 440, 488, 26, 267, 543, 1551, 8, 958, 459, 1199, 63, 493, 995, 283, 87, 13854, 465, 289, 26, 288, 367, 2004, 315, 24498, 26, 355, 289, 14, 952, 8, 1205, 9, 272, 587, 26, 267, 367, 2004, 315, 24498, 26, 288, 870, 8, 7433, 14, 908, 8, 751, 29, 1205, 14, 751, 14, 5410, 63, 354, 12, 3303, 21217, 63, 505, 29, 1205, 14, 505, 12, 3303, 2004, 63, 344, 29, 1205, 14, 344, 12, 3303, 21217, 63, 3966, 29, 1205, 14, 3966, 63, 292, 430, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 1798, 275, 7534, 14, 10730, 342, 272, 1572, 275, 1798, 14, 525, 63, 25024, 63, 12730, 63, 923, 342, 272, 1572, 14, 525, 63, 2094, 4517, 751, 13, 344, 297, 1720, 534, 1899, 1305, 367, 1314, 370, 372, 20780, 358, 272, 1572, 14, 525, 63, 2094, 4517, 5410, 354, 297, 1720, 534, 9616, 354, 367, 1314, 370, 372, 20780, 358, 272, 1798, 14, 525, 63, 2094, 4517, 1199, 13, 493, 297, 1720, 534, 3534, 370, 570, 3140, 402, 3839, 358, 272, 1249, 275, 1798, 14, 1122, 63, 589, 342, 272, 340, 440, 334, 589, 14, 751, 63, 344, 503, 1249, 14, 5410, 354, 304, 267, 746, 1722, 480, 5556, 1471, 4165, 1373, 402, 922, 13, 344, 503, 6426, 354, 531, 272, 340, 440, 1006, 779, 1864, 13285, 540, 63, 3078, 12, 1868, 13285, 540, 63, 12961, 12, 437, 10203, 63, 3078, 12, 437, 10203, 63, 12961, 4682, 267, 746, 1722, 480, 5556, 1471, 5627, 1868, 13285, 540, 63, 3078, 12, 1868, 13285, 540, 63, 12961, 12, 437, 10203, 63, 3078, 12, 437, 10203, 63, 12961, 315, 307, 14, 647, 531, 272, 2446, 8, 751, 63, 344, 29, 589, 14, 751, 63, 344, 12, 6426, 354, 29, 589, 14, 5410, 354, 12, 1072, 63, 493, 29, 589, 14, 1199, 63, 493, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
chrisxue815/leetcode_python
problems/test_1074.py
1
1156
import unittest from typing import List import utils # O(mn^2) time. O(mn) space. Prefix sum. class Solution: def numSubmatrixSumTarget(self, matrix: List[List[int]], target: int) -> int: result = 0 m = len(matrix) n = len(matrix[0]) sums = [[0] * m for _ in range(n + 1)] for r, row in enumerate(matrix): s = 0 for c, cell in enumerate(row): s += cell sums[c + 1][r] = s for lo in range(n): for hi in range(lo, n): lo_col = sums[lo] hi_col = sums[hi + 1] counts = {0: 1} s = 0 for r in range(m): s += hi_col[r] - lo_col[r] if s - target in counts: result += counts[s - target] if s in counts: counts[s] += 1 else: counts[s] = 1 return result class Test(unittest.TestCase): def test(self): utils.test(self, __file__, Solution) if __name__ == '__main__': unittest.main()
unlicense
[ 646, 2882, 199, 504, 14090, 492, 3820, 199, 199, 646, 3778, 421, 199, 3, 593, 8, 10344, 62, 18, 9, 900, 14, 593, 8, 10344, 9, 4601, 14, 25110, 3089, 14, 199, 533, 9274, 26, 272, 347, 1967, 2610, 3642, 6959, 4277, 8, 277, 12, 3634, 26, 3820, 59, 1296, 59, 442, 2365, 1347, 26, 1109, 9, 1035, 1109, 26, 267, 754, 275, 378, 267, 333, 275, 822, 8, 3642, 9, 267, 302, 275, 822, 8, 3642, 59, 16, 566, 267, 27690, 275, 3474, 16, 61, 627, 333, 367, 485, 315, 1425, 8, 78, 435, 413, 1874, 398, 367, 519, 12, 1962, 315, 3874, 8, 3642, 304, 288, 308, 275, 378, 288, 367, 286, 12, 4917, 315, 3874, 8, 1143, 304, 355, 308, 847, 4917, 355, 27690, 59, 67, 435, 413, 1527, 82, 61, 275, 308, 398, 367, 560, 315, 1425, 8, 78, 304, 288, 367, 13759, 315, 1425, 8, 320, 12, 302, 304, 355, 560, 63, 761, 275, 27690, 59, 320, 61, 355, 13759, 63, 761, 275, 27690, 59, 5812, 435, 413, 61, 355, 8242, 275, 469, 16, 26, 413, 93, 355, 308, 275, 378, 355, 367, 519, 315, 1425, 8, 77, 304, 490, 308, 847, 13759, 63, 761, 59, 82, 61, 446, 560, 63, 761, 59, 82, 61, 490, 340, 308, 446, 1347, 315, 8242, 26, 717, 754, 847, 8242, 59, 83, 446, 1347, 61, 490, 340, 308, 315, 8242, 26, 717, 8242, 59, 83, 61, 847, 413, 490, 587, 26, 717, 8242, 59, 83, 61, 275, 413, 398, 372, 754, 421, 199, 533, 1379, 8, 2796, 14, 1746, 304, 272, 347, 511, 8, 277, 304, 267, 3778, 14, 396, 8, 277, 12, 636, 493, 3108, 9274, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 14090, 492, 3820, 199, 199, 646, 3778, 421, 199, 3, 593, 8, 10344, 62, 18, 9, 900, 14, 593, 8, 10344, 9, 4601, 14, 25110, 3089, 14, 199, 533, 9274, 26, 272, 347, 1967, 2610, 3642, 6959, 4277, 8, 277, 12, 3634, 26, 3820, 59, 1296, 59, 442, 2365, 1347, 26, 1109, 9, 1035, 1109, 26, 267, 754, 275, 378, 267, 333, 275, 822, 8, 3642, 9, 267, 302, 275, 822, 8, 3642, 59, 16, 566, 267, 27690, 275, 3474, 16, 61, 627, 333, 367, 485, 315, 1425, 8, 78, 435, 413, 1874, 398, 367, 519, 12, 1962, 315, 3874, 8, 3642, 304, 288, 308, 275, 378, 288, 367, 286, 12, 4917, 315, 3874, 8, 1143, 304, 355, 308, 847, 4917, 355, 27690, 59, 67, 435, 413, 1527, 82, 61, 275, 308, 398, 367, 560, 315, 1425, 8, 78, 304, 288, 367, 13759, 315, 1425, 8, 320, 12, 302, 304, 355, 560, 63, 761, 275, 27690, 59, 320, 61, 355, 13759, 63, 761, 275, 27690, 59, 5812, 435, 413, 61, 355, 8242, 275, 469, 16, 26, 413, 93, 355, 308, 275, 378, 355, 367, 519, 315, 1425, 8, 77, 304, 490, 308, 847, 13759, 63, 761, 59, 82, 61, 446, 560, 63, 761, 59, 82, 61, 490, 340, 308, 446, 1347, 315, 8242, 26, 717, 754, 847, 8242, 59, 83, 446, 1347, 61, 490, 340, 308, 315, 8242, 26, 717, 8242, 59, 83, 61, 847, 413, 490, 587, 26, 717, 8242, 59, 83, 61, 275, 413, 398, 372, 754, 421, 199, 533, 1379, 8, 2796, 14, 1746, 304, 272, 347, 511, 8, 277, 304, 267, 3778, 14, 396, 8, 277, 12, 636, 493, 3108, 9274, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
juanyaw/python
cpython/Lib/test/test_ftplib.py
7
37729
"""Test script for ftplib module.""" # Modified by Giampaolo Rodola' to test FTP class, IPv6 and TLS # environment import ftplib import asyncore import asynchat import socket import io import errno import os import time try: import ssl except ImportError: ssl = None from unittest import TestCase, skipUnless from test import support from test.support import HOST, HOSTv6 threading = support.import_module('threading') TIMEOUT = 3 # the dummy data returned by server over the data channel when # RETR, LIST, NLST, MLSD commands are issued RETR_DATA = 'abcde12345\r\n' * 1000 LIST_DATA = 'foo\r\nbar\r\n' NLST_DATA = 'foo\r\nbar\r\n' MLSD_DATA = ("type=cdir;perm=el;unique==keVO1+ZF4; test\r\n" "type=pdir;perm=e;unique==keVO1+d?3; ..\r\n" "type=OS.unix=slink:/foobar;perm=;unique==keVO1+4G4; foobar\r\n" "type=OS.unix=chr-13/29;perm=;unique==keVO1+5G4; device\r\n" "type=OS.unix=blk-11/108;perm=;unique==keVO1+6G4; block\r\n" "type=file;perm=awr;unique==keVO1+8G4; writable\r\n" "type=dir;perm=cpmel;unique==keVO1+7G4; promiscuous\r\n" "type=dir;perm=;unique==keVO1+1t2; no-exec\r\n" "type=file;perm=r;unique==keVO1+EG4; two words\r\n" "type=file;perm=r;unique==keVO1+IH4; leading space\r\n" "type=file;perm=r;unique==keVO1+1G4; file1\r\n" "type=dir;perm=cpmel;unique==keVO1+7G4; incoming\r\n" "type=file;perm=r;unique==keVO1+1G4; file2\r\n" "type=file;perm=r;unique==keVO1+1G4; file3\r\n" "type=file;perm=r;unique==keVO1+1G4; file4\r\n") class DummyDTPHandler(asynchat.async_chat): dtp_conn_closed = False def __init__(self, conn, baseclass): asynchat.async_chat.__init__(self, conn) self.baseclass = baseclass self.baseclass.last_received_data = '' def handle_read(self): self.baseclass.last_received_data += self.recv(1024).decode('ascii') def handle_close(self): # XXX: this method can be called many times in a row for a single # connection, including in clear-text (non-TLS) mode. # (behaviour witnessed with test_data_connection) if not self.dtp_conn_closed: self.baseclass.push('226 transfer complete') self.close() self.dtp_conn_closed = True def push(self, what): if self.baseclass.next_data is not None: what = self.baseclass.next_data self.baseclass.next_data = None if not what: return self.close_when_done() super(DummyDTPHandler, self).push(what.encode('ascii')) def handle_error(self): raise Exception class DummyFTPHandler(asynchat.async_chat): dtp_handler = DummyDTPHandler def __init__(self, conn): asynchat.async_chat.__init__(self, conn) # tells the socket to handle urgent data inline (ABOR command) self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_OOBINLINE, 1) self.set_terminator(b"\r\n") self.in_buffer = [] self.dtp = None self.last_received_cmd = None self.last_received_data = '' self.next_response = '' self.next_data = None self.rest = None self.next_retr_data = RETR_DATA self.push('220 welcome') def collect_incoming_data(self, data): self.in_buffer.append(data) def found_terminator(self): line = b''.join(self.in_buffer).decode('ascii') self.in_buffer = [] if self.next_response: self.push(self.next_response) self.next_response = '' cmd = line.split(' ')[0].lower() self.last_received_cmd = cmd space = line.find(' ') if space != -1: arg = line[space + 1:] else: arg = "" if hasattr(self, 'cmd_' + cmd): method = getattr(self, 'cmd_' + cmd) method(arg) else: self.push('550 command "%s" not understood.' %cmd) def handle_error(self): raise Exception def push(self, data): asynchat.async_chat.push(self, data.encode('ascii') + b'\r\n') def cmd_port(self, arg): addr = list(map(int, arg.split(','))) ip = '%d.%d.%d.%d' %tuple(addr[:4]) port = (addr[4] * 256) + addr[5] s = socket.create_connection((ip, port), timeout=TIMEOUT) self.dtp = self.dtp_handler(s, baseclass=self) self.push('200 active data connection established') def cmd_pasv(self, arg): with socket.socket() as sock: sock.bind((self.socket.getsockname()[0], 0)) sock.listen() sock.settimeout(TIMEOUT) ip, port = sock.getsockname()[:2] ip = ip.replace('.', ','); p1 = port / 256; p2 = port % 256 self.push('227 entering passive mode (%s,%d,%d)' %(ip, p1, p2)) conn, addr = sock.accept() self.dtp = self.dtp_handler(conn, baseclass=self) def cmd_eprt(self, arg): af, ip, port = arg.split(arg[0])[1:-1] port = int(port) s = socket.create_connection((ip, port), timeout=TIMEOUT) self.dtp = self.dtp_handler(s, baseclass=self) self.push('200 active data connection established') def cmd_epsv(self, arg): with socket.socket(socket.AF_INET6) as sock: sock.bind((self.socket.getsockname()[0], 0)) sock.listen() sock.settimeout(TIMEOUT) port = sock.getsockname()[1] self.push('229 entering extended passive mode (|||%d|)' %port) conn, addr = sock.accept() self.dtp = self.dtp_handler(conn, baseclass=self) def cmd_echo(self, arg): # sends back the received string (used by the test suite) self.push(arg) def cmd_noop(self, arg): self.push('200 noop ok') def cmd_user(self, arg): self.push('331 username ok') def cmd_pass(self, arg): self.push('230 password ok') def cmd_acct(self, arg): self.push('230 acct ok') def cmd_rnfr(self, arg): self.push('350 rnfr ok') def cmd_rnto(self, arg): self.push('250 rnto ok') def cmd_dele(self, arg): self.push('250 dele ok') def cmd_cwd(self, arg): self.push('250 cwd ok') def cmd_size(self, arg): self.push('250 1000') def cmd_mkd(self, arg): self.push('257 "%s"' %arg) def cmd_rmd(self, arg): self.push('250 rmd ok') def cmd_pwd(self, arg): self.push('257 "pwd ok"') def cmd_type(self, arg): self.push('200 type ok') def cmd_quit(self, arg): self.push('221 quit ok') self.close() def cmd_abor(self, arg): self.push('226 abor ok') def cmd_stor(self, arg): self.push('125 stor ok') def cmd_rest(self, arg): self.rest = arg self.push('350 rest ok') def cmd_retr(self, arg): self.push('125 retr ok') if self.rest is not None: offset = int(self.rest) else: offset = 0 self.dtp.push(self.next_retr_data[offset:]) self.dtp.close_when_done() self.rest = None def cmd_list(self, arg): self.push('125 list ok') self.dtp.push(LIST_DATA) self.dtp.close_when_done() def cmd_nlst(self, arg): self.push('125 nlst ok') self.dtp.push(NLST_DATA) self.dtp.close_when_done() def cmd_opts(self, arg): self.push('200 opts ok') def cmd_mlsd(self, arg): self.push('125 mlsd ok') self.dtp.push(MLSD_DATA) self.dtp.close_when_done() def cmd_setlongretr(self, arg): # For testing. Next RETR will return long line. self.next_retr_data = 'x' * int(arg) self.push('125 setlongretr ok') class DummyFTPServer(asyncore.dispatcher, threading.Thread): handler = DummyFTPHandler def __init__(self, address, af=socket.AF_INET): threading.Thread.__init__(self) asyncore.dispatcher.__init__(self) self.create_socket(af, socket.SOCK_STREAM) self.bind(address) self.listen(5) self.active = False self.active_lock = threading.Lock() self.host, self.port = self.socket.getsockname()[:2] self.handler_instance = None def start(self): assert not self.active self.__flag = threading.Event() threading.Thread.start(self) self.__flag.wait() def run(self): self.active = True self.__flag.set() while self.active and asyncore.socket_map: self.active_lock.acquire() asyncore.loop(timeout=0.1, count=1) self.active_lock.release() asyncore.close_all(ignore_all=True) def stop(self): assert self.active self.active = False self.join() def handle_accepted(self, conn, addr): self.handler_instance = self.handler(conn) def handle_connect(self): self.close() handle_read = handle_connect def writable(self): return 0 def handle_error(self): raise Exception if ssl is not None: CERTFILE = os.path.join(os.path.dirname(__file__), "keycert3.pem") CAFILE = os.path.join(os.path.dirname(__file__), "pycacert.pem") class SSLConnection(asyncore.dispatcher): """An asyncore.dispatcher subclass supporting TLS/SSL.""" _ssl_accepting = False _ssl_closing = False def secure_connection(self): socket = ssl.wrap_socket(self.socket, suppress_ragged_eofs=False, certfile=CERTFILE, server_side=True, do_handshake_on_connect=False, ssl_version=ssl.PROTOCOL_SSLv23) self.del_channel() self.set_socket(socket) self._ssl_accepting = True def _do_ssl_handshake(self): try: self.socket.do_handshake() except ssl.SSLError as err: if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return elif err.args[0] == ssl.SSL_ERROR_EOF: return self.handle_close() raise except OSError as err: if err.args[0] == errno.ECONNABORTED: return self.handle_close() else: self._ssl_accepting = False def _do_ssl_shutdown(self): self._ssl_closing = True try: self.socket = self.socket.unwrap() except ssl.SSLError as err: if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return except OSError as err: # Any "socket error" corresponds to a SSL_ERROR_SYSCALL return # from OpenSSL's SSL_shutdown(), corresponding to a # closed socket condition. See also: # http://www.mail-archive.com/openssl-users@openssl.org/msg60710.html pass self._ssl_closing = False if getattr(self, '_ccc', False) is False: super(SSLConnection, self).close() else: pass def handle_read_event(self): if self._ssl_accepting: self._do_ssl_handshake() elif self._ssl_closing: self._do_ssl_shutdown() else: super(SSLConnection, self).handle_read_event() def handle_write_event(self): if self._ssl_accepting: self._do_ssl_handshake() elif self._ssl_closing: self._do_ssl_shutdown() else: super(SSLConnection, self).handle_write_event() def send(self, data): try: return super(SSLConnection, self).send(data) except ssl.SSLError as err: if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN, ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return 0 raise def recv(self, buffer_size): try: return super(SSLConnection, self).recv(buffer_size) except ssl.SSLError as err: if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return b'' if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN): self.handle_close() return b'' raise def handle_error(self): raise Exception def close(self): if (isinstance(self.socket, ssl.SSLSocket) and self.socket._sslobj is not None): self._do_ssl_shutdown() else: super(SSLConnection, self).close() class DummyTLS_DTPHandler(SSLConnection, DummyDTPHandler): """A DummyDTPHandler subclass supporting TLS/SSL.""" def __init__(self, conn, baseclass): DummyDTPHandler.__init__(self, conn, baseclass) if self.baseclass.secure_data_channel: self.secure_connection() class DummyTLS_FTPHandler(SSLConnection, DummyFTPHandler): """A DummyFTPHandler subclass supporting TLS/SSL.""" dtp_handler = DummyTLS_DTPHandler def __init__(self, conn): DummyFTPHandler.__init__(self, conn) self.secure_data_channel = False self._ccc = False def cmd_auth(self, line): """Set up secure control channel.""" self.push('234 AUTH TLS successful') self.secure_connection() def cmd_ccc(self, line): self.push('220 Reverting back to clear-text') self._ccc = True self._do_ssl_shutdown() def cmd_pbsz(self, line): """Negotiate size of buffer for secure data transfer. For TLS/SSL the only valid value for the parameter is '0'. Any other value is accepted but ignored. """ self.push('200 PBSZ=0 successful.') def cmd_prot(self, line): """Setup un/secure data channel.""" arg = line.upper() if arg == 'C': self.push('200 Protection set to Clear') self.secure_data_channel = False elif arg == 'P': self.push('200 Protection set to Private') self.secure_data_channel = True else: self.push("502 Unrecognized PROT type (use C or P).") class DummyTLS_FTPServer(DummyFTPServer): handler = DummyTLS_FTPHandler class TestFTPClass(TestCase): def setUp(self): self.server = DummyFTPServer((HOST, 0)) self.server.start() self.client = ftplib.FTP(timeout=TIMEOUT) self.client.connect(self.server.host, self.server.port) def tearDown(self): self.client.close() self.server.stop() def check_data(self, received, expected): self.assertEqual(len(received), len(expected)) self.assertEqual(received, expected) def test_getwelcome(self): self.assertEqual(self.client.getwelcome(), '220 welcome') def test_sanitize(self): self.assertEqual(self.client.sanitize('foo'), repr('foo')) self.assertEqual(self.client.sanitize('pass 12345'), repr('pass *****')) self.assertEqual(self.client.sanitize('PASS 12345'), repr('PASS *****')) def test_exceptions(self): self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 400') self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 499') self.assertRaises(ftplib.error_perm, self.client.sendcmd, 'echo 500') self.assertRaises(ftplib.error_perm, self.client.sendcmd, 'echo 599') self.assertRaises(ftplib.error_proto, self.client.sendcmd, 'echo 999') def test_all_errors(self): exceptions = (ftplib.error_reply, ftplib.error_temp, ftplib.error_perm, ftplib.error_proto, ftplib.Error, OSError, EOFError) for x in exceptions: try: raise x('exception not included in all_errors set') except ftplib.all_errors: pass def test_set_pasv(self): # passive mode is supposed to be enabled by default self.assertTrue(self.client.passiveserver) self.client.set_pasv(True) self.assertTrue(self.client.passiveserver) self.client.set_pasv(False) self.assertFalse(self.client.passiveserver) def test_voidcmd(self): self.client.voidcmd('echo 200') self.client.voidcmd('echo 299') self.assertRaises(ftplib.error_reply, self.client.voidcmd, 'echo 199') self.assertRaises(ftplib.error_reply, self.client.voidcmd, 'echo 300') def test_login(self): self.client.login() def test_acct(self): self.client.acct('passwd') def test_rename(self): self.client.rename('a', 'b') self.server.handler_instance.next_response = '200' self.assertRaises(ftplib.error_reply, self.client.rename, 'a', 'b') def test_delete(self): self.client.delete('foo') self.server.handler_instance.next_response = '199' self.assertRaises(ftplib.error_reply, self.client.delete, 'foo') def test_size(self): self.client.size('foo') def test_mkd(self): dir = self.client.mkd('/foo') self.assertEqual(dir, '/foo') def test_rmd(self): self.client.rmd('foo') def test_cwd(self): dir = self.client.cwd('/foo') self.assertEqual(dir, '250 cwd ok') def test_pwd(self): dir = self.client.pwd() self.assertEqual(dir, 'pwd ok') def test_quit(self): self.assertEqual(self.client.quit(), '221 quit ok') # Ensure the connection gets closed; sock attribute should be None self.assertEqual(self.client.sock, None) def test_abort(self): self.client.abort() def test_retrbinary(self): def callback(data): received.append(data.decode('ascii')) received = [] self.client.retrbinary('retr', callback) self.check_data(''.join(received), RETR_DATA) def test_retrbinary_rest(self): def callback(data): received.append(data.decode('ascii')) for rest in (0, 10, 20): received = [] self.client.retrbinary('retr', callback, rest=rest) self.check_data(''.join(received), RETR_DATA[rest:]) def test_retrlines(self): received = [] self.client.retrlines('retr', received.append) self.check_data(''.join(received), RETR_DATA.replace('\r\n', '')) def test_storbinary(self): f = io.BytesIO(RETR_DATA.encode('ascii')) self.client.storbinary('stor', f) self.check_data(self.server.handler_instance.last_received_data, RETR_DATA) # test new callback arg flag = [] f.seek(0) self.client.storbinary('stor', f, callback=lambda x: flag.append(None)) self.assertTrue(flag) def test_storbinary_rest(self): f = io.BytesIO(RETR_DATA.replace('\r\n', '\n').encode('ascii')) for r in (30, '30'): f.seek(0) self.client.storbinary('stor', f, rest=r) self.assertEqual(self.server.handler_instance.rest, str(r)) def test_storlines(self): f = io.BytesIO(RETR_DATA.replace('\r\n', '\n').encode('ascii')) self.client.storlines('stor', f) self.check_data(self.server.handler_instance.last_received_data, RETR_DATA) # test new callback arg flag = [] f.seek(0) self.client.storlines('stor foo', f, callback=lambda x: flag.append(None)) self.assertTrue(flag) f = io.StringIO(RETR_DATA.replace('\r\n', '\n')) # storlines() expects a binary file, not a text file with support.check_warnings(('', BytesWarning), quiet=True): self.assertRaises(TypeError, self.client.storlines, 'stor foo', f) def test_nlst(self): self.client.nlst() self.assertEqual(self.client.nlst(), NLST_DATA.split('\r\n')[:-1]) def test_dir(self): l = [] self.client.dir(lambda x: l.append(x)) self.assertEqual(''.join(l), LIST_DATA.replace('\r\n', '')) def test_mlsd(self): list(self.client.mlsd()) list(self.client.mlsd(path='/')) list(self.client.mlsd(path='/', facts=['size', 'type'])) ls = list(self.client.mlsd()) for name, facts in ls: self.assertIsInstance(name, str) self.assertIsInstance(facts, dict) self.assertTrue(name) self.assertIn('type', facts) self.assertIn('perm', facts) self.assertIn('unique', facts) def set_data(data): self.server.handler_instance.next_data = data def test_entry(line, type=None, perm=None, unique=None, name=None): type = 'type' if type is None else type perm = 'perm' if perm is None else perm unique = 'unique' if unique is None else unique name = 'name' if name is None else name set_data(line) _name, facts = next(self.client.mlsd()) self.assertEqual(_name, name) self.assertEqual(facts['type'], type) self.assertEqual(facts['perm'], perm) self.assertEqual(facts['unique'], unique) # plain test_entry('type=type;perm=perm;unique=unique; name\r\n') # "=" in fact value test_entry('type=ty=pe;perm=perm;unique=unique; name\r\n', type="ty=pe") test_entry('type==type;perm=perm;unique=unique; name\r\n', type="=type") test_entry('type=t=y=pe;perm=perm;unique=unique; name\r\n', type="t=y=pe") test_entry('type=====;perm=perm;unique=unique; name\r\n', type="====") # spaces in name test_entry('type=type;perm=perm;unique=unique; na me\r\n', name="na me") test_entry('type=type;perm=perm;unique=unique; name \r\n', name="name ") test_entry('type=type;perm=perm;unique=unique; name\r\n', name=" name") test_entry('type=type;perm=perm;unique=unique; n am e\r\n', name="n am e") # ";" in name test_entry('type=type;perm=perm;unique=unique; na;me\r\n', name="na;me") test_entry('type=type;perm=perm;unique=unique; ;name\r\n', name=";name") test_entry('type=type;perm=perm;unique=unique; ;name;\r\n', name=";name;") test_entry('type=type;perm=perm;unique=unique; ;;;;\r\n', name=";;;;") # case sensitiveness set_data('Type=type;TyPe=perm;UNIQUE=unique; name\r\n') _name, facts = next(self.client.mlsd()) for x in facts: self.assertTrue(x.islower()) # no data (directory empty) set_data('') self.assertRaises(StopIteration, next, self.client.mlsd()) set_data('') for x in self.client.mlsd(): self.fail("unexpected data %s" % x) def test_makeport(self): with self.client.makeport(): # IPv4 is in use, just make sure send_eprt has not been used self.assertEqual(self.server.handler_instance.last_received_cmd, 'port') def test_makepasv(self): host, port = self.client.makepasv() conn = socket.create_connection((host, port), timeout=TIMEOUT) conn.close() # IPv4 is in use, just make sure send_epsv has not been used self.assertEqual(self.server.handler_instance.last_received_cmd, 'pasv') def test_with_statement(self): self.client.quit() def is_client_connected(): if self.client.sock is None: return False try: self.client.sendcmd('noop') except (OSError, EOFError): return False return True # base test with ftplib.FTP(timeout=TIMEOUT) as self.client: self.client.connect(self.server.host, self.server.port) self.client.sendcmd('noop') self.assertTrue(is_client_connected()) self.assertEqual(self.server.handler_instance.last_received_cmd, 'quit') self.assertFalse(is_client_connected()) # QUIT sent inside the with block with ftplib.FTP(timeout=TIMEOUT) as self.client: self.client.connect(self.server.host, self.server.port) self.client.sendcmd('noop') self.client.quit() self.assertEqual(self.server.handler_instance.last_received_cmd, 'quit') self.assertFalse(is_client_connected()) # force a wrong response code to be sent on QUIT: error_perm # is expected and the connection is supposed to be closed try: with ftplib.FTP(timeout=TIMEOUT) as self.client: self.client.connect(self.server.host, self.server.port) self.client.sendcmd('noop') self.server.handler_instance.next_response = '550 error on quit' except ftplib.error_perm as err: self.assertEqual(str(err), '550 error on quit') else: self.fail('Exception not raised') # needed to give the threaded server some time to set the attribute # which otherwise would still be == 'noop' time.sleep(0.1) self.assertEqual(self.server.handler_instance.last_received_cmd, 'quit') self.assertFalse(is_client_connected()) def test_source_address(self): self.client.quit() port = support.find_unused_port() try: self.client.connect(self.server.host, self.server.port, source_address=(HOST, port)) self.assertEqual(self.client.sock.getsockname()[1], port) self.client.quit() except OSError as e: if e.errno == errno.EADDRINUSE: self.skipTest("couldn't bind to port %d" % port) raise def test_source_address_passive_connection(self): port = support.find_unused_port() self.client.source_address = (HOST, port) try: with self.client.transfercmd('list') as sock: self.assertEqual(sock.getsockname()[1], port) except OSError as e: if e.errno == errno.EADDRINUSE: self.skipTest("couldn't bind to port %d" % port) raise def test_parse257(self): self.assertEqual(ftplib.parse257('257 "/foo/bar"'), '/foo/bar') self.assertEqual(ftplib.parse257('257 "/foo/bar" created'), '/foo/bar') self.assertEqual(ftplib.parse257('257 ""'), '') self.assertEqual(ftplib.parse257('257 "" created'), '') self.assertRaises(ftplib.error_reply, ftplib.parse257, '250 "/foo/bar"') # The 257 response is supposed to include the directory # name and in case it contains embedded double-quotes # they must be doubled (see RFC-959, chapter 7, appendix 2). self.assertEqual(ftplib.parse257('257 "/foo/b""ar"'), '/foo/b"ar') self.assertEqual(ftplib.parse257('257 "/foo/b""ar" created'), '/foo/b"ar') def test_line_too_long(self): self.assertRaises(ftplib.Error, self.client.sendcmd, 'x' * self.client.maxline * 2) def test_retrlines_too_long(self): self.client.sendcmd('SETLONGRETR %d' % (self.client.maxline * 2)) received = [] self.assertRaises(ftplib.Error, self.client.retrlines, 'retr', received.append) def test_storlines_too_long(self): f = io.BytesIO(b'x' * self.client.maxline * 2) self.assertRaises(ftplib.Error, self.client.storlines, 'stor', f) @skipUnless(support.IPV6_ENABLED, "IPv6 not enabled") class TestIPv6Environment(TestCase): def setUp(self): self.server = DummyFTPServer((HOSTv6, 0), af=socket.AF_INET6) self.server.start() self.client = ftplib.FTP(timeout=TIMEOUT) self.client.connect(self.server.host, self.server.port) def tearDown(self): self.client.close() self.server.stop() def test_af(self): self.assertEqual(self.client.af, socket.AF_INET6) def test_makeport(self): with self.client.makeport(): self.assertEqual(self.server.handler_instance.last_received_cmd, 'eprt') def test_makepasv(self): host, port = self.client.makepasv() conn = socket.create_connection((host, port), timeout=TIMEOUT) conn.close() self.assertEqual(self.server.handler_instance.last_received_cmd, 'epsv') def test_transfer(self): def retr(): def callback(data): received.append(data.decode('ascii')) received = [] self.client.retrbinary('retr', callback) self.assertEqual(len(''.join(received)), len(RETR_DATA)) self.assertEqual(''.join(received), RETR_DATA) self.client.set_pasv(True) retr() self.client.set_pasv(False) retr() @skipUnless(ssl, "SSL not available") class TestTLS_FTPClassMixin(TestFTPClass): """Repeat TestFTPClass tests starting the TLS layer for both control and data connections first. """ def setUp(self): self.server = DummyTLS_FTPServer((HOST, 0)) self.server.start() self.client = ftplib.FTP_TLS(timeout=TIMEOUT) self.client.connect(self.server.host, self.server.port) # enable TLS self.client.auth() self.client.prot_p() @skipUnless(ssl, "SSL not available") class TestTLS_FTPClass(TestCase): """Specific TLS_FTP class tests.""" def setUp(self): self.server = DummyTLS_FTPServer((HOST, 0)) self.server.start() self.client = ftplib.FTP_TLS(timeout=TIMEOUT) self.client.connect(self.server.host, self.server.port) def tearDown(self): self.client.close() self.server.stop() def test_control_connection(self): self.assertNotIsInstance(self.client.sock, ssl.SSLSocket) self.client.auth() self.assertIsInstance(self.client.sock, ssl.SSLSocket) def test_data_connection(self): # clear text with self.client.transfercmd('list') as sock: self.assertNotIsInstance(sock, ssl.SSLSocket) self.assertEqual(self.client.voidresp(), "226 transfer complete") # secured, after PROT P self.client.prot_p() with self.client.transfercmd('list') as sock: self.assertIsInstance(sock, ssl.SSLSocket) self.assertEqual(self.client.voidresp(), "226 transfer complete") # PROT C is issued, the connection must be in cleartext again self.client.prot_c() with self.client.transfercmd('list') as sock: self.assertNotIsInstance(sock, ssl.SSLSocket) self.assertEqual(self.client.voidresp(), "226 transfer complete") def test_login(self): # login() is supposed to implicitly secure the control connection self.assertNotIsInstance(self.client.sock, ssl.SSLSocket) self.client.login() self.assertIsInstance(self.client.sock, ssl.SSLSocket) # make sure that AUTH TLS doesn't get issued again self.client.login() def test_auth_issued_twice(self): self.client.auth() self.assertRaises(ValueError, self.client.auth) def test_auth_ssl(self): try: self.client.ssl_version = ssl.PROTOCOL_SSLv23 self.client.auth() self.assertRaises(ValueError, self.client.auth) finally: self.client.ssl_version = ssl.PROTOCOL_TLSv1 def test_context(self): self.client.quit() ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertRaises(ValueError, ftplib.FTP_TLS, keyfile=CERTFILE, context=ctx) self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE, context=ctx) self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE, keyfile=CERTFILE, context=ctx) self.client = ftplib.FTP_TLS(context=ctx, timeout=TIMEOUT) self.client.connect(self.server.host, self.server.port) self.assertNotIsInstance(self.client.sock, ssl.SSLSocket) self.client.auth() self.assertIs(self.client.sock.context, ctx) self.assertIsInstance(self.client.sock, ssl.SSLSocket) self.client.prot_p() with self.client.transfercmd('list') as sock: self.assertIs(sock.context, ctx) self.assertIsInstance(sock, ssl.SSLSocket) def test_ccc(self): self.assertRaises(ValueError, self.client.ccc) self.client.login(secure=True) self.assertIsInstance(self.client.sock, ssl.SSLSocket) self.client.ccc() self.assertRaises(ValueError, self.client.sock.unwrap) def test_check_hostname(self): self.client.quit() ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.verify_mode = ssl.CERT_REQUIRED ctx.check_hostname = True ctx.load_verify_locations(CAFILE) self.client = ftplib.FTP_TLS(context=ctx, timeout=TIMEOUT) # 127.0.0.1 doesn't match SAN self.client.connect(self.server.host, self.server.port) with self.assertRaises(ssl.CertificateError): self.client.auth() # exception quits connection self.client.connect(self.server.host, self.server.port) self.client.prot_p() with self.assertRaises(ssl.CertificateError): with self.client.transfercmd("list") as sock: pass self.client.quit() self.client.connect("localhost", self.server.port) self.client.auth() self.client.quit() self.client.connect("localhost", self.server.port) self.client.prot_p() with self.client.transfercmd("list") as sock: pass class TestTimeouts(TestCase): def setUp(self): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(20) self.port = support.bind_port(self.sock) self.server_thread = threading.Thread(target=self.server) self.server_thread.start() # Wait for the server to be ready. self.evt.wait() self.evt.clear() self.old_port = ftplib.FTP.port ftplib.FTP.port = self.port def tearDown(self): ftplib.FTP.port = self.old_port self.server_thread.join() def server(self): # This method sets the evt 3 times: # 1) when the connection is ready to be accepted. # 2) when it is safe for the caller to close the connection # 3) when we have closed the socket self.sock.listen() # (1) Signal the caller that we are ready to accept the connection. self.evt.set() try: conn, addr = self.sock.accept() except socket.timeout: pass else: conn.sendall(b"1 Hola mundo\n") conn.shutdown(socket.SHUT_WR) # (2) Signal the caller that it is safe to close the socket. self.evt.set() conn.close() finally: self.sock.close() def testTimeoutDefault(self): # default -- use global socket timeout self.assertIsNone(socket.getdefaulttimeout()) socket.setdefaulttimeout(30) try: ftp = ftplib.FTP(HOST) finally: socket.setdefaulttimeout(None) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutNone(self): # no timeout -- do not use global socket timeout self.assertIsNone(socket.getdefaulttimeout()) socket.setdefaulttimeout(30) try: ftp = ftplib.FTP(HOST, timeout=None) finally: socket.setdefaulttimeout(None) self.assertIsNone(ftp.sock.gettimeout()) self.evt.wait() ftp.close() def testTimeoutValue(self): # a value ftp = ftplib.FTP(HOST, timeout=30) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutConnect(self): ftp = ftplib.FTP() ftp.connect(HOST, timeout=30) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutDifferentOrder(self): ftp = ftplib.FTP(timeout=30) ftp.connect(HOST) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutDirectAccess(self): ftp = ftplib.FTP() ftp.timeout = 30 ftp.connect(HOST) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def test_main(): tests = [TestFTPClass, TestTimeouts, TestIPv6Environment, TestTLS_FTPClassMixin, TestTLS_FTPClass] thread_info = support.threading_setup() try: support.run_unittest(*tests) finally: support.threading_cleanup(*thread_info) if __name__ == '__main__': test_main()
bsd-3-clause
[ 624, 774, 2884, 367, 14904, 773, 859, 1041, 199, 199, 3, 22016, 701, 598, 4674, 311, 8035, 320, 820, 364, 22205, 7, 370, 511, 23125, 1021, 12, 6509, 22, 436, 12213, 199, 3, 3734, 199, 199, 646, 14904, 773, 199, 646, 30328, 199, 646, 465, 5654, 292, 199, 646, 2838, 199, 646, 5890, 199, 646, 7554, 199, 646, 747, 199, 646, 900, 199, 893, 26, 272, 492, 6149, 199, 2590, 3545, 26, 272, 6149, 275, 488, 199, 199, 504, 2882, 492, 7640, 12, 3372, 5524, 199, 504, 511, 492, 2291, 199, 504, 511, 14, 4058, 492, 25741, 12, 25741, 86, 22, 199, 12562, 275, 2291, 14, 646, 63, 578, 360, 12562, 358, 199, 199, 8899, 275, 650, 199, 3, 314, 7283, 666, 2138, 701, 1654, 1806, 314, 666, 3623, 1380, 199, 3, 17409, 50, 12, 21716, 12, 24719, 840, 12, 28007, 3693, 3718, 787, 21117, 199, 7341, 50, 63, 3998, 275, 283, 28109, 13261, 60, 82, 60, 78, 7, 627, 5198, 199, 4924, 63, 3998, 275, 283, 1421, 60, 82, 60, 78, 1700, 60, 82, 60, 78, 7, 199, 14176, 840, 63, 3998, 275, 283, 1421, 60, 82, 60, 78, 1700, 60, 82, 60, 78, 7, 199, 1698, 3693, 63, 3998, 275, 1689, 466, 29, 67, 694, 27, 8220, 29, 352, 27, 3235, 389, 415, 10662, 17, 11, 23643, 20, 27, 511, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 80, 694, 27, 8220, 29, 69, 27, 3235, 389, 415, 10662, 17, 11, 68, 31, 19, 27, 2508, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 3100, 14, 11864, 29, 83, 1073, 11254, 9664, 27, 8220, 29, 27, 3235, 389, 415, 10662, 17, 11, 20, 39, 20, 27, 29245, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 3100, 14, 11864, 29, 10194, 13, 969, 15, 1398, 27, 8220, 29, 27, 3235, 389, 415, 10662, 17, 11, 21, 39, 20, 27, 2243, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 3100, 14, 11864, 29, 14023, 13, 845, 15, 8079, 27, 8220, 29, 27, 3235, 389, 415, 10662, 17, 11, 22, 39, 20, 27, 1853, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 493, 27, 8220, 29, 10084, 82, 27, 3235, 389, 415, 10662, 17, 11, 24, 39, 20, 27, 17267, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 694, 27, 8220, 29, 1850, 26908, 27, 3235, 389, 415, 10662, 17, 11, 23, 39, 20, 27, 8023, 27641, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 694, 27, 8220, 29, 27, 3235, 389, 415, 10662, 17, 11, 17, 84, 18, 27, 949, 13, 1628, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 493, 27, 8220, 29, 82, 27, 3235, 389, 415, 10662, 17, 11, 4680, 20, 27, 2877, 5932, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 493, 27, 8220, 29, 82, 27, 3235, 389, 415, 10662, 17, 11, 19824, 20, 27, 221, 9186, 4601, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 493, 27, 8220, 29, 82, 27, 3235, 389, 415, 10662, 17, 11, 17, 39, 20, 27, 570, 17, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 694, 27, 8220, 29, 1850, 26908, 27, 3235, 389, 415, 10662, 17, 11, 23, 39, 20, 27, 12467, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 493, 27, 8220, 29, 82, 27, 3235, 389, 415, 10662, 17, 11, 17, 39, 20, 27, 570, 18, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 493, 27, 8220, 29, 82, 27, 3235, 389, 415, 10662, 17, 11, 17, 39, 20, 27, 570, 19, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 493, 27, 8220, 29, 82, 27, 3235, 389, 415, 10662, 17, 11, 17, 39, 20, 27, 570, 20, 60, 82, 60, 78, 531, 421, 199, 533, 9762, 36, 6495, 2461, 8, 305, 5654, 292, 14, 4146, 63, 10289, 304, 272, 366, 683, 63, 1631, 63, 5938, 275, 756, 339, 347, 636, 826, 721, 277, 12, 2557, 12, 1300, 533, 304, 267, 465, 5654, 292, 14, 4146, 63, 10289, 855, 826, 721, 277, 12, 2557, 9, 267, 291, 14, 1095, 533, 275, 1300, 533, 267, 291, 14, 1095, 533, 14, 2019, 63, 9226, 63, 576, 275, 2125, 339, 347, 2429, 63, 739, 8, 277, 304, 267, 291, 14, 1095, 533, 14, 2019, 63, 9226, 63, 576, 847, 291, 14, 7637, 8, 7727, 680, 2708, 360, 4371, 358, 339, 347, 2429, 63, 1600, 8, 277, 304, 267, 327, 5787, 26, 642, 1083, 883, 506, 2797, 5002, 5431, 315, 282, 1962, 367, 282, 2849, 267, 327, 1950, 12, 5893, 315, 5436, 13, 505, 334, 2865, 13, 10224, 9, 818, 14, 267, 327, 334, 1235, 4425, 567, 336, 390, 17775, 939, 543, 511, 63, 576, 63, 2105, 9, 267, 340, 440, 291, 14, 68, 683, 63, 1631, 63, 5938, 26, 288, 291, 14, 1095, 533, 14, 5335, 360, 11085, 9307, 4890, 358, 288, 291, 14, 1600, 342, 288, 291, 14, 68, 683, 63, 1631, 63, 5938, 275, 715, 339, 347, 6675, 8, 277, 12, 4052, 304, 267, 340, 291, 14, 1095, 533, 14, 2184, 63, 576, 365, 440, 488, 26, 288, 4052, 275, 291, 14, 1095, 533, 14, 2184, 63, 576, 288, 291, 14, 1095, 533, 14, 2184, 63, 576, 275, 488, 267, 340, 440, 4052, 26, 288, 372, 291, 14, 1600, 63, 6526, 63, 4456, 342, 267, 1613, 8, 11324, 36, 6495, 2461, 12, 291, 680, 5335, 8, 10058, 14, 2143, 360, 4371, 1333, 339, 347, 2429, 63, 705, 8, 277, 304, 267, 746, 2186, 421, 199, 533, 9762, 15123, 2461, 8, 305, 5654, 292, 14, 4146, 63, 10289, 304, 339, 366, 683, 63, 2232, 275, 9762, 36, 6495, 2461, 339, 347, 636, 826, 721, 277, 12, 2557, 304, 267, 465, 5654, 292, 14, 4146, 63, 10289, 855, 826, 721, 277, 12, 2557, 9, 267, 327, 26544, 314, 2838, 370, 2429, 7629, 12069, 666, 8308, 334, 1217, 726, 1414, 9, 267, 291, 14, 3450, 14, 27689, 8, 3450, 14, 15096, 63, 17462, 12, 2838, 14, 4118, 63, 47, 5488, 568, 6174, 12, 413, 9, 267, 291, 14, 409, 63, 26370, 8, 66, 3212, 82, 60, 78, 531, 267, 291, 14, 262, 63, 2738, 275, 942, 267, 291, 14 ]
[ 774, 2884, 367, 14904, 773, 859, 1041, 199, 199, 3, 22016, 701, 598, 4674, 311, 8035, 320, 820, 364, 22205, 7, 370, 511, 23125, 1021, 12, 6509, 22, 436, 12213, 199, 3, 3734, 199, 199, 646, 14904, 773, 199, 646, 30328, 199, 646, 465, 5654, 292, 199, 646, 2838, 199, 646, 5890, 199, 646, 7554, 199, 646, 747, 199, 646, 900, 199, 893, 26, 272, 492, 6149, 199, 2590, 3545, 26, 272, 6149, 275, 488, 199, 199, 504, 2882, 492, 7640, 12, 3372, 5524, 199, 504, 511, 492, 2291, 199, 504, 511, 14, 4058, 492, 25741, 12, 25741, 86, 22, 199, 12562, 275, 2291, 14, 646, 63, 578, 360, 12562, 358, 199, 199, 8899, 275, 650, 199, 3, 314, 7283, 666, 2138, 701, 1654, 1806, 314, 666, 3623, 1380, 199, 3, 17409, 50, 12, 21716, 12, 24719, 840, 12, 28007, 3693, 3718, 787, 21117, 199, 7341, 50, 63, 3998, 275, 283, 28109, 13261, 60, 82, 60, 78, 7, 627, 5198, 199, 4924, 63, 3998, 275, 283, 1421, 60, 82, 60, 78, 1700, 60, 82, 60, 78, 7, 199, 14176, 840, 63, 3998, 275, 283, 1421, 60, 82, 60, 78, 1700, 60, 82, 60, 78, 7, 199, 1698, 3693, 63, 3998, 275, 1689, 466, 29, 67, 694, 27, 8220, 29, 352, 27, 3235, 389, 415, 10662, 17, 11, 23643, 20, 27, 511, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 80, 694, 27, 8220, 29, 69, 27, 3235, 389, 415, 10662, 17, 11, 68, 31, 19, 27, 2508, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 3100, 14, 11864, 29, 83, 1073, 11254, 9664, 27, 8220, 29, 27, 3235, 389, 415, 10662, 17, 11, 20, 39, 20, 27, 29245, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 3100, 14, 11864, 29, 10194, 13, 969, 15, 1398, 27, 8220, 29, 27, 3235, 389, 415, 10662, 17, 11, 21, 39, 20, 27, 2243, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 3100, 14, 11864, 29, 14023, 13, 845, 15, 8079, 27, 8220, 29, 27, 3235, 389, 415, 10662, 17, 11, 22, 39, 20, 27, 1853, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 493, 27, 8220, 29, 10084, 82, 27, 3235, 389, 415, 10662, 17, 11, 24, 39, 20, 27, 17267, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 694, 27, 8220, 29, 1850, 26908, 27, 3235, 389, 415, 10662, 17, 11, 23, 39, 20, 27, 8023, 27641, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 694, 27, 8220, 29, 27, 3235, 389, 415, 10662, 17, 11, 17, 84, 18, 27, 949, 13, 1628, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 493, 27, 8220, 29, 82, 27, 3235, 389, 415, 10662, 17, 11, 4680, 20, 27, 2877, 5932, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 493, 27, 8220, 29, 82, 27, 3235, 389, 415, 10662, 17, 11, 19824, 20, 27, 221, 9186, 4601, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 493, 27, 8220, 29, 82, 27, 3235, 389, 415, 10662, 17, 11, 17, 39, 20, 27, 570, 17, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 694, 27, 8220, 29, 1850, 26908, 27, 3235, 389, 415, 10662, 17, 11, 23, 39, 20, 27, 12467, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 493, 27, 8220, 29, 82, 27, 3235, 389, 415, 10662, 17, 11, 17, 39, 20, 27, 570, 18, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 493, 27, 8220, 29, 82, 27, 3235, 389, 415, 10662, 17, 11, 17, 39, 20, 27, 570, 19, 60, 82, 60, 78, 2, 1467, 298, 466, 29, 493, 27, 8220, 29, 82, 27, 3235, 389, 415, 10662, 17, 11, 17, 39, 20, 27, 570, 20, 60, 82, 60, 78, 531, 421, 199, 533, 9762, 36, 6495, 2461, 8, 305, 5654, 292, 14, 4146, 63, 10289, 304, 272, 366, 683, 63, 1631, 63, 5938, 275, 756, 339, 347, 636, 826, 721, 277, 12, 2557, 12, 1300, 533, 304, 267, 465, 5654, 292, 14, 4146, 63, 10289, 855, 826, 721, 277, 12, 2557, 9, 267, 291, 14, 1095, 533, 275, 1300, 533, 267, 291, 14, 1095, 533, 14, 2019, 63, 9226, 63, 576, 275, 2125, 339, 347, 2429, 63, 739, 8, 277, 304, 267, 291, 14, 1095, 533, 14, 2019, 63, 9226, 63, 576, 847, 291, 14, 7637, 8, 7727, 680, 2708, 360, 4371, 358, 339, 347, 2429, 63, 1600, 8, 277, 304, 267, 327, 5787, 26, 642, 1083, 883, 506, 2797, 5002, 5431, 315, 282, 1962, 367, 282, 2849, 267, 327, 1950, 12, 5893, 315, 5436, 13, 505, 334, 2865, 13, 10224, 9, 818, 14, 267, 327, 334, 1235, 4425, 567, 336, 390, 17775, 939, 543, 511, 63, 576, 63, 2105, 9, 267, 340, 440, 291, 14, 68, 683, 63, 1631, 63, 5938, 26, 288, 291, 14, 1095, 533, 14, 5335, 360, 11085, 9307, 4890, 358, 288, 291, 14, 1600, 342, 288, 291, 14, 68, 683, 63, 1631, 63, 5938, 275, 715, 339, 347, 6675, 8, 277, 12, 4052, 304, 267, 340, 291, 14, 1095, 533, 14, 2184, 63, 576, 365, 440, 488, 26, 288, 4052, 275, 291, 14, 1095, 533, 14, 2184, 63, 576, 288, 291, 14, 1095, 533, 14, 2184, 63, 576, 275, 488, 267, 340, 440, 4052, 26, 288, 372, 291, 14, 1600, 63, 6526, 63, 4456, 342, 267, 1613, 8, 11324, 36, 6495, 2461, 12, 291, 680, 5335, 8, 10058, 14, 2143, 360, 4371, 1333, 339, 347, 2429, 63, 705, 8, 277, 304, 267, 746, 2186, 421, 199, 533, 9762, 15123, 2461, 8, 305, 5654, 292, 14, 4146, 63, 10289, 304, 339, 366, 683, 63, 2232, 275, 9762, 36, 6495, 2461, 339, 347, 636, 826, 721, 277, 12, 2557, 304, 267, 465, 5654, 292, 14, 4146, 63, 10289, 855, 826, 721, 277, 12, 2557, 9, 267, 327, 26544, 314, 2838, 370, 2429, 7629, 12069, 666, 8308, 334, 1217, 726, 1414, 9, 267, 291, 14, 3450, 14, 27689, 8, 3450, 14, 15096, 63, 17462, 12, 2838, 14, 4118, 63, 47, 5488, 568, 6174, 12, 413, 9, 267, 291, 14, 409, 63, 26370, 8, 66, 3212, 82, 60, 78, 531, 267, 291, 14, 262, 63, 2738, 275, 942, 267, 291, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
hvdieren/parsec-swan
pkgs/libs/libxml2/src/python/tests/thread2.py
87
2240
#!/usr/bin/python -u import string, sys, time import thread from threading import Thread, Lock import libxml2 THREADS_COUNT = 15 failed = 0 class ErrorHandler: def __init__(self): self.errors = [] self.lock = Lock() def handler(self,ctx,str): self.lock.acquire() self.errors.append(str) self.lock.release() def getLineNumbersDefault(): old = libxml2.lineNumbersDefault(0) libxml2.lineNumbersDefault(old) return old def test(expectedLineNumbersDefault): time.sleep(1) global failed # check a per thread-global if expectedLineNumbersDefault != getLineNumbersDefault(): failed = 1 print "FAILED to obtain correct value for " \ "lineNumbersDefault in thread %d" % thread.get_ident() # check ther global error handler # (which is NOT per-thread in the python bindings) try: doc = libxml2.parseFile("bad.xml") except: pass else: assert "failed" # global error handler eh = ErrorHandler() libxml2.registerErrorHandler(eh.handler,"") # set on the main thread only libxml2.lineNumbersDefault(1) test(1) ec = len(eh.errors) if ec == 0: print "FAILED: should have obtained errors" sys.exit(1) ts = [] for i in range(THREADS_COUNT): # expect 0 for lineNumbersDefault because # the new value has been set on the main thread only ts.append(Thread(target=test,args=(0,))) for t in ts: t.start() for t in ts: t.join() if len(eh.errors) != ec+THREADS_COUNT*ec: print "FAILED: did not obtain the correct number of errors" sys.exit(1) # set lineNumbersDefault for future new threads libxml2.thrDefLineNumbersDefaultValue(1) ts = [] for i in range(THREADS_COUNT): # expect 1 for lineNumbersDefault ts.append(Thread(target=test,args=(1,))) for t in ts: t.start() for t in ts: t.join() if len(eh.errors) != ec+THREADS_COUNT*ec*2: print "FAILED: did not obtain the correct number of errors" sys.exit(1) if failed: print "FAILED" sys.exit(1) # Memory debug specific libxml2.cleanupParser() if libxml2.debugMemory(1) == 0: print "OK" else: print "Memory leak %d bytes" % (libxml2.debugMemory(1)) libxml2.dumpMemory()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1548, 446, 85, 199, 646, 1059, 12, 984, 12, 900, 199, 646, 2462, 199, 504, 5796, 492, 11086, 12, 15536, 199, 199, 646, 15404, 18, 199, 199, 16103, 51, 63, 8760, 275, 4114, 199, 199, 4892, 275, 378, 199, 199, 533, 4520, 2461, 26, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2550, 275, 942, 267, 291, 14, 831, 275, 15536, 342, 339, 347, 3016, 8, 277, 12, 3799, 12, 495, 304, 267, 291, 14, 831, 14, 8174, 342, 267, 291, 14, 2550, 14, 740, 8, 495, 9, 267, 291, 14, 831, 14, 3221, 342, 199, 199, 318, 664, 3049, 22951, 2698, 837, 272, 2269, 275, 15404, 18, 14, 604, 22951, 2698, 8, 16, 9, 272, 15404, 18, 14, 604, 22951, 2698, 8, 1753, 9, 272, 372, 2269, 199, 199, 318, 511, 8, 2062, 3049, 22951, 2698, 304, 272, 900, 14, 4532, 8, 17, 9, 272, 2288, 3405, 272, 327, 1104, 282, 1126, 2462, 13, 2966, 272, 340, 1420, 3049, 22951, 2698, 1137, 664, 3049, 22951, 2698, 837, 267, 3405, 275, 413, 267, 870, 298, 12299, 370, 3332, 3211, 574, 367, 298, 971, 1598, 298, 604, 22951, 2698, 315, 2462, 450, 68, 2, 450, 2462, 14, 362, 63, 5425, 342, 272, 327, 1104, 23418, 2288, 1125, 3016, 5591, 327, 334, 6777, 365, 2845, 1126, 13, 2671, 315, 314, 2366, 17792, 9, 272, 862, 26, 267, 1382, 275, 15404, 18, 14, 1122, 1173, 480, 4087, 14, 1652, 531, 272, 871, 26, 267, 986, 272, 587, 26, 267, 702, 298, 4892, 2, 199, 199, 3, 2288, 1125, 3016, 199, 24528, 275, 4520, 2461, 342, 199, 773, 1652, 18, 14, 2683, 25933, 8, 24528, 14, 2232, 12, 7230, 199, 199, 3, 663, 641, 314, 2446, 2462, 1454, 199, 773, 1652, 18, 14, 604, 22951, 2698, 8, 17, 9, 221, 199, 396, 8, 17, 9, 199, 825, 275, 822, 8, 24528, 14, 2550, 9, 199, 692, 7062, 508, 378, 26, 272, 870, 298, 12299, 26, 1077, 1172, 15884, 2552, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 1086, 275, 942, 199, 509, 284, 315, 1425, 8, 16103, 51, 63, 8760, 304, 272, 327, 4282, 378, 367, 1004, 22951, 2698, 2952, 272, 327, 314, 892, 574, 965, 2757, 663, 641, 314, 2446, 2462, 1454, 272, 6714, 14, 740, 8, 4436, 8, 1375, 29, 396, 12, 589, 2687, 16, 20097, 199, 509, 307, 315, 6714, 26, 272, 307, 14, 928, 342, 199, 509, 307, 315, 6714, 26, 272, 307, 14, 904, 342, 199, 199, 692, 822, 8, 24528, 14, 2550, 9, 1137, 7062, 11, 16103, 51, 63, 8760, 10, 825, 26, 272, 870, 298, 12299, 26, 8103, 440, 3332, 314, 3211, 1329, 402, 2552, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 3, 663, 1004, 22951, 2698, 367, 6466, 892, 7183, 199, 773, 1652, 18, 14, 28854, 6172, 3049, 22951, 2698, 1110, 8, 17, 9, 199, 1086, 275, 942, 199, 509, 284, 315, 1425, 8, 16103, 51, 63, 8760, 304, 272, 327, 4282, 413, 367, 1004, 22951, 2698, 272, 6714, 14, 740, 8, 4436, 8, 1375, 29, 396, 12, 589, 2687, 17, 20097, 199, 509, 307, 315, 6714, 26, 272, 307, 14, 928, 342, 199, 509, 307, 315, 6714, 26, 272, 307, 14, 904, 342, 199, 199, 692, 822, 8, 24528, 14, 2550, 9, 1137, 7062, 11, 16103, 51, 63, 8760, 10, 825, 10, 18, 26, 272, 870, 298, 12299, 26, 8103, 440, 3332, 314, 3211, 1329, 402, 2552, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 692, 3405, 26, 272, 870, 298, 12299, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 3, 15825, 3105, 2488, 199, 773, 1652, 18, 14, 7661, 2842, 342, 199, 692, 15404, 18, 14, 1757, 8628, 8, 17, 9, 508, 378, 26, 272, 870, 298, 3593, 2, 199, 2836, 26, 272, 870, 298, 8628, 25831, 450, 68, 2783, 2, 450, 334, 773, 1652, 18, 14, 1757, 8628, 8, 17, 430, 272, 15404, 18, 14, 2724, 8628, 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 ]
[ 2647, 15, 1393, 15, 1548, 446, 85, 199, 646, 1059, 12, 984, 12, 900, 199, 646, 2462, 199, 504, 5796, 492, 11086, 12, 15536, 199, 199, 646, 15404, 18, 199, 199, 16103, 51, 63, 8760, 275, 4114, 199, 199, 4892, 275, 378, 199, 199, 533, 4520, 2461, 26, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2550, 275, 942, 267, 291, 14, 831, 275, 15536, 342, 339, 347, 3016, 8, 277, 12, 3799, 12, 495, 304, 267, 291, 14, 831, 14, 8174, 342, 267, 291, 14, 2550, 14, 740, 8, 495, 9, 267, 291, 14, 831, 14, 3221, 342, 199, 199, 318, 664, 3049, 22951, 2698, 837, 272, 2269, 275, 15404, 18, 14, 604, 22951, 2698, 8, 16, 9, 272, 15404, 18, 14, 604, 22951, 2698, 8, 1753, 9, 272, 372, 2269, 199, 199, 318, 511, 8, 2062, 3049, 22951, 2698, 304, 272, 900, 14, 4532, 8, 17, 9, 272, 2288, 3405, 272, 327, 1104, 282, 1126, 2462, 13, 2966, 272, 340, 1420, 3049, 22951, 2698, 1137, 664, 3049, 22951, 2698, 837, 267, 3405, 275, 413, 267, 870, 298, 12299, 370, 3332, 3211, 574, 367, 298, 971, 1598, 298, 604, 22951, 2698, 315, 2462, 450, 68, 2, 450, 2462, 14, 362, 63, 5425, 342, 272, 327, 1104, 23418, 2288, 1125, 3016, 5591, 327, 334, 6777, 365, 2845, 1126, 13, 2671, 315, 314, 2366, 17792, 9, 272, 862, 26, 267, 1382, 275, 15404, 18, 14, 1122, 1173, 480, 4087, 14, 1652, 531, 272, 871, 26, 267, 986, 272, 587, 26, 267, 702, 298, 4892, 2, 199, 199, 3, 2288, 1125, 3016, 199, 24528, 275, 4520, 2461, 342, 199, 773, 1652, 18, 14, 2683, 25933, 8, 24528, 14, 2232, 12, 7230, 199, 199, 3, 663, 641, 314, 2446, 2462, 1454, 199, 773, 1652, 18, 14, 604, 22951, 2698, 8, 17, 9, 221, 199, 396, 8, 17, 9, 199, 825, 275, 822, 8, 24528, 14, 2550, 9, 199, 692, 7062, 508, 378, 26, 272, 870, 298, 12299, 26, 1077, 1172, 15884, 2552, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 1086, 275, 942, 199, 509, 284, 315, 1425, 8, 16103, 51, 63, 8760, 304, 272, 327, 4282, 378, 367, 1004, 22951, 2698, 2952, 272, 327, 314, 892, 574, 965, 2757, 663, 641, 314, 2446, 2462, 1454, 272, 6714, 14, 740, 8, 4436, 8, 1375, 29, 396, 12, 589, 2687, 16, 20097, 199, 509, 307, 315, 6714, 26, 272, 307, 14, 928, 342, 199, 509, 307, 315, 6714, 26, 272, 307, 14, 904, 342, 199, 199, 692, 822, 8, 24528, 14, 2550, 9, 1137, 7062, 11, 16103, 51, 63, 8760, 10, 825, 26, 272, 870, 298, 12299, 26, 8103, 440, 3332, 314, 3211, 1329, 402, 2552, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 3, 663, 1004, 22951, 2698, 367, 6466, 892, 7183, 199, 773, 1652, 18, 14, 28854, 6172, 3049, 22951, 2698, 1110, 8, 17, 9, 199, 1086, 275, 942, 199, 509, 284, 315, 1425, 8, 16103, 51, 63, 8760, 304, 272, 327, 4282, 413, 367, 1004, 22951, 2698, 272, 6714, 14, 740, 8, 4436, 8, 1375, 29, 396, 12, 589, 2687, 17, 20097, 199, 509, 307, 315, 6714, 26, 272, 307, 14, 928, 342, 199, 509, 307, 315, 6714, 26, 272, 307, 14, 904, 342, 199, 199, 692, 822, 8, 24528, 14, 2550, 9, 1137, 7062, 11, 16103, 51, 63, 8760, 10, 825, 10, 18, 26, 272, 870, 298, 12299, 26, 8103, 440, 3332, 314, 3211, 1329, 402, 2552, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 692, 3405, 26, 272, 870, 298, 12299, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 3, 15825, 3105, 2488, 199, 773, 1652, 18, 14, 7661, 2842, 342, 199, 692, 15404, 18, 14, 1757, 8628, 8, 17, 9, 508, 378, 26, 272, 870, 298, 3593, 2, 199, 2836, 26, 272, 870, 298, 8628, 25831, 450, 68, 2783, 2, 450, 334, 773, 1652, 18, 14, 1757, 8628, 8, 17, 430, 272, 15404, 18, 14, 2724, 8628, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
seanh/pyblosxom-simplemarkdown
pyblosxomsimplemarkdown/__init__.py
2
1639
__author__ = "Sean Hammond pyblosxomsimplemarkdown at seanh dot cc" __version__ = "0.1" __url__ = "https://github.com/seanh/pyblosxomsimplemarkdown" __description__ = ("A Pyblosxom entryparser plugin that uses Markdown syntax " "and parses the whole file as the entry body") from Pyblosxom import tools def verify_installation(request): try: import markdown return True except ImportError: print "Couldn't import markdown, is Python Markdown installed?" return False def cb_entryparser(entryparsingdict): for extension in ('md', 'markdown'): entryparsingdict[extension] = parse return entryparsingdict def cb_preformat(args): if args.get('parser') == 'simplemarkdown': import markdown return markdown.markdown( u''.join(args['story']), extensions=['extra', 'smarty'], output_format='html5' ) def parse(filename, request): # FIXME: We're assuming the file is UTF-8. lines = [line.decode('utf8') for line in open(filename, 'r').readlines()] # Call the preformat function, this should return us an HTML string for # the body of the entry. args = {'parser': 'simplemarkdown', 'story': lines, 'request': request} body = tools.run_callback( 'preformat', args, donefunc=lambda x: x is not None, defaultfunc=lambda x: ''.join(x['story'])) entry_data = {'body': body} # No title! # Call the postformat callbacks. tools.run_callback( 'postformat', {'request': request, 'entry_data': entry_data}) return entry_data
gpl-3.0
[ 363, 2502, 363, 420, 275, 298, 1513, 290, 869, 455, 2106, 68, 1134, 66, 11560, 88, 676, 4129, 15653, 737, 542, 290, 72, 6308, 7429, 2, 199, 363, 1023, 363, 258, 275, 298, 16, 14, 17, 2, 199, 363, 633, 363, 260, 275, 298, 2859, 921, 5031, 14, 957, 15, 261, 290, 72, 15, 647, 66, 11560, 88, 676, 4129, 15653, 2, 199, 363, 1802, 363, 275, 1689, 33, 1611, 66, 11560, 88, 676, 2397, 2087, 3589, 626, 4440, 24537, 6302, 298, 673, 298, 460, 19953, 314, 8852, 570, 465, 314, 2397, 2396, 531, 421, 199, 504, 1611, 66, 11560, 88, 676, 492, 7249, 421, 199, 318, 4911, 63, 23048, 8, 1069, 304, 272, 862, 26, 267, 492, 18502, 267, 372, 715, 272, 871, 3545, 26, 267, 870, 298, 20485, 1133, 492, 18502, 12, 365, 2018, 24537, 4903, 13472, 267, 372, 756, 421, 199, 318, 7434, 63, 2373, 2087, 8, 2373, 11059, 807, 304, 272, 367, 3329, 315, 661, 1064, 297, 283, 15653, 735, 267, 2397, 11059, 807, 59, 3435, 61, 275, 2198, 272, 372, 2397, 11059, 807, 421, 199, 318, 7434, 63, 657, 908, 8, 589, 304, 272, 340, 1249, 14, 362, 360, 2087, 358, 508, 283, 4129, 15653, 356, 267, 492, 18502, 267, 372, 18502, 14, 15653, 8, 288, 399, 17067, 904, 8, 589, 459, 17372, 3815, 288, 5478, 2968, 2911, 297, 283, 24193, 369, 995, 288, 1072, 63, 908, 534, 1360, 21, 7, 267, 776, 421, 199, 318, 2198, 8, 1501, 12, 1056, 304, 272, 327, 7600, 26, 2136, 3984, 18002, 314, 570, 365, 9094, 13, 24, 14, 272, 2385, 275, 359, 604, 14, 2708, 360, 1624, 24, 358, 367, 1004, 315, 1551, 8, 1501, 12, 283, 82, 1959, 9684, 5106, 339, 327, 6523, 314, 876, 908, 805, 12, 642, 1077, 372, 2739, 376, 4163, 1059, 367, 272, 327, 314, 2396, 402, 314, 2397, 14, 272, 1249, 275, 791, 2087, 356, 283, 4129, 15653, 297, 283, 17372, 356, 2385, 12, 283, 1069, 356, 1056, 93, 272, 2396, 275, 7249, 14, 1065, 63, 3058, 8, 267, 283, 657, 908, 297, 1249, 12, 4224, 1532, 29, 2734, 671, 26, 671, 365, 440, 488, 12, 267, 849, 1532, 29, 2734, 671, 26, 6522, 904, 8, 88, 459, 17372, 5156, 339, 2397, 63, 576, 275, 791, 2030, 356, 2396, 93, 221, 327, 3091, 2538, 1, 339, 327, 6523, 314, 2963, 908, 13484, 14, 272, 7249, 14, 1065, 63, 3058, 8, 267, 283, 1932, 908, 297, 791, 1069, 356, 1056, 12, 283, 2373, 63, 576, 356, 2397, 63, 576, 1552, 339, 372, 2397, 63, 576, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2502, 363, 420, 275, 298, 1513, 290, 869, 455, 2106, 68, 1134, 66, 11560, 88, 676, 4129, 15653, 737, 542, 290, 72, 6308, 7429, 2, 199, 363, 1023, 363, 258, 275, 298, 16, 14, 17, 2, 199, 363, 633, 363, 260, 275, 298, 2859, 921, 5031, 14, 957, 15, 261, 290, 72, 15, 647, 66, 11560, 88, 676, 4129, 15653, 2, 199, 363, 1802, 363, 275, 1689, 33, 1611, 66, 11560, 88, 676, 2397, 2087, 3589, 626, 4440, 24537, 6302, 298, 673, 298, 460, 19953, 314, 8852, 570, 465, 314, 2397, 2396, 531, 421, 199, 504, 1611, 66, 11560, 88, 676, 492, 7249, 421, 199, 318, 4911, 63, 23048, 8, 1069, 304, 272, 862, 26, 267, 492, 18502, 267, 372, 715, 272, 871, 3545, 26, 267, 870, 298, 20485, 1133, 492, 18502, 12, 365, 2018, 24537, 4903, 13472, 267, 372, 756, 421, 199, 318, 7434, 63, 2373, 2087, 8, 2373, 11059, 807, 304, 272, 367, 3329, 315, 661, 1064, 297, 283, 15653, 735, 267, 2397, 11059, 807, 59, 3435, 61, 275, 2198, 272, 372, 2397, 11059, 807, 421, 199, 318, 7434, 63, 657, 908, 8, 589, 304, 272, 340, 1249, 14, 362, 360, 2087, 358, 508, 283, 4129, 15653, 356, 267, 492, 18502, 267, 372, 18502, 14, 15653, 8, 288, 399, 17067, 904, 8, 589, 459, 17372, 3815, 288, 5478, 2968, 2911, 297, 283, 24193, 369, 995, 288, 1072, 63, 908, 534, 1360, 21, 7, 267, 776, 421, 199, 318, 2198, 8, 1501, 12, 1056, 304, 272, 327, 7600, 26, 2136, 3984, 18002, 314, 570, 365, 9094, 13, 24, 14, 272, 2385, 275, 359, 604, 14, 2708, 360, 1624, 24, 358, 367, 1004, 315, 1551, 8, 1501, 12, 283, 82, 1959, 9684, 5106, 339, 327, 6523, 314, 876, 908, 805, 12, 642, 1077, 372, 2739, 376, 4163, 1059, 367, 272, 327, 314, 2396, 402, 314, 2397, 14, 272, 1249, 275, 791, 2087, 356, 283, 4129, 15653, 297, 283, 17372, 356, 2385, 12, 283, 1069, 356, 1056, 93, 272, 2396, 275, 7249, 14, 1065, 63, 3058, 8, 267, 283, 657, 908, 297, 1249, 12, 4224, 1532, 29, 2734, 671, 26, 671, 365, 440, 488, 12, 267, 849, 1532, 29, 2734, 671, 26, 6522, 904, 8, 88, 459, 17372, 5156, 339, 2397, 63, 576, 275, 791, 2030, 356, 2396, 93, 221, 327, 3091, 2538, 1, 339, 327, 6523, 314, 2963, 908, 13484, 14, 272, 7249, 14, 1065, 63, 3058, 8, 267, 283, 1932, 908, 297, 791, 1069, 356, 1056, 12, 283, 2373, 63, 576, 356, 2397, 63, 576, 1552, 339, 372, 2397, 63, 576, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
doublerr/torment
torment/decorators.py
5
3750
# Copyright 2015 Alex Brandt # # 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 functools import inspect import logging import typing # noqa (use mypy typing) from typing import Any from typing import Callable logger = logging.getLogger(__name__) logger.propogate = False logger.addHandler(logging.NullHandler()) def log(prefix = ''): '''Add start and stop logging messages to the function. Parameters ---------- :``prefix``: a prefix for the function name (optional) ''' function = None if inspect.isfunction(prefix): prefix, function = '', prefix def _(function): @functools.wraps(function, assigned = functools.WRAPPER_ASSIGNMENTS + ( '__file__', )) def wrapper(*args, **kwargs): name, my_args = function.__name__, args if inspect.ismethod(function): name = function.__self__.__class__.__name__ + '.' + function.__name__ elif len(args): members = dict(inspect.getmembers(args[0], predicate = lambda _: inspect.ismethod(_) and _.__name__ == function.__name__)) logger.debug('members.keys(): %s', members.keys()) if len(members): name, my_args = args[0].__class__.__name__ + '.' + function.__name__, args[1:] format_args = ( prefix + name, ', '.join(list(map(str, my_args)) + [ ' = '.join(map(str, item)) for item in kwargs.items() ]), ) logger.info('STARTING: %s(%s)', *format_args) try: return function(*args, **kwargs) except: logger.exception('EXCEPTION: %s(%s)', *format_args) raise finally: logger.info('STOPPING: %s(%s)', *format_args) return wrapper if function is not None: _ = _(function) return _ def mock(name: str) -> Callable[[Any], None]: '''Setup properties indicating status of name mock. This is designed to decorate ``torment.TestContext`` methods and is used to provide a consistent interface for determining if name is mocked once and only once. Parameters ---------- :``name``: symbol in context's module to mock Return Value(s) --------------- True if name is mocked; otherwise, False. Also, creates a property on the method's self, is_mocked_name, with this value. ''' def _(func): @functools.wraps(func) def wrapper(self, *args, **kwargs): logger.info('STARTING: mock ' + name) is_mocked = False sanitized_name = name.replace('.', '_').strip('_') if name in self.mocks_mask: logger.info('STOPPING: mock ' + name + '—MASKED') elif getattr(self, '_is_mocked_' + sanitized_name, False): is_mocked = True logger.info('STOPPING: mock ' + name + '—EXISTS') else: func(self, *args, **kwargs) is_mocked = True logger.info('STOPPING: mock ' + name) setattr(self, '_is_mocked_' + sanitized_name, is_mocked) return is_mocked return wrapper return _
apache-2.0
[ 3, 1898, 6900, 22986, 699, 3759, 84, 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, 646, 9143, 199, 646, 6485, 199, 646, 2050, 199, 646, 14090, 221, 327, 8151, 334, 1180, 3002, 647, 14090, 9, 199, 199, 504, 14090, 492, 6184, 199, 504, 14090, 492, 16975, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 2921, 14, 496, 555, 3237, 275, 756, 199, 2921, 14, 18826, 8, 4806, 14, 8849, 2461, 1012, 421, 199, 318, 943, 8, 1861, 275, 21019, 272, 1449, 1123, 1343, 436, 3631, 2050, 3788, 370, 314, 805, 14, 339, 3897, 272, 4143, 339, 520, 1040, 1861, 18983, 282, 2403, 367, 314, 805, 536, 334, 4144, 9, 339, 1449, 339, 805, 275, 488, 339, 340, 6485, 14, 374, 1593, 8, 1861, 304, 267, 2403, 12, 805, 275, 3260, 2403, 339, 347, 12561, 1593, 304, 267, 768, 17869, 14, 13582, 8, 1593, 12, 7943, 275, 9143, 14, 23824, 4227, 63, 23680, 20967, 435, 334, 2560, 493, 7500, 5082, 267, 347, 4975, 2031, 589, 12, 1011, 958, 304, 288, 536, 12, 3002, 63, 589, 275, 805, 855, 354, 3108, 1249, 953, 340, 6485, 14, 374, 765, 8, 1593, 304, 355, 536, 275, 805, 855, 277, 4914, 533, 4914, 354, 363, 435, 7815, 435, 805, 855, 354, 363, 288, 916, 822, 8, 589, 304, 355, 7556, 275, 1211, 8, 10955, 14, 28719, 8, 589, 59, 16, 467, 11944, 275, 2400, 24700, 6485, 14, 374, 765, 1547, 9, 436, 485, 855, 354, 363, 508, 805, 855, 354, 8964, 355, 2512, 14, 1757, 360, 6334, 14, 1612, 837, 450, 83, 297, 7556, 14, 1612, 1012, 2234, 340, 822, 8, 6334, 304, 490, 536, 12, 3002, 63, 589, 275, 1249, 59, 16, 17979, 533, 4914, 354, 363, 435, 7815, 435, 805, 855, 354, 3108, 1249, 59, 17, 2938, 953, 1475, 63, 589, 275, 334, 355, 2403, 435, 536, 12, 355, 1656, 1987, 904, 8, 513, 8, 1130, 8, 495, 12, 3002, 63, 589, 430, 435, 359, 283, 275, 1987, 904, 8, 1130, 8, 495, 12, 1242, 430, 367, 1242, 315, 2074, 14, 1744, 342, 17318, 288, 776, 953, 2512, 14, 815, 360, 7363, 1206, 26, 450, 83, 4042, 83, 3196, 627, 908, 63, 589, 9, 953, 862, 26, 355, 372, 805, 2031, 589, 12, 1011, 958, 9, 288, 871, 26, 355, 2512, 14, 1971, 360, 15375, 26, 450, 83, 4042, 83, 3196, 627, 908, 63, 589, 9, 355, 746, 288, 3753, 26, 355, 2512, 14, 815, 360, 11632, 15675, 26, 450, 83, 4042, 83, 3196, 627, 908, 63, 589, 9, 398, 372, 4975, 339, 340, 805, 365, 440, 488, 26, 267, 485, 275, 12561, 1593, 9, 339, 372, 485, 421, 199, 318, 1683, 8, 354, 26, 620, 9, 1035, 16975, 9046, 9874, 467, 488, 2189, 272, 1449, 8555, 4382, 9297, 2004, 402, 536, 1683, 14, 339, 961, 365, 19829, 370, 24774, 1124, 8270, 434, 14, 774, 2998, 1040, 3102, 436, 365, 1202, 370, 272, 5647, 282, 12137, 3217, 367, 26638, 340, 536, 365, 16991, 5403, 436, 272, 1454, 5403, 14, 339, 3897, 272, 4143, 339, 520, 1040, 354, 18983, 5272, 315, 1067, 1159, 859, 370, 1683, 339, 1432, 1594, 8, 83, 9, 272, 3001, 12797, 339, 715, 340, 536, 365, 16991, 27, 4257, 12, 756, 14, 221, 6121, 12, 8491, 282, 3324, 641, 314, 272, 1083, 1159, 291, 12, 365, 63, 27740, 63, 354, 12, 543, 642, 574, 14, 339, 1449, 339, 347, 12561, 1532, 304, 267, 768, 17869, 14, 13582, 8, 1532, 9, 267, 347, 4975, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 288, 2512, 14, 815, 360, 7363, 1206, 26, 1683, 283, 435, 536, 9, 953, 365, 63, 27740, 275, 756, 953, 31734, 63, 354, 275, 536, 14, 1814, 14078, 2513, 1959, 1913, 26341, 953, 340, 536, 315, 291, 14, 25191, 63, 2629, 26, 355, 2512, 14, 815, 360, 11632, 15675, 26, 1683, 283, 435, 536, 435, 283, 20292, 12880, 1149, 358, 288, 916, 2519, 8, 277, 12, 2513, 374, 63, 27740, 8650, 435, 31734, 63, 354, 12, 756, 304, 355, 365, 63, 27740, 275, 715, 2234, 2512, 14, 815, 360, 11632, 15675, 26, 1683, 283, 435, 536, 435, 283, 20292, 23558, 358, 288, 587, 26, 355, 2562, 8, 277, 12, 627, 589, 12, 1011, 958, 9, 2234, 365, 63, 27740, 275, 715, 2234, 2512, 14, 815, 360, 11632, 15675, 26, 1683, 283, 435, 536, 9, 953, 5371, 8, 277, 12, 2513, 374, 63, 27740, 8650, 435, 31734, 63, 354, 12, 365, 63, 27740, 9, 953, 372, 365, 63, 27740, 398, 372, 4975, 339, 372, 485, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 22986, 699, 3759, 84, 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, 646, 9143, 199, 646, 6485, 199, 646, 2050, 199, 646, 14090, 221, 327, 8151, 334, 1180, 3002, 647, 14090, 9, 199, 199, 504, 14090, 492, 6184, 199, 504, 14090, 492, 16975, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 2921, 14, 496, 555, 3237, 275, 756, 199, 2921, 14, 18826, 8, 4806, 14, 8849, 2461, 1012, 421, 199, 318, 943, 8, 1861, 275, 21019, 272, 1449, 1123, 1343, 436, 3631, 2050, 3788, 370, 314, 805, 14, 339, 3897, 272, 4143, 339, 520, 1040, 1861, 18983, 282, 2403, 367, 314, 805, 536, 334, 4144, 9, 339, 1449, 339, 805, 275, 488, 339, 340, 6485, 14, 374, 1593, 8, 1861, 304, 267, 2403, 12, 805, 275, 3260, 2403, 339, 347, 12561, 1593, 304, 267, 768, 17869, 14, 13582, 8, 1593, 12, 7943, 275, 9143, 14, 23824, 4227, 63, 23680, 20967, 435, 334, 2560, 493, 7500, 5082, 267, 347, 4975, 2031, 589, 12, 1011, 958, 304, 288, 536, 12, 3002, 63, 589, 275, 805, 855, 354, 3108, 1249, 953, 340, 6485, 14, 374, 765, 8, 1593, 304, 355, 536, 275, 805, 855, 277, 4914, 533, 4914, 354, 363, 435, 7815, 435, 805, 855, 354, 363, 288, 916, 822, 8, 589, 304, 355, 7556, 275, 1211, 8, 10955, 14, 28719, 8, 589, 59, 16, 467, 11944, 275, 2400, 24700, 6485, 14, 374, 765, 1547, 9, 436, 485, 855, 354, 363, 508, 805, 855, 354, 8964, 355, 2512, 14, 1757, 360, 6334, 14, 1612, 837, 450, 83, 297, 7556, 14, 1612, 1012, 2234, 340, 822, 8, 6334, 304, 490, 536, 12, 3002, 63, 589, 275, 1249, 59, 16, 17979, 533, 4914, 354, 363, 435, 7815, 435, 805, 855, 354, 3108, 1249, 59, 17, 2938, 953, 1475, 63, 589, 275, 334, 355, 2403, 435, 536, 12, 355, 1656, 1987, 904, 8, 513, 8, 1130, 8, 495, 12, 3002, 63, 589, 430, 435, 359, 283, 275, 1987, 904, 8, 1130, 8, 495, 12, 1242, 430, 367, 1242, 315, 2074, 14, 1744, 342, 17318, 288, 776, 953, 2512, 14, 815, 360, 7363, 1206, 26, 450, 83, 4042, 83, 3196, 627, 908, 63, 589, 9, 953, 862, 26, 355, 372, 805, 2031, 589, 12, 1011, 958, 9, 288, 871, 26, 355, 2512, 14, 1971, 360, 15375, 26, 450, 83, 4042, 83, 3196, 627, 908, 63, 589, 9, 355, 746, 288, 3753, 26, 355, 2512, 14, 815, 360, 11632, 15675, 26, 450, 83, 4042, 83, 3196, 627, 908, 63, 589, 9, 398, 372, 4975, 339, 340, 805, 365, 440, 488, 26, 267, 485, 275, 12561, 1593, 9, 339, 372, 485, 421, 199, 318, 1683, 8, 354, 26, 620, 9, 1035, 16975, 9046, 9874, 467, 488, 2189, 272, 1449, 8555, 4382, 9297, 2004, 402, 536, 1683, 14, 339, 961, 365, 19829, 370, 24774, 1124, 8270, 434, 14, 774, 2998, 1040, 3102, 436, 365, 1202, 370, 272, 5647, 282, 12137, 3217, 367, 26638, 340, 536, 365, 16991, 5403, 436, 272, 1454, 5403, 14, 339, 3897, 272, 4143, 339, 520, 1040, 354, 18983, 5272, 315, 1067, 1159, 859, 370, 1683, 339, 1432, 1594, 8, 83, 9, 272, 3001, 12797, 339, 715, 340, 536, 365, 16991, 27, 4257, 12, 756, 14, 221, 6121, 12, 8491, 282, 3324, 641, 314, 272, 1083, 1159, 291, 12, 365, 63, 27740, 63, 354, 12, 543, 642, 574, 14, 339, 1449, 339, 347, 12561, 1532, 304, 267, 768, 17869, 14, 13582, 8, 1532, 9, 267, 347, 4975, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 288, 2512, 14, 815, 360, 7363, 1206, 26, 1683, 283, 435, 536, 9, 953, 365, 63, 27740, 275, 756, 953, 31734, 63, 354, 275, 536, 14, 1814, 14078, 2513, 1959, 1913, 26341, 953, 340, 536, 315, 291, 14, 25191, 63, 2629, 26, 355, 2512, 14, 815, 360, 11632, 15675, 26, 1683, 283, 435, 536, 435, 283, 20292, 12880, 1149, 358, 288, 916, 2519, 8, 277, 12, 2513, 374, 63, 27740, 8650, 435, 31734, 63, 354, 12, 756, 304, 355, 365, 63, 27740, 275, 715, 2234, 2512, 14, 815, 360, 11632, 15675, 26, 1683, 283, 435, 536, 435, 283, 20292, 23558, 358, 288, 587, 26, 355, 2562, 8, 277, 12, 627, 589, 12, 1011, 958, 9, 2234, 365, 63, 27740, 275, 715, 2234, 2512, 14, 815, 360, 11632, 15675, 26, 1683, 283, 435, 536, 9, 953, 5371, 8, 277, 12, 2513, 374, 63, 27740, 8650, 435, 31734, 63, 354, 12, 365, 63, 27740, 9, 953, 372, 365, 63, 27740, 398, 372, 4975, 339, 372, 485, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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- """Inter Rater Agreement contains -------- fleiss_kappa cohens_kappa aggregate_raters: helper function to get data into fleiss_kappa format to_table: helper function to create contingency table, can be used for cohens_kappa Created on Thu Dec 06 22:57:56 2012 Author: Josef Perktold License: BSD-3 References ---------- Wikipedia: kappa's initially based on these two pages http://en.wikipedia.org/wiki/Fleiss%27_kappa http://en.wikipedia.org/wiki/Cohen's_kappa SAS-Manual : formulas for cohens_kappa, especially variances see also R package irr TODO ---- standard errors and hypothesis tests for fleiss_kappa other statistics and tests, in R package irr, SAS has more inconsistent internal naming, changed variable names as I added more functionality convenience functions to create required data format from raw data DONE """ import numpy as np from scipy import stats #get rid of this? need only norm.sf class ResultsBunch(dict): template = '%r' def __init__(self, **kwds): dict.__init__(self, kwds) self.__dict__ = self self._initialize() def _initialize(self): pass def __str__(self): return self.template % self def _int_ifclose(x, dec=1, width=4): '''helper function for creating result string for int or float only dec=1 and width=4 is implemented Parameters ---------- x : int or float value to format dec : 1 number of decimals to print if x is not an integer width : 4 width of string Returns ------- xint : int or float x is converted to int if it is within 1e-14 of an integer x_string : str x formatted as string, either '%4d' or '%4.1f' ''' xint = int(round(x)) if np.max(np.abs(xint - x)) < 1e-14: return xint, '%4d' % xint else: return x, '%4.1f' % x def aggregate_raters(data, n_cat=None): '''convert raw data with shape (subject, rater) to (subject, cat_counts) brings data into correct format for fleiss_kappa bincount will raise exception if data cannot be converted to integer. Parameters ---------- data : array_like, 2-Dim data containing category assignment with subjects in rows and raters in columns. n_cat : None or int If None, then the data is converted to integer categories, 0,1,2,...,n_cat-1. Because of the relabeling only category levels with non-zero counts are included. If this is an integer, then the category levels in the data are already assumed to be in integers, 0,1,2,...,n_cat-1. In this case, the returned array may contain columns with zero count, if no subject has been categorized with this level. Returns ------- arr : nd_array, (n_rows, n_cat) Contains counts of raters that assigned a category level to individuals. Subjects are in rows, category levels in columns. ''' data = np.asarray(data) n_rows = data.shape[0] if n_cat is None: #I could add int conversion (reverse_index) to np.unique cat_uni, cat_int = np.unique(data.ravel(), return_inverse=True) n_cat = len(cat_uni) data_ = cat_int.reshape(data.shape) else: cat_uni = np.arange(n_cat) #for return only, assumed cat levels data_ = data tt = np.zeros((n_rows, n_cat), int) for idx, row in enumerate(data_): ro = np.bincount(row) tt[idx, :len(ro)] = ro return tt, cat_uni def to_table(data, bins=None): '''convert raw data with shape (subject, rater) to (rater1, rater2) brings data into correct format for cohens_kappa Parameters ---------- data : array_like, 2-Dim data containing category assignment with subjects in rows and raters in columns. bins : None, int or tuple of array_like If None, then the data is converted to integer categories, 0,1,2,...,n_cat-1. Because of the relabeling only category levels with non-zero counts are included. If this is an integer, then the category levels in the data are already assumed to be in integers, 0,1,2,...,n_cat-1. In this case, the returned array may contain columns with zero count, if no subject has been categorized with this level. If bins are a tuple of two array_like, then the bins are directly used by ``numpy.histogramdd``. This is useful if we want to merge categories. Returns ------- arr : nd_array, (n_cat, n_cat) Contingency table that contains counts of category level with rater1 in rows and rater2 in columns. Notes ----- no NaN handling, delete rows with missing values This works also for more than two raters. In that case the dimension of the resulting contingency table is the same as the number of raters instead of 2-dimensional. ''' data = np.asarray(data) n_rows, n_cols = data.shape if bins is None: #I could add int conversion (reverse_index) to np.unique cat_uni, cat_int = np.unique(data.ravel(), return_inverse=True) n_cat = len(cat_uni) data_ = cat_int.reshape(data.shape) bins_ = np.arange(n_cat+1) - 0.5 #alternative implementation with double loop #tt = np.asarray([[(x == [i,j]).all(1).sum() for j in cat_uni] # for i in cat_uni] ) #other altervative: unique rows and bincount elif np.isscalar(bins): bins_ = np.arange(bins+1) - 0.5 data_ = data else: bins_ = bins data_ = data tt = np.histogramdd(data_, (bins_,)*n_cols) return tt[0], bins_ def fleiss_kappa(table): '''Fleiss' kappa multi-rater agreement measure Parameters ---------- table : array_like, 2-D assumes subjects in rows, and categories in columns Returns ------- kappa : float Fleiss's kappa statistic for inter rater agreement Notes ----- coded from Wikipedia page http://en.wikipedia.org/wiki/Fleiss%27_kappa no variance or tests yet ''' table = 1.0 * np.asarray(table) #avoid integer division n_sub, n_cat = table.shape n_total = table.sum() n_rater = table.sum(1) n_rat = n_rater.max() #assume fully ranked assert n_total == n_sub * n_rat #marginal frequency of categories p_cat = table.sum(0) / n_total table2 = table * table p_rat = (table2.sum(1) - n_rat) / (n_rat * (n_rat - 1.)) p_mean = p_rat.mean() p_mean_exp = (p_cat*p_cat).sum() kappa = (p_mean - p_mean_exp) / (1- p_mean_exp) return kappa def cohens_kappa(table, weights=None, return_results=True, wt=None): '''Compute Cohen's kappa with variance and equal-zero test Parameters ---------- table : array_like, 2-Dim square array with results of two raters, one rater in rows, second rater in columns weights : array_like The interpretation of weights depends on the wt argument. If both are None, then the simple kappa is computed. see wt for the case when wt is not None If weights is two dimensional, then it is directly used as a weight matrix. For computing the variance of kappa, the maximum of the weights is assumed to be smaller or equal to one. TODO: fix conflicting definitions in the 2-Dim case for wt : None or string If wt and weights are None, then the simple kappa is computed. If wt is given, but weights is None, then the weights are set to be [0, 1, 2, ..., k]. If weights is a one-dimensional array, then it is used to construct the weight matrix given the following options. wt in ['linear', 'ca' or None] : use linear weights, Cicchetti-Allison actual weights are linear in the score "weights" difference wt in ['quadratic', 'fc'] : use linear weights, Fleiss-Cohen actual weights are squared in the score "weights" difference wt = 'toeplitz' : weight matrix is constructed as a toeplitz matrix from the one dimensional weights. return_results : bool If True (default), then an instance of KappaResults is returned. If False, then only kappa is computed and returned. Returns ------- results or kappa If return_results is True (default), then a results instance with all statistics is returned If return_results is False, then only kappa is calculated and returned. Notes ----- There are two conflicting definitions of the weight matrix, Wikipedia versus SAS manual. However, the computation are invariant to rescaling of the weights matrix, so there is no difference in the results. Weights for 'linear' and 'quadratic' are interpreted as scores for the categories, the weights in the computation are based on the pairwise difference between the scores. Weights for 'toeplitz' are a interpreted as weighted distance. The distance only depends on how many levels apart two entries in the table are but not on the levels themselves. example: weights = '0, 1, 2, 3' and wt is either linear or toeplitz means that the weighting only depends on the simple distance of levels. weights = '0, 0, 1, 1' and wt = 'linear' means that the first two levels are zero distance apart and the same for the last two levels. This is the sampe as forming two aggregated levels by merging the first two and the last two levels, respectively. weights = [0, 1, 2, 3] and wt = 'quadratic' is the same as squaring these weights and using wt = 'toeplitz'. References ---------- Wikipedia SAS Manual ''' table = np.asarray(table, float) #avoid integer division agree = np.diag(table).sum() nobs = table.sum() probs = table / nobs freqs = probs #TODO: rename to use freqs instead of probs for observed probs_diag = np.diag(probs) freq_row = table.sum(1) / nobs freq_col = table.sum(0) / nobs prob_exp = freq_col * freq_row[:, None] assert np.allclose(prob_exp.sum(), 1) #print prob_exp.sum() agree_exp = np.diag(prob_exp).sum() #need for kappa_max if weights is None and wt is None: kind = 'Simple' kappa = (agree / nobs - agree_exp) / (1 - agree_exp) if return_results: #variance term_a = probs_diag * (1 - (freq_row + freq_col) * (1 - kappa))**2 term_a = term_a.sum() term_b = probs * (freq_col[:, None] + freq_row)**2 d_idx = np.arange(table.shape[0]) term_b[d_idx, d_idx] = 0 #set diagonal to zero term_b = (1 - kappa)**2 * term_b.sum() term_c = (kappa - agree_exp * (1-kappa))**2 var_kappa = (term_a + term_b - term_c) / (1 - agree_exp)**2 / nobs #term_c = freq_col * freq_row[:, None] * (freq_col + freq_row[:,None]) term_c = freq_col * freq_row * (freq_col + freq_row) var_kappa0 = (agree_exp + agree_exp**2 - term_c.sum()) var_kappa0 /= (1 - agree_exp)**2 * nobs else: if weights is None: weights = np.arange(table.shape[0]) #weights follows the Wikipedia definition, not the SAS, which is 1 - kind = 'Weighted' weights = np.asarray(weights, float) if weights.ndim == 1: if wt in ['ca', 'linear', None]: weights = np.abs(weights[:, None] - weights) / \ (weights[-1] - weights[0]) elif wt in ['fc', 'quadratic']: weights = (weights[:, None] - weights)**2 / \ (weights[-1] - weights[0])**2 elif wt == 'toeplitz': #assume toeplitz structure from scipy.linalg import toeplitz #weights = toeplitz(np.arange(table.shape[0])) weights = toeplitz(weights) else: raise ValueError('wt option is not known') else: rows, cols = table.shape if (table.shape != weights.shape): raise ValueError('weights are not square') #this is formula from Wikipedia kappa = 1 - (weights * table).sum() / nobs / (weights * prob_exp).sum() #TODO: add var_kappa for weighted version if return_results: var_kappa = np.nan var_kappa0 = np.nan #switch to SAS manual weights, problem if user specifies weights #w is negative in some examples, #but weights is scale invariant in examples and rough check of source w = 1. - weights w_row = (freq_col * w).sum(1) w_col = (freq_row[:, None] * w).sum(0) agree_wexp = (w * freq_col * freq_row[:, None]).sum() term_a = freqs * (w - (w_col + w_row[:, None]) * (1 - kappa))**2 fac = 1. / ((1 - agree_wexp)**2 * nobs) var_kappa = term_a.sum() - (kappa - agree_wexp * (1 - kappa))**2 var_kappa *= fac freqse = freq_col * freq_row[:, None] var_kappa0 = (freqse * (w - (w_col + w_row[:, None]))**2).sum() var_kappa0 -= agree_wexp**2 var_kappa0 *= fac kappa_max = (np.minimum(freq_row, freq_col).sum() - agree_exp) / \ (1 - agree_exp) if return_results: res = KappaResults( kind=kind, kappa=kappa, kappa_max=kappa_max, weights=weights, var_kappa=var_kappa, var_kappa0=var_kappa0 ) return res else: return kappa _kappa_template = '''\ %(kind)s Kappa Coefficient -------------------------------- Kappa %(kappa)6.4f ASE %(std_kappa)6.4f %(alpha_ci)s%% Lower Conf Limit %(kappa_low)6.4f %(alpha_ci)s%% Upper Conf Limit %(kappa_upp)6.4f Test of H0: %(kind)s Kappa = 0 ASE under H0 %(std_kappa0)6.4f Z %(z_value)6.4f One-sided Pr > Z %(pvalue_one_sided)6.4f Two-sided Pr > |Z| %(pvalue_two_sided)6.4f ''' ''' Weighted Kappa Coefficient -------------------------------- Weighted Kappa 0.4701 ASE 0.1457 95% Lower Conf Limit 0.1845 95% Upper Conf Limit 0.7558 Test of H0: Weighted Kappa = 0 ASE under H0 0.1426 Z 3.2971 One-sided Pr > Z 0.0005 Two-sided Pr > |Z| 0.0010 ''' class KappaResults(ResultsBunch): '''Results for Cohen's kappa Attributes ---------- kappa : cohen's kappa var_kappa : variance of kappa std_kappa : standard deviation of kappa alpha : one-sided probability for confidence interval kappa_low : lower (1-alpha) confidence limit kappa_upp : upper (1-alpha) confidence limit var_kappa0 : variance of kappa under H0: kappa=0 std_kappa0 : standard deviation of kappa under H0: kappa=0 z_value : test statistic for H0: kappa=0, is standard normal distributed pvalue_one_sided : one sided p-value for H0: kappa=0 and H1: kappa>0 pvalue_two_sided : two sided p-value for H0: kappa=0 and H1: kappa!=0 distribution_kappa : asymptotic normal distribution of kappa distribution_zero_null : asymptotic normal distribution of kappa under H0: kappa=0 The confidence interval for kappa and the statistics for the test of H0: kappa=0 are based on the asymptotic normal distribution of kappa. ''' template = _kappa_template def _initialize(self): if not 'alpha' in self: self['alpha'] = 0.025 self['alpha_ci'] = _int_ifclose(100 - 0.025 * 200)[1] self['std_kappa'] = np.sqrt(self['var_kappa']) self['std_kappa0'] = np.sqrt(self['var_kappa0']) self['z_value'] = self['kappa'] / self['std_kappa0'] self['pvalue_one_sided'] = stats.norm.sf(self['z_value']) self['pvalue_two_sided'] = stats.norm.sf(np.abs(self['z_value'])) * 2 delta = stats.norm.isf(self['alpha']) * self['std_kappa'] self['kappa_low'] = self['kappa'] - delta self['kappa_upp'] = self['kappa'] + delta self['distribution_kappa'] = stats.norm(loc=self['kappa'], scale=self['std_kappa']) self['distribution_zero_null'] = stats.norm(loc=0, scale=self['std_kappa0']) def __str__(self): return self.template % self
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 2620, 820, 6618, 28629, 199, 199, 6134, 199, 518, 199, 21599, 19857, 63, 31918, 199, 331, 72, 8764, 63, 31918, 199, 199, 7516, 63, 1866, 2393, 26, 272, 5922, 805, 370, 664, 666, 1901, 289, 274, 19857, 63, 31918, 1475, 199, 475, 63, 1224, 26, 272, 5922, 805, 370, 1218, 406, 1337, 9501, 1817, 12, 883, 506, 1202, 367, 512, 72, 8764, 63, 31918, 199, 199, 10502, 641, 3868, 85, 13966, 24293, 6928, 26, 1641, 26, 1367, 6029, 199, 5949, 26, 1603, 3362, 70, 3492, 5973, 1753, 199, 3761, 26, 6289, 13, 19, 199, 199, 15242, 199, 9460, 199, 55, 29386, 26, 1022, 15999, 1159, 22801, 4079, 641, 3520, 2877, 6497, 272, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 38, 274, 19857, 5, 1465, 63, 31918, 272, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 967, 16800, 1159, 63, 31918, 199, 15319, 13, 22382, 520, 1824, 32646, 367, 512, 72, 8764, 63, 31918, 12, 24002, 11773, 83, 199, 3239, 2597, 820, 2559, 8190, 82, 199, 199, 11768, 199, 375, 199, 6807, 2552, 436, 29268, 2295, 367, 289, 274, 19857, 63, 31918, 199, 1848, 11076, 436, 2295, 12, 2043, 315, 820, 2559, 8190, 82, 12, 26124, 965, 1655, 199, 262, 15478, 5007, 19720, 12, 2896, 1750, 1561, 465, 473, 3483, 1655, 2043, 9330, 199, 388, 23329, 3423, 370, 1218, 1415, 666, 1475, 687, 3066, 666, 2043, 577, 4817, 199, 199, 624, 421, 199, 646, 2680, 465, 980, 199, 504, 7026, 492, 5020, 221, 327, 362, 16146, 402, 642, 31, 1929, 1454, 6316, 14, 7646, 421, 199, 533, 24288, 34, 4689, 8, 807, 304, 339, 1978, 275, 1543, 82, 7, 339, 347, 636, 826, 721, 277, 12, 1011, 10340, 304, 267, 1211, 855, 826, 721, 277, 12, 16286, 9, 267, 291, 855, 807, 363, 221, 275, 291, 267, 291, 423, 8489, 342, 339, 347, 485, 8489, 8, 277, 304, 267, 986, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1160, 450, 291, 199, 199, 318, 485, 442, 63, 692, 1600, 8, 88, 12, 9700, 29, 17, 12, 3462, 29, 20, 304, 272, 1449, 3676, 805, 367, 6425, 754, 1059, 367, 1109, 503, 2069, 339, 1454, 9700, 29, 17, 436, 3462, 29, 20, 365, 6366, 339, 3897, 272, 4143, 272, 671, 520, 1109, 503, 2069, 267, 574, 370, 1475, 272, 9700, 520, 413, 267, 1329, 402, 6107, 83, 370, 870, 340, 671, 365, 440, 376, 3000, 272, 3462, 520, 841, 267, 3462, 402, 1059, 339, 1803, 272, 5514, 272, 671, 442, 520, 1109, 503, 2069, 267, 671, 365, 6702, 370, 1109, 340, 652, 365, 4453, 413, 69, 13, 1079, 402, 376, 3000, 272, 671, 63, 875, 520, 620, 267, 671, 7871, 465, 1059, 12, 1902, 1543, 20, 68, 7, 503, 1543, 20, 14, 17, 70, 7, 339, 1449, 272, 671, 442, 275, 1109, 8, 2363, 8, 88, 430, 272, 340, 980, 14, 988, 8, 1590, 14, 2101, 8, 88, 442, 446, 671, 430, 665, 413, 69, 13, 1079, 26, 267, 372, 671, 442, 12, 1543, 20, 68, 7, 450, 671, 442, 272, 587, 26, 267, 372, 671, 12, 1543, 20, 14, 17, 70, 7, 450, 671, 421, 199, 318, 9531, 63, 1866, 2393, 8, 576, 12, 302, 63, 3385, 29, 403, 304, 272, 1449, 3916, 3066, 666, 543, 2215, 334, 5875, 12, 519, 6618, 9, 370, 334, 5875, 12, 6230, 63, 6851, 9, 339, 11665, 780, 666, 1901, 3211, 1475, 367, 289, 274, 19857, 63, 31918, 339, 2517, 835, 911, 746, 1919, 340, 666, 3913, 506, 6702, 370, 3000, 14, 339, 3897, 272, 4143, 272, 666, 520, 1625, 63, 2930, 12, 499, 13, 19156, 267, 666, 3035, 4637, 9801, 543, 32446, 315, 4730, 436, 6634, 2393, 267, 315, 4362, 14, 272, 302, 63, 3385, 520, 488, 503, 1109, 267, 982, 488, 12, 2066, 314, 666, 365, 6702, 370, 3000, 9695, 12, 267, 378, 12, 17, 12, 18, 32699, 78, 63, 3385, 13, 17, 14, 13821, 402, 314, 295, 1302, 316, 1454, 4637, 11106, 267, 543, 2222, 13, 4262, 8242, 787, 5120, 14, 267, 982, 642, 365, 376, 3000, 12, 2066, 314, 4637, 11106, 315, 314, 666, 787, 2575, 267, 10826, 370, 506, 315, 9446, 12, 378, 12, 17, 12, 18, 32699, 78, 63, 3385, 13, 17, 14, 1010, 642, 1930, 12, 314, 267, 2138, 1625, 1443, 1395, 4362, 543, 4697, 2338, 12, 340, 949, 5420, 267, 965, 2757, 7737, 269, 1759, 543, 642, 2166, 14, 339, 1803, 272, 5514, 272, 7953, 520, 5222, 63, 1144, 12, 334, 78, 63, 3838, 12, 302, 63, 3385, 9, 267, 22493, 8242, 402, 6634, 2393, 626, 7943, 282, 4637, 2166, 370, 8212, 83, 14, 267, 26793, 83, 787, 315, 4730, 12, 4637, 11106, 315, 4362, 14, 2378, 1449, 272, 666, 275, 980, 14, 8748, 8, 576, 9, 272, 302, 63, 3838, 275, 666, 14, 1392, 59, 16, 61, 272, 340, 302, 63, 3385, 365, 488, 26, 267, 327, 41, 4293, 1050, 1109, 8603, 334, 4471, 63, 1080, 9, 370, 980, 14, 3235, 267, 6230, 63, 5411, 12, 6230, 63, 442, 275, 980, 14, 3235, 8, 576, 14, 11186, 1062, 372, 63, 11668, 29, 549, 9, 267, 302, 63, 3385, 275, 822, 8, 3385, 63, 5411, 9, 267, 666, 63, 275, 6230, 63, 442, 14, 5217, 8, 576, 14, 1392, 9, 272, 587, 26, 267, 6230, 63, 5411, 275, 980, 14, 5605, 8, 78, 63, 3385, 9, 221, 327, 509, 372, 1454, 12, 10826, 6230, 11106, 267, 666, 63, 275, 666, 339, 13638, 275, 980, 14, 4250, 1332, 78, 63, 3838, 12, 302, 63, 3385, 395, 1109, 9, 272, 367, 4280, 12, 1962, 315, 3874, 8, 576, 7822, 267, 882, 275, 980, 14, 1393, 835, 8, 1143, 9, 267, 13638, 59, 2996, 12, 520, 552, 8, 293, 1874, 275, 882, 339, 372, 13638, 12, 6230, 63, 5411, 199, 199, 318, 370, 63, 1224, 8, 576, 12, 13341, 29, 403, 304, 272, 1449, 3916, 3066, 666, 543, 2215, 334, 5875, 12, 519, 6618, 9, 370, 334, 1866, 82, 17, 12, 519, 6618, 18, 9, 339, 11665, 780, 666, 1901, 3211, 1475, 367, 512, 72, 8764, 63, 31918, 339, 3897, 272, 4143, 272, 666, 520, 1625 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 2620, 820, 6618, 28629, 199, 199, 6134, 199, 518, 199, 21599, 19857, 63, 31918, 199, 331, 72, 8764, 63, 31918, 199, 199, 7516, 63, 1866, 2393, 26, 272, 5922, 805, 370, 664, 666, 1901, 289, 274, 19857, 63, 31918, 1475, 199, 475, 63, 1224, 26, 272, 5922, 805, 370, 1218, 406, 1337, 9501, 1817, 12, 883, 506, 1202, 367, 512, 72, 8764, 63, 31918, 199, 199, 10502, 641, 3868, 85, 13966, 24293, 6928, 26, 1641, 26, 1367, 6029, 199, 5949, 26, 1603, 3362, 70, 3492, 5973, 1753, 199, 3761, 26, 6289, 13, 19, 199, 199, 15242, 199, 9460, 199, 55, 29386, 26, 1022, 15999, 1159, 22801, 4079, 641, 3520, 2877, 6497, 272, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 38, 274, 19857, 5, 1465, 63, 31918, 272, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 967, 16800, 1159, 63, 31918, 199, 15319, 13, 22382, 520, 1824, 32646, 367, 512, 72, 8764, 63, 31918, 12, 24002, 11773, 83, 199, 3239, 2597, 820, 2559, 8190, 82, 199, 199, 11768, 199, 375, 199, 6807, 2552, 436, 29268, 2295, 367, 289, 274, 19857, 63, 31918, 199, 1848, 11076, 436, 2295, 12, 2043, 315, 820, 2559, 8190, 82, 12, 26124, 965, 1655, 199, 262, 15478, 5007, 19720, 12, 2896, 1750, 1561, 465, 473, 3483, 1655, 2043, 9330, 199, 388, 23329, 3423, 370, 1218, 1415, 666, 1475, 687, 3066, 666, 2043, 577, 4817, 199, 199, 624, 421, 199, 646, 2680, 465, 980, 199, 504, 7026, 492, 5020, 221, 327, 362, 16146, 402, 642, 31, 1929, 1454, 6316, 14, 7646, 421, 199, 533, 24288, 34, 4689, 8, 807, 304, 339, 1978, 275, 1543, 82, 7, 339, 347, 636, 826, 721, 277, 12, 1011, 10340, 304, 267, 1211, 855, 826, 721, 277, 12, 16286, 9, 267, 291, 855, 807, 363, 221, 275, 291, 267, 291, 423, 8489, 342, 339, 347, 485, 8489, 8, 277, 304, 267, 986, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1160, 450, 291, 199, 199, 318, 485, 442, 63, 692, 1600, 8, 88, 12, 9700, 29, 17, 12, 3462, 29, 20, 304, 272, 1449, 3676, 805, 367, 6425, 754, 1059, 367, 1109, 503, 2069, 339, 1454, 9700, 29, 17, 436, 3462, 29, 20, 365, 6366, 339, 3897, 272, 4143, 272, 671, 520, 1109, 503, 2069, 267, 574, 370, 1475, 272, 9700, 520, 413, 267, 1329, 402, 6107, 83, 370, 870, 340, 671, 365, 440, 376, 3000, 272, 3462, 520, 841, 267, 3462, 402, 1059, 339, 1803, 272, 5514, 272, 671, 442, 520, 1109, 503, 2069, 267, 671, 365, 6702, 370, 1109, 340, 652, 365, 4453, 413, 69, 13, 1079, 402, 376, 3000, 272, 671, 63, 875, 520, 620, 267, 671, 7871, 465, 1059, 12, 1902, 1543, 20, 68, 7, 503, 1543, 20, 14, 17, 70, 7, 339, 1449, 272, 671, 442, 275, 1109, 8, 2363, 8, 88, 430, 272, 340, 980, 14, 988, 8, 1590, 14, 2101, 8, 88, 442, 446, 671, 430, 665, 413, 69, 13, 1079, 26, 267, 372, 671, 442, 12, 1543, 20, 68, 7, 450, 671, 442, 272, 587, 26, 267, 372, 671, 12, 1543, 20, 14, 17, 70, 7, 450, 671, 421, 199, 318, 9531, 63, 1866, 2393, 8, 576, 12, 302, 63, 3385, 29, 403, 304, 272, 1449, 3916, 3066, 666, 543, 2215, 334, 5875, 12, 519, 6618, 9, 370, 334, 5875, 12, 6230, 63, 6851, 9, 339, 11665, 780, 666, 1901, 3211, 1475, 367, 289, 274, 19857, 63, 31918, 339, 2517, 835, 911, 746, 1919, 340, 666, 3913, 506, 6702, 370, 3000, 14, 339, 3897, 272, 4143, 272, 666, 520, 1625, 63, 2930, 12, 499, 13, 19156, 267, 666, 3035, 4637, 9801, 543, 32446, 315, 4730, 436, 6634, 2393, 267, 315, 4362, 14, 272, 302, 63, 3385, 520, 488, 503, 1109, 267, 982, 488, 12, 2066, 314, 666, 365, 6702, 370, 3000, 9695, 12, 267, 378, 12, 17, 12, 18, 32699, 78, 63, 3385, 13, 17, 14, 13821, 402, 314, 295, 1302, 316, 1454, 4637, 11106, 267, 543, 2222, 13, 4262, 8242, 787, 5120, 14, 267, 982, 642, 365, 376, 3000, 12, 2066, 314, 4637, 11106, 315, 314, 666, 787, 2575, 267, 10826, 370, 506, 315, 9446, 12, 378, 12, 17, 12, 18, 32699, 78, 63, 3385, 13, 17, 14, 1010, 642, 1930, 12, 314, 267, 2138, 1625, 1443, 1395, 4362, 543, 4697, 2338, 12, 340, 949, 5420, 267, 965, 2757, 7737, 269, 1759, 543, 642, 2166, 14, 339, 1803, 272, 5514, 272, 7953, 520, 5222, 63, 1144, 12, 334, 78, 63, 3838, 12, 302, 63, 3385, 9, 267, 22493, 8242, 402, 6634, 2393, 626, 7943, 282, 4637, 2166, 370, 8212, 83, 14, 267, 26793, 83, 787, 315, 4730, 12, 4637, 11106, 315, 4362, 14, 2378, 1449, 272, 666, 275, 980, 14, 8748, 8, 576, 9, 272, 302, 63, 3838, 275, 666, 14, 1392, 59, 16, 61, 272, 340, 302, 63, 3385, 365, 488, 26, 267, 327, 41, 4293, 1050, 1109, 8603, 334, 4471, 63, 1080, 9, 370, 980, 14, 3235, 267, 6230, 63, 5411, 12, 6230, 63, 442, 275, 980, 14, 3235, 8, 576, 14, 11186, 1062, 372, 63, 11668, 29, 549, 9, 267, 302, 63, 3385, 275, 822, 8, 3385, 63, 5411, 9, 267, 666, 63, 275, 6230, 63, 442, 14, 5217, 8, 576, 14, 1392, 9, 272, 587, 26, 267, 6230, 63, 5411, 275, 980, 14, 5605, 8, 78, 63, 3385, 9, 221, 327, 509, 372, 1454, 12, 10826, 6230, 11106, 267, 666, 63, 275, 666, 339, 13638, 275, 980, 14, 4250, 1332, 78, 63, 3838, 12, 302, 63, 3385, 395, 1109, 9, 272, 367, 4280, 12, 1962, 315, 3874, 8, 576, 7822, 267, 882, 275, 980, 14, 1393, 835, 8, 1143, 9, 267, 13638, 59, 2996, 12, 520, 552, 8, 293, 1874, 275, 882, 339, 372, 13638, 12, 6230, 63, 5411, 199, 199, 318, 370, 63, 1224, 8, 576, 12, 13341, 29, 403, 304, 272, 1449, 3916, 3066, 666, 543, 2215, 334, 5875, 12, 519, 6618, 9, 370, 334, 1866, 82, 17, 12, 519, 6618, 18, 9, 339, 11665, 780, 666, 1901, 3211, 1475, 367, 512, 72, 8764, 63, 31918, 339, 3897, 272, 4143, 272, 666, 520, 1625, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sestrella/ansible
lib/ansible/module_utils/network/ios/providers/cli/config/bgp/neighbors.py
15
6850
# # (c) 2019, Ansible by Red Hat, inc # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # import re from ansible.module_utils.six import iteritems from ansible.module_utils.network.common.utils import to_list from ansible.module_utils.network.ios.providers.providers import CliProvider class Neighbors(CliProvider): def render(self, config=None, nbr_list=None): commands = list() safe_list = list() if not nbr_list: nbr_list = self.get_value('config.neighbors') for item in nbr_list: neighbor_commands = list() context = 'neighbor %s' % item['neighbor'] cmd = '%s remote-as %s' % (context, item['remote_as']) if not config or cmd not in config: neighbor_commands.append(cmd) for key, value in iteritems(item): if value is not None: meth = getattr(self, '_render_%s' % key, None) if meth: resp = meth(item, config) if resp: neighbor_commands.extend(to_list(resp)) commands.extend(neighbor_commands) safe_list.append(context) if self.params['operation'] == 'replace': if config and safe_list: commands.extend(self._negate_config(config, safe_list)) return commands def _negate_config(self, config, safe_list=None): commands = list() matches = re.findall(r'(neighbor \S+)', config, re.M) for item in set(matches).difference(safe_list): commands.append('no %s' % item) return commands def _render_local_as(self, item, config=None): cmd = 'neighbor %s local-as %s' % (item['neighbor'], item['local_as']) if not config or cmd not in config: return cmd def _render_port(self, item, config=None): cmd = 'neighbor %s port %s' % (item['neighbor'], item['port']) if not config or cmd not in config: return cmd def _render_description(self, item, config=None): cmd = 'neighbor %s description %s' % (item['neighbor'], item['description']) if not config or cmd not in config: return cmd def _render_enabled(self, item, config=None): cmd = 'neighbor %s shutdown' % item['neighbor'] if item['enabled'] is True: if not config or cmd in config: cmd = 'no %s' % cmd return cmd elif not config or cmd not in config: return cmd def _render_update_source(self, item, config=None): cmd = 'neighbor %s update-source %s' % (item['neighbor'], item['update_source']) if not config or cmd not in config: return cmd def _render_password(self, item, config=None): cmd = 'neighbor %s password %s' % (item['neighbor'], item['password']) if not config or cmd not in config: return cmd def _render_ebgp_multihop(self, item, config=None): cmd = 'neighbor %s ebgp-multihop %s' % (item['neighbor'], item['ebgp_multihop']) if not config or cmd not in config: return cmd def _render_peer_group(self, item, config=None): cmd = 'neighbor %s peer-group %s' % (item['neighbor'], item['peer_group']) if not config or cmd not in config: return cmd def _render_timers(self, item, config): """generate bgp timer related configuration """ keepalive = item['timers']['keepalive'] holdtime = item['timers']['holdtime'] min_neighbor_holdtime = item['timers']['min_neighbor_holdtime'] neighbor = item['neighbor'] if keepalive and holdtime: cmd = 'neighbor %s timers %s %s' % (neighbor, keepalive, holdtime) if min_neighbor_holdtime: cmd += ' %s' % min_neighbor_holdtime if not config or cmd not in config: return cmd class AFNeighbors(CliProvider): def render(self, config=None, nbr_list=None): commands = list() if not nbr_list: return for item in nbr_list: neighbor_commands = list() for key, value in iteritems(item): if value is not None: meth = getattr(self, '_render_%s' % key, None) if meth: resp = meth(item, config) if resp: neighbor_commands.extend(to_list(resp)) commands.extend(neighbor_commands) return commands def _render_advertisement_interval(self, item, config=None): cmd = 'neighbor %s advertisement-interval %s' % (item['neighbor'], item['advertisement_interval']) if not config or cmd not in config: return cmd def _render_route_reflector_client(self, item, config=None): cmd = 'neighbor %s route-reflector-client' % item['neighbor'] if item['route_reflector_client'] is False: if not config or cmd in config: cmd = 'no %s' % cmd return cmd elif not config or cmd not in config: return cmd def _render_route_server_client(self, item, config=None): cmd = 'neighbor %s route-server-client' % item['neighbor'] if item['route_server_client'] is False: if not config or cmd in config: cmd = 'no %s' % cmd return cmd elif not config or cmd not in config: return cmd def _render_remove_private_as(self, item, config=None): cmd = 'neighbor %s remove-private-as' % item['neighbor'] if item['remove_private_as'] is False: if not config or cmd in config: cmd = 'no %s' % cmd return cmd elif not config or cmd not in config: return cmd def _render_next_hop_self(self, item, config=None): cmd = 'neighbor %s next-hop-self' % item['neighbor'] if item['next_hop_self'] is False: if not config or cmd in config: cmd = 'no %s' % cmd return cmd elif not config or cmd not in config: return cmd def _render_activate(self, item, config=None): cmd = 'neighbor %s activate' % item['neighbor'] if item['activate'] is False: if not config or cmd in config: cmd = 'no %s' % cmd return cmd elif not config or cmd not in config: return cmd def _render_maximum_prefix(self, item, config=None): cmd = 'neighbor %s maximum-prefix %s' % (item['neighbor'], item['maximum_prefix']) if not config or cmd not in config: return cmd
gpl-3.0
[ 3, 199, 3, 334, 67, 9, 20312, 12, 2622, 701, 9572, 13002, 12, 12864, 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, 3, 199, 646, 295, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 10849, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 2330, 14, 1208, 492, 370, 63, 513, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 9207, 14, 9710, 14, 9710, 492, 445, 317, 6663, 421, 199, 533, 5612, 7398, 8, 20653, 6663, 304, 339, 347, 3795, 8, 277, 12, 1101, 29, 403, 12, 31646, 63, 513, 29, 403, 304, 267, 3718, 275, 769, 342, 267, 5048, 63, 513, 275, 769, 342, 267, 340, 440, 31646, 63, 513, 26, 288, 31646, 63, 513, 275, 291, 14, 362, 63, 585, 360, 888, 14, 11113, 358, 398, 367, 1242, 315, 31646, 63, 513, 26, 288, 15503, 63, 4405, 275, 769, 342, 288, 1067, 275, 283, 13881, 450, 83, 7, 450, 1242, 459, 13881, 418, 288, 2088, 275, 1543, 83, 3982, 13, 305, 450, 83, 7, 450, 334, 1100, 12, 1242, 459, 3846, 63, 305, 1105, 953, 340, 440, 1101, 503, 2088, 440, 315, 1101, 26, 355, 15503, 63, 4405, 14, 740, 8, 1760, 9, 953, 367, 790, 12, 574, 315, 10849, 8, 1053, 304, 355, 340, 574, 365, 440, 488, 26, 490, 12750, 275, 2519, 8, 277, 12, 2513, 3352, 4970, 83, 7, 450, 790, 12, 488, 9, 490, 340, 12750, 26, 717, 3085, 275, 12750, 8, 1053, 12, 1101, 9, 717, 340, 3085, 26, 1169, 15503, 63, 4405, 14, 2880, 8, 475, 63, 513, 8, 4518, 430, 953, 3718, 14, 2880, 8, 13881, 63, 4405, 9, 288, 5048, 63, 513, 14, 740, 8, 1100, 9, 398, 340, 291, 14, 1162, 459, 5735, 418, 508, 283, 1814, 356, 288, 340, 1101, 436, 5048, 63, 513, 26, 355, 3718, 14, 2880, 8, 277, 423, 28901, 63, 888, 8, 888, 12, 5048, 63, 513, 430, 398, 372, 3718, 339, 347, 485, 28901, 63, 888, 8, 277, 12, 1101, 12, 5048, 63, 513, 29, 403, 304, 267, 3718, 275, 769, 342, 267, 4450, 275, 295, 14, 6452, 8, 82, 6774, 13881, 971, 51, 14705, 1101, 12, 295, 14, 45, 9, 267, 367, 1242, 315, 663, 8, 6742, 680, 9196, 8, 3489, 63, 513, 304, 288, 3718, 14, 740, 360, 889, 450, 83, 7, 450, 1242, 9, 267, 372, 3718, 339, 347, 485, 3352, 63, 1832, 63, 305, 8, 277, 12, 1242, 12, 1101, 29, 403, 304, 267, 2088, 275, 283, 13881, 450, 83, 2257, 13, 305, 450, 83, 7, 450, 334, 1053, 459, 13881, 995, 1242, 459, 1832, 63, 305, 1105, 267, 340, 440, 1101, 503, 2088, 440, 315, 1101, 26, 288, 372, 2088, 339, 347, 485, 3352, 63, 719, 8, 277, 12, 1242, 12, 1101, 29, 403, 304, 267, 2088, 275, 283, 13881, 450, 83, 1844, 450, 83, 7, 450, 334, 1053, 459, 13881, 995, 1242, 459, 719, 1105, 267, 340, 440, 1101, 503, 2088, 440, 315, 1101, 26, 288, 372, 2088, 339, 347, 485, 3352, 63, 1802, 8, 277, 12, 1242, 12, 1101, 29, 403, 304, 267, 2088, 275, 283, 13881, 450, 83, 1369, 450, 83, 7, 450, 334, 1053, 459, 13881, 995, 1242, 459, 1802, 1105, 267, 340, 440, 1101, 503, 2088, 440, 315, 1101, 26, 288, 372, 2088, 339, 347, 485, 3352, 63, 3827, 8, 277, 12, 1242, 12, 1101, 29, 403, 304, 267, 2088, 275, 283, 13881, 450, 83, 12842, 7, 450, 1242, 459, 13881, 418, 267, 340, 1242, 459, 3827, 418, 365, 715, 26, 288, 340, 440, 1101, 503, 2088, 315, 1101, 26, 355, 2088, 275, 283, 889, 450, 83, 7, 450, 2088, 355, 372, 2088, 267, 916, 440, 1101, 503, 2088, 440, 315, 1101, 26, 288, 372, 2088, 339, 347, 485, 3352, 63, 873, 63, 1365, 8, 277, 12, 1242, 12, 1101, 29, 403, 304, 267, 2088, 275, 283, 13881, 450, 83, 1678, 13, 1365, 450, 83, 7, 450, 334, 1053, 459, 13881, 995, 1242, 459, 873, 63, 1365, 1105, 267, 340, 440, 1101, 503, 2088, 440, 315, 1101, 26, 288, 372, 2088, 339, 347, 485, 3352, 63, 2060, 8, 277, 12, 1242, 12, 1101, 29, 403, 304, 267, 2088, 275, 283, 13881, 450, 83, 2505, 450, 83, 7, 450, 334, 1053, 459, 13881, 995, 1242, 459, 2060, 1105, 267, 340, 440, 1101, 503, 2088, 440, 315, 1101, 26, 288, 372, 2088, 339, 347, 485, 3352, 63, 2871, 4927, 63, 3029, 13376, 8, 277, 12, 1242, 12, 1101, 29, 403, 304, 267, 2088, 275, 283, 13881, 450, 83, 325, 10132, 13, 3029, 13376, 450, 83, 7, 450, 334, 1053, 459, 13881, 995, 1242, 459, 2871, 4927, 63, 3029, 13376, 1105, 267, 340, 440, 1101, 503, 2088, 440, 315, 1101, 26, 288, 372, 2088, 339, 347, 485, 3352, 63, 7866, 63, 923, 8, 277, 12, 1242, 12, 1101, 29, 403, 304, 267, 2088, 275, 283, 13881, 450, 83, 9104, 13, 923, 450, 83, 7, 450, 334, 1053, 459, 13881, 995, 1242, 459, 7866, 63, 923, 1105, 267, 340, 440, 1101, 503, 2088, 440, 315, 1101, 26, 288, 372, 2088, 339, 347, 485, 3352, 63, 27386, 8, 277, 12, 1242, 12, 1101, 304, 267, 408, 4208, 16884, 9715, 4048, 2897, 267, 408, 267, 4215, 9631, 275, 1242, 459, 27386, 2545, 28227, 418, 267, 10266, 521, 275, 1242, 459, 27386, 2545, 12239, 521, 418, 267, 1748, 63, 13881, 63, 12239, 521, 275, 1242, 459, 27386, 2545, 827, 63, 13881, 63, 12239, 521, 418, 267, 15503, 275, 1242, 459, 13881, 418, 398, 340, 4215, 9631, 436, 10266, 521, 26, 288, 2088, 275, 283, 13881, 450, 83, 900, 2393, 450, 83, 450, 83, 7, 450, 334, 13881, 12, 4215, 9631, 12, 10266, 521, 9, 288, 340, 1748, 63, 13881, 63, 12239, 521, 26, 355, 2088, 847, 283, 450, 83, 7, 450, 1748, 63, 13881, 63, 12239, 521, 288, 340, 440, 1101, 503, 2088, 440, 315, 1101, 26, 355, 372, 2088, 421, 199, 533, 20089, 20011, 8, 20653, 6663, 304, 339, 347, 3795, 8, 277, 12, 1101, 29, 403, 12, 31646, 63, 513 ]
[ 199, 3, 334, 67, 9, 20312, 12, 2622, 701, 9572, 13002, 12, 12864, 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, 3, 199, 646, 295, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 10849, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 2330, 14, 1208, 492, 370, 63, 513, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 9207, 14, 9710, 14, 9710, 492, 445, 317, 6663, 421, 199, 533, 5612, 7398, 8, 20653, 6663, 304, 339, 347, 3795, 8, 277, 12, 1101, 29, 403, 12, 31646, 63, 513, 29, 403, 304, 267, 3718, 275, 769, 342, 267, 5048, 63, 513, 275, 769, 342, 267, 340, 440, 31646, 63, 513, 26, 288, 31646, 63, 513, 275, 291, 14, 362, 63, 585, 360, 888, 14, 11113, 358, 398, 367, 1242, 315, 31646, 63, 513, 26, 288, 15503, 63, 4405, 275, 769, 342, 288, 1067, 275, 283, 13881, 450, 83, 7, 450, 1242, 459, 13881, 418, 288, 2088, 275, 1543, 83, 3982, 13, 305, 450, 83, 7, 450, 334, 1100, 12, 1242, 459, 3846, 63, 305, 1105, 953, 340, 440, 1101, 503, 2088, 440, 315, 1101, 26, 355, 15503, 63, 4405, 14, 740, 8, 1760, 9, 953, 367, 790, 12, 574, 315, 10849, 8, 1053, 304, 355, 340, 574, 365, 440, 488, 26, 490, 12750, 275, 2519, 8, 277, 12, 2513, 3352, 4970, 83, 7, 450, 790, 12, 488, 9, 490, 340, 12750, 26, 717, 3085, 275, 12750, 8, 1053, 12, 1101, 9, 717, 340, 3085, 26, 1169, 15503, 63, 4405, 14, 2880, 8, 475, 63, 513, 8, 4518, 430, 953, 3718, 14, 2880, 8, 13881, 63, 4405, 9, 288, 5048, 63, 513, 14, 740, 8, 1100, 9, 398, 340, 291, 14, 1162, 459, 5735, 418, 508, 283, 1814, 356, 288, 340, 1101, 436, 5048, 63, 513, 26, 355, 3718, 14, 2880, 8, 277, 423, 28901, 63, 888, 8, 888, 12, 5048, 63, 513, 430, 398, 372, 3718, 339, 347, 485, 28901, 63, 888, 8, 277, 12, 1101, 12, 5048, 63, 513, 29, 403, 304, 267, 3718, 275, 769, 342, 267, 4450, 275, 295, 14, 6452, 8, 82, 6774, 13881, 971, 51, 14705, 1101, 12, 295, 14, 45, 9, 267, 367, 1242, 315, 663, 8, 6742, 680, 9196, 8, 3489, 63, 513, 304, 288, 3718, 14, 740, 360, 889, 450, 83, 7, 450, 1242, 9, 267, 372, 3718, 339, 347, 485, 3352, 63, 1832, 63, 305, 8, 277, 12, 1242, 12, 1101, 29, 403, 304, 267, 2088, 275, 283, 13881, 450, 83, 2257, 13, 305, 450, 83, 7, 450, 334, 1053, 459, 13881, 995, 1242, 459, 1832, 63, 305, 1105, 267, 340, 440, 1101, 503, 2088, 440, 315, 1101, 26, 288, 372, 2088, 339, 347, 485, 3352, 63, 719, 8, 277, 12, 1242, 12, 1101, 29, 403, 304, 267, 2088, 275, 283, 13881, 450, 83, 1844, 450, 83, 7, 450, 334, 1053, 459, 13881, 995, 1242, 459, 719, 1105, 267, 340, 440, 1101, 503, 2088, 440, 315, 1101, 26, 288, 372, 2088, 339, 347, 485, 3352, 63, 1802, 8, 277, 12, 1242, 12, 1101, 29, 403, 304, 267, 2088, 275, 283, 13881, 450, 83, 1369, 450, 83, 7, 450, 334, 1053, 459, 13881, 995, 1242, 459, 1802, 1105, 267, 340, 440, 1101, 503, 2088, 440, 315, 1101, 26, 288, 372, 2088, 339, 347, 485, 3352, 63, 3827, 8, 277, 12, 1242, 12, 1101, 29, 403, 304, 267, 2088, 275, 283, 13881, 450, 83, 12842, 7, 450, 1242, 459, 13881, 418, 267, 340, 1242, 459, 3827, 418, 365, 715, 26, 288, 340, 440, 1101, 503, 2088, 315, 1101, 26, 355, 2088, 275, 283, 889, 450, 83, 7, 450, 2088, 355, 372, 2088, 267, 916, 440, 1101, 503, 2088, 440, 315, 1101, 26, 288, 372, 2088, 339, 347, 485, 3352, 63, 873, 63, 1365, 8, 277, 12, 1242, 12, 1101, 29, 403, 304, 267, 2088, 275, 283, 13881, 450, 83, 1678, 13, 1365, 450, 83, 7, 450, 334, 1053, 459, 13881, 995, 1242, 459, 873, 63, 1365, 1105, 267, 340, 440, 1101, 503, 2088, 440, 315, 1101, 26, 288, 372, 2088, 339, 347, 485, 3352, 63, 2060, 8, 277, 12, 1242, 12, 1101, 29, 403, 304, 267, 2088, 275, 283, 13881, 450, 83, 2505, 450, 83, 7, 450, 334, 1053, 459, 13881, 995, 1242, 459, 2060, 1105, 267, 340, 440, 1101, 503, 2088, 440, 315, 1101, 26, 288, 372, 2088, 339, 347, 485, 3352, 63, 2871, 4927, 63, 3029, 13376, 8, 277, 12, 1242, 12, 1101, 29, 403, 304, 267, 2088, 275, 283, 13881, 450, 83, 325, 10132, 13, 3029, 13376, 450, 83, 7, 450, 334, 1053, 459, 13881, 995, 1242, 459, 2871, 4927, 63, 3029, 13376, 1105, 267, 340, 440, 1101, 503, 2088, 440, 315, 1101, 26, 288, 372, 2088, 339, 347, 485, 3352, 63, 7866, 63, 923, 8, 277, 12, 1242, 12, 1101, 29, 403, 304, 267, 2088, 275, 283, 13881, 450, 83, 9104, 13, 923, 450, 83, 7, 450, 334, 1053, 459, 13881, 995, 1242, 459, 7866, 63, 923, 1105, 267, 340, 440, 1101, 503, 2088, 440, 315, 1101, 26, 288, 372, 2088, 339, 347, 485, 3352, 63, 27386, 8, 277, 12, 1242, 12, 1101, 304, 267, 408, 4208, 16884, 9715, 4048, 2897, 267, 408, 267, 4215, 9631, 275, 1242, 459, 27386, 2545, 28227, 418, 267, 10266, 521, 275, 1242, 459, 27386, 2545, 12239, 521, 418, 267, 1748, 63, 13881, 63, 12239, 521, 275, 1242, 459, 27386, 2545, 827, 63, 13881, 63, 12239, 521, 418, 267, 15503, 275, 1242, 459, 13881, 418, 398, 340, 4215, 9631, 436, 10266, 521, 26, 288, 2088, 275, 283, 13881, 450, 83, 900, 2393, 450, 83, 450, 83, 7, 450, 334, 13881, 12, 4215, 9631, 12, 10266, 521, 9, 288, 340, 1748, 63, 13881, 63, 12239, 521, 26, 355, 2088, 847, 283, 450, 83, 7, 450, 1748, 63, 13881, 63, 12239, 521, 288, 340, 440, 1101, 503, 2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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ptkool/spark
python/pyspark/sql/tests/test_pandas_udf.py
12
10115
# # 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 unittest from pyspark.sql.functions import udf, pandas_udf, PandasUDFType from pyspark.sql.types import * from pyspark.sql.utils import ParseException from pyspark.rdd import PythonEvalType from pyspark.testing.sqlutils import ReusedSQLTestCase, have_pandas, have_pyarrow, \ pandas_requirement_message, pyarrow_requirement_message from pyspark.testing.utils import QuietTest from py4j.protocol import Py4JJavaError @unittest.skipIf( not have_pandas or not have_pyarrow, pandas_requirement_message or pyarrow_requirement_message) class PandasUDFTests(ReusedSQLTestCase): def test_pandas_udf_basic(self): udf = pandas_udf(lambda x: x, DoubleType()) self.assertEqual(udf.returnType, DoubleType()) self.assertEqual(udf.evalType, PythonEvalType.SQL_SCALAR_PANDAS_UDF) udf = pandas_udf(lambda x: x, DoubleType(), PandasUDFType.SCALAR) self.assertEqual(udf.returnType, DoubleType()) self.assertEqual(udf.evalType, PythonEvalType.SQL_SCALAR_PANDAS_UDF) udf = pandas_udf(lambda x: x, 'double', PandasUDFType.SCALAR) self.assertEqual(udf.returnType, DoubleType()) self.assertEqual(udf.evalType, PythonEvalType.SQL_SCALAR_PANDAS_UDF) udf = pandas_udf(lambda x: x, StructType([StructField("v", DoubleType())]), PandasUDFType.GROUPED_MAP) self.assertEqual(udf.returnType, StructType([StructField("v", DoubleType())])) self.assertEqual(udf.evalType, PythonEvalType.SQL_GROUPED_MAP_PANDAS_UDF) udf = pandas_udf(lambda x: x, 'v double', PandasUDFType.GROUPED_MAP) self.assertEqual(udf.returnType, StructType([StructField("v", DoubleType())])) self.assertEqual(udf.evalType, PythonEvalType.SQL_GROUPED_MAP_PANDAS_UDF) udf = pandas_udf(lambda x: x, 'v double', functionType=PandasUDFType.GROUPED_MAP) self.assertEqual(udf.returnType, StructType([StructField("v", DoubleType())])) self.assertEqual(udf.evalType, PythonEvalType.SQL_GROUPED_MAP_PANDAS_UDF) udf = pandas_udf(lambda x: x, returnType='v double', functionType=PandasUDFType.GROUPED_MAP) self.assertEqual(udf.returnType, StructType([StructField("v", DoubleType())])) self.assertEqual(udf.evalType, PythonEvalType.SQL_GROUPED_MAP_PANDAS_UDF) def test_pandas_udf_decorator(self): @pandas_udf(DoubleType()) def foo(x): return x self.assertEqual(foo.returnType, DoubleType()) self.assertEqual(foo.evalType, PythonEvalType.SQL_SCALAR_PANDAS_UDF) @pandas_udf(returnType=DoubleType()) def foo(x): return x self.assertEqual(foo.returnType, DoubleType()) self.assertEqual(foo.evalType, PythonEvalType.SQL_SCALAR_PANDAS_UDF) schema = StructType([StructField("v", DoubleType())]) @pandas_udf(schema, PandasUDFType.GROUPED_MAP) def foo(x): return x self.assertEqual(foo.returnType, schema) self.assertEqual(foo.evalType, PythonEvalType.SQL_GROUPED_MAP_PANDAS_UDF) @pandas_udf('v double', PandasUDFType.GROUPED_MAP) def foo(x): return x self.assertEqual(foo.returnType, schema) self.assertEqual(foo.evalType, PythonEvalType.SQL_GROUPED_MAP_PANDAS_UDF) @pandas_udf(schema, functionType=PandasUDFType.GROUPED_MAP) def foo(x): return x self.assertEqual(foo.returnType, schema) self.assertEqual(foo.evalType, PythonEvalType.SQL_GROUPED_MAP_PANDAS_UDF) @pandas_udf(returnType='double', functionType=PandasUDFType.SCALAR) def foo(x): return x self.assertEqual(foo.returnType, DoubleType()) self.assertEqual(foo.evalType, PythonEvalType.SQL_SCALAR_PANDAS_UDF) @pandas_udf(returnType=schema, functionType=PandasUDFType.GROUPED_MAP) def foo(x): return x self.assertEqual(foo.returnType, schema) self.assertEqual(foo.evalType, PythonEvalType.SQL_GROUPED_MAP_PANDAS_UDF) def test_udf_wrong_arg(self): with QuietTest(self.sc): with self.assertRaises(ParseException): @pandas_udf('blah') def foo(x): return x with self.assertRaisesRegexp(ValueError, 'Invalid returnType.*None'): @pandas_udf(functionType=PandasUDFType.SCALAR) def foo(x): return x with self.assertRaisesRegexp(ValueError, 'Invalid functionType'): @pandas_udf('double', 100) def foo(x): return x with self.assertRaisesRegexp(ValueError, '0-arg pandas_udfs.*not.*supported'): pandas_udf(lambda: 1, LongType(), PandasUDFType.SCALAR) with self.assertRaisesRegexp(ValueError, '0-arg pandas_udfs.*not.*supported'): @pandas_udf(LongType(), PandasUDFType.SCALAR) def zero_with_type(): return 1 with self.assertRaisesRegexp(TypeError, 'Invalid returnType'): @pandas_udf(returnType=PandasUDFType.GROUPED_MAP) def foo(df): return df with self.assertRaisesRegexp(TypeError, 'Invalid returnType'): @pandas_udf(returnType='double', functionType=PandasUDFType.GROUPED_MAP) def foo(df): return df with self.assertRaisesRegexp(ValueError, 'Invalid function'): @pandas_udf(returnType='k int, v double', functionType=PandasUDFType.GROUPED_MAP) def foo(k, v, w): return k def test_stopiteration_in_udf(self): def foo(x): raise StopIteration() def foofoo(x, y): raise StopIteration() exc_message = "Caught StopIteration thrown from user's code; failing the task" df = self.spark.range(0, 100) # plain udf (test for SPARK-23754) self.assertRaisesRegexp( Py4JJavaError, exc_message, df.withColumn('v', udf(foo)('id')).collect ) # pandas scalar udf self.assertRaisesRegexp( Py4JJavaError, exc_message, df.withColumn( 'v', pandas_udf(foo, 'double', PandasUDFType.SCALAR)('id') ).collect ) # pandas grouped map self.assertRaisesRegexp( Py4JJavaError, exc_message, df.groupBy('id').apply( pandas_udf(foo, df.schema, PandasUDFType.GROUPED_MAP) ).collect ) self.assertRaisesRegexp( Py4JJavaError, exc_message, df.groupBy('id').apply( pandas_udf(foofoo, df.schema, PandasUDFType.GROUPED_MAP) ).collect ) # pandas grouped agg self.assertRaisesRegexp( Py4JJavaError, exc_message, df.groupBy('id').agg( pandas_udf(foo, 'double', PandasUDFType.GROUPED_AGG)('id') ).collect ) def test_pandas_udf_detect_unsafe_type_conversion(self): import pandas as pd import numpy as np values = [1.0] * 3 pdf = pd.DataFrame({'A': values}) df = self.spark.createDataFrame(pdf).repartition(1) @pandas_udf(returnType="int") def udf(column): return pd.Series(np.linspace(0, 1, len(column))) # Since 0.11.0, PyArrow supports the feature to raise an error for unsafe cast. with self.sql_conf({ "spark.sql.execution.pandas.arrowSafeTypeConversion": True}): with self.assertRaisesRegexp(Exception, "Exception thrown when converting pandas.Series"): df.select(['A']).withColumn('udf', udf('A')).collect() # Disabling Arrow safe type check. with self.sql_conf({ "spark.sql.execution.pandas.arrowSafeTypeConversion": False}): df.select(['A']).withColumn('udf', udf('A')).collect() def test_pandas_udf_arrow_overflow(self): import pandas as pd df = self.spark.range(0, 1) @pandas_udf(returnType="byte") def udf(column): return pd.Series([128] * len(column)) # When enabling safe type check, Arrow 0.11.0+ disallows overflow cast. with self.sql_conf({ "spark.sql.execution.pandas.arrowSafeTypeConversion": True}): with self.assertRaisesRegexp(Exception, "Exception thrown when converting pandas.Series"): df.withColumn('udf', udf('id')).collect() # Disabling safe type check, let Arrow do the cast anyway. with self.sql_conf({"spark.sql.execution.pandas.arrowSafeTypeConversion": False}): df.withColumn('udf', udf('id')).collect() if __name__ == "__main__": from pyspark.sql.tests.test_pandas_udf import * try: import xmlrunner 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, 2882, 199, 199, 504, 15847, 14, 3009, 14, 5777, 492, 399, 1587, 12, 10634, 63, 10031, 12, 510, 7683, 3383, 38, 804, 199, 504, 15847, 14, 3009, 14, 1313, 492, 627, 199, 504, 15847, 14, 3009, 14, 1208, 492, 20946, 199, 504, 15847, 14, 20533, 492, 2018, 10006, 804, 199, 504, 15847, 14, 4776, 14, 3009, 1208, 492, 799, 2972, 4657, 1746, 12, 1172, 63, 15718, 12, 1172, 63, 647, 7691, 12, 971, 272, 10634, 63, 12434, 63, 1188, 12, 1134, 7691, 63, 12434, 63, 1188, 199, 504, 15847, 14, 4776, 14, 1208, 492, 1413, 1907, 386, 774, 199, 199, 504, 1134, 20, 74, 14, 3922, 492, 1611, 20, 42, 12576, 547, 421, 199, 32, 2796, 14, 15118, 8, 272, 440, 1172, 63, 15718, 503, 440, 1172, 63, 647, 7691, 12, 272, 10634, 63, 12434, 63, 1188, 503, 1134, 7691, 63, 12434, 63, 1188, 9, 199, 533, 510, 7683, 3383, 38, 2925, 8, 497, 2972, 4657, 1746, 304, 339, 347, 511, 63, 15718, 63, 10031, 63, 4316, 8, 277, 304, 267, 399, 1587, 275, 10634, 63, 10031, 8, 2734, 671, 26, 671, 12, 22945, 804, 1012, 267, 291, 14, 629, 8, 10031, 14, 1107, 804, 12, 22945, 804, 1012, 267, 291, 14, 629, 8, 10031, 14, 2579, 804, 12, 2018, 10006, 804, 14, 4657, 63, 17209, 689, 63, 48, 3649, 1179, 63, 3383, 38, 9, 398, 399, 1587, 275, 10634, 63, 10031, 8, 2734, 671, 26, 671, 12, 22945, 804, 1062, 510, 7683, 3383, 38, 804, 14, 17209, 689, 9, 267, 291, 14, 629, 8, 10031, 14, 1107, 804, 12, 22945, 804, 1012, 267, 291, 14, 629, 8, 10031, 14, 2579, 804, 12, 2018, 10006, 804, 14, 4657, 63, 17209, 689, 63, 48, 3649, 1179, 63, 3383, 38, 9, 398, 399, 1587, 275, 10634, 63, 10031, 8, 2734, 671, 26, 671, 12, 283, 3157, 297, 510, 7683, 3383, 38, 804, 14, 17209, 689, 9, 267, 291, 14, 629, 8, 10031, 14, 1107, 804, 12, 22945, 804, 1012, 267, 291, 14, 629, 8, 10031, 14, 2579, 804, 12, 2018, 10006, 804, 14, 4657, 63, 17209, 689, 63, 48, 3649, 1179, 63, 3383, 38, 9, 398, 399, 1587, 275, 10634, 63, 10031, 8, 2734, 671, 26, 671, 12, 13039, 804, 779, 4836, 792, 480, 86, 401, 22945, 804, 1012, 2522, 586, 510, 7683, 3383, 38, 804, 14, 7823, 1149, 63, 5443, 9, 267, 291, 14, 629, 8, 10031, 14, 1107, 804, 12, 13039, 804, 779, 4836, 792, 480, 86, 401, 22945, 804, 1012, 2459, 267, 291, 14, 629, 8, 10031, 14, 2579, 804, 12, 2018, 10006, 804, 14, 4657, 63, 7823, 1149, 63, 5443, 63, 48, 3649, 1179, 63, 3383, 38, 9, 398, 399, 1587, 275, 10634, 63, 10031, 8, 2734, 671, 26, 671, 12, 283, 86, 4270, 297, 510, 7683, 3383, 38, 804, 14, 7823, 1149, 63, 5443, 9, 267, 291, 14, 629, 8, 10031, 14, 1107, 804, 12, 13039, 804, 779, 4836, 792, 480, 86, 401, 22945, 804, 1012, 2459, 267, 291, 14, 629, 8, 10031, 14, 2579, 804, 12, 2018, 10006, 804, 14, 4657, 63, 7823, 1149, 63, 5443, 63, 48, 3649, 1179, 63, 3383, 38, 9, 398, 399, 1587, 275, 10634, 63, 10031, 8, 2734, 671, 26, 671, 12, 283, 86, 4270, 297, 586, 805, 804, 29, 48, 7683, 3383, 38, 804, 14, 7823, 1149, 63, 5443, 9, 267, 291, 14, 629, 8, 10031, 14, 1107, 804, 12, 13039, 804, 779, 4836, 792, 480, 86, 401, 22945, 804, 1012, 2459, 267, 291, 14, 629, 8, 10031, 14, 2579, 804, 12, 2018, 10006, 804, 14, 4657, 63, 7823, 1149, 63, 5443, 63, 48, 3649, 1179, 63, 3383, 38, 9, 398, 399, 1587, 275, 10634, 63, 10031, 8, 2734, 671, 26, 671, 12, 372, 804, 534, 86, 4270, 297, 586, 805, 804, 29, 48, 7683, 3383, 38, 804, 14, 7823, 1149, 63, 5443, 9, 267, 291, 14, 629, 8, 10031, 14, 1107, 804, 12, 13039, 804, 779, 4836, 792, 480, 86, 401, 22945, 804, 1012, 2459, 267, 291, 14, 629, 8, 10031, 14, 2579, 804, 12, 2018, 10006, 804, 14, 4657, 63, 7823, 1149, 63, 5443, 63, 48, 3649, 1179, 63, 3383, 38, 9, 339, 347, 511, 63, 15718, 63, 10031, 63, 11547, 8, 277, 304, 267, 768, 15718, 63, 10031, 8, 7281, 804, 1012, 267, 347, 3925, 8, 88, 304, 288, 372, 671, 267, 291, 14, 629, 8, 1421, 14, 1107, 804, 12, 22945, 804, 1012, 267, 291, 14, 629, 8, 1421, 14, 2579, 804, 12, 2018, 10006, 804, 14, 4657, 63, 17209, 689, 63, 48, 3649, 1179, 63, 3383, 38, 9, 398, 768, 15718, 63, 10031, 8, 1107, 804, 29, 7281, 804, 1012, 267, 347, 3925, 8, 88, 304, 288, 372, 671, 267, 291, 14, 629, 8, 1421, 14, 1107, 804, 12, 22945, 804, 1012, 267, 291, 14, 629, 8, 1421, 14, 2579, 804, 12, 2018, 10006, 804, 14, 4657, 63, 17209, 689, 63, 48, 3649, 1179, 63, 3383, 38, 9, 398, 4177, 275, 13039, 804, 779, 4836, 792, 480, 86, 401, 22945, 804, 30719, 398, 768, 15718, 63, 10031, 8, 3629, 12, 510, 7683, 3383, 38, 804, 14, 7823, 1149 ]
[ 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, 2882, 199, 199, 504, 15847, 14, 3009, 14, 5777, 492, 399, 1587, 12, 10634, 63, 10031, 12, 510, 7683, 3383, 38, 804, 199, 504, 15847, 14, 3009, 14, 1313, 492, 627, 199, 504, 15847, 14, 3009, 14, 1208, 492, 20946, 199, 504, 15847, 14, 20533, 492, 2018, 10006, 804, 199, 504, 15847, 14, 4776, 14, 3009, 1208, 492, 799, 2972, 4657, 1746, 12, 1172, 63, 15718, 12, 1172, 63, 647, 7691, 12, 971, 272, 10634, 63, 12434, 63, 1188, 12, 1134, 7691, 63, 12434, 63, 1188, 199, 504, 15847, 14, 4776, 14, 1208, 492, 1413, 1907, 386, 774, 199, 199, 504, 1134, 20, 74, 14, 3922, 492, 1611, 20, 42, 12576, 547, 421, 199, 32, 2796, 14, 15118, 8, 272, 440, 1172, 63, 15718, 503, 440, 1172, 63, 647, 7691, 12, 272, 10634, 63, 12434, 63, 1188, 503, 1134, 7691, 63, 12434, 63, 1188, 9, 199, 533, 510, 7683, 3383, 38, 2925, 8, 497, 2972, 4657, 1746, 304, 339, 347, 511, 63, 15718, 63, 10031, 63, 4316, 8, 277, 304, 267, 399, 1587, 275, 10634, 63, 10031, 8, 2734, 671, 26, 671, 12, 22945, 804, 1012, 267, 291, 14, 629, 8, 10031, 14, 1107, 804, 12, 22945, 804, 1012, 267, 291, 14, 629, 8, 10031, 14, 2579, 804, 12, 2018, 10006, 804, 14, 4657, 63, 17209, 689, 63, 48, 3649, 1179, 63, 3383, 38, 9, 398, 399, 1587, 275, 10634, 63, 10031, 8, 2734, 671, 26, 671, 12, 22945, 804, 1062, 510, 7683, 3383, 38, 804, 14, 17209, 689, 9, 267, 291, 14, 629, 8, 10031, 14, 1107, 804, 12, 22945, 804, 1012, 267, 291, 14, 629, 8, 10031, 14, 2579, 804, 12, 2018, 10006, 804, 14, 4657, 63, 17209, 689, 63, 48, 3649, 1179, 63, 3383, 38, 9, 398, 399, 1587, 275, 10634, 63, 10031, 8, 2734, 671, 26, 671, 12, 283, 3157, 297, 510, 7683, 3383, 38, 804, 14, 17209, 689, 9, 267, 291, 14, 629, 8, 10031, 14, 1107, 804, 12, 22945, 804, 1012, 267, 291, 14, 629, 8, 10031, 14, 2579, 804, 12, 2018, 10006, 804, 14, 4657, 63, 17209, 689, 63, 48, 3649, 1179, 63, 3383, 38, 9, 398, 399, 1587, 275, 10634, 63, 10031, 8, 2734, 671, 26, 671, 12, 13039, 804, 779, 4836, 792, 480, 86, 401, 22945, 804, 1012, 2522, 586, 510, 7683, 3383, 38, 804, 14, 7823, 1149, 63, 5443, 9, 267, 291, 14, 629, 8, 10031, 14, 1107, 804, 12, 13039, 804, 779, 4836, 792, 480, 86, 401, 22945, 804, 1012, 2459, 267, 291, 14, 629, 8, 10031, 14, 2579, 804, 12, 2018, 10006, 804, 14, 4657, 63, 7823, 1149, 63, 5443, 63, 48, 3649, 1179, 63, 3383, 38, 9, 398, 399, 1587, 275, 10634, 63, 10031, 8, 2734, 671, 26, 671, 12, 283, 86, 4270, 297, 510, 7683, 3383, 38, 804, 14, 7823, 1149, 63, 5443, 9, 267, 291, 14, 629, 8, 10031, 14, 1107, 804, 12, 13039, 804, 779, 4836, 792, 480, 86, 401, 22945, 804, 1012, 2459, 267, 291, 14, 629, 8, 10031, 14, 2579, 804, 12, 2018, 10006, 804, 14, 4657, 63, 7823, 1149, 63, 5443, 63, 48, 3649, 1179, 63, 3383, 38, 9, 398, 399, 1587, 275, 10634, 63, 10031, 8, 2734, 671, 26, 671, 12, 283, 86, 4270, 297, 586, 805, 804, 29, 48, 7683, 3383, 38, 804, 14, 7823, 1149, 63, 5443, 9, 267, 291, 14, 629, 8, 10031, 14, 1107, 804, 12, 13039, 804, 779, 4836, 792, 480, 86, 401, 22945, 804, 1012, 2459, 267, 291, 14, 629, 8, 10031, 14, 2579, 804, 12, 2018, 10006, 804, 14, 4657, 63, 7823, 1149, 63, 5443, 63, 48, 3649, 1179, 63, 3383, 38, 9, 398, 399, 1587, 275, 10634, 63, 10031, 8, 2734, 671, 26, 671, 12, 372, 804, 534, 86, 4270, 297, 586, 805, 804, 29, 48, 7683, 3383, 38, 804, 14, 7823, 1149, 63, 5443, 9, 267, 291, 14, 629, 8, 10031, 14, 1107, 804, 12, 13039, 804, 779, 4836, 792, 480, 86, 401, 22945, 804, 1012, 2459, 267, 291, 14, 629, 8, 10031, 14, 2579, 804, 12, 2018, 10006, 804, 14, 4657, 63, 7823, 1149, 63, 5443, 63, 48, 3649, 1179, 63, 3383, 38, 9, 339, 347, 511, 63, 15718, 63, 10031, 63, 11547, 8, 277, 304, 267, 768, 15718, 63, 10031, 8, 7281, 804, 1012, 267, 347, 3925, 8, 88, 304, 288, 372, 671, 267, 291, 14, 629, 8, 1421, 14, 1107, 804, 12, 22945, 804, 1012, 267, 291, 14, 629, 8, 1421, 14, 2579, 804, 12, 2018, 10006, 804, 14, 4657, 63, 17209, 689, 63, 48, 3649, 1179, 63, 3383, 38, 9, 398, 768, 15718, 63, 10031, 8, 1107, 804, 29, 7281, 804, 1012, 267, 347, 3925, 8, 88, 304, 288, 372, 671, 267, 291, 14, 629, 8, 1421, 14, 1107, 804, 12, 22945, 804, 1012, 267, 291, 14, 629, 8, 1421, 14, 2579, 804, 12, 2018, 10006, 804, 14, 4657, 63, 17209, 689, 63, 48, 3649, 1179, 63, 3383, 38, 9, 398, 4177, 275, 13039, 804, 779, 4836, 792, 480, 86, 401, 22945, 804, 30719, 398, 768, 15718, 63, 10031, 8, 3629, 12, 510, 7683, 3383, 38, 804, 14, 7823, 1149, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sofianehaddad/ot-svn
python/test/t_ProcessSample_std.py
2
2014
#! /usr/bin/env python from openturns import * TESTPREAMBLE() RandomGenerator.SetSeed(0) try: # size of timeGrid size = 6 dimension = 1 sample = NumericalSample(size, dimension) for i in range(size): for j in range(dimension): sample[i, j] = i + j + 1 # TimeGrid timeGrid = RegularGrid(0.0, 1.0 / (size - 1), size) # TimeSeries timeSeries = TimeSeries(timeGrid, sample) # We create an empty ProcessSample with default constructor psample0 = ProcessSample() psample0.setName("PSample0") print "Default constructor" print "psample0=", psample0 # We create an empty ProcessSample with timeGrid, size and dimension # arguments psample1 = ProcessSample(timeGrid, 4, dimension) psample1.setName("PSample1") print "Constructor based on size, dimension and timeGrid" print "psample1=", psample1 # change the first component using operator [] psample1[0] = timeSeries print "changing psample1[0] with []" print "psample1[0]=", (psample1[0]) # We create a ProcessSample with size and timeSeries arguments psample2 = ProcessSample(3, timeSeries) psample2.setName("PSample2") print "Constructor based on size / timeSeries" print "psample2=", psample2 # TimeSeriesCollection ## collection = TimeSeriesCollection() # collection.add(timeSeries) ## sample *= [0.1] ## newtimeSeries = TimeSeries(timeGrid, sample) # collection.add(newtimeSeries) # We create a ProcessSample with collection arguments arguments ## psample3 = ProcessSample(collection) # psample3.setName("PSample3") # print "Constructor based on collection " # print "psample3=", psample3 ## ts = psample3[1] # print "last element of psample3=", (ts) # print "psample3 mean=", psample3.computeMean() # print "psample3 temporal mean=", psample3.computeTemporalMean() except: import sys print "t_ProcessSample_std.py", sys.exc_type, sys.exc_value
mit
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 504, 1551, 353, 83, 492, 627, 199, 199, 2864, 4225, 1156, 34, 906, 342, 199, 3883, 7599, 14, 1084, 19554, 8, 16, 9, 199, 199, 893, 26, 339, 327, 1568, 402, 900, 7900, 272, 1568, 275, 1227, 272, 6240, 275, 413, 272, 2690, 275, 653, 27685, 8176, 8, 890, 12, 6240, 9, 272, 367, 284, 315, 1425, 8, 890, 304, 267, 367, 1335, 315, 1425, 8, 7430, 304, 288, 2690, 59, 73, 12, 1335, 61, 275, 284, 435, 1335, 435, 413, 339, 327, 4703, 7900, 272, 900, 7900, 275, 18528, 7900, 8, 16, 14, 16, 12, 413, 14, 16, 1182, 334, 890, 446, 413, 395, 1568, 9, 339, 327, 4703, 9641, 272, 900, 9641, 275, 4703, 9641, 8, 521, 7900, 12, 2690, 9, 339, 327, 2136, 1218, 376, 2701, 7132, 8176, 543, 849, 3787, 272, 299, 3271, 16, 275, 7132, 8176, 342, 272, 299, 3271, 16, 14, 18347, 480, 5067, 865, 16, 531, 272, 870, 298, 2698, 3787, 2, 272, 870, 298, 1190, 865, 16, 11107, 299, 3271, 16, 339, 327, 2136, 1218, 376, 2701, 7132, 8176, 543, 900, 7900, 12, 1568, 436, 6240, 272, 327, 2368, 272, 299, 3271, 17, 275, 7132, 8176, 8, 521, 7900, 12, 841, 12, 6240, 9, 272, 299, 3271, 17, 14, 18347, 480, 5067, 865, 17, 531, 272, 870, 298, 11447, 4079, 641, 1568, 12, 6240, 436, 900, 7900, 2, 272, 870, 298, 1190, 865, 17, 11107, 299, 3271, 17, 339, 327, 1570, 314, 1642, 3931, 1808, 4182, 942, 272, 299, 3271, 17, 59, 16, 61, 275, 900, 9641, 272, 870, 298, 29131, 299, 3271, 17, 59, 16, 61, 543, 942, 2, 272, 870, 298, 1190, 865, 17, 59, 16, 10404, 401, 334, 1190, 865, 17, 59, 16, 566, 339, 327, 2136, 1218, 282, 7132, 8176, 543, 1568, 436, 900, 9641, 2368, 272, 299, 3271, 18, 275, 7132, 8176, 8, 19, 12, 900, 9641, 9, 272, 299, 3271, 18, 14, 18347, 480, 5067, 865, 18, 531, 272, 870, 298, 11447, 4079, 641, 1568, 1182, 900, 9641, 2, 272, 870, 298, 1190, 865, 18, 11107, 299, 3271, 18, 339, 327, 4703, 9641, 7768, 272, 925, 3245, 275, 4703, 9641, 7768, 342, 272, 327, 3245, 14, 525, 8, 521, 9641, 9, 339, 925, 2690, 9000, 359, 16, 14, 17, 61, 272, 925, 892, 521, 9641, 275, 4703, 9641, 8, 521, 7900, 12, 2690, 9, 272, 327, 3245, 14, 525, 8, 1222, 521, 9641, 9, 339, 327, 2136, 1218, 282, 7132, 8176, 543, 3245, 2368, 2368, 272, 925, 299, 3271, 19, 275, 7132, 8176, 8, 3627, 9, 339, 327, 299, 3271, 19, 14, 18347, 480, 5067, 865, 19, 531, 272, 327, 870, 298, 11447, 4079, 641, 3245, 298, 272, 327, 870, 298, 1190, 865, 19, 11107, 299, 3271, 19, 339, 925, 6714, 275, 299, 3271, 19, 59, 17, 61, 272, 327, 870, 298, 2019, 1819, 402, 299, 3271, 19, 11107, 334, 1086, 9, 272, 327, 870, 298, 1190, 865, 19, 4615, 11107, 299, 3271, 19, 14, 3357, 14825, 342, 272, 327, 870, 298, 1190, 865, 19, 16457, 279, 4615, 11107, 299, 3271, 19, 14, 3357, 6530, 19849, 14825, 342, 421, 199, 2590, 26, 272, 492, 984, 272, 870, 298, 84, 63, 3498, 8176, 63, 1516, 14, 647, 401, 984, 14, 2804, 63, 466, 12, 984, 14, 2804, 63, 585, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 504, 1551, 353, 83, 492, 627, 199, 199, 2864, 4225, 1156, 34, 906, 342, 199, 3883, 7599, 14, 1084, 19554, 8, 16, 9, 199, 199, 893, 26, 339, 327, 1568, 402, 900, 7900, 272, 1568, 275, 1227, 272, 6240, 275, 413, 272, 2690, 275, 653, 27685, 8176, 8, 890, 12, 6240, 9, 272, 367, 284, 315, 1425, 8, 890, 304, 267, 367, 1335, 315, 1425, 8, 7430, 304, 288, 2690, 59, 73, 12, 1335, 61, 275, 284, 435, 1335, 435, 413, 339, 327, 4703, 7900, 272, 900, 7900, 275, 18528, 7900, 8, 16, 14, 16, 12, 413, 14, 16, 1182, 334, 890, 446, 413, 395, 1568, 9, 339, 327, 4703, 9641, 272, 900, 9641, 275, 4703, 9641, 8, 521, 7900, 12, 2690, 9, 339, 327, 2136, 1218, 376, 2701, 7132, 8176, 543, 849, 3787, 272, 299, 3271, 16, 275, 7132, 8176, 342, 272, 299, 3271, 16, 14, 18347, 480, 5067, 865, 16, 531, 272, 870, 298, 2698, 3787, 2, 272, 870, 298, 1190, 865, 16, 11107, 299, 3271, 16, 339, 327, 2136, 1218, 376, 2701, 7132, 8176, 543, 900, 7900, 12, 1568, 436, 6240, 272, 327, 2368, 272, 299, 3271, 17, 275, 7132, 8176, 8, 521, 7900, 12, 841, 12, 6240, 9, 272, 299, 3271, 17, 14, 18347, 480, 5067, 865, 17, 531, 272, 870, 298, 11447, 4079, 641, 1568, 12, 6240, 436, 900, 7900, 2, 272, 870, 298, 1190, 865, 17, 11107, 299, 3271, 17, 339, 327, 1570, 314, 1642, 3931, 1808, 4182, 942, 272, 299, 3271, 17, 59, 16, 61, 275, 900, 9641, 272, 870, 298, 29131, 299, 3271, 17, 59, 16, 61, 543, 942, 2, 272, 870, 298, 1190, 865, 17, 59, 16, 10404, 401, 334, 1190, 865, 17, 59, 16, 566, 339, 327, 2136, 1218, 282, 7132, 8176, 543, 1568, 436, 900, 9641, 2368, 272, 299, 3271, 18, 275, 7132, 8176, 8, 19, 12, 900, 9641, 9, 272, 299, 3271, 18, 14, 18347, 480, 5067, 865, 18, 531, 272, 870, 298, 11447, 4079, 641, 1568, 1182, 900, 9641, 2, 272, 870, 298, 1190, 865, 18, 11107, 299, 3271, 18, 339, 327, 4703, 9641, 7768, 272, 925, 3245, 275, 4703, 9641, 7768, 342, 272, 327, 3245, 14, 525, 8, 521, 9641, 9, 339, 925, 2690, 9000, 359, 16, 14, 17, 61, 272, 925, 892, 521, 9641, 275, 4703, 9641, 8, 521, 7900, 12, 2690, 9, 272, 327, 3245, 14, 525, 8, 1222, 521, 9641, 9, 339, 327, 2136, 1218, 282, 7132, 8176, 543, 3245, 2368, 2368, 272, 925, 299, 3271, 19, 275, 7132, 8176, 8, 3627, 9, 339, 327, 299, 3271, 19, 14, 18347, 480, 5067, 865, 19, 531, 272, 327, 870, 298, 11447, 4079, 641, 3245, 298, 272, 327, 870, 298, 1190, 865, 19, 11107, 299, 3271, 19, 339, 925, 6714, 275, 299, 3271, 19, 59, 17, 61, 272, 327, 870, 298, 2019, 1819, 402, 299, 3271, 19, 11107, 334, 1086, 9, 272, 327, 870, 298, 1190, 865, 19, 4615, 11107, 299, 3271, 19, 14, 3357, 14825, 342, 272, 327, 870, 298, 1190, 865, 19, 16457, 279, 4615, 11107, 299, 3271, 19, 14, 3357, 6530, 19849, 14825, 342, 421, 199, 2590, 26, 272, 492, 984, 272, 870, 298, 84, 63, 3498, 8176, 63, 1516, 14, 647, 401, 984, 14, 2804, 63, 466, 12, 984, 14, 2804, 63, 585, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
adwiputra/LUMENS-repo
processing/admintools/geoserver/util.py
6
1231
# -*- coding: utf-8 -*- """ *************************************************************************** util.py --------------------- Date : November 2012 Copyright : (C) 2012 by David Winslow Email : dwins at opengeo dot com *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * *************************************************************************** """ __author__ = 'David Winslow' __date__ = 'November 2012' __copyright__ = '(C) 2012, David Winslow' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' def shapefile_and_friends(path): return dict((ext, path + '.' + ext) for ext in ['shx', 'shp', 'dbf', 'prj' ])
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 17623, 272, 4884, 14, 647, 272, 10652, 9858, 272, 6148, 463, 520, 3091, 432, 976, 6029, 272, 1898, 3322, 520, 334, 35, 9, 6029, 701, 20232, 644, 3617, 674, 272, 11426, 4483, 520, 366, 2676, 83, 737, 1551, 6721, 6308, 2414, 199, 17623, 199, 10, 17997, 627, 199, 10, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 199, 10, 257, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 221, 627, 199, 10, 257, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 258, 627, 199, 10, 257, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 15530, 627, 199, 10, 17997, 627, 199, 17623, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 36, 17204, 644, 3617, 674, 7, 199, 363, 602, 363, 275, 283, 1944, 432, 976, 6029, 7, 199, 363, 7307, 363, 275, 8189, 35, 9, 6029, 12, 20232, 644, 3617, 674, 7, 199, 199, 3, 961, 911, 664, 8717, 543, 282, 6135, 12002, 17, 1380, 1265, 886, 282, 6135, 6359, 199, 199, 363, 5792, 363, 275, 4505, 3484, 2689, 40, 12913, 421, 199, 318, 2215, 493, 63, 460, 63, 18024, 8, 515, 304, 272, 372, 1211, 1332, 832, 12, 931, 435, 7815, 435, 1599, 9, 367, 1599, 315, 788, 609, 88, 297, 283, 17299, 297, 283, 26826, 297, 283, 2700, 74, 7, 355, 4794, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 624, 199, 17623, 272, 4884, 14, 647, 272, 10652, 9858, 272, 6148, 463, 520, 3091, 432, 976, 6029, 272, 1898, 3322, 520, 334, 35, 9, 6029, 701, 20232, 644, 3617, 674, 272, 11426, 4483, 520, 366, 2676, 83, 737, 1551, 6721, 6308, 2414, 199, 17623, 199, 10, 17997, 627, 199, 10, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 199, 10, 257, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 221, 627, 199, 10, 257, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 258, 627, 199, 10, 257, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 15530, 627, 199, 10, 17997, 627, 199, 17623, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 36, 17204, 644, 3617, 674, 7, 199, 363, 602, 363, 275, 283, 1944, 432, 976, 6029, 7, 199, 363, 7307, 363, 275, 8189, 35, 9, 6029, 12, 20232, 644, 3617, 674, 7, 199, 199, 3, 961, 911, 664, 8717, 543, 282, 6135, 12002, 17, 1380, 1265, 886, 282, 6135, 6359, 199, 199, 363, 5792, 363, 275, 4505, 3484, 2689, 40, 12913, 421, 199, 318, 2215, 493, 63, 460, 63, 18024, 8, 515, 304, 272, 372, 1211, 1332, 832, 12, 931, 435, 7815, 435, 1599, 9, 367, 1599, 315, 788, 609, 88, 297, 283, 17299, 297, 283, 26826, 297, 283, 2700, 74, 7, 355, 4794, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
dalegregory/odoo
addons/event/wizard/event_confirm.py
339
1387
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp import models, api class event_confirm(models.TransientModel): """Event Confirmation""" _name = "event.confirm" @api.multi def confirm(self): events = self.env['event.event'].browse(self._context.get('event_ids', [])) events.do_confirm() 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, 504, 5166, 492, 1709, 12, 2986, 421, 199, 533, 1566, 63, 9548, 8, 992, 14, 14612, 14928, 1685, 304, 272, 408, 2390, 1448, 11701, 624, 272, 485, 354, 275, 298, 1430, 14, 9548, 2, 339, 768, 1246, 14, 3029, 272, 347, 12679, 8, 277, 304, 267, 4474, 275, 291, 14, 1813, 459, 1430, 14, 1430, 2278, 4570, 8, 277, 423, 1100, 14, 362, 360, 1430, 63, 1580, 297, 15927, 267, 4474, 14, 1117, 63, 9548, 342, 267, 372, 791, 466, 356, 283, 723, 14, 3723, 14, 2442, 63, 3806, 63, 1600, 936, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 492, 1709, 12, 2986, 421, 199, 533, 1566, 63, 9548, 8, 992, 14, 14612, 14928, 1685, 304, 272, 408, 2390, 1448, 11701, 624, 272, 485, 354, 275, 298, 1430, 14, 9548, 2, 339, 768, 1246, 14, 3029, 272, 347, 12679, 8, 277, 304, 267, 4474, 275, 291, 14, 1813, 459, 1430, 14, 1430, 2278, 4570, 8, 277, 423, 1100, 14, 362, 360, 1430, 63, 1580, 297, 15927, 267, 4474, 14, 1117, 63, 9548, 342, 267, 372, 791, 466, 356, 283, 723, 14, 3723, 14, 2442, 63, 3806, 63, 1600, 936, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
raghavrv/scikit-learn
examples/linear_model/plot_logistic.py
73
1568
#!/usr/bin/python # -*- coding: utf-8 -*- """ ========================================================= Logistic function ========================================================= Shown in the plot is how the logistic regression would, in this synthetic dataset, classify values as either 0 or 1, i.e. class one or two, using the logistic curve. """ print(__doc__) # Code source: Gael Varoquaux # License: BSD 3 clause import numpy as np import matplotlib.pyplot as plt from sklearn import linear_model # this is our test set, it's just a straight line with some # Gaussian noise xmin, xmax = -5, 5 n_samples = 100 np.random.seed(0) X = np.random.normal(size=n_samples) y = (X > 0).astype(np.float) X[X > 0] *= 4 X += .3 * np.random.normal(size=n_samples) X = X[:, np.newaxis] # run the classifier clf = linear_model.LogisticRegression(C=1e5) clf.fit(X, y) # and plot the result plt.figure(1, figsize=(4, 3)) plt.clf() plt.scatter(X.ravel(), y, color='black', zorder=20) X_test = np.linspace(-5, 10, 300) def model(x): return 1 / (1 + np.exp(-x)) loss = model(X_test * clf.coef_ + clf.intercept_).ravel() plt.plot(X_test, loss, color='red', linewidth=3) ols = linear_model.LinearRegression() ols.fit(X, y) plt.plot(X_test, ols.coef_ * X_test + ols.intercept_, linewidth=1) plt.axhline(.5, color='.5') plt.ylabel('y') plt.xlabel('X') plt.xticks(range(-5, 10)) plt.yticks([0, 0.5, 1]) plt.ylim(-.25, 1.25) plt.xlim(-4, 10) plt.legend(('Logistic Regression Model', 'Linear Regression Model'), loc="lower right", fontsize='small') plt.show()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 421, 199, 624, 199, 12813, 15495, 199, 2445, 6937, 805, 199, 12813, 15495, 199, 199, 6824, 78, 315, 314, 5137, 365, 4212, 314, 30360, 10864, 3955, 12, 315, 642, 199, 9466, 21231, 4789, 12, 28837, 1338, 465, 1902, 378, 503, 413, 12, 199, 73, 14, 69, 14, 1021, 1373, 503, 2877, 12, 1808, 314, 30360, 15318, 14, 199, 199, 624, 199, 1361, 3460, 1301, 3368, 421, 199, 3, 5495, 1350, 26, 9647, 352, 21084, 79, 392, 10962, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 199, 504, 6357, 492, 7798, 63, 1238, 199, 199, 3, 642, 365, 4154, 511, 663, 12, 652, 1159, 2951, 282, 23669, 1004, 543, 2005, 199, 3, 17131, 11145, 199, 21601, 12, 19906, 275, 446, 21, 12, 959, 199, 78, 63, 3356, 275, 2948, 199, 1590, 14, 2355, 14, 5176, 8, 16, 9, 199, 56, 275, 980, 14, 2355, 14, 3302, 8, 890, 29, 78, 63, 3356, 9, 199, 89, 275, 334, 56, 690, 378, 680, 6041, 8, 1590, 14, 1609, 9, 199, 56, 59, 56, 690, 378, 61, 9000, 841, 199, 56, 847, 1275, 19, 627, 980, 14, 2355, 14, 3302, 8, 890, 29, 78, 63, 3356, 9, 199, 199, 56, 275, 1323, 3981, 980, 14, 14483, 61, 199, 3, 1255, 314, 12429, 199, 9694, 275, 7798, 63, 1238, 14, 2445, 23032, 8, 35, 29, 17, 69, 21, 9, 199, 9694, 14, 3269, 8, 56, 12, 612, 9, 199, 199, 3, 436, 5137, 314, 754, 199, 6003, 14, 8941, 8, 17, 12, 6085, 890, 2687, 20, 12, 650, 430, 199, 6003, 14, 9694, 342, 199, 6003, 14, 13512, 8, 56, 14, 11186, 1062, 612, 12, 3164, 534, 8399, 297, 1315, 1648, 29, 1165, 9, 199, 56, 63, 396, 275, 980, 14, 11649, 2801, 21, 12, 1616, 12, 9601, 9, 421, 199, 318, 1402, 8, 88, 304, 272, 372, 413, 1182, 334, 17, 435, 980, 14, 1474, 2801, 88, 430, 199, 4358, 275, 1402, 8, 56, 63, 396, 627, 6975, 14, 8009, 63, 435, 6975, 14, 10863, 63, 680, 11186, 342, 199, 6003, 14, 2798, 8, 56, 63, 396, 12, 5621, 12, 3164, 534, 581, 297, 21213, 29, 19, 9, 199, 199, 1446, 275, 7798, 63, 1238, 14, 10608, 13013, 342, 199, 1446, 14, 3269, 8, 56, 12, 612, 9, 199, 6003, 14, 2798, 8, 56, 63, 396, 12, 312, 478, 14, 8009, 63, 627, 1323, 63, 396, 435, 312, 478, 14, 10863, 3131, 21213, 29, 17, 9, 199, 6003, 14, 1219, 32625, 13417, 21, 12, 3164, 15637, 21, 358, 199, 199, 6003, 14, 13849, 360, 89, 358, 199, 6003, 14, 14168, 360, 56, 358, 199, 6003, 14, 26217, 8, 1842, 2801, 21, 12, 1616, 430, 199, 6003, 14, 30588, 779, 16, 12, 378, 14, 21, 12, 413, 566, 199, 6003, 14, 18123, 2801, 14, 821, 12, 413, 14, 821, 9, 199, 6003, 14, 18512, 2801, 20, 12, 1616, 9, 199, 6003, 14, 10231, 4725, 2445, 6937, 13262, 5822, 297, 283, 10608, 13262, 5822, 659, 1779, 4355, 628, 2325, 2451, 401, 19740, 534, 7241, 358, 199, 6003, 14, 2384, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 421, 199, 624, 199, 12813, 15495, 199, 2445, 6937, 805, 199, 12813, 15495, 199, 199, 6824, 78, 315, 314, 5137, 365, 4212, 314, 30360, 10864, 3955, 12, 315, 642, 199, 9466, 21231, 4789, 12, 28837, 1338, 465, 1902, 378, 503, 413, 12, 199, 73, 14, 69, 14, 1021, 1373, 503, 2877, 12, 1808, 314, 30360, 15318, 14, 199, 199, 624, 199, 1361, 3460, 1301, 3368, 421, 199, 3, 5495, 1350, 26, 9647, 352, 21084, 79, 392, 10962, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 199, 504, 6357, 492, 7798, 63, 1238, 199, 199, 3, 642, 365, 4154, 511, 663, 12, 652, 1159, 2951, 282, 23669, 1004, 543, 2005, 199, 3, 17131, 11145, 199, 21601, 12, 19906, 275, 446, 21, 12, 959, 199, 78, 63, 3356, 275, 2948, 199, 1590, 14, 2355, 14, 5176, 8, 16, 9, 199, 56, 275, 980, 14, 2355, 14, 3302, 8, 890, 29, 78, 63, 3356, 9, 199, 89, 275, 334, 56, 690, 378, 680, 6041, 8, 1590, 14, 1609, 9, 199, 56, 59, 56, 690, 378, 61, 9000, 841, 199, 56, 847, 1275, 19, 627, 980, 14, 2355, 14, 3302, 8, 890, 29, 78, 63, 3356, 9, 199, 199, 56, 275, 1323, 3981, 980, 14, 14483, 61, 199, 3, 1255, 314, 12429, 199, 9694, 275, 7798, 63, 1238, 14, 2445, 23032, 8, 35, 29, 17, 69, 21, 9, 199, 9694, 14, 3269, 8, 56, 12, 612, 9, 199, 199, 3, 436, 5137, 314, 754, 199, 6003, 14, 8941, 8, 17, 12, 6085, 890, 2687, 20, 12, 650, 430, 199, 6003, 14, 9694, 342, 199, 6003, 14, 13512, 8, 56, 14, 11186, 1062, 612, 12, 3164, 534, 8399, 297, 1315, 1648, 29, 1165, 9, 199, 56, 63, 396, 275, 980, 14, 11649, 2801, 21, 12, 1616, 12, 9601, 9, 421, 199, 318, 1402, 8, 88, 304, 272, 372, 413, 1182, 334, 17, 435, 980, 14, 1474, 2801, 88, 430, 199, 4358, 275, 1402, 8, 56, 63, 396, 627, 6975, 14, 8009, 63, 435, 6975, 14, 10863, 63, 680, 11186, 342, 199, 6003, 14, 2798, 8, 56, 63, 396, 12, 5621, 12, 3164, 534, 581, 297, 21213, 29, 19, 9, 199, 199, 1446, 275, 7798, 63, 1238, 14, 10608, 13013, 342, 199, 1446, 14, 3269, 8, 56, 12, 612, 9, 199, 6003, 14, 2798, 8, 56, 63, 396, 12, 312, 478, 14, 8009, 63, 627, 1323, 63, 396, 435, 312, 478, 14, 10863, 3131, 21213, 29, 17, 9, 199, 6003, 14, 1219, 32625, 13417, 21, 12, 3164, 15637, 21, 358, 199, 199, 6003, 14, 13849, 360, 89, 358, 199, 6003, 14, 14168, 360, 56, 358, 199, 6003, 14, 26217, 8, 1842, 2801, 21, 12, 1616, 430, 199, 6003, 14, 30588, 779, 16, 12, 378, 14, 21, 12, 413, 566, 199, 6003, 14, 18123, 2801, 14, 821, 12, 413, 14, 821, 9, 199, 6003, 14, 18512, 2801, 20, 12, 1616, 9, 199, 6003, 14, 10231, 4725, 2445, 6937, 13262, 5822, 297, 283, 10608, 13262, 5822, 659, 1779, 4355, 628, 2325, 2451, 401, 19740, 534, 7241, 358, 199, 6003, 14, 2384, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
a-doumoulakis/tensorflow
tensorflow/contrib/gan/python/losses/python/losses_wargs.py
73
1174
# Copyright 2017 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """TFGAN grouped API. Please see README.md for details and usage.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function # pylint: disable=wildcard-import from tensorflow.contrib.gan.python.losses.python import losses_impl from tensorflow.contrib.gan.python.losses.python.losses_impl import * # pylint: enable=wildcard-import from tensorflow.python.util.all_util import remove_undocumented remove_undocumented(__name__, losses_impl.__all__)
apache-2.0
[ 3, 1898, 9708, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 6145, 39, 879, 16251, 3261, 14, 7754, 1937, 27781, 14, 1064, 367, 2436, 436, 4503, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 3, 4287, 26, 3507, 29, 16692, 13, 646, 199, 504, 3228, 14, 2828, 14, 24975, 14, 1548, 14, 17865, 14, 1548, 492, 21289, 63, 5472, 199, 504, 3228, 14, 2828, 14, 24975, 14, 1548, 14, 17865, 14, 1548, 14, 17865, 63, 5472, 492, 627, 199, 3, 4287, 26, 4756, 29, 16692, 13, 646, 199, 199, 504, 3228, 14, 1548, 14, 1974, 14, 452, 63, 1974, 492, 2813, 63, 30107, 12546, 199, 199, 2168, 63, 30107, 12546, 3460, 354, 3108, 21289, 63, 5472, 855, 452, 3368, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 9708, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 6145, 39, 879, 16251, 3261, 14, 7754, 1937, 27781, 14, 1064, 367, 2436, 436, 4503, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 3, 4287, 26, 3507, 29, 16692, 13, 646, 199, 504, 3228, 14, 2828, 14, 24975, 14, 1548, 14, 17865, 14, 1548, 492, 21289, 63, 5472, 199, 504, 3228, 14, 2828, 14, 24975, 14, 1548, 14, 17865, 14, 1548, 14, 17865, 63, 5472, 492, 627, 199, 3, 4287, 26, 4756, 29, 16692, 13, 646, 199, 199, 504, 3228, 14, 1548, 14, 1974, 14, 452, 63, 1974, 492, 2813, 63, 30107, 12546, 199, 199, 2168, 63, 30107, 12546, 3460, 354, 3108, 21289, 63, 5472, 855, 452, 3368, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
mozilla/fjord
vendor/packages/requests-2.7.0/requests/packages/urllib3/__init__.py
482
2055
""" urllib3 - Thread-safe connection pooling and re-using. """ __author__ = 'Andrey Petrov (andrey.petrov@shazow.net)' __license__ = 'MIT' __version__ = '1.10.4' from .connectionpool import ( HTTPConnectionPool, HTTPSConnectionPool, connection_from_url ) from . import exceptions from .filepost import encode_multipart_formdata from .poolmanager import PoolManager, ProxyManager, proxy_from_url from .response import HTTPResponse from .util.request import make_headers from .util.url import get_host from .util.timeout import Timeout from .util.retry import Retry # Set default logging handler to avoid "No handler found" warnings. import logging try: # Python 2.7+ from logging import NullHandler except ImportError: class NullHandler(logging.Handler): def emit(self, record): pass logging.getLogger(__name__).addHandler(NullHandler()) def add_stderr_logger(level=logging.DEBUG): """ Helper for quickly adding a StreamHandler to the logger. Useful for debugging. Returns the handler after adding it. """ # This method needs to be in this __init__.py to get the __name__ correct # even if urllib3 is vendored within another package. logger = logging.getLogger(__name__) handler = logging.StreamHandler() handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s')) logger.addHandler(handler) logger.setLevel(level) logger.debug('Added a stderr logging handler to logger: %s' % __name__) return handler # ... Clean up. del NullHandler import warnings # SecurityWarning's always go off by default. warnings.simplefilter('always', exceptions.SecurityWarning, append=True) # InsecurePlatformWarning's don't vary between requests, so we keep it default. warnings.simplefilter('default', exceptions.InsecurePlatformWarning, append=True) def disable_warnings(category=exceptions.HTTPWarning): """ Helper for quickly disabling all urllib3 warnings. """ warnings.simplefilter('ignore', category)
bsd-3-clause
[ 624, 199, 4078, 19, 446, 11086, 13, 3489, 1950, 20699, 436, 295, 13, 4941, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 3325, 17885, 31449, 293, 86, 334, 460, 17885, 14, 321, 1374, 86, 32, 609, 4651, 583, 14, 846, 3171, 199, 363, 1682, 363, 275, 283, 13965, 7, 199, 363, 1023, 363, 275, 283, 17, 14, 709, 14, 20, 7, 421, 199, 504, 1275, 2105, 2293, 492, 334, 272, 3101, 23929, 12, 272, 14147, 23929, 12, 272, 1950, 63, 504, 63, 633, 199, 9, 199, 199, 504, 1275, 492, 4967, 199, 504, 1275, 493, 1932, 492, 3752, 63, 10123, 63, 30942, 199, 504, 1275, 2293, 2609, 492, 15553, 2988, 12, 12373, 2988, 12, 4566, 63, 504, 63, 633, 199, 504, 1275, 1310, 492, 29034, 199, 504, 1275, 1974, 14, 1069, 492, 1852, 63, 2139, 199, 504, 1275, 1974, 14, 633, 492, 664, 63, 1102, 199, 504, 1275, 1974, 14, 2593, 492, 12878, 199, 504, 1275, 1974, 14, 7154, 492, 20506, 421, 199, 3, 2494, 849, 2050, 3016, 370, 5126, 298, 1944, 3016, 1911, 2, 3598, 14, 199, 646, 2050, 199, 893, 26, 221, 327, 2018, 499, 14, 23, 11, 272, 687, 2050, 492, 12119, 2461, 199, 2590, 3545, 26, 272, 1021, 12119, 2461, 8, 4806, 14, 2461, 304, 267, 347, 8689, 8, 277, 12, 2777, 304, 288, 986, 199, 199, 4806, 14, 5572, 3460, 354, 28634, 18826, 8, 8849, 2461, 1012, 199, 199, 318, 1050, 63, 3083, 63, 2921, 8, 1896, 29, 4806, 14, 5287, 304, 272, 408, 272, 11642, 367, 23661, 7791, 282, 8271, 2461, 370, 314, 2512, 14, 18491, 367, 272, 10201, 14, 339, 1803, 314, 3016, 2410, 7791, 652, 14, 272, 408, 272, 327, 961, 1083, 4839, 370, 506, 315, 642, 636, 826, 4343, 647, 370, 664, 314, 636, 354, 363, 3211, 272, 327, 2755, 340, 4011, 19, 365, 373, 500, 2908, 4453, 4573, 2559, 14, 272, 2512, 275, 2050, 14, 5572, 3460, 354, 3368, 272, 3016, 275, 2050, 14, 22482, 342, 272, 3016, 14, 26076, 8, 4806, 14, 7772, 24713, 18331, 9, 83, 2818, 20056, 9, 83, 2818, 1188, 9, 83, 1333, 272, 2512, 14, 18826, 8, 2232, 9, 272, 2512, 14, 13548, 8, 1896, 9, 272, 2512, 14, 1757, 360, 20201, 282, 4635, 2050, 3016, 370, 2512, 26, 450, 83, 7, 450, 636, 354, 3368, 272, 372, 3016, 199, 199, 3, 2263, 12762, 1536, 14, 199, 2264, 12119, 2461, 421, 199, 646, 3598, 199, 3, 13863, 3849, 1159, 3544, 2621, 2331, 701, 849, 14, 199, 5451, 14, 18815, 360, 9223, 297, 4967, 14, 7676, 3849, 12, 5666, 29, 549, 9, 199, 3, 1010, 7817, 10397, 3849, 1159, 2793, 1133, 17083, 3382, 4145, 12, 880, 781, 4215, 652, 849, 14, 199, 5451, 14, 18815, 360, 885, 297, 4967, 14, 607, 7817, 10397, 3849, 12, 1993, 5666, 29, 549, 9, 199, 199, 318, 3507, 63, 5451, 8, 3710, 29, 3924, 14, 2856, 3849, 304, 272, 408, 272, 11642, 367, 23661, 30723, 1006, 4011, 19, 3598, 14, 272, 408, 272, 3598, 14, 18815, 360, 4247, 297, 4637, 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 ]
[ 199, 4078, 19, 446, 11086, 13, 3489, 1950, 20699, 436, 295, 13, 4941, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 3325, 17885, 31449, 293, 86, 334, 460, 17885, 14, 321, 1374, 86, 32, 609, 4651, 583, 14, 846, 3171, 199, 363, 1682, 363, 275, 283, 13965, 7, 199, 363, 1023, 363, 275, 283, 17, 14, 709, 14, 20, 7, 421, 199, 504, 1275, 2105, 2293, 492, 334, 272, 3101, 23929, 12, 272, 14147, 23929, 12, 272, 1950, 63, 504, 63, 633, 199, 9, 199, 199, 504, 1275, 492, 4967, 199, 504, 1275, 493, 1932, 492, 3752, 63, 10123, 63, 30942, 199, 504, 1275, 2293, 2609, 492, 15553, 2988, 12, 12373, 2988, 12, 4566, 63, 504, 63, 633, 199, 504, 1275, 1310, 492, 29034, 199, 504, 1275, 1974, 14, 1069, 492, 1852, 63, 2139, 199, 504, 1275, 1974, 14, 633, 492, 664, 63, 1102, 199, 504, 1275, 1974, 14, 2593, 492, 12878, 199, 504, 1275, 1974, 14, 7154, 492, 20506, 421, 199, 3, 2494, 849, 2050, 3016, 370, 5126, 298, 1944, 3016, 1911, 2, 3598, 14, 199, 646, 2050, 199, 893, 26, 221, 327, 2018, 499, 14, 23, 11, 272, 687, 2050, 492, 12119, 2461, 199, 2590, 3545, 26, 272, 1021, 12119, 2461, 8, 4806, 14, 2461, 304, 267, 347, 8689, 8, 277, 12, 2777, 304, 288, 986, 199, 199, 4806, 14, 5572, 3460, 354, 28634, 18826, 8, 8849, 2461, 1012, 199, 199, 318, 1050, 63, 3083, 63, 2921, 8, 1896, 29, 4806, 14, 5287, 304, 272, 408, 272, 11642, 367, 23661, 7791, 282, 8271, 2461, 370, 314, 2512, 14, 18491, 367, 272, 10201, 14, 339, 1803, 314, 3016, 2410, 7791, 652, 14, 272, 408, 272, 327, 961, 1083, 4839, 370, 506, 315, 642, 636, 826, 4343, 647, 370, 664, 314, 636, 354, 363, 3211, 272, 327, 2755, 340, 4011, 19, 365, 373, 500, 2908, 4453, 4573, 2559, 14, 272, 2512, 275, 2050, 14, 5572, 3460, 354, 3368, 272, 3016, 275, 2050, 14, 22482, 342, 272, 3016, 14, 26076, 8, 4806, 14, 7772, 24713, 18331, 9, 83, 2818, 20056, 9, 83, 2818, 1188, 9, 83, 1333, 272, 2512, 14, 18826, 8, 2232, 9, 272, 2512, 14, 13548, 8, 1896, 9, 272, 2512, 14, 1757, 360, 20201, 282, 4635, 2050, 3016, 370, 2512, 26, 450, 83, 7, 450, 636, 354, 3368, 272, 372, 3016, 199, 199, 3, 2263, 12762, 1536, 14, 199, 2264, 12119, 2461, 421, 199, 646, 3598, 199, 3, 13863, 3849, 1159, 3544, 2621, 2331, 701, 849, 14, 199, 5451, 14, 18815, 360, 9223, 297, 4967, 14, 7676, 3849, 12, 5666, 29, 549, 9, 199, 3, 1010, 7817, 10397, 3849, 1159, 2793, 1133, 17083, 3382, 4145, 12, 880, 781, 4215, 652, 849, 14, 199, 5451, 14, 18815, 360, 885, 297, 4967, 14, 607, 7817, 10397, 3849, 12, 1993, 5666, 29, 549, 9, 199, 199, 318, 3507, 63, 5451, 8, 3710, 29, 3924, 14, 2856, 3849, 304, 272, 408, 272, 11642, 367, 23661, 30723, 1006, 4011, 19, 3598, 14, 272, 408, 272, 3598, 14, 18815, 360, 4247, 297, 4637, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
oe-alliance/openmultibootmanager
src/ubi_reader/ubifs/misc.py
2
2179
#!/usr/bin/env python ############################################################# # ubi_reader/ubifs # (c) 2013 Jason Pruitt (jrspruitt@gmail.com) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. ############################################################# import lzo import struct import zlib from ubifs.defines import * # For happy printing ino_types = ['file', 'dir', 'lnk', 'blk', 'chr', 'fifo', 'sock'] node_types = ['ino', 'data', 'dent', 'xent', 'trun', 'pad', 'sb', 'mst', 'ref', 'idx', 'cs', 'orph'] key_types = ['ino', 'data', 'dent', 'xent'] def parse_key(key): """Parse node key Arguments: Str:key -- Hex string literal of node key. Returns: Int:key_type -- Type of key, data, ino, dent, etc. Int:ino_num -- Inode number. Int:khash -- Key hash. """ hkey, lkey = struct.unpack('<II', key[0:UBIFS_SK_LEN]) ino_num = hkey & UBIFS_S_KEY_HASH_MASK key_type = lkey >> UBIFS_S_KEY_BLOCK_BITS khash = lkey #if key_type < UBIFS_KEY_TYPES_CNT: return {'type': key_type, 'ino_num': ino_num, 'khash': khash} def decompress(ctype, unc_len, data): """Decompress data. Arguments: Int:ctype -- Compression type LZO, ZLIB (*currently unused*). Int:unc_len -- Uncompressed data lenth. Str:data -- Data to be uncompessed. Returns: Uncompressed Data. """ if ctype == UBIFS_COMPR_LZO: return lzo.decompress(''.join(('\xf0', struct.pack('>I', unc_len), data))) elif ctype == UBIFS_COMPR_ZLIB: return zlib.decompress(data, -11) else: return data
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 26207, 8776, 199, 3, 399, 4492, 63, 5503, 15, 456, 20985, 199, 3, 334, 67, 9, 6171, 1603, 2660, 25716, 4993, 84, 334, 74, 15642, 82, 4993, 84, 32, 6799, 14, 957, 9, 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, 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, 26207, 8776, 199, 646, 634, 18070, 199, 646, 2702, 199, 646, 12472, 199, 504, 23730, 20985, 14, 14334, 492, 627, 199, 199, 3, 2104, 394, 18869, 16116, 199, 10175, 63, 1313, 275, 788, 493, 297, 283, 694, 297, 283, 6066, 75, 297, 283, 14023, 297, 283, 10194, 297, 283, 22976, 297, 283, 5096, 418, 199, 932, 63, 1313, 275, 788, 10175, 297, 283, 576, 297, 283, 1326, 297, 283, 88, 484, 297, 283, 454, 324, 297, 283, 6226, 297, 283, 9264, 297, 283, 77, 270, 297, 283, 1121, 297, 283, 2996, 297, 283, 1259, 297, 283, 6847, 418, 199, 498, 63, 1313, 275, 788, 10175, 297, 283, 576, 297, 283, 1326, 297, 283, 88, 484, 418, 421, 199, 318, 2198, 63, 498, 8, 498, 304, 272, 408, 4003, 1031, 790, 339, 7628, 26, 272, 8303, 26, 498, 259, 1553, 28333, 1059, 8785, 402, 1031, 790, 14, 339, 1803, 26, 272, 9805, 26, 498, 63, 466, 257, 1553, 2434, 402, 790, 12, 666, 12, 315, 79, 12, 477, 343, 12, 5423, 14, 272, 9805, 26, 10175, 63, 1507, 259, 1553, 473, 932, 1329, 14, 272, 9805, 26, 75, 2227, 420, 1553, 2606, 2631, 14, 272, 408, 272, 394, 498, 12, 634, 498, 275, 2702, 14, 5301, 4827, 8921, 297, 790, 59, 16, 26, 2533, 4656, 51, 63, 8656, 63, 5304, 566, 272, 315, 79, 63, 1507, 275, 394, 498, 1253, 738, 34, 4656, 51, 63, 51, 63, 3078, 63, 14395, 63, 12880, 272, 790, 63, 466, 275, 634, 498, 4331, 738, 34, 4656, 51, 63, 51, 63, 3078, 63, 8475, 63, 14662, 272, 1022, 2227, 275, 634, 498, 339, 327, 692, 790, 63, 466, 665, 738, 34, 4656, 51, 63, 3078, 63, 7893, 63, 35, 12460, 26, 272, 372, 791, 466, 356, 790, 63, 466, 12, 283, 10175, 63, 1507, 356, 315, 79, 63, 1507, 12, 283, 75, 2227, 356, 1022, 2227, 93, 421, 199, 318, 24733, 8, 3667, 12, 625, 67, 63, 552, 12, 666, 304, 272, 408, 872, 6447, 666, 14, 339, 7628, 26, 272, 9805, 26, 3667, 259, 1553, 3599, 1941, 730, 491, 58, 47, 12, 3107, 5617, 19943, 19767, 9563, 10, 680, 272, 9805, 26, 1097, 63, 552, 221, 1553, 1910, 10895, 666, 822, 273, 14, 272, 8303, 26, 576, 258, 1553, 3918, 370, 506, 625, 863, 397, 939, 14, 339, 1803, 26, 272, 1910, 10895, 3918, 14, 272, 408, 272, 340, 16360, 508, 738, 34, 4656, 51, 63, 22827, 63, 44, 58, 47, 26, 267, 372, 634, 18070, 14, 14954, 17840, 904, 8, 2258, 1949, 16, 297, 2702, 14, 1389, 16099, 41, 297, 625, 67, 63, 552, 395, 666, 1724, 272, 916, 16360, 508, 738, 34, 4656, 51, 63, 22827, 63, 58, 5617, 26, 267, 372, 12472, 14, 14954, 8, 576, 12, 446, 845, 9, 272, 587, 26, 267, 372, 666, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 26207, 8776, 199, 3, 399, 4492, 63, 5503, 15, 456, 20985, 199, 3, 334, 67, 9, 6171, 1603, 2660, 25716, 4993, 84, 334, 74, 15642, 82, 4993, 84, 32, 6799, 14, 957, 9, 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, 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, 26207, 8776, 199, 646, 634, 18070, 199, 646, 2702, 199, 646, 12472, 199, 504, 23730, 20985, 14, 14334, 492, 627, 199, 199, 3, 2104, 394, 18869, 16116, 199, 10175, 63, 1313, 275, 788, 493, 297, 283, 694, 297, 283, 6066, 75, 297, 283, 14023, 297, 283, 10194, 297, 283, 22976, 297, 283, 5096, 418, 199, 932, 63, 1313, 275, 788, 10175, 297, 283, 576, 297, 283, 1326, 297, 283, 88, 484, 297, 283, 454, 324, 297, 283, 6226, 297, 283, 9264, 297, 283, 77, 270, 297, 283, 1121, 297, 283, 2996, 297, 283, 1259, 297, 283, 6847, 418, 199, 498, 63, 1313, 275, 788, 10175, 297, 283, 576, 297, 283, 1326, 297, 283, 88, 484, 418, 421, 199, 318, 2198, 63, 498, 8, 498, 304, 272, 408, 4003, 1031, 790, 339, 7628, 26, 272, 8303, 26, 498, 259, 1553, 28333, 1059, 8785, 402, 1031, 790, 14, 339, 1803, 26, 272, 9805, 26, 498, 63, 466, 257, 1553, 2434, 402, 790, 12, 666, 12, 315, 79, 12, 477, 343, 12, 5423, 14, 272, 9805, 26, 10175, 63, 1507, 259, 1553, 473, 932, 1329, 14, 272, 9805, 26, 75, 2227, 420, 1553, 2606, 2631, 14, 272, 408, 272, 394, 498, 12, 634, 498, 275, 2702, 14, 5301, 4827, 8921, 297, 790, 59, 16, 26, 2533, 4656, 51, 63, 8656, 63, 5304, 566, 272, 315, 79, 63, 1507, 275, 394, 498, 1253, 738, 34, 4656, 51, 63, 51, 63, 3078, 63, 14395, 63, 12880, 272, 790, 63, 466, 275, 634, 498, 4331, 738, 34, 4656, 51, 63, 51, 63, 3078, 63, 8475, 63, 14662, 272, 1022, 2227, 275, 634, 498, 339, 327, 692, 790, 63, 466, 665, 738, 34, 4656, 51, 63, 3078, 63, 7893, 63, 35, 12460, 26, 272, 372, 791, 466, 356, 790, 63, 466, 12, 283, 10175, 63, 1507, 356, 315, 79, 63, 1507, 12, 283, 75, 2227, 356, 1022, 2227, 93, 421, 199, 318, 24733, 8, 3667, 12, 625, 67, 63, 552, 12, 666, 304, 272, 408, 872, 6447, 666, 14, 339, 7628, 26, 272, 9805, 26, 3667, 259, 1553, 3599, 1941, 730, 491, 58, 47, 12, 3107, 5617, 19943, 19767, 9563, 10, 680, 272, 9805, 26, 1097, 63, 552, 221, 1553, 1910, 10895, 666, 822, 273, 14, 272, 8303, 26, 576, 258, 1553, 3918, 370, 506, 625, 863, 397, 939, 14, 339, 1803, 26, 272, 1910, 10895, 3918, 14, 272, 408, 272, 340, 16360, 508, 738, 34, 4656, 51, 63, 22827, 63, 44, 58, 47, 26, 267, 372, 634, 18070, 14, 14954, 17840, 904, 8, 2258, 1949, 16, 297, 2702, 14, 1389, 16099, 41, 297, 625, 67, 63, 552, 395, 666, 1724, 272, 916, 16360, 508, 738, 34, 4656, 51, 63, 22827, 63, 58, 5617, 26, 267, 372, 12472, 14, 14954, 8, 576, 12, 446, 845, 9, 272, 587, 26, 267, 372, 666, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
tSed/buildroot
support/testing/infra/__init__.py
3
2877
import contextlib import os import re import sys import tempfile import subprocess from urllib2 import urlopen, HTTPError, URLError ARTIFACTS_URL = "http://autobuild.buildroot.net/artefacts/" def open_log_file(builddir, stage, logtofile=True): """ Open a file for logging and return its handler. If logtofile is True, returns sys.stdout. Otherwise opens a file with a suitable name in the build directory. """ if logtofile: fhandle = open("{}-{}.log".format(builddir, stage), 'a+') else: fhandle = sys.stdout return fhandle def filepath(relpath): return os.path.join(os.getcwd(), "support/testing", relpath) def download(dldir, filename): finalpath = os.path.join(dldir, filename) if os.path.exists(finalpath): return finalpath if not os.path.exists(dldir): os.makedirs(dldir) tmpfile = tempfile.mktemp(dir=dldir) print "Downloading to {}".format(tmpfile) try: url_fh = urlopen(os.path.join(ARTIFACTS_URL, filename)) with open(tmpfile, "w+") as tmpfile_fh: tmpfile_fh.write(url_fh.read()) except (HTTPError, URLError), err: os.unlink(tmpfile) raise err print "Renaming from %s to %s" % (tmpfile, finalpath) os.rename(tmpfile, finalpath) return finalpath def get_elf_arch_tag(builddir, prefix, fpath, tag): """ Runs the cross readelf on 'fpath', then extracts the value of tag 'tag'. Example: >>> get_elf_arch_tag('output', 'arm-none-linux-gnueabi-', 'bin/busybox', 'Tag_CPU_arch') v5TEJ >>> """ cmd = ["host/bin/{}-readelf".format(prefix), "-A", os.path.join("target", fpath)] out = subprocess.check_output(cmd, cwd=builddir, env={"LANG": "C"}) regexp = re.compile("^ {}: (.*)$".format(tag)) for line in out.splitlines(): m = regexp.match(line) if not m: continue return m.group(1) return None def get_file_arch(builddir, prefix, fpath): return get_elf_arch_tag(builddir, prefix, fpath, "Tag_CPU_arch") def get_elf_prog_interpreter(builddir, prefix, fpath): """ Runs the cross readelf on 'fpath' to extract the program interpreter name and returns it. Example: >>> get_elf_prog_interpreter('br-tests/TestExternalToolchainLinaroArm', 'arm-linux-gnueabihf', 'bin/busybox') /lib/ld-linux-armhf.so.3 >>> """ cmd = ["host/bin/{}-readelf".format(prefix), "-l", os.path.join("target", fpath)] out = subprocess.check_output(cmd, cwd=builddir, env={"LANG": "C"}) regexp = re.compile("^ *\[Requesting program interpreter: (.*)\]$") for line in out.splitlines(): m = regexp.match(line) if not m: continue return m.group(1) return None
gpl-2.0
[ 646, 15502, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 5549, 199, 646, 3873, 199, 504, 4011, 18, 492, 18279, 12, 15050, 12, 30794, 199, 199, 2294, 41, 18164, 51, 63, 2632, 275, 298, 1014, 921, 2495, 1506, 14, 1506, 1231, 14, 846, 15, 285, 266, 5047, 6687, 199, 199, 318, 1551, 63, 793, 63, 493, 8, 21728, 12, 9546, 12, 943, 475, 493, 29, 549, 304, 272, 408, 272, 3232, 282, 570, 367, 2050, 436, 372, 2399, 3016, 14, 272, 982, 943, 475, 493, 365, 715, 12, 2529, 984, 14, 2703, 14, 6630, 30848, 282, 570, 272, 543, 282, 11233, 536, 315, 314, 1900, 2082, 14, 272, 408, 272, 340, 943, 475, 493, 26, 267, 289, 2479, 275, 1551, 20794, 13, 31270, 793, 1674, 908, 8, 21728, 12, 9546, 395, 283, 65, 13854, 272, 587, 26, 267, 289, 2479, 275, 984, 14, 2703, 272, 372, 289, 2479, 199, 199, 318, 9911, 8, 12405, 304, 272, 372, 747, 14, 515, 14, 904, 8, 736, 14, 9458, 1062, 298, 4058, 15, 4776, 401, 20700, 9, 199, 199, 318, 5235, 8, 5030, 694, 12, 1788, 304, 272, 4242, 515, 275, 747, 14, 515, 14, 904, 8, 5030, 694, 12, 1788, 9, 272, 340, 747, 14, 515, 14, 2444, 8, 5094, 515, 304, 267, 372, 4242, 515, 339, 340, 440, 747, 14, 515, 14, 2444, 8, 5030, 694, 304, 267, 747, 14, 8347, 8, 5030, 694, 9, 339, 25137, 275, 5549, 14, 22136, 8, 694, 29, 5030, 694, 9, 272, 870, 298, 18085, 370, 8352, 908, 8, 21930, 9, 339, 862, 26, 267, 1166, 63, 12853, 275, 18279, 8, 736, 14, 515, 14, 904, 8, 2294, 41, 18164, 51, 63, 2632, 12, 1788, 430, 267, 543, 1551, 8, 21930, 12, 298, 87, 21425, 465, 25137, 63, 12853, 26, 288, 25137, 63, 12853, 14, 952, 8, 633, 63, 12853, 14, 739, 1012, 272, 871, 334, 12815, 12, 30794, 395, 2329, 26, 267, 747, 14, 7162, 8, 21930, 9, 267, 746, 2329, 339, 870, 298, 5349, 9568, 687, 450, 83, 370, 450, 83, 2, 450, 334, 21930, 12, 4242, 515, 9, 272, 747, 14, 8165, 8, 21930, 12, 4242, 515, 9, 272, 372, 4242, 515, 199, 199, 318, 664, 63, 25371, 63, 1047, 63, 1450, 8, 21728, 12, 2403, 12, 30540, 12, 1947, 304, 272, 408, 272, 23773, 314, 8059, 295, 9587, 276, 641, 283, 23248, 297, 2066, 5536, 83, 314, 574, 402, 1947, 283, 1450, 1370, 272, 5679, 26, 272, 1306, 664, 63, 25371, 63, 1047, 63, 1450, 360, 1199, 297, 283, 5362, 13, 3592, 13, 5135, 13, 784, 310, 14677, 14382, 586, 283, 1393, 15, 25265, 1977, 297, 283, 1931, 63, 11011, 63, 1047, 358, 272, 373, 21, 3727, 42, 272, 1306, 272, 408, 272, 2088, 275, 2097, 1102, 15, 1393, 14698, 13, 8273, 271, 276, 1674, 908, 8, 1861, 395, 1779, 3905, 33, 401, 747, 14, 515, 14, 904, 480, 1375, 401, 30540, 1874, 272, 734, 275, 3873, 14, 1074, 63, 1199, 8, 1760, 12, 8288, 29, 21728, 12, 2589, 8871, 7442, 582, 298, 35, 5984, 272, 13156, 275, 295, 14, 2014, 18523, 221, 24702, 334, 12432, 4, 1674, 908, 8, 1450, 430, 272, 367, 1004, 315, 734, 14, 7644, 837, 267, 333, 275, 13156, 14, 1431, 8, 604, 9, 267, 340, 440, 333, 26, 288, 1980, 267, 372, 333, 14, 923, 8, 17, 9, 272, 372, 488, 199, 199, 318, 664, 63, 493, 63, 1047, 8, 21728, 12, 2403, 12, 30540, 304, 272, 372, 664, 63, 25371, 63, 1047, 63, 1450, 8, 21728, 12, 2403, 12, 30540, 12, 298, 1931, 63, 11011, 63, 1047, 531, 199, 199, 318, 664, 63, 25371, 63, 6595, 63, 20244, 8, 21728, 12, 2403, 12, 30540, 304, 272, 408, 272, 23773, 314, 8059, 295, 9587, 276, 641, 283, 23248, 7, 370, 5536, 314, 2240, 12693, 272, 536, 436, 2529, 652, 14, 272, 5679, 26, 272, 1306, 664, 63, 25371, 63, 6595, 63, 20244, 360, 3289, 13, 2219, 15, 774, 11389, 5157, 4429, 27889, 285, 79, 1596, 77, 297, 639, 283, 5362, 13, 5135, 13, 784, 310, 14677, 9188, 297, 639, 283, 1393, 15, 25265, 1977, 358, 272, 1182, 773, 15, 1447, 13, 5135, 13, 5362, 9188, 14, 1152, 14, 19, 272, 1306, 272, 408, 272, 2088, 275, 2097, 1102, 15, 1393, 14698, 13, 8273, 271, 276, 1674, 908, 8, 1861, 395, 1779, 3905, 76, 401, 747, 14, 515, 14, 904, 480, 1375, 401, 30540, 1874, 272, 734, 275, 3873, 14, 1074, 63, 1199, 8, 1760, 12, 8288, 29, 21728, 12, 2589, 8871, 7442, 582, 298, 35, 5984, 272, 13156, 275, 295, 14, 2014, 18523, 627, 25621, 2017, 316, 2240, 12693, 26, 334, 2795, 2862, 61, 22550, 272, 367, 1004, 315, 734, 14, 7644, 837, 267, 333, 275, 13156, 14, 1431, 8, 604, 9, 267, 340, 440, 333, 26, 288, 1980, 267, 372, 333, 14, 923, 8, 17, 9, 272, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 15502, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 5549, 199, 646, 3873, 199, 504, 4011, 18, 492, 18279, 12, 15050, 12, 30794, 199, 199, 2294, 41, 18164, 51, 63, 2632, 275, 298, 1014, 921, 2495, 1506, 14, 1506, 1231, 14, 846, 15, 285, 266, 5047, 6687, 199, 199, 318, 1551, 63, 793, 63, 493, 8, 21728, 12, 9546, 12, 943, 475, 493, 29, 549, 304, 272, 408, 272, 3232, 282, 570, 367, 2050, 436, 372, 2399, 3016, 14, 272, 982, 943, 475, 493, 365, 715, 12, 2529, 984, 14, 2703, 14, 6630, 30848, 282, 570, 272, 543, 282, 11233, 536, 315, 314, 1900, 2082, 14, 272, 408, 272, 340, 943, 475, 493, 26, 267, 289, 2479, 275, 1551, 20794, 13, 31270, 793, 1674, 908, 8, 21728, 12, 9546, 395, 283, 65, 13854, 272, 587, 26, 267, 289, 2479, 275, 984, 14, 2703, 272, 372, 289, 2479, 199, 199, 318, 9911, 8, 12405, 304, 272, 372, 747, 14, 515, 14, 904, 8, 736, 14, 9458, 1062, 298, 4058, 15, 4776, 401, 20700, 9, 199, 199, 318, 5235, 8, 5030, 694, 12, 1788, 304, 272, 4242, 515, 275, 747, 14, 515, 14, 904, 8, 5030, 694, 12, 1788, 9, 272, 340, 747, 14, 515, 14, 2444, 8, 5094, 515, 304, 267, 372, 4242, 515, 339, 340, 440, 747, 14, 515, 14, 2444, 8, 5030, 694, 304, 267, 747, 14, 8347, 8, 5030, 694, 9, 339, 25137, 275, 5549, 14, 22136, 8, 694, 29, 5030, 694, 9, 272, 870, 298, 18085, 370, 8352, 908, 8, 21930, 9, 339, 862, 26, 267, 1166, 63, 12853, 275, 18279, 8, 736, 14, 515, 14, 904, 8, 2294, 41, 18164, 51, 63, 2632, 12, 1788, 430, 267, 543, 1551, 8, 21930, 12, 298, 87, 21425, 465, 25137, 63, 12853, 26, 288, 25137, 63, 12853, 14, 952, 8, 633, 63, 12853, 14, 739, 1012, 272, 871, 334, 12815, 12, 30794, 395, 2329, 26, 267, 747, 14, 7162, 8, 21930, 9, 267, 746, 2329, 339, 870, 298, 5349, 9568, 687, 450, 83, 370, 450, 83, 2, 450, 334, 21930, 12, 4242, 515, 9, 272, 747, 14, 8165, 8, 21930, 12, 4242, 515, 9, 272, 372, 4242, 515, 199, 199, 318, 664, 63, 25371, 63, 1047, 63, 1450, 8, 21728, 12, 2403, 12, 30540, 12, 1947, 304, 272, 408, 272, 23773, 314, 8059, 295, 9587, 276, 641, 283, 23248, 297, 2066, 5536, 83, 314, 574, 402, 1947, 283, 1450, 1370, 272, 5679, 26, 272, 1306, 664, 63, 25371, 63, 1047, 63, 1450, 360, 1199, 297, 283, 5362, 13, 3592, 13, 5135, 13, 784, 310, 14677, 14382, 586, 283, 1393, 15, 25265, 1977, 297, 283, 1931, 63, 11011, 63, 1047, 358, 272, 373, 21, 3727, 42, 272, 1306, 272, 408, 272, 2088, 275, 2097, 1102, 15, 1393, 14698, 13, 8273, 271, 276, 1674, 908, 8, 1861, 395, 1779, 3905, 33, 401, 747, 14, 515, 14, 904, 480, 1375, 401, 30540, 1874, 272, 734, 275, 3873, 14, 1074, 63, 1199, 8, 1760, 12, 8288, 29, 21728, 12, 2589, 8871, 7442, 582, 298, 35, 5984, 272, 13156, 275, 295, 14, 2014, 18523, 221, 24702, 334, 12432, 4, 1674, 908, 8, 1450, 430, 272, 367, 1004, 315, 734, 14, 7644, 837, 267, 333, 275, 13156, 14, 1431, 8, 604, 9, 267, 340, 440, 333, 26, 288, 1980, 267, 372, 333, 14, 923, 8, 17, 9, 272, 372, 488, 199, 199, 318, 664, 63, 493, 63, 1047, 8, 21728, 12, 2403, 12, 30540, 304, 272, 372, 664, 63, 25371, 63, 1047, 63, 1450, 8, 21728, 12, 2403, 12, 30540, 12, 298, 1931, 63, 11011, 63, 1047, 531, 199, 199, 318, 664, 63, 25371, 63, 6595, 63, 20244, 8, 21728, 12, 2403, 12, 30540, 304, 272, 408, 272, 23773, 314, 8059, 295, 9587, 276, 641, 283, 23248, 7, 370, 5536, 314, 2240, 12693, 272, 536, 436, 2529, 652, 14, 272, 5679, 26, 272, 1306, 664, 63, 25371, 63, 6595, 63, 20244, 360, 3289, 13, 2219, 15, 774, 11389, 5157, 4429, 27889, 285, 79, 1596, 77, 297, 639, 283, 5362, 13, 5135, 13, 784, 310, 14677, 9188, 297, 639, 283, 1393, 15, 25265, 1977, 358, 272, 1182, 773, 15, 1447, 13, 5135, 13, 5362, 9188, 14, 1152, 14, 19, 272, 1306, 272, 408, 272, 2088, 275, 2097, 1102, 15, 1393, 14698, 13, 8273, 271, 276, 1674, 908, 8, 1861, 395, 1779, 3905, 76, 401, 747, 14, 515, 14, 904, 480, 1375, 401, 30540, 1874, 272, 734, 275, 3873, 14, 1074, 63, 1199, 8, 1760, 12, 8288, 29, 21728, 12, 2589, 8871, 7442, 582, 298, 35, 5984, 272, 13156, 275, 295, 14, 2014, 18523, 627, 25621, 2017, 316, 2240, 12693, 26, 334, 2795, 2862, 61, 22550, 272, 367, 1004, 315, 734, 14, 7644, 837, 267, 333, 275, 13156, 14, 1431, 8, 604, 9, 267, 340, 440, 333, 26, 288, 1980, 267, 372, 333, 14, 923, 8, 17, 9, 272, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
zyq001/ryu
ryu/services/protocols/vrrp/utils.py
37
2419
# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation. # Copyright (C) 2013 Isaku Yamahata <yamahata at private email ne jp> # # 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 ryu.lib.packet import ethernet from ryu.lib.packet import vlan from ryu.ofproto import ether from ryu.topology import api as topo_api def may_add_vlan(packet, vlan_id): """ :type packet: ryu.lib.packet.packet.Packet :param packet: :type vlan_id: int (0 <= vlan_id <= 4095) or None (= No VLAN) :param vlan_id: """ if vlan_id is None: return e = packet.protocols[0] assert isinstance(e, ethernet.ethernet) v = vlan.vlan(0, 0, vlan_id, e.ethertype) e.ethertype = ether.ETH_TYPE_8021Q packet.add_protocol(v) def get_dp(app, dpid): """ :type dpid: datapath id :param dpid: :rtype: ryu.controller.controller.Datapatyh :returns: datapath corresponding to dpid """ switches = topo_api.get_switch(app, dpid) if not switches: return None assert len(switches) == 1 return switches[0].dp def dp_packet_out(dp, port_no, data): # OF 1.2 ofproto = dp.ofproto ofproto_parser = dp.ofproto_parser actions = [ofproto_parser.OFPActionOutput(port_no, ofproto.OFPCML_NO_BUFFER)] packet_out = ofproto_parser.OFPPacketOut( dp, 0xffffffff, ofproto.OFPP_CONTROLLER, actions, data) dp.send_msg(packet_out) def dp_flow_mod(dp, table, command, priority, match, instructions, out_port=None): # OF 1.2 ofproto = dp.ofproto ofproto_parser = dp.ofproto_parser if out_port is None: out_port = ofproto.OFPP_ANY flow_mod = ofproto_parser.OFPFlowMod( dp, 0, 0, table, command, 0, 0, priority, 0xffffffff, out_port, ofproto.OFPG_ANY, ofproto.OFPFF_CHECK_OVERLAP, match, instructions) dp.send_msg(flow_mod)
apache-2.0
[ 3, 1898, 334, 35, 9, 6171, 653, 711, 678, 23884, 2180, 436, 23884, 9339, 11098, 14, 199, 3, 1898, 334, 35, 9, 6171, 6596, 1151, 85, 1488, 14541, 72, 419, 665, 11552, 391, 72, 419, 737, 5726, 3031, 1279, 28921, 30, 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, 504, 25494, 14, 773, 14, 6253, 492, 21944, 199, 504, 25494, 14, 773, 14, 6253, 492, 10119, 199, 504, 25494, 14, 15129, 492, 30201, 199, 504, 25494, 14, 10775, 492, 2986, 465, 11111, 63, 1246, 421, 199, 318, 1443, 63, 525, 63, 7175, 8, 6253, 12, 10119, 63, 344, 304, 272, 408, 272, 520, 466, 3644, 26, 25494, 14, 773, 14, 6253, 14, 6253, 14, 2726, 272, 520, 635, 3644, 26, 272, 520, 466, 10119, 63, 344, 26, 1109, 334, 16, 2695, 10119, 63, 344, 2695, 841, 19113, 9, 503, 488, 24649, 3091, 17591, 9, 272, 520, 635, 10119, 63, 344, 26, 272, 408, 272, 340, 10119, 63, 344, 365, 488, 26, 267, 372, 339, 325, 275, 3644, 14, 16541, 59, 16, 61, 272, 702, 1228, 8, 69, 12, 21944, 14, 20354, 9, 272, 373, 275, 10119, 14, 7175, 8, 16, 12, 378, 12, 10119, 63, 344, 12, 325, 14, 27732, 466, 9, 272, 325, 14, 27732, 466, 275, 30201, 14, 21265, 63, 2711, 63, 11366, 17, 49, 272, 3644, 14, 525, 63, 3922, 8, 86, 9, 421, 199, 318, 664, 63, 5780, 8, 571, 12, 366, 3150, 304, 272, 408, 272, 520, 466, 366, 3150, 26, 24991, 1305, 272, 520, 635, 366, 3150, 26, 272, 520, 4500, 26, 25494, 14, 5538, 14, 5538, 14, 1451, 10853, 89, 72, 272, 520, 5808, 26, 24991, 5226, 370, 366, 3150, 272, 408, 272, 24563, 275, 11111, 63, 1246, 14, 362, 63, 5656, 8, 571, 12, 366, 3150, 9, 272, 340, 440, 24563, 26, 267, 372, 488, 272, 702, 822, 8, 32332, 9, 508, 413, 272, 372, 24563, 59, 16, 1055, 5780, 421, 199, 318, 12392, 63, 6253, 63, 548, 8, 5780, 12, 1844, 63, 889, 12, 666, 304, 272, 327, 1634, 413, 14, 18, 272, 14122, 275, 12392, 14, 15129, 272, 14122, 63, 2087, 275, 12392, 14, 15129, 63, 2087, 272, 5445, 275, 359, 15129, 63, 2087, 14, 6733, 3310, 2959, 8, 719, 63, 889, 12, 6343, 14122, 14, 3359, 4222, 1698, 63, 2826, 63, 10960, 1874, 272, 3644, 63, 548, 275, 14122, 63, 2087, 14, 6733, 2726, 2204, 8, 267, 12392, 12, 378, 21870, 12, 14122, 14, 6733, 48, 63, 5801, 14881, 540, 12, 5445, 12, 666, 9, 272, 12392, 14, 2254, 63, 1328, 8, 6253, 63, 548, 9, 421, 199, 318, 12392, 63, 1659, 63, 1494, 8, 5780, 12, 1817, 12, 1414, 12, 7464, 12, 1336, 12, 15794, 12, 355, 734, 63, 719, 29, 403, 304, 272, 327, 1634, 413, 14, 18, 272, 14122, 275, 12392, 14, 15129, 272, 14122, 63, 2087, 275, 12392, 14, 15129, 63, 2087, 272, 340, 734, 63, 719, 365, 488, 26, 267, 734, 63, 719, 275, 14122, 14, 6733, 48, 63, 8974, 272, 6369, 63, 1494, 275, 14122, 63, 2087, 14, 6733, 5060, 9871, 8, 267, 12392, 12, 378, 12, 378, 12, 1817, 12, 1414, 12, 378, 12, 378, 12, 267, 7464, 12, 378, 21870, 12, 734, 63, 719, 12, 14122, 14, 6733, 39, 63, 8974, 12, 267, 14122, 14, 6733, 1665, 63, 8936, 63, 14336, 44, 1282, 12, 1336, 12, 15794, 9, 272, 12392, 14, 2254, 63, 1328, 8, 1659, 63, 1494, 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 ]
[ 1898, 334, 35, 9, 6171, 653, 711, 678, 23884, 2180, 436, 23884, 9339, 11098, 14, 199, 3, 1898, 334, 35, 9, 6171, 6596, 1151, 85, 1488, 14541, 72, 419, 665, 11552, 391, 72, 419, 737, 5726, 3031, 1279, 28921, 30, 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, 504, 25494, 14, 773, 14, 6253, 492, 21944, 199, 504, 25494, 14, 773, 14, 6253, 492, 10119, 199, 504, 25494, 14, 15129, 492, 30201, 199, 504, 25494, 14, 10775, 492, 2986, 465, 11111, 63, 1246, 421, 199, 318, 1443, 63, 525, 63, 7175, 8, 6253, 12, 10119, 63, 344, 304, 272, 408, 272, 520, 466, 3644, 26, 25494, 14, 773, 14, 6253, 14, 6253, 14, 2726, 272, 520, 635, 3644, 26, 272, 520, 466, 10119, 63, 344, 26, 1109, 334, 16, 2695, 10119, 63, 344, 2695, 841, 19113, 9, 503, 488, 24649, 3091, 17591, 9, 272, 520, 635, 10119, 63, 344, 26, 272, 408, 272, 340, 10119, 63, 344, 365, 488, 26, 267, 372, 339, 325, 275, 3644, 14, 16541, 59, 16, 61, 272, 702, 1228, 8, 69, 12, 21944, 14, 20354, 9, 272, 373, 275, 10119, 14, 7175, 8, 16, 12, 378, 12, 10119, 63, 344, 12, 325, 14, 27732, 466, 9, 272, 325, 14, 27732, 466, 275, 30201, 14, 21265, 63, 2711, 63, 11366, 17, 49, 272, 3644, 14, 525, 63, 3922, 8, 86, 9, 421, 199, 318, 664, 63, 5780, 8, 571, 12, 366, 3150, 304, 272, 408, 272, 520, 466, 366, 3150, 26, 24991, 1305, 272, 520, 635, 366, 3150, 26, 272, 520, 4500, 26, 25494, 14, 5538, 14, 5538, 14, 1451, 10853, 89, 72, 272, 520, 5808, 26, 24991, 5226, 370, 366, 3150, 272, 408, 272, 24563, 275, 11111, 63, 1246, 14, 362, 63, 5656, 8, 571, 12, 366, 3150, 9, 272, 340, 440, 24563, 26, 267, 372, 488, 272, 702, 822, 8, 32332, 9, 508, 413, 272, 372, 24563, 59, 16, 1055, 5780, 421, 199, 318, 12392, 63, 6253, 63, 548, 8, 5780, 12, 1844, 63, 889, 12, 666, 304, 272, 327, 1634, 413, 14, 18, 272, 14122, 275, 12392, 14, 15129, 272, 14122, 63, 2087, 275, 12392, 14, 15129, 63, 2087, 272, 5445, 275, 359, 15129, 63, 2087, 14, 6733, 3310, 2959, 8, 719, 63, 889, 12, 6343, 14122, 14, 3359, 4222, 1698, 63, 2826, 63, 10960, 1874, 272, 3644, 63, 548, 275, 14122, 63, 2087, 14, 6733, 2726, 2204, 8, 267, 12392, 12, 378, 21870, 12, 14122, 14, 6733, 48, 63, 5801, 14881, 540, 12, 5445, 12, 666, 9, 272, 12392, 14, 2254, 63, 1328, 8, 6253, 63, 548, 9, 421, 199, 318, 12392, 63, 1659, 63, 1494, 8, 5780, 12, 1817, 12, 1414, 12, 7464, 12, 1336, 12, 15794, 12, 355, 734, 63, 719, 29, 403, 304, 272, 327, 1634, 413, 14, 18, 272, 14122, 275, 12392, 14, 15129, 272, 14122, 63, 2087, 275, 12392, 14, 15129, 63, 2087, 272, 340, 734, 63, 719, 365, 488, 26, 267, 734, 63, 719, 275, 14122, 14, 6733, 48, 63, 8974, 272, 6369, 63, 1494, 275, 14122, 63, 2087, 14, 6733, 5060, 9871, 8, 267, 12392, 12, 378, 12, 378, 12, 1817, 12, 1414, 12, 378, 12, 378, 12, 267, 7464, 12, 378, 21870, 12, 734, 63, 719, 12, 14122, 14, 6733, 39, 63, 8974, 12, 267, 14122, 14, 6733, 1665, 63, 8936, 63, 14336, 44, 1282, 12, 1336, 12, 15794, 9, 272, 12392, 14, 2254, 63, 1328, 8, 1659, 63, 1494, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
MjAbuz/foundation
foundation/djangocms_pagebanner/cms_toolbar.py
1
2382
from cms.api import get_page_draft from cms.toolbar_pool import toolbar_pool from cms.toolbar_base import CMSToolbar from cms.utils import get_cms_setting from cms.utils.permissions import has_page_change_permission from django.core.urlresolvers import reverse, NoReverseMatch from django.utils.translation import ugettext_lazy as _ from .models import PageBannerExtension _banner_change_url = 'admin:djangocms_pagebanner_pagebannerextension_change' _banner_add_url = 'admin:djangocms_pagebanner_pagebannerextension_add' @toolbar_pool.register class PageBannerExtensionToolbar(CMSToolbar): def populate(self): # always use draft if we have a page self.page = get_page_draft(self.request.current_page) if not self.page: # Nothing to do return # check global permissions if CMS_PERMISSIONS is active if get_cms_setting('PERMISSION'): has_global_current_page_change_permission = \ has_page_change_permission(self.request) else: has_global_current_page_change_permission = False # check if user has page edit permission can_change = (self.request.current_page and self.request.current_page.has_change_permission( self.request)) if has_global_current_page_change_permission or can_change: try: page_banner_extension = PageBannerExtension.objects.get( extended_object_id=self.page.id) except PageBannerExtension.DoesNotExist: page_banner_extension = None try: if page_banner_extension: url = reverse(_banner_change_url, args=(page_banner_extension.pk,)) else: url = (reverse(_banner_add_url) + '?extended_object=%s' % self.page.pk) except NoReverseMatch: # not in urls pass else: not_edit_mode = not self.toolbar.edit_mode current_page_menu = self.toolbar.get_or_create_menu('page') current_page_menu.add_modal_item(_('Page banner'), url=url, disabled=not_edit_mode)
mit
[ 504, 19240, 14, 1246, 492, 664, 63, 1606, 63, 7185, 199, 504, 19240, 14, 13951, 63, 2293, 492, 22483, 63, 2293, 199, 504, 19240, 14, 13951, 63, 1095, 492, 445, 45, 840, 21943, 1700, 199, 504, 19240, 14, 1208, 492, 664, 63, 10781, 63, 6031, 199, 504, 19240, 14, 1208, 14, 6060, 492, 965, 63, 1606, 63, 1461, 63, 5693, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 12, 32036, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1275, 992, 492, 10331, 22107, 6382, 199, 199, 63, 13066, 63, 1461, 63, 633, 275, 283, 2113, 26, 12816, 679, 706, 63, 1606, 13066, 63, 1606, 13206, 685, 15063, 724, 438, 63, 1461, 7, 199, 63, 13066, 63, 525, 63, 633, 275, 283, 2113, 26, 12816, 679, 706, 63, 1606, 13066, 63, 1606, 13206, 685, 15063, 724, 438, 63, 525, 7, 421, 199, 32, 13951, 63, 2293, 14, 2683, 199, 533, 10331, 22107, 6382, 29630, 8, 9249, 840, 21943, 1700, 304, 272, 347, 13904, 8, 277, 304, 267, 327, 3544, 675, 11872, 340, 781, 1172, 282, 2034, 267, 291, 14, 1606, 275, 664, 63, 1606, 63, 7185, 8, 277, 14, 1069, 14, 1818, 63, 1606, 9, 398, 340, 440, 291, 14, 1606, 26, 288, 327, 20550, 370, 886, 288, 372, 398, 327, 1104, 2288, 3443, 340, 29554, 63, 4227, 31978, 365, 4702, 267, 340, 664, 63, 10781, 63, 6031, 360, 4227, 22320, 735, 288, 965, 63, 2966, 63, 1818, 63, 1606, 63, 1461, 63, 5693, 275, 971, 355, 965, 63, 1606, 63, 1461, 63, 5693, 8, 277, 14, 1069, 9, 267, 587, 26, 288, 965, 63, 2966, 63, 1818, 63, 1606, 63, 1461, 63, 5693, 275, 756, 288, 327, 1104, 340, 922, 965, 2034, 5283, 4983, 267, 883, 63, 1461, 275, 334, 277, 14, 1069, 14, 1818, 63, 1606, 436, 1993, 291, 14, 1069, 14, 1818, 63, 1606, 14, 1989, 63, 1461, 63, 5693, 8, 2079, 291, 14, 1069, 430, 398, 340, 965, 63, 2966, 63, 1818, 63, 1606, 63, 1461, 63, 5693, 503, 883, 63, 1461, 26, 288, 862, 26, 355, 2034, 63, 13066, 63, 3435, 275, 10331, 22107, 6382, 14, 1462, 14, 362, 8, 490, 9243, 63, 785, 63, 344, 29, 277, 14, 1606, 14, 344, 9, 288, 871, 10331, 22107, 6382, 14, 7400, 26, 355, 2034, 63, 13066, 63, 3435, 275, 488, 288, 862, 26, 355, 340, 2034, 63, 13066, 63, 3435, 26, 490, 1166, 275, 3837, 1547, 13066, 63, 1461, 63, 633, 12, 3303, 1249, 2687, 1606, 63, 13066, 63, 3435, 14, 2051, 4641, 355, 587, 26, 490, 1166, 275, 334, 4471, 1547, 13066, 63, 525, 63, 633, 9, 435, 2574, 8720, 10525, 63, 785, 2458, 83, 7, 450, 291, 14, 1606, 14, 2051, 9, 288, 871, 32036, 26, 355, 327, 440, 315, 8187, 355, 986, 288, 587, 26, 355, 440, 63, 3773, 63, 632, 275, 440, 291, 14, 13951, 14, 3773, 63, 632, 355, 1453, 63, 1606, 63, 4470, 275, 291, 14, 13951, 14, 362, 63, 269, 63, 981, 63, 4470, 360, 1606, 358, 355, 1453, 63, 1606, 63, 4470, 14, 525, 63, 17713, 63, 1053, 6723, 3276, 20997, 659, 1740, 1166, 29, 633, 12, 1740, 6980, 29, 1397, 63, 3773, 63, 632, 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 ]
[ 19240, 14, 1246, 492, 664, 63, 1606, 63, 7185, 199, 504, 19240, 14, 13951, 63, 2293, 492, 22483, 63, 2293, 199, 504, 19240, 14, 13951, 63, 1095, 492, 445, 45, 840, 21943, 1700, 199, 504, 19240, 14, 1208, 492, 664, 63, 10781, 63, 6031, 199, 504, 19240, 14, 1208, 14, 6060, 492, 965, 63, 1606, 63, 1461, 63, 5693, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 12, 32036, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1275, 992, 492, 10331, 22107, 6382, 199, 199, 63, 13066, 63, 1461, 63, 633, 275, 283, 2113, 26, 12816, 679, 706, 63, 1606, 13066, 63, 1606, 13206, 685, 15063, 724, 438, 63, 1461, 7, 199, 63, 13066, 63, 525, 63, 633, 275, 283, 2113, 26, 12816, 679, 706, 63, 1606, 13066, 63, 1606, 13206, 685, 15063, 724, 438, 63, 525, 7, 421, 199, 32, 13951, 63, 2293, 14, 2683, 199, 533, 10331, 22107, 6382, 29630, 8, 9249, 840, 21943, 1700, 304, 272, 347, 13904, 8, 277, 304, 267, 327, 3544, 675, 11872, 340, 781, 1172, 282, 2034, 267, 291, 14, 1606, 275, 664, 63, 1606, 63, 7185, 8, 277, 14, 1069, 14, 1818, 63, 1606, 9, 398, 340, 440, 291, 14, 1606, 26, 288, 327, 20550, 370, 886, 288, 372, 398, 327, 1104, 2288, 3443, 340, 29554, 63, 4227, 31978, 365, 4702, 267, 340, 664, 63, 10781, 63, 6031, 360, 4227, 22320, 735, 288, 965, 63, 2966, 63, 1818, 63, 1606, 63, 1461, 63, 5693, 275, 971, 355, 965, 63, 1606, 63, 1461, 63, 5693, 8, 277, 14, 1069, 9, 267, 587, 26, 288, 965, 63, 2966, 63, 1818, 63, 1606, 63, 1461, 63, 5693, 275, 756, 288, 327, 1104, 340, 922, 965, 2034, 5283, 4983, 267, 883, 63, 1461, 275, 334, 277, 14, 1069, 14, 1818, 63, 1606, 436, 1993, 291, 14, 1069, 14, 1818, 63, 1606, 14, 1989, 63, 1461, 63, 5693, 8, 2079, 291, 14, 1069, 430, 398, 340, 965, 63, 2966, 63, 1818, 63, 1606, 63, 1461, 63, 5693, 503, 883, 63, 1461, 26, 288, 862, 26, 355, 2034, 63, 13066, 63, 3435, 275, 10331, 22107, 6382, 14, 1462, 14, 362, 8, 490, 9243, 63, 785, 63, 344, 29, 277, 14, 1606, 14, 344, 9, 288, 871, 10331, 22107, 6382, 14, 7400, 26, 355, 2034, 63, 13066, 63, 3435, 275, 488, 288, 862, 26, 355, 340, 2034, 63, 13066, 63, 3435, 26, 490, 1166, 275, 3837, 1547, 13066, 63, 1461, 63, 633, 12, 3303, 1249, 2687, 1606, 63, 13066, 63, 3435, 14, 2051, 4641, 355, 587, 26, 490, 1166, 275, 334, 4471, 1547, 13066, 63, 525, 63, 633, 9, 435, 2574, 8720, 10525, 63, 785, 2458, 83, 7, 450, 291, 14, 1606, 14, 2051, 9, 288, 871, 32036, 26, 355, 327, 440, 315, 8187, 355, 986, 288, 587, 26, 355, 440, 63, 3773, 63, 632, 275, 440, 291, 14, 13951, 14, 3773, 63, 632, 355, 1453, 63, 1606, 63, 4470, 275, 291, 14, 13951, 14, 362, 63, 269, 63, 981, 63, 4470, 360, 1606, 358, 355, 1453, 63, 1606, 63, 4470, 14, 525, 63, 17713, 63, 1053, 6723, 3276, 20997, 659, 1740, 1166, 29, 633, 12, 1740, 6980, 29, 1397, 63, 3773, 63, 632, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
viru/ansible-modules-core
cloud/openstack/os_server_actions.py
54
7060
#!/usr/bin/python # coding: utf-8 -*- # Copyright (c) 2015, Jesse Keating <jlk@derpops.bike> # # This module is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This software is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this software. If not, see <http://www.gnu.org/licenses/>. try: import shade from shade import meta HAS_SHADE = True except ImportError: HAS_SHADE = False DOCUMENTATION = ''' --- module: os_server_actions short_description: Perform actions on Compute Instances from OpenStack extends_documentation_fragment: openstack version_added: "2.0" author: "Jesse Keating (@j2sol)" description: - Perform server actions on an existing compute instance from OpenStack. This module does not return any data other than changed true/false. options: server: description: - Name or ID of the instance required: true wait: description: - If the module should wait for the instance action to be performed. required: false default: 'yes' timeout: description: - The amount of time the module should wait for the instance to perform the requested action. required: false default: 180 action: description: - Perform the given action. The lock and unlock actions always return changed as the servers API does not provide lock status. choices: [stop, start, pause, unpause, lock, unlock, suspend, resume] default: present requirements: - "python >= 2.6" - "shade" ''' EXAMPLES = ''' # Pauses a compute instance - os_server_actions: action: pause auth: auth_url: https://mycloud.openstack.blueboxgrid.com:5001/v2.0 username: admin password: admin project_name: admin server: vm1 timeout: 200 ''' _action_map = {'stop': 'SHUTOFF', 'start': 'ACTIVE', 'pause': 'PAUSED', 'unpause': 'ACTIVE', 'lock': 'ACTIVE', # API doesn't show lock/unlock status 'unlock': 'ACTIVE', 'suspend': 'SUSPENDED', 'resume': 'ACTIVE',} _admin_actions = ['pause', 'unpause', 'suspend', 'resume', 'lock', 'unlock'] def _wait(timeout, cloud, server, action): """Wait for the server to reach the desired state for the given action.""" for count in shade._utils._iterate_timeout( timeout, "Timeout waiting for server to complete %s" % action): try: server = cloud.get_server(server.id) except Exception: continue if server.status == _action_map[action]: return if server.status == 'ERROR': module.fail_json(msg="Server reached ERROR state while attempting to %s" % action) def _system_state_change(action, status): """Check if system state would change.""" if status == _action_map[action]: return False return True def main(): argument_spec = openstack_full_argument_spec( server=dict(required=True), action=dict(required=True, choices=['stop', 'start', 'pause', 'unpause', 'lock', 'unlock', 'suspend', 'resume']), ) module_kwargs = openstack_module_kwargs() module = AnsibleModule(argument_spec, supports_check_mode=True, **module_kwargs) if not HAS_SHADE: module.fail_json(msg='shade is required for this module') action = module.params['action'] wait = module.params['wait'] timeout = module.params['timeout'] try: if action in _admin_actions: cloud = shade.operator_cloud(**module.params) else: cloud = shade.openstack_cloud(**module.params) server = cloud.get_server(module.params['server']) if not server: module.fail_json(msg='Could not find server %s' % server) status = server.status if module.check_mode: module.exit_json(changed=_system_state_change(action, status)) if action == 'stop': if not _system_state_change(action, status): module.exit_json(changed=False) cloud.nova_client.servers.stop(server=server.id) if wait: _wait(timeout, cloud, server, action) module.exit_json(changed=True) if action == 'start': if not _system_state_change(action, status): module.exit_json(changed=False) cloud.nova_client.servers.start(server=server.id) if wait: _wait(timeout, cloud, server, action) module.exit_json(changed=True) if action == 'pause': if not _system_state_change(action, status): module.exit_json(changed=False) cloud.nova_client.servers.pause(server=server.id) if wait: _wait(timeout, cloud, server, action) module.exit_json(changed=True) elif action == 'unpause': if not _system_state_change(action, status): module.exit_json(changed=False) cloud.nova_client.servers.unpause(server=server.id) if wait: _wait(timeout, cloud, server, action) module.exit_json(changed=True) elif action == 'lock': # lock doesn't set a state, just do it cloud.nova_client.servers.lock(server=server.id) module.exit_json(changed=True) elif action == 'unlock': # unlock doesn't set a state, just do it cloud.nova_client.servers.unlock(server=server.id) module.exit_json(changed=True) elif action == 'suspend': if not _system_state_change(action, status): module.exit_json(changed=False) cloud.nova_client.servers.suspend(server=server.id) if wait: _wait(timeout, cloud, server, action) module.exit_json(changed=True) elif action == 'resume': if not _system_state_change(action, status): module.exit_json(changed=False) cloud.nova_client.servers.resume(server=server.id) if wait: _wait(timeout, cloud, server, action) module.exit_json(changed=True) except shade.OpenStackCloudException as e: module.fail_json(msg=e.message, extra_data=e.extra_data) # this is magic, see lib/ansible/module_common.py from ansible.module_utils.basic import * from ansible.module_utils.openstack import * if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 67, 9, 6900, 12, 1603, 397, 261, 25645, 1958, 665, 74, 23333, 32, 424, 80, 1483, 14, 4492, 415, 30, 199, 3, 199, 3, 961, 859, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2032, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2032, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 893, 26, 272, 492, 32250, 272, 687, 32250, 492, 3404, 272, 7509, 63, 8461, 1093, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 8461, 1093, 275, 756, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 747, 63, 1000, 63, 3723, 199, 3612, 63, 1802, 26, 14795, 5445, 641, 8354, 10066, 83, 687, 14260, 199, 11036, 63, 9970, 63, 7677, 26, 13869, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 2502, 26, 298, 42, 397, 261, 25645, 1958, 8593, 74, 18, 7873, 2924, 199, 1802, 26, 2043, 446, 14795, 1654, 5445, 641, 376, 3411, 4526, 1256, 687, 14260, 14, 1362, 961, 859, 1630, 440, 372, 1263, 666, 1163, 2419, 2896, 2549, 15, 3910, 14, 199, 1419, 26, 2043, 1654, 26, 1362, 1369, 26, 267, 446, 2812, 503, 2870, 402, 314, 1256, 1362, 1415, 26, 2549, 2043, 3618, 26, 1362, 1369, 26, 267, 446, 982, 314, 859, 1077, 3618, 367, 314, 1256, 1595, 370, 506, 10585, 14, 1362, 1415, 26, 3055, 1362, 849, 26, 283, 5066, 7, 2043, 2653, 26, 1362, 1369, 26, 267, 446, 710, 5982, 402, 900, 314, 859, 1077, 3618, 367, 314, 1256, 370, 5147, 881, 314, 5839, 1595, 14, 1362, 1415, 26, 3055, 1362, 849, 26, 13576, 2043, 1595, 26, 1362, 1369, 26, 2126, 446, 14795, 314, 1627, 1595, 14, 710, 4650, 436, 28451, 5445, 3544, 372, 268, 2896, 465, 314, 8037, 3261, 1630, 440, 5647, 4650, 2004, 14, 1362, 3415, 26, 359, 2379, 12, 1343, 12, 16834, 12, 625, 11241, 12, 4650, 12, 28451, 12, 20288, 12, 14604, 61, 1362, 849, 26, 3451, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 22, 2, 272, 446, 298, 31170, 2, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 510, 3844, 874, 282, 4526, 1256, 199, 13, 747, 63, 1000, 63, 3723, 26, 2126, 1595, 26, 16834, 2126, 1790, 26, 268, 1790, 63, 633, 26, 4178, 921, 1662, 4091, 14, 8512, 14, 6304, 1977, 3825, 14, 957, 26, 21, 4587, 15, 86, 18, 14, 16, 268, 3434, 26, 4628, 268, 2505, 26, 4628, 268, 2199, 63, 354, 26, 4628, 2126, 1654, 26, 4169, 17, 2126, 2653, 26, 1926, 199, 2344, 199, 199, 63, 1287, 63, 1130, 275, 791, 2379, 356, 283, 24340, 7517, 297, 2049, 283, 928, 356, 283, 10401, 297, 2049, 283, 11241, 356, 283, 8470, 8558, 297, 2049, 283, 324, 11241, 356, 283, 10401, 297, 2049, 283, 831, 356, 283, 10401, 297, 327, 3261, 3181, 1133, 2498, 4650, 15, 17966, 2004, 2049, 283, 17966, 356, 283, 10401, 297, 2049, 283, 14480, 356, 283, 51, 28011, 25518, 297, 2049, 283, 9964, 356, 283, 10401, 297, 93, 199, 199, 63, 2113, 63, 3723, 275, 788, 11241, 297, 283, 324, 11241, 297, 283, 14480, 297, 283, 9964, 297, 283, 831, 297, 283, 17966, 418, 199, 199, 318, 485, 2573, 8, 2593, 12, 8002, 12, 1654, 12, 1595, 304, 272, 408, 7536, 367, 314, 1654, 370, 12276, 314, 6387, 1174, 367, 314, 1627, 1595, 1041, 339, 367, 2338, 315, 32250, 423, 1208, 423, 20627, 63, 2593, 8, 288, 2653, 12, 288, 298, 6372, 10923, 367, 1654, 370, 4890, 450, 83, 2, 450, 1595, 304, 267, 862, 26, 288, 1654, 275, 8002, 14, 362, 63, 1000, 8, 1000, 14, 344, 9, 267, 871, 2186, 26, 288, 1980, 398, 340, 1654, 14, 1205, 508, 485, 1287, 63, 1130, 59, 1287, 2189, 288, 372, 398, 340, 1654, 14, 1205, 508, 283, 3170, 356, 288, 859, 14, 1633, 63, 1001, 8, 1328, 628, 3120, 13075, 12539, 1174, 1830, 19595, 370, 450, 83, 2, 450, 1595, 9, 199, 199, 318, 485, 2253, 63, 929, 63, 1461, 8, 1287, 12, 2004, 304, 272, 408, 1799, 340, 2656, 1174, 3955, 1570, 1041, 272, 340, 2004, 508, 485, 1287, 63, 1130, 59, 1287, 2189, 267, 372, 756, 272, 372, 715, 199, 199, 318, 2446, 837, 272, 1423, 63, 1650, 275, 13869, 63, 2861, 63, 2094, 63, 1650, 8, 267, 1654, 29, 807, 8, 2427, 29, 549, 395, 267, 1595, 29, 807, 8, 2427, 29, 549, 12, 3415, 2968, 2379, 297, 283, 928, 297, 283, 11241, 297, 283, 324, 11241, 297, 4490, 283, 831, 297, 283, 17966, 297, 283, 14480, 297, 283, 9964, 3815, 272, 776, 339, 859, 63, 958, 275, 13869, 63, 578, 63, 958, 342, 272, 859, 275, 6953, 8, 2094, 63, 1650, 12, 5171, 63, 1074, 63, 632, 29, 549, 12, 1011, 578, 63, 958, 9, 339, 340, 440, 7509, 63, 8461, 1093, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 31170, 365, 1415, 367, 642, 859, 358, 339, 1595, 275, 859, 14, 1162, 459, 1287, 418, 272, 3618, 275, 859, 14, 1162, 459, 2573, 418, 272, 2653, 275, 859, 14, 1162, 459, 2593, 418, 339, 862, 26, 267, 340, 1595, 315, 485, 2113, 63, 3723, 26, 288, 8002, 275, 32250, 14, 3856, 63, 4091, 3682, 578, 14, 1162, 9, 267, 587, 26, 288, 8002, 275, 32250, 14, 8512, 63, 4091, 3682, 578, 14, 1162, 9, 267, 1654, 275, 8002, 14, 362, 63, 1000, 8, 578, 14, 1162, 459 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 67, 9, 6900, 12, 1603, 397, 261, 25645, 1958, 665, 74, 23333, 32, 424, 80, 1483, 14, 4492, 415, 30, 199, 3, 199, 3, 961, 859, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2032, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2032, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 893, 26, 272, 492, 32250, 272, 687, 32250, 492, 3404, 272, 7509, 63, 8461, 1093, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 8461, 1093, 275, 756, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 747, 63, 1000, 63, 3723, 199, 3612, 63, 1802, 26, 14795, 5445, 641, 8354, 10066, 83, 687, 14260, 199, 11036, 63, 9970, 63, 7677, 26, 13869, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 2502, 26, 298, 42, 397, 261, 25645, 1958, 8593, 74, 18, 7873, 2924, 199, 1802, 26, 2043, 446, 14795, 1654, 5445, 641, 376, 3411, 4526, 1256, 687, 14260, 14, 1362, 961, 859, 1630, 440, 372, 1263, 666, 1163, 2419, 2896, 2549, 15, 3910, 14, 199, 1419, 26, 2043, 1654, 26, 1362, 1369, 26, 267, 446, 2812, 503, 2870, 402, 314, 1256, 1362, 1415, 26, 2549, 2043, 3618, 26, 1362, 1369, 26, 267, 446, 982, 314, 859, 1077, 3618, 367, 314, 1256, 1595, 370, 506, 10585, 14, 1362, 1415, 26, 3055, 1362, 849, 26, 283, 5066, 7, 2043, 2653, 26, 1362, 1369, 26, 267, 446, 710, 5982, 402, 900, 314, 859, 1077, 3618, 367, 314, 1256, 370, 5147, 881, 314, 5839, 1595, 14, 1362, 1415, 26, 3055, 1362, 849, 26, 13576, 2043, 1595, 26, 1362, 1369, 26, 2126, 446, 14795, 314, 1627, 1595, 14, 710, 4650, 436, 28451, 5445, 3544, 372, 268, 2896, 465, 314, 8037, 3261, 1630, 440, 5647, 4650, 2004, 14, 1362, 3415, 26, 359, 2379, 12, 1343, 12, 16834, 12, 625, 11241, 12, 4650, 12, 28451, 12, 20288, 12, 14604, 61, 1362, 849, 26, 3451, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 22, 2, 272, 446, 298, 31170, 2, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 510, 3844, 874, 282, 4526, 1256, 199, 13, 747, 63, 1000, 63, 3723, 26, 2126, 1595, 26, 16834, 2126, 1790, 26, 268, 1790, 63, 633, 26, 4178, 921, 1662, 4091, 14, 8512, 14, 6304, 1977, 3825, 14, 957, 26, 21, 4587, 15, 86, 18, 14, 16, 268, 3434, 26, 4628, 268, 2505, 26, 4628, 268, 2199, 63, 354, 26, 4628, 2126, 1654, 26, 4169, 17, 2126, 2653, 26, 1926, 199, 2344, 199, 199, 63, 1287, 63, 1130, 275, 791, 2379, 356, 283, 24340, 7517, 297, 2049, 283, 928, 356, 283, 10401, 297, 2049, 283, 11241, 356, 283, 8470, 8558, 297, 2049, 283, 324, 11241, 356, 283, 10401, 297, 2049, 283, 831, 356, 283, 10401, 297, 327, 3261, 3181, 1133, 2498, 4650, 15, 17966, 2004, 2049, 283, 17966, 356, 283, 10401, 297, 2049, 283, 14480, 356, 283, 51, 28011, 25518, 297, 2049, 283, 9964, 356, 283, 10401, 297, 93, 199, 199, 63, 2113, 63, 3723, 275, 788, 11241, 297, 283, 324, 11241, 297, 283, 14480, 297, 283, 9964, 297, 283, 831, 297, 283, 17966, 418, 199, 199, 318, 485, 2573, 8, 2593, 12, 8002, 12, 1654, 12, 1595, 304, 272, 408, 7536, 367, 314, 1654, 370, 12276, 314, 6387, 1174, 367, 314, 1627, 1595, 1041, 339, 367, 2338, 315, 32250, 423, 1208, 423, 20627, 63, 2593, 8, 288, 2653, 12, 288, 298, 6372, 10923, 367, 1654, 370, 4890, 450, 83, 2, 450, 1595, 304, 267, 862, 26, 288, 1654, 275, 8002, 14, 362, 63, 1000, 8, 1000, 14, 344, 9, 267, 871, 2186, 26, 288, 1980, 398, 340, 1654, 14, 1205, 508, 485, 1287, 63, 1130, 59, 1287, 2189, 288, 372, 398, 340, 1654, 14, 1205, 508, 283, 3170, 356, 288, 859, 14, 1633, 63, 1001, 8, 1328, 628, 3120, 13075, 12539, 1174, 1830, 19595, 370, 450, 83, 2, 450, 1595, 9, 199, 199, 318, 485, 2253, 63, 929, 63, 1461, 8, 1287, 12, 2004, 304, 272, 408, 1799, 340, 2656, 1174, 3955, 1570, 1041, 272, 340, 2004, 508, 485, 1287, 63, 1130, 59, 1287, 2189, 267, 372, 756, 272, 372, 715, 199, 199, 318, 2446, 837, 272, 1423, 63, 1650, 275, 13869, 63, 2861, 63, 2094, 63, 1650, 8, 267, 1654, 29, 807, 8, 2427, 29, 549, 395, 267, 1595, 29, 807, 8, 2427, 29, 549, 12, 3415, 2968, 2379, 297, 283, 928, 297, 283, 11241, 297, 283, 324, 11241, 297, 4490, 283, 831, 297, 283, 17966, 297, 283, 14480, 297, 283, 9964, 3815, 272, 776, 339, 859, 63, 958, 275, 13869, 63, 578, 63, 958, 342, 272, 859, 275, 6953, 8, 2094, 63, 1650, 12, 5171, 63, 1074, 63, 632, 29, 549, 12, 1011, 578, 63, 958, 9, 339, 340, 440, 7509, 63, 8461, 1093, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 31170, 365, 1415, 367, 642, 859, 358, 339, 1595, 275, 859, 14, 1162, 459, 1287, 418, 272, 3618, 275, 859, 14, 1162, 459, 2573, 418, 272, 2653, 275, 859, 14, 1162, 459, 2593, 418, 339, 862, 26, 267, 340, 1595, 315, 485, 2113, 63, 3723, 26, 288, 8002, 275, 32250, 14, 3856, 63, 4091, 3682, 578, 14, 1162, 9, 267, 587, 26, 288, 8002, 275, 32250, 14, 8512, 63, 4091, 3682, 578, 14, 1162, 9, 267, 1654, 275, 8002, 14, 362, 63, 1000, 8, 578, 14, 1162, 459, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
RenegadesTV/repository.renegadestv
script.renegadestv/streaming.py
5
11689
# # Copyright (C) 2014 Tommy Winther # http://tommy.winther.nu # # Modified for FTV Guide (09/2014 onwards) # by Thomas Geppert [bluezed] - bluezed.apps@gmail.com # # This Program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, 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; see the file LICENSE.txt. If not, write to # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. # http://www.gnu.org/copyleft/gpl.html # import xbmc from xml.etree import ElementTree import ConfigParser import os import xbmcaddon class StreamsService(object): def __init__(self, addon): if (int(addon.getSetting('addons.ini.type')) == 0): path = xbmc.translatePath(os.path.join('special://profile', 'addon_data', 'script.renegadestv', 'addons2.ini')) else: path = str(addon.getSetting('addons.ini.file')) self.addonsParser = ConfigParser.ConfigParser(dict_type=OrderedDict) self.addonsParser.optionxform = lambda option: option try: self.addonsParser.read(path) except: print 'unable to parse addons.ini' def loadFavourites(self): entries = list() path = xbmc.translatePath(os.path.join('special://profile', 'favourites.xml')) if os.path.exists(path): f = open(path) xml = f.read() f.close() try: doc = ElementTree.fromstring(xml) for node in doc.findall('favourite'): value = node.text if value[0:11] == 'PlayMedia("': value = value[11:-2] elif value[0:10] == 'PlayMedia(': value = value[10:-1] elif value[0:22] == 'ActivateWindow(10025,"': value = value[22:-9] elif value[0:21] == 'ActivateWindow(10025,': value = value[22:-8] else: continue entries.append((node.get('name'), value)) except: pass return entries def getAddons(self): return self.addonsParser.sections() def getAddonStreams(self, id): return self.addonsParser.items(id) def detectStream(self, channel): """ @param channel: @type channel: source.Channel """ favourites = self.loadFavourites() # First check favourites, if we get exact match we use it for label, stream in favourites: if label == channel.title: return stream # Second check all addons and return all matches matches = list() for id in self.getAddons(): try: xbmcaddon.Addon(id) except Exception: continue # ignore addons that are not installed for (label, stream) in self.getAddonStreams(id): if label == channel.title: matches.append((id, label, stream)) if len(matches) == 1: return matches[0][2] else: return matches class OrderedDict(dict): # From: http://code.activestate.com/recipes/576693/ 'Dictionary that remembers insertion order' # An inherited dict maps keys to values. # The inherited dict provides __getitem__, __len__, __contains__, and get. # The remaining methods are order-aware. # Big-O running times for all methods are the same as for regular dictionaries. # The internal self.__map dictionary maps keys to links in a doubly linked list. # The circular doubly linked list starts and ends with a sentinel element. # The sentinel element never gets deleted (this simplifies the algorithm). # Each link is stored as a list of length three: [PREV, NEXT, KEY]. def __init__(self, *args, **kwds): '''Initialize an ordered dictionary. Signature is the same as for regular dictionaries, but keyword arguments are not recommended because their insertion order is arbitrary. ''' if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) try: self.__root except AttributeError: self.__root = root = [] # sentinel node root[:] = [root, root, None] self.__map = {} self.__update(*args, **kwds) def __setitem__(self, key, value, dict_setitem=dict.__setitem__): 'od.__setitem__(i, y) <==> od[i]=y' # Setting a new item creates a new link which goes at the end of the linked # list, and the inherited dictionary is updated with the new key/value pair. if key not in self: root = self.__root last = root[0] last[1] = root[0] = self.__map[key] = [last, root, key] dict_setitem(self, key, value) def __delitem__(self, key, dict_delitem=dict.__delitem__): 'od.__delitem__(y) <==> del od[y]' # Deleting an existing item uses self.__map to find the link which is # then removed by updating the links in the predecessor and successor nodes. dict_delitem(self, key) link_prev, link_next, key = self.__map.pop(key) link_prev[1] = link_next link_next[0] = link_prev def __iter__(self): 'od.__iter__() <==> iter(od)' root = self.__root curr = root[1] while curr is not root: yield curr[2] curr = curr[1] def __reversed__(self): 'od.__reversed__() <==> reversed(od)' root = self.__root curr = root[0] while curr is not root: yield curr[2] curr = curr[0] def clear(self): 'od.clear() -> None. Remove all items from od.' try: for node in self.__map.itervalues(): del node[:] root = self.__root root[:] = [root, root, None] self.__map.clear() except AttributeError: pass dict.clear(self) def popitem(self, last=True): '''od.popitem() -> (k, v), return and remove a (key, value) pair. Pairs are returned in LIFO order if last is true or FIFO order if false. ''' if not self: raise KeyError('dictionary is empty') root = self.__root if last: link = root[0] link_prev = link[0] link_prev[1] = root root[0] = link_prev else: link = root[1] link_next = link[1] root[1] = link_next link_next[0] = root key = link[2] del self.__map[key] value = dict.pop(self, key) return key, value # -- the following methods do not depend on the internal structure -- def keys(self): 'od.keys() -> list of keys in od' return list(self) def values(self): 'od.values() -> list of values in od' return [self[key] for key in self] def items(self): 'od.items() -> list of (key, value) pairs in od' return [(key, self[key]) for key in self] def iterkeys(self): 'od.iterkeys() -> an iterator over the keys in od' return iter(self) def itervalues(self): 'od.itervalues -> an iterator over the values in od' for k in self: yield self[k] def iteritems(self): 'od.iteritems -> an iterator over the (key, value) items in od' for k in self: yield (k, self[k]) def update(*args, **kwds): '''od.update(E, **F) -> None. Update od from dict/iterable E and F. If E is a dict instance, does: for k in E: od[k] = E[k] If E has a .keys() method, does: for k in E.keys(): od[k] = E[k] Or if E is an iterable of items, does: for k, v in E: od[k] = v In either case, this is followed by: for k, v in F.items(): od[k] = v ''' if len(args) > 2: raise TypeError('update() takes at most 2 positional ' 'arguments (%d given)' % (len(args),)) elif not args: raise TypeError('update() takes at least 1 argument (0 given)') self = args[0] # Make progressively weaker assumptions about "other" other = () if len(args) == 2: other = args[1] if isinstance(other, dict): for key in other: self[key] = other[key] elif hasattr(other, 'keys'): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __update = update # let subclasses override update without breaking __init__ __marker = object() def pop(self, key, default=__marker): '''od.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised. ''' if key in self: result = self[key] del self[key] return result if default is self.__marker: raise KeyError(key) return default def setdefault(self, key, default=None): 'od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od' if key in self: return self[key] self[key] = default return default def __repr__(self, _repr_running={}): 'od.__repr__() <==> repr(od)' call_key = id(self), _get_ident() if call_key in _repr_running: return '...' _repr_running[call_key] = 1 try: if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, self.items()) finally: del _repr_running[call_key] def __reduce__(self): 'Return state information for pickling' items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() for k in vars(OrderedDict()): inst_dict.pop(k, None) if inst_dict: return (self.__class__, (items,), inst_dict) return self.__class__, (items,) def copy(self): 'od.copy() -> a shallow copy of od' return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): '''OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S and values equal to v (which defaults to None). ''' d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): '''od.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive while comparison to a regular mapping is order-insensitive. ''' if isinstance(other, OrderedDict): return len(self)==len(other) and self.items() == other.items() return dict.__eq__(self, other) def __ne__(self, other): return not self == other
gpl-2.0
[ 3, 199, 3, 420, 1898, 334, 35, 9, 6927, 4005, 31155, 13036, 728, 199, 3, 420, 1455, 921, 475, 31155, 14, 2676, 728, 14, 4850, 199, 3, 199, 3, 420, 22016, 367, 481, 12764, 15423, 334, 1643, 15, 7280, 641, 4751, 9, 199, 3, 420, 701, 27864, 598, 1545, 28621, 359, 6304, 7068, 61, 446, 10030, 7068, 14, 5181, 32, 6799, 14, 957, 199, 3, 199, 3, 221, 961, 18841, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 221, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 221, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 221, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 18841, 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, 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, 18841, 27, 1937, 314, 570, 5113, 14, 2424, 14, 221, 982, 440, 12, 2218, 370, 199, 3, 221, 314, 2868, 2290, 2752, 12, 1227, 2194, 603, 405, 437, 432, 12, 445, 455, 9528, 12, 4828, 12497, 7491, 12, 8217, 14, 199, 3, 221, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 1574, 3039, 15, 11692, 14, 1360, 199, 3, 199, 646, 11709, 199, 504, 2748, 14, 9464, 492, 13139, 199, 646, 14196, 199, 646, 747, 199, 646, 11709, 9291, 421, 199, 533, 8271, 83, 3167, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 13553, 304, 267, 340, 334, 442, 8, 9291, 14, 30008, 360, 10788, 14, 2730, 14, 466, 1333, 508, 378, 304, 288, 931, 275, 11709, 14, 5275, 2042, 8, 736, 14, 515, 14, 904, 360, 6664, 921, 2913, 297, 283, 9291, 63, 576, 297, 283, 1579, 14, 264, 685, 5294, 2614, 86, 297, 283, 10788, 18, 14, 2730, 1333, 267, 587, 26, 288, 931, 275, 620, 8, 9291, 14, 30008, 360, 10788, 14, 2730, 14, 493, 1333, 398, 291, 14, 10788, 2842, 275, 14196, 14, 15218, 8, 807, 63, 466, 29, 16882, 9, 267, 291, 14, 10788, 2842, 14, 1422, 24226, 275, 2400, 945, 26, 945, 267, 862, 26, 288, 291, 14, 10788, 2842, 14, 739, 8, 515, 9, 267, 871, 26, 288, 870, 283, 17200, 370, 2198, 21293, 14, 2730, 7, 339, 347, 2248, 38, 1214, 567, 4033, 8, 277, 304, 267, 4811, 275, 769, 342, 267, 931, 275, 11709, 14, 5275, 2042, 8, 736, 14, 515, 14, 904, 360, 6664, 921, 2913, 297, 283, 30763, 567, 4033, 14, 1652, 1333, 267, 340, 747, 14, 515, 14, 2444, 8, 515, 304, 288, 289, 275, 1551, 8, 515, 9, 288, 2748, 275, 289, 14, 739, 342, 288, 289, 14, 1600, 342, 953, 862, 26, 355, 1382, 275, 13139, 14, 13521, 8, 1652, 9, 355, 367, 1031, 315, 1382, 14, 6452, 360, 30763, 567, 1175, 735, 490, 574, 275, 1031, 14, 505, 490, 340, 574, 59, 16, 26, 845, 61, 508, 283, 9651, 11398, 480, 356, 717, 574, 275, 574, 59, 845, 6809, 18, 61, 490, 916, 574, 59, 16, 26, 709, 61, 508, 283, 9651, 11398, 6176, 717, 574, 275, 574, 59, 709, 6809, 17, 61, 490, 916, 574, 59, 16, 26, 1081, 61, 508, 283, 30120, 4301, 8, 1960, 821, 4589, 356, 717, 574, 275, 574, 59, 1081, 6809, 25, 61, 490, 916, 574, 59, 16, 26, 2025, 61, 508, 283, 30120, 4301, 8, 1960, 821, 12, 356, 717, 574, 275, 574, 59, 1081, 6809, 24, 61, 490, 587, 26, 717, 1980, 4951, 4811, 14, 740, 1332, 932, 14, 362, 360, 354, 659, 574, 430, 288, 871, 26, 355, 986, 398, 372, 4811, 339, 347, 664, 1123, 4654, 8, 277, 304, 267, 372, 291, 14, 10788, 2842, 14, 7786, 342, 339, 347, 664, 19654, 19358, 8, 277, 12, 1305, 304, 267, 372, 291, 14, 10788, 2842, 14, 1744, 8, 344, 9, 339, 347, 9696, 3296, 8, 277, 12, 3623, 304, 267, 408, 267, 768, 635, 3623, 26, 267, 768, 466, 3623, 26, 1350, 14, 5358, 267, 408, 267, 289, 1214, 567, 4033, 275, 291, 14, 912, 38, 1214, 567, 4033, 342, 398, 327, 7758, 1104, 289, 1214, 567, 4033, 12, 340, 781, 664, 5835, 1336, 781, 675, 652, 267, 367, 1768, 12, 2547, 315, 289, 1214, 567, 4033, 26, 288, 340, 1768, 508, 3623, 14, 1213, 26, 355, 372, 2547, 7318, 327, 16707, 1104, 1006, 21293, 436, 372, 1006, 4450, 267, 4450, 275, 769, 342, 267, 367, 1305, 315, 291, 14, 362, 1123, 4654, 837, 288, 862, 26, 355, 11709, 9291, 14, 19654, 8, 344, 9, 288, 871, 2186, 26, 355, 1980, 327, 3686, 21293, 626, 787, 440, 4903, 953, 367, 334, 1302, 12, 2547, 9, 315, 291, 14, 362, 19654, 19358, 8, 344, 304, 355, 340, 1768, 508, 3623, 14, 1213, 26, 490, 4450, 14, 740, 1332, 344, 12, 1768, 12, 2547, 430, 398, 340, 822, 8, 6742, 9, 508, 413, 26, 288, 372, 4450, 59, 16, 1527, 18, 61, 267, 587, 26, 288, 372, 4450, 421, 199, 533, 8773, 8, 807, 304, 272, 327, 11606, 26, 1455, 921, 600, 14, 32595, 14, 957, 15, 25200, 15, 1641, 1272, 3129, 15, 272, 283, 11728, 626, 295, 6334, 22470, 1865, 7, 272, 327, 1626, 12623, 1211, 9033, 2883, 370, 1338, 14, 272, 327, 710, 12623, 1211, 6571, 636, 6095, 3108, 636, 552, 3108, 636, 6134, 3108, 436, 664, 14, 272, 327, 710, 7971, 3102, 787, 1865, 13, 14600, 14, 272, 327, 13123, 13, 47, 3879, 5431, 367, 1006, 3102, 787, 314, 2011, 465, 367, 5578, 11196, 14, 339, 327, 710, 5007, 291, 855, 1130, 2600, 9033, 2883, 370, 6220, 315, 282, 28584, 590, 10632, 769, 14, 272, 327, 710, 15032, 28584, 590, 10632, 769, 9174, 436, 11187, 543, 282, 13792, 1819, 14, 272, 327, 710, 13792, 1819, 7078, 7545, 5463, 334, 3749, 17553, 5604, 314, 5563, 680, 272, 327, 7048, 2142, 365, 5489, 465, 282, 769, 402 ]
[ 199, 3, 420, 1898, 334, 35, 9, 6927, 4005, 31155, 13036, 728, 199, 3, 420, 1455, 921, 475, 31155, 14, 2676, 728, 14, 4850, 199, 3, 199, 3, 420, 22016, 367, 481, 12764, 15423, 334, 1643, 15, 7280, 641, 4751, 9, 199, 3, 420, 701, 27864, 598, 1545, 28621, 359, 6304, 7068, 61, 446, 10030, 7068, 14, 5181, 32, 6799, 14, 957, 199, 3, 199, 3, 221, 961, 18841, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 221, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 221, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 221, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 18841, 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, 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, 18841, 27, 1937, 314, 570, 5113, 14, 2424, 14, 221, 982, 440, 12, 2218, 370, 199, 3, 221, 314, 2868, 2290, 2752, 12, 1227, 2194, 603, 405, 437, 432, 12, 445, 455, 9528, 12, 4828, 12497, 7491, 12, 8217, 14, 199, 3, 221, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 1574, 3039, 15, 11692, 14, 1360, 199, 3, 199, 646, 11709, 199, 504, 2748, 14, 9464, 492, 13139, 199, 646, 14196, 199, 646, 747, 199, 646, 11709, 9291, 421, 199, 533, 8271, 83, 3167, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 13553, 304, 267, 340, 334, 442, 8, 9291, 14, 30008, 360, 10788, 14, 2730, 14, 466, 1333, 508, 378, 304, 288, 931, 275, 11709, 14, 5275, 2042, 8, 736, 14, 515, 14, 904, 360, 6664, 921, 2913, 297, 283, 9291, 63, 576, 297, 283, 1579, 14, 264, 685, 5294, 2614, 86, 297, 283, 10788, 18, 14, 2730, 1333, 267, 587, 26, 288, 931, 275, 620, 8, 9291, 14, 30008, 360, 10788, 14, 2730, 14, 493, 1333, 398, 291, 14, 10788, 2842, 275, 14196, 14, 15218, 8, 807, 63, 466, 29, 16882, 9, 267, 291, 14, 10788, 2842, 14, 1422, 24226, 275, 2400, 945, 26, 945, 267, 862, 26, 288, 291, 14, 10788, 2842, 14, 739, 8, 515, 9, 267, 871, 26, 288, 870, 283, 17200, 370, 2198, 21293, 14, 2730, 7, 339, 347, 2248, 38, 1214, 567, 4033, 8, 277, 304, 267, 4811, 275, 769, 342, 267, 931, 275, 11709, 14, 5275, 2042, 8, 736, 14, 515, 14, 904, 360, 6664, 921, 2913, 297, 283, 30763, 567, 4033, 14, 1652, 1333, 267, 340, 747, 14, 515, 14, 2444, 8, 515, 304, 288, 289, 275, 1551, 8, 515, 9, 288, 2748, 275, 289, 14, 739, 342, 288, 289, 14, 1600, 342, 953, 862, 26, 355, 1382, 275, 13139, 14, 13521, 8, 1652, 9, 355, 367, 1031, 315, 1382, 14, 6452, 360, 30763, 567, 1175, 735, 490, 574, 275, 1031, 14, 505, 490, 340, 574, 59, 16, 26, 845, 61, 508, 283, 9651, 11398, 480, 356, 717, 574, 275, 574, 59, 845, 6809, 18, 61, 490, 916, 574, 59, 16, 26, 709, 61, 508, 283, 9651, 11398, 6176, 717, 574, 275, 574, 59, 709, 6809, 17, 61, 490, 916, 574, 59, 16, 26, 1081, 61, 508, 283, 30120, 4301, 8, 1960, 821, 4589, 356, 717, 574, 275, 574, 59, 1081, 6809, 25, 61, 490, 916, 574, 59, 16, 26, 2025, 61, 508, 283, 30120, 4301, 8, 1960, 821, 12, 356, 717, 574, 275, 574, 59, 1081, 6809, 24, 61, 490, 587, 26, 717, 1980, 4951, 4811, 14, 740, 1332, 932, 14, 362, 360, 354, 659, 574, 430, 288, 871, 26, 355, 986, 398, 372, 4811, 339, 347, 664, 1123, 4654, 8, 277, 304, 267, 372, 291, 14, 10788, 2842, 14, 7786, 342, 339, 347, 664, 19654, 19358, 8, 277, 12, 1305, 304, 267, 372, 291, 14, 10788, 2842, 14, 1744, 8, 344, 9, 339, 347, 9696, 3296, 8, 277, 12, 3623, 304, 267, 408, 267, 768, 635, 3623, 26, 267, 768, 466, 3623, 26, 1350, 14, 5358, 267, 408, 267, 289, 1214, 567, 4033, 275, 291, 14, 912, 38, 1214, 567, 4033, 342, 398, 327, 7758, 1104, 289, 1214, 567, 4033, 12, 340, 781, 664, 5835, 1336, 781, 675, 652, 267, 367, 1768, 12, 2547, 315, 289, 1214, 567, 4033, 26, 288, 340, 1768, 508, 3623, 14, 1213, 26, 355, 372, 2547, 7318, 327, 16707, 1104, 1006, 21293, 436, 372, 1006, 4450, 267, 4450, 275, 769, 342, 267, 367, 1305, 315, 291, 14, 362, 1123, 4654, 837, 288, 862, 26, 355, 11709, 9291, 14, 19654, 8, 344, 9, 288, 871, 2186, 26, 355, 1980, 327, 3686, 21293, 626, 787, 440, 4903, 953, 367, 334, 1302, 12, 2547, 9, 315, 291, 14, 362, 19654, 19358, 8, 344, 304, 355, 340, 1768, 508, 3623, 14, 1213, 26, 490, 4450, 14, 740, 1332, 344, 12, 1768, 12, 2547, 430, 398, 340, 822, 8, 6742, 9, 508, 413, 26, 288, 372, 4450, 59, 16, 1527, 18, 61, 267, 587, 26, 288, 372, 4450, 421, 199, 533, 8773, 8, 807, 304, 272, 327, 11606, 26, 1455, 921, 600, 14, 32595, 14, 957, 15, 25200, 15, 1641, 1272, 3129, 15, 272, 283, 11728, 626, 295, 6334, 22470, 1865, 7, 272, 327, 1626, 12623, 1211, 9033, 2883, 370, 1338, 14, 272, 327, 710, 12623, 1211, 6571, 636, 6095, 3108, 636, 552, 3108, 636, 6134, 3108, 436, 664, 14, 272, 327, 710, 7971, 3102, 787, 1865, 13, 14600, 14, 272, 327, 13123, 13, 47, 3879, 5431, 367, 1006, 3102, 787, 314, 2011, 465, 367, 5578, 11196, 14, 339, 327, 710, 5007, 291, 855, 1130, 2600, 9033, 2883, 370, 6220, 315, 282, 28584, 590, 10632, 769, 14, 272, 327, 710, 15032, 28584, 590, 10632, 769, 9174, 436, 11187, 543, 282, 13792, 1819, 14, 272, 327, 710, 13792, 1819, 7078, 7545, 5463, 334, 3749, 17553, 5604, 314, 5563, 680, 272, 327, 7048, 2142, 365, 5489, 465, 282, 769, 402, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
apporc/neutron
neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/test_sriov_nic_agent.py
15
13083
# Copyright 2014 Mellanox Technologies, Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. import mock from oslo_config import cfg from oslo_utils import uuidutils from neutron.plugins.ml2.drivers.mech_sriov.agent.common import config # noqa from neutron.plugins.ml2.drivers.mech_sriov.agent.common import exceptions from neutron.plugins.ml2.drivers.mech_sriov.agent import sriov_nic_agent from neutron.tests import base DEVICE_MAC = '11:22:33:44:55:66' PCI_SLOT = "0000:06:00.1" class TestSriovAgent(base.BaseTestCase): def setUp(self): super(TestSriovAgent, self).setUp() # disable setting up periodic state reporting cfg.CONF.set_override('report_interval', 0, 'AGENT') cfg.CONF.set_default('firewall_driver', 'neutron.agent.firewall.NoopFirewallDriver', group='SECURITYGROUP') cfg.CONF.set_default('enable_security_group', False, group='SECURITYGROUP') class MockFixedIntervalLoopingCall(object): def __init__(self, f): self.f = f def start(self, interval=0): self.f() mock.patch('oslo_service.loopingcall.' 'FixedIntervalLoopingCall', new=MockFixedIntervalLoopingCall) self.agent = sriov_nic_agent.SriovNicSwitchAgent({}, {}, 0) @mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent.pci_lib." "PciDeviceIPWrapper.get_assigned_macs", return_value=[(DEVICE_MAC, PCI_SLOT)]) @mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent." "eswitch_manager.PciOsWrapper.is_assigned_vf", return_value=True) def test_treat_devices_removed_with_existed_device(self, *args): agent = sriov_nic_agent.SriovNicSwitchAgent({}, {}, 0) devices = [(DEVICE_MAC, PCI_SLOT)] with mock.patch.object(agent.plugin_rpc, "update_device_down") as fn_udd: fn_udd.return_value = {'device': DEVICE_MAC, 'exists': True} resync = agent.treat_devices_removed(devices) self.assertFalse(resync) self.assertTrue(fn_udd.called) @mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent.pci_lib." "PciDeviceIPWrapper.get_assigned_macs", return_value=[(DEVICE_MAC, PCI_SLOT)]) @mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent." "eswitch_manager.PciOsWrapper.is_assigned_vf", return_value=True) def test_treat_devices_removed_with_not_existed_device(self, *args): agent = sriov_nic_agent.SriovNicSwitchAgent({}, {}, 0) devices = [(DEVICE_MAC, PCI_SLOT)] with mock.patch.object(agent.plugin_rpc, "update_device_down") as fn_udd: fn_udd.return_value = {'device': DEVICE_MAC, 'exists': False} with mock.patch.object(sriov_nic_agent.LOG, 'debug') as log: resync = agent.treat_devices_removed(devices) self.assertEqual(1, log.call_count) self.assertFalse(resync) self.assertTrue(fn_udd.called) @mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent.pci_lib." "PciDeviceIPWrapper.get_assigned_macs", return_value=[(DEVICE_MAC, PCI_SLOT)]) @mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent." "eswitch_manager.PciOsWrapper.is_assigned_vf", return_value=True) def test_treat_devices_removed_failed(self, *args): agent = sriov_nic_agent.SriovNicSwitchAgent({}, {}, 0) devices = [(DEVICE_MAC, PCI_SLOT)] with mock.patch.object(agent.plugin_rpc, "update_device_down") as fn_udd: fn_udd.side_effect = Exception() with mock.patch.object(sriov_nic_agent.LOG, 'debug') as log: resync = agent.treat_devices_removed(devices) self.assertEqual(1, log.call_count) self.assertTrue(resync) self.assertTrue(fn_udd.called) def mock_scan_devices(self, expected, mock_current, registered_devices, updated_devices): self.agent.eswitch_mgr = mock.Mock() self.agent.eswitch_mgr.get_assigned_devices_info.return_value = ( mock_current) results = self.agent.scan_devices(registered_devices, updated_devices) self.assertEqual(expected, results) def test_scan_devices_returns_empty_sets(self): registered = set() updated = set() mock_current = set() expected = {'current': set(), 'updated': set(), 'added': set(), 'removed': set()} self.mock_scan_devices(expected, mock_current, registered, updated) def test_scan_devices_no_changes(self): registered = set(['1', '2']) updated = set() mock_current = set(['1', '2']) expected = {'current': set(['1', '2']), 'updated': set(), 'added': set(), 'removed': set()} self.mock_scan_devices(expected, mock_current, registered, updated) def test_scan_devices_new_and_removed(self): registered = set(['1', '2']) updated = set() mock_current = set(['2', '3']) expected = {'current': set(['2', '3']), 'updated': set(), 'added': set(['3']), 'removed': set(['1'])} self.mock_scan_devices(expected, mock_current, registered, updated) def test_scan_devices_new_updates(self): registered = set(['1']) updated = set(['2']) mock_current = set(['1', '2']) expected = {'current': set(['1', '2']), 'updated': set(['2']), 'added': set(['2']), 'removed': set()} self.mock_scan_devices(expected, mock_current, registered, updated) def test_scan_devices_updated_missing(self): registered = set(['1']) updated = set(['2']) mock_current = set(['1']) expected = {'current': set(['1']), 'updated': set(), 'added': set(), 'removed': set()} self.mock_scan_devices(expected, mock_current, registered, updated) def test_process_network_devices(self): agent = self.agent device_info = {'current': set(), 'added': set(['mac3', 'mac4']), 'updated': set(['mac2', 'mac3']), 'removed': set(['mac1'])} agent.sg_agent.prepare_devices_filter = mock.Mock() agent.sg_agent.refresh_firewall = mock.Mock() agent.treat_devices_added_updated = mock.Mock(return_value=False) agent.treat_devices_removed = mock.Mock(return_value=False) agent.process_network_devices(device_info) agent.sg_agent.prepare_devices_filter.assert_called_with( set(['mac3', 'mac4'])) self.assertTrue(agent.sg_agent.refresh_firewall.called) agent.treat_devices_added_updated.assert_called_with(set(['mac2', 'mac3', 'mac4'])) agent.treat_devices_removed.assert_called_with(set(['mac1'])) def test_treat_devices_added_updated_admin_state_up_true(self): agent = self.agent mock_details = {'device': 'aa:bb:cc:dd:ee:ff', 'port_id': 'port123', 'network_id': 'net123', 'admin_state_up': True, 'network_type': 'vlan', 'segmentation_id': 100, 'profile': {'pci_slot': '1:2:3.0'}, 'physical_network': 'physnet1', 'port_security_enabled': False} agent.plugin_rpc = mock.Mock() agent.plugin_rpc.get_devices_details_list.return_value = [mock_details] agent.eswitch_mgr = mock.Mock() agent.eswitch_mgr.device_exists.return_value = True agent.set_device_state = mock.Mock() agent.set_device_spoofcheck = mock.Mock() resync_needed = agent.treat_devices_added_updated( set(['aa:bb:cc:dd:ee:ff'])) self.assertFalse(resync_needed) agent.eswitch_mgr.device_exists.assert_called_with('aa:bb:cc:dd:ee:ff', '1:2:3.0') agent.eswitch_mgr.set_device_state.assert_called_with( 'aa:bb:cc:dd:ee:ff', '1:2:3.0', True) agent.eswitch_mgr.set_device_spoofcheck.assert_called_with( 'aa:bb:cc:dd:ee:ff', '1:2:3.0', False) self.assertTrue(agent.plugin_rpc.update_device_up.called) def test_treat_device_ip_link_state_not_supported(self): agent = self.agent agent.plugin_rpc = mock.Mock() agent.eswitch_mgr = mock.Mock() agent.eswitch_mgr.device_exists.return_value = True agent.eswitch_mgr.set_device_state.side_effect = ( exceptions.IpCommandOperationNotSupportedError( dev_name='aa:bb:cc:dd:ee:ff')) agent.treat_device('aa:bb:cc:dd:ee:ff', '1:2:3:0', admin_state_up=True) self.assertTrue(agent.plugin_rpc.update_device_up.called) def test_treat_device_set_device_state_exception(self): agent = self.agent agent.plugin_rpc = mock.Mock() agent.eswitch_mgr = mock.Mock() agent.eswitch_mgr.device_exists.return_value = True agent.eswitch_mgr.set_device_state.side_effect = ( exceptions.SriovNicError()) agent.treat_device('aa:bb:cc:dd:ee:ff', '1:2:3:0', admin_state_up=True) self.assertFalse(agent.plugin_rpc.update_device_up.called) def test_treat_devices_added_updated_admin_state_up_false(self): agent = self.agent mock_details = {'device': 'aa:bb:cc:dd:ee:ff', 'port_id': 'port123', 'network_id': 'net123', 'admin_state_up': False, 'network_type': 'vlan', 'segmentation_id': 100, 'profile': {'pci_slot': '1:2:3.0'}, 'physical_network': 'physnet1'} agent.plugin_rpc = mock.Mock() agent.plugin_rpc.get_devices_details_list.return_value = [mock_details] agent.remove_port_binding = mock.Mock() resync_needed = agent.treat_devices_added_updated( set(['aa:bb:cc:dd:ee:ff'])) self.assertFalse(resync_needed) self.assertFalse(agent.plugin_rpc.update_device_up.called) class FakeAgent(object): def __init__(self): self.updated_devices = set() class TestSriovNicSwitchRpcCallbacks(base.BaseTestCase): def setUp(self): super(TestSriovNicSwitchRpcCallbacks, self).setUp() self.context = object() self.agent = FakeAgent() sg_agent = object() self.sriov_rpc_callback = sriov_nic_agent.SriovNicSwitchRpcCallbacks( self.context, self.agent, sg_agent) def _create_fake_port(self): return {'id': uuidutils.generate_uuid(), 'binding:profile': {'pci_slot': PCI_SLOT}, 'mac_address': DEVICE_MAC} def test_port_update_with_pci_slot(self): port = self._create_fake_port() kwargs = {'context': self.context, 'port': port} self.sriov_rpc_callback.port_update(**kwargs) self.assertEqual(set([(DEVICE_MAC, PCI_SLOT)]), self.agent.updated_devices) def test_port_update_without_pci_slot(self): port = self._create_fake_port() port['binding:profile'] = None kwargs = {'context': self.context, 'port': port} self.sriov_rpc_callback.port_update(**kwargs) self.assertEqual(set(), self.agent.updated_devices)
apache-2.0
[ 3, 1898, 6927, 603, 352, 1502, 19131, 19215, 12, 12126, 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, 421, 199, 646, 1683, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 1208, 492, 5377, 1208, 199, 199, 504, 8224, 14, 5265, 14, 757, 18, 14, 13337, 14, 278, 335, 63, 83, 322, 8822, 14, 4054, 14, 2330, 492, 1101, 221, 327, 8151, 199, 504, 8224, 14, 5265, 14, 757, 18, 14, 13337, 14, 278, 335, 63, 83, 322, 8822, 14, 4054, 14, 2330, 492, 4967, 199, 504, 8224, 14, 5265, 14, 757, 18, 14, 13337, 14, 278, 335, 63, 83, 322, 8822, 14, 4054, 492, 308, 322, 8822, 63, 12165, 63, 4054, 199, 504, 8224, 14, 2219, 492, 1300, 199, 199, 10555, 63, 9410, 275, 283, 845, 26, 1081, 26, 1153, 26, 1602, 26, 1229, 26, 1272, 7, 199, 23905, 63, 32328, 275, 298, 993, 26, 1690, 26, 383, 14, 17, 2, 421, 199, 533, 1379, 51, 322, 8822, 7788, 8, 1095, 14, 20760, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 51, 322, 8822, 7788, 12, 291, 680, 5996, 342, 267, 327, 3507, 4260, 1536, 18745, 1174, 17290, 267, 4810, 14, 3103, 14, 409, 63, 4415, 360, 3070, 63, 4284, 297, 378, 12, 283, 14565, 358, 267, 4810, 14, 3103, 14, 409, 63, 885, 360, 10794, 63, 3090, 297, 2490, 283, 10271, 14, 4054, 14, 10794, 14, 1944, 411, 24260, 6158, 297, 2490, 1572, 534, 13554, 7823, 358, 267, 4810, 14, 3103, 14, 409, 63, 885, 360, 4296, 63, 4416, 63, 923, 297, 2490, 756, 12, 2490, 1572, 534, 13554, 7823, 358, 398, 1021, 4420, 9515, 8227, 7382, 316, 2176, 8, 785, 304, 288, 347, 636, 826, 721, 277, 12, 289, 304, 355, 291, 14, 70, 275, 289, 953, 347, 1343, 8, 277, 12, 6252, 29, 16, 304, 355, 291, 14, 70, 342, 398, 1683, 14, 2068, 360, 736, 320, 63, 1364, 14, 3813, 316, 1250, 3530, 673, 283, 9515, 8227, 7382, 316, 2176, 297, 673, 892, 29, 3346, 9515, 8227, 7382, 316, 2176, 9, 398, 291, 14, 4054, 275, 308, 322, 8822, 63, 12165, 63, 4054, 14, 51, 322, 8822, 46, 530, 10167, 7788, 16037, 5479, 378, 9, 339, 768, 1805, 14, 2068, 480, 10271, 14, 5265, 14, 757, 18, 14, 13337, 14, 278, 335, 63, 83, 322, 8822, 14, 4054, 14, 12024, 63, 773, 2122, 355, 298, 23246, 2510, 1772, 4590, 14, 362, 63, 12941, 63, 19309, 401, 355, 372, 63, 585, 17497, 10555, 63, 9410, 12, 510, 3553, 63, 32328, 3948, 272, 768, 1805, 14, 2068, 480, 10271, 14, 5265, 14, 757, 18, 14, 13337, 14, 278, 335, 63, 83, 322, 8822, 14, 4054, 2122, 355, 298, 397, 3111, 63, 2609, 14, 23246, 24351, 4590, 14, 374, 63, 12941, 63, 19963, 401, 355, 372, 63, 585, 29, 549, 9, 272, 347, 511, 63, 84, 8319, 63, 6410, 63, 10649, 63, 1045, 63, 476, 4957, 63, 1782, 8, 277, 12, 627, 589, 304, 267, 6631, 275, 308, 322, 8822, 63, 12165, 63, 4054, 14, 51, 322, 8822, 46, 530, 10167, 7788, 16037, 5479, 378, 9, 267, 7256, 275, 3842, 10555, 63, 9410, 12, 510, 3553, 63, 32328, 1874, 267, 543, 1683, 14, 2068, 14, 785, 8, 4054, 14, 2718, 63, 4354, 12, 3044, 298, 873, 63, 1782, 63, 2110, 531, 465, 4325, 63, 8615, 26, 288, 4325, 63, 8615, 14, 1107, 63, 585, 275, 791, 1782, 356, 11643, 63, 9410, 12, 3521, 283, 2444, 356, 715, 93, 288, 522, 1870, 275, 6631, 14, 84, 8319, 63, 6410, 63, 10649, 8, 6410, 9, 288, 291, 14, 3334, 8, 470, 1870, 9, 288, 291, 14, 1815, 8, 2324, 63, 8615, 14, 3527, 9, 339, 768, 1805, 14, 2068, 480, 10271, 14, 5265, 14, 757, 18, 14, 13337, 14, 278, 335, 63, 83, 322, 8822, 14, 4054, 14, 12024, 63, 773, 2122, 355, 298, 23246, 2510, 1772, 4590, 14, 362, 63, 12941, 63, 19309, 401, 355, 372, 63, 585, 17497, 10555, 63, 9410, 12, 510, 3553, 63, 32328, 3948, 272, 768, 1805, 14, 2068, 480, 10271, 14, 5265, 14, 757, 18, 14, 13337, 14, 278, 335, 63, 83, 322, 8822, 14, 4054, 2122, 355, 298, 397, 3111, 63, 2609, 14, 23246, 24351, 4590, 14, 374, 63, 12941, 63, 19963, 401, 355, 372, 63, 585, 29, 549, 9, 272, 347, 511, 63, 84, 8319, 63, 6410, 63, 10649, 63, 1045, 63, 1397, 63, 476, 4957, 63, 1782, 8, 277, 12, 627, 589, 304, 267, 6631, 275, 308, 322, 8822, 63, 12165, 63, 4054, 14, 51, 322, 8822, 46, 530, 10167, 7788, 16037, 5479, 378, 9, 267, 7256, 275, 3842, 10555, 63, 9410, 12, 510, 3553, 63, 32328, 1874, 267, 543, 1683, 14, 2068, 14, 785, 8, 4054, 14, 2718, 63, 4354, 12, 3044, 298, 873, 63, 1782, 63, 2110, 531, 465, 4325, 63, 8615, 26, 288, 4325, 63, 8615, 14, 1107, 63, 585, 275, 791, 1782, 356, 11643, 63, 9410, 12, 3521, 283, 2444, 356, 756, 93, 288, 543, 1683, 14, 2068, 14, 785, 8, 83, 322, 8822, 63, 12165, 63, 4054, 14, 4947, 12, 3521, 283, 1757, 358, 465, 943, 26, 355, 522, 1870, 275, 6631, 14, 84, 8319, 63, 6410, 63, 10649, 8, 6410, 9, 355, 291, 14, 629, 8, 17, 12, 943, 14, 1250, 63, 835, 9, 355, 291, 14, 3334, 8, 470, 1870, 9, 355, 291, 14, 1815, 8, 2324, 63, 8615, 14, 3527, 9, 339, 768, 1805, 14, 2068, 480 ]
[ 1898, 6927, 603, 352, 1502, 19131, 19215, 12, 12126, 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, 421, 199, 646, 1683, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 1208, 492, 5377, 1208, 199, 199, 504, 8224, 14, 5265, 14, 757, 18, 14, 13337, 14, 278, 335, 63, 83, 322, 8822, 14, 4054, 14, 2330, 492, 1101, 221, 327, 8151, 199, 504, 8224, 14, 5265, 14, 757, 18, 14, 13337, 14, 278, 335, 63, 83, 322, 8822, 14, 4054, 14, 2330, 492, 4967, 199, 504, 8224, 14, 5265, 14, 757, 18, 14, 13337, 14, 278, 335, 63, 83, 322, 8822, 14, 4054, 492, 308, 322, 8822, 63, 12165, 63, 4054, 199, 504, 8224, 14, 2219, 492, 1300, 199, 199, 10555, 63, 9410, 275, 283, 845, 26, 1081, 26, 1153, 26, 1602, 26, 1229, 26, 1272, 7, 199, 23905, 63, 32328, 275, 298, 993, 26, 1690, 26, 383, 14, 17, 2, 421, 199, 533, 1379, 51, 322, 8822, 7788, 8, 1095, 14, 20760, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 51, 322, 8822, 7788, 12, 291, 680, 5996, 342, 267, 327, 3507, 4260, 1536, 18745, 1174, 17290, 267, 4810, 14, 3103, 14, 409, 63, 4415, 360, 3070, 63, 4284, 297, 378, 12, 283, 14565, 358, 267, 4810, 14, 3103, 14, 409, 63, 885, 360, 10794, 63, 3090, 297, 2490, 283, 10271, 14, 4054, 14, 10794, 14, 1944, 411, 24260, 6158, 297, 2490, 1572, 534, 13554, 7823, 358, 267, 4810, 14, 3103, 14, 409, 63, 885, 360, 4296, 63, 4416, 63, 923, 297, 2490, 756, 12, 2490, 1572, 534, 13554, 7823, 358, 398, 1021, 4420, 9515, 8227, 7382, 316, 2176, 8, 785, 304, 288, 347, 636, 826, 721, 277, 12, 289, 304, 355, 291, 14, 70, 275, 289, 953, 347, 1343, 8, 277, 12, 6252, 29, 16, 304, 355, 291, 14, 70, 342, 398, 1683, 14, 2068, 360, 736, 320, 63, 1364, 14, 3813, 316, 1250, 3530, 673, 283, 9515, 8227, 7382, 316, 2176, 297, 673, 892, 29, 3346, 9515, 8227, 7382, 316, 2176, 9, 398, 291, 14, 4054, 275, 308, 322, 8822, 63, 12165, 63, 4054, 14, 51, 322, 8822, 46, 530, 10167, 7788, 16037, 5479, 378, 9, 339, 768, 1805, 14, 2068, 480, 10271, 14, 5265, 14, 757, 18, 14, 13337, 14, 278, 335, 63, 83, 322, 8822, 14, 4054, 14, 12024, 63, 773, 2122, 355, 298, 23246, 2510, 1772, 4590, 14, 362, 63, 12941, 63, 19309, 401, 355, 372, 63, 585, 17497, 10555, 63, 9410, 12, 510, 3553, 63, 32328, 3948, 272, 768, 1805, 14, 2068, 480, 10271, 14, 5265, 14, 757, 18, 14, 13337, 14, 278, 335, 63, 83, 322, 8822, 14, 4054, 2122, 355, 298, 397, 3111, 63, 2609, 14, 23246, 24351, 4590, 14, 374, 63, 12941, 63, 19963, 401, 355, 372, 63, 585, 29, 549, 9, 272, 347, 511, 63, 84, 8319, 63, 6410, 63, 10649, 63, 1045, 63, 476, 4957, 63, 1782, 8, 277, 12, 627, 589, 304, 267, 6631, 275, 308, 322, 8822, 63, 12165, 63, 4054, 14, 51, 322, 8822, 46, 530, 10167, 7788, 16037, 5479, 378, 9, 267, 7256, 275, 3842, 10555, 63, 9410, 12, 510, 3553, 63, 32328, 1874, 267, 543, 1683, 14, 2068, 14, 785, 8, 4054, 14, 2718, 63, 4354, 12, 3044, 298, 873, 63, 1782, 63, 2110, 531, 465, 4325, 63, 8615, 26, 288, 4325, 63, 8615, 14, 1107, 63, 585, 275, 791, 1782, 356, 11643, 63, 9410, 12, 3521, 283, 2444, 356, 715, 93, 288, 522, 1870, 275, 6631, 14, 84, 8319, 63, 6410, 63, 10649, 8, 6410, 9, 288, 291, 14, 3334, 8, 470, 1870, 9, 288, 291, 14, 1815, 8, 2324, 63, 8615, 14, 3527, 9, 339, 768, 1805, 14, 2068, 480, 10271, 14, 5265, 14, 757, 18, 14, 13337, 14, 278, 335, 63, 83, 322, 8822, 14, 4054, 14, 12024, 63, 773, 2122, 355, 298, 23246, 2510, 1772, 4590, 14, 362, 63, 12941, 63, 19309, 401, 355, 372, 63, 585, 17497, 10555, 63, 9410, 12, 510, 3553, 63, 32328, 3948, 272, 768, 1805, 14, 2068, 480, 10271, 14, 5265, 14, 757, 18, 14, 13337, 14, 278, 335, 63, 83, 322, 8822, 14, 4054, 2122, 355, 298, 397, 3111, 63, 2609, 14, 23246, 24351, 4590, 14, 374, 63, 12941, 63, 19963, 401, 355, 372, 63, 585, 29, 549, 9, 272, 347, 511, 63, 84, 8319, 63, 6410, 63, 10649, 63, 1045, 63, 1397, 63, 476, 4957, 63, 1782, 8, 277, 12, 627, 589, 304, 267, 6631, 275, 308, 322, 8822, 63, 12165, 63, 4054, 14, 51, 322, 8822, 46, 530, 10167, 7788, 16037, 5479, 378, 9, 267, 7256, 275, 3842, 10555, 63, 9410, 12, 510, 3553, 63, 32328, 1874, 267, 543, 1683, 14, 2068, 14, 785, 8, 4054, 14, 2718, 63, 4354, 12, 3044, 298, 873, 63, 1782, 63, 2110, 531, 465, 4325, 63, 8615, 26, 288, 4325, 63, 8615, 14, 1107, 63, 585, 275, 791, 1782, 356, 11643, 63, 9410, 12, 3521, 283, 2444, 356, 756, 93, 288, 543, 1683, 14, 2068, 14, 785, 8, 83, 322, 8822, 63, 12165, 63, 4054, 14, 4947, 12, 3521, 283, 1757, 358, 465, 943, 26, 355, 522, 1870, 275, 6631, 14, 84, 8319, 63, 6410, 63, 10649, 8, 6410, 9, 355, 291, 14, 629, 8, 17, 12, 943, 14, 1250, 63, 835, 9, 355, 291, 14, 3334, 8, 470, 1870, 9, 355, 291, 14, 1815, 8, 2324, 63, 8615, 14, 3527, 9, 339, 768, 1805, 14, 2068, 480, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sv-dev1/odoo
addons/project_issue/project_issue.py
217
29319
#-*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from datetime import datetime from openerp import api from openerp import SUPERUSER_ID from openerp import tools from openerp.osv import fields, osv, orm from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT from openerp.tools import html2plaintext from openerp.tools.translate import _ class project_issue_version(osv.Model): _name = "project.issue.version" _order = "name desc" _columns = { 'name': fields.char('Version Number', required=True), 'active': fields.boolean('Active', required=False), } _defaults = { 'active': 1, } class project_issue(osv.Model): _name = "project.issue" _description = "Project Issue" _order = "priority desc, create_date desc" _inherit = ['mail.thread', 'ir.needaction_mixin'] _mail_post_access = 'read' _track = { 'stage_id': { # this is only an heuristics; depending on your particular stage configuration it may not match all 'new' stages 'project_issue.mt_issue_new': lambda self, cr, uid, obj, ctx=None: obj.stage_id and obj.stage_id.sequence <= 1, 'project_issue.mt_issue_stage': lambda self, cr, uid, obj, ctx=None: obj.stage_id and obj.stage_id.sequence > 1, }, 'user_id': { 'project_issue.mt_issue_assigned': lambda self, cr, uid, obj, ctx=None: obj.user_id and obj.user_id.id, }, 'kanban_state': { 'project_issue.mt_issue_blocked': lambda self, cr, uid, obj, ctx=None: obj.kanban_state == 'blocked', 'project_issue.mt_issue_ready': lambda self, cr, uid, obj, ctx=None: obj.kanban_state == 'done', }, } def _get_default_partner(self, cr, uid, context=None): project_id = self._get_default_project_id(cr, uid, context) if project_id: project = self.pool.get('project.project').browse(cr, uid, project_id, context=context) if project and project.partner_id: return project.partner_id.id return False def _get_default_project_id(self, cr, uid, context=None): """ Gives default project by checking if present in the context """ return self._resolve_project_id_from_context(cr, uid, context=context) def _get_default_stage_id(self, cr, uid, context=None): """ Gives default stage_id """ project_id = self._get_default_project_id(cr, uid, context=context) return self.stage_find(cr, uid, [], project_id, [('fold', '=', False)], context=context) def _resolve_project_id_from_context(self, cr, uid, context=None): """ Returns ID of project based on the value of 'default_project_id' context key, or None if it cannot be resolved to a single project. """ if context is None: context = {} if type(context.get('default_project_id')) in (int, long): return context.get('default_project_id') if isinstance(context.get('default_project_id'), basestring): project_name = context['default_project_id'] project_ids = self.pool.get('project.project').name_search(cr, uid, name=project_name, context=context) if len(project_ids) == 1: return int(project_ids[0][0]) return None def _read_group_stage_ids(self, cr, uid, ids, domain, read_group_order=None, access_rights_uid=None, context=None): access_rights_uid = access_rights_uid or uid stage_obj = self.pool.get('project.task.type') order = stage_obj._order # lame hack to allow reverting search, should just work in the trivial case if read_group_order == 'stage_id desc': order = "%s desc" % order # retrieve section_id from the context and write the domain # - ('id', 'in', 'ids'): add columns that should be present # - OR ('case_default', '=', True), ('fold', '=', False): add default columns that are not folded # - OR ('project_ids', 'in', project_id), ('fold', '=', False) if project_id: add project columns that are not folded search_domain = [] project_id = self._resolve_project_id_from_context(cr, uid, context=context) if project_id: search_domain += ['|', ('project_ids', '=', project_id)] search_domain += [('id', 'in', ids)] # perform search stage_ids = stage_obj._search(cr, uid, search_domain, order=order, access_rights_uid=access_rights_uid, context=context) result = stage_obj.name_get(cr, access_rights_uid, stage_ids, context=context) # restore order of the search result.sort(lambda x,y: cmp(stage_ids.index(x[0]), stage_ids.index(y[0]))) fold = {} for stage in stage_obj.browse(cr, access_rights_uid, stage_ids, context=context): fold[stage.id] = stage.fold or False return result, fold def _compute_day(self, cr, uid, ids, fields, args, context=None): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Openday’s IDs @return: difference between current date and log date @param context: A standard dictionary for contextual values """ Calendar = self.pool['resource.calendar'] res = dict((res_id, {}) for res_id in ids) for issue in self.browse(cr, uid, ids, context=context): values = { 'day_open': 0.0, 'day_close': 0.0, 'working_hours_open': 0.0, 'working_hours_close': 0.0, 'days_since_creation': 0.0, 'inactivity_days': 0.0, } # if the working hours on the project are not defined, use default ones (8 -> 12 and 13 -> 17 * 5), represented by None calendar_id = None if issue.project_id and issue.project_id.resource_calendar_id: calendar_id = issue.project_id.resource_calendar_id.id dt_create_date = datetime.strptime(issue.create_date, DEFAULT_SERVER_DATETIME_FORMAT) if issue.date_open: dt_date_open = datetime.strptime(issue.date_open, DEFAULT_SERVER_DATETIME_FORMAT) values['day_open'] = (dt_date_open - dt_create_date).total_seconds() / (24.0 * 3600) values['working_hours_open'] = Calendar._interval_hours_get( cr, uid, calendar_id, dt_create_date, dt_date_open, timezone_from_uid=issue.user_id.id or uid, exclude_leaves=False, context=context) if issue.date_closed: dt_date_closed = datetime.strptime(issue.date_closed, DEFAULT_SERVER_DATETIME_FORMAT) values['day_close'] = (dt_date_closed - dt_create_date).total_seconds() / (24.0 * 3600) values['working_hours_close'] = Calendar._interval_hours_get( cr, uid, calendar_id, dt_create_date, dt_date_closed, timezone_from_uid=issue.user_id.id or uid, exclude_leaves=False, context=context) days_since_creation = datetime.today() - dt_create_date values['days_since_creation'] = days_since_creation.days if issue.date_action_last: inactive_days = datetime.today() - datetime.strptime(issue.date_action_last, DEFAULT_SERVER_DATETIME_FORMAT) elif issue.date_last_stage_update: inactive_days = datetime.today() - datetime.strptime(issue.date_last_stage_update, DEFAULT_SERVER_DATETIME_FORMAT) else: inactive_days = datetime.today() - datetime.strptime(issue.create_date, DEFAULT_SERVER_DATETIME_FORMAT) values['inactivity_days'] = inactive_days.days # filter only required values for field in fields: res[issue.id][field] = values[field] return res def _hours_get(self, cr, uid, ids, field_names, args, context=None): task_pool = self.pool.get('project.task') res = {} for issue in self.browse(cr, uid, ids, context=context): progress = 0.0 if issue.task_id: progress = task_pool._hours_get(cr, uid, [issue.task_id.id], field_names, args, context=context)[issue.task_id.id]['progress'] res[issue.id] = {'progress' : progress} return res def on_change_project(self, cr, uid, ids, project_id, context=None): if project_id: project = self.pool.get('project.project').browse(cr, uid, project_id, context=context) if project and project.partner_id: return {'value': {'partner_id': project.partner_id.id}} return {} def _get_issue_task(self, cr, uid, ids, context=None): issues = [] issue_pool = self.pool.get('project.issue') for task in self.pool.get('project.task').browse(cr, uid, ids, context=context): issues += issue_pool.search(cr, uid, [('task_id','=',task.id)]) return issues def _get_issue_work(self, cr, uid, ids, context=None): issues = [] issue_pool = self.pool.get('project.issue') for work in self.pool.get('project.task.work').browse(cr, uid, ids, context=context): if work.task_id: issues += issue_pool.search(cr, uid, [('task_id','=',work.task_id.id)]) return issues _columns = { 'id': fields.integer('ID', readonly=True), 'name': fields.char('Issue', required=True), 'active': fields.boolean('Active', required=False), 'create_date': fields.datetime('Creation Date', readonly=True, select=True), 'write_date': fields.datetime('Update Date', readonly=True), 'days_since_creation': fields.function(_compute_day, string='Days since creation date', \ multi='compute_day', type="integer", help="Difference in days between creation date and current date"), 'date_deadline': fields.date('Deadline'), 'section_id': fields.many2one('crm.case.section', 'Sales Team', \ select=True, help='Sales team to which Case belongs to.\ Define Responsible user and Email account for mail gateway.'), 'partner_id': fields.many2one('res.partner', 'Contact', select=1), 'company_id': fields.many2one('res.company', 'Company'), 'description': fields.text('Private Note'), 'kanban_state': fields.selection([('normal', 'Normal'),('blocked', 'Blocked'),('done', 'Ready for next stage')], 'Kanban State', track_visibility='onchange', help="A Issue's kanban state indicates special situations affecting it:\n" " * Normal is the default situation\n" " * Blocked indicates something is preventing the progress of this issue\n" " * Ready for next stage indicates the issue is ready to be pulled to the next stage", required=False), 'email_from': fields.char('Email', size=128, help="These people will receive email.", select=1), 'email_cc': fields.char('Watchers Emails', size=256, help="These email addresses will be added to the CC field of all inbound and outbound emails for this record before being sent. Separate multiple email addresses with a comma"), 'date_open': fields.datetime('Assigned', readonly=True, select=True), # Project Issue fields 'date_closed': fields.datetime('Closed', readonly=True, select=True), 'date': fields.datetime('Date'), 'date_last_stage_update': fields.datetime('Last Stage Update', select=True), 'channel': fields.char('Channel', help="Communication channel."), 'categ_ids': fields.many2many('project.category', string='Tags'), 'priority': fields.selection([('0','Low'), ('1','Normal'), ('2','High')], 'Priority', select=True), 'version_id': fields.many2one('project.issue.version', 'Version'), 'stage_id': fields.many2one ('project.task.type', 'Stage', track_visibility='onchange', select=True, domain="[('project_ids', '=', project_id)]", copy=False), 'project_id': fields.many2one('project.project', 'Project', track_visibility='onchange', select=True), 'duration': fields.float('Duration'), 'task_id': fields.many2one('project.task', 'Task', domain="[('project_id','=',project_id)]"), 'day_open': fields.function(_compute_day, string='Days to Assign', multi='compute_day', type="float", store={'project.issue': (lambda self, cr, uid, ids, c={}: ids, ['date_open'], 10)}), 'day_close': fields.function(_compute_day, string='Days to Close', multi='compute_day', type="float", store={'project.issue': (lambda self, cr, uid, ids, c={}: ids, ['date_closed'], 10)}), 'user_id': fields.many2one('res.users', 'Assigned to', required=False, select=1, track_visibility='onchange'), 'working_hours_open': fields.function(_compute_day, string='Working Hours to assign the Issue', multi='compute_day', type="float", store={'project.issue': (lambda self, cr, uid, ids, c={}: ids, ['date_open'], 10)}), 'working_hours_close': fields.function(_compute_day, string='Working Hours to close the Issue', multi='compute_day', type="float", store={'project.issue': (lambda self, cr, uid, ids, c={}: ids, ['date_closed'], 10)}), 'inactivity_days': fields.function(_compute_day, string='Days since last action', multi='compute_day', type="integer", help="Difference in days between last action and current date"), 'color': fields.integer('Color Index'), 'user_email': fields.related('user_id', 'email', type='char', string='User Email', readonly=True), 'date_action_last': fields.datetime('Last Action', readonly=1), 'date_action_next': fields.datetime('Next Action', readonly=1), 'progress': fields.function(_hours_get, string='Progress (%)', multi='hours', group_operator="avg", help="Computed as: Time Spent / Total Time.", store = { 'project.issue': (lambda self, cr, uid, ids, c={}: ids, ['task_id'], 10), 'project.task': (_get_issue_task, ['work_ids', 'remaining_hours', 'planned_hours', 'state', 'stage_id'], 10), 'project.task.work': (_get_issue_work, ['hours'], 10), }), } _defaults = { 'active': 1, 'stage_id': lambda s, cr, uid, c: s._get_default_stage_id(cr, uid, c), 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.helpdesk', context=c), 'priority': '0', 'kanban_state': 'normal', 'date_last_stage_update': fields.datetime.now, 'user_id': lambda obj, cr, uid, context: uid, } _group_by_full = { 'stage_id': _read_group_stage_ids } def copy(self, cr, uid, id, default=None, context=None): issue = self.read(cr, uid, [id], ['name'], context=context)[0] if not default: default = {} default = default.copy() default.update(name=_('%s (copy)') % (issue['name'])) return super(project_issue, self).copy(cr, uid, id, default=default, context=context) def create(self, cr, uid, vals, context=None): context = dict(context or {}) if vals.get('project_id') and not context.get('default_project_id'): context['default_project_id'] = vals.get('project_id') if vals.get('user_id'): vals['date_open'] = fields.datetime.now() if 'stage_id' in vals: vals.update(self.onchange_stage_id(cr, uid, None, vals.get('stage_id'), context=context)['value']) # context: no_log, because subtype already handle this create_context = dict(context, mail_create_nolog=True) return super(project_issue, self).create(cr, uid, vals, context=create_context) def write(self, cr, uid, ids, vals, context=None): # stage change: update date_last_stage_update if 'stage_id' in vals: vals.update(self.onchange_stage_id(cr, uid, ids, vals.get('stage_id'), context=context)['value']) vals['date_last_stage_update'] = fields.datetime.now() if 'kanban_state' not in vals: vals['kanban_state'] = 'normal' # user_id change: update date_start if vals.get('user_id'): vals['date_open'] = fields.datetime.now() return super(project_issue, self).write(cr, uid, ids, vals, context) def onchange_task_id(self, cr, uid, ids, task_id, context=None): if not task_id: return {'value': {}} task = self.pool.get('project.task').browse(cr, uid, task_id, context=context) return {'value': {'user_id': task.user_id.id, }} def onchange_partner_id(self, cr, uid, ids, partner_id, context=None): """ This function returns value of partner email address based on partner :param part: Partner's id """ result = {} if partner_id: partner = self.pool['res.partner'].browse(cr, uid, partner_id, context) result['email_from'] = partner.email return {'value': result} def get_empty_list_help(self, cr, uid, help, context=None): context = dict(context or {}) context['empty_list_help_model'] = 'project.project' context['empty_list_help_id'] = context.get('default_project_id') context['empty_list_help_document_name'] = _("issues") return super(project_issue, self).get_empty_list_help(cr, uid, help, context=context) # ------------------------------------------------------- # Stage management # ------------------------------------------------------- def onchange_stage_id(self, cr, uid, ids, stage_id, context=None): if not stage_id: return {'value': {}} stage = self.pool['project.task.type'].browse(cr, uid, stage_id, context=context) if stage.fold: return {'value': {'date_closed': fields.datetime.now()}} return {'value': {'date_closed': False}} def stage_find(self, cr, uid, cases, section_id, domain=[], order='sequence', context=None): """ Override of the base.stage method Parameter of the stage search taken from the issue: - type: stage type must be the same or 'both' - section_id: if set, stages must belong to this section or be a default case """ if isinstance(cases, (int, long)): cases = self.browse(cr, uid, cases, context=context) # collect all section_ids section_ids = [] if section_id: section_ids.append(section_id) for task in cases: if task.project_id: section_ids.append(task.project_id.id) # OR all section_ids and OR with case_default search_domain = [] if section_ids: search_domain += [('|')] * (len(section_ids)-1) for section_id in section_ids: search_domain.append(('project_ids', '=', section_id)) search_domain += list(domain) # perform search, return the first found stage_ids = self.pool.get('project.task.type').search(cr, uid, search_domain, order=order, context=context) if stage_ids: return stage_ids[0] return False def case_escalate(self, cr, uid, ids, context=None): # FIXME rename this method to issue_escalate for issue in self.browse(cr, uid, ids, context=context): data = {} esc_proj = issue.project_id.project_escalation_id if not esc_proj: raise osv.except_osv(_('Warning!'), _('You cannot escalate this issue.\nThe relevant Project has not configured the Escalation Project!')) data['project_id'] = esc_proj.id if esc_proj.user_id: data['user_id'] = esc_proj.user_id.id issue.write(data) if issue.task_id: issue.task_id.write({'project_id': esc_proj.id, 'user_id': False}) return True # ------------------------------------------------------- # Mail gateway # ------------------------------------------------------- def message_get_reply_to(self, cr, uid, ids, context=None): """ Override to get the reply_to of the parent project. """ issues = self.browse(cr, SUPERUSER_ID, ids, context=context) project_ids = set([issue.project_id.id for issue in issues if issue.project_id]) aliases = self.pool['project.project'].message_get_reply_to(cr, uid, list(project_ids), context=context) return dict((issue.id, aliases.get(issue.project_id and issue.project_id.id or 0, False)) for issue in issues) def message_get_suggested_recipients(self, cr, uid, ids, context=None): recipients = super(project_issue, self).message_get_suggested_recipients(cr, uid, ids, context=context) try: for issue in self.browse(cr, uid, ids, context=context): if issue.partner_id: self._message_add_suggested_recipient(cr, uid, recipients, issue, partner=issue.partner_id, reason=_('Customer')) elif issue.email_from: self._message_add_suggested_recipient(cr, uid, recipients, issue, email=issue.email_from, reason=_('Customer Email')) except (osv.except_osv, orm.except_orm): # no read access rights -> just ignore suggested recipients because this imply modifying followers pass return recipients def message_new(self, cr, uid, msg, custom_values=None, context=None): """ Overrides mail_thread message_new that is called by the mailgateway through message_process. This override updates the document according to the email. """ if custom_values is None: custom_values = {} context = dict(context or {}, state_to='draft') defaults = { 'name': msg.get('subject') or _("No Subject"), 'email_from': msg.get('from'), 'email_cc': msg.get('cc'), 'partner_id': msg.get('author_id', False), 'user_id': False, } defaults.update(custom_values) res_id = super(project_issue, self).message_new(cr, uid, msg, custom_values=defaults, context=context) return res_id @api.cr_uid_ids_context def message_post(self, cr, uid, thread_id, body='', subject=None, type='notification', subtype=None, parent_id=False, attachments=None, context=None, content_subtype='html', **kwargs): """ Overrides mail_thread message_post so that we can set the date of last action field when a new message is posted on the issue. """ if context is None: context = {} res = super(project_issue, self).message_post(cr, uid, thread_id, body=body, subject=subject, type=type, subtype=subtype, parent_id=parent_id, attachments=attachments, context=context, content_subtype=content_subtype, **kwargs) if thread_id and subtype: self.write(cr, SUPERUSER_ID, thread_id, {'date_action_last': fields.datetime.now()}, context=context) return res class project(osv.Model): _inherit = "project.project" def _get_alias_models(self, cr, uid, context=None): return [('project.task', "Tasks"), ("project.issue", "Issues")] def _issue_count(self, cr, uid, ids, field_name, arg, context=None): Issue = self.pool['project.issue'] return { project_id: Issue.search_count(cr,uid, [('project_id', '=', project_id), ('stage_id.fold', '=', False)], context=context) for project_id in ids } _columns = { 'project_escalation_id': fields.many2one('project.project', 'Project Escalation', help='If any issue is escalated from the current Project, it will be listed under the project selected here.', states={'close': [('readonly', True)], 'cancelled': [('readonly', True)]}), 'issue_count': fields.function(_issue_count, type='integer', string="Issues",), 'issue_ids': fields.one2many('project.issue', 'project_id', domain=[('stage_id.fold', '=', False)]) } def _check_escalation(self, cr, uid, ids, context=None): project_obj = self.browse(cr, uid, ids[0], context=context) if project_obj.project_escalation_id: if project_obj.project_escalation_id.id == project_obj.id: return False return True _constraints = [ (_check_escalation, 'Error! You cannot assign escalation to the same project!', ['project_escalation_id']) ] class account_analytic_account(osv.Model): _inherit = 'account.analytic.account' _description = 'Analytic Account' _columns = { 'use_issues': fields.boolean('Issues', help="Check this field if this project manages issues"), } def on_change_template(self, cr, uid, ids, template_id, date_start=False, context=None): res = super(account_analytic_account, self).on_change_template(cr, uid, ids, template_id, date_start=date_start, context=context) if template_id and 'value' in res: template = self.browse(cr, uid, template_id, context=context) res['value']['use_issues'] = template.use_issues return res def _trigger_project_creation(self, cr, uid, vals, context=None): if context is None: context = {} res = super(account_analytic_account, self)._trigger_project_creation(cr, uid, vals, context=context) return res or (vals.get('use_issues') and not 'project_creation_in_progress' in context) class project_project(osv.Model): _inherit = 'project.project' _defaults = { 'use_issues': True } def _check_create_write_values(self, cr, uid, vals, context=None): """ Perform some check on values given to create or write. """ # Handle use_tasks / use_issues: if only one is checked, alias should take the same model if vals.get('use_tasks') and not vals.get('use_issues'): vals['alias_model'] = 'project.task' elif vals.get('use_issues') and not vals.get('use_tasks'): vals['alias_model'] = 'project.issue' def on_change_use_tasks_or_issues(self, cr, uid, ids, use_tasks, use_issues, context=None): values = {} if use_tasks and not use_issues: values['alias_model'] = 'project.task' elif not use_tasks and use_issues: values['alias_model'] = 'project.issue' return {'value': values} def create(self, cr, uid, vals, context=None): self._check_create_write_values(cr, uid, vals, context=context) return super(project_project, self).create(cr, uid, vals, context=context) def write(self, cr, uid, ids, vals, context=None): self._check_create_write_values(cr, uid, vals, context=context) return super(project_project, self).write(cr, uid, ids, vals, context=context) class res_partner(osv.osv): def _issue_count(self, cr, uid, ids, field_name, arg, context=None): Issue = self.pool['project.issue'] return { partner_id: Issue.search_count(cr,uid, [('partner_id', '=', partner_id)]) for partner_id in ids } """ Inherits partner and adds Issue information in the partner form """ _inherit = 'res.partner' _columns = { 'issue_count': fields.function(_issue_count, string='# Issues', type='integer'), } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 327, 13, 1837, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 2197, 492, 2197, 199, 199, 504, 5166, 492, 2986, 199, 504, 5166, 492, 12824, 63, 998, 199, 504, 5166, 492, 7249, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 12, 9813, 199, 504, 5166, 14, 2537, 492, 6186, 63, 6613, 63, 12488, 63, 4807, 199, 504, 5166, 14, 2537, 492, 3517, 18, 17426, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 421, 199, 533, 2199, 63, 5237, 63, 1023, 8, 4795, 14, 1685, 304, 272, 485, 354, 275, 298, 1715, 14, 5237, 14, 1023, 2, 272, 485, 1648, 275, 298, 354, 4328, 2, 272, 485, 3406, 275, 469, 267, 283, 354, 356, 1504, 14, 1560, 360, 3353, 4860, 297, 1415, 29, 549, 395, 267, 283, 2682, 356, 1504, 14, 4871, 360, 7472, 297, 1415, 29, 797, 395, 272, 789, 272, 485, 4322, 275, 469, 267, 283, 2682, 356, 413, 12, 272, 789, 199, 199, 533, 2199, 63, 5237, 8, 4795, 14, 1685, 304, 272, 485, 354, 275, 298, 1715, 14, 5237, 2, 272, 485, 1802, 275, 298, 4761, 13383, 2, 272, 485, 1648, 275, 298, 6693, 4328, 12, 1218, 63, 602, 4328, 2, 272, 485, 6486, 275, 788, 1198, 14, 2671, 297, 283, 723, 14, 9321, 1287, 63, 20406, 418, 339, 485, 1198, 63, 1932, 63, 2732, 275, 283, 739, 7, 272, 485, 3885, 275, 469, 267, 283, 8614, 63, 344, 356, 469, 288, 327, 642, 365, 1454, 376, 946, 300, 631, 2932, 27, 10298, 641, 2195, 6770, 9546, 2897, 652, 1443, 440, 1336, 1006, 283, 1222, 7, 24490, 288, 283, 1715, 63, 5237, 14, 2037, 63, 5237, 63, 1222, 356, 2400, 291, 12, 2467, 12, 1747, 12, 1559, 12, 4027, 29, 403, 26, 1559, 14, 8614, 63, 344, 436, 1559, 14, 8614, 63, 344, 14, 4041, 2695, 413, 12, 288, 283, 1715, 63, 5237, 14, 2037, 63, 5237, 63, 8614, 356, 2400, 291, 12, 2467, 12, 1747, 12, 1559, 12, 4027, 29, 403, 26, 1559, 14, 8614, 63, 344, 436, 1559, 14, 8614, 63, 344, 14, 4041, 690, 413, 12, 267, 1660, 267, 283, 751, 63, 344, 356, 469, 288, 283, 1715, 63, 5237, 14, 2037, 63, 5237, 63, 12941, 356, 2400, 291, 12, 2467, 12, 1747, 12, 1559, 12, 4027, 29, 403, 26, 1559, 14, 751, 63, 344, 436, 1559, 14, 751, 63, 344, 14, 344, 12, 267, 1660, 267, 283, 29305, 13206, 63, 929, 356, 469, 288, 283, 1715, 63, 5237, 14, 2037, 63, 5237, 63, 17726, 356, 2400, 291, 12, 2467, 12, 1747, 12, 1559, 12, 4027, 29, 403, 26, 1559, 14, 29305, 13206, 63, 929, 508, 283, 17726, 297, 288, 283, 1715, 63, 5237, 14, 2037, 63, 5237, 63, 2179, 356, 2400, 291, 12, 2467, 12, 1747, 12, 1559, 12, 4027, 29, 403, 26, 1559, 14, 29305, 13206, 63, 929, 508, 283, 4456, 297, 267, 1660, 272, 789, 339, 347, 485, 362, 63, 885, 63, 3899, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 2199, 63, 344, 275, 291, 423, 362, 63, 885, 63, 1715, 63, 344, 8, 1556, 12, 1747, 12, 1067, 9, 267, 340, 2199, 63, 344, 26, 288, 2199, 275, 291, 14, 2293, 14, 362, 360, 1715, 14, 1715, 1959, 4570, 8, 1556, 12, 1747, 12, 2199, 63, 344, 12, 1067, 29, 1100, 9, 288, 340, 2199, 436, 2199, 14, 3899, 63, 344, 26, 355, 372, 2199, 14, 3899, 63, 344, 14, 344, 267, 372, 756, 339, 347, 485, 362, 63, 885, 63, 1715, 63, 344, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 408, 598, 7602, 849, 2199, 701, 7907, 340, 3451, 315, 314, 1067, 408, 267, 372, 291, 423, 6983, 63, 1715, 63, 344, 63, 504, 63, 1100, 8, 1556, 12, 1747, 12, 1067, 29, 1100, 9, 339, 347, 485, 362, 63, 885, 63, 8614, 63, 344, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 408, 598, 7602, 849, 9546, 63, 344, 408, 267, 2199, 63, 344, 275, 291, 423, 362, 63, 885, 63, 1715, 63, 344, 8, 1556, 12, 1747, 12, 1067, 29, 1100, 9, 267, 372, 291, 14, 8614, 63, 1623, 8, 1556, 12, 1747, 12, 990, 2199, 63, 344, 12, 4274, 14011, 297, 6291, 756, 4360, 1067, 29, 1100, 9, 339, 347, 485, 6983, 63, 1715, 63, 344, 63, 504, 63, 1100, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 408, 1803, 2870, 402, 2199, 4079, 641, 314, 574, 402, 283, 885, 63, 1715, 63, 344, 7, 288, 1067, 790, 12, 503, 488, 340, 652, 3913, 506, 12152, 370, 282, 2849, 288, 2199, 14, 267, 408, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 267, 340, 730, 8, 1100, 14, 362, 360, 885, 63, 1715, 63, 344, 1333, 315, 334, 442, 12, 1846, 304, 288, 372, 1067, 14, 362, 360, 885, 63, 1715, 63, 344, 358, 267, 340, 1228, 8, 1100, 14, 362, 360, 885, 63, 1715, 63, 344 ]
[ 13, 1837, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 2197, 492, 2197, 199, 199, 504, 5166, 492, 2986, 199, 504, 5166, 492, 12824, 63, 998, 199, 504, 5166, 492, 7249, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 12, 9813, 199, 504, 5166, 14, 2537, 492, 6186, 63, 6613, 63, 12488, 63, 4807, 199, 504, 5166, 14, 2537, 492, 3517, 18, 17426, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 421, 199, 533, 2199, 63, 5237, 63, 1023, 8, 4795, 14, 1685, 304, 272, 485, 354, 275, 298, 1715, 14, 5237, 14, 1023, 2, 272, 485, 1648, 275, 298, 354, 4328, 2, 272, 485, 3406, 275, 469, 267, 283, 354, 356, 1504, 14, 1560, 360, 3353, 4860, 297, 1415, 29, 549, 395, 267, 283, 2682, 356, 1504, 14, 4871, 360, 7472, 297, 1415, 29, 797, 395, 272, 789, 272, 485, 4322, 275, 469, 267, 283, 2682, 356, 413, 12, 272, 789, 199, 199, 533, 2199, 63, 5237, 8, 4795, 14, 1685, 304, 272, 485, 354, 275, 298, 1715, 14, 5237, 2, 272, 485, 1802, 275, 298, 4761, 13383, 2, 272, 485, 1648, 275, 298, 6693, 4328, 12, 1218, 63, 602, 4328, 2, 272, 485, 6486, 275, 788, 1198, 14, 2671, 297, 283, 723, 14, 9321, 1287, 63, 20406, 418, 339, 485, 1198, 63, 1932, 63, 2732, 275, 283, 739, 7, 272, 485, 3885, 275, 469, 267, 283, 8614, 63, 344, 356, 469, 288, 327, 642, 365, 1454, 376, 946, 300, 631, 2932, 27, 10298, 641, 2195, 6770, 9546, 2897, 652, 1443, 440, 1336, 1006, 283, 1222, 7, 24490, 288, 283, 1715, 63, 5237, 14, 2037, 63, 5237, 63, 1222, 356, 2400, 291, 12, 2467, 12, 1747, 12, 1559, 12, 4027, 29, 403, 26, 1559, 14, 8614, 63, 344, 436, 1559, 14, 8614, 63, 344, 14, 4041, 2695, 413, 12, 288, 283, 1715, 63, 5237, 14, 2037, 63, 5237, 63, 8614, 356, 2400, 291, 12, 2467, 12, 1747, 12, 1559, 12, 4027, 29, 403, 26, 1559, 14, 8614, 63, 344, 436, 1559, 14, 8614, 63, 344, 14, 4041, 690, 413, 12, 267, 1660, 267, 283, 751, 63, 344, 356, 469, 288, 283, 1715, 63, 5237, 14, 2037, 63, 5237, 63, 12941, 356, 2400, 291, 12, 2467, 12, 1747, 12, 1559, 12, 4027, 29, 403, 26, 1559, 14, 751, 63, 344, 436, 1559, 14, 751, 63, 344, 14, 344, 12, 267, 1660, 267, 283, 29305, 13206, 63, 929, 356, 469, 288, 283, 1715, 63, 5237, 14, 2037, 63, 5237, 63, 17726, 356, 2400, 291, 12, 2467, 12, 1747, 12, 1559, 12, 4027, 29, 403, 26, 1559, 14, 29305, 13206, 63, 929, 508, 283, 17726, 297, 288, 283, 1715, 63, 5237, 14, 2037, 63, 5237, 63, 2179, 356, 2400, 291, 12, 2467, 12, 1747, 12, 1559, 12, 4027, 29, 403, 26, 1559, 14, 29305, 13206, 63, 929, 508, 283, 4456, 297, 267, 1660, 272, 789, 339, 347, 485, 362, 63, 885, 63, 3899, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 2199, 63, 344, 275, 291, 423, 362, 63, 885, 63, 1715, 63, 344, 8, 1556, 12, 1747, 12, 1067, 9, 267, 340, 2199, 63, 344, 26, 288, 2199, 275, 291, 14, 2293, 14, 362, 360, 1715, 14, 1715, 1959, 4570, 8, 1556, 12, 1747, 12, 2199, 63, 344, 12, 1067, 29, 1100, 9, 288, 340, 2199, 436, 2199, 14, 3899, 63, 344, 26, 355, 372, 2199, 14, 3899, 63, 344, 14, 344, 267, 372, 756, 339, 347, 485, 362, 63, 885, 63, 1715, 63, 344, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 408, 598, 7602, 849, 2199, 701, 7907, 340, 3451, 315, 314, 1067, 408, 267, 372, 291, 423, 6983, 63, 1715, 63, 344, 63, 504, 63, 1100, 8, 1556, 12, 1747, 12, 1067, 29, 1100, 9, 339, 347, 485, 362, 63, 885, 63, 8614, 63, 344, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 408, 598, 7602, 849, 9546, 63, 344, 408, 267, 2199, 63, 344, 275, 291, 423, 362, 63, 885, 63, 1715, 63, 344, 8, 1556, 12, 1747, 12, 1067, 29, 1100, 9, 267, 372, 291, 14, 8614, 63, 1623, 8, 1556, 12, 1747, 12, 990, 2199, 63, 344, 12, 4274, 14011, 297, 6291, 756, 4360, 1067, 29, 1100, 9, 339, 347, 485, 6983, 63, 1715, 63, 344, 63, 504, 63, 1100, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 408, 1803, 2870, 402, 2199, 4079, 641, 314, 574, 402, 283, 885, 63, 1715, 63, 344, 7, 288, 1067, 790, 12, 503, 488, 340, 652, 3913, 506, 12152, 370, 282, 2849, 288, 2199, 14, 267, 408, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 267, 340, 730, 8, 1100, 14, 362, 360, 885, 63, 1715, 63, 344, 1333, 315, 334, 442, 12, 1846, 304, 288, 372, 1067, 14, 362, 360, 885, 63, 1715, 63, 344, 358, 267, 340, 1228, 8, 1100, 14, 362, 360, 885, 63, 1715, 63, 344, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
maheshp/novatest
nova/tests/baremetal/test_ipmi.py
9
8176
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # coding=utf-8 # Copyright 2012 Hewlett-Packard Development Company, L.P. # Copyright (c) 2012 NTT DOCOMO, 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. """Test class for baremetal IPMI power manager.""" import os import stat import tempfile from oslo.config import cfg from nova import test from nova.tests.baremetal.db import utils as bm_db_utils from nova import utils from nova.virt.baremetal import baremetal_states from nova.virt.baremetal import ipmi from nova.virt.baremetal import utils as bm_utils CONF = cfg.CONF class BareMetalIPMITestCase(test.TestCase): def setUp(self): super(BareMetalIPMITestCase, self).setUp() self.node = bm_db_utils.new_bm_node( id=123, pm_address='fake-address', pm_user='fake-user', pm_password='fake-password') self.ipmi = ipmi.IPMI(self.node) def test_construct(self): self.assertEqual(self.ipmi.node_id, 123) self.assertEqual(self.ipmi.address, 'fake-address') self.assertEqual(self.ipmi.user, 'fake-user') self.assertEqual(self.ipmi.password, 'fake-password') def test_make_password_file(self): pw_file = ipmi._make_password_file(self.node['pm_password']) try: self.assertTrue(os.path.isfile(pw_file)) self.assertEqual(os.stat(pw_file)[stat.ST_MODE] & 0777, 0600) with open(pw_file, "r") as f: pm_password = f.read() self.assertEqual(pm_password, self.node['pm_password']) finally: os.unlink(pw_file) def test_exec_ipmitool(self): pw_file = '/tmp/password_file' self.mox.StubOutWithMock(ipmi, '_make_password_file') self.mox.StubOutWithMock(utils, 'execute') self.mox.StubOutWithMock(bm_utils, 'unlink_without_raise') ipmi._make_password_file(self.ipmi.password).AndReturn(pw_file) args = [ 'ipmitool', '-I', 'lanplus', '-H', self.ipmi.address, '-U', self.ipmi.user, '-f', pw_file, 'A', 'B', 'C', ] utils.execute(*args, attempts=3).AndReturn(('', '')) bm_utils.unlink_without_raise(pw_file).AndReturn(None) self.mox.ReplayAll() self.ipmi._exec_ipmitool('A B C') self.mox.VerifyAll() def test_is_power(self): self.mox.StubOutWithMock(self.ipmi, '_exec_ipmitool') self.ipmi._exec_ipmitool("power status").AndReturn( ["Chassis Power is on\n"]) self.mox.ReplayAll() self.ipmi._is_power("on") self.mox.VerifyAll() def test_power_already_on(self): self.flags(ipmi_power_retry=0, group='baremetal') self.mox.StubOutWithMock(self.ipmi, '_exec_ipmitool') self.ipmi._exec_ipmitool("power status").AndReturn( ["Chassis Power is on\n"]) self.mox.ReplayAll() self.ipmi.state = baremetal_states.DELETED self.ipmi._power_on() self.mox.VerifyAll() self.assertEqual(self.ipmi.state, baremetal_states.ACTIVE) def test_power_on_ok(self): self.flags(ipmi_power_retry=0, group='baremetal') self.mox.StubOutWithMock(self.ipmi, '_exec_ipmitool') self.ipmi._exec_ipmitool("power status").AndReturn( ["Chassis Power is off\n"]) self.ipmi._exec_ipmitool("power on").AndReturn([]) self.ipmi._exec_ipmitool("power status").AndReturn( ["Chassis Power is on\n"]) self.mox.ReplayAll() self.ipmi.state = baremetal_states.DELETED self.ipmi._power_on() self.mox.VerifyAll() self.assertEqual(self.ipmi.state, baremetal_states.ACTIVE) def test_power_on_fail(self): self.flags(ipmi_power_retry=0, group='baremetal') self.mox.StubOutWithMock(self.ipmi, '_exec_ipmitool') self.ipmi._exec_ipmitool("power status").AndReturn( ["Chassis Power is off\n"]) self.ipmi._exec_ipmitool("power on").AndReturn([]) self.ipmi._exec_ipmitool("power status").AndReturn( ["Chassis Power is off\n"]) self.mox.ReplayAll() self.ipmi.state = baremetal_states.DELETED self.ipmi._power_on() self.mox.VerifyAll() self.assertEqual(self.ipmi.state, baremetal_states.ERROR) def test_power_on_max_retries(self): self.flags(ipmi_power_retry=2, group='baremetal') self.mox.StubOutWithMock(self.ipmi, '_exec_ipmitool') self.ipmi._exec_ipmitool("power status").AndReturn( ["Chassis Power is off\n"]) self.ipmi._exec_ipmitool("power on").AndReturn([]) self.ipmi._exec_ipmitool("power status").AndReturn( ["Chassis Power is off\n"]) self.ipmi._exec_ipmitool("power on").AndReturn([]) self.ipmi._exec_ipmitool("power status").AndReturn( ["Chassis Power is off\n"]) self.ipmi._exec_ipmitool("power on").AndReturn([]) self.ipmi._exec_ipmitool("power status").AndReturn( ["Chassis Power is off\n"]) self.mox.ReplayAll() self.ipmi.state = baremetal_states.DELETED self.ipmi._power_on() self.mox.VerifyAll() self.assertEqual(self.ipmi.state, baremetal_states.ERROR) self.assertEqual(self.ipmi.retries, 3) def test_power_off_ok(self): self.flags(ipmi_power_retry=0, group='baremetal') self.mox.StubOutWithMock(self.ipmi, '_exec_ipmitool') self.ipmi._exec_ipmitool("power status").AndReturn( ["Chassis Power is on\n"]) self.ipmi._exec_ipmitool("power off").AndReturn([]) self.ipmi._exec_ipmitool("power status").AndReturn( ["Chassis Power is off\n"]) self.mox.ReplayAll() self.ipmi.state = baremetal_states.ACTIVE self.ipmi._power_off() self.mox.VerifyAll() self.assertEqual(self.ipmi.state, baremetal_states.DELETED) def test_get_console_pid_path(self): self.flags(terminal_pid_dir='/tmp', group='baremetal') path = ipmi._get_console_pid_path(self.ipmi.node_id) self.assertEqual(path, '/tmp/%s.pid' % self.ipmi.node_id) def test_console_pid(self): fd, path = tempfile.mkstemp() with os.fdopen(fd, 'w') as f: f.write("12345\n") self.mox.StubOutWithMock(ipmi, '_get_console_pid_path') ipmi._get_console_pid_path(self.ipmi.node_id).AndReturn(path) self.mox.ReplayAll() pid = ipmi._get_console_pid(self.ipmi.node_id) bm_utils.unlink_without_raise(path) self.mox.VerifyAll() self.assertEqual(pid, 12345) def test_console_pid_nan(self): fd, path = tempfile.mkstemp() with os.fdopen(fd, 'w') as f: f.write("hello world\n") self.mox.StubOutWithMock(ipmi, '_get_console_pid_path') ipmi._get_console_pid_path(self.ipmi.node_id).AndReturn(path) self.mox.ReplayAll() pid = ipmi._get_console_pid(self.ipmi.node_id) bm_utils.unlink_without_raise(path) self.mox.VerifyAll() self.assertTrue(pid is None) def test_console_pid_file_not_found(self): pid_path = ipmi._get_console_pid_path(self.ipmi.node_id) self.mox.StubOutWithMock(os.path, 'exists') os.path.exists(pid_path).AndReturn(False) self.mox.ReplayAll() pid = ipmi._get_console_pid(self.ipmi.node_id) self.mox.VerifyAll() self.assertTrue(pid is None)
apache-2.0
[ 3, 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 3, 2803, 29, 1624, 13, 24, 199, 199, 3, 1898, 6029, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 1898, 334, 67, 9, 6029, 653, 1481, 3506, 1439, 2679, 12, 7839, 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, 624, 774, 1021, 367, 18753, 22420, 3531, 10709, 7074, 5256, 1041, 199, 199, 646, 747, 199, 646, 5672, 199, 646, 5549, 199, 199, 504, 11258, 14, 888, 492, 4810, 199, 199, 504, 5913, 492, 511, 199, 504, 5913, 14, 2219, 14, 14890, 22420, 14, 697, 492, 3778, 465, 25425, 63, 697, 63, 1208, 199, 504, 5913, 492, 3778, 199, 504, 5913, 14, 4549, 14, 14890, 22420, 492, 18753, 22420, 63, 4981, 199, 504, 5913, 14, 4549, 14, 14890, 22420, 492, 3384, 2664, 199, 504, 5913, 14, 4549, 14, 14890, 22420, 492, 3778, 465, 25425, 63, 1208, 199, 199, 3103, 275, 4810, 14, 3103, 421, 199, 533, 699, 1530, 4015, 279, 1772, 13965, 27309, 8, 396, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 34, 1530, 4015, 279, 1772, 13965, 27309, 12, 291, 680, 5996, 342, 267, 291, 14, 932, 275, 25425, 63, 697, 63, 1208, 14, 1222, 63, 12648, 63, 932, 8, 355, 1305, 29, 4288, 12, 355, 14207, 63, 1562, 534, 3183, 13, 1562, 297, 355, 14207, 63, 751, 534, 3183, 13, 751, 297, 355, 14207, 63, 2060, 534, 3183, 13, 2060, 358, 267, 291, 14, 711, 2664, 275, 3384, 2664, 14, 1772, 10709, 8, 277, 14, 932, 9, 339, 347, 511, 63, 8514, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 711, 2664, 14, 932, 63, 344, 12, 11869, 9, 267, 291, 14, 629, 8, 277, 14, 711, 2664, 14, 1562, 12, 283, 3183, 13, 1562, 358, 267, 291, 14, 629, 8, 277, 14, 711, 2664, 14, 751, 12, 283, 3183, 13, 751, 358, 267, 291, 14, 629, 8, 277, 14, 711, 2664, 14, 2060, 12, 283, 3183, 13, 2060, 358, 339, 347, 511, 63, 1875, 63, 2060, 63, 493, 8, 277, 304, 267, 19206, 63, 493, 275, 3384, 2664, 423, 1875, 63, 2060, 63, 493, 8, 277, 14, 932, 459, 7073, 63, 2060, 1105, 267, 862, 26, 288, 291, 14, 1815, 8, 736, 14, 515, 14, 6292, 8, 8796, 63, 493, 430, 288, 291, 14, 629, 8, 736, 14, 3736, 8, 8796, 63, 493, 2788, 3736, 14, 840, 63, 6963, 61, 1253, 378, 11956, 12, 378, 6683, 9, 288, 543, 1551, 8, 8796, 63, 493, 12, 298, 82, 531, 465, 289, 26, 355, 14207, 63, 2060, 275, 289, 14, 739, 342, 288, 291, 14, 629, 8, 7073, 63, 2060, 12, 291, 14, 932, 459, 7073, 63, 2060, 1105, 267, 3753, 26, 288, 747, 14, 7162, 8, 8796, 63, 493, 9, 339, 347, 511, 63, 1628, 63, 711, 1147, 21943, 8, 277, 304, 267, 19206, 63, 493, 275, 1994, 2791, 15, 2060, 63, 493, 7, 398, 291, 14, 6625, 14, 12088, 8, 711, 2664, 12, 2513, 1875, 63, 2060, 63, 493, 358, 267, 291, 14, 6625, 14, 12088, 8, 1208, 12, 283, 2526, 358, 267, 291, 14, 6625, 14, 12088, 8, 12648, 63, 1208, 12, 283, 7162, 63, 7395, 63, 3730, 358, 267, 3384, 2664, 423, 1875, 63, 2060, 63, 493, 8, 277, 14, 711, 2664, 14, 2060, 680, 8572, 8, 8796, 63, 493, 9, 267, 1249, 275, 359, 355, 283, 711, 1147, 21943, 297, 355, 2475, 41, 297, 283, 1502, 6666, 297, 355, 2475, 40, 297, 291, 14, 711, 2664, 14, 1562, 12, 355, 2475, 53, 297, 291, 14, 711, 2664, 14, 751, 12, 355, 2475, 70, 297, 19206, 63, 493, 12, 355, 283, 33, 297, 283, 34, 297, 283, 35, 297, 355, 1622, 267, 3778, 14, 2526, 2031, 589, 12, 12454, 29, 19, 680, 8572, 4725, 297, 12381, 267, 25425, 63, 1208, 14, 7162, 63, 7395, 63, 3730, 8, 8796, 63, 493, 680, 8572, 8, 403, 9, 267, 291, 14, 6625, 14, 12982, 342, 398, 291, 14, 711, 2664, 423, 1628, 63, 711, 1147, 21943, 360, 33, 699, 445, 358, 267, 291, 14, 6625, 14, 31912, 342, 339, 347, 511, 63, 374, 63, 5652, 8, 277, 304, 267, 291, 14, 6625, 14, 12088, 8, 277, 14, 711, 2664, 12, 2513, 1628, 63, 711, 1147, 21943, 358, 267, 291, 14, 711, 2664, 423, 1628, 63, 711, 1147, 21943, 480, 5652, 2004, 3471, 8572, 8, 355, 2097, 1049, 20743, 18879, 365, 641, 60, 78, 3135, 267, 291, 14, 6625, 14, 12982, 342, 398, 291, 14, 711, 2664, 423, 374, 63, 5652, 480, 265, 531, 267, 291, 14, 6625, 14, 31912, 342, 339, 347, 511, 63, 5652, 63, 14039, 63, 265, 8, 277, 304, 267, 291, 14, 2469, 8, 711, 2664, 63, 5652, 63, 7154, 29, 16, 12, 1572, 534, 14890, 22420, 358, 267, 291, 14, 6625, 14, 12088, 8, 277, 14, 711, 2664, 12, 2513, 1628, 63, 711, 1147, 21943, 358, 398, 291, 14, 711, 2664, 423, 1628, 63, 711, 1147, 21943, 480, 5652, 2004, 3471, 8572, 8, 355, 2097, 1049, 20743, 18879, 365, 641, 60, 78, 3135, 267, 291, 14, 6625, 14, 12982, 342, 398, 291, 14, 711, 2664, 14, 929, 275, 18753, 22420, 63, 4981, 14, 27408, 267, 291, 14, 711, 2664, 423, 5652, 63, 265, 342, 267, 291, 14, 6625, 14, 31912, 342, 267, 291, 14, 629 ]
[ 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 3, 2803, 29, 1624, 13, 24, 199, 199, 3, 1898, 6029, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 1898, 334, 67, 9, 6029, 653, 1481, 3506, 1439, 2679, 12, 7839, 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, 624, 774, 1021, 367, 18753, 22420, 3531, 10709, 7074, 5256, 1041, 199, 199, 646, 747, 199, 646, 5672, 199, 646, 5549, 199, 199, 504, 11258, 14, 888, 492, 4810, 199, 199, 504, 5913, 492, 511, 199, 504, 5913, 14, 2219, 14, 14890, 22420, 14, 697, 492, 3778, 465, 25425, 63, 697, 63, 1208, 199, 504, 5913, 492, 3778, 199, 504, 5913, 14, 4549, 14, 14890, 22420, 492, 18753, 22420, 63, 4981, 199, 504, 5913, 14, 4549, 14, 14890, 22420, 492, 3384, 2664, 199, 504, 5913, 14, 4549, 14, 14890, 22420, 492, 3778, 465, 25425, 63, 1208, 199, 199, 3103, 275, 4810, 14, 3103, 421, 199, 533, 699, 1530, 4015, 279, 1772, 13965, 27309, 8, 396, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 34, 1530, 4015, 279, 1772, 13965, 27309, 12, 291, 680, 5996, 342, 267, 291, 14, 932, 275, 25425, 63, 697, 63, 1208, 14, 1222, 63, 12648, 63, 932, 8, 355, 1305, 29, 4288, 12, 355, 14207, 63, 1562, 534, 3183, 13, 1562, 297, 355, 14207, 63, 751, 534, 3183, 13, 751, 297, 355, 14207, 63, 2060, 534, 3183, 13, 2060, 358, 267, 291, 14, 711, 2664, 275, 3384, 2664, 14, 1772, 10709, 8, 277, 14, 932, 9, 339, 347, 511, 63, 8514, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 711, 2664, 14, 932, 63, 344, 12, 11869, 9, 267, 291, 14, 629, 8, 277, 14, 711, 2664, 14, 1562, 12, 283, 3183, 13, 1562, 358, 267, 291, 14, 629, 8, 277, 14, 711, 2664, 14, 751, 12, 283, 3183, 13, 751, 358, 267, 291, 14, 629, 8, 277, 14, 711, 2664, 14, 2060, 12, 283, 3183, 13, 2060, 358, 339, 347, 511, 63, 1875, 63, 2060, 63, 493, 8, 277, 304, 267, 19206, 63, 493, 275, 3384, 2664, 423, 1875, 63, 2060, 63, 493, 8, 277, 14, 932, 459, 7073, 63, 2060, 1105, 267, 862, 26, 288, 291, 14, 1815, 8, 736, 14, 515, 14, 6292, 8, 8796, 63, 493, 430, 288, 291, 14, 629, 8, 736, 14, 3736, 8, 8796, 63, 493, 2788, 3736, 14, 840, 63, 6963, 61, 1253, 378, 11956, 12, 378, 6683, 9, 288, 543, 1551, 8, 8796, 63, 493, 12, 298, 82, 531, 465, 289, 26, 355, 14207, 63, 2060, 275, 289, 14, 739, 342, 288, 291, 14, 629, 8, 7073, 63, 2060, 12, 291, 14, 932, 459, 7073, 63, 2060, 1105, 267, 3753, 26, 288, 747, 14, 7162, 8, 8796, 63, 493, 9, 339, 347, 511, 63, 1628, 63, 711, 1147, 21943, 8, 277, 304, 267, 19206, 63, 493, 275, 1994, 2791, 15, 2060, 63, 493, 7, 398, 291, 14, 6625, 14, 12088, 8, 711, 2664, 12, 2513, 1875, 63, 2060, 63, 493, 358, 267, 291, 14, 6625, 14, 12088, 8, 1208, 12, 283, 2526, 358, 267, 291, 14, 6625, 14, 12088, 8, 12648, 63, 1208, 12, 283, 7162, 63, 7395, 63, 3730, 358, 267, 3384, 2664, 423, 1875, 63, 2060, 63, 493, 8, 277, 14, 711, 2664, 14, 2060, 680, 8572, 8, 8796, 63, 493, 9, 267, 1249, 275, 359, 355, 283, 711, 1147, 21943, 297, 355, 2475, 41, 297, 283, 1502, 6666, 297, 355, 2475, 40, 297, 291, 14, 711, 2664, 14, 1562, 12, 355, 2475, 53, 297, 291, 14, 711, 2664, 14, 751, 12, 355, 2475, 70, 297, 19206, 63, 493, 12, 355, 283, 33, 297, 283, 34, 297, 283, 35, 297, 355, 1622, 267, 3778, 14, 2526, 2031, 589, 12, 12454, 29, 19, 680, 8572, 4725, 297, 12381, 267, 25425, 63, 1208, 14, 7162, 63, 7395, 63, 3730, 8, 8796, 63, 493, 680, 8572, 8, 403, 9, 267, 291, 14, 6625, 14, 12982, 342, 398, 291, 14, 711, 2664, 423, 1628, 63, 711, 1147, 21943, 360, 33, 699, 445, 358, 267, 291, 14, 6625, 14, 31912, 342, 339, 347, 511, 63, 374, 63, 5652, 8, 277, 304, 267, 291, 14, 6625, 14, 12088, 8, 277, 14, 711, 2664, 12, 2513, 1628, 63, 711, 1147, 21943, 358, 267, 291, 14, 711, 2664, 423, 1628, 63, 711, 1147, 21943, 480, 5652, 2004, 3471, 8572, 8, 355, 2097, 1049, 20743, 18879, 365, 641, 60, 78, 3135, 267, 291, 14, 6625, 14, 12982, 342, 398, 291, 14, 711, 2664, 423, 374, 63, 5652, 480, 265, 531, 267, 291, 14, 6625, 14, 31912, 342, 339, 347, 511, 63, 5652, 63, 14039, 63, 265, 8, 277, 304, 267, 291, 14, 2469, 8, 711, 2664, 63, 5652, 63, 7154, 29, 16, 12, 1572, 534, 14890, 22420, 358, 267, 291, 14, 6625, 14, 12088, 8, 277, 14, 711, 2664, 12, 2513, 1628, 63, 711, 1147, 21943, 358, 398, 291, 14, 711, 2664, 423, 1628, 63, 711, 1147, 21943, 480, 5652, 2004, 3471, 8572, 8, 355, 2097, 1049, 20743, 18879, 365, 641, 60, 78, 3135, 267, 291, 14, 6625, 14, 12982, 342, 398, 291, 14, 711, 2664, 14, 929, 275, 18753, 22420, 63, 4981, 14, 27408, 267, 291, 14, 711, 2664, 423, 5652, 63, 265, 342, 267, 291, 14, 6625, 14, 31912, 342, 267, 291, 14, 629, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Charlotte-Morgan/inasafe
safe/gis/vector/tools.py
4
16940
# coding=utf-8 """Tools for vector layers.""" import logging from math import isnan import ogr from qgis.core import ( QgsSpatialIndex, QgsFeatureRequest, QgsFeature, QgsField, QgsProject, QgsDistanceArea, QgsWkbTypes, QgsCoordinateReferenceSystem, QgsMemoryProviderUtils, QgsFields ) from qgis.PyQt.QtCore import QVariant from safe.common.exceptions import ( MemoryLayerCreationError, # SpatialIndexCreationError, ) from safe.definitions.units import unit_metres, unit_square_metres from safe.definitions.utilities import definition from safe.gis.vector.clean_geometry import geometry_checker, clean_layer from safe.utilities.profiling import profile from safe.utilities.rounding import convert_unit __copyright__ = "Copyright 2016, The InaSAFE Project" __license__ = "GPL version 3" __email__ = "info@inasafe.org" __revision__ = '$Format:%H$' LOGGER = logging.getLogger('InaSAFE') wkb_type_groups = { 'Point': ( QgsWkbTypes.Point, QgsWkbTypes.MultiPoint, QgsWkbTypes.Point25D, QgsWkbTypes.MultiPoint25D,), 'LineString': ( QgsWkbTypes.LineString, QgsWkbTypes.MultiLineString, QgsWkbTypes.LineString25D, QgsWkbTypes.MultiLineString25D,), 'Polygon': ( QgsWkbTypes.Polygon, QgsWkbTypes.MultiPolygon, QgsWkbTypes.Polygon25D, QgsWkbTypes.MultiPolygon25D,), } for key, value in list(wkb_type_groups.items()): for const in value: wkb_type_groups[const] = key # This table come from https://qgis.org/api/qgsunittypes_8h_source.html#l00043 distance_unit = { 0: 'Meters', 1: 'Kilometres', 2: 'Feets', 3: 'Nautical Miles', 4: 'Yards', 5: 'Miles', 6: 'Degrees', 7: 'Unknown Unit' } # This table come from https://qgis.org/api/qgsunittypes_8h_source.html#l00065 area_unit = { 0: 'Square Meters', 1: 'Square Kilometres', 2: 'Square Feet', 3: 'Square Yards', 4: 'Square Miles', 5: 'Hectares', 6: 'Acres', 7: 'Square Nautical Miles', 8: 'Square Degrees', 9: 'unknown Unit' } # Field type converter from QGIS to OGR # Source http://www.gdal.org/ogr__core_8h.html#a787194be field_type_converter = { QVariant.String: ogr.OFTString, QVariant.Int: ogr.OFTInteger, QVariant.Double: ogr.OFTReal, } @profile def create_memory_layer( layer_name, geometry, coordinate_reference_system=None, fields=None): """Create a vector memory layer. :param layer_name: The name of the layer. :type layer_name: str :param geometry: The geometry of the layer. :rtype geometry: QgsWkbTypes (note: from C++ QgsWkbTypes::GeometryType enum) :param coordinate_reference_system: The CRS of the memory layer. :type coordinate_reference_system: QgsCoordinateReferenceSystem :param fields: Fields of the vector layer. Default to None. :type fields: QgsFields :return: The memory layer. :rtype: QgsVectorLayer """ if geometry == QgsWkbTypes.PointGeometry: wkb_type = QgsWkbTypes.MultiPoint elif geometry == QgsWkbTypes.LineGeometry: wkb_type = QgsWkbTypes.MultiLineString elif geometry == QgsWkbTypes.PolygonGeometry: wkb_type = QgsWkbTypes.MultiPolygon elif geometry == QgsWkbTypes.NullGeometry: wkb_type = QgsWkbTypes.NoGeometry else: raise MemoryLayerCreationError( 'Layer geometry must be one of: Point, Line, ' 'Polygon or Null, I got %s' % geometry) if coordinate_reference_system is None: coordinate_reference_system = QgsCoordinateReferenceSystem() if fields is None: fields = QgsFields() elif not isinstance(fields, QgsFields): # fields is a list new_fields = QgsFields() for f in fields: new_fields.append(f) fields = new_fields memory_layer = QgsMemoryProviderUtils. \ createMemoryLayer(name=layer_name, fields=fields, geometryType=wkb_type, crs=coordinate_reference_system) memory_layer.dataProvider().createSpatialIndex() memory_layer.keywords = { 'inasafe_fields': {} } return memory_layer @profile def copy_layer(source, target): """Copy a vector layer to another one. :param source: The vector layer to copy. :type source: QgsVectorLayer :param target: The destination. :type source: QgsVectorLayer """ out_feature = QgsFeature() target.startEditing() request = QgsFeatureRequest() aggregation_layer = False if source.keywords.get('layer_purpose') == 'aggregation': try: use_selected_only = source.use_selected_features_only except AttributeError: use_selected_only = False # We need to check if the user wants selected feature only and if there # is one minimum selected. if use_selected_only and source.selectedFeatureCount() > 0: request.setFilterFids(source.selectedFeatureIds()) aggregation_layer = True for i, feature in enumerate(source.getFeatures(request)): geom = feature.geometry() if aggregation_layer and feature.hasGeometry(): # See issue https://github.com/inasafe/inasafe/issues/3713 # and issue https://github.com/inasafe/inasafe/issues/3927 # Also handle if feature has no geometry. was_valid, geom = geometry_checker(geom) if not geom: LOGGER.info( 'One geometry in the aggregation layer is still invalid ' 'after cleaning.') out_feature.setGeometry(geom) out_feature.setAttributes(feature.attributes()) target.addFeature(out_feature) target.commitChanges() @profile def rename_fields(layer, fields_to_copy): """Rename fields inside an attribute table. Only since QGIS 2.16. :param layer: The vector layer. :type layer: QgsVectorLayer :param fields_to_copy: Dictionary of fields to copy. :type fields_to_copy: dict """ for field in fields_to_copy: index = layer.fields().lookupField(field) if index != -1: layer.startEditing() layer.renameAttribute(index, fields_to_copy[field]) layer.commitChanges() LOGGER.info( 'Renaming field %s to %s' % (field, fields_to_copy[field])) else: LOGGER.info( 'Field %s not present in the layer while trying to renaming ' 'it to %s' % (field, fields_to_copy[field])) @profile def copy_fields(layer, fields_to_copy): """Copy fields inside an attribute table. :param layer: The vector layer. :type layer: QgsVectorLayer :param fields_to_copy: Dictionary of fields to copy. :type fields_to_copy: dict """ for field in fields_to_copy: index = layer.fields().lookupField(field) if index != -1: layer.startEditing() source_field = layer.fields().at(index) new_field = QgsField(source_field) new_field.setName(fields_to_copy[field]) layer.addAttribute(new_field) new_index = layer.fields().lookupField(fields_to_copy[field]) for feature in layer.getFeatures(): attributes = feature.attributes() source_value = attributes[index] layer.changeAttributeValue( feature.id(), new_index, source_value) layer.commitChanges() layer.updateFields() # Avoid crash #4729 @profile def remove_fields(layer, fields_to_remove): """Remove fields from a vector layer. :param layer: The vector layer. :type layer: QgsVectorLayer :param fields_to_remove: List of fields to remove. :type fields_to_remove: list """ index_to_remove = [] data_provider = layer.dataProvider() for field in fields_to_remove: index = layer.fields().lookupField(field) if index != -1: index_to_remove.append(index) data_provider.deleteAttributes(index_to_remove) layer.updateFields() @profile def create_spatial_index(layer): """Helper function to create the spatial index on a vector layer. This function is mainly used to see the processing time with the decorator. :param layer: The vector layer. :type layer: QgsVectorLayer :return: The index. :rtype: QgsSpatialIndex """ request = QgsFeatureRequest().setSubsetOfAttributes([]) try: spatial_index = QgsSpatialIndex(layer.getFeatures(request)) except BaseException: # Spatial index is creating an unknown exception. # https://github.com/inasafe/inasafe/issues/4304 # or https://gitter.im/inasafe/inasafe?at=5a2903d487680e6230e0359a LOGGER.warning( 'An Exception has been raised from the spatial index creation. ' 'We will clean your layer and try again.') new_layer = clean_layer(layer) try: spatial_index = QgsSpatialIndex(new_layer.getFeatures()) except BaseException: # We got another exception. # We try now to insert feature by feature. # It's slower than the using the feature iterator. spatial_index = QgsSpatialIndex() for feature in new_layer.getFeatures(request): try: spatial_index.insertFeature(feature) except BaseException: LOGGER.critical( 'A feature has been removed from the spatial index.') # # We tried one time to clean the layer, we can't do more. # LOGGER.critical( # 'An Exception has been raised from the spatial index ' # 'creation. Unfortunately, we already try to clean your ' # 'layer. We will stop here the process.') # raise SpatialIndexCreationError return spatial_index def create_field_from_definition(field_definition, name=None, sub_name=None): """Helper to create a field from definition. :param field_definition: The definition of the field (see: safe.definitions.fields). :type field_definition: dict :param name: The name is required if the field name is dynamic and need a string formatting. :type name: basestring :param sub_name: The name is required if the field name is dynamic and need a string formatting. :type sub_name: basestring :return: The new field. :rtype: QgsField """ field = QgsField() if name and not sub_name: field.setName(field_definition['field_name'] % name) elif name and sub_name: field.setName(field_definition['field_name'] % (name, sub_name)) else: field.setName(field_definition['field_name']) if isinstance(field_definition['type'], list): # Use the first element in the list of type field.setType(field_definition['type'][0]) else: field.setType(field_definition['type']) field.setLength(field_definition['length']) field.setPrecision(field_definition['precision']) return field def create_ogr_field_from_definition(field_definition): """Helper to create a field from definition. :param field_definition: The definition of the field (see: safe.definitions.fields). :type field_definition: dict :return: The new ogr field definition. :rtype: ogr.FieldDefn """ if isinstance(field_definition['type'], list): # Use the first element in the list of type field_type = field_definition['type'][0] else: field_type = field_definition['type'] # Conversion to OGR field field_type = field_type_converter.get(field_type, ogr.OFTString) return ogr.FieldDefn(field_definition['field_name'], field_type) def field_index_from_definition(layer, field_definition): return layer.fields().lookupField(field_definition['field_name']) def read_dynamic_inasafe_field(inasafe_fields, dynamic_field, black_list=None): """Helper to read inasafe_fields using a dynamic field. :param inasafe_fields: inasafe_fields keywords to use. :type inasafe_fields: dict :param dynamic_field: The dynamic field to use. :type dynamic_field: safe.definitions.fields :param black_list: A list of fields which are conflicting with the dynamic field. Same field name pattern. :return: A list of unique value used in this dynamic field. :return: list """ pattern = dynamic_field['key'] pattern = pattern.replace('%s', '') if black_list is None: black_list = [] black_list = [field['key'] for field in black_list] unique_exposure = [] for field_key, name_field in list(inasafe_fields.items()): if field_key.endswith(pattern) and field_key not in black_list: unique_exposure.append(field_key.replace(pattern, '')) return unique_exposure class SizeCalculator(): """Special object to handle size calculation with an output unit.""" def __init__( self, coordinate_reference_system, geometry_type, exposure_key): """Constructor for the size calculator. :param coordinate_reference_system: The Coordinate Reference System of the layer. :type coordinate_reference_system: QgsCoordinateReferenceSystem :param exposure_key: The geometry type of the layer. :type exposure_key: qgis.core.QgsWkbTypes.GeometryType """ self.calculator = QgsDistanceArea() self.calculator.setSourceCrs( coordinate_reference_system, QgsProject.instance().transformContext() ) self.calculator.setEllipsoid('WGS84') if geometry_type == QgsWkbTypes.LineGeometry: self.default_unit = unit_metres LOGGER.info('The size calculator is set to use {unit}'.format( unit=distance_unit[self.calculator.lengthUnits()])) else: self.default_unit = unit_square_metres LOGGER.info('The size calculator is set to use {unit}'.format( unit=distance_unit[self.calculator.areaUnits()])) self.geometry_type = geometry_type self.output_unit = None if exposure_key: exposure_definition = definition(exposure_key) self.output_unit = exposure_definition['size_unit'] def measure_distance(self, point_a, point_b): """Measure the distance between two points. This is added here since QgsDistanceArea object is already called here. :param point_a: First Point. :type point_a: QgsPoint :param point_b: Second Point. :type point_b: QgsPoint :return: The distance between input points. :rtype: float """ return self.calculator.measureLine(point_a, point_b) def measure(self, geometry): """Measure the length or the area of a geometry. :param geometry: The geometry. :type geometry: QgsGeometry :return: The geometric size in the expected exposure unit. :rtype: float """ message = 'Size with NaN value : geometry valid={valid}, WKT={wkt}' feature_size = 0 if geometry.isMultipart(): # Be careful, the size calculator is not working well on a # multipart. # So we compute the size part per part. See ticket #3812 for single in geometry.asGeometryCollection(): if self.geometry_type == QgsWkbTypes.LineGeometry: geometry_size = self.calculator.measureLength(single) else: geometry_size = self.calculator.measureArea(single) if not isnan(geometry_size): feature_size += geometry_size else: LOGGER.debug(message.format( valid=single.isGeosValid(), wkt=single.asWkt())) else: if self.geometry_type == QgsWkbTypes.LineGeometry: geometry_size = self.calculator.measureLength(geometry) else: geometry_size = self.calculator.measureArea(geometry) if not isnan(geometry_size): feature_size = geometry_size else: LOGGER.debug(message.format( valid=geometry.isGeosValid(), wkt=geometry.asWkt())) feature_size = round(feature_size) if self.output_unit: if self.output_unit != self.default_unit: feature_size = convert_unit( feature_size, self.default_unit, self.output_unit) return feature_size
gpl-3.0
[ 3, 2803, 29, 1624, 13, 24, 199, 199, 624, 11654, 367, 5477, 9393, 1041, 421, 199, 646, 2050, 199, 504, 3473, 492, 365, 4304, 199, 199, 646, 20713, 199, 504, 15640, 14, 1018, 492, 334, 272, 4888, 18075, 2681, 12, 272, 26833, 2017, 12, 272, 26833, 12, 272, 4888, 792, 12, 272, 4888, 4761, 12, 272, 4888, 10076, 11043, 12, 272, 4888, 55, 7862, 4100, 12, 272, 4888, 18017, 5083, 3989, 12, 272, 4888, 8628, 6663, 7535, 12, 272, 4888, 7304, 199, 9, 199, 199, 504, 15640, 14, 24107, 14, 10901, 492, 27875, 199, 199, 504, 5048, 14, 2330, 14, 3924, 492, 334, 272, 15825, 5003, 5482, 5263, 12, 272, 327, 13423, 2681, 5482, 5263, 12, 199, 9, 199, 504, 5048, 14, 15388, 14, 5260, 492, 4137, 63, 10207, 470, 12, 4137, 63, 9646, 63, 10207, 470, 199, 504, 5048, 14, 15388, 14, 16355, 492, 5492, 199, 504, 5048, 14, 5668, 14, 4106, 14, 3118, 63, 7660, 492, 3400, 63, 6743, 12, 3633, 63, 1897, 199, 504, 5048, 14, 16355, 14, 496, 19294, 492, 4690, 199, 504, 5048, 14, 16355, 14, 15326, 492, 3957, 63, 3248, 199, 199, 363, 7307, 363, 275, 298, 7384, 7800, 12, 710, 1010, 65, 27657, 7290, 2, 199, 363, 1682, 363, 275, 298, 12006, 1015, 650, 2, 199, 363, 2123, 363, 275, 298, 815, 32, 262, 305, 6504, 14, 1308, 2, 199, 363, 5792, 363, 275, 4505, 3484, 2689, 40, 12913, 199, 199, 10186, 275, 2050, 14, 5572, 360, 607, 65, 27657, 358, 199, 199, 18914, 63, 466, 63, 2634, 275, 469, 272, 283, 3428, 356, 334, 267, 4888, 55, 7862, 4100, 14, 3428, 12, 267, 4888, 55, 7862, 4100, 14, 3947, 3428, 12, 267, 4888, 55, 7862, 4100, 14, 3428, 821, 36, 12, 267, 4888, 55, 7862, 4100, 14, 3947, 3428, 821, 36, 4706, 272, 283, 22134, 356, 334, 267, 4888, 55, 7862, 4100, 14, 22134, 12, 267, 4888, 55, 7862, 4100, 14, 3947, 22134, 12, 267, 4888, 55, 7862, 4100, 14, 22134, 821, 36, 12, 267, 4888, 55, 7862, 4100, 14, 3947, 22134, 821, 36, 4706, 272, 283, 12367, 356, 334, 267, 4888, 55, 7862, 4100, 14, 12367, 12, 267, 4888, 55, 7862, 4100, 14, 3947, 12367, 12, 267, 4888, 55, 7862, 4100, 14, 12367, 821, 36, 12, 267, 4888, 55, 7862, 4100, 14, 3947, 12367, 821, 36, 4706, 199, 93, 199, 509, 790, 12, 574, 315, 769, 8, 18914, 63, 466, 63, 2634, 14, 1744, 5109, 272, 367, 950, 315, 574, 26, 267, 24249, 63, 466, 63, 2634, 59, 1297, 61, 275, 790, 199, 199, 3, 961, 1817, 11492, 687, 4178, 921, 25325, 14, 1308, 15, 1246, 15, 81, 458, 3248, 1313, 63, 24, 72, 63, 1365, 14, 1360, 3, 76, 383, 5882, 199, 5590, 63, 3248, 275, 469, 272, 378, 26, 283, 1352, 878, 297, 272, 413, 26, 283, 43, 11737, 10207, 470, 297, 272, 499, 26, 283, 3456, 8716, 297, 272, 650, 26, 283, 46, 3844, 3294, 603, 22894, 297, 272, 841, 26, 283, 57, 5596, 297, 272, 959, 26, 283, 45, 22894, 297, 272, 1227, 26, 283, 26135, 5710, 297, 272, 1520, 26, 283, 5912, 12008, 7, 199, 93, 199, 199, 3, 961, 1817, 11492, 687, 4178, 921, 25325, 14, 1308, 15, 1246, 15, 81, 458, 3248, 1313, 63, 24, 72, 63, 1365, 14, 1360, 3, 76, 1493, 2182, 199, 6789, 63, 3248, 275, 469, 272, 378, 26, 283, 23373, 3194, 878, 297, 272, 413, 26, 283, 23373, 1804, 11737, 10207, 470, 297, 272, 499, 26, 283, 23373, 7949, 386, 297, 272, 650, 26, 283, 23373, 1488, 5596, 297, 272, 841, 26, 283, 23373, 603, 22894, 297, 272, 959, 26, 283, 40, 449, 11044, 297, 272, 1227, 26, 283, 1945, 470, 297, 272, 1520, 26, 283, 23373, 653, 3844, 3294, 603, 22894, 297, 272, 1695, 26, 283, 23373, 1487, 71, 5710, 297, 272, 1749, 26, 283, 5187, 12008, 7, 199, 93, 199, 199, 3, 5024, 730, 11109, 687, 27024, 370, 10904, 199, 3, 5800, 1455, 921, 1544, 14, 11600, 14, 1308, 15, 14945, 363, 1018, 63, 24, 72, 14, 1360, 3, 65, 32363, 10860, 1235, 199, 698, 63, 466, 63, 11256, 275, 469, 272, 27875, 14, 1558, 26, 20713, 14, 47, 2161, 1558, 12, 272, 27875, 14, 3241, 26, 20713, 14, 47, 2161, 2674, 12, 272, 27875, 14, 7281, 26, 20713, 14, 47, 2161, 10099, 12, 199, 93, 421, 199, 32, 2913, 199, 318, 1218, 63, 4844, 63, 1897, 8, 267, 4045, 63, 354, 12, 3400, 12, 10021, 63, 4443, 63, 2253, 29, 403, 12, 1504, 29, 403, 304, 272, 408, 2499, 282, 5477, 4402, 4045, 14, 339, 520, 635, 4045, 63, 354, 26, 710, 536, 402, 314, 4045, 14, 272, 520, 466, 4045, 63, 354, 26, 620, 339, 520, 635, 3400, 26, 710, 3400, 402, 314, 4045, 14, 272, 520, 4500, 3400, 26, 4888, 55, 7862, 4100, 334, 4610, 26, 2151, 687, 445, 4176, 4888, 55, 7862, 4100, 447, 6831, 804, 4952, 9, 339, 520, 635, 10021, 63, 4443, 63, 2253, 26, 710, 445, 15062, 402, 314, 4402, 4045, 14, 272, 520, 466, 10021, 63, 4443, 63, 2253, 26, 4888, 18017, 5083, 3989, 339, 520, 635, 1504, 26, 16424, 402, 314, 5477, 4045, 14, 3758, 370, 488, 14, 272, 520, 466, 1504, 26, 4888, 7304, 339, 520, 1107, 26, 710, 4402, 4045, 14, 272, 520, 4500, 26, 22507, 272, 408, 339, 340, 3400, 508, 4888, 55, 7862, 4100, 14, 3428, 6831, 26, 267, 24249, 63, 466, 275, 4888, 55, 7862, 4100, 14, 3947, 3428, 272, 916, 3400, 508, 4888, 55, 7862, 4100, 14, 3049, 6831, 26, 267, 24249, 63, 466, 275, 4888, 55, 7862, 4100, 14, 3947, 22134, 272, 916, 3400, 508, 4888, 55, 7862, 4100, 14, 12367, 6831, 26, 267, 24249, 63, 466, 275, 4888, 55, 7862, 4100, 14, 3947, 12367, 272, 916, 3400, 508, 4888, 55, 7862, 4100, 14, 8849, 6831, 26, 267, 24249, 63, 466, 275, 4888, 55, 7862, 4100, 14, 1944, 6831, 272, 587, 26, 267, 746, 15825, 5003, 5482, 5263, 8, 288, 283, 5003, 3400, 1471, 506, 1373, 402, 26, 7584, 12, 7030, 12, 283, 288, 283, 12367, 503, 12119, 12, 473, 4788, 450, 83, 7, 450, 3400, 9, 339, 340, 10021, 63, 4443, 63, 2253, 365 ]
[ 2803, 29, 1624, 13, 24, 199, 199, 624, 11654, 367, 5477, 9393, 1041, 421, 199, 646, 2050, 199, 504, 3473, 492, 365, 4304, 199, 199, 646, 20713, 199, 504, 15640, 14, 1018, 492, 334, 272, 4888, 18075, 2681, 12, 272, 26833, 2017, 12, 272, 26833, 12, 272, 4888, 792, 12, 272, 4888, 4761, 12, 272, 4888, 10076, 11043, 12, 272, 4888, 55, 7862, 4100, 12, 272, 4888, 18017, 5083, 3989, 12, 272, 4888, 8628, 6663, 7535, 12, 272, 4888, 7304, 199, 9, 199, 199, 504, 15640, 14, 24107, 14, 10901, 492, 27875, 199, 199, 504, 5048, 14, 2330, 14, 3924, 492, 334, 272, 15825, 5003, 5482, 5263, 12, 272, 327, 13423, 2681, 5482, 5263, 12, 199, 9, 199, 504, 5048, 14, 15388, 14, 5260, 492, 4137, 63, 10207, 470, 12, 4137, 63, 9646, 63, 10207, 470, 199, 504, 5048, 14, 15388, 14, 16355, 492, 5492, 199, 504, 5048, 14, 5668, 14, 4106, 14, 3118, 63, 7660, 492, 3400, 63, 6743, 12, 3633, 63, 1897, 199, 504, 5048, 14, 16355, 14, 496, 19294, 492, 4690, 199, 504, 5048, 14, 16355, 14, 15326, 492, 3957, 63, 3248, 199, 199, 363, 7307, 363, 275, 298, 7384, 7800, 12, 710, 1010, 65, 27657, 7290, 2, 199, 363, 1682, 363, 275, 298, 12006, 1015, 650, 2, 199, 363, 2123, 363, 275, 298, 815, 32, 262, 305, 6504, 14, 1308, 2, 199, 363, 5792, 363, 275, 4505, 3484, 2689, 40, 12913, 199, 199, 10186, 275, 2050, 14, 5572, 360, 607, 65, 27657, 358, 199, 199, 18914, 63, 466, 63, 2634, 275, 469, 272, 283, 3428, 356, 334, 267, 4888, 55, 7862, 4100, 14, 3428, 12, 267, 4888, 55, 7862, 4100, 14, 3947, 3428, 12, 267, 4888, 55, 7862, 4100, 14, 3428, 821, 36, 12, 267, 4888, 55, 7862, 4100, 14, 3947, 3428, 821, 36, 4706, 272, 283, 22134, 356, 334, 267, 4888, 55, 7862, 4100, 14, 22134, 12, 267, 4888, 55, 7862, 4100, 14, 3947, 22134, 12, 267, 4888, 55, 7862, 4100, 14, 22134, 821, 36, 12, 267, 4888, 55, 7862, 4100, 14, 3947, 22134, 821, 36, 4706, 272, 283, 12367, 356, 334, 267, 4888, 55, 7862, 4100, 14, 12367, 12, 267, 4888, 55, 7862, 4100, 14, 3947, 12367, 12, 267, 4888, 55, 7862, 4100, 14, 12367, 821, 36, 12, 267, 4888, 55, 7862, 4100, 14, 3947, 12367, 821, 36, 4706, 199, 93, 199, 509, 790, 12, 574, 315, 769, 8, 18914, 63, 466, 63, 2634, 14, 1744, 5109, 272, 367, 950, 315, 574, 26, 267, 24249, 63, 466, 63, 2634, 59, 1297, 61, 275, 790, 199, 199, 3, 961, 1817, 11492, 687, 4178, 921, 25325, 14, 1308, 15, 1246, 15, 81, 458, 3248, 1313, 63, 24, 72, 63, 1365, 14, 1360, 3, 76, 383, 5882, 199, 5590, 63, 3248, 275, 469, 272, 378, 26, 283, 1352, 878, 297, 272, 413, 26, 283, 43, 11737, 10207, 470, 297, 272, 499, 26, 283, 3456, 8716, 297, 272, 650, 26, 283, 46, 3844, 3294, 603, 22894, 297, 272, 841, 26, 283, 57, 5596, 297, 272, 959, 26, 283, 45, 22894, 297, 272, 1227, 26, 283, 26135, 5710, 297, 272, 1520, 26, 283, 5912, 12008, 7, 199, 93, 199, 199, 3, 961, 1817, 11492, 687, 4178, 921, 25325, 14, 1308, 15, 1246, 15, 81, 458, 3248, 1313, 63, 24, 72, 63, 1365, 14, 1360, 3, 76, 1493, 2182, 199, 6789, 63, 3248, 275, 469, 272, 378, 26, 283, 23373, 3194, 878, 297, 272, 413, 26, 283, 23373, 1804, 11737, 10207, 470, 297, 272, 499, 26, 283, 23373, 7949, 386, 297, 272, 650, 26, 283, 23373, 1488, 5596, 297, 272, 841, 26, 283, 23373, 603, 22894, 297, 272, 959, 26, 283, 40, 449, 11044, 297, 272, 1227, 26, 283, 1945, 470, 297, 272, 1520, 26, 283, 23373, 653, 3844, 3294, 603, 22894, 297, 272, 1695, 26, 283, 23373, 1487, 71, 5710, 297, 272, 1749, 26, 283, 5187, 12008, 7, 199, 93, 199, 199, 3, 5024, 730, 11109, 687, 27024, 370, 10904, 199, 3, 5800, 1455, 921, 1544, 14, 11600, 14, 1308, 15, 14945, 363, 1018, 63, 24, 72, 14, 1360, 3, 65, 32363, 10860, 1235, 199, 698, 63, 466, 63, 11256, 275, 469, 272, 27875, 14, 1558, 26, 20713, 14, 47, 2161, 1558, 12, 272, 27875, 14, 3241, 26, 20713, 14, 47, 2161, 2674, 12, 272, 27875, 14, 7281, 26, 20713, 14, 47, 2161, 10099, 12, 199, 93, 421, 199, 32, 2913, 199, 318, 1218, 63, 4844, 63, 1897, 8, 267, 4045, 63, 354, 12, 3400, 12, 10021, 63, 4443, 63, 2253, 29, 403, 12, 1504, 29, 403, 304, 272, 408, 2499, 282, 5477, 4402, 4045, 14, 339, 520, 635, 4045, 63, 354, 26, 710, 536, 402, 314, 4045, 14, 272, 520, 466, 4045, 63, 354, 26, 620, 339, 520, 635, 3400, 26, 710, 3400, 402, 314, 4045, 14, 272, 520, 4500, 3400, 26, 4888, 55, 7862, 4100, 334, 4610, 26, 2151, 687, 445, 4176, 4888, 55, 7862, 4100, 447, 6831, 804, 4952, 9, 339, 520, 635, 10021, 63, 4443, 63, 2253, 26, 710, 445, 15062, 402, 314, 4402, 4045, 14, 272, 520, 466, 10021, 63, 4443, 63, 2253, 26, 4888, 18017, 5083, 3989, 339, 520, 635, 1504, 26, 16424, 402, 314, 5477, 4045, 14, 3758, 370, 488, 14, 272, 520, 466, 1504, 26, 4888, 7304, 339, 520, 1107, 26, 710, 4402, 4045, 14, 272, 520, 4500, 26, 22507, 272, 408, 339, 340, 3400, 508, 4888, 55, 7862, 4100, 14, 3428, 6831, 26, 267, 24249, 63, 466, 275, 4888, 55, 7862, 4100, 14, 3947, 3428, 272, 916, 3400, 508, 4888, 55, 7862, 4100, 14, 3049, 6831, 26, 267, 24249, 63, 466, 275, 4888, 55, 7862, 4100, 14, 3947, 22134, 272, 916, 3400, 508, 4888, 55, 7862, 4100, 14, 12367, 6831, 26, 267, 24249, 63, 466, 275, 4888, 55, 7862, 4100, 14, 3947, 12367, 272, 916, 3400, 508, 4888, 55, 7862, 4100, 14, 8849, 6831, 26, 267, 24249, 63, 466, 275, 4888, 55, 7862, 4100, 14, 1944, 6831, 272, 587, 26, 267, 746, 15825, 5003, 5482, 5263, 8, 288, 283, 5003, 3400, 1471, 506, 1373, 402, 26, 7584, 12, 7030, 12, 283, 288, 283, 12367, 503, 12119, 12, 473, 4788, 450, 83, 7, 450, 3400, 9, 339, 340, 10021, 63, 4443, 63, 2253, 365, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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right 2010 Google Inc. # Copyright (c) 2011 Mitch Garnaat http://garnaat.org/ # Copyright (c) 2011, Eucalyptus Systems, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, dis- # tribute, sublicense, and/or sell copies of the Software, and to permit # persons to whom the Software is furnished to do so, subject to the fol- # lowing conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. """ Handles authentication required to AWS and GS """ import base64 import boto import boto.auth_handler import boto.exception import boto.plugin import boto.utils import hmac import sys import urllib import time import datetime import copy from email.utils import formatdate from boto.auth_handler import AuthHandler from boto.exception import BotoClientError # # the following is necessary because of the incompatibilities # between Python 2.4, 2.5, and 2.6 as well as the fact that some # people running 2.4 have installed hashlib as a separate module # this fix was provided by boto user mccormix. # see: http://code.google.com/p/boto/issues/detail?id=172 # for more details. # try: from hashlib import sha1 as sha from hashlib import sha256 as sha256 if sys.version[:3] == "2.4": # we are using an hmac that expects a .new() method. class Faker: def __init__(self, which): self.which = which self.digest_size = self.which().digest_size def new(self, *args, **kwargs): return self.which(*args, **kwargs) sha = Faker(sha) sha256 = Faker(sha256) except ImportError: import sha sha256 = None class HmacKeys(object): """Key based Auth handler helper.""" def __init__(self, host, config, provider): if provider.access_key is None or provider.secret_key is None: raise boto.auth_handler.NotReadyToAuthenticate() self.host = host self.update_provider(provider) def update_provider(self, provider): self._provider = provider self._hmac = hmac.new(self._provider.secret_key, digestmod=sha) if sha256: self._hmac_256 = hmac.new(self._provider.secret_key, digestmod=sha256) else: self._hmac_256 = None def algorithm(self): if self._hmac_256: return 'HmacSHA256' else: return 'HmacSHA1' def _get_hmac(self): if self._hmac_256: digestmod = sha256 else: digestmod = sha return hmac.new(self._provider.secret_key, digestmod=digestmod) def sign_string(self, string_to_sign): new_hmac = self._get_hmac() new_hmac.update(string_to_sign) return base64.encodestring(new_hmac.digest()).strip() def __getstate__(self): pickled_dict = copy.copy(self.__dict__) del pickled_dict['_hmac'] del pickled_dict['_hmac_256'] return pickled_dict def __setstate__(self, dct): self.__dict__ = dct self.update_provider(self._provider) class AnonAuthHandler(AuthHandler, HmacKeys): """ Implements Anonymous requests. """ capability = ['anon'] def __init__(self, host, config, provider): AuthHandler.__init__(self, host, config, provider) def add_auth(self, http_request, **kwargs): pass class HmacAuthV1Handler(AuthHandler, HmacKeys): """ Implements the HMAC request signing used by S3 and GS.""" capability = ['hmac-v1', 's3'] def __init__(self, host, config, provider): AuthHandler.__init__(self, host, config, provider) HmacKeys.__init__(self, host, config, provider) self._hmac_256 = None def update_provider(self, provider): super(HmacAuthV1Handler, self).update_provider(provider) self._hmac_256 = None def add_auth(self, http_request, **kwargs): headers = http_request.headers method = http_request.method auth_path = http_request.auth_path if 'Date' not in headers: headers['Date'] = formatdate(usegmt=True) if self._provider.security_token: key = self._provider.security_token_header headers[key] = self._provider.security_token string_to_sign = boto.utils.canonical_string(method, auth_path, headers, None, self._provider) boto.log.debug('StringToSign:\n%s' % string_to_sign) b64_hmac = self.sign_string(string_to_sign) auth_hdr = self._provider.auth_header headers['Authorization'] = ("%s %s:%s" % (auth_hdr, self._provider.access_key, b64_hmac)) class HmacAuthV2Handler(AuthHandler, HmacKeys): """ Implements the simplified HMAC authorization used by CloudFront. """ capability = ['hmac-v2', 'cloudfront'] def __init__(self, host, config, provider): AuthHandler.__init__(self, host, config, provider) HmacKeys.__init__(self, host, config, provider) self._hmac_256 = None def update_provider(self, provider): super(HmacAuthV2Handler, self).update_provider(provider) self._hmac_256 = None def add_auth(self, http_request, **kwargs): headers = http_request.headers if 'Date' not in headers: headers['Date'] = formatdate(usegmt=True) if self._provider.security_token: key = self._provider.security_token_header headers[key] = self._provider.security_token b64_hmac = self.sign_string(headers['Date']) auth_hdr = self._provider.auth_header headers['Authorization'] = ("%s %s:%s" % (auth_hdr, self._provider.access_key, b64_hmac)) class HmacAuthV3Handler(AuthHandler, HmacKeys): """Implements the new Version 3 HMAC authorization used by Route53.""" capability = ['hmac-v3', 'route53', 'ses'] def __init__(self, host, config, provider): AuthHandler.__init__(self, host, config, provider) HmacKeys.__init__(self, host, config, provider) def add_auth(self, http_request, **kwargs): headers = http_request.headers if 'Date' not in headers: headers['Date'] = formatdate(usegmt=True) if self._provider.security_token: key = self._provider.security_token_header headers[key] = self._provider.security_token b64_hmac = self.sign_string(headers['Date']) s = "AWS3-HTTPS AWSAccessKeyId=%s," % self._provider.access_key s += "Algorithm=%s,Signature=%s" % (self.algorithm(), b64_hmac) headers['X-Amzn-Authorization'] = s class HmacAuthV3HTTPHandler(AuthHandler, HmacKeys): """ Implements the new Version 3 HMAC authorization used by DynamoDB. """ capability = ['hmac-v3-http'] def __init__(self, host, config, provider): AuthHandler.__init__(self, host, config, provider) HmacKeys.__init__(self, host, config, provider) def headers_to_sign(self, http_request): """ Select the headers from the request that need to be included in the StringToSign. """ headers_to_sign = {} headers_to_sign = {'Host': self.host} for name, value in http_request.headers.items(): lname = name.lower() if lname.startswith('x-amz'): headers_to_sign[name] = value return headers_to_sign def canonical_headers(self, headers_to_sign): """ Return the headers that need to be included in the StringToSign in their canonical form by converting all header keys to lower case, sorting them in alphabetical order and then joining them into a string, separated by newlines. """ l = sorted(['%s:%s' % (n.lower().strip(), headers_to_sign[n].strip()) for n in headers_to_sign]) return '\n'.join(l) def string_to_sign(self, http_request): """ Return the canonical StringToSign as well as a dict containing the original version of all headers that were included in the StringToSign. """ headers_to_sign = self.headers_to_sign(http_request) canonical_headers = self.canonical_headers(headers_to_sign) string_to_sign = '\n'.join([http_request.method, http_request.auth_path, '', canonical_headers, '', http_request.body]) return string_to_sign, headers_to_sign def add_auth(self, req, **kwargs): """ Add AWS3 authentication to a request. :type req: :class`boto.connection.HTTPRequest` :param req: The HTTPRequest object. """ # This could be a retry. Make sure the previous # authorization header is removed first. if 'X-Amzn-Authorization' in req.headers: del req.headers['X-Amzn-Authorization'] req.headers['X-Amz-Date'] = formatdate(usegmt=True) if self._provider.security_token: req.headers['X-Amz-Security-Token'] = self._provider.security_token string_to_sign, headers_to_sign = self.string_to_sign(req) boto.log.debug('StringToSign:\n%s' % string_to_sign) hash_value = sha256(string_to_sign).digest() b64_hmac = self.sign_string(hash_value) s = "AWS3 AWSAccessKeyId=%s," % self._provider.access_key s += "Algorithm=%s," % self.algorithm() s += "SignedHeaders=%s," % ';'.join(headers_to_sign) s += "Signature=%s" % b64_hmac req.headers['X-Amzn-Authorization'] = s class HmacAuthV4Handler(AuthHandler, HmacKeys): """ Implements the new Version 4 HMAC authorization. """ capability = ['hmac-v4'] def __init__(self, host, config, provider, service_name=None, region_name=None): AuthHandler.__init__(self, host, config, provider) HmacKeys.__init__(self, host, config, provider) # You can set the service_name and region_name to override the # values which would otherwise come from the endpoint, e.g. # <service>.<region>.amazonaws.com. self.service_name = service_name self.region_name = region_name def _sign(self, key, msg, hex=False): if hex: sig = hmac.new(key, msg.encode('utf-8'), sha256).hexdigest() else: sig = hmac.new(key, msg.encode('utf-8'), sha256).digest() return sig def headers_to_sign(self, http_request): """ Select the headers from the request that need to be included in the StringToSign. """ headers_to_sign = {} headers_to_sign = {'Host': self.host} for name, value in http_request.headers.items(): lname = name.lower() if lname.startswith('x-amz'): headers_to_sign[name] = value return headers_to_sign def query_string(self, http_request): parameter_names = sorted(http_request.params.keys()) pairs = [] for pname in parameter_names: pval = str(http_request.params[pname]).encode('utf-8') pairs.append(urllib.quote(pname, safe='') + '=' + urllib.quote(pval, safe='-_~')) return '&'.join(pairs) def canonical_query_string(self, http_request): # POST requests pass parameters in through the # http_request.body field. if http_request.method == 'POST': return "" l = [] for param in sorted(http_request.params): value = str(http_request.params[param]) l.append('%s=%s' % (urllib.quote(param, safe='-_.~'), urllib.quote(value, safe='-_.~'))) return '&'.join(l) def canonical_headers(self, headers_to_sign): """ Return the headers that need to be included in the StringToSign in their canonical form by converting all header keys to lower case, sorting them in alphabetical order and then joining them into a string, separated by newlines. """ l = sorted(['%s:%s' % (n.lower().strip(), ' '.join(headers_to_sign[n].strip().split())) for n in headers_to_sign]) return '\n'.join(l) def signed_headers(self, headers_to_sign): l = ['%s' % n.lower().strip() for n in headers_to_sign] l = sorted(l) return ';'.join(l) def canonical_uri(self, http_request): return http_request.auth_path def payload(self, http_request): body = http_request.body # If the body is a file like object, we can use # boto.utils.compute_hash, which will avoid reading # the entire body into memory. if hasattr(body, 'seek') and hasattr(body, 'read'): return boto.utils.compute_hash(body, hash_algorithm=sha256)[0] return sha256(http_request.body).hexdigest() def canonical_request(self, http_request): cr = [http_request.method.upper()] cr.append(self.canonical_uri(http_request)) cr.append(self.canonical_query_string(http_request)) headers_to_sign = self.headers_to_sign(http_request) cr.append(self.canonical_headers(headers_to_sign) + '\n') cr.append(self.signed_headers(headers_to_sign)) cr.append(self.payload(http_request)) return '\n'.join(cr) def scope(self, http_request): scope = [self._provider.access_key] scope.append(http_request.timestamp) scope.append(http_request.region_name) scope.append(http_request.service_name) scope.append('aws4_request') return '/'.join(scope) def credential_scope(self, http_request): scope = [] http_request.timestamp = http_request.headers['X-Amz-Date'][0:8] scope.append(http_request.timestamp) # The service_name and region_name either come from: # * The service_name/region_name attrs or (if these values are None) # * parsed from the endpoint <service>.<region>.amazonaws.com. parts = http_request.host.split('.') if self.region_name is not None: region_name = self.region_name else: if len(parts) == 3: region_name = 'us-east-1' else: region_name = parts[1] if self.service_name is not None: service_name = self.service_name else: service_name = parts[0] http_request.service_name = service_name http_request.region_name = region_name scope.append(http_request.region_name) scope.append(http_request.service_name) scope.append('aws4_request') return '/'.join(scope) def string_to_sign(self, http_request, canonical_request): """ Return the canonical StringToSign as well as a dict containing the original version of all headers that were included in the StringToSign. """ sts = ['AWS4-HMAC-SHA256'] sts.append(http_request.headers['X-Amz-Date']) sts.append(self.credential_scope(http_request)) sts.append(sha256(canonical_request).hexdigest()) return '\n'.join(sts) def signature(self, http_request, string_to_sign): key = self._provider.secret_key k_date = self._sign(('AWS4' + key).encode('utf-8'), http_request.timestamp) k_region = self._sign(k_date, http_request.region_name) k_service = self._sign(k_region, http_request.service_name) k_signing = self._sign(k_service, 'aws4_request') return self._sign(k_signing, string_to_sign, hex=True) def add_auth(self, req, **kwargs): """ Add AWS4 authentication to a request. :type req: :class`boto.connection.HTTPRequest` :param req: The HTTPRequest object. """ # This could be a retry. Make sure the previous # authorization header is removed first. if 'X-Amzn-Authorization' in req.headers: del req.headers['X-Amzn-Authorization'] now = datetime.datetime.utcnow() req.headers['X-Amz-Date'] = now.strftime('%Y%m%dT%H%M%SZ') if self._provider.security_token: req.headers['X-Amz-Security-Token'] = self._provider.security_token qs = self.query_string(req) if qs and req.method == 'POST': # Stash request parameters into post body # before we generate the signature. req.body = qs req.headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8' req.headers['Content-Length'] = str(len(req.body)) else: # Safe to modify req.path here since # the signature will use req.auth_path. req.path = req.path.split('?')[0] req.path = req.path + '?' + qs canonical_request = self.canonical_request(req) boto.log.debug('CanonicalRequest:\n%s' % canonical_request) string_to_sign = self.string_to_sign(req, canonical_request) boto.log.debug('StringToSign:\n%s' % string_to_sign) signature = self.signature(req, string_to_sign) boto.log.debug('Signature:\n%s' % signature) headers_to_sign = self.headers_to_sign(req) l = ['AWS4-HMAC-SHA256 Credential=%s' % self.scope(req)] l.append('SignedHeaders=%s' % self.signed_headers(headers_to_sign)) l.append('Signature=%s' % signature) req.headers['Authorization'] = ','.join(l) class QuerySignatureHelper(HmacKeys): """ Helper for Query signature based Auth handler. Concrete sub class need to implement _calc_sigature method. """ def add_auth(self, http_request, **kwargs): headers = http_request.headers params = http_request.params params['AWSAccessKeyId'] = self._provider.access_key params['SignatureVersion'] = self.SignatureVersion params['Timestamp'] = boto.utils.get_ts() qs, signature = self._calc_signature( http_request.params, http_request.method, http_request.auth_path, http_request.host) boto.log.debug('query_string: %s Signature: %s' % (qs, signature)) if http_request.method == 'POST': headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8' http_request.body = qs + '&Signature=' + urllib.quote_plus(signature) http_request.headers['Content-Length'] = str(len(http_request.body)) else: http_request.body = '' # if this is a retried request, the qs from the previous try will # already be there, we need to get rid of that and rebuild it http_request.path = http_request.path.split('?')[0] http_request.path = (http_request.path + '?' + qs + '&Signature=' + urllib.quote_plus(signature)) class QuerySignatureV0AuthHandler(QuerySignatureHelper, AuthHandler): """Provides Signature V0 Signing""" SignatureVersion = 0 capability = ['sign-v0'] def _calc_signature(self, params, *args): boto.log.debug('using _calc_signature_0') hmac = self._get_hmac() s = params['Action'] + params['Timestamp'] hmac.update(s) keys = params.keys() keys.sort(cmp=lambda x, y: cmp(x.lower(), y.lower())) pairs = [] for key in keys: val = boto.utils.get_utf8_value(params[key]) pairs.append(key + '=' + urllib.quote(val)) qs = '&'.join(pairs) return (qs, base64.b64encode(hmac.digest())) class QuerySignatureV1AuthHandler(QuerySignatureHelper, AuthHandler): """ Provides Query Signature V1 Authentication. """ SignatureVersion = 1 capability = ['sign-v1', 'mturk'] def __init__(self, *args, **kw): QuerySignatureHelper.__init__(self, *args, **kw) AuthHandler.__init__(self, *args, **kw) self._hmac_256 = None def _calc_signature(self, params, *args): boto.log.debug('using _calc_signature_1') hmac = self._get_hmac() keys = params.keys() keys.sort(cmp=lambda x, y: cmp(x.lower(), y.lower())) pairs = [] for key in keys: hmac.update(key) val = boto.utils.get_utf8_value(params[key]) hmac.update(val) pairs.append(key + '=' + urllib.quote(val)) qs = '&'.join(pairs) return (qs, base64.b64encode(hmac.digest())) class QuerySignatureV2AuthHandler(QuerySignatureHelper, AuthHandler): """Provides Query Signature V2 Authentication.""" SignatureVersion = 2 capability = ['sign-v2', 'ec2', 'ec2', 'emr', 'fps', 'ecs', 'sdb', 'iam', 'rds', 'sns', 'sqs', 'cloudformation'] def _calc_signature(self, params, verb, path, server_name): boto.log.debug('using _calc_signature_2') string_to_sign = '%s\n%s\n%s\n' % (verb, server_name.lower(), path) hmac = self._get_hmac() params['SignatureMethod'] = self.algorithm() if self._provider.security_token: params['SecurityToken'] = self._provider.security_token keys = sorted(params.keys()) pairs = [] for key in keys: val = boto.utils.get_utf8_value(params[key]) pairs.append(urllib.quote(key, safe='') + '=' + urllib.quote(val, safe='-_~')) qs = '&'.join(pairs) boto.log.debug('query string: %s' % qs) string_to_sign += qs boto.log.debug('string_to_sign: %s' % string_to_sign) hmac.update(string_to_sign) b64 = base64.b64encode(hmac.digest()) boto.log.debug('len(b64)=%d' % len(b64)) boto.log.debug('base64 encoded digest: %s' % b64) return (qs, b64) class POSTPathQSV2AuthHandler(QuerySignatureV2AuthHandler, AuthHandler): """ Query Signature V2 Authentication relocating signed query into the path and allowing POST requests with Content-Types. """ capability = ['mws'] def add_auth(self, req, **kwargs): req.params['AWSAccessKeyId'] = self._provider.access_key req.params['SignatureVersion'] = self.SignatureVersion req.params['Timestamp'] = boto.utils.get_ts() qs, signature = self._calc_signature(req.params, req.method, req.auth_path, req.host) boto.log.debug('query_string: %s Signature: %s' % (qs, signature)) if req.method == 'POST': req.headers['Content-Length'] = str(len(req.body)) req.headers['Content-Type'] = req.headers.get('Content-Type', 'text/plain') else: req.body = '' # if this is a retried req, the qs from the previous try will # already be there, we need to get rid of that and rebuild it req.path = req.path.split('?')[0] req.path = (req.path + '?' + qs + '&Signature=' + urllib.quote_plus(signature)) def get_auth_handler(host, config, provider, requested_capability=None): """Finds an AuthHandler that is ready to authenticate. Lists through all the registered AuthHandlers to find one that is willing to handle for the requested capabilities, config and provider. :type host: string :param host: The name of the host :type config: :param config: :type provider: :param provider: Returns: An implementation of AuthHandler. Raises: boto.exception.NoAuthHandlerFound """ ready_handlers = [] auth_handlers = boto.plugin.get_plugin(AuthHandler, requested_capability) total_handlers = len(auth_handlers) for handler in auth_handlers: try: ready_handlers.append(handler(host, config, provider)) except boto.auth_handler.NotReadyToAuthenticate: pass if not ready_handlers: checked_handlers = auth_handlers names = [handler.__name__ for handler in checked_handlers] raise boto.exception.NoAuthHandlerFound( 'No handler was ready to authenticate. %d handlers were checked.' ' %s ' 'Check your credentials' % (len(names), str(names))) # We select the last ready auth handler that was loaded, to allow users to # customize how auth works in environments where there are shared boto # config files (e.g., /etc/boto.cfg and ~/.boto): The more general, # system-wide shared configs should be loaded first, and the user's # customizations loaded last. That way, for example, the system-wide # config might include a plugin_directory that includes a service account # auth plugin shared by all users of a Google Compute Engine instance # (allowing sharing of non-user data between various services), and the # user could override this with a .boto config that includes user-specific # credentials (for access to user data). return ready_handlers[-1]
bsd-3-clause
[ 3, 1898, 7129, 4475, 3277, 14, 199, 3, 1898, 334, 67, 9, 7760, 603, 9414, 598, 26272, 1455, 921, 71, 26272, 14, 1308, 15, 199, 3, 1898, 334, 67, 9, 7760, 12, 662, 85, 915, 89, 541, 527, 15285, 12, 3277, 14, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 421, 199, 624, 199, 23555, 6299, 1415, 370, 10168, 436, 598, 51, 199, 624, 199, 199, 646, 1300, 772, 199, 646, 6055, 199, 646, 6055, 14, 1178, 63, 2232, 199, 646, 6055, 14, 1971, 199, 646, 6055, 14, 2718, 199, 646, 6055, 14, 1208, 199, 646, 20330, 199, 646, 984, 199, 646, 4011, 199, 646, 900, 199, 646, 2197, 199, 646, 1331, 199, 504, 3031, 14, 1208, 492, 1475, 602, 199, 199, 504, 6055, 14, 1178, 63, 2232, 492, 3590, 2461, 199, 504, 6055, 14, 1971, 492, 24411, 19992, 199, 3, 199, 3, 314, 2569, 365, 5784, 2952, 402, 314, 315, 863, 2159, 66, 5462, 199, 3, 3382, 2018, 499, 14, 20, 12, 499, 14, 21, 12, 436, 499, 14, 22, 465, 5521, 465, 314, 10572, 626, 2005, 199, 3, 13135, 3879, 499, 14, 20, 1172, 4903, 8337, 465, 282, 7396, 859, 199, 3, 642, 5325, 1990, 2741, 701, 6055, 922, 16377, 989, 13979, 14, 199, 3, 1937, 26, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 10914, 15, 10115, 15, 5506, 31, 344, 29, 10419, 199, 3, 367, 1655, 2436, 14, 199, 3, 199, 893, 26, 272, 687, 8337, 492, 7793, 17, 465, 7793, 272, 687, 8337, 492, 7793, 3912, 465, 7793, 3912, 339, 340, 984, 14, 1023, 1491, 19, 61, 508, 298, 18, 14, 20, 582, 267, 327, 781, 787, 1808, 376, 20330, 626, 14292, 282, 1275, 1222, 342, 1083, 14, 267, 1021, 481, 12630, 26, 288, 347, 636, 826, 721, 277, 12, 1314, 304, 355, 291, 14, 6777, 275, 1314, 355, 291, 14, 5671, 63, 890, 275, 291, 14, 6777, 1252, 5671, 63, 890, 953, 347, 892, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 355, 372, 291, 14, 6777, 2031, 589, 12, 1011, 958, 9, 398, 7793, 275, 481, 12630, 8, 4835, 9, 267, 7793, 3912, 275, 481, 12630, 8, 4835, 3912, 9, 199, 199, 2590, 3545, 26, 272, 492, 7793, 272, 7793, 3912, 275, 488, 421, 199, 533, 869, 3088, 6340, 8, 785, 304, 272, 408, 1197, 4079, 3590, 3016, 5922, 1041, 339, 347, 636, 826, 721, 277, 12, 1591, 12, 1101, 12, 5022, 304, 267, 340, 5022, 14, 2732, 63, 498, 365, 488, 503, 5022, 14, 4731, 63, 498, 365, 488, 26, 288, 746, 6055, 14, 1178, 63, 2232, 14, 1763, 17960, 1378, 21476, 342, 267, 291, 14, 1102, 275, 1591, 267, 291, 14, 873, 63, 3780, 8, 3780, 9, 339, 347, 1678, 63, 3780, 8, 277, 12, 5022, 304, 267, 291, 423, 3780, 275, 5022, 267, 291, 423, 18537, 275, 20330, 14, 1222, 8, 277, 423, 3780, 14, 4731, 63, 498, 12, 10017, 1494, 29, 4835, 9, 267, 340, 7793, 3912, 26, 288, 291, 423, 18537, 63, 3912, 275, 20330, 14, 1222, 8, 277, 423, 3780, 14, 4731, 63, 498, 12, 4228, 10017, 1494, 29, 4835, 3912, 9, 267, 587, 26, 288, 291, 423, 18537, 63, 3912, 275, 488, 339, 347, 5563, 8, 277, 304, 267, 340, 291, 423, 18537, 63, 3912, 26, 288, 372, 283, 40, 3088, 8461, 3912, 7, 267, 587, 26, 288, 372, 283, 40, 3088, 8461, 17, 7, 339, 347, 485, 362, 63, 18537, 8, 277, 304, 267, 340, 291, 423, 18537, 63, 3912, 26, 288, 10017, 1494, 275, 7793, 3912, 267, 587, 26, 288, 10017, 1494, 275, 7793, 267, 372, 20330, 14, 1222, 8, 277, 423, 3780, 14, 4731, 63, 498, 12, 717, 10017, 1494, 29, 5671, 1494, 9, 339, 347, 2070, 63, 875, 8, 277, 12, 1059, 63, 475, 63, 1037, 304, 267, 892, 63, 18537, 275, 291, 423, 362, 63, 18537, 342, 267, 892, 63, 18537, 14, 873, 8, 875, 63, 475, 63, 1037, 9, 267, 372, 1300, 772, 14, 2143, 875, 8, 1222, 63, 18537, 14, 5671, 8801, 1913, 342, 339, 347, 636, 16011, 721, 277, 304, 267, 18731, 63, 807, 275, 1331, 14, 1574, 8, 277, 855, 807, 3368, 267, 2150, 18731, 63, 807, 8680, 18537, 418, 267, 2150, 18731, 63, 807, 8680, 18537, 63, 3912, 418, 267, 372, 18731, 63, 807, 339, 347, 636, 17212, 721, 277, 12, 16354, 304, 267, 291, 855, 807, 363, 275, 16354, 267, 291, 14, 873, 63, 3780, 8, 277, 423, 3780, 9, 421, 199, 533, 1626, 265, 21547, 8, 21547, 12, 869, 3088, 6340, 304, 272, 408, 272, 24664, 24523, 4145, 14, 272, 408, 339, 19854, 275, 788, 21009, 418, 339, 347, 636, 826, 721, 277, 12, 1591, 12, 1101, 12, 5022, 304, 267, 3590, 2461, 855, 826, 721, 277, 12, 1591, 12, 1101, 12, 5022, 9, 339, 347, 1050, 63, 1178 ]
[ 1898, 7129, 4475, 3277, 14, 199, 3, 1898, 334, 67, 9, 7760, 603, 9414, 598, 26272, 1455, 921, 71, 26272, 14, 1308, 15, 199, 3, 1898, 334, 67, 9, 7760, 12, 662, 85, 915, 89, 541, 527, 15285, 12, 3277, 14, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 421, 199, 624, 199, 23555, 6299, 1415, 370, 10168, 436, 598, 51, 199, 624, 199, 199, 646, 1300, 772, 199, 646, 6055, 199, 646, 6055, 14, 1178, 63, 2232, 199, 646, 6055, 14, 1971, 199, 646, 6055, 14, 2718, 199, 646, 6055, 14, 1208, 199, 646, 20330, 199, 646, 984, 199, 646, 4011, 199, 646, 900, 199, 646, 2197, 199, 646, 1331, 199, 504, 3031, 14, 1208, 492, 1475, 602, 199, 199, 504, 6055, 14, 1178, 63, 2232, 492, 3590, 2461, 199, 504, 6055, 14, 1971, 492, 24411, 19992, 199, 3, 199, 3, 314, 2569, 365, 5784, 2952, 402, 314, 315, 863, 2159, 66, 5462, 199, 3, 3382, 2018, 499, 14, 20, 12, 499, 14, 21, 12, 436, 499, 14, 22, 465, 5521, 465, 314, 10572, 626, 2005, 199, 3, 13135, 3879, 499, 14, 20, 1172, 4903, 8337, 465, 282, 7396, 859, 199, 3, 642, 5325, 1990, 2741, 701, 6055, 922, 16377, 989, 13979, 14, 199, 3, 1937, 26, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 10914, 15, 10115, 15, 5506, 31, 344, 29, 10419, 199, 3, 367, 1655, 2436, 14, 199, 3, 199, 893, 26, 272, 687, 8337, 492, 7793, 17, 465, 7793, 272, 687, 8337, 492, 7793, 3912, 465, 7793, 3912, 339, 340, 984, 14, 1023, 1491, 19, 61, 508, 298, 18, 14, 20, 582, 267, 327, 781, 787, 1808, 376, 20330, 626, 14292, 282, 1275, 1222, 342, 1083, 14, 267, 1021, 481, 12630, 26, 288, 347, 636, 826, 721, 277, 12, 1314, 304, 355, 291, 14, 6777, 275, 1314, 355, 291, 14, 5671, 63, 890, 275, 291, 14, 6777, 1252, 5671, 63, 890, 953, 347, 892, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 355, 372, 291, 14, 6777, 2031, 589, 12, 1011, 958, 9, 398, 7793, 275, 481, 12630, 8, 4835, 9, 267, 7793, 3912, 275, 481, 12630, 8, 4835, 3912, 9, 199, 199, 2590, 3545, 26, 272, 492, 7793, 272, 7793, 3912, 275, 488, 421, 199, 533, 869, 3088, 6340, 8, 785, 304, 272, 408, 1197, 4079, 3590, 3016, 5922, 1041, 339, 347, 636, 826, 721, 277, 12, 1591, 12, 1101, 12, 5022, 304, 267, 340, 5022, 14, 2732, 63, 498, 365, 488, 503, 5022, 14, 4731, 63, 498, 365, 488, 26, 288, 746, 6055, 14, 1178, 63, 2232, 14, 1763, 17960, 1378, 21476, 342, 267, 291, 14, 1102, 275, 1591, 267, 291, 14, 873, 63, 3780, 8, 3780, 9, 339, 347, 1678, 63, 3780, 8, 277, 12, 5022, 304, 267, 291, 423, 3780, 275, 5022, 267, 291, 423, 18537, 275, 20330, 14, 1222, 8, 277, 423, 3780, 14, 4731, 63, 498, 12, 10017, 1494, 29, 4835, 9, 267, 340, 7793, 3912, 26, 288, 291, 423, 18537, 63, 3912, 275, 20330, 14, 1222, 8, 277, 423, 3780, 14, 4731, 63, 498, 12, 4228, 10017, 1494, 29, 4835, 3912, 9, 267, 587, 26, 288, 291, 423, 18537, 63, 3912, 275, 488, 339, 347, 5563, 8, 277, 304, 267, 340, 291, 423, 18537, 63, 3912, 26, 288, 372, 283, 40, 3088, 8461, 3912, 7, 267, 587, 26, 288, 372, 283, 40, 3088, 8461, 17, 7, 339, 347, 485, 362, 63, 18537, 8, 277, 304, 267, 340, 291, 423, 18537, 63, 3912, 26, 288, 10017, 1494, 275, 7793, 3912, 267, 587, 26, 288, 10017, 1494, 275, 7793, 267, 372, 20330, 14, 1222, 8, 277, 423, 3780, 14, 4731, 63, 498, 12, 717, 10017, 1494, 29, 5671, 1494, 9, 339, 347, 2070, 63, 875, 8, 277, 12, 1059, 63, 475, 63, 1037, 304, 267, 892, 63, 18537, 275, 291, 423, 362, 63, 18537, 342, 267, 892, 63, 18537, 14, 873, 8, 875, 63, 475, 63, 1037, 9, 267, 372, 1300, 772, 14, 2143, 875, 8, 1222, 63, 18537, 14, 5671, 8801, 1913, 342, 339, 347, 636, 16011, 721, 277, 304, 267, 18731, 63, 807, 275, 1331, 14, 1574, 8, 277, 855, 807, 3368, 267, 2150, 18731, 63, 807, 8680, 18537, 418, 267, 2150, 18731, 63, 807, 8680, 18537, 63, 3912, 418, 267, 372, 18731, 63, 807, 339, 347, 636, 17212, 721, 277, 12, 16354, 304, 267, 291, 855, 807, 363, 275, 16354, 267, 291, 14, 873, 63, 3780, 8, 277, 423, 3780, 9, 421, 199, 533, 1626, 265, 21547, 8, 21547, 12, 869, 3088, 6340, 304, 272, 408, 272, 24664, 24523, 4145, 14, 272, 408, 339, 19854, 275, 788, 21009, 418, 339, 347, 636, 826, 721, 277, 12, 1591, 12, 1101, 12, 5022, 304, 267, 3590, 2461, 855, 826, 721, 277, 12, 1591, 12, 1101, 12, 5022, 9, 339, 347, 1050, 63, 1178, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
perryjohnson/biplaneblade
sandia_blade_lib/prep_stn32_mesh.py
1
10860
"""Write initial TrueGrid files for one Sandia blade station. Usage ----- start an IPython (qt)console with the pylab flag: $ ipython qtconsole --pylab or $ ipython --pylab Then, from the prompt, run this script: |> %run sandia_blade_lib/prep_stnXX_mesh.py or |> import sandia_blade_lib/prep_stnXX_mesh Author: Perry Roth-Johnson Last updated: April 10, 2014 """ import matplotlib.pyplot as plt import lib.blade as bl import lib.poly_utils as pu from shapely.geometry import Polygon # SET THESE PARAMETERS ----------------- station_num = 32 # -------------------------------------- plt.close('all') # load the Sandia blade m = bl.MonoplaneBlade('Sandia blade SNL100-00', 'sandia_blade') # pre-process the station dimensions station = m.list_of_stations[station_num-1] station.airfoil.create_polygon() station.structure.create_all_layers() station.structure.save_all_layer_edges() station.structure.write_all_part_polygons() # plot the parts station.plot_parts() # access the structure for this station st = station.structure # upper spar cap ----------------------------------------------------------- label = 'upper spar cap' # create the bounding polygon usc = st.spar_cap.layer['upper'] is1 = st.internal_surface_1.layer['resin'] points_usc = [ tuple(usc.left[0]), # SparCap_upper.txt (usc.left[0][0], 0.1), is1.polygon.interiors[0].coords[0], # InternalSurface1_resin.txt tuple(usc.right[1]), # SparCap_upper.txt (usc.right[1][0], 0.25), (usc.left[0][0], 0.25) ] bounding_polygon = Polygon(points_usc) pu.plot_polygon(bounding_polygon, 'None', '#000000') # cut the new layer polygons pu.cut_plot_and_write_alt_layer(st.external_surface, 'triax', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.external_surface, 'gelcoat', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.internal_surface_1, 'resin', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.internal_surface_1, 'triax', label, bounding_polygon) # lower spar cap ----------------------------------------------------------- label = 'lower spar cap' # create the bounding polygon lsc = st.spar_cap.layer['lower'] points_lsc = [ tuple(lsc.left[1]), (lsc.left[1][0], 0.0), is1.polygon.interiors[0].coords[292-222], # InternalSurface1_resin.txt tuple(lsc.right[0]), # SparCap_lower.txt (lsc.right[0][0], -0.15), (lsc.left[1][0], -0.15) ] bounding_polygon = Polygon(points_lsc) pu.plot_polygon(bounding_polygon, 'None', '#000000') # cut the new layer polygons pu.cut_plot_and_write_alt_layer(st.external_surface, 'triax', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.external_surface, 'gelcoat', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.internal_surface_1, 'resin', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.internal_surface_1, 'triax', label, bounding_polygon) # TE reinforcement, upper 1 ------------------------------------------------ label = 'TE reinforcement, upper 1' # create the bounding polygon ter = st.TE_reinforcement.layer['foam'] points_teu1 = [ (ter.top[0][0], 0.25), # TE_Reinforcement_foam.txt tuple(ter.top[0]), # TE_Reinforcement_foam.txt (0.47, 0.12), is1.polygon.interiors[0].coords[457-222], # InternalSurface1_resin.txt (is1.polygon.interiors[0].coords[457-222][0], 0.25) # InternalSurface1_resin.txt ] bounding_polygon = Polygon(points_teu1) pu.plot_polygon(bounding_polygon, 'None', '#000000') # cut the new layer polygons pu.cut_plot_and_write_alt_layer(st.external_surface, 'triax', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.external_surface, 'gelcoat', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.internal_surface_1, 'resin', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.internal_surface_1, 'triax', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.TE_reinforcement, 'foam', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.TE_reinforcement, 'uniax', label, bounding_polygon) # TE reinforcement, lower 1 ------------------------------------------------ label = 'TE reinforcement, lower 1' # create the bounding polygon points_tel1 = [ (ter.bottom[0][0], -0.15), # TE_Reinforcement_foam.txt tuple(ter.bottom[1]), # TE_Reinforcement_foam.txt (0.47, -0.01), (0.7, 0.05), points_teu1[-2], # InternalSurface1_resin.txt (points_teu1[-1][0], -0.15) # InternalSurface1_resin.txt ] bounding_polygon = Polygon(points_tel1) pu.plot_polygon(bounding_polygon, 'None', '#000000') # cut the new layer polygons pu.cut_plot_and_write_alt_layer(st.external_surface, 'triax', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.external_surface, 'gelcoat', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.internal_surface_1, 'resin', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.internal_surface_1, 'triax', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.TE_reinforcement, 'foam', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.TE_reinforcement, 'uniax', label, bounding_polygon) # TE reinforcement, upper 2 ------------------------------------------------ label = 'TE reinforcement, upper 2' # create the bounding polygon is1t = st.internal_surface_1.layer['triax'] points_teu2 = [ points_teu1[-1], points_teu1[-2], is1t.polygon.interiors[0].coords[364-176], # InternalSurface1_triax.txt is1t.polygon.exterior.coords[24-3], # InternalSurface1_triax.txt (is1t.polygon.exterior.coords[24-3][0], 0.25) # InternalSurface1_triax.txt ] bounding_polygon = Polygon(points_teu2) pu.plot_polygon(bounding_polygon, 'None', '#000000') # cut the new layer polygons pu.cut_plot_and_write_alt_layer(st.external_surface, 'triax', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.external_surface, 'gelcoat', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.internal_surface_1, 'resin', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.internal_surface_1, 'triax', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.TE_reinforcement, 'foam', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.TE_reinforcement, 'uniax', label, bounding_polygon) # TE reinforcement, lower 2 ------------------------------------------------ label = 'TE reinforcement, lower 2' # create the bounding polygon points_tel2 = [ (points_teu2[0][0], -0.1), points_teu2[1], points_teu2[2], points_teu2[3], (points_teu2[3][0], -0.1) ] bounding_polygon = Polygon(points_tel2) pu.plot_polygon(bounding_polygon, 'None', '#000000') # cut the new layer polygons pu.cut_plot_and_write_alt_layer(st.external_surface, 'triax', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.external_surface, 'gelcoat', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.internal_surface_1, 'resin', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.internal_surface_1, 'triax', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.TE_reinforcement, 'foam', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.TE_reinforcement, 'uniax', label, bounding_polygon) # TE reinforcement, upper 3 ------------------------------------------------ label = 'TE reinforcement, upper 3' # create the bounding polygon teru = st.TE_reinforcement.layer['uniax'] est = st.external_surface.layer['triax'] esg = st.external_surface.layer['gelcoat'] points_teu3 = [ points_teu2[-1], points_teu2[-2], ter.polygon.exterior.coords[0], teru.polygon.exterior.coords[0], (est.polygon.exterior.coords[-1][0], 0.002), est.polygon.exterior.coords[-2], esg.polygon.exterior.coords[-2], (esg.polygon.exterior.coords[-2][0], 0.25) ] bounding_polygon = Polygon(points_teu3) pu.plot_polygon(bounding_polygon, 'None', '#000000') # cut the new layer polygons pu.cut_plot_and_write_alt_layer(st.external_surface, 'triax', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.external_surface, 'gelcoat', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.TE_reinforcement, 'foam', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.TE_reinforcement, 'uniax', label, bounding_polygon) # TE reinforcement, lower 3 ------------------------------------------------ label = 'TE reinforcement, lower 3' # create the bounding polygon points_tel3 = [ (points_teu3[0][0], -0.1), points_teu3[1], points_teu3[2], points_teu3[3], points_teu3[4], est.polygon.exterior.coords[-1], esg.polygon.exterior.coords[-1], (points_teu3[4][0], -0.1) ] bounding_polygon = Polygon(points_tel3) pu.plot_polygon(bounding_polygon, 'None', '#000000') # cut the new layer polygons pu.cut_plot_and_write_alt_layer(st.external_surface, 'triax', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.external_surface, 'gelcoat', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.TE_reinforcement, 'foam', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.TE_reinforcement, 'uniax', label, bounding_polygon) # LE panel ----------------------------------------------------------------- label = 'LE panel' # create the bounding polygon lep = st.LE_panel.layer['foam'] is1 = st.internal_surface_1.layer['resin'] points_le = [ (-0.7,-0.1), (lep.bottom[0][0],-0.1), (lep.bottom[0][0],0.25), (-0.7, 0.25) ] bounding_polygon = Polygon(points_le) pu.plot_polygon(bounding_polygon, 'None', '#000000') # cut the new layer polygons pu.cut_plot_and_write_alt_layer(st.external_surface, 'triax', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.external_surface, 'gelcoat', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.internal_surface_1, 'resin', label, bounding_polygon) pu.cut_plot_and_write_alt_layer(st.internal_surface_1, 'triax', label, bounding_polygon) # show the plot plt.show() # write the TrueGrid input file for mesh generation --------------------- st.write_truegrid_inputfile( interrupt_flag=True, additional_layers=[ st.spar_cap.layer['upper'], st.spar_cap.layer['lower'], st.LE_panel.layer['foam'] ], alt_TE_reinforcement=True, soft_warning=False)
gpl-3.0
[ 624, 3534, 2536, 715, 7900, 1584, 367, 1373, 29359, 2391, 330, 17236, 16518, 14, 2999, 199, 7692, 202, 199, 9858, 202, 199, 928, 376, 16243, 334, 8440, 9, 6614, 543, 314, 19199, 3305, 26, 202, 199, 4, 284, 1548, 19227, 6614, 1553, 32538, 202, 199, 269, 202, 199, 4, 284, 1548, 1553, 32538, 202, 199, 28226, 12, 687, 314, 8457, 12, 1255, 642, 2884, 26, 202, 199, 92, 30, 450, 1065, 28698, 2391, 63, 66, 17236, 63, 773, 15, 10837, 63, 270, 78, 2483, 63, 6480, 14, 647, 202, 199, 269, 202, 199, 92, 30, 492, 28698, 2391, 63, 66, 17236, 63, 773, 15, 10837, 63, 270, 78, 2483, 63, 6480, 2999, 199, 5949, 26, 3492, 651, 6848, 273, 13, 5691, 25338, 265, 202, 199, 6090, 4588, 26, 437, 28026, 1616, 12, 6927, 2999, 199, 624, 8065, 199, 646, 8027, 14, 13563, 465, 4488, 202, 199, 646, 1973, 14, 66, 17236, 465, 6826, 202, 199, 646, 1973, 14, 6023, 63, 1208, 465, 18848, 202, 199, 504, 2215, 590, 14, 7660, 492, 17560, 8065, 199, 3, 11543, 4221, 654, 37, 23710, 10652, 13, 202, 199, 10600, 63, 1507, 275, 4337, 202, 199, 3, 11016, 8648, 202, 199, 6003, 14, 1600, 360, 452, 358, 2999, 199, 3, 2248, 314, 29359, 2391, 330, 17236, 202, 199, 77, 275, 6826, 14, 6671, 411, 24064, 34, 17236, 360, 23906, 2391, 330, 17236, 428, 14176, 1960, 13, 383, 297, 283, 18904, 2391, 63, 66, 17236, 358, 2999, 199, 3, 876, 13, 1412, 314, 16518, 7365, 202, 199, 10600, 275, 333, 14, 513, 63, 1618, 63, 270, 1298, 59, 10600, 63, 1507, 13, 17, 61, 202, 199, 10600, 14, 8387, 545, 382, 14, 981, 63, 16295, 342, 202, 199, 10600, 14, 6976, 14, 981, 63, 452, 63, 4359, 342, 202, 199, 10600, 14, 6976, 14, 2117, 63, 452, 63, 1897, 63, 6929, 342, 202, 199, 10600, 14, 6976, 14, 952, 63, 452, 63, 2064, 63, 2515, 18067, 342, 2999, 199, 3, 5137, 314, 4184, 202, 199, 10600, 14, 2798, 63, 4181, 342, 2999, 199, 3, 2879, 314, 5523, 367, 642, 16518, 202, 199, 270, 275, 16518, 14, 6976, 2999, 199, 3, 7008, 28668, 4021, 9527, 13715, 202, 199, 1302, 275, 283, 4142, 28668, 4021, 7, 2999, 199, 3, 1218, 314, 16842, 17248, 202, 199, 527, 67, 275, 410, 14, 22502, 63, 2874, 14, 1897, 459, 4142, 418, 202, 199, 374, 17, 275, 410, 14, 4672, 63, 10992, 63, 17, 14, 1897, 459, 470, 262, 418, 202, 199, 3438, 63, 527, 67, 275, 359, 1128, 2008, 8, 527, 67, 14, 3039, 59, 16, 2522, 4519, 327, 428, 462, 9155, 63, 4142, 14, 2424, 1128, 334, 527, 67, 14, 3039, 59, 16, 1527, 16, 467, 378, 14, 17, 395, 1128, 365, 17, 14, 16295, 14, 5707, 322, 1384, 59, 16, 1055, 8032, 59, 16, 467, 257, 327, 12624, 16923, 17, 63, 470, 262, 14, 2424, 1128, 2008, 8, 527, 67, 14, 1019, 59, 17, 2522, 3777, 327, 428, 462, 9155, 63, 4142, 14, 2424, 1128, 334, 527, 67, 14, 1019, 59, 17, 1527, 16, 467, 378, 14, 821, 395, 1128, 334, 527, 67, 14, 3039, 59, 16, 1527, 16, 467, 378, 14, 821, 9, 1128, 1622, 202, 199, 24511, 63, 16295, 275, 17560, 8, 3438, 63, 527, 67, 9, 202, 199, 3165, 14, 2798, 63, 16295, 8, 24511, 63, 16295, 12, 283, 403, 297, 3943, 3273, 358, 2999, 199, 3, 10415, 314, 892, 4045, 30658, 202, 199, 3165, 14, 5919, 63, 2798, 63, 460, 63, 952, 63, 4478, 63, 1897, 8, 270, 14, 5159, 63, 10992, 12, 283, 599, 1219, 297, 1768, 12, 26259, 16842, 63, 16295, 9, 202, 199, 3165, 14, 5919, 63, 2798, 63, 460, 63, 952, 63, 4478, 63, 1897, 8, 270, 14, 5159, 63, 10992, 12, 283, 24920, 331, 292, 297, 1768, 12, 26259, 16842, 63, 16295, 9, 202, 199, 3165, 14, 5919, 63, 2798, 63, 460, 63, 952, 63, 4478, 63, 1897, 8, 270, 14, 4672, 63, 10992, 63, 17, 12, 283, 470, 262, 297, 1768, 12, 26259, 16842, 63, 16295, 9, 202, 199, 3165, 14, 5919, 63, 2798, 63, 460, 63, 952, 63, 4478, 63, 1897, 8, 270, 14, 4672, 63, 10992, 63, 17, 12, 283, 599, 1219, 297, 1768, 12, 26259, 16842, 63, 16295, 9, 2999, 199, 3, 5117, 28668, 4021, 9527, 13715, 202, 199, 1302, 275, 283, 2325, 28668, 4021, 7, 2999, 199, 3, 1218, 314, 16842, 17248, 202, 199, 478, 67, 275, 410, 14, 22502, 63, 2874, 14, 1897, 459, 2325, 418, 202, 199, 3438, 63, 478, 67, 275, 359, 1128, 2008, 8, 478, 67, 14, 3039, 59, 17, 2522, 1128, 334, 478, 67, 14, 3039, 59, 17, 1527, 16, 467, 378, 14, 16, 395, 1128, 365, 17, 14, 16295, 14, 5707, 322, 1384, 59, 16, 1055, 8032, 59, 17027, 13, 9485, 467, 257, 327, 12624, 16923, 17, 63, 470, 262, 14, 2424, 1128, 2008, 8, 478, 67, 14, 1019, 59, 16, 2522, 263, 327, 428, 462, 9155, 63, 2325, 14, 2424, 1128, 334, 478, 67, 14, 1019, 59, 16, 1527, 16, 467, 446, 16, 14, 1046, 395, 1128, 334, 478, 67, 14, 3039, 59, 17, 1527, 16, 467, 446, 16, 14, 1046, 9, 1128, 1622, 202, 199, 24511, 63, 16295, 275, 17560, 8, 3438, 63, 478, 67, 9, 202, 199, 3165, 14, 2798, 63, 16295, 8, 24511, 63, 16295, 12, 283, 403, 297, 3943, 3273, 358, 2999, 199, 3, 10415, 314, 892, 4045, 30658, 202, 199, 3165, 14, 5919, 63, 2798, 63, 460, 63, 952, 63, 4478, 63, 1897, 8, 270, 14, 5159, 63, 10992, 12, 283, 599, 1219, 297, 1768, 12, 26259, 16842, 63, 16295, 9, 202, 199, 3165, 14, 5919, 63, 2798, 63, 460, 63, 952, 63, 4478, 63, 1897, 8, 270, 14, 5159, 63, 10992, 12, 283, 24920, 331, 292, 297, 1768, 12, 26259, 16842, 63, 16295, 9, 202, 199, 3165, 14, 5919, 63, 2798, 63, 460, 63, 952, 63, 4478, 63, 1897, 8, 270, 14, 4672, 63, 10992, 63, 17, 12, 283, 470, 262, 297, 1768, 12, 26259, 16842, 63, 16295, 9, 202, 199, 3165, 14, 5919, 63, 2798, 63, 460, 63, 952, 63, 4478, 63, 1897, 8, 270, 14, 4672, 63, 10992, 63, 17, 12, 283, 599, 1219 ]
[ 3534, 2536, 715, 7900, 1584, 367, 1373, 29359, 2391, 330, 17236, 16518, 14, 2999, 199, 7692, 202, 199, 9858, 202, 199, 928, 376, 16243, 334, 8440, 9, 6614, 543, 314, 19199, 3305, 26, 202, 199, 4, 284, 1548, 19227, 6614, 1553, 32538, 202, 199, 269, 202, 199, 4, 284, 1548, 1553, 32538, 202, 199, 28226, 12, 687, 314, 8457, 12, 1255, 642, 2884, 26, 202, 199, 92, 30, 450, 1065, 28698, 2391, 63, 66, 17236, 63, 773, 15, 10837, 63, 270, 78, 2483, 63, 6480, 14, 647, 202, 199, 269, 202, 199, 92, 30, 492, 28698, 2391, 63, 66, 17236, 63, 773, 15, 10837, 63, 270, 78, 2483, 63, 6480, 2999, 199, 5949, 26, 3492, 651, 6848, 273, 13, 5691, 25338, 265, 202, 199, 6090, 4588, 26, 437, 28026, 1616, 12, 6927, 2999, 199, 624, 8065, 199, 646, 8027, 14, 13563, 465, 4488, 202, 199, 646, 1973, 14, 66, 17236, 465, 6826, 202, 199, 646, 1973, 14, 6023, 63, 1208, 465, 18848, 202, 199, 504, 2215, 590, 14, 7660, 492, 17560, 8065, 199, 3, 11543, 4221, 654, 37, 23710, 10652, 13, 202, 199, 10600, 63, 1507, 275, 4337, 202, 199, 3, 11016, 8648, 202, 199, 6003, 14, 1600, 360, 452, 358, 2999, 199, 3, 2248, 314, 29359, 2391, 330, 17236, 202, 199, 77, 275, 6826, 14, 6671, 411, 24064, 34, 17236, 360, 23906, 2391, 330, 17236, 428, 14176, 1960, 13, 383, 297, 283, 18904, 2391, 63, 66, 17236, 358, 2999, 199, 3, 876, 13, 1412, 314, 16518, 7365, 202, 199, 10600, 275, 333, 14, 513, 63, 1618, 63, 270, 1298, 59, 10600, 63, 1507, 13, 17, 61, 202, 199, 10600, 14, 8387, 545, 382, 14, 981, 63, 16295, 342, 202, 199, 10600, 14, 6976, 14, 981, 63, 452, 63, 4359, 342, 202, 199, 10600, 14, 6976, 14, 2117, 63, 452, 63, 1897, 63, 6929, 342, 202, 199, 10600, 14, 6976, 14, 952, 63, 452, 63, 2064, 63, 2515, 18067, 342, 2999, 199, 3, 5137, 314, 4184, 202, 199, 10600, 14, 2798, 63, 4181, 342, 2999, 199, 3, 2879, 314, 5523, 367, 642, 16518, 202, 199, 270, 275, 16518, 14, 6976, 2999, 199, 3, 7008, 28668, 4021, 9527, 13715, 202, 199, 1302, 275, 283, 4142, 28668, 4021, 7, 2999, 199, 3, 1218, 314, 16842, 17248, 202, 199, 527, 67, 275, 410, 14, 22502, 63, 2874, 14, 1897, 459, 4142, 418, 202, 199, 374, 17, 275, 410, 14, 4672, 63, 10992, 63, 17, 14, 1897, 459, 470, 262, 418, 202, 199, 3438, 63, 527, 67, 275, 359, 1128, 2008, 8, 527, 67, 14, 3039, 59, 16, 2522, 4519, 327, 428, 462, 9155, 63, 4142, 14, 2424, 1128, 334, 527, 67, 14, 3039, 59, 16, 1527, 16, 467, 378, 14, 17, 395, 1128, 365, 17, 14, 16295, 14, 5707, 322, 1384, 59, 16, 1055, 8032, 59, 16, 467, 257, 327, 12624, 16923, 17, 63, 470, 262, 14, 2424, 1128, 2008, 8, 527, 67, 14, 1019, 59, 17, 2522, 3777, 327, 428, 462, 9155, 63, 4142, 14, 2424, 1128, 334, 527, 67, 14, 1019, 59, 17, 1527, 16, 467, 378, 14, 821, 395, 1128, 334, 527, 67, 14, 3039, 59, 16, 1527, 16, 467, 378, 14, 821, 9, 1128, 1622, 202, 199, 24511, 63, 16295, 275, 17560, 8, 3438, 63, 527, 67, 9, 202, 199, 3165, 14, 2798, 63, 16295, 8, 24511, 63, 16295, 12, 283, 403, 297, 3943, 3273, 358, 2999, 199, 3, 10415, 314, 892, 4045, 30658, 202, 199, 3165, 14, 5919, 63, 2798, 63, 460, 63, 952, 63, 4478, 63, 1897, 8, 270, 14, 5159, 63, 10992, 12, 283, 599, 1219, 297, 1768, 12, 26259, 16842, 63, 16295, 9, 202, 199, 3165, 14, 5919, 63, 2798, 63, 460, 63, 952, 63, 4478, 63, 1897, 8, 270, 14, 5159, 63, 10992, 12, 283, 24920, 331, 292, 297, 1768, 12, 26259, 16842, 63, 16295, 9, 202, 199, 3165, 14, 5919, 63, 2798, 63, 460, 63, 952, 63, 4478, 63, 1897, 8, 270, 14, 4672, 63, 10992, 63, 17, 12, 283, 470, 262, 297, 1768, 12, 26259, 16842, 63, 16295, 9, 202, 199, 3165, 14, 5919, 63, 2798, 63, 460, 63, 952, 63, 4478, 63, 1897, 8, 270, 14, 4672, 63, 10992, 63, 17, 12, 283, 599, 1219, 297, 1768, 12, 26259, 16842, 63, 16295, 9, 2999, 199, 3, 5117, 28668, 4021, 9527, 13715, 202, 199, 1302, 275, 283, 2325, 28668, 4021, 7, 2999, 199, 3, 1218, 314, 16842, 17248, 202, 199, 478, 67, 275, 410, 14, 22502, 63, 2874, 14, 1897, 459, 2325, 418, 202, 199, 3438, 63, 478, 67, 275, 359, 1128, 2008, 8, 478, 67, 14, 3039, 59, 17, 2522, 1128, 334, 478, 67, 14, 3039, 59, 17, 1527, 16, 467, 378, 14, 16, 395, 1128, 365, 17, 14, 16295, 14, 5707, 322, 1384, 59, 16, 1055, 8032, 59, 17027, 13, 9485, 467, 257, 327, 12624, 16923, 17, 63, 470, 262, 14, 2424, 1128, 2008, 8, 478, 67, 14, 1019, 59, 16, 2522, 263, 327, 428, 462, 9155, 63, 2325, 14, 2424, 1128, 334, 478, 67, 14, 1019, 59, 16, 1527, 16, 467, 446, 16, 14, 1046, 395, 1128, 334, 478, 67, 14, 3039, 59, 17, 1527, 16, 467, 446, 16, 14, 1046, 9, 1128, 1622, 202, 199, 24511, 63, 16295, 275, 17560, 8, 3438, 63, 478, 67, 9, 202, 199, 3165, 14, 2798, 63, 16295, 8, 24511, 63, 16295, 12, 283, 403, 297, 3943, 3273, 358, 2999, 199, 3, 10415, 314, 892, 4045, 30658, 202, 199, 3165, 14, 5919, 63, 2798, 63, 460, 63, 952, 63, 4478, 63, 1897, 8, 270, 14, 5159, 63, 10992, 12, 283, 599, 1219, 297, 1768, 12, 26259, 16842, 63, 16295, 9, 202, 199, 3165, 14, 5919, 63, 2798, 63, 460, 63, 952, 63, 4478, 63, 1897, 8, 270, 14, 5159, 63, 10992, 12, 283, 24920, 331, 292, 297, 1768, 12, 26259, 16842, 63, 16295, 9, 202, 199, 3165, 14, 5919, 63, 2798, 63, 460, 63, 952, 63, 4478, 63, 1897, 8, 270, 14, 4672, 63, 10992, 63, 17, 12, 283, 470, 262, 297, 1768, 12, 26259, 16842, 63, 16295, 9, 202, 199, 3165, 14, 5919, 63, 2798, 63, 460, 63, 952, 63, 4478, 63, 1897, 8, 270, 14, 4672, 63, 10992, 63, 17, 12, 283, 599, 1219, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
paulproteus/django
django/contrib/gis/geos/prototypes/coordseq.py
624
3112
from ctypes import c_double, c_int, c_uint, POINTER from django.contrib.gis.geos.libgeos import GEOM_PTR, CS_PTR from django.contrib.gis.geos.prototypes.errcheck import last_arg_byref, GEOSException from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc ## Error-checking routines specific to coordinate sequences. ## def check_cs_ptr(result, func, cargs): "Error checking on routines that return Geometries." if not result: raise GEOSException('Error encountered checking Coordinate Sequence returned from GEOS C function "%s".' % func.__name__) return result def check_cs_op(result, func, cargs): "Checks the status code of a coordinate sequence operation." if result == 0: raise GEOSException('Could not set value on coordinate sequence') else: return result def check_cs_get(result, func, cargs): "Checking the coordinate sequence retrieval." check_cs_op(result, func, cargs) # Object in by reference, return its value. return last_arg_byref(cargs) ## Coordinate sequence prototype generation functions. ## def cs_int(func): "For coordinate sequence routines that return an integer." func.argtypes = [CS_PTR, POINTER(c_uint)] func.restype = c_int func.errcheck = check_cs_get return func def cs_operation(func, ordinate=False, get=False): "For coordinate sequence operations." if get: # Get routines get double parameter passed-in by reference. func.errcheck = check_cs_get dbl_param = POINTER(c_double) else: func.errcheck = check_cs_op dbl_param = c_double if ordinate: # Get/Set ordinate routines have an extra uint parameter. func.argtypes = [CS_PTR, c_uint, c_uint, dbl_param] else: func.argtypes = [CS_PTR, c_uint, dbl_param] func.restype = c_int return func def cs_output(func, argtypes): "For routines that return a coordinate sequence." func.argtypes = argtypes func.restype = CS_PTR func.errcheck = check_cs_ptr return func ## Coordinate Sequence ctypes prototypes ## # Coordinate Sequence constructors & cloning. cs_clone = cs_output(GEOSFunc('GEOSCoordSeq_clone'), [CS_PTR]) create_cs = cs_output(GEOSFunc('GEOSCoordSeq_create'), [c_uint, c_uint]) get_cs = cs_output(GEOSFunc('GEOSGeom_getCoordSeq'), [GEOM_PTR]) # Getting, setting ordinate cs_getordinate = cs_operation(GEOSFunc('GEOSCoordSeq_getOrdinate'), ordinate=True, get=True) cs_setordinate = cs_operation(GEOSFunc('GEOSCoordSeq_setOrdinate'), ordinate=True) # For getting, x, y, z cs_getx = cs_operation(GEOSFunc('GEOSCoordSeq_getX'), get=True) cs_gety = cs_operation(GEOSFunc('GEOSCoordSeq_getY'), get=True) cs_getz = cs_operation(GEOSFunc('GEOSCoordSeq_getZ'), get=True) # For setting, x, y, z cs_setx = cs_operation(GEOSFunc('GEOSCoordSeq_setX')) cs_sety = cs_operation(GEOSFunc('GEOSCoordSeq_setY')) cs_setz = cs_operation(GEOSFunc('GEOSCoordSeq_setZ')) # These routines return size & dimensions. cs_getsize = cs_int(GEOSFunc('GEOSCoordSeq_getSize')) cs_getdims = cs_int(GEOSFunc('GEOSCoordSeq_getDimensions'))
bsd-3-clause
[ 504, 5577, 492, 286, 63, 3157, 12, 286, 63, 442, 12, 286, 63, 1635, 12, 6569, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 773, 12151, 492, 8991, 7474, 63, 14528, 12, 17447, 63, 14528, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 21205, 492, 2061, 63, 1273, 63, 20447, 12, 21390, 21686, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 2671, 3489, 492, 11920, 7465, 199, 199, 309, 4520, 13, 19527, 14975, 2488, 370, 10021, 8013, 14, 925, 199, 318, 1104, 63, 1259, 63, 4695, 8, 1099, 12, 2562, 12, 286, 589, 304, 272, 298, 547, 7907, 641, 14975, 626, 372, 5346, 14100, 2122, 272, 340, 440, 754, 26, 267, 746, 21390, 21686, 360, 547, 14556, 7907, 25334, 323, 10975, 2138, 687, 11920, 445, 805, 2071, 83, 24217, 450, 2562, 855, 354, 3368, 272, 372, 754, 199, 199, 318, 1104, 63, 1259, 63, 411, 8, 1099, 12, 2562, 12, 286, 589, 304, 272, 298, 11834, 314, 2004, 1233, 402, 282, 10021, 3414, 3439, 2122, 272, 340, 754, 508, 378, 26, 267, 746, 21390, 21686, 360, 6531, 440, 663, 574, 641, 10021, 3414, 358, 272, 587, 26, 267, 372, 754, 199, 199, 318, 1104, 63, 1259, 63, 362, 8, 1099, 12, 2562, 12, 286, 589, 304, 272, 298, 14740, 314, 10021, 3414, 27157, 2122, 272, 1104, 63, 1259, 63, 411, 8, 1099, 12, 2562, 12, 286, 589, 9, 272, 327, 6935, 315, 701, 3659, 12, 372, 2399, 574, 14, 272, 372, 2061, 63, 1273, 63, 20447, 8, 67, 589, 9, 199, 199, 309, 25334, 323, 3414, 19393, 10152, 3423, 14, 925, 199, 318, 7117, 63, 442, 8, 1532, 304, 272, 298, 1858, 10021, 3414, 14975, 626, 372, 376, 3000, 2122, 272, 2562, 14, 10025, 275, 359, 3298, 63, 14528, 12, 6569, 8, 67, 63, 1635, 1874, 272, 2562, 14, 9990, 275, 286, 63, 442, 272, 2562, 14, 21205, 275, 1104, 63, 1259, 63, 362, 272, 372, 2562, 199, 199, 318, 7117, 63, 5735, 8, 1532, 12, 6206, 23043, 29, 797, 12, 664, 29, 797, 304, 272, 298, 1858, 10021, 3414, 5331, 2122, 272, 340, 664, 26, 267, 327, 2372, 14975, 664, 4270, 2725, 3032, 13, 262, 701, 3659, 14, 267, 2562, 14, 21205, 275, 1104, 63, 1259, 63, 362, 267, 1592, 76, 63, 635, 275, 6569, 8, 67, 63, 3157, 9, 272, 587, 26, 267, 2562, 14, 21205, 275, 1104, 63, 1259, 63, 411, 267, 1592, 76, 63, 635, 275, 286, 63, 3157, 339, 340, 6206, 23043, 26, 267, 327, 2372, 15, 1084, 6206, 23043, 14975, 1172, 376, 2402, 3152, 2725, 14, 267, 2562, 14, 10025, 275, 359, 3298, 63, 14528, 12, 286, 63, 1635, 12, 286, 63, 1635, 12, 1592, 76, 63, 635, 61, 272, 587, 26, 267, 2562, 14, 10025, 275, 359, 3298, 63, 14528, 12, 286, 63, 1635, 12, 1592, 76, 63, 635, 61, 339, 2562, 14, 9990, 275, 286, 63, 442, 272, 372, 2562, 199, 199, 318, 7117, 63, 1199, 8, 1532, 12, 29669, 304, 272, 298, 1858, 14975, 626, 372, 282, 10021, 3414, 2122, 272, 2562, 14, 10025, 275, 29669, 272, 2562, 14, 9990, 275, 17447, 63, 14528, 272, 2562, 14, 21205, 275, 1104, 63, 1259, 63, 4695, 272, 372, 2562, 199, 199, 309, 25334, 323, 10975, 5577, 19393, 83, 925, 199, 199, 3, 25334, 323, 10975, 31604, 1253, 824, 19718, 14, 199, 1259, 63, 6311, 275, 7117, 63, 1199, 8, 31887, 360, 14151, 14957, 11205, 63, 6311, 659, 359, 3298, 63, 14528, 566, 199, 981, 63, 1259, 275, 7117, 63, 1199, 8, 31887, 360, 14151, 14957, 11205, 63, 981, 659, 359, 67, 63, 1635, 12, 286, 63, 1635, 566, 199, 362, 63, 1259, 275, 7117, 63, 1199, 8, 31887, 360, 14151, 13427, 63, 362, 14957, 11205, 659, 359, 31080, 63, 14528, 566, 199, 199, 3, 20703, 12, 4260, 6206, 23043, 199, 1259, 63, 362, 4055, 323, 275, 7117, 63, 5735, 8, 31887, 360, 14151, 14957, 11205, 63, 30457, 68, 23043, 659, 6206, 23043, 29, 549, 12, 664, 29, 549, 9, 199, 1259, 63, 409, 4055, 323, 275, 7117, 63, 5735, 8, 31887, 360, 14151, 14957, 11205, 63, 409, 2844, 68, 23043, 659, 6206, 23043, 29, 549, 9, 199, 199, 3, 2104, 10232, 12, 671, 12, 612, 12, 1315, 199, 1259, 63, 362, 88, 275, 7117, 63, 5735, 8, 31887, 360, 14151, 14957, 11205, 63, 362, 56, 659, 664, 29, 549, 9, 199, 1259, 63, 362, 89, 275, 7117, 63, 5735, 8, 31887, 360, 14151, 14957, 11205, 63, 362, 57, 659, 664, 29, 549, 9, 199, 1259, 63, 362, 90, 275, 7117, 63, 5735, 8, 31887, 360, 14151, 14957, 11205, 63, 362, 58, 659, 664, 29, 549, 9, 199, 199, 3, 2104, 4260, 12, 671, 12, 612, 12, 1315, 199, 1259, 63, 409, 88, 275, 7117, 63, 5735, 8, 31887, 360, 14151, 14957, 11205, 63, 409, 56, 1333, 199, 1259, 63, 261, 369, 275, 7117, 63, 5735, 8, 31887, 360, 14151, 14957, 11205, 63, 409, 57, 1333, 199, 1259, 63, 409, 90, 275, 7117, 63, 5735, 8, 31887, 360, 14151, 14957, 11205, 63, 409, 58, 1333, 199, 199, 3, 5723, 14975, 372, 1568, 1253, 7365, 14, 199, 1259, 63, 20733, 275, 7117, 63, 442, 8, 31887, 360, 14151, 14957, 11205, 63, 362, 2320, 1333, 199, 1259, 63, 362, 5380, 275, 7117, 63, 442, 8, 31887, 360, 14151, 14957, 11205, 63, 362, 23370, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 5577, 492, 286, 63, 3157, 12, 286, 63, 442, 12, 286, 63, 1635, 12, 6569, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 773, 12151, 492, 8991, 7474, 63, 14528, 12, 17447, 63, 14528, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 21205, 492, 2061, 63, 1273, 63, 20447, 12, 21390, 21686, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 2671, 3489, 492, 11920, 7465, 199, 199, 309, 4520, 13, 19527, 14975, 2488, 370, 10021, 8013, 14, 925, 199, 318, 1104, 63, 1259, 63, 4695, 8, 1099, 12, 2562, 12, 286, 589, 304, 272, 298, 547, 7907, 641, 14975, 626, 372, 5346, 14100, 2122, 272, 340, 440, 754, 26, 267, 746, 21390, 21686, 360, 547, 14556, 7907, 25334, 323, 10975, 2138, 687, 11920, 445, 805, 2071, 83, 24217, 450, 2562, 855, 354, 3368, 272, 372, 754, 199, 199, 318, 1104, 63, 1259, 63, 411, 8, 1099, 12, 2562, 12, 286, 589, 304, 272, 298, 11834, 314, 2004, 1233, 402, 282, 10021, 3414, 3439, 2122, 272, 340, 754, 508, 378, 26, 267, 746, 21390, 21686, 360, 6531, 440, 663, 574, 641, 10021, 3414, 358, 272, 587, 26, 267, 372, 754, 199, 199, 318, 1104, 63, 1259, 63, 362, 8, 1099, 12, 2562, 12, 286, 589, 304, 272, 298, 14740, 314, 10021, 3414, 27157, 2122, 272, 1104, 63, 1259, 63, 411, 8, 1099, 12, 2562, 12, 286, 589, 9, 272, 327, 6935, 315, 701, 3659, 12, 372, 2399, 574, 14, 272, 372, 2061, 63, 1273, 63, 20447, 8, 67, 589, 9, 199, 199, 309, 25334, 323, 3414, 19393, 10152, 3423, 14, 925, 199, 318, 7117, 63, 442, 8, 1532, 304, 272, 298, 1858, 10021, 3414, 14975, 626, 372, 376, 3000, 2122, 272, 2562, 14, 10025, 275, 359, 3298, 63, 14528, 12, 6569, 8, 67, 63, 1635, 1874, 272, 2562, 14, 9990, 275, 286, 63, 442, 272, 2562, 14, 21205, 275, 1104, 63, 1259, 63, 362, 272, 372, 2562, 199, 199, 318, 7117, 63, 5735, 8, 1532, 12, 6206, 23043, 29, 797, 12, 664, 29, 797, 304, 272, 298, 1858, 10021, 3414, 5331, 2122, 272, 340, 664, 26, 267, 327, 2372, 14975, 664, 4270, 2725, 3032, 13, 262, 701, 3659, 14, 267, 2562, 14, 21205, 275, 1104, 63, 1259, 63, 362, 267, 1592, 76, 63, 635, 275, 6569, 8, 67, 63, 3157, 9, 272, 587, 26, 267, 2562, 14, 21205, 275, 1104, 63, 1259, 63, 411, 267, 1592, 76, 63, 635, 275, 286, 63, 3157, 339, 340, 6206, 23043, 26, 267, 327, 2372, 15, 1084, 6206, 23043, 14975, 1172, 376, 2402, 3152, 2725, 14, 267, 2562, 14, 10025, 275, 359, 3298, 63, 14528, 12, 286, 63, 1635, 12, 286, 63, 1635, 12, 1592, 76, 63, 635, 61, 272, 587, 26, 267, 2562, 14, 10025, 275, 359, 3298, 63, 14528, 12, 286, 63, 1635, 12, 1592, 76, 63, 635, 61, 339, 2562, 14, 9990, 275, 286, 63, 442, 272, 372, 2562, 199, 199, 318, 7117, 63, 1199, 8, 1532, 12, 29669, 304, 272, 298, 1858, 14975, 626, 372, 282, 10021, 3414, 2122, 272, 2562, 14, 10025, 275, 29669, 272, 2562, 14, 9990, 275, 17447, 63, 14528, 272, 2562, 14, 21205, 275, 1104, 63, 1259, 63, 4695, 272, 372, 2562, 199, 199, 309, 25334, 323, 10975, 5577, 19393, 83, 925, 199, 199, 3, 25334, 323, 10975, 31604, 1253, 824, 19718, 14, 199, 1259, 63, 6311, 275, 7117, 63, 1199, 8, 31887, 360, 14151, 14957, 11205, 63, 6311, 659, 359, 3298, 63, 14528, 566, 199, 981, 63, 1259, 275, 7117, 63, 1199, 8, 31887, 360, 14151, 14957, 11205, 63, 981, 659, 359, 67, 63, 1635, 12, 286, 63, 1635, 566, 199, 362, 63, 1259, 275, 7117, 63, 1199, 8, 31887, 360, 14151, 13427, 63, 362, 14957, 11205, 659, 359, 31080, 63, 14528, 566, 199, 199, 3, 20703, 12, 4260, 6206, 23043, 199, 1259, 63, 362, 4055, 323, 275, 7117, 63, 5735, 8, 31887, 360, 14151, 14957, 11205, 63, 30457, 68, 23043, 659, 6206, 23043, 29, 549, 12, 664, 29, 549, 9, 199, 1259, 63, 409, 4055, 323, 275, 7117, 63, 5735, 8, 31887, 360, 14151, 14957, 11205, 63, 409, 2844, 68, 23043, 659, 6206, 23043, 29, 549, 9, 199, 199, 3, 2104, 10232, 12, 671, 12, 612, 12, 1315, 199, 1259, 63, 362, 88, 275, 7117, 63, 5735, 8, 31887, 360, 14151, 14957, 11205, 63, 362, 56, 659, 664, 29, 549, 9, 199, 1259, 63, 362, 89, 275, 7117, 63, 5735, 8, 31887, 360, 14151, 14957, 11205, 63, 362, 57, 659, 664, 29, 549, 9, 199, 1259, 63, 362, 90, 275, 7117, 63, 5735, 8, 31887, 360, 14151, 14957, 11205, 63, 362, 58, 659, 664, 29, 549, 9, 199, 199, 3, 2104, 4260, 12, 671, 12, 612, 12, 1315, 199, 1259, 63, 409, 88, 275, 7117, 63, 5735, 8, 31887, 360, 14151, 14957, 11205, 63, 409, 56, 1333, 199, 1259, 63, 261, 369, 275, 7117, 63, 5735, 8, 31887, 360, 14151, 14957, 11205, 63, 409, 57, 1333, 199, 1259, 63, 409, 90, 275, 7117, 63, 5735, 8, 31887, 360, 14151, 14957, 11205, 63, 409, 58, 1333, 199, 199, 3, 5723, 14975, 372, 1568, 1253, 7365, 14, 199, 1259, 63, 20733, 275, 7117, 63, 442, 8, 31887, 360, 14151, 14957, 11205, 63, 362, 2320, 1333, 199, 1259, 63, 362, 5380, 275, 7117, 63, 442, 8, 31887, 360, 14151, 14957, 11205, 63, 362, 23370, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
chuan9/chromium-crosswalk
build/android/gyp/ant.py
109
2148
#!/usr/bin/env python # # Copyright 2013 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """An Ant wrapper that suppresses useless Ant output. Ant build scripts output "BUILD SUCCESSFUL" and build timing at the end of every build. In the Android build, this just adds a lot of useless noise to the build output. This script forwards its arguments to ant, and prints Ant's output up until the BUILD SUCCESSFUL line. Also, when a command fails, this script will re-run that ant command with the '-verbose' argument so that the failure is easier to debug. """ import optparse import sys import traceback from util import build_utils def main(argv): option_parser = optparse.OptionParser() build_utils.AddDepfileOption(option_parser) options, args = option_parser.parse_args(argv[1:]) try: stdout = build_utils.CheckOutput(['ant'] + args) except build_utils.CalledProcessError: # It is very difficult to diagnose ant failures without the '-verbose' # argument. So, when an ant command fails, re-run it with '-verbose' so that # the cause of the failure is easier to identify. verbose_args = ['-verbose'] + [a for a in args if a != '-quiet'] try: stdout = build_utils.CheckOutput(['ant'] + verbose_args) except build_utils.CalledProcessError: traceback.print_exc() sys.exit(1) # If this did sys.exit(1), building again would succeed (which would be # awkward). Instead, just print a big warning. build_utils.PrintBigWarning( 'This is unexpected. `ant ' + ' '.join(args) + '` failed.' + 'But, running `ant ' + ' '.join(verbose_args) + '` passed.') stdout = stdout.strip().split('\n') for line in stdout: if line.strip() == 'BUILD SUCCESSFUL': break print line if options.depfile: assert '-buildfile' in args ant_buildfile = args[args.index('-buildfile') + 1] build_utils.WriteDepfile( options.depfile, [ant_buildfile] + build_utils.GetPythonDependencies()) if __name__ == '__main__': sys.exit(main(sys.argv))
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 6171, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 2493, 437, 343, 4975, 626, 4973, 4357, 31291, 437, 343, 1072, 14, 199, 199, 31935, 1900, 10554, 1072, 298, 8248, 28364, 38, 1293, 2, 436, 1900, 20542, 737, 314, 1284, 402, 199, 14287, 1900, 14, 1010, 314, 14694, 1900, 12, 642, 2951, 9584, 282, 13918, 402, 31291, 11145, 370, 314, 199, 1506, 1072, 14, 961, 2884, 17465, 2399, 2368, 370, 27384, 12, 436, 14767, 437, 343, 1159, 199, 1199, 1536, 5133, 314, 22974, 28364, 38, 1293, 1004, 14, 199, 199, 31892, 12, 1380, 282, 1414, 6918, 12, 642, 2884, 911, 295, 13, 1065, 626, 27384, 1414, 543, 314, 199, 12418, 3832, 7, 1423, 880, 626, 314, 5988, 365, 14905, 370, 3105, 14, 199, 624, 199, 199, 646, 8691, 199, 646, 984, 199, 646, 5190, 199, 199, 504, 4884, 492, 1900, 63, 1208, 421, 199, 318, 2446, 8, 3020, 304, 523, 945, 63, 2087, 275, 8691, 14, 14553, 342, 523, 1900, 63, 1208, 14, 1123, 8598, 493, 2602, 8, 1422, 63, 2087, 9, 523, 1511, 12, 1249, 275, 945, 63, 2087, 14, 1122, 63, 589, 8, 3020, 59, 17, 5728, 819, 862, 26, 272, 3839, 275, 1900, 63, 1208, 14, 1799, 2959, 2941, 867, 418, 435, 1249, 9, 523, 871, 1900, 63, 1208, 14, 24691, 26, 272, 327, 2779, 365, 7437, 29870, 370, 8348, 21085, 27384, 9081, 1928, 314, 2475, 3832, 7, 272, 327, 1423, 14, 2002, 12, 1380, 376, 27384, 1414, 6918, 12, 295, 13, 1065, 652, 543, 2475, 3832, 7, 880, 626, 272, 327, 314, 7675, 402, 314, 5988, 365, 14905, 370, 10405, 14, 272, 3376, 63, 589, 275, 11573, 3832, 418, 435, 359, 65, 367, 282, 315, 1249, 340, 282, 1137, 2475, 10243, 418, 272, 862, 26, 489, 3839, 275, 1900, 63, 1208, 14, 1799, 2959, 2941, 867, 418, 435, 3376, 63, 589, 9, 272, 871, 1900, 63, 1208, 14, 24691, 26, 489, 5190, 14, 1361, 63, 2804, 342, 489, 984, 14, 2224, 8, 17, 9, 339, 327, 982, 642, 8103, 984, 14, 2224, 8, 17, 395, 10015, 4020, 3955, 17961, 334, 6777, 3955, 506, 272, 327, 26936, 829, 1005, 680, 15345, 12, 2951, 870, 282, 7282, 5721, 14, 272, 1900, 63, 1208, 14, 5375, 7279, 3849, 8, 267, 283, 2765, 365, 10537, 14, 658, 867, 283, 435, 283, 1987, 904, 8, 589, 9, 435, 26144, 3405, 3530, 435, 267, 283, 28543, 12, 3879, 658, 867, 283, 435, 283, 1987, 904, 8, 3832, 63, 589, 9, 435, 26144, 3032, 2659, 819, 3839, 275, 3839, 14, 1913, 1252, 1294, 2258, 78, 358, 523, 367, 1004, 315, 3839, 26, 272, 340, 1004, 14, 1913, 342, 508, 283, 8248, 28364, 38, 1293, 356, 489, 2059, 272, 870, 1004, 819, 340, 1511, 14, 2601, 493, 26, 272, 702, 2475, 1506, 493, 7, 315, 1249, 272, 27384, 63, 1506, 493, 275, 1249, 59, 589, 14, 1080, 3654, 1506, 493, 358, 435, 413, 61, 339, 1900, 63, 1208, 14, 3534, 8598, 493, 8, 267, 1511, 14, 2601, 493, 12, 267, 359, 867, 63, 1506, 493, 61, 435, 1900, 63, 1208, 14, 1002, 4718, 11927, 1012, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 984, 14, 2224, 8, 973, 8, 1274, 14, 3020, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 6171, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 2493, 437, 343, 4975, 626, 4973, 4357, 31291, 437, 343, 1072, 14, 199, 199, 31935, 1900, 10554, 1072, 298, 8248, 28364, 38, 1293, 2, 436, 1900, 20542, 737, 314, 1284, 402, 199, 14287, 1900, 14, 1010, 314, 14694, 1900, 12, 642, 2951, 9584, 282, 13918, 402, 31291, 11145, 370, 314, 199, 1506, 1072, 14, 961, 2884, 17465, 2399, 2368, 370, 27384, 12, 436, 14767, 437, 343, 1159, 199, 1199, 1536, 5133, 314, 22974, 28364, 38, 1293, 1004, 14, 199, 199, 31892, 12, 1380, 282, 1414, 6918, 12, 642, 2884, 911, 295, 13, 1065, 626, 27384, 1414, 543, 314, 199, 12418, 3832, 7, 1423, 880, 626, 314, 5988, 365, 14905, 370, 3105, 14, 199, 624, 199, 199, 646, 8691, 199, 646, 984, 199, 646, 5190, 199, 199, 504, 4884, 492, 1900, 63, 1208, 421, 199, 318, 2446, 8, 3020, 304, 523, 945, 63, 2087, 275, 8691, 14, 14553, 342, 523, 1900, 63, 1208, 14, 1123, 8598, 493, 2602, 8, 1422, 63, 2087, 9, 523, 1511, 12, 1249, 275, 945, 63, 2087, 14, 1122, 63, 589, 8, 3020, 59, 17, 5728, 819, 862, 26, 272, 3839, 275, 1900, 63, 1208, 14, 1799, 2959, 2941, 867, 418, 435, 1249, 9, 523, 871, 1900, 63, 1208, 14, 24691, 26, 272, 327, 2779, 365, 7437, 29870, 370, 8348, 21085, 27384, 9081, 1928, 314, 2475, 3832, 7, 272, 327, 1423, 14, 2002, 12, 1380, 376, 27384, 1414, 6918, 12, 295, 13, 1065, 652, 543, 2475, 3832, 7, 880, 626, 272, 327, 314, 7675, 402, 314, 5988, 365, 14905, 370, 10405, 14, 272, 3376, 63, 589, 275, 11573, 3832, 418, 435, 359, 65, 367, 282, 315, 1249, 340, 282, 1137, 2475, 10243, 418, 272, 862, 26, 489, 3839, 275, 1900, 63, 1208, 14, 1799, 2959, 2941, 867, 418, 435, 3376, 63, 589, 9, 272, 871, 1900, 63, 1208, 14, 24691, 26, 489, 5190, 14, 1361, 63, 2804, 342, 489, 984, 14, 2224, 8, 17, 9, 339, 327, 982, 642, 8103, 984, 14, 2224, 8, 17, 395, 10015, 4020, 3955, 17961, 334, 6777, 3955, 506, 272, 327, 26936, 829, 1005, 680, 15345, 12, 2951, 870, 282, 7282, 5721, 14, 272, 1900, 63, 1208, 14, 5375, 7279, 3849, 8, 267, 283, 2765, 365, 10537, 14, 658, 867, 283, 435, 283, 1987, 904, 8, 589, 9, 435, 26144, 3405, 3530, 435, 267, 283, 28543, 12, 3879, 658, 867, 283, 435, 283, 1987, 904, 8, 3832, 63, 589, 9, 435, 26144, 3032, 2659, 819, 3839, 275, 3839, 14, 1913, 1252, 1294, 2258, 78, 358, 523, 367, 1004, 315, 3839, 26, 272, 340, 1004, 14, 1913, 342, 508, 283, 8248, 28364, 38, 1293, 356, 489, 2059, 272, 870, 1004, 819, 340, 1511, 14, 2601, 493, 26, 272, 702, 2475, 1506, 493, 7, 315, 1249, 272, 27384, 63, 1506, 493, 275, 1249, 59, 589, 14, 1080, 3654, 1506, 493, 358, 435, 413, 61, 339, 1900, 63, 1208, 14, 3534, 8598, 493, 8, 267, 1511, 14, 2601, 493, 12, 267, 359, 867, 63, 1506, 493, 61, 435, 1900, 63, 1208, 14, 1002, 4718, 11927, 1012, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 984, 14, 2224, 8, 973, 8, 1274, 14, 3020, 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, 32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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
40223137/w17w17
static/Brython3.1.1-20150328-091302/Lib/unittest/suite.py
748
9715
"""TestSuite""" import sys from . import case from . import util __unittest = True def _call_if_exists(parent, attr): func = getattr(parent, attr, lambda: None) func() class BaseTestSuite(object): """A simple test suite that doesn't provide class or module shared fixtures. """ def __init__(self, tests=()): self._tests = [] self.addTests(tests) def __repr__(self): return "<%s tests=%s>" % (util.strclass(self.__class__), list(self)) def __eq__(self, other): if not isinstance(other, self.__class__): return NotImplemented return list(self) == list(other) def __ne__(self, other): return not self == other def __iter__(self): return iter(self._tests) def countTestCases(self): cases = 0 for test in self: cases += test.countTestCases() return cases def addTest(self, test): # sanity checks if not callable(test): raise TypeError("{} is not callable".format(repr(test))) if isinstance(test, type) and issubclass(test, (case.TestCase, TestSuite)): raise TypeError("TestCases and TestSuites must be instantiated " "before passing them to addTest()") self._tests.append(test) def addTests(self, tests): if isinstance(tests, str): raise TypeError("tests must be an iterable of tests, not a string") for test in tests: self.addTest(test) def run(self, result): for test in self: if result.shouldStop: break test(result) return result def __call__(self, *args, **kwds): return self.run(*args, **kwds) def debug(self): """Run the tests without collecting errors in a TestResult""" for test in self: test.debug() class TestSuite(BaseTestSuite): """A test suite is a composite test consisting of a number of TestCases. For use, create an instance of TestSuite, then add test case instances. When all tests have been added, the suite can be passed to a test runner, such as TextTestRunner. It will run the individual test cases in the order in which they were added, aggregating the results. When subclassing, do not forget to call the base class constructor. """ def run(self, result, debug=False): topLevel = False if getattr(result, '_testRunEntered', False) is False: result._testRunEntered = topLevel = True for test in self: if result.shouldStop: break if _isnotsuite(test): self._tearDownPreviousClass(test, result) self._handleModuleFixture(test, result) self._handleClassSetUp(test, result) result._previousTestClass = test.__class__ if (getattr(test.__class__, '_classSetupFailed', False) or getattr(result, '_moduleSetUpFailed', False)): continue if not debug: test(result) else: test.debug() if topLevel: self._tearDownPreviousClass(None, result) self._handleModuleTearDown(result) result._testRunEntered = False return result def debug(self): """Run the tests without collecting errors in a TestResult""" debug = _DebugResult() self.run(debug, True) ################################ def _handleClassSetUp(self, test, result): previousClass = getattr(result, '_previousTestClass', None) currentClass = test.__class__ if currentClass == previousClass: return if result._moduleSetUpFailed: return if getattr(currentClass, "__unittest_skip__", False): return try: currentClass._classSetupFailed = False except TypeError: # test may actually be a function # so its class will be a builtin-type pass setUpClass = getattr(currentClass, 'setUpClass', None) if setUpClass is not None: _call_if_exists(result, '_setupStdout') try: setUpClass() except Exception as e: if isinstance(result, _DebugResult): raise currentClass._classSetupFailed = True className = util.strclass(currentClass) errorName = 'setUpClass (%s)' % className self._addClassOrModuleLevelException(result, e, errorName) finally: _call_if_exists(result, '_restoreStdout') def _get_previous_module(self, result): previousModule = None previousClass = getattr(result, '_previousTestClass', None) if previousClass is not None: previousModule = previousClass.__module__ return previousModule def _handleModuleFixture(self, test, result): previousModule = self._get_previous_module(result) currentModule = test.__class__.__module__ if currentModule == previousModule: return self._handleModuleTearDown(result) result._moduleSetUpFailed = False try: module = sys.modules[currentModule] except KeyError: return setUpModule = getattr(module, 'setUpModule', None) if setUpModule is not None: _call_if_exists(result, '_setupStdout') try: setUpModule() except Exception as e: if isinstance(result, _DebugResult): raise result._moduleSetUpFailed = True errorName = 'setUpModule (%s)' % currentModule self._addClassOrModuleLevelException(result, e, errorName) finally: _call_if_exists(result, '_restoreStdout') def _addClassOrModuleLevelException(self, result, exception, errorName): error = _ErrorHolder(errorName) addSkip = getattr(result, 'addSkip', None) if addSkip is not None and isinstance(exception, case.SkipTest): addSkip(error, str(exception)) else: result.addError(error, sys.exc_info()) def _handleModuleTearDown(self, result): previousModule = self._get_previous_module(result) if previousModule is None: return if result._moduleSetUpFailed: return try: module = sys.modules[previousModule] except KeyError: return tearDownModule = getattr(module, 'tearDownModule', None) if tearDownModule is not None: _call_if_exists(result, '_setupStdout') try: tearDownModule() except Exception as e: if isinstance(result, _DebugResult): raise errorName = 'tearDownModule (%s)' % previousModule self._addClassOrModuleLevelException(result, e, errorName) finally: _call_if_exists(result, '_restoreStdout') def _tearDownPreviousClass(self, test, result): previousClass = getattr(result, '_previousTestClass', None) currentClass = test.__class__ if currentClass == previousClass: return if getattr(previousClass, '_classSetupFailed', False): return if getattr(result, '_moduleSetUpFailed', False): return if getattr(previousClass, "__unittest_skip__", False): return tearDownClass = getattr(previousClass, 'tearDownClass', None) if tearDownClass is not None: _call_if_exists(result, '_setupStdout') try: tearDownClass() except Exception as e: if isinstance(result, _DebugResult): raise className = util.strclass(previousClass) errorName = 'tearDownClass (%s)' % className self._addClassOrModuleLevelException(result, e, errorName) finally: _call_if_exists(result, '_restoreStdout') class _ErrorHolder(object): """ Placeholder for a TestCase inside a result. As far as a TestResult is concerned, this looks exactly like a unit test. Used to insert arbitrary errors into a test suite run. """ # Inspired by the ErrorHolder from Twisted: # http://twistedmatrix.com/trac/browser/trunk/twisted/trial/runner.py # attribute used by TestResult._exc_info_to_string failureException = None def __init__(self, description): self.description = description def id(self): return self.description def shortDescription(self): return None def __repr__(self): return "<ErrorHolder description=%r>" % (self.description,) def __str__(self): return self.id() def run(self, result): # could call result.addError(...) - but this test-like object # shouldn't be run anyway pass def __call__(self, result): return self.run(result) def countTestCases(self): return 0 def _isnotsuite(test): "A crude way to tell apart testcases and suites with duck-typing" try: iter(test) except TypeError: return True return False class _DebugResult(object): "Used by the TestSuite to hold previous class when running in debug." _previousTestClass = None _moduleSetUpFailed = False shouldStop = False
gpl-3.0
[ 624, 10591, 624, 199, 199, 646, 984, 199, 199, 504, 1275, 492, 1930, 199, 504, 1275, 492, 4884, 199, 199, 363, 2796, 275, 715, 421, 199, 318, 485, 1250, 63, 692, 63, 2444, 8, 1708, 12, 1921, 304, 272, 2562, 275, 2519, 8, 1708, 12, 1921, 12, 2400, 26, 488, 9, 272, 2562, 342, 421, 199, 533, 3523, 10591, 8, 785, 304, 272, 408, 33, 3486, 511, 5241, 626, 3181, 1133, 5647, 1021, 503, 859, 5709, 15188, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 2295, 23603, 267, 291, 423, 2219, 275, 942, 267, 291, 14, 525, 2925, 8, 2219, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 23054, 83, 2295, 2458, 83, 4335, 450, 334, 1974, 14, 495, 533, 8, 277, 855, 533, 10139, 769, 8, 277, 430, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 340, 440, 1228, 8, 1848, 12, 291, 855, 533, 18580, 288, 372, 3784, 267, 372, 769, 8, 277, 9, 508, 769, 8, 1848, 9, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 291, 508, 1163, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 423, 2219, 9, 339, 347, 2338, 19346, 8, 277, 304, 267, 5560, 275, 378, 267, 367, 511, 315, 291, 26, 288, 5560, 847, 511, 14, 835, 19346, 342, 267, 372, 5560, 339, 347, 1050, 774, 8, 277, 12, 511, 304, 267, 327, 16740, 5920, 267, 340, 440, 4550, 8, 396, 304, 288, 746, 3146, 20794, 365, 440, 4550, 1674, 908, 8, 2722, 8, 396, 1724, 267, 340, 1228, 8, 396, 12, 730, 9, 436, 11602, 8, 396, 12, 1740, 334, 2546, 14, 1746, 12, 20979, 2298, 288, 746, 3146, 480, 19346, 436, 1379, 24458, 1471, 506, 17544, 298, 1169, 298, 5182, 9476, 3062, 370, 1050, 774, 16060, 267, 291, 423, 2219, 14, 740, 8, 396, 9, 339, 347, 1050, 2925, 8, 277, 12, 2295, 304, 267, 340, 1228, 8, 2219, 12, 620, 304, 288, 746, 3146, 480, 2219, 1471, 506, 376, 6076, 402, 2295, 12, 440, 282, 1059, 531, 267, 367, 511, 315, 2295, 26, 288, 291, 14, 15714, 8, 396, 9, 339, 347, 1255, 8, 277, 12, 754, 304, 267, 367, 511, 315, 291, 26, 288, 340, 754, 14, 5626, 6293, 26, 355, 2059, 288, 511, 8, 1099, 9, 267, 372, 754, 339, 347, 636, 1250, 721, 277, 12, 627, 589, 12, 1011, 10340, 304, 267, 372, 291, 14, 1065, 2031, 589, 12, 1011, 10340, 9, 339, 347, 3105, 8, 277, 304, 267, 408, 2540, 314, 2295, 1928, 32223, 2552, 315, 282, 23795, 624, 267, 367, 511, 315, 291, 26, 288, 511, 14, 1757, 342, 421, 199, 533, 20979, 8, 1563, 10591, 304, 272, 408, 33, 511, 5241, 365, 282, 19306, 511, 22581, 402, 282, 1329, 402, 7640, 83, 14, 339, 2104, 675, 12, 1218, 376, 1256, 402, 20979, 12, 2066, 1050, 511, 1930, 4454, 14, 272, 3979, 1006, 2295, 1172, 2757, 3483, 12, 314, 5241, 883, 506, 3032, 370, 282, 511, 272, 7876, 12, 4066, 465, 4516, 13649, 14, 2779, 911, 1255, 314, 8212, 511, 5560, 272, 315, 314, 1865, 315, 1314, 2985, 4898, 3483, 12, 10454, 1958, 314, 2058, 14, 3979, 272, 24572, 12, 886, 440, 19459, 370, 1240, 314, 1300, 1021, 3787, 14, 272, 408, 339, 347, 1255, 8, 277, 12, 754, 12, 3105, 29, 797, 304, 267, 2746, 4670, 275, 756, 267, 340, 2519, 8, 1099, 12, 2513, 396, 2540, 1327, 3014, 297, 756, 9, 365, 756, 26, 288, 754, 423, 396, 2540, 1327, 3014, 275, 2746, 4670, 275, 715, 398, 367, 511, 315, 291, 26, 288, 340, 754, 14, 5626, 6293, 26, 355, 2059, 953, 340, 485, 374, 1397, 5768, 8, 396, 304, 355, 291, 423, 12336, 18021, 2543, 8, 396, 12, 754, 9, 355, 291, 423, 2479, 2377, 12812, 8, 396, 12, 754, 9, 355, 291, 423, 2479, 2543, 19845, 8, 396, 12, 754, 9, 355, 754, 423, 6352, 22009, 275, 511, 855, 533, 363, 2234, 340, 334, 5675, 8, 396, 855, 533, 3108, 2513, 533, 8555, 4276, 297, 756, 9, 503, 490, 2519, 8, 1099, 12, 2513, 578, 19845, 4276, 297, 756, 2298, 490, 1980, 953, 340, 440, 3105, 26, 355, 511, 8, 1099, 9, 288, 587, 26, 355, 511, 14, 1757, 342, 398, 340, 2746, 4670, 26, 288, 291, 423, 12336, 18021, 2543, 8, 403, 12, 754, 9, 288, 291, 423, 2479, 2377, 30711, 8, 1099, 9, 288, 754, 423, 396, 2540, 1327, 3014, 275, 756, 267, 372, 754, 339, 347, 3105, 8, 277, 304, 267, 408, 2540, 314, 2295, 1928, 32223, 2552, 315, 282, 23795, 624, 267, 3105, 275, 485, 7084, 2889, 342, 267, 291, 14, 1065, 8, 1757, 12, 715, 9, 339, 10371, 339, 347, 485, 2479, 2543, 19845, 8, 277, 12, 511, 12, 754, 304, 267, 4136, 2543, 275, 2519, 8, 1099, 12, 2513, 6352, 22009, 297, 488, 9, 267, 1453, 2543, 275, 511, 855, 533, 363, 267, 340, 1453, 2543, 508, 4136, 2543, 26, 288, 372, 267, 340, 754, 423, 578, 19845, 4276, 26, 288, 372, 267, 340, 2519, 8, 1818, 2543, 12, 4396, 2796, 63, 2759, 13915, 756, 304, 288, 372, 398, 862, 26, 288, 1453, 2543, 423, 533, 8555, 4276, 275, 756, 267, 871, 3146, 26, 288, 327, 511, 1443, 5965, 506, 282, 805, 288, 327, 880, 2399, 1021, 911, 506, 282, 6762, 13, 466, 288, 986, 398, 18561, 275, 2519, 8, 1818, 2543, 12, 283, 27777, 297, 488, 9, 267, 340, 18561, 365, 440, 488, 26, 288, 485, 1250, 63, 692, 63, 2444, 8, 1099, 12, 2513, 2758, 26080, 358, 288, 862, 26, 355, 18561, 342, 288, 871, 2186, 465, 325, 26, 355, 340, 1228, 8, 1099, 12, 485, 7084, 2889, 304, 490, 746, 355, 1453, 2543, 423, 533, 8555, 4276, 275, 715, 355, 1021, 985, 275, 4884, 14, 495, 533, 8, 1818, 2543, 9, 355, 1125, 985, 275, 283, 27777, 4366, 83, 3171, 450, 1021, 985, 355, 291, 423, 525, 2543, 2844, 2377, 4670, 1726, 8, 1099, 12, 325, 12, 1125, 985, 9, 288, 3753, 26, 355, 485, 1250, 63, 692, 63, 2444, 8, 1099, 12, 2513, 8011, 26080, 358, 339, 347, 485, 362, 63, 6352, 63, 578, 8, 277, 12, 754, 304 ]
[ 10591, 624, 199, 199, 646, 984, 199, 199, 504, 1275, 492, 1930, 199, 504, 1275, 492, 4884, 199, 199, 363, 2796, 275, 715, 421, 199, 318, 485, 1250, 63, 692, 63, 2444, 8, 1708, 12, 1921, 304, 272, 2562, 275, 2519, 8, 1708, 12, 1921, 12, 2400, 26, 488, 9, 272, 2562, 342, 421, 199, 533, 3523, 10591, 8, 785, 304, 272, 408, 33, 3486, 511, 5241, 626, 3181, 1133, 5647, 1021, 503, 859, 5709, 15188, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 2295, 23603, 267, 291, 423, 2219, 275, 942, 267, 291, 14, 525, 2925, 8, 2219, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 23054, 83, 2295, 2458, 83, 4335, 450, 334, 1974, 14, 495, 533, 8, 277, 855, 533, 10139, 769, 8, 277, 430, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 340, 440, 1228, 8, 1848, 12, 291, 855, 533, 18580, 288, 372, 3784, 267, 372, 769, 8, 277, 9, 508, 769, 8, 1848, 9, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 291, 508, 1163, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 423, 2219, 9, 339, 347, 2338, 19346, 8, 277, 304, 267, 5560, 275, 378, 267, 367, 511, 315, 291, 26, 288, 5560, 847, 511, 14, 835, 19346, 342, 267, 372, 5560, 339, 347, 1050, 774, 8, 277, 12, 511, 304, 267, 327, 16740, 5920, 267, 340, 440, 4550, 8, 396, 304, 288, 746, 3146, 20794, 365, 440, 4550, 1674, 908, 8, 2722, 8, 396, 1724, 267, 340, 1228, 8, 396, 12, 730, 9, 436, 11602, 8, 396, 12, 1740, 334, 2546, 14, 1746, 12, 20979, 2298, 288, 746, 3146, 480, 19346, 436, 1379, 24458, 1471, 506, 17544, 298, 1169, 298, 5182, 9476, 3062, 370, 1050, 774, 16060, 267, 291, 423, 2219, 14, 740, 8, 396, 9, 339, 347, 1050, 2925, 8, 277, 12, 2295, 304, 267, 340, 1228, 8, 2219, 12, 620, 304, 288, 746, 3146, 480, 2219, 1471, 506, 376, 6076, 402, 2295, 12, 440, 282, 1059, 531, 267, 367, 511, 315, 2295, 26, 288, 291, 14, 15714, 8, 396, 9, 339, 347, 1255, 8, 277, 12, 754, 304, 267, 367, 511, 315, 291, 26, 288, 340, 754, 14, 5626, 6293, 26, 355, 2059, 288, 511, 8, 1099, 9, 267, 372, 754, 339, 347, 636, 1250, 721, 277, 12, 627, 589, 12, 1011, 10340, 304, 267, 372, 291, 14, 1065, 2031, 589, 12, 1011, 10340, 9, 339, 347, 3105, 8, 277, 304, 267, 408, 2540, 314, 2295, 1928, 32223, 2552, 315, 282, 23795, 624, 267, 367, 511, 315, 291, 26, 288, 511, 14, 1757, 342, 421, 199, 533, 20979, 8, 1563, 10591, 304, 272, 408, 33, 511, 5241, 365, 282, 19306, 511, 22581, 402, 282, 1329, 402, 7640, 83, 14, 339, 2104, 675, 12, 1218, 376, 1256, 402, 20979, 12, 2066, 1050, 511, 1930, 4454, 14, 272, 3979, 1006, 2295, 1172, 2757, 3483, 12, 314, 5241, 883, 506, 3032, 370, 282, 511, 272, 7876, 12, 4066, 465, 4516, 13649, 14, 2779, 911, 1255, 314, 8212, 511, 5560, 272, 315, 314, 1865, 315, 1314, 2985, 4898, 3483, 12, 10454, 1958, 314, 2058, 14, 3979, 272, 24572, 12, 886, 440, 19459, 370, 1240, 314, 1300, 1021, 3787, 14, 272, 408, 339, 347, 1255, 8, 277, 12, 754, 12, 3105, 29, 797, 304, 267, 2746, 4670, 275, 756, 267, 340, 2519, 8, 1099, 12, 2513, 396, 2540, 1327, 3014, 297, 756, 9, 365, 756, 26, 288, 754, 423, 396, 2540, 1327, 3014, 275, 2746, 4670, 275, 715, 398, 367, 511, 315, 291, 26, 288, 340, 754, 14, 5626, 6293, 26, 355, 2059, 953, 340, 485, 374, 1397, 5768, 8, 396, 304, 355, 291, 423, 12336, 18021, 2543, 8, 396, 12, 754, 9, 355, 291, 423, 2479, 2377, 12812, 8, 396, 12, 754, 9, 355, 291, 423, 2479, 2543, 19845, 8, 396, 12, 754, 9, 355, 754, 423, 6352, 22009, 275, 511, 855, 533, 363, 2234, 340, 334, 5675, 8, 396, 855, 533, 3108, 2513, 533, 8555, 4276, 297, 756, 9, 503, 490, 2519, 8, 1099, 12, 2513, 578, 19845, 4276, 297, 756, 2298, 490, 1980, 953, 340, 440, 3105, 26, 355, 511, 8, 1099, 9, 288, 587, 26, 355, 511, 14, 1757, 342, 398, 340, 2746, 4670, 26, 288, 291, 423, 12336, 18021, 2543, 8, 403, 12, 754, 9, 288, 291, 423, 2479, 2377, 30711, 8, 1099, 9, 288, 754, 423, 396, 2540, 1327, 3014, 275, 756, 267, 372, 754, 339, 347, 3105, 8, 277, 304, 267, 408, 2540, 314, 2295, 1928, 32223, 2552, 315, 282, 23795, 624, 267, 3105, 275, 485, 7084, 2889, 342, 267, 291, 14, 1065, 8, 1757, 12, 715, 9, 339, 10371, 339, 347, 485, 2479, 2543, 19845, 8, 277, 12, 511, 12, 754, 304, 267, 4136, 2543, 275, 2519, 8, 1099, 12, 2513, 6352, 22009, 297, 488, 9, 267, 1453, 2543, 275, 511, 855, 533, 363, 267, 340, 1453, 2543, 508, 4136, 2543, 26, 288, 372, 267, 340, 754, 423, 578, 19845, 4276, 26, 288, 372, 267, 340, 2519, 8, 1818, 2543, 12, 4396, 2796, 63, 2759, 13915, 756, 304, 288, 372, 398, 862, 26, 288, 1453, 2543, 423, 533, 8555, 4276, 275, 756, 267, 871, 3146, 26, 288, 327, 511, 1443, 5965, 506, 282, 805, 288, 327, 880, 2399, 1021, 911, 506, 282, 6762, 13, 466, 288, 986, 398, 18561, 275, 2519, 8, 1818, 2543, 12, 283, 27777, 297, 488, 9, 267, 340, 18561, 365, 440, 488, 26, 288, 485, 1250, 63, 692, 63, 2444, 8, 1099, 12, 2513, 2758, 26080, 358, 288, 862, 26, 355, 18561, 342, 288, 871, 2186, 465, 325, 26, 355, 340, 1228, 8, 1099, 12, 485, 7084, 2889, 304, 490, 746, 355, 1453, 2543, 423, 533, 8555, 4276, 275, 715, 355, 1021, 985, 275, 4884, 14, 495, 533, 8, 1818, 2543, 9, 355, 1125, 985, 275, 283, 27777, 4366, 83, 3171, 450, 1021, 985, 355, 291, 423, 525, 2543, 2844, 2377, 4670, 1726, 8, 1099, 12, 325, 12, 1125, 985, 9, 288, 3753, 26, 355, 485, 1250, 63, 692, 63, 2444, 8, 1099, 12, 2513, 8011, 26080, 358, 339, 347, 485, 362, 63, 6352, 63, 578, 8, 277, 12, 754, 304, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
astrofrog/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/ext/_bundled/ordereddict.py
21
9002
# Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and pypy. # Passes Python2.7's test suite and incorporates all the latest updates. # MIT-licensed from: # http://code.activestate.com/recipes/576693/ # http://docs.python.org/2/library/collections.html#ordereddict-objects try: from thread import get_ident as _get_ident except ImportError: from dummy_thread import get_ident as _get_ident try: from _abcoll import KeysView, ValuesView, ItemsView except ImportError: pass class OrderedDict(dict): 'Dictionary that remembers insertion order' # An inherited dict maps keys to values. # The inherited dict provides __getitem__, __len__, __contains__, and get. # The remaining methods are order-aware. # Big-O running times for all methods are the same as for regular # dictionaries. # The internal self.__map dictionary maps keys to links in a doubly linked list. # The circular doubly linked list starts and ends with a sentinel element. # The sentinel element never gets deleted (this simplifies the algorithm). # Each link is stored as a list of length three: [PREV, NEXT, KEY]. def __init__(self, *args, **kwargs): '''Initialize an ordered dictionary. Signature is the same as for regular dictionaries, but keyword arguments are not recommended because their insertion order is arbitrary. ''' if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) try: self.__root except AttributeError: self.__root = root = [] # sentinel node root[:] = [root, root, None] self.__map = {} self.__update(*args, **kwargs) def __setitem__(self, key, value, dict_setitem=dict.__setitem__): 'od.__setitem__(i, y) <==> od[i]=y' # Setting a new item creates a new link which goes at the end of the linked # list, and the inherited dictionary is updated with the new key/value # pair. if key not in self: root = self.__root last = root[0] last[1] = root[0] = self.__map[key] = [last, root, key] dict_setitem(self, key, value) def __delitem__(self, key, dict_delitem=dict.__delitem__): 'od.__delitem__(y) <==> del od[y]' # Deleting an existing item uses self.__map to find the link which is # then removed by updating the links in the predecessor and successor # nodes. dict_delitem(self, key) link_prev, link_next, key = self.__map.pop(key) link_prev[1] = link_next link_next[0] = link_prev def __iter__(self): 'od.__iter__() <==> iter(od)' root = self.__root curr = root[1] while curr is not root: yield curr[2] curr = curr[1] def __reversed__(self): 'od.__reversed__() <==> reversed(od)' root = self.__root curr = root[0] while curr is not root: yield curr[2] curr = curr[0] def clear(self): 'od.clear() -> None. Remove all items from od.' try: for node in self.__map.itervalues(): del node[:] root = self.__root root[:] = [root, root, None] self.__map.clear() except AttributeError: pass dict.clear(self) def popitem(self, last=True): '''od.popitem() -> (k, v), return and remove a (key, value) pair. Pairs are returned in LIFO order if last is true or FIFO order if false. ''' if not self: raise KeyError('dictionary is empty') root = self.__root if last: link = root[0] link_prev = link[0] link_prev[1] = root root[0] = link_prev else: link = root[1] link_next = link[1] root[1] = link_next link_next[0] = root key = link[2] del self.__map[key] value = dict.pop(self, key) return key, value # -- the following methods do not depend on the internal structure -- def keys(self): 'od.keys() -> list of keys in od' return list(self) def values(self): 'od.values() -> list of values in od' return [self[key] for key in self] def items(self): 'od.items() -> list of (key, value) pairs in od' return [(key, self[key]) for key in self] def iterkeys(self): 'od.iterkeys() -> an iterator over the keys in od' return iter(self) def itervalues(self): 'od.itervalues -> an iterator over the values in od' for k in self: yield self[k] def iteritems(self): 'od.iteritems -> an iterator over the (key, value) items in od' for k in self: yield (k, self[k]) def update(*args, **kwargs): '''od.update(E, **F) -> None. Update od from dict/iterable E and F. If E is a dict instance, does: for k in E: od[k] = E[k] If E has a .keys() method, does: for k in E.keys(): od[k] = E[k] Or if E is an iterable of items, does: for k, v in E: od[k] = v In either case, this is followed by: for k, v in F.items(): od[k] = v ''' if len(args) > 2: raise TypeError('update() takes at most 2 positional ' 'arguments (%d given)' % (len(args),)) elif not args: raise TypeError('update() takes at least 1 argument (0 given)') self = args[0] # Make progressively weaker assumptions about "other" other = () if len(args) == 2: other = args[1] if isinstance(other, dict): for key in other: self[key] = other[key] elif hasattr(other, 'keys'): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwargs.items(): self[key] = value # let subclasses override update without breaking __init__ __update = update __marker = object() def pop(self, key, default=__marker): '''od.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised. ''' if key in self: result = self[key] del self[key] return result if default is self.__marker: raise KeyError(key) return default def setdefault(self, key, default=None): 'od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od' if key in self: return self[key] self[key] = default return default def __repr__(self, _repr_running={}): 'od.__repr__() <==> repr(od)' call_key = id(self), _get_ident() if call_key in _repr_running: return '...' _repr_running[call_key] = 1 try: if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, self.items()) finally: del _repr_running[call_key] def __reduce__(self): 'Return state information for pickling' items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() for k in vars(OrderedDict()): inst_dict.pop(k, None) if inst_dict: return (self.__class__, (items,), inst_dict) return self.__class__, (items,) def copy(self): 'od.copy() -> a shallow copy of od' return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): '''OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S and values equal to v (which defaults to None). ''' d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): '''od.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive while comparison to a regular mapping is order-insensitive. ''' if isinstance(other, OrderedDict): return len(self) == len(other) and self.items() == other.items() return dict.__eq__(self, other) def __ne__(self, other): return not self == other # -- the following methods are only used in Python 2.7 -- def viewkeys(self): "od.viewkeys() -> a set-like object providing a view on od's keys" return KeysView(self) def viewvalues(self): "od.viewvalues() -> an object providing a view on od's values" return ValuesView(self) def viewitems(self): "od.viewitems() -> a set-like object providing a view on od's items" return ItemsView(self)
bsd-2-clause
[ 3, 10257, 719, 402, 8773, 342, 1021, 626, 7858, 641, 2018, 499, 14, 20, 12, 499, 14, 21, 12, 499, 14, 22, 12, 499, 14, 23, 436, 1134, 647, 14, 199, 3, 510, 1916, 2018, 18, 14, 23, 1159, 511, 5241, 436, 30147, 2335, 1006, 314, 8839, 7029, 14, 199, 199, 3, 10697, 13, 1682, 68, 687, 26, 199, 3, 1455, 921, 600, 14, 32595, 14, 957, 15, 25200, 15, 1641, 1272, 3129, 15, 199, 3, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 7882, 14, 1360, 3, 8235, 807, 13, 1462, 199, 199, 893, 26, 272, 687, 2462, 492, 664, 63, 5425, 465, 485, 362, 63, 5425, 199, 2590, 3545, 26, 272, 687, 7283, 63, 2671, 492, 664, 63, 5425, 465, 485, 362, 63, 5425, 199, 199, 893, 26, 272, 687, 485, 371, 15772, 492, 17276, 2768, 12, 13468, 2768, 12, 20720, 2768, 199, 2590, 3545, 26, 272, 986, 421, 199, 533, 8773, 8, 807, 304, 339, 283, 11728, 626, 295, 6334, 22470, 1865, 7, 272, 327, 1626, 12623, 1211, 9033, 2883, 370, 1338, 14, 272, 327, 710, 12623, 1211, 6571, 636, 6095, 3108, 636, 552, 3108, 636, 6134, 3108, 436, 664, 14, 272, 327, 710, 7971, 3102, 787, 1865, 13, 14600, 14, 272, 327, 13123, 13, 47, 3879, 5431, 367, 1006, 3102, 787, 314, 2011, 465, 367, 5578, 272, 327, 11196, 14, 339, 327, 710, 5007, 291, 855, 1130, 2600, 9033, 2883, 370, 6220, 315, 282, 28584, 590, 10632, 769, 14, 272, 327, 710, 15032, 28584, 590, 10632, 769, 9174, 436, 11187, 543, 282, 13792, 1819, 14, 272, 327, 710, 13792, 1819, 7078, 7545, 5463, 334, 3749, 17553, 5604, 314, 5563, 680, 272, 327, 7048, 2142, 365, 5489, 465, 282, 769, 402, 2582, 7795, 26, 221, 359, 28422, 12, 653, 2472, 12, 9301, 1055, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1449, 9345, 376, 7741, 2600, 14, 221, 18603, 365, 314, 2011, 465, 367, 267, 5578, 11196, 12, 1325, 4252, 2368, 787, 440, 14318, 267, 2952, 3932, 22470, 1865, 365, 9697, 14, 398, 1449, 267, 340, 822, 8, 589, 9, 690, 413, 26, 288, 746, 3146, 360, 2062, 737, 4750, 413, 2368, 12, 4788, 450, 68, 7, 450, 822, 8, 589, 430, 267, 862, 26, 288, 291, 855, 1231, 267, 871, 4281, 26, 288, 291, 855, 1231, 275, 1738, 275, 942, 9326, 327, 13792, 1031, 288, 1738, 5873, 275, 359, 1231, 12, 1738, 12, 488, 61, 288, 291, 855, 1130, 275, 1052, 267, 291, 855, 873, 2031, 589, 12, 1011, 958, 9, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 12, 1211, 63, 8617, 29, 807, 855, 8617, 18580, 267, 283, 364, 855, 8617, 721, 73, 12, 612, 9, 22651, 14467, 59, 73, 10404, 89, 7, 267, 327, 13510, 282, 892, 1242, 8491, 282, 892, 2142, 1314, 13538, 737, 314, 1284, 402, 314, 10632, 267, 327, 769, 12, 436, 314, 12623, 2600, 365, 4588, 543, 314, 892, 790, 15, 585, 267, 327, 4092, 14, 267, 340, 790, 440, 315, 291, 26, 288, 1738, 275, 291, 855, 1231, 288, 2061, 275, 1738, 59, 16, 61, 288, 2061, 59, 17, 61, 275, 1738, 59, 16, 61, 275, 291, 855, 1130, 59, 498, 61, 275, 359, 2019, 12, 1738, 12, 790, 61, 267, 1211, 63, 8617, 8, 277, 12, 790, 12, 574, 9, 339, 347, 636, 13228, 721, 277, 12, 790, 12, 1211, 63, 13228, 29, 807, 855, 13228, 18580, 267, 283, 364, 855, 13228, 721, 89, 9, 22651, 2150, 14467, 59, 89, 6616, 267, 327, 15920, 376, 3411, 1242, 4440, 291, 855, 1130, 370, 2342, 314, 2142, 1314, 365, 267, 327, 2066, 4829, 701, 12928, 314, 6220, 315, 314, 876, 27914, 269, 436, 3182, 269, 267, 327, 3380, 14, 267, 1211, 63, 13228, 8, 277, 12, 790, 9, 267, 2142, 63, 5701, 12, 2142, 63, 2184, 12, 790, 275, 291, 855, 1130, 14, 1935, 8, 498, 9, 267, 2142, 63, 5701, 59, 17, 61, 275, 2142, 63, 2184, 267, 2142, 63, 2184, 59, 16, 61, 275, 2142, 63, 5701, 339, 347, 636, 1661, 721, 277, 304, 267, 283, 364, 855, 1661, 4533, 22651, 2740, 8, 364, 3171, 267, 1738, 275, 291, 855, 1231, 267, 8230, 275, 1738, 59, 17, 61, 267, 1830, 8230, 365, 440, 1738, 26, 288, 1995, 8230, 59, 18, 61, 288, 8230, 275, 8230, 59, 17, 61, 339, 347, 636, 13501, 721, 277, 304, 267, 283, 364, 855, 13501, 4533, 22651, 10822, 8, 364, 3171, 267, 1738, 275, 291, 855, 1231, 267, 8230, 275, 1738, 59, 16, 61, 267, 1830, 8230, 365, 440, 1738, 26, 288, 1995, 8230, 59, 18, 61, 288, 8230, 275, 8230, 59, 16, 61, 339, 347, 5436, 8, 277, 304, 267, 283, 364, 14, 3584, 342, 1035, 488, 14, 221, 5852, 1006, 2974, 687, 14467, 3530, 267, 862, 26, 288, 367, 1031, 315, 291, 855, 1130, 14, 13012, 837, 355, 2150, 1031, 5873, 288, 1738, 275, 291, 855, 1231, 288, 1738, 5873, 275, 359, 1231, 12, 1738, 12, 488, 61, 288, 291, 855, 1130, 14, 3584, 342, 267, 871, 4281, 26, 288, 986, 267, 1211, 14, 3584, 8, 277, 9, 339, 347, 4560, 1053, 8, 277, 12, 2061, 29, 549, 304, 267, 1449, 364, 14, 24882, 342, 1035, 334, 75, 12, 373, 395, 372, 436, 2813, 282, 334, 498, 12, 574, 9, 4092, 14, 267, 510, 8387, 83, 787, 2138, 315, 3782, 3230, 1865, 340, 2061, 365, 2549, 503, 15435, 3230, 1865, 340, 3055, 14, 398, 1449, 267, 340, 440, 291, 26, 288, 746, 4067, 360, 9086, 365, 2701, 358, 267, 1738, 275, 291, 855, 1231, 267, 340, 2061, 26, 288, 2142, 275, 1738, 59, 16, 61, 288, 2142, 63, 5701, 275, 2142, 59, 16, 61, 288, 2142, 63, 5701, 59, 17, 61, 275, 1738, 288, 1738, 59, 16, 61, 275, 2142, 63, 5701, 267, 587, 26, 288, 2142, 275, 1738, 59, 17, 61, 288, 2142, 63, 2184, 275, 2142, 59, 17, 61, 288, 1738, 59, 17, 61, 275, 2142, 63, 2184, 288, 2142, 63, 2184, 59, 16, 61, 275, 1738, 267, 790, 275, 2142, 59, 18, 61, 267, 2150, 291, 855, 1130, 59, 498, 61, 267, 574, 275, 1211, 14, 1935, 8, 277 ]
[ 10257, 719, 402, 8773, 342, 1021, 626, 7858, 641, 2018, 499, 14, 20, 12, 499, 14, 21, 12, 499, 14, 22, 12, 499, 14, 23, 436, 1134, 647, 14, 199, 3, 510, 1916, 2018, 18, 14, 23, 1159, 511, 5241, 436, 30147, 2335, 1006, 314, 8839, 7029, 14, 199, 199, 3, 10697, 13, 1682, 68, 687, 26, 199, 3, 1455, 921, 600, 14, 32595, 14, 957, 15, 25200, 15, 1641, 1272, 3129, 15, 199, 3, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 7882, 14, 1360, 3, 8235, 807, 13, 1462, 199, 199, 893, 26, 272, 687, 2462, 492, 664, 63, 5425, 465, 485, 362, 63, 5425, 199, 2590, 3545, 26, 272, 687, 7283, 63, 2671, 492, 664, 63, 5425, 465, 485, 362, 63, 5425, 199, 199, 893, 26, 272, 687, 485, 371, 15772, 492, 17276, 2768, 12, 13468, 2768, 12, 20720, 2768, 199, 2590, 3545, 26, 272, 986, 421, 199, 533, 8773, 8, 807, 304, 339, 283, 11728, 626, 295, 6334, 22470, 1865, 7, 272, 327, 1626, 12623, 1211, 9033, 2883, 370, 1338, 14, 272, 327, 710, 12623, 1211, 6571, 636, 6095, 3108, 636, 552, 3108, 636, 6134, 3108, 436, 664, 14, 272, 327, 710, 7971, 3102, 787, 1865, 13, 14600, 14, 272, 327, 13123, 13, 47, 3879, 5431, 367, 1006, 3102, 787, 314, 2011, 465, 367, 5578, 272, 327, 11196, 14, 339, 327, 710, 5007, 291, 855, 1130, 2600, 9033, 2883, 370, 6220, 315, 282, 28584, 590, 10632, 769, 14, 272, 327, 710, 15032, 28584, 590, 10632, 769, 9174, 436, 11187, 543, 282, 13792, 1819, 14, 272, 327, 710, 13792, 1819, 7078, 7545, 5463, 334, 3749, 17553, 5604, 314, 5563, 680, 272, 327, 7048, 2142, 365, 5489, 465, 282, 769, 402, 2582, 7795, 26, 221, 359, 28422, 12, 653, 2472, 12, 9301, 1055, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1449, 9345, 376, 7741, 2600, 14, 221, 18603, 365, 314, 2011, 465, 367, 267, 5578, 11196, 12, 1325, 4252, 2368, 787, 440, 14318, 267, 2952, 3932, 22470, 1865, 365, 9697, 14, 398, 1449, 267, 340, 822, 8, 589, 9, 690, 413, 26, 288, 746, 3146, 360, 2062, 737, 4750, 413, 2368, 12, 4788, 450, 68, 7, 450, 822, 8, 589, 430, 267, 862, 26, 288, 291, 855, 1231, 267, 871, 4281, 26, 288, 291, 855, 1231, 275, 1738, 275, 942, 9326, 327, 13792, 1031, 288, 1738, 5873, 275, 359, 1231, 12, 1738, 12, 488, 61, 288, 291, 855, 1130, 275, 1052, 267, 291, 855, 873, 2031, 589, 12, 1011, 958, 9, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 12, 1211, 63, 8617, 29, 807, 855, 8617, 18580, 267, 283, 364, 855, 8617, 721, 73, 12, 612, 9, 22651, 14467, 59, 73, 10404, 89, 7, 267, 327, 13510, 282, 892, 1242, 8491, 282, 892, 2142, 1314, 13538, 737, 314, 1284, 402, 314, 10632, 267, 327, 769, 12, 436, 314, 12623, 2600, 365, 4588, 543, 314, 892, 790, 15, 585, 267, 327, 4092, 14, 267, 340, 790, 440, 315, 291, 26, 288, 1738, 275, 291, 855, 1231, 288, 2061, 275, 1738, 59, 16, 61, 288, 2061, 59, 17, 61, 275, 1738, 59, 16, 61, 275, 291, 855, 1130, 59, 498, 61, 275, 359, 2019, 12, 1738, 12, 790, 61, 267, 1211, 63, 8617, 8, 277, 12, 790, 12, 574, 9, 339, 347, 636, 13228, 721, 277, 12, 790, 12, 1211, 63, 13228, 29, 807, 855, 13228, 18580, 267, 283, 364, 855, 13228, 721, 89, 9, 22651, 2150, 14467, 59, 89, 6616, 267, 327, 15920, 376, 3411, 1242, 4440, 291, 855, 1130, 370, 2342, 314, 2142, 1314, 365, 267, 327, 2066, 4829, 701, 12928, 314, 6220, 315, 314, 876, 27914, 269, 436, 3182, 269, 267, 327, 3380, 14, 267, 1211, 63, 13228, 8, 277, 12, 790, 9, 267, 2142, 63, 5701, 12, 2142, 63, 2184, 12, 790, 275, 291, 855, 1130, 14, 1935, 8, 498, 9, 267, 2142, 63, 5701, 59, 17, 61, 275, 2142, 63, 2184, 267, 2142, 63, 2184, 59, 16, 61, 275, 2142, 63, 5701, 339, 347, 636, 1661, 721, 277, 304, 267, 283, 364, 855, 1661, 4533, 22651, 2740, 8, 364, 3171, 267, 1738, 275, 291, 855, 1231, 267, 8230, 275, 1738, 59, 17, 61, 267, 1830, 8230, 365, 440, 1738, 26, 288, 1995, 8230, 59, 18, 61, 288, 8230, 275, 8230, 59, 17, 61, 339, 347, 636, 13501, 721, 277, 304, 267, 283, 364, 855, 13501, 4533, 22651, 10822, 8, 364, 3171, 267, 1738, 275, 291, 855, 1231, 267, 8230, 275, 1738, 59, 16, 61, 267, 1830, 8230, 365, 440, 1738, 26, 288, 1995, 8230, 59, 18, 61, 288, 8230, 275, 8230, 59, 16, 61, 339, 347, 5436, 8, 277, 304, 267, 283, 364, 14, 3584, 342, 1035, 488, 14, 221, 5852, 1006, 2974, 687, 14467, 3530, 267, 862, 26, 288, 367, 1031, 315, 291, 855, 1130, 14, 13012, 837, 355, 2150, 1031, 5873, 288, 1738, 275, 291, 855, 1231, 288, 1738, 5873, 275, 359, 1231, 12, 1738, 12, 488, 61, 288, 291, 855, 1130, 14, 3584, 342, 267, 871, 4281, 26, 288, 986, 267, 1211, 14, 3584, 8, 277, 9, 339, 347, 4560, 1053, 8, 277, 12, 2061, 29, 549, 304, 267, 1449, 364, 14, 24882, 342, 1035, 334, 75, 12, 373, 395, 372, 436, 2813, 282, 334, 498, 12, 574, 9, 4092, 14, 267, 510, 8387, 83, 787, 2138, 315, 3782, 3230, 1865, 340, 2061, 365, 2549, 503, 15435, 3230, 1865, 340, 3055, 14, 398, 1449, 267, 340, 440, 291, 26, 288, 746, 4067, 360, 9086, 365, 2701, 358, 267, 1738, 275, 291, 855, 1231, 267, 340, 2061, 26, 288, 2142, 275, 1738, 59, 16, 61, 288, 2142, 63, 5701, 275, 2142, 59, 16, 61, 288, 2142, 63, 5701, 59, 17, 61, 275, 1738, 288, 1738, 59, 16, 61, 275, 2142, 63, 5701, 267, 587, 26, 288, 2142, 275, 1738, 59, 17, 61, 288, 2142, 63, 2184, 275, 2142, 59, 17, 61, 288, 1738, 59, 17, 61, 275, 2142, 63, 2184, 288, 2142, 63, 2184, 59, 16, 61, 275, 1738, 267, 790, 275, 2142, 59, 18, 61, 267, 2150, 291, 855, 1130, 59, 498, 61, 267, 574, 275, 1211, 14, 1935, 8, 277, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
plotly/plotly.py
packages/python/plotly/plotly/validators/streamtube/legendgrouptitle/_font.py
1
1540
import _plotly_utils.basevalidators class FontValidator(_plotly_utils.basevalidators.CompoundValidator): def __init__( self, plotly_name="font", parent_name="streamtube.legendgrouptitle", **kwargs ): super(FontValidator, self).__init__( plotly_name=plotly_name, parent_name=parent_name, data_class_str=kwargs.pop("data_class_str", "Font"), data_docs=kwargs.pop( "data_docs", """ color family HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The Chart Studio Cloud (at https://chart-studio.plotly.com or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include "Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New Roman". size """, ), **kwargs )
mit
[ 646, 485, 2798, 590, 63, 1208, 14, 1095, 11346, 421, 199, 533, 26159, 8640, 1547, 2798, 590, 63, 1208, 14, 1095, 11346, 14, 26552, 8640, 304, 272, 347, 636, 826, 721, 267, 291, 12, 5137, 590, 63, 354, 628, 4246, 401, 1676, 63, 354, 628, 1745, 84, 3375, 14, 10231, 923, 1213, 401, 1011, 958, 272, 3461, 267, 1613, 8, 6986, 8640, 12, 291, 2843, 826, 721, 288, 5137, 590, 63, 354, 29, 2798, 590, 63, 354, 12, 288, 1676, 63, 354, 29, 1708, 63, 354, 12, 288, 666, 63, 533, 63, 495, 29, 958, 14, 1935, 480, 576, 63, 533, 63, 495, 401, 298, 6986, 1288, 288, 666, 63, 4757, 29, 958, 14, 1935, 8, 355, 298, 576, 63, 4757, 401, 355, 408, 288, 3164, 953, 9614, 355, 4163, 5023, 9614, 446, 314, 730, 1409, 626, 911, 506, 355, 6781, 701, 314, 3330, 7042, 14, 710, 3330, 7042, 355, 911, 1454, 506, 7688, 370, 4838, 282, 5023, 340, 652, 365, 355, 2808, 641, 314, 2656, 1314, 652, 1758, 2335, 14, 355, 22896, 3663, 5023, 21450, 20111, 12, 11673, 701, 355, 24476, 12, 370, 6623, 314, 16705, 315, 1314, 370, 355, 4838, 26219, 340, 2985, 10621, 1133, 2808, 641, 314, 355, 2656, 14, 710, 24874, 13225, 8142, 334, 292, 355, 4178, 921, 9019, 13, 19806, 14, 2798, 590, 14, 957, 503, 641, 13, 657, 77, 572, 9, 355, 12821, 5935, 641, 282, 1654, 12, 2382, 1454, 282, 355, 3504, 1329, 402, 26219, 787, 4903, 436, 355, 3748, 14, 5723, 2387, 298, 33, 1383, 401, 298, 13129, 475, 401, 355, 298, 35, 567, 4446, 7053, 401, 298, 36, 3977, 428, 796, 401, 12, 298, 36, 3977, 3739, 692, 401, 355, 298, 36, 3977, 428, 796, 10953, 79, 401, 298, 5761, 86, 390, 305, 7309, 401, 298, 16411, 355, 9739, 377, 52, 401, 298, 4299, 428, 796, 401, 298, 5674, 1529, 401, 298, 4189, 428, 796, 355, 653, 7691, 401, 298, 1537, 274, 3316, 401, 298, 17687, 7053, 820, 21604, 1674, 288, 1568, 199, 199, 7208, 288, 2318, 288, 1011, 958, 267, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 485, 2798, 590, 63, 1208, 14, 1095, 11346, 421, 199, 533, 26159, 8640, 1547, 2798, 590, 63, 1208, 14, 1095, 11346, 14, 26552, 8640, 304, 272, 347, 636, 826, 721, 267, 291, 12, 5137, 590, 63, 354, 628, 4246, 401, 1676, 63, 354, 628, 1745, 84, 3375, 14, 10231, 923, 1213, 401, 1011, 958, 272, 3461, 267, 1613, 8, 6986, 8640, 12, 291, 2843, 826, 721, 288, 5137, 590, 63, 354, 29, 2798, 590, 63, 354, 12, 288, 1676, 63, 354, 29, 1708, 63, 354, 12, 288, 666, 63, 533, 63, 495, 29, 958, 14, 1935, 480, 576, 63, 533, 63, 495, 401, 298, 6986, 1288, 288, 666, 63, 4757, 29, 958, 14, 1935, 8, 355, 298, 576, 63, 4757, 401, 355, 408, 288, 3164, 953, 9614, 355, 4163, 5023, 9614, 446, 314, 730, 1409, 626, 911, 506, 355, 6781, 701, 314, 3330, 7042, 14, 710, 3330, 7042, 355, 911, 1454, 506, 7688, 370, 4838, 282, 5023, 340, 652, 365, 355, 2808, 641, 314, 2656, 1314, 652, 1758, 2335, 14, 355, 22896, 3663, 5023, 21450, 20111, 12, 11673, 701, 355, 24476, 12, 370, 6623, 314, 16705, 315, 1314, 370, 355, 4838, 26219, 340, 2985, 10621, 1133, 2808, 641, 314, 355, 2656, 14, 710, 24874, 13225, 8142, 334, 292, 355, 4178, 921, 9019, 13, 19806, 14, 2798, 590, 14, 957, 503, 641, 13, 657, 77, 572, 9, 355, 12821, 5935, 641, 282, 1654, 12, 2382, 1454, 282, 355, 3504, 1329, 402, 26219, 787, 4903, 436, 355, 3748, 14, 5723, 2387, 298, 33, 1383, 401, 298, 13129, 475, 401, 355, 298, 35, 567, 4446, 7053, 401, 298, 36, 3977, 428, 796, 401, 12, 298, 36, 3977, 3739, 692, 401, 355, 298, 36, 3977, 428, 796, 10953, 79, 401, 298, 5761, 86, 390, 305, 7309, 401, 298, 16411, 355, 9739, 377, 52, 401, 298, 4299, 428, 796, 401, 298, 5674, 1529, 401, 298, 4189, 428, 796, 355, 653, 7691, 401, 298, 1537, 274, 3316, 401, 298, 17687, 7053, 820, 21604, 1674, 288, 1568, 199, 199, 7208, 288, 2318, 288, 1011, 958, 267, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
aceofall/zephyr-iotos
doc/scripts/extract_content.py
15
1990
#!/usr/bin/env python3 # # Copyright (c) 2017, Intel Corporation # # SPDX-License-Identifier: Apache-2.0 # Very quick script to move docs from different places into the doc directory # to fix the website and external links import os import shutil import re import sys import fnmatch # direcories to search for .rst files CONTENT_DIRS = ["samples", "boards"] # directives to parse for included files DIRECTIVES = ["figure","include","image","literalinclude"] if "ZEPHYR_BASE" not in os.environ: sys.stderr.write("$ZEPHYR_BASE environment variable undefined.\n") exit(1) ZEPHYR_BASE = os.environ["ZEPHYR_BASE"] def get_rst_files(dir): matches = [] for root, dirnames, filenames in os.walk('%s/%s' %(ZEPHYR_BASE, dir)): for filename in fnmatch.filter(filenames, '*.rst'): matches.append(os.path.join(root, filename)) for file in matches: frel = file.replace(ZEPHYR_BASE,"").strip("/") dir=os.path.dirname(frel) if not os.path.exists(os.path.join(ZEPHYR_BASE, "doc", dir)): os.makedirs(os.path.join(ZEPHYR_BASE, "doc", dir)) shutil.copyfile(file, os.path.join(ZEPHYR_BASE, "doc", frel)) with open(file, encoding="utf-8") as f: content = f.readlines() content = [x.strip() for x in content] directives = "|".join(DIRECTIVES) pattern = re.compile("\s*\.\.\s+(%s)::\s+(.*)" %directives) for l in content: m = pattern.match(l) if m: inf = m.group(2) ind = os.path.dirname(inf) if not os.path.exists(os.path.join(ZEPHYR_BASE, "doc", dir, ind)): os.makedirs(os.path.join(ZEPHYR_BASE, "doc", dir, ind)) shutil.copyfile(os.path.join(ZEPHYR_BASE, dir, inf), os.path.join(ZEPHYR_BASE, "doc", dir, inf)) f.close() def main(): for d in CONTENT_DIRS: get_rst_files(d) if __name__ == "__main__": main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 199, 3, 1898, 334, 67, 9, 9708, 12, 20619, 11098, 199, 3, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 3668, 13, 18, 14, 16, 199, 199, 3, 812, 994, 12530, 2884, 370, 4057, 9149, 687, 3365, 9825, 1901, 314, 1382, 2082, 199, 3, 370, 5325, 314, 10691, 436, 5957, 6220, 199, 199, 646, 747, 199, 646, 5145, 199, 646, 295, 199, 646, 984, 199, 646, 15951, 421, 199, 3, 487, 264, 989, 1500, 370, 2754, 367, 1275, 8332, 1584, 199, 9663, 63, 14455, 275, 2097, 3356, 401, 298, 19267, 937, 199, 199, 3, 13502, 370, 2198, 367, 5120, 1584, 199, 6098, 6882, 654, 275, 2097, 8941, 2266, 2613, 2266, 1569, 2266, 8939, 2613, 937, 199, 199, 692, 298, 3687, 9791, 3763, 63, 5825, 2, 440, 315, 747, 14, 2314, 26, 272, 984, 14, 3083, 14, 952, 21506, 3687, 9791, 3763, 63, 5825, 3734, 1750, 10942, 3134, 78, 531, 272, 4458, 8, 17, 9, 199, 3687, 9791, 3763, 63, 5825, 275, 747, 14, 2314, 905, 3687, 9791, 3763, 63, 5825, 937, 199, 199, 318, 664, 63, 8332, 63, 1725, 8, 694, 304, 272, 4450, 275, 942, 272, 367, 1738, 12, 22310, 12, 6203, 315, 747, 14, 7757, 3508, 83, 3149, 83, 7, 2818, 3687, 9791, 3763, 63, 5825, 12, 2935, 2298, 267, 367, 1788, 315, 15951, 14, 1541, 8, 10309, 12, 11937, 8332, 735, 288, 4450, 14, 740, 8, 736, 14, 515, 14, 904, 8, 1231, 12, 1788, 430, 272, 367, 570, 315, 4450, 26, 267, 289, 3369, 275, 570, 14, 1814, 8, 3687, 9791, 3763, 63, 5825, 12, 341, 680, 1913, 19031, 267, 2935, 29, 736, 14, 515, 14, 3475, 8, 70, 3369, 9, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 3687, 9791, 3763, 63, 5825, 12, 298, 1301, 401, 2935, 2298, 288, 747, 14, 8347, 8, 736, 14, 515, 14, 904, 8, 3687, 9791, 3763, 63, 5825, 12, 298, 1301, 401, 2935, 430, 398, 5145, 14, 21997, 8, 493, 12, 747, 14, 515, 14, 904, 8, 3687, 9791, 3763, 63, 5825, 12, 298, 1301, 401, 289, 3369, 430, 398, 543, 1551, 8, 493, 12, 2644, 628, 1624, 13, 24, 531, 465, 289, 26, 288, 1564, 275, 289, 14, 9684, 342, 267, 1564, 275, 359, 88, 14, 1913, 342, 367, 671, 315, 1564, 61, 267, 13502, 275, 15733, 1674, 904, 8, 6098, 6882, 654, 9, 267, 3851, 275, 295, 14, 2014, 4582, 83, 7590, 3134, 3134, 83, 11, 4042, 83, 304, 3427, 83, 15622, 2795, 2924, 450, 23216, 9, 267, 367, 634, 315, 1564, 26, 288, 333, 275, 3851, 14, 1431, 8, 76, 9, 288, 340, 333, 26, 355, 10739, 275, 333, 14, 923, 8, 18, 9, 355, 7654, 275, 747, 14, 515, 14, 3475, 8, 4904, 9, 355, 340, 440, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 3687, 9791, 3763, 63, 5825, 12, 298, 1301, 401, 2935, 12, 7654, 2298, 490, 747, 14, 8347, 8, 736, 14, 515, 14, 904, 8, 3687, 9791, 3763, 63, 5825, 12, 298, 1301, 401, 2935, 12, 7654, 430, 2234, 5145, 14, 21997, 8, 736, 14, 515, 14, 904, 8, 3687, 9791, 3763, 63, 5825, 12, 2935, 12, 10739, 395, 717, 747, 14, 515, 14, 904, 8, 3687, 9791, 3763, 63, 5825, 12, 298, 1301, 401, 2935, 12, 10739, 430, 398, 289, 14, 1600, 342, 199, 199, 318, 2446, 837, 272, 367, 366, 315, 29417, 63, 14455, 26, 267, 664, 63, 8332, 63, 1725, 8, 68, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 199, 3, 1898, 334, 67, 9, 9708, 12, 20619, 11098, 199, 3, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 3668, 13, 18, 14, 16, 199, 199, 3, 812, 994, 12530, 2884, 370, 4057, 9149, 687, 3365, 9825, 1901, 314, 1382, 2082, 199, 3, 370, 5325, 314, 10691, 436, 5957, 6220, 199, 199, 646, 747, 199, 646, 5145, 199, 646, 295, 199, 646, 984, 199, 646, 15951, 421, 199, 3, 487, 264, 989, 1500, 370, 2754, 367, 1275, 8332, 1584, 199, 9663, 63, 14455, 275, 2097, 3356, 401, 298, 19267, 937, 199, 199, 3, 13502, 370, 2198, 367, 5120, 1584, 199, 6098, 6882, 654, 275, 2097, 8941, 2266, 2613, 2266, 1569, 2266, 8939, 2613, 937, 199, 199, 692, 298, 3687, 9791, 3763, 63, 5825, 2, 440, 315, 747, 14, 2314, 26, 272, 984, 14, 3083, 14, 952, 21506, 3687, 9791, 3763, 63, 5825, 3734, 1750, 10942, 3134, 78, 531, 272, 4458, 8, 17, 9, 199, 3687, 9791, 3763, 63, 5825, 275, 747, 14, 2314, 905, 3687, 9791, 3763, 63, 5825, 937, 199, 199, 318, 664, 63, 8332, 63, 1725, 8, 694, 304, 272, 4450, 275, 942, 272, 367, 1738, 12, 22310, 12, 6203, 315, 747, 14, 7757, 3508, 83, 3149, 83, 7, 2818, 3687, 9791, 3763, 63, 5825, 12, 2935, 2298, 267, 367, 1788, 315, 15951, 14, 1541, 8, 10309, 12, 11937, 8332, 735, 288, 4450, 14, 740, 8, 736, 14, 515, 14, 904, 8, 1231, 12, 1788, 430, 272, 367, 570, 315, 4450, 26, 267, 289, 3369, 275, 570, 14, 1814, 8, 3687, 9791, 3763, 63, 5825, 12, 341, 680, 1913, 19031, 267, 2935, 29, 736, 14, 515, 14, 3475, 8, 70, 3369, 9, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 3687, 9791, 3763, 63, 5825, 12, 298, 1301, 401, 2935, 2298, 288, 747, 14, 8347, 8, 736, 14, 515, 14, 904, 8, 3687, 9791, 3763, 63, 5825, 12, 298, 1301, 401, 2935, 430, 398, 5145, 14, 21997, 8, 493, 12, 747, 14, 515, 14, 904, 8, 3687, 9791, 3763, 63, 5825, 12, 298, 1301, 401, 289, 3369, 430, 398, 543, 1551, 8, 493, 12, 2644, 628, 1624, 13, 24, 531, 465, 289, 26, 288, 1564, 275, 289, 14, 9684, 342, 267, 1564, 275, 359, 88, 14, 1913, 342, 367, 671, 315, 1564, 61, 267, 13502, 275, 15733, 1674, 904, 8, 6098, 6882, 654, 9, 267, 3851, 275, 295, 14, 2014, 4582, 83, 7590, 3134, 3134, 83, 11, 4042, 83, 304, 3427, 83, 15622, 2795, 2924, 450, 23216, 9, 267, 367, 634, 315, 1564, 26, 288, 333, 275, 3851, 14, 1431, 8, 76, 9, 288, 340, 333, 26, 355, 10739, 275, 333, 14, 923, 8, 18, 9, 355, 7654, 275, 747, 14, 515, 14, 3475, 8, 4904, 9, 355, 340, 440, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 3687, 9791, 3763, 63, 5825, 12, 298, 1301, 401, 2935, 12, 7654, 2298, 490, 747, 14, 8347, 8, 736, 14, 515, 14, 904, 8, 3687, 9791, 3763, 63, 5825, 12, 298, 1301, 401, 2935, 12, 7654, 430, 2234, 5145, 14, 21997, 8, 736, 14, 515, 14, 904, 8, 3687, 9791, 3763, 63, 5825, 12, 2935, 12, 10739, 395, 717, 747, 14, 515, 14, 904, 8, 3687, 9791, 3763, 63, 5825, 12, 298, 1301, 401, 2935, 12, 10739, 430, 398, 289, 14, 1600, 342, 199, 199, 318, 2446, 837, 272, 367, 366, 315, 29417, 63, 14455, 26, 267, 664, 63, 8332, 63, 1725, 8, 68, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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is a modulable IRC bot, built around XML configuration files. # Copyright (C) 2012 Mercier Pierre-Olivier # # 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 logging from tools.config import load_file logger = logging.getLogger("nemubot.prompt.builtins") def end(toks, context, prompt): """Quit the prompt for reload or exit""" if toks[0] == "refresh": return "refresh" elif toks[0] == "reset": return "reset" else: context.quit() return "quit" def liste(toks, context, prompt): """Show some lists""" if len(toks) > 1: for l in toks[1:]: l = l.lower() if l == "server" or l == "servers": for srv in context.servers.keys(): print (" - %s (state: %s) ;" % (srv, "connected" if context.servers[srv].connected else "disconnected")) if len(context.servers) == 0: print (" > No server loaded") elif l == "mod" or l == "mods" or l == "module" or l == "modules": for mod in context.modules.keys(): print (" - %s ;" % mod) if len(context.modules) == 0: print (" > No module loaded") elif l in prompt.HOOKS_LIST: f, d = prompt.HOOKS_LIST[l] f(d, context, prompt) else: print (" Unknown list `%s'" % l) else: print (" Please give a list to show: servers, ...") def load(toks, context, prompt): """Load an XML configuration file""" if len(toks) > 1: for filename in toks[1:]: load_file(filename, context) else: print ("Not enough arguments. `load' takes a filename.") return def select(toks, context, prompt): """Select the current server""" if (len(toks) == 2 and toks[1] != "None" and toks[1] != "nemubot" and toks[1] != "none"): if toks[1] in context.servers: prompt.selectedServer = context.servers[toks[1]] else: print ("select: server `%s' not found." % toks[1]) else: prompt.selectedServer = None return def unload(toks, context, prompt): """Unload a module""" if len(toks) == 2 and toks[1] == "all": for name in context.modules.keys(): context.unload_module(name) elif len(toks) > 1: for name in toks[1:]: if context.unload_module(name): print (" Module `%s' successfully unloaded." % name) else: print (" No module `%s' loaded, can't unload!" % name) else: print ("Not enough arguments. `unload' takes a module name.") def debug(toks, context, prompt): """Enable/Disable debug mode on a module""" if len(toks) > 1: for name in toks[1:]: if name in context.modules: context.modules[name].DEBUG = not context.modules[name].DEBUG if context.modules[name].DEBUG: print (" Module `%s' now in DEBUG mode." % name) else: print (" Debug for module module `%s' disabled." % name) else: print (" No module `%s' loaded, can't debug!" % name) else: print ("Not enough arguments. `debug' takes a module name.") # Register build-ins CAPS = { 'quit': end, # Disconnect all server and quit 'exit': end, # Alias for quit 'reset': end, # Reload the prompt 'refresh': end, # Reload the prompt but save modules 'load': load, # Load a servers or module configuration file 'unload': unload, # Unload a module and remove it from the list 'select': select, # Select a server 'list': liste, # Show lists 'debug': debug, # Pass a module in debug mode }
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 5612, 77, 456, 357, 365, 282, 3413, 348, 461, 473, 8205, 5888, 12, 6137, 6818, 4692, 2897, 1584, 14, 199, 3, 1898, 334, 35, 9, 6029, 221, 18880, 559, 281, 510, 4446, 264, 13, 47, 317, 26645, 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, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 2050, 199, 199, 504, 7249, 14, 888, 492, 2248, 63, 493, 199, 199, 2921, 275, 2050, 14, 5572, 480, 685, 77, 456, 357, 14, 7650, 14, 10372, 531, 421, 199, 318, 1284, 8, 29328, 12, 1067, 12, 8457, 304, 272, 408, 24145, 314, 8457, 367, 13101, 503, 4458, 624, 272, 340, 28415, 59, 16, 61, 508, 298, 6635, 582, 267, 372, 298, 6635, 2, 272, 916, 28415, 59, 16, 61, 508, 298, 3958, 582, 267, 372, 298, 3958, 2, 272, 587, 26, 267, 1067, 14, 10589, 342, 272, 372, 298, 10589, 2, 421, 199, 318, 1212, 1597, 8, 29328, 12, 1067, 12, 8457, 304, 272, 408, 6824, 2005, 5548, 624, 272, 340, 822, 8, 29328, 9, 690, 413, 26, 267, 367, 634, 315, 28415, 59, 17, 10688, 288, 634, 275, 634, 14, 2325, 342, 288, 340, 634, 508, 298, 1000, 2, 503, 634, 508, 298, 5871, 582, 355, 367, 20006, 315, 1067, 14, 5871, 14, 1612, 837, 490, 870, 1689, 221, 446, 450, 83, 334, 929, 26, 450, 83, 9, 8700, 2, 450, 334, 15165, 12, 9349, 298, 7113, 2, 340, 1067, 14, 5871, 59, 15165, 1055, 7113, 587, 298, 27476, 2237, 355, 340, 822, 8, 1100, 14, 5871, 9, 508, 378, 26, 490, 870, 1689, 221, 690, 3091, 1654, 6511, 531, 953, 916, 634, 508, 298, 1494, 2, 503, 634, 508, 298, 19709, 2, 503, 634, 508, 298, 578, 2, 503, 634, 508, 298, 3112, 582, 355, 367, 3413, 315, 1067, 14, 3112, 14, 1612, 837, 490, 870, 1689, 221, 446, 450, 83, 8700, 2, 450, 3413, 9, 355, 340, 822, 8, 1100, 14, 3112, 9, 508, 378, 26, 490, 870, 1689, 221, 690, 3091, 859, 6511, 531, 953, 916, 634, 315, 8457, 14, 28706, 51, 63, 4924, 26, 355, 289, 12, 366, 275, 8457, 14, 28706, 51, 63, 4924, 59, 76, 61, 355, 289, 8, 68, 12, 1067, 12, 8457, 9, 953, 587, 26, 355, 870, 1689, 221, 14831, 769, 18633, 83, 4065, 450, 634, 9, 272, 587, 26, 267, 870, 1689, 221, 7754, 8120, 282, 769, 370, 2498, 26, 8037, 12, 2263, 531, 421, 199, 318, 2248, 8, 29328, 12, 1067, 12, 8457, 304, 272, 408, 6200, 376, 4692, 2897, 570, 624, 272, 340, 822, 8, 29328, 9, 690, 413, 26, 267, 367, 1788, 315, 28415, 59, 17, 10688, 288, 2248, 63, 493, 8, 1501, 12, 1067, 9, 272, 587, 26, 267, 870, 1689, 1763, 8321, 2368, 14, 658, 912, 7, 6181, 282, 1788, 2685, 272, 372, 421, 199, 318, 3504, 8, 29328, 12, 1067, 12, 8457, 304, 272, 408, 5446, 314, 1453, 1654, 624, 272, 340, 334, 552, 8, 29328, 9, 508, 499, 436, 28415, 59, 17, 61, 1137, 298, 403, 2, 436, 267, 28415, 59, 17, 61, 1137, 298, 685, 77, 456, 357, 2, 436, 28415, 59, 17, 61, 1137, 298, 3592, 2349, 267, 340, 28415, 59, 17, 61, 315, 1067, 14, 5871, 26, 288, 8457, 14, 5511, 3120, 275, 1067, 14, 5871, 59, 29328, 59, 17, 2677, 267, 587, 26, 288, 870, 1689, 2416, 26, 1654, 18633, 83, 7, 440, 1911, 2122, 450, 28415, 59, 17, 566, 272, 587, 26, 267, 8457, 14, 5511, 3120, 275, 488, 272, 372, 421, 199, 318, 625, 912, 8, 29328, 12, 1067, 12, 8457, 304, 272, 408, 31470, 282, 859, 624, 272, 340, 822, 8, 29328, 9, 508, 499, 436, 28415, 59, 17, 61, 508, 298, 452, 582, 267, 367, 536, 315, 1067, 14, 3112, 14, 1612, 837, 288, 1067, 14, 25477, 63, 578, 8, 354, 9, 272, 916, 822, 8, 29328, 9, 690, 413, 26, 267, 367, 536, 315, 28415, 59, 17, 10688, 288, 340, 1067, 14, 25477, 63, 578, 8, 354, 304, 355, 870, 1689, 221, 5673, 18633, 83, 7, 8792, 625, 4591, 2122, 450, 536, 9, 288, 587, 26, 355, 870, 1689, 221, 3091, 859, 18633, 83, 7, 6511, 12, 883, 1133, 625, 912, 9539, 450, 536, 9, 272, 587, 26, 267, 870, 1689, 1763, 8321, 2368, 14, 658, 25477, 7, 6181, 282, 859, 536, 2685, 421, 199, 318, 3105, 8, 29328, 12, 1067, 12, 8457, 304, 272, 408, 6476, 15, 13707, 3105, 818, 641, 282, 859, 624, 272, 340, 822, 8, 29328, 9, 690, 413, 26, 267, 367, 536, 315, 28415, 59, 17, 10688, 288, 340, 536, 315, 1067, 14, 3112, 26, 355, 1067, 14, 3112, 59, 354, 1055, 5287, 275, 440, 1067, 14, 3112, 59, 354, 1055, 5287, 355, 340, 1067, 14, 3112, 59, 354, 1055, 5287, 26, 490, 870, 1689, 221, 5673, 18633, 83, 7, 3063, 315, 10990, 818, 2122, 450, 536, 9, 355, 587, 26, 490, 870, 1689, 221, 14245, 367, 859, 859, 18633, 83, 7, 6980, 2122, 450, 536, 9, 288, 587, 26, 355, 870, 1689, 221, 3091, 859, 18633, 83, 7, 6511, 12, 883, 1133, 3105, 9539, 450, 536, 9, 272, 587, 26, 267, 870, 1689, 1763, 8321, 2368, 14, 658, 1757, 7, 6181, 282, 859, 536, 2685, 421, 199, 3, 11828, 1900, 13, 3617, 199, 8549, 51 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 5612, 77, 456, 357, 365, 282, 3413, 348, 461, 473, 8205, 5888, 12, 6137, 6818, 4692, 2897, 1584, 14, 199, 3, 1898, 334, 35, 9, 6029, 221, 18880, 559, 281, 510, 4446, 264, 13, 47, 317, 26645, 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, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 2050, 199, 199, 504, 7249, 14, 888, 492, 2248, 63, 493, 199, 199, 2921, 275, 2050, 14, 5572, 480, 685, 77, 456, 357, 14, 7650, 14, 10372, 531, 421, 199, 318, 1284, 8, 29328, 12, 1067, 12, 8457, 304, 272, 408, 24145, 314, 8457, 367, 13101, 503, 4458, 624, 272, 340, 28415, 59, 16, 61, 508, 298, 6635, 582, 267, 372, 298, 6635, 2, 272, 916, 28415, 59, 16, 61, 508, 298, 3958, 582, 267, 372, 298, 3958, 2, 272, 587, 26, 267, 1067, 14, 10589, 342, 272, 372, 298, 10589, 2, 421, 199, 318, 1212, 1597, 8, 29328, 12, 1067, 12, 8457, 304, 272, 408, 6824, 2005, 5548, 624, 272, 340, 822, 8, 29328, 9, 690, 413, 26, 267, 367, 634, 315, 28415, 59, 17, 10688, 288, 634, 275, 634, 14, 2325, 342, 288, 340, 634, 508, 298, 1000, 2, 503, 634, 508, 298, 5871, 582, 355, 367, 20006, 315, 1067, 14, 5871, 14, 1612, 837, 490, 870, 1689, 221, 446, 450, 83, 334, 929, 26, 450, 83, 9, 8700, 2, 450, 334, 15165, 12, 9349, 298, 7113, 2, 340, 1067, 14, 5871, 59, 15165, 1055, 7113, 587, 298, 27476, 2237, 355, 340, 822, 8, 1100, 14, 5871, 9, 508, 378, 26, 490, 870, 1689, 221, 690, 3091, 1654, 6511, 531, 953, 916, 634, 508, 298, 1494, 2, 503, 634, 508, 298, 19709, 2, 503, 634, 508, 298, 578, 2, 503, 634, 508, 298, 3112, 582, 355, 367, 3413, 315, 1067, 14, 3112, 14, 1612, 837, 490, 870, 1689, 221, 446, 450, 83, 8700, 2, 450, 3413, 9, 355, 340, 822, 8, 1100, 14, 3112, 9, 508, 378, 26, 490, 870, 1689, 221, 690, 3091, 859, 6511, 531, 953, 916, 634, 315, 8457, 14, 28706, 51, 63, 4924, 26, 355, 289, 12, 366, 275, 8457, 14, 28706, 51, 63, 4924, 59, 76, 61, 355, 289, 8, 68, 12, 1067, 12, 8457, 9, 953, 587, 26, 355, 870, 1689, 221, 14831, 769, 18633, 83, 4065, 450, 634, 9, 272, 587, 26, 267, 870, 1689, 221, 7754, 8120, 282, 769, 370, 2498, 26, 8037, 12, 2263, 531, 421, 199, 318, 2248, 8, 29328, 12, 1067, 12, 8457, 304, 272, 408, 6200, 376, 4692, 2897, 570, 624, 272, 340, 822, 8, 29328, 9, 690, 413, 26, 267, 367, 1788, 315, 28415, 59, 17, 10688, 288, 2248, 63, 493, 8, 1501, 12, 1067, 9, 272, 587, 26, 267, 870, 1689, 1763, 8321, 2368, 14, 658, 912, 7, 6181, 282, 1788, 2685, 272, 372, 421, 199, 318, 3504, 8, 29328, 12, 1067, 12, 8457, 304, 272, 408, 5446, 314, 1453, 1654, 624, 272, 340, 334, 552, 8, 29328, 9, 508, 499, 436, 28415, 59, 17, 61, 1137, 298, 403, 2, 436, 267, 28415, 59, 17, 61, 1137, 298, 685, 77, 456, 357, 2, 436, 28415, 59, 17, 61, 1137, 298, 3592, 2349, 267, 340, 28415, 59, 17, 61, 315, 1067, 14, 5871, 26, 288, 8457, 14, 5511, 3120, 275, 1067, 14, 5871, 59, 29328, 59, 17, 2677, 267, 587, 26, 288, 870, 1689, 2416, 26, 1654, 18633, 83, 7, 440, 1911, 2122, 450, 28415, 59, 17, 566, 272, 587, 26, 267, 8457, 14, 5511, 3120, 275, 488, 272, 372, 421, 199, 318, 625, 912, 8, 29328, 12, 1067, 12, 8457, 304, 272, 408, 31470, 282, 859, 624, 272, 340, 822, 8, 29328, 9, 508, 499, 436, 28415, 59, 17, 61, 508, 298, 452, 582, 267, 367, 536, 315, 1067, 14, 3112, 14, 1612, 837, 288, 1067, 14, 25477, 63, 578, 8, 354, 9, 272, 916, 822, 8, 29328, 9, 690, 413, 26, 267, 367, 536, 315, 28415, 59, 17, 10688, 288, 340, 1067, 14, 25477, 63, 578, 8, 354, 304, 355, 870, 1689, 221, 5673, 18633, 83, 7, 8792, 625, 4591, 2122, 450, 536, 9, 288, 587, 26, 355, 870, 1689, 221, 3091, 859, 18633, 83, 7, 6511, 12, 883, 1133, 625, 912, 9539, 450, 536, 9, 272, 587, 26, 267, 870, 1689, 1763, 8321, 2368, 14, 658, 25477, 7, 6181, 282, 859, 536, 2685, 421, 199, 318, 3105, 8, 29328, 12, 1067, 12, 8457, 304, 272, 408, 6476, 15, 13707, 3105, 818, 641, 282, 859, 624, 272, 340, 822, 8, 29328, 9, 690, 413, 26, 267, 367, 536, 315, 28415, 59, 17, 10688, 288, 340, 536, 315, 1067, 14, 3112, 26, 355, 1067, 14, 3112, 59, 354, 1055, 5287, 275, 440, 1067, 14, 3112, 59, 354, 1055, 5287, 355, 340, 1067, 14, 3112, 59, 354, 1055, 5287, 26, 490, 870, 1689, 221, 5673, 18633, 83, 7, 3063, 315, 10990, 818, 2122, 450, 536, 9, 355, 587, 26, 490, 870, 1689, 221, 14245, 367, 859, 859, 18633, 83, 7, 6980, 2122, 450, 536, 9, 288, 587, 26, 355, 870, 1689, 221, 3091, 859, 18633, 83, 7, 6511, 12, 883, 1133, 3105, 9539, 450, 536, 9, 272, 587, 26, 267, 870, 1689, 1763, 8321, 2368, 14, 658, 1757, 7, 6181, 282, 859, 536, 2685, 421, 199, 3, 11828, 1900, 13, 3617, 199, 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1, 1, 1, 1, 1 ]
trulia/thoth-demo
activemq/examples/stomp/python/stomppy/publisher.py
8
1616
#!/usr/bin/env python # ------------------------------------------------------------------------ # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ------------------------------------------------------------------------ import time import sys import os import stomp user = os.getenv("ACTIVEMQ_USER") or "admin" password = os.getenv("ACTIVEMQ_PASSWORD") or "password" host = os.getenv("ACTIVEMQ_HOST") or "localhost" port = os.getenv("ACTIVEMQ_PORT") or 61613 destination = sys.argv[1:2] or ["/topic/event"] destination = destination[0] messages = 10000 data = "Hello World from Python" conn = stomp.Connection(host_and_ports = [(host, port)]) conn.start() conn.connect(login=user,passcode=password) for i in range(0, messages): conn.send(data, destination=destination, persistent='false') conn.send("SHUTDOWN", destination=destination, persistent='false') conn.disconnect()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 5620, 518, 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, 221, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 221, 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, 5620, 518, 523, 199, 646, 900, 199, 646, 984, 199, 646, 747, 199, 646, 410, 22527, 199, 199, 751, 275, 747, 14, 12959, 480, 10401, 14449, 63, 3791, 531, 503, 298, 2113, 2, 199, 2060, 275, 747, 14, 12959, 480, 10401, 14449, 63, 9032, 531, 503, 298, 2060, 2, 199, 1102, 275, 747, 14, 12959, 480, 10401, 14449, 63, 5449, 531, 503, 298, 5967, 2, 199, 719, 275, 747, 14, 12959, 480, 10401, 14449, 63, 3657, 531, 503, 1227, 975, 969, 199, 6881, 275, 984, 14, 3020, 59, 17, 26, 18, 61, 503, 2097, 15, 5746, 15, 1430, 937, 199, 6881, 275, 5724, 59, 16, 61, 199, 199, 3431, 275, 11630, 199, 576, 275, 298, 6257, 13064, 687, 2018, 2, 199, 199, 1631, 275, 410, 22527, 14, 3225, 8, 1102, 63, 460, 63, 5203, 275, 3842, 1102, 12, 1844, 3948, 199, 1631, 14, 928, 342, 199, 1631, 14, 2242, 8, 2886, 29, 751, 12, 1529, 600, 29, 2060, 9, 199, 199, 509, 284, 315, 1425, 8, 16, 12, 3788, 304, 523, 2557, 14, 2254, 8, 576, 12, 5724, 29, 6881, 12, 16149, 534, 3910, 358, 2043, 199, 1631, 14, 2254, 480, 24340, 8819, 401, 5724, 29, 6881, 12, 16149, 534, 3910, 358, 199, 199, 1631, 14, 10673, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 5620, 518, 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, 221, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 221, 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, 5620, 518, 523, 199, 646, 900, 199, 646, 984, 199, 646, 747, 199, 646, 410, 22527, 199, 199, 751, 275, 747, 14, 12959, 480, 10401, 14449, 63, 3791, 531, 503, 298, 2113, 2, 199, 2060, 275, 747, 14, 12959, 480, 10401, 14449, 63, 9032, 531, 503, 298, 2060, 2, 199, 1102, 275, 747, 14, 12959, 480, 10401, 14449, 63, 5449, 531, 503, 298, 5967, 2, 199, 719, 275, 747, 14, 12959, 480, 10401, 14449, 63, 3657, 531, 503, 1227, 975, 969, 199, 6881, 275, 984, 14, 3020, 59, 17, 26, 18, 61, 503, 2097, 15, 5746, 15, 1430, 937, 199, 6881, 275, 5724, 59, 16, 61, 199, 199, 3431, 275, 11630, 199, 576, 275, 298, 6257, 13064, 687, 2018, 2, 199, 199, 1631, 275, 410, 22527, 14, 3225, 8, 1102, 63, 460, 63, 5203, 275, 3842, 1102, 12, 1844, 3948, 199, 1631, 14, 928, 342, 199, 1631, 14, 2242, 8, 2886, 29, 751, 12, 1529, 600, 29, 2060, 9, 199, 199, 509, 284, 315, 1425, 8, 16, 12, 3788, 304, 523, 2557, 14, 2254, 8, 576, 12, 5724, 29, 6881, 12, 16149, 534, 3910, 358, 2043, 199, 1631, 14, 2254, 480, 24340, 8819, 401, 5724, 29, 6881, 12, 16149, 534, 3910, 358, 199, 199, 1631, 14, 10673, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sirpercival/kivy
kivy/core/clipboard/__init__.py
8
1731
''' 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:: >>> from kivy.core.clipboard import Clipboard >>> Clipboard.get_types() ['TIMESTAMP', 'TARGETS', 'MULTIPLE', 'SAVE_TARGETS', 'UTF8_STRING', 'COMPOUND_TEXT', 'TEXT', 'STRING', 'text/plain;charset=utf-8', 'text/plain'] >>> Clipboard.get('TEXT') 'Hello World' >>> Clipboard.put('Great', 'UTF8_STRING') >>> Clipboard.get_types() ['UTF8_STRING'] >>> Clipboard.get('UTF8_STRING') 'Great' .. note:: The main implementation relies on Pygame and works well with text/strings. Anything else might not work the same on all platforms. ''' __all__ = ('ClipboardBase', 'Clipboard') from kivy.core import core_select_lib from kivy.utils import platform class ClipboardBase(object): def get(self, mimetype): '''Get the current data in clipboard, using the mimetype if possible ''' return None def put(self, data, mimetype): '''Put data on the clipboard, and attach a mimetype ''' pass def get_types(self): '''Return a list of supported mimetypes ''' return [] # load clipboard implementation _clipboards = [] _platform = platform if _platform == 'android': _clipboards.append( ('android', 'clipboard_android', 'ClipboardAndroid')) elif _platform in ('macosx', 'linux', 'win'): _clipboards.append( ('pygame', 'clipboard_pygame', 'ClipboardPygame')) _clipboards.append( ('dummy', 'clipboard_dummy', 'ClipboardDummy')) Clipboard = core_select_lib('clipboard', _clipboards, True) del _clipboards del _platform
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, 447, 339, 1306, 687, 17227, 14, 1018, 14, 7548, 3576, 492, 445, 3587, 3576, 272, 1306, 445, 3587, 3576, 14, 362, 63, 1313, 342, 272, 788, 20277, 297, 283, 32358, 297, 283, 21894, 906, 297, 283, 19318, 63, 32358, 297, 283, 6610, 24, 63, 5353, 297, 272, 283, 11265, 1512, 6131, 63, 3876, 297, 283, 3876, 297, 283, 5353, 297, 283, 505, 15, 6104, 27, 6043, 29, 1624, 13, 24, 297, 272, 283, 505, 15, 6104, 418, 272, 1306, 445, 3587, 3576, 14, 362, 360, 3876, 358, 272, 283, 6257, 13064, 7, 272, 1306, 445, 3587, 3576, 14, 524, 360, 39, 8319, 297, 283, 6610, 24, 63, 5353, 358, 272, 1306, 445, 3587, 3576, 14, 362, 63, 1313, 342, 272, 788, 6610, 24, 63, 5353, 418, 272, 1306, 445, 3587, 3576, 14, 362, 360, 6610, 24, 63, 5353, 358, 272, 283, 39, 8319, 7, 199, 199, 703, 5317, 447, 710, 2446, 4514, 25749, 641, 1611, 5097, 436, 5419, 5521, 543, 881, 1318, 15, 5465, 14, 6184, 2127, 587, 5594, 440, 1736, 314, 2011, 641, 1006, 10677, 14, 199, 2344, 199, 199, 363, 452, 363, 275, 661, 28459, 1563, 297, 283, 28459, 358, 199, 199, 504, 17227, 14, 1018, 492, 6170, 63, 2416, 63, 773, 199, 504, 17227, 14, 1208, 492, 4298, 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, 267, 1449, 267, 372, 488, 339, 347, 5324, 8, 277, 12, 666, 12, 12200, 304, 267, 1449, 18989, 666, 641, 314, 11353, 3576, 12, 436, 6554, 282, 12200, 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, 421, 199, 3, 2248, 11353, 3576, 4514, 199, 63, 7548, 19267, 275, 942, 199, 63, 3246, 275, 4298, 199, 692, 485, 3246, 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, 485, 3246, 315, 661, 28546, 297, 283, 5135, 297, 283, 2676, 735, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 22278, 297, 283, 7548, 3576, 63, 22278, 297, 283, 28459, 2713, 5097, 1333, 199, 63, 7548, 19267, 14, 740, 8, 272, 661, 5869, 297, 283, 7548, 3576, 63, 5869, 297, 283, 28459, 11324, 1333, 199, 199, 28459, 275, 6170, 63, 2416, 63, 773, 360, 7548, 3576, 297, 485, 7548, 19267, 12, 715, 9, 199, 199, 2264, 485, 7548, 19267, 199, 2264, 485, 3246, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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, 447, 339, 1306, 687, 17227, 14, 1018, 14, 7548, 3576, 492, 445, 3587, 3576, 272, 1306, 445, 3587, 3576, 14, 362, 63, 1313, 342, 272, 788, 20277, 297, 283, 32358, 297, 283, 21894, 906, 297, 283, 19318, 63, 32358, 297, 283, 6610, 24, 63, 5353, 297, 272, 283, 11265, 1512, 6131, 63, 3876, 297, 283, 3876, 297, 283, 5353, 297, 283, 505, 15, 6104, 27, 6043, 29, 1624, 13, 24, 297, 272, 283, 505, 15, 6104, 418, 272, 1306, 445, 3587, 3576, 14, 362, 360, 3876, 358, 272, 283, 6257, 13064, 7, 272, 1306, 445, 3587, 3576, 14, 524, 360, 39, 8319, 297, 283, 6610, 24, 63, 5353, 358, 272, 1306, 445, 3587, 3576, 14, 362, 63, 1313, 342, 272, 788, 6610, 24, 63, 5353, 418, 272, 1306, 445, 3587, 3576, 14, 362, 360, 6610, 24, 63, 5353, 358, 272, 283, 39, 8319, 7, 199, 199, 703, 5317, 447, 710, 2446, 4514, 25749, 641, 1611, 5097, 436, 5419, 5521, 543, 881, 1318, 15, 5465, 14, 6184, 2127, 587, 5594, 440, 1736, 314, 2011, 641, 1006, 10677, 14, 199, 2344, 199, 199, 363, 452, 363, 275, 661, 28459, 1563, 297, 283, 28459, 358, 199, 199, 504, 17227, 14, 1018, 492, 6170, 63, 2416, 63, 773, 199, 504, 17227, 14, 1208, 492, 4298, 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, 267, 1449, 267, 372, 488, 339, 347, 5324, 8, 277, 12, 666, 12, 12200, 304, 267, 1449, 18989, 666, 641, 314, 11353, 3576, 12, 436, 6554, 282, 12200, 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, 421, 199, 3, 2248, 11353, 3576, 4514, 199, 63, 7548, 19267, 275, 942, 199, 63, 3246, 275, 4298, 199, 692, 485, 3246, 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, 485, 3246, 315, 661, 28546, 297, 283, 5135, 297, 283, 2676, 735, 272, 485, 7548, 19267, 14, 740, 8, 267, 661, 22278, 297, 283, 7548, 3576, 63, 22278, 297, 283, 28459, 2713, 5097, 1333, 199, 63, 7548, 19267, 14, 740, 8, 272, 661, 5869, 297, 283, 7548, 3576, 63, 5869, 297, 283, 28459, 11324, 1333, 199, 199, 28459, 275, 6170, 63, 2416, 63, 773, 360, 7548, 3576, 297, 485, 7548, 19267, 12, 715, 9, 199, 199, 2264, 485, 7548, 19267, 199, 2264, 485, 3246, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
SDSG-Invenio/invenio
invenio/modules/upgrader/upgrades/invenio_release_1_2_0.py
23
1274
# -*- coding: utf-8 -*- # # This file is part of Invenio. # Copyright (C) 2015 CERN. # # Invenio 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. # # Invenio 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 Invenio; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. """Invenio v1.2.0.""" depends_on = ['invenio_2015_03_03_tag_value'] def info(): """Return upgrade recipe information.""" return "Invenio v1.2.0" def do_upgrade(): """Carry out the upgrade.""" pass def estimate(): """Estimate running time of upgrade in seconds (optional).""" return 1 def pre_upgrade(): """Pre-upgrade checks.""" pass def post_upgrade(): """Post-upgrade checks.""" print "NOTE: Please run `webcoll -u admin -f` to apply new changes."
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 12235, 14, 199, 3, 1898, 334, 35, 9, 6900, 24354, 14, 199, 3, 199, 3, 12235, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 12235, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 12235, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 624, 607, 7597, 373, 17, 14, 18, 14, 16, 1041, 199, 199, 8912, 63, 265, 275, 788, 30628, 63, 7806, 63, 1644, 63, 1644, 63, 1450, 63, 585, 418, 421, 199, 318, 2256, 837, 272, 408, 1767, 10754, 17121, 2556, 1041, 272, 372, 298, 607, 7597, 373, 17, 14, 18, 14, 16, 2, 421, 199, 318, 886, 63, 9375, 837, 272, 408, 16034, 651, 734, 314, 10754, 1041, 272, 986, 421, 199, 318, 14497, 837, 272, 408, 31020, 3879, 900, 402, 10754, 315, 4696, 334, 4144, 10477, 272, 372, 413, 421, 199, 318, 876, 63, 9375, 837, 272, 408, 2398, 13, 9375, 5920, 1041, 272, 986, 421, 199, 318, 2963, 63, 9375, 837, 272, 408, 6564, 13, 9375, 5920, 1041, 272, 870, 298, 19855, 26, 7754, 1255, 658, 2520, 15772, 446, 85, 4628, 446, 70, 64, 370, 4838, 892, 4493, 2122, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 12235, 14, 199, 3, 1898, 334, 35, 9, 6900, 24354, 14, 199, 3, 199, 3, 12235, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 12235, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 12235, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 624, 607, 7597, 373, 17, 14, 18, 14, 16, 1041, 199, 199, 8912, 63, 265, 275, 788, 30628, 63, 7806, 63, 1644, 63, 1644, 63, 1450, 63, 585, 418, 421, 199, 318, 2256, 837, 272, 408, 1767, 10754, 17121, 2556, 1041, 272, 372, 298, 607, 7597, 373, 17, 14, 18, 14, 16, 2, 421, 199, 318, 886, 63, 9375, 837, 272, 408, 16034, 651, 734, 314, 10754, 1041, 272, 986, 421, 199, 318, 14497, 837, 272, 408, 31020, 3879, 900, 402, 10754, 315, 4696, 334, 4144, 10477, 272, 372, 413, 421, 199, 318, 876, 63, 9375, 837, 272, 408, 2398, 13, 9375, 5920, 1041, 272, 986, 421, 199, 318, 2963, 63, 9375, 837, 272, 408, 6564, 13, 9375, 5920, 1041, 272, 870, 298, 19855, 26, 7754, 1255, 658, 2520, 15772, 446, 85, 4628, 446, 70, 64, 370, 4838, 892, 4493, 2122, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
chauhanhardik/populo
lms/lib/comment_client/thread.py
58
8410
import logging from eventtracking import tracker from .utils import merge_dict, strip_blank, strip_none, extract, perform_request from .utils import CommentClientRequestError import models import settings log = logging.getLogger(__name__) class Thread(models.Model): # accessible_fields can be set and retrieved on the model accessible_fields = [ 'id', 'title', 'body', 'anonymous', 'anonymous_to_peers', 'course_id', 'closed', 'tags', 'votes', 'commentable_id', 'username', 'user_id', 'created_at', 'updated_at', 'comments_count', 'unread_comments_count', 'at_position_list', 'children', 'type', 'highlighted_title', 'highlighted_body', 'endorsed', 'read', 'group_id', 'group_name', 'pinned', 'abuse_flaggers', 'resp_skip', 'resp_limit', 'resp_total', 'thread_type', 'endorsed_responses', 'non_endorsed_responses', 'non_endorsed_resp_total', 'context', ] # updateable_fields are sent in PUT requests updatable_fields = [ 'title', 'body', 'anonymous', 'anonymous_to_peers', 'course_id', 'closed', 'user_id', 'commentable_id', 'group_id', 'group_name', 'pinned', 'thread_type' ] # metric_tag_fields are used by Datadog to record metrics about the model metric_tag_fields = [ 'course_id', 'group_id', 'pinned', 'closed', 'anonymous', 'anonymous_to_peers', 'endorsed', 'read' ] # initializable_fields are sent in POST requests initializable_fields = updatable_fields + ['thread_type', 'context'] base_url = "{prefix}/threads".format(prefix=settings.PREFIX) default_retrieve_params = {'recursive': False} type = 'thread' @classmethod def search(cls, query_params): default_params = {'page': 1, 'per_page': 20, 'course_id': query_params['course_id'], 'recursive': False} params = merge_dict(default_params, strip_blank(strip_none(query_params))) if query_params.get('text'): url = cls.url(action='search') else: url = cls.url(action='get_all', params=extract(params, 'commentable_id')) if params.get('commentable_id'): del params['commentable_id'] response = perform_request( 'get', url, params, metric_tags=[u'course_id:{}'.format(query_params['course_id'])], metric_action='thread.search', paged_results=True ) if query_params.get('text'): search_query = query_params['text'] course_id = query_params['course_id'] group_id = query_params['group_id'] if 'group_id' in query_params else None requested_page = params['page'] total_results = response.get('total_results') corrected_text = response.get('corrected_text') # Record search result metric to allow search quality analysis. # course_id is already included in the context for the event tracker tracker.emit( 'edx.forum.searched', { 'query': search_query, 'corrected_text': corrected_text, 'group_id': group_id, 'page': requested_page, 'total_results': total_results, } ) log.info( u'forum_text_search query="{search_query}" corrected_text="{corrected_text}" course_id={course_id} group_id={group_id} page={requested_page} total_results={total_results}'.format( search_query=search_query, corrected_text=corrected_text, course_id=course_id, group_id=group_id, requested_page=requested_page, total_results=total_results ) ) return response.get('collection', []), response.get('page', 1), response.get('num_pages', 1), response.get('corrected_text') @classmethod def url_for_threads(cls, params={}): if params.get('commentable_id'): return u"{prefix}/{commentable_id}/threads".format(prefix=settings.PREFIX, commentable_id=params['commentable_id']) else: return u"{prefix}/threads".format(prefix=settings.PREFIX) @classmethod def url_for_search_threads(cls, params={}): return "{prefix}/search/threads".format(prefix=settings.PREFIX) @classmethod def url(cls, action, params={}): if action in ['get_all', 'post']: return cls.url_for_threads(params) elif action == 'search': return cls.url_for_search_threads(params) else: return super(Thread, cls).url(action, params) # TODO: This is currently overriding Model._retrieve only to add parameters # for the request. Model._retrieve should be modified to handle this such # that subclasses don't need to override for this. def _retrieve(self, *args, **kwargs): url = self.url(action='get', params=self.attributes) request_params = { 'recursive': kwargs.get('recursive'), 'user_id': kwargs.get('user_id'), 'mark_as_read': kwargs.get('mark_as_read', True), 'resp_skip': kwargs.get('response_skip'), 'resp_limit': kwargs.get('response_limit'), } request_params = strip_none(request_params) response = perform_request( 'get', url, request_params, metric_action='model.retrieve', metric_tags=self._metric_tags ) self._update_from_response(response) def flagAbuse(self, user, voteable): if voteable.type == 'thread': url = _url_for_flag_abuse_thread(voteable.id) elif voteable.type == 'comment': url = _url_for_flag_comment(voteable.id) else: raise CommentClientRequestError("Can only flag/unflag threads or comments") params = {'user_id': user.id} response = perform_request( 'put', url, params, metric_action='thread.abuse.flagged', metric_tags=self._metric_tags ) voteable._update_from_response(response) def unFlagAbuse(self, user, voteable, removeAll): if voteable.type == 'thread': url = _url_for_unflag_abuse_thread(voteable.id) elif voteable.type == 'comment': url = _url_for_unflag_comment(voteable.id) else: raise CommentClientRequestError("Can only flag/unflag for threads or comments") params = {'user_id': user.id} #if you're an admin, when you unflag, remove ALL flags if removeAll: params['all'] = True response = perform_request( 'put', url, params, metric_tags=self._metric_tags, metric_action='thread.abuse.unflagged' ) voteable._update_from_response(response) def pin(self, user, thread_id): url = _url_for_pin_thread(thread_id) params = {'user_id': user.id} response = perform_request( 'put', url, params, metric_tags=self._metric_tags, metric_action='thread.pin' ) self._update_from_response(response) def un_pin(self, user, thread_id): url = _url_for_un_pin_thread(thread_id) params = {'user_id': user.id} response = perform_request( 'put', url, params, metric_tags=self._metric_tags, metric_action='thread.unpin' ) self._update_from_response(response) def _url_for_flag_abuse_thread(thread_id): return "{prefix}/threads/{thread_id}/abuse_flag".format(prefix=settings.PREFIX, thread_id=thread_id) def _url_for_unflag_abuse_thread(thread_id): return "{prefix}/threads/{thread_id}/abuse_unflag".format(prefix=settings.PREFIX, thread_id=thread_id) def _url_for_pin_thread(thread_id): return "{prefix}/threads/{thread_id}/pin".format(prefix=settings.PREFIX, thread_id=thread_id) def _url_for_un_pin_thread(thread_id): return "{prefix}/threads/{thread_id}/unpin".format(prefix=settings.PREFIX, thread_id=thread_id)
agpl-3.0
[ 646, 2050, 199, 199, 504, 1566, 14428, 492, 15271, 199, 504, 1275, 1208, 492, 5389, 63, 807, 12, 6202, 63, 2500, 12, 6202, 63, 3592, 12, 5536, 12, 5147, 63, 1069, 199, 504, 1275, 1208, 492, 6819, 3041, 19261, 199, 646, 1709, 199, 646, 2202, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 11086, 8, 992, 14, 1685, 304, 339, 327, 17909, 63, 955, 883, 506, 663, 436, 12396, 641, 314, 1402, 272, 17909, 63, 955, 275, 359, 267, 283, 344, 297, 283, 1213, 297, 283, 2030, 297, 283, 12628, 297, 283, 12628, 63, 475, 63, 22416, 297, 283, 1972, 63, 344, 297, 267, 283, 5938, 297, 283, 2969, 297, 283, 16660, 297, 283, 3349, 461, 63, 344, 297, 283, 2473, 297, 283, 751, 63, 344, 297, 267, 283, 3966, 63, 292, 297, 283, 5334, 63, 292, 297, 283, 6223, 63, 835, 297, 283, 28677, 63, 6223, 63, 835, 297, 267, 283, 292, 63, 3124, 63, 513, 297, 283, 3223, 297, 283, 466, 297, 283, 6260, 27883, 63, 1213, 297, 267, 283, 6260, 27883, 63, 2030, 297, 283, 7454, 939, 297, 283, 739, 297, 283, 923, 63, 344, 297, 283, 923, 63, 354, 297, 283, 7751, 7439, 297, 267, 283, 371, 1180, 63, 4173, 31988, 297, 283, 4518, 63, 2759, 297, 283, 4518, 63, 3097, 297, 283, 4518, 63, 2923, 297, 283, 2671, 63, 466, 297, 267, 283, 7454, 939, 63, 10360, 297, 283, 2865, 63, 7454, 939, 63, 10360, 297, 283, 2865, 63, 7454, 939, 63, 4518, 63, 2923, 297, 267, 283, 1100, 297, 272, 1622, 339, 327, 1678, 461, 63, 955, 787, 4847, 315, 18337, 4145, 272, 1536, 4616, 461, 63, 955, 275, 359, 267, 283, 1213, 297, 283, 2030, 297, 283, 12628, 297, 283, 12628, 63, 475, 63, 22416, 297, 283, 1972, 63, 344, 297, 267, 283, 5938, 297, 283, 751, 63, 344, 297, 283, 3349, 461, 63, 344, 297, 283, 923, 63, 344, 297, 283, 923, 63, 354, 297, 283, 7751, 7439, 297, 283, 2671, 63, 466, 7, 272, 1622, 339, 327, 6370, 63, 1450, 63, 955, 787, 1202, 701, 577, 292, 30821, 370, 2777, 7186, 3595, 314, 1402, 272, 6370, 63, 1450, 63, 955, 275, 359, 267, 283, 1972, 63, 344, 297, 283, 923, 63, 344, 297, 283, 7751, 7439, 297, 283, 5938, 297, 283, 12628, 297, 283, 12628, 63, 475, 63, 22416, 297, 267, 283, 7454, 939, 297, 283, 739, 7, 272, 1622, 339, 327, 2536, 14065, 63, 955, 787, 4847, 315, 8761, 4145, 272, 2536, 14065, 63, 955, 275, 1536, 4616, 461, 63, 955, 435, 788, 2671, 63, 466, 297, 283, 1100, 418, 339, 1300, 63, 633, 275, 5310, 1861, 5995, 6962, 1674, 908, 8, 1861, 29, 1751, 14, 6351, 9, 272, 849, 63, 14270, 63, 1162, 275, 791, 9931, 356, 756, 93, 272, 730, 275, 283, 2671, 7, 339, 768, 3744, 272, 347, 2754, 8, 1886, 12, 1827, 63, 1162, 304, 398, 849, 63, 1162, 275, 791, 1606, 356, 413, 12, 2079, 283, 529, 63, 1606, 356, 3388, 12, 2079, 283, 1972, 63, 344, 356, 1827, 63, 1162, 459, 1972, 63, 344, 995, 2079, 283, 9931, 356, 756, 93, 267, 1862, 275, 5389, 63, 807, 8, 885, 63, 1162, 12, 6202, 63, 2500, 8, 1913, 63, 3592, 8, 1131, 63, 1162, 1724, 398, 340, 1827, 63, 1162, 14, 362, 360, 505, 735, 288, 1166, 275, 843, 14, 633, 8, 1287, 534, 1733, 358, 267, 587, 26, 288, 1166, 275, 843, 14, 633, 8, 1287, 534, 362, 63, 452, 297, 1862, 29, 5005, 8, 1162, 12, 283, 3349, 461, 63, 344, 1333, 288, 340, 1862, 14, 362, 360, 3349, 461, 63, 344, 735, 355, 2150, 1862, 459, 3349, 461, 63, 344, 418, 267, 1177, 275, 5147, 63, 1069, 8, 288, 283, 362, 297, 288, 1166, 12, 288, 1862, 12, 288, 6370, 63, 2969, 1524, 85, 7, 1972, 63, 344, 26, 11123, 908, 8, 1131, 63, 1162, 459, 1972, 63, 344, 1105, 467, 288, 6370, 63, 1287, 534, 2671, 14, 1733, 297, 288, 2034, 68, 63, 2604, 29, 549, 267, 776, 267, 340, 1827, 63, 1162, 14, 362, 360, 505, 735, 288, 2754, 63, 1131, 275, 1827, 63, 1162, 459, 505, 418, 288, 2518, 63, 344, 275, 1827, 63, 1162, 459, 1972, 63, 344, 418, 288, 1572, 63, 344, 275, 1827, 63, 1162, 459, 923, 63, 344, 418, 340, 283, 923, 63, 344, 7, 315, 1827, 63, 1162, 587, 488, 288, 5839, 63, 1606, 275, 1862, 459, 1606, 418, 288, 3141, 63, 2604, 275, 1177, 14, 362, 360, 2923, 63, 2604, 358, 288, 30156, 63, 505, 275, 1177, 14, 362, 360, 28125, 63, 505, 358, 288, 327, 12651, 2754, 754, 6370, 370, 2040, 2754, 11030, 11284, 14, 288, 327, 2518, 63, 344, 365, 2575, 5120, 315, 314, 1067, 367, 314, 1566, 15271, 288, 15271, 14, 8159, 8, 355, 283, 8268, 14, 10044, 14, 1733, 379, 297, 355, 469, 490, 283, 1131, 356, 2754, 63, 1131, 12, 490, 283, 28125, 63, 505, 356, 30156, 63, 505, 12, 490, 283, 923, 63, 344, 356, 1572, 63, 344, 12, 490, 283, 1606, 356, 5839, 63, 1606, 12, 490, 283, 2923, 63, 2604, 356, 3141, 63, 2604, 12, 355, 789, 288, 776, 288, 943, 14, 815, 8, 355, 399, 7, 10044, 63, 505, 63, 1733, 1827, 18448, 1733, 63, 1131, 7063, 30156, 63, 505, 18448, 28125, 63, 505, 7063, 2518, 63, 344, 3126, 1972, 63, 344, 93, 1572, 63, 344, 3126, 923, 63, 344, 93, 2034, 3126, 11151, 63, 1606, 93, 3141, 63, 2604, 3126, 2923, 63, 2604, 5285, 908, 8, 490, 2754, 63, 1131, 29, 1733, 63, 1131, 12, 490, 30156, 63, 505, 29, 28125, 63, 505, 12, 490, 2518, 63, 344, 29, 1972, 63, 344, 12, 490, 1572, 63, 344, 29, 923, 63, 344, 12, 490, 5839, 63, 1606, 29, 11151, 63, 1606, 12, 490, 3141, 63, 2604, 29, 2923, 63, 2604, 355, 776, 288, 776, 267, 372, 1177, 14, 362, 360, 3627, 297, 14431, 1177, 14, 362, 360, 1606, 297, 413, 395, 1177, 14, 362, 360, 1507, 63, 5856, 297, 413, 395, 1177, 14, 362, 360, 28125, 63, 505, 358, 339, 768, 3744, 272, 347, 1166, 63, 509, 63, 6962, 8, 1886, 12, 1862 ]
[ 2050, 199, 199, 504, 1566, 14428, 492, 15271, 199, 504, 1275, 1208, 492, 5389, 63, 807, 12, 6202, 63, 2500, 12, 6202, 63, 3592, 12, 5536, 12, 5147, 63, 1069, 199, 504, 1275, 1208, 492, 6819, 3041, 19261, 199, 646, 1709, 199, 646, 2202, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 11086, 8, 992, 14, 1685, 304, 339, 327, 17909, 63, 955, 883, 506, 663, 436, 12396, 641, 314, 1402, 272, 17909, 63, 955, 275, 359, 267, 283, 344, 297, 283, 1213, 297, 283, 2030, 297, 283, 12628, 297, 283, 12628, 63, 475, 63, 22416, 297, 283, 1972, 63, 344, 297, 267, 283, 5938, 297, 283, 2969, 297, 283, 16660, 297, 283, 3349, 461, 63, 344, 297, 283, 2473, 297, 283, 751, 63, 344, 297, 267, 283, 3966, 63, 292, 297, 283, 5334, 63, 292, 297, 283, 6223, 63, 835, 297, 283, 28677, 63, 6223, 63, 835, 297, 267, 283, 292, 63, 3124, 63, 513, 297, 283, 3223, 297, 283, 466, 297, 283, 6260, 27883, 63, 1213, 297, 267, 283, 6260, 27883, 63, 2030, 297, 283, 7454, 939, 297, 283, 739, 297, 283, 923, 63, 344, 297, 283, 923, 63, 354, 297, 283, 7751, 7439, 297, 267, 283, 371, 1180, 63, 4173, 31988, 297, 283, 4518, 63, 2759, 297, 283, 4518, 63, 3097, 297, 283, 4518, 63, 2923, 297, 283, 2671, 63, 466, 297, 267, 283, 7454, 939, 63, 10360, 297, 283, 2865, 63, 7454, 939, 63, 10360, 297, 283, 2865, 63, 7454, 939, 63, 4518, 63, 2923, 297, 267, 283, 1100, 297, 272, 1622, 339, 327, 1678, 461, 63, 955, 787, 4847, 315, 18337, 4145, 272, 1536, 4616, 461, 63, 955, 275, 359, 267, 283, 1213, 297, 283, 2030, 297, 283, 12628, 297, 283, 12628, 63, 475, 63, 22416, 297, 283, 1972, 63, 344, 297, 267, 283, 5938, 297, 283, 751, 63, 344, 297, 283, 3349, 461, 63, 344, 297, 283, 923, 63, 344, 297, 283, 923, 63, 354, 297, 283, 7751, 7439, 297, 283, 2671, 63, 466, 7, 272, 1622, 339, 327, 6370, 63, 1450, 63, 955, 787, 1202, 701, 577, 292, 30821, 370, 2777, 7186, 3595, 314, 1402, 272, 6370, 63, 1450, 63, 955, 275, 359, 267, 283, 1972, 63, 344, 297, 283, 923, 63, 344, 297, 283, 7751, 7439, 297, 283, 5938, 297, 283, 12628, 297, 283, 12628, 63, 475, 63, 22416, 297, 267, 283, 7454, 939, 297, 283, 739, 7, 272, 1622, 339, 327, 2536, 14065, 63, 955, 787, 4847, 315, 8761, 4145, 272, 2536, 14065, 63, 955, 275, 1536, 4616, 461, 63, 955, 435, 788, 2671, 63, 466, 297, 283, 1100, 418, 339, 1300, 63, 633, 275, 5310, 1861, 5995, 6962, 1674, 908, 8, 1861, 29, 1751, 14, 6351, 9, 272, 849, 63, 14270, 63, 1162, 275, 791, 9931, 356, 756, 93, 272, 730, 275, 283, 2671, 7, 339, 768, 3744, 272, 347, 2754, 8, 1886, 12, 1827, 63, 1162, 304, 398, 849, 63, 1162, 275, 791, 1606, 356, 413, 12, 2079, 283, 529, 63, 1606, 356, 3388, 12, 2079, 283, 1972, 63, 344, 356, 1827, 63, 1162, 459, 1972, 63, 344, 995, 2079, 283, 9931, 356, 756, 93, 267, 1862, 275, 5389, 63, 807, 8, 885, 63, 1162, 12, 6202, 63, 2500, 8, 1913, 63, 3592, 8, 1131, 63, 1162, 1724, 398, 340, 1827, 63, 1162, 14, 362, 360, 505, 735, 288, 1166, 275, 843, 14, 633, 8, 1287, 534, 1733, 358, 267, 587, 26, 288, 1166, 275, 843, 14, 633, 8, 1287, 534, 362, 63, 452, 297, 1862, 29, 5005, 8, 1162, 12, 283, 3349, 461, 63, 344, 1333, 288, 340, 1862, 14, 362, 360, 3349, 461, 63, 344, 735, 355, 2150, 1862, 459, 3349, 461, 63, 344, 418, 267, 1177, 275, 5147, 63, 1069, 8, 288, 283, 362, 297, 288, 1166, 12, 288, 1862, 12, 288, 6370, 63, 2969, 1524, 85, 7, 1972, 63, 344, 26, 11123, 908, 8, 1131, 63, 1162, 459, 1972, 63, 344, 1105, 467, 288, 6370, 63, 1287, 534, 2671, 14, 1733, 297, 288, 2034, 68, 63, 2604, 29, 549, 267, 776, 267, 340, 1827, 63, 1162, 14, 362, 360, 505, 735, 288, 2754, 63, 1131, 275, 1827, 63, 1162, 459, 505, 418, 288, 2518, 63, 344, 275, 1827, 63, 1162, 459, 1972, 63, 344, 418, 288, 1572, 63, 344, 275, 1827, 63, 1162, 459, 923, 63, 344, 418, 340, 283, 923, 63, 344, 7, 315, 1827, 63, 1162, 587, 488, 288, 5839, 63, 1606, 275, 1862, 459, 1606, 418, 288, 3141, 63, 2604, 275, 1177, 14, 362, 360, 2923, 63, 2604, 358, 288, 30156, 63, 505, 275, 1177, 14, 362, 360, 28125, 63, 505, 358, 288, 327, 12651, 2754, 754, 6370, 370, 2040, 2754, 11030, 11284, 14, 288, 327, 2518, 63, 344, 365, 2575, 5120, 315, 314, 1067, 367, 314, 1566, 15271, 288, 15271, 14, 8159, 8, 355, 283, 8268, 14, 10044, 14, 1733, 379, 297, 355, 469, 490, 283, 1131, 356, 2754, 63, 1131, 12, 490, 283, 28125, 63, 505, 356, 30156, 63, 505, 12, 490, 283, 923, 63, 344, 356, 1572, 63, 344, 12, 490, 283, 1606, 356, 5839, 63, 1606, 12, 490, 283, 2923, 63, 2604, 356, 3141, 63, 2604, 12, 355, 789, 288, 776, 288, 943, 14, 815, 8, 355, 399, 7, 10044, 63, 505, 63, 1733, 1827, 18448, 1733, 63, 1131, 7063, 30156, 63, 505, 18448, 28125, 63, 505, 7063, 2518, 63, 344, 3126, 1972, 63, 344, 93, 1572, 63, 344, 3126, 923, 63, 344, 93, 2034, 3126, 11151, 63, 1606, 93, 3141, 63, 2604, 3126, 2923, 63, 2604, 5285, 908, 8, 490, 2754, 63, 1131, 29, 1733, 63, 1131, 12, 490, 30156, 63, 505, 29, 28125, 63, 505, 12, 490, 2518, 63, 344, 29, 1972, 63, 344, 12, 490, 1572, 63, 344, 29, 923, 63, 344, 12, 490, 5839, 63, 1606, 29, 11151, 63, 1606, 12, 490, 3141, 63, 2604, 29, 2923, 63, 2604, 355, 776, 288, 776, 267, 372, 1177, 14, 362, 360, 3627, 297, 14431, 1177, 14, 362, 360, 1606, 297, 413, 395, 1177, 14, 362, 360, 1507, 63, 5856, 297, 413, 395, 1177, 14, 362, 360, 28125, 63, 505, 358, 339, 768, 3744, 272, 347, 1166, 63, 509, 63, 6962, 8, 1886, 12, 1862, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
QianBIG/odoo
addons/marketing_campaign/__init__.py
380
1087
# -*- 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 marketing_campaign 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, 199, 646, 2216, 13800, 63, 17368, 199, 646, 3622, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 2216, 13800, 63, 17368, 199, 646, 3622, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
Martin456/eve
eve/methods/post.py
2
11303
# -*- coding: utf-8 -*- """ eve.methods.post ~~~~~~~~~~~~~~~~ This module implements the POST method, supported by the resources endpoints. :copyright: (c) 2017 by Nicola Iarocci. :license: BSD, see LICENSE for more details. """ from datetime import datetime from flask import current_app as app, abort from eve.utils import config, parse_request, debug_error_message from eve.auth import requires_auth from eve.validation import DocumentError from eve.methods.common import parse, payload, ratelimit, \ pre_event, store_media_files, resolve_user_restricted_access, \ resolve_embedded_fields, build_response_document, marshal_write_response, \ resolve_sub_resource_path, resolve_document_etag, oplog_push, resource_link from eve.versioning import resolve_document_version, \ insert_versioning_documents @ratelimit() @requires_auth('resource') @pre_event def post(resource, payl=None): """ Default function for handling POST requests, it has decorators for rate limiting, authentication and for raising pre-request events. After the decorators are applied forwards to call to :func:`post_internal` .. versionchanged:: 0.5 Split original post() into post/post_internal combo. """ return post_internal(resource, payl, skip_validation=False) def post_internal(resource, payl=None, skip_validation=False): """ Intended for internal post calls, this method is not rate limited, authentication is not checked and pre-request events are not raised. Adds one or more documents to a resource. Each document is validated against the domain schema. If validation passes the document is inserted and ID_FIELD, LAST_UPDATED and DATE_CREATED along with a link to the document are returned. If validation fails, a list of validation issues is returned. :param resource: name of the resource involved. :param payl: alternative payload. When calling post() from your own code you can provide an alternative payload. This can be useful, for example, when you have a callback function hooked to a certain endpoint, and want to perform additional post() calls from there. Please be advised that in order to successfully use this option, a request context must be available. See https://github.com/pyeve/eve/issues/74 for a discussion, and a typical use case. :param skip_validation: skip payload validation before write (bool) .. versionchanged:: 0.7 Add support for Location header. Closes #795. .. versionchanged:: 0.6 Fix: since v0.6, skip_validation = True causes a 422 response (#726). .. versionchanged:: 0.6 Initialize DELETED field when soft_delete is enabled. .. versionchanged:: 0.5 Back to resolving default values after validation as now the validator can properly validate dependency even when some have default values. See #353. Push updates to the OpLog. Original post() has been split into post() and post_internal(). ETAGS are now stored with documents (#369). .. versionchanged:: 0.4 Resolve default values before validation is performed. See #353. Support for document versioning. .. versionchanged:: 0.3 Return 201 if at least one document has been successfully inserted. Fix #231 auth field not set if resource level authentication is set. Support for media fields. When IF_MATCH is disabled, no etag is included in the payload. Support for new validation format introduced with Cerberus v0.5. .. versionchanged:: 0.2 Use the new STATUS setting. Use the new ISSUES setting. Raise 'on_pre_<method>' event. Explicitly resolve default values instead of letting them be resolved by common.parse. This avoids a validation error when a read-only field also has a default value. Added ``on_inserted*`` events after the database insert .. versionchanged:: 0.1.1 auth.request_auth_value is now used to store the auth_field value. .. versionchanged:: 0.1.0 More robust handling of auth_field. Support for optional HATEOAS. .. versionchanged: 0.0.9 Event hooks renamed to be more robust and consistent: 'on_posting' renamed to 'on_insert'. You can now pass a pre-defined custom payload to the funcion. .. versionchanged:: 0.0.9 Storing self.app.auth.userid in auth_field when 'user-restricted resource access' is enabled. .. versionchanged: 0.0.7 Support for Rate-Limiting. Support for 'extra_response_fields'. 'on_posting' and 'on_posting_<resource>' events are raised before the documents are inserted into the database. This allows callback functions to arbitrarily edit/update the documents being stored. .. versionchanged:: 0.0.6 Support for bulk inserts. Please note: validation constraints are checked against the database, and not between the payload documents themselves. This causes an interesting corner case: in the event of a multiple documents payload where two or more documents carry the same value for a field where the 'unique' constraint is set, the payload will validate successfully, as there are no duplicates in the database (yet). If this is an issue, the client can always send the documents once at a time for insertion, or validate locally before submitting the payload to the API. .. versionchanged:: 0.0.5 Support for 'application/json' Content-Type . Support for 'user-restricted resource access'. .. versionchanged:: 0.0.4 Added the ``requires_auth`` decorator. .. versionchanged:: 0.0.3 JSON links. Superflous ``response`` container removed. """ date_utc = datetime.utcnow().replace(microsecond=0) resource_def = app.config['DOMAIN'][resource] schema = resource_def['schema'] validator = None if skip_validation \ else app.validator(schema, resource=resource) documents = [] results = [] failures = 0 id_field = resource_def['id_field'] if config.BANDWIDTH_SAVER is True: embedded_fields = [] else: req = parse_request(resource) embedded_fields = resolve_embedded_fields(resource, req) # validation, and additional fields if payl is None: payl = payload() if isinstance(payl, dict): payl = [payl] if not payl: # empty bulk insert abort(400, description=debug_error_message( 'Empty bulk insert' )) if len(payl) > 1 and not config.DOMAIN[resource]['bulk_enabled']: abort(400, description=debug_error_message( 'Bulk insert not allowed' )) for value in payl: document = [] doc_issues = {} try: document = parse(value, resource) resolve_sub_resource_path(document, resource) if skip_validation: validation = True else: validation = validator.validate(document) if validation: # validation is successful # validator might be not available if skip_validation. #726. if validator: # Apply coerced values document = validator.document # Populate meta and default fields document[config.LAST_UPDATED] = \ document[config.DATE_CREATED] = date_utc if config.DOMAIN[resource]['soft_delete'] is True: document[config.DELETED] = False resolve_user_restricted_access(document, resource) store_media_files(document, resource) resolve_document_version(document, resource, 'POST') else: # validation errors added to list of document issues doc_issues = validator.errors except DocumentError as e: doc_issues['validation exception'] = str(e) except Exception as e: # most likely a problem with the incoming payload, report back to # the client as if it was a validation issue app.logger.exception(e) doc_issues['exception'] = str(e) if len(doc_issues): document = { config.STATUS: config.STATUS_ERR, config.ISSUES: doc_issues, } failures += 1 documents.append(document) if failures: # If at least one document got issues, the whole request fails and a # ``422 Bad Request`` status is return. for document in documents: if config.STATUS in document \ and document[config.STATUS] == config.STATUS_ERR: results.append(document) else: results.append({config.STATUS: config.STATUS_OK}) return_code = config.VALIDATION_ERROR_STATUS else: # notify callbacks getattr(app, "on_insert")(resource, documents) getattr(app, "on_insert_%s" % resource)(documents) # compute etags here as documents might have been updated by callbacks. resolve_document_etag(documents, resource) # bulk insert ids = app.data.insert(resource, documents) # update oplog if needed oplog_push(resource, documents, 'POST') # assign document ids for document in documents: # either return the custom ID_FIELD or the id returned by # data.insert(). id_ = document.get(id_field, ids.pop(0)) document[id_field] = id_ # build the full response document result = document build_response_document( result, resource, embedded_fields, document) # add extra write meta data result[config.STATUS] = config.STATUS_OK # limit what actually gets sent to minimize bandwidth usage result = marshal_write_response(result, resource) results.append(result) # insert versioning docs insert_versioning_documents(resource, documents) # notify callbacks getattr(app, "on_inserted")(resource, documents) getattr(app, "on_inserted_%s" % resource)(documents) # request was received and accepted; at least one document passed # validation and was accepted for insertion. return_code = 201 if len(results) == 1: response = results.pop(0) else: response = { config.STATUS: config.STATUS_ERR if failures else config.STATUS_OK, config.ITEMS: results, } if failures: response[config.ERROR] = { "code": return_code, "message": "Insertion failure: %d document(s) contain(s) error(s)" % failures, } location_header = None if return_code != 201 or not documents else \ [('Location', '%s/%s' % (resource_link(), documents[0][id_field]))] return response, None, None, return_code, location_header
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 272, 325, 432, 14, 2474, 14, 1932, 272, 18294, 339, 961, 859, 9031, 314, 8761, 1083, 12, 3748, 701, 314, 5944, 272, 16173, 14, 339, 520, 7307, 26, 334, 67, 9, 9708, 701, 653, 12802, 416, 473, 285, 679, 559, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 504, 2197, 492, 2197, 199, 504, 7209, 492, 1453, 63, 571, 465, 1145, 12, 12004, 199, 504, 325, 432, 14, 1208, 492, 1101, 12, 2198, 63, 1069, 12, 3105, 63, 705, 63, 1188, 199, 504, 325, 432, 14, 1178, 492, 5074, 63, 1178, 199, 504, 325, 432, 14, 6136, 492, 7543, 547, 199, 504, 325, 432, 14, 2474, 14, 2330, 492, 2198, 12, 4886, 12, 6634, 3097, 12, 971, 272, 876, 63, 1430, 12, 3877, 63, 4603, 63, 1725, 12, 7512, 63, 751, 63, 17973, 63, 2732, 12, 971, 272, 7512, 63, 18757, 63, 955, 12, 1900, 63, 1310, 63, 3554, 12, 21985, 63, 952, 63, 1310, 12, 971, 272, 7512, 63, 954, 63, 1927, 63, 515, 12, 7512, 63, 3554, 63, 11304, 12, 1687, 793, 63, 5335, 12, 2073, 63, 1073, 199, 504, 325, 432, 14, 30968, 492, 7512, 63, 3554, 63, 1023, 12, 971, 272, 5518, 63, 30968, 63, 12233, 421, 199, 32, 1866, 3097, 342, 199, 32, 6537, 63, 1178, 360, 1927, 358, 199, 32, 657, 63, 1430, 199, 318, 2963, 8, 1927, 12, 8633, 76, 29, 403, 304, 272, 408, 272, 3758, 805, 367, 7252, 8761, 4145, 12, 652, 965, 20419, 367, 272, 6634, 2304, 316, 12, 6299, 436, 367, 17026, 876, 13, 1069, 4474, 14, 12836, 314, 272, 20419, 787, 6781, 17465, 370, 1240, 370, 520, 1532, 1705, 1932, 63, 4672, 64, 339, 2508, 16434, 447, 378, 14, 21, 2126, 11740, 3379, 2963, 342, 1901, 2963, 15, 1932, 63, 4672, 20972, 14, 272, 408, 272, 372, 2963, 63, 4672, 8, 1927, 12, 8633, 76, 12, 3372, 63, 6136, 29, 797, 9, 421, 199, 318, 2963, 63, 4672, 8, 1927, 12, 8633, 76, 29, 403, 12, 3372, 63, 6136, 29, 797, 304, 272, 408, 272, 1010, 6943, 367, 5007, 2963, 4882, 12, 642, 1083, 365, 440, 6634, 13988, 12, 272, 6299, 365, 440, 7923, 436, 876, 13, 1069, 4474, 787, 440, 4915, 14, 272, 15747, 1373, 503, 1655, 8247, 370, 282, 2073, 14, 7048, 2213, 365, 16468, 272, 6169, 314, 2881, 4177, 14, 982, 6411, 14933, 314, 2213, 365, 11788, 272, 436, 2870, 63, 8609, 12, 491, 11307, 63, 23612, 1149, 436, 30131, 63, 26561, 3180, 543, 282, 2142, 370, 314, 272, 2213, 787, 2138, 14, 982, 6411, 6918, 12, 282, 769, 402, 6411, 10876, 272, 365, 2138, 14, 339, 520, 635, 2073, 26, 536, 402, 314, 2073, 28244, 14, 272, 520, 635, 8633, 76, 26, 13943, 4886, 14, 3979, 6358, 2963, 342, 687, 2195, 5705, 1233, 326, 1265, 883, 5647, 376, 13943, 4886, 14, 961, 883, 506, 2997, 12, 326, 367, 2893, 12, 1380, 1265, 1172, 282, 3233, 805, 5759, 379, 370, 282, 326, 9842, 6037, 12, 436, 2934, 370, 5147, 4722, 2963, 342, 4882, 326, 687, 2337, 14, 199, 326, 7754, 506, 1503, 17311, 626, 315, 1865, 370, 8792, 675, 642, 326, 945, 12, 282, 1056, 1067, 1471, 506, 2808, 14, 199, 326, 1666, 4178, 921, 5031, 14, 957, 15, 647, 4754, 15, 4754, 15, 10115, 15, 1342, 367, 282, 326, 16582, 12, 436, 282, 25780, 675, 1930, 14, 272, 520, 635, 3372, 63, 6136, 26, 3372, 4886, 6411, 2544, 2218, 334, 2245, 9, 339, 2508, 16434, 447, 378, 14, 23, 2126, 2654, 2291, 367, 12625, 1406, 14, 5980, 874, 327, 22370, 14, 339, 2508, 16434, 447, 378, 14, 22, 2126, 14811, 26, 3967, 373, 16, 14, 22, 12, 3372, 63, 6136, 275, 715, 14486, 282, 841, 1081, 1177, 15196, 31229, 680, 339, 2508, 16434, 447, 378, 14, 22, 2126, 11578, 12355, 18348, 901, 1380, 11620, 63, 1807, 365, 5223, 14, 339, 2508, 16434, 447, 378, 14, 21, 2126, 10257, 370, 30685, 849, 1338, 2410, 6411, 465, 3063, 314, 11822, 2126, 883, 7684, 4107, 5936, 2755, 1380, 2005, 1172, 849, 1338, 14, 1666, 2126, 327, 15355, 14, 2126, 22643, 7029, 370, 314, 9319, 2445, 14, 2126, 12769, 2963, 342, 965, 2757, 3715, 1901, 2963, 342, 436, 2963, 63, 4672, 1252, 2126, 662, 17626, 787, 3063, 5489, 543, 8247, 15196, 11939, 680, 339, 2508, 16434, 447, 378, 14, 20, 2126, 31096, 849, 1338, 2544, 6411, 365, 10585, 14, 1666, 327, 15355, 14, 2126, 12502, 367, 2213, 1015, 316, 14, 339, 2508, 16434, 447, 378, 14, 19, 2126, 1432, 1784, 340, 737, 5210, 1373, 2213, 965, 2757, 8792, 11788, 14, 2126, 14811, 327, 11921, 1790, 901, 440, 663, 340, 2073, 2166, 6299, 365, 663, 14, 2126, 12502, 367, 5898, 1504, 14, 2126, 3979, 8036, 63, 14747, 365, 6980, 12, 949, 13677, 365, 5120, 315, 314, 4886, 14, 2126, 12502, 367, 892, 6411, 1475, 21399, 543, 11002, 605, 527, 373, 16, 14, 21, 14, 339, 2508, 16434, 447, 378, 14, 18, 2126, 3645, 314, 892, 18460, 4260, 14, 2126, 3645, 314, 892, 2281, 6195, 654, 4260, 14, 2126, 14771, 283, 265, 63, 657, 27718, 765, 3524, 1566, 14, 2126, 23872, 590, 7512, 849, 1338, 3140, 402, 4691, 1337, 3062, 506, 12152, 2126, 701, 2863, 14, 1122, 14, 961, 23674, 282, 6411, 1125, 1380, 282, 1586, 13, 2118, 901, 2126, 2597, 965, 282, 849, 574, 14, 2126, 16230, 1124, 265, 63, 28565, 10, 1040, 4474, 2410, 314, 3050, 5518, 339, 2508, 16434, 447, 378, 14, 17, 14, 17, 2126, 1790, 14, 1069, 63, 1178, 63, 585, 365, 3063, 1202, 370, 3877, 314, 1790, 63, 698, 574, 14, 339, 2508, 16434, 447, 378, 14, 17, 14, 16, 2126, 16917, 23399, 7252, 402, 1790, 63, 698, 14, 2126, 12502, 367, 2716, 869, 1951, 47, 1179, 14, 339, 2508, 16434, 26, 378, 14, 16, 14, 25, 2126, 6763, 12604, 17864, 370, 506, 1655, 23399, 436, 12137, 26, 283, 265, 63, 23980, 7, 2126, 17864, 370, 283, 265, 63, 3176, 1370, 2126, 2047, 883, 3063, 986, 282, 876, 13, 4037, 3537, 4886, 370, 314, 9627, 9718, 14, 339, 2508, 16434, 447, 378, 14, 16, 14, 25, 2126, 1933 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 272, 325, 432, 14, 2474, 14, 1932, 272, 18294, 339, 961, 859, 9031, 314, 8761, 1083, 12, 3748, 701, 314, 5944, 272, 16173, 14, 339, 520, 7307, 26, 334, 67, 9, 9708, 701, 653, 12802, 416, 473, 285, 679, 559, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 504, 2197, 492, 2197, 199, 504, 7209, 492, 1453, 63, 571, 465, 1145, 12, 12004, 199, 504, 325, 432, 14, 1208, 492, 1101, 12, 2198, 63, 1069, 12, 3105, 63, 705, 63, 1188, 199, 504, 325, 432, 14, 1178, 492, 5074, 63, 1178, 199, 504, 325, 432, 14, 6136, 492, 7543, 547, 199, 504, 325, 432, 14, 2474, 14, 2330, 492, 2198, 12, 4886, 12, 6634, 3097, 12, 971, 272, 876, 63, 1430, 12, 3877, 63, 4603, 63, 1725, 12, 7512, 63, 751, 63, 17973, 63, 2732, 12, 971, 272, 7512, 63, 18757, 63, 955, 12, 1900, 63, 1310, 63, 3554, 12, 21985, 63, 952, 63, 1310, 12, 971, 272, 7512, 63, 954, 63, 1927, 63, 515, 12, 7512, 63, 3554, 63, 11304, 12, 1687, 793, 63, 5335, 12, 2073, 63, 1073, 199, 504, 325, 432, 14, 30968, 492, 7512, 63, 3554, 63, 1023, 12, 971, 272, 5518, 63, 30968, 63, 12233, 421, 199, 32, 1866, 3097, 342, 199, 32, 6537, 63, 1178, 360, 1927, 358, 199, 32, 657, 63, 1430, 199, 318, 2963, 8, 1927, 12, 8633, 76, 29, 403, 304, 272, 408, 272, 3758, 805, 367, 7252, 8761, 4145, 12, 652, 965, 20419, 367, 272, 6634, 2304, 316, 12, 6299, 436, 367, 17026, 876, 13, 1069, 4474, 14, 12836, 314, 272, 20419, 787, 6781, 17465, 370, 1240, 370, 520, 1532, 1705, 1932, 63, 4672, 64, 339, 2508, 16434, 447, 378, 14, 21, 2126, 11740, 3379, 2963, 342, 1901, 2963, 15, 1932, 63, 4672, 20972, 14, 272, 408, 272, 372, 2963, 63, 4672, 8, 1927, 12, 8633, 76, 12, 3372, 63, 6136, 29, 797, 9, 421, 199, 318, 2963, 63, 4672, 8, 1927, 12, 8633, 76, 29, 403, 12, 3372, 63, 6136, 29, 797, 304, 272, 408, 272, 1010, 6943, 367, 5007, 2963, 4882, 12, 642, 1083, 365, 440, 6634, 13988, 12, 272, 6299, 365, 440, 7923, 436, 876, 13, 1069, 4474, 787, 440, 4915, 14, 272, 15747, 1373, 503, 1655, 8247, 370, 282, 2073, 14, 7048, 2213, 365, 16468, 272, 6169, 314, 2881, 4177, 14, 982, 6411, 14933, 314, 2213, 365, 11788, 272, 436, 2870, 63, 8609, 12, 491, 11307, 63, 23612, 1149, 436, 30131, 63, 26561, 3180, 543, 282, 2142, 370, 314, 272, 2213, 787, 2138, 14, 982, 6411, 6918, 12, 282, 769, 402, 6411, 10876, 272, 365, 2138, 14, 339, 520, 635, 2073, 26, 536, 402, 314, 2073, 28244, 14, 272, 520, 635, 8633, 76, 26, 13943, 4886, 14, 3979, 6358, 2963, 342, 687, 2195, 5705, 1233, 326, 1265, 883, 5647, 376, 13943, 4886, 14, 961, 883, 506, 2997, 12, 326, 367, 2893, 12, 1380, 1265, 1172, 282, 3233, 805, 5759, 379, 370, 282, 326, 9842, 6037, 12, 436, 2934, 370, 5147, 4722, 2963, 342, 4882, 326, 687, 2337, 14, 199, 326, 7754, 506, 1503, 17311, 626, 315, 1865, 370, 8792, 675, 642, 326, 945, 12, 282, 1056, 1067, 1471, 506, 2808, 14, 199, 326, 1666, 4178, 921, 5031, 14, 957, 15, 647, 4754, 15, 4754, 15, 10115, 15, 1342, 367, 282, 326, 16582, 12, 436, 282, 25780, 675, 1930, 14, 272, 520, 635, 3372, 63, 6136, 26, 3372, 4886, 6411, 2544, 2218, 334, 2245, 9, 339, 2508, 16434, 447, 378, 14, 23, 2126, 2654, 2291, 367, 12625, 1406, 14, 5980, 874, 327, 22370, 14, 339, 2508, 16434, 447, 378, 14, 22, 2126, 14811, 26, 3967, 373, 16, 14, 22, 12, 3372, 63, 6136, 275, 715, 14486, 282, 841, 1081, 1177, 15196, 31229, 680, 339, 2508, 16434, 447, 378, 14, 22, 2126, 11578, 12355, 18348, 901, 1380, 11620, 63, 1807, 365, 5223, 14, 339, 2508, 16434, 447, 378, 14, 21, 2126, 10257, 370, 30685, 849, 1338, 2410, 6411, 465, 3063, 314, 11822, 2126, 883, 7684, 4107, 5936, 2755, 1380, 2005, 1172, 849, 1338, 14, 1666, 2126, 327, 15355, 14, 2126, 22643, 7029, 370, 314, 9319, 2445, 14, 2126, 12769, 2963, 342, 965, 2757, 3715, 1901, 2963, 342, 436, 2963, 63, 4672, 1252, 2126, 662, 17626, 787, 3063, 5489, 543, 8247, 15196, 11939, 680, 339, 2508, 16434, 447, 378, 14, 20, 2126, 31096, 849, 1338, 2544, 6411, 365, 10585, 14, 1666, 327, 15355, 14, 2126, 12502, 367, 2213, 1015, 316, 14, 339, 2508, 16434, 447, 378, 14, 19, 2126, 1432, 1784, 340, 737, 5210, 1373, 2213, 965, 2757, 8792, 11788, 14, 2126, 14811, 327, 11921, 1790, 901, 440, 663, 340, 2073, 2166, 6299, 365, 663, 14, 2126, 12502, 367, 5898, 1504, 14, 2126, 3979, 8036, 63, 14747, 365, 6980, 12, 949, 13677, 365, 5120, 315, 314, 4886, 14, 2126, 12502, 367, 892, 6411, 1475, 21399, 543, 11002, 605, 527, 373, 16, 14, 21, 14, 339, 2508, 16434, 447, 378, 14, 18, 2126, 3645, 314, 892, 18460, 4260, 14, 2126, 3645, 314, 892, 2281, 6195, 654, 4260, 14, 2126, 14771, 283, 265, 63, 657, 27718, 765, 3524, 1566, 14, 2126, 23872, 590, 7512, 849, 1338, 3140, 402, 4691, 1337, 3062, 506, 12152, 2126, 701, 2863, 14, 1122, 14, 961, 23674, 282, 6411, 1125, 1380, 282, 1586, 13, 2118, 901, 2126, 2597, 965, 282, 849, 574, 14, 2126, 16230, 1124, 265, 63, 28565, 10, 1040, 4474, 2410, 314, 3050, 5518, 339, 2508, 16434, 447, 378, 14, 17, 14, 17, 2126, 1790, 14, 1069, 63, 1178, 63, 585, 365, 3063, 1202, 370, 3877, 314, 1790, 63, 698, 574, 14, 339, 2508, 16434, 447, 378, 14, 17, 14, 16, 2126, 16917, 23399, 7252, 402, 1790, 63, 698, 14, 2126, 12502, 367, 2716, 869, 1951, 47, 1179, 14, 339, 2508, 16434, 26, 378, 14, 16, 14, 25, 2126, 6763, 12604, 17864, 370, 506, 1655, 23399, 436, 12137, 26, 283, 265, 63, 23980, 7, 2126, 17864, 370, 283, 265, 63, 3176, 1370, 2126, 2047, 883, 3063, 986, 282, 876, 13, 4037, 3537, 4886, 370, 314, 9627, 9718, 14, 339, 2508, 16434, 447, 378, 14, 16, 14, 25, 2126, 1933, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
zyguan/HDFS-503-on-0.20.2
src/contrib/hod/testing/testThreads.py
182
3075
#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 unittest, os, sys, re, threading, time myDirectory = os.path.realpath(sys.argv[0]) rootDirectory = re.sub("/testing/.*", "", myDirectory) sys.path.append(rootDirectory) from testing.lib import BaseTestSuite # module specific imports import os, tempfile, random excludes = [] import getpass from hodlib.Common.threads import simpleCommand from testing.helper import sampleText # All test-case classes should have the naming convention test_.* class test_SimpleCommand(unittest.TestCase): def setUp(self): self.rootDir = '/tmp/hod-%s' % getpass.getuser() if not os.path.exists(self.rootDir): os.mkdir(self.rootDir) self.prefix= 'ThreadsTestSuite.test_SimpleCommand' self.testFile = None pass def testRedirectedStdout(self): self.testFile= tempfile.NamedTemporaryFile(dir=self.rootDir, \ prefix=self.prefix) cmd=simpleCommand('helper','%s %s 1 1>%s' % \ (sys.executable, \ os.path.join(rootDirectory, "testing", "helper.py"), \ self.testFile.name)) cmd.start() cmd.join() self.testFile.seek(0) stdout = self.testFile.read() # print stdout, sampleText assert(stdout == sampleText) pass def testRedirectedStderr(self): self.testFile= tempfile.NamedTemporaryFile(dir=self.rootDir, \ prefix=self.prefix) cmd=simpleCommand('helper','%s %s 2 2>%s' % \ (sys.executable, \ os.path.join(rootDirectory, "testing", "helper.py"), \ self.testFile.name)) cmd.start() cmd.join() self.testFile.seek(0) stderror = self.testFile.read() # print stderror, sampleText assert(stderror == sampleText) pass def tearDown(self): if self.testFile: self.testFile.close() pass class ThreadsTestSuite(BaseTestSuite): def __init__(self): # suite setup BaseTestSuite.__init__(self, __name__, excludes) pass def cleanUp(self): # suite tearDown pass def RunThreadsTests(): # modulename_suite suite = ThreadsTestSuite() testResult = suite.runTests() suite.cleanUp() return testResult if __name__ == "__main__": RunThreadsTests()
apache-2.0
[ 3, 31661, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 269, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 16832, 543, 642, 1736, 367, 4722, 2556, 199, 3, 1135, 1005, 316, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 475, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 23662, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 1045, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 3, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 3097, 1298, 1334, 314, 844, 14, 199, 646, 2882, 12, 747, 12, 984, 12, 295, 12, 5796, 12, 900, 199, 199, 1662, 6231, 275, 747, 14, 515, 14, 11091, 8, 1274, 14, 3020, 59, 16, 566, 199, 1231, 6231, 257, 275, 295, 14, 954, 4769, 4776, 15, 2795, 401, 4873, 3002, 6231, 9, 199, 199, 1274, 14, 515, 14, 740, 8, 1231, 6231, 9, 199, 199, 504, 5343, 14, 773, 492, 3523, 10591, 199, 199, 3, 859, 2488, 8925, 199, 646, 747, 12, 5549, 12, 2196, 199, 199, 26984, 275, 942, 199, 199, 646, 18354, 199, 504, 394, 364, 773, 14, 7844, 14, 6962, 492, 3486, 3110, 199, 504, 5343, 14, 3676, 492, 2690, 1872, 199, 199, 3, 2900, 511, 13, 2546, 3992, 1077, 1172, 314, 19720, 16129, 511, 63, 2795, 199, 533, 511, 63, 3184, 3110, 8, 2796, 14, 1746, 304, 523, 347, 3613, 8, 277, 304, 272, 291, 14, 1231, 3567, 275, 1994, 2791, 15, 72, 364, 3295, 83, 7, 450, 18354, 14, 362, 751, 342, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 277, 14, 1231, 3567, 304, 489, 747, 14, 8215, 8, 277, 14, 1231, 3567, 9, 272, 291, 14, 1861, 29, 283, 22785, 10591, 14, 396, 63, 3184, 3110, 7, 272, 291, 14, 396, 1173, 275, 488, 272, 986, 819, 347, 511, 497, 12080, 26080, 8, 277, 304, 272, 291, 14, 396, 1173, 29, 5549, 14, 19320, 8, 694, 29, 277, 14, 1231, 3567, 12, 971, 6901, 2403, 29, 277, 14, 1861, 9, 272, 2088, 29, 4129, 3110, 360, 3676, 1673, 5, 83, 450, 83, 413, 413, 6598, 83, 7, 450, 971, 1993, 334, 1274, 14, 5904, 12, 971, 1993, 747, 14, 515, 14, 904, 8, 1231, 6231, 12, 298, 4776, 401, 298, 3676, 14, 647, 1288, 971, 1993, 291, 14, 396, 1173, 14, 354, 430, 339, 2088, 14, 928, 342, 272, 2088, 14, 904, 342, 2286, 291, 14, 396, 1173, 14, 5507, 8, 16, 9, 272, 3839, 275, 291, 14, 396, 1173, 14, 739, 342, 272, 327, 870, 3839, 12, 2690, 1872, 272, 702, 8, 2703, 508, 2690, 1872, 9, 272, 986, 819, 347, 511, 497, 12080, 933, 2303, 8, 277, 304, 272, 291, 14, 396, 1173, 29, 5549, 14, 19320, 8, 694, 29, 277, 14, 1231, 3567, 12, 971, 6059, 2403, 29, 277, 14, 1861, 9, 272, 2088, 29, 4129, 3110, 360, 3676, 1673, 5, 83, 450, 83, 499, 499, 6598, 83, 7, 450, 971, 1993, 334, 1274, 14, 5904, 12, 971, 1993, 747, 14, 515, 14, 904, 8, 1231, 6231, 12, 298, 4776, 401, 298, 3676, 14, 647, 1288, 971, 1993, 291, 14, 396, 1173, 14, 354, 430, 272, 2088, 14, 928, 342, 272, 2088, 14, 904, 342, 489, 272, 291, 14, 396, 1173, 14, 5507, 8, 16, 9, 272, 410, 424, 451, 275, 291, 14, 396, 1173, 14, 739, 342, 272, 327, 870, 410, 424, 451, 12, 2690, 1872, 272, 702, 8, 270, 424, 451, 508, 2690, 1872, 9, 272, 986, 819, 347, 6766, 8, 277, 304, 272, 340, 291, 14, 396, 1173, 26, 291, 14, 396, 1173, 14, 1600, 342, 272, 986, 199, 199, 533, 11086, 83, 10591, 8, 1563, 10591, 304, 523, 347, 636, 826, 721, 277, 304, 272, 327, 5241, 3272, 272, 3523, 10591, 855, 826, 721, 277, 12, 636, 354, 3108, 23388, 9, 272, 986, 12244, 347, 3633, 1721, 8, 277, 304, 272, 327, 5241, 6766, 272, 986, 199, 199, 318, 3378, 22785, 2925, 837, 523, 327, 30045, 63, 5768, 523, 5241, 275, 11086, 83, 10591, 342, 523, 511, 2889, 275, 5241, 14, 1065, 2925, 342, 523, 5241, 14, 3118, 1721, 342, 523, 372, 511, 2889, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 523, 3378, 22785, 2925, 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 ]
[ 31661, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 269, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 16832, 543, 642, 1736, 367, 4722, 2556, 199, 3, 1135, 1005, 316, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 475, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 23662, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 1045, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 3, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 3097, 1298, 1334, 314, 844, 14, 199, 646, 2882, 12, 747, 12, 984, 12, 295, 12, 5796, 12, 900, 199, 199, 1662, 6231, 275, 747, 14, 515, 14, 11091, 8, 1274, 14, 3020, 59, 16, 566, 199, 1231, 6231, 257, 275, 295, 14, 954, 4769, 4776, 15, 2795, 401, 4873, 3002, 6231, 9, 199, 199, 1274, 14, 515, 14, 740, 8, 1231, 6231, 9, 199, 199, 504, 5343, 14, 773, 492, 3523, 10591, 199, 199, 3, 859, 2488, 8925, 199, 646, 747, 12, 5549, 12, 2196, 199, 199, 26984, 275, 942, 199, 199, 646, 18354, 199, 504, 394, 364, 773, 14, 7844, 14, 6962, 492, 3486, 3110, 199, 504, 5343, 14, 3676, 492, 2690, 1872, 199, 199, 3, 2900, 511, 13, 2546, 3992, 1077, 1172, 314, 19720, 16129, 511, 63, 2795, 199, 533, 511, 63, 3184, 3110, 8, 2796, 14, 1746, 304, 523, 347, 3613, 8, 277, 304, 272, 291, 14, 1231, 3567, 275, 1994, 2791, 15, 72, 364, 3295, 83, 7, 450, 18354, 14, 362, 751, 342, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 277, 14, 1231, 3567, 304, 489, 747, 14, 8215, 8, 277, 14, 1231, 3567, 9, 272, 291, 14, 1861, 29, 283, 22785, 10591, 14, 396, 63, 3184, 3110, 7, 272, 291, 14, 396, 1173, 275, 488, 272, 986, 819, 347, 511, 497, 12080, 26080, 8, 277, 304, 272, 291, 14, 396, 1173, 29, 5549, 14, 19320, 8, 694, 29, 277, 14, 1231, 3567, 12, 971, 6901, 2403, 29, 277, 14, 1861, 9, 272, 2088, 29, 4129, 3110, 360, 3676, 1673, 5, 83, 450, 83, 413, 413, 6598, 83, 7, 450, 971, 1993, 334, 1274, 14, 5904, 12, 971, 1993, 747, 14, 515, 14, 904, 8, 1231, 6231, 12, 298, 4776, 401, 298, 3676, 14, 647, 1288, 971, 1993, 291, 14, 396, 1173, 14, 354, 430, 339, 2088, 14, 928, 342, 272, 2088, 14, 904, 342, 2286, 291, 14, 396, 1173, 14, 5507, 8, 16, 9, 272, 3839, 275, 291, 14, 396, 1173, 14, 739, 342, 272, 327, 870, 3839, 12, 2690, 1872, 272, 702, 8, 2703, 508, 2690, 1872, 9, 272, 986, 819, 347, 511, 497, 12080, 933, 2303, 8, 277, 304, 272, 291, 14, 396, 1173, 29, 5549, 14, 19320, 8, 694, 29, 277, 14, 1231, 3567, 12, 971, 6059, 2403, 29, 277, 14, 1861, 9, 272, 2088, 29, 4129, 3110, 360, 3676, 1673, 5, 83, 450, 83, 499, 499, 6598, 83, 7, 450, 971, 1993, 334, 1274, 14, 5904, 12, 971, 1993, 747, 14, 515, 14, 904, 8, 1231, 6231, 12, 298, 4776, 401, 298, 3676, 14, 647, 1288, 971, 1993, 291, 14, 396, 1173, 14, 354, 430, 272, 2088, 14, 928, 342, 272, 2088, 14, 904, 342, 489, 272, 291, 14, 396, 1173, 14, 5507, 8, 16, 9, 272, 410, 424, 451, 275, 291, 14, 396, 1173, 14, 739, 342, 272, 327, 870, 410, 424, 451, 12, 2690, 1872, 272, 702, 8, 270, 424, 451, 508, 2690, 1872, 9, 272, 986, 819, 347, 6766, 8, 277, 304, 272, 340, 291, 14, 396, 1173, 26, 291, 14, 396, 1173, 14, 1600, 342, 272, 986, 199, 199, 533, 11086, 83, 10591, 8, 1563, 10591, 304, 523, 347, 636, 826, 721, 277, 304, 272, 327, 5241, 3272, 272, 3523, 10591, 855, 826, 721, 277, 12, 636, 354, 3108, 23388, 9, 272, 986, 12244, 347, 3633, 1721, 8, 277, 304, 272, 327, 5241, 6766, 272, 986, 199, 199, 318, 3378, 22785, 2925, 837, 523, 327, 30045, 63, 5768, 523, 5241, 275, 11086, 83, 10591, 342, 523, 511, 2889, 275, 5241, 14, 1065, 2925, 342, 523, 5241, 14, 3118, 1721, 342, 523, 372, 511, 2889, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 523, 3378, 22785, 2925, 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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0, 0, 0, 0, 0, 0 ]
junmoa/dpark
dpark/env.py
6
3049
import os import logging import time import socket import shutil import zmq from dpark import util import dpark.conf as conf logger = logging.getLogger(__name__) class DparkEnv: environ = {} @classmethod def register(cls, name, value): cls.environ[name] = value @classmethod def get(cls, name, default=None): return cls.environ.get(name, default) def __init__(self): self.started = False def start(self, isMaster, environ={}): if self.started: return logger.debug("start env in %s: %s %s", os.getpid(), isMaster, environ) self.isMaster = isMaster if isMaster: roots = conf.DPARK_WORK_DIR if isinstance(roots, str): roots = roots.split(',') name = '%s-%s-%d' % (time.strftime("%Y%m%d-%H%M%S"), socket.gethostname(), os.getpid()) self.workdir = [os.path.join(root, name) for root in roots] try: for d in self.workdir: util.mkdir_p(d) except OSError as e: if environ.get('is_local', False): raise e self.environ['SERVER_URI'] = 'file://' + self.workdir[0] self.environ['WORKDIR'] = self.workdir self.environ['COMPRESS'] = util.COMPRESS else: self.environ.update(environ) if self.environ['COMPRESS'] != util.COMPRESS: raise Exception("no %s available" % self.environ['COMPRESS']) self.ctx = zmq.Context() from dpark.tracker import TrackerServer, TrackerClient if isMaster: self.trackerServer = TrackerServer() self.trackerServer.start() addr = self.trackerServer.addr env.register('TrackerAddr', addr) else: addr = env.get('TrackerAddr') self.trackerClient = TrackerClient(addr) from dpark.cache import CacheTracker self.cacheTracker = CacheTracker() from dpark.shuffle import LocalFileShuffle, MapOutputTracker LocalFileShuffle.initialize(isMaster) self.mapOutputTracker = MapOutputTracker() from dpark.shuffle import ParallelShuffleFetcher self.shuffleFetcher = ParallelShuffleFetcher(2) from dpark.broadcast import start_manager start_manager(isMaster) self.started = True logger.debug("env started") def stop(self): if not getattr(self, 'started', False): return logger.debug("stop env in %s", os.getpid()) self.shuffleFetcher.stop() self.cacheTracker.stop() self.mapOutputTracker.stop() if self.isMaster: self.trackerServer.stop() from dpark.broadcast import stop_manager stop_manager() logger.debug("cleaning workdir ...") for d in self.workdir: shutil.rmtree(d, True) logger.debug("done.") self.started = False env = DparkEnv()
bsd-3-clause
[ 646, 747, 199, 646, 2050, 199, 646, 900, 199, 646, 2838, 199, 646, 5145, 199, 199, 646, 26633, 199, 199, 504, 366, 5149, 492, 4884, 199, 646, 366, 5149, 14, 2190, 465, 3743, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 577, 5149, 7744, 26, 272, 6160, 275, 1052, 339, 768, 3744, 272, 347, 2274, 8, 1886, 12, 536, 12, 574, 304, 267, 843, 14, 2314, 59, 354, 61, 275, 574, 339, 768, 3744, 272, 347, 664, 8, 1886, 12, 536, 12, 849, 29, 403, 304, 267, 372, 843, 14, 2314, 14, 362, 8, 354, 12, 849, 9, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 8924, 275, 756, 339, 347, 1343, 8, 277, 12, 365, 12288, 12, 6160, 16420, 267, 340, 291, 14, 8924, 26, 288, 372, 267, 2512, 14, 1757, 480, 928, 2589, 315, 450, 83, 26, 450, 83, 450, 83, 401, 747, 14, 17829, 1062, 365, 12288, 12, 6160, 9, 267, 291, 14, 374, 12288, 275, 365, 12288, 267, 340, 365, 12288, 26, 288, 14361, 275, 3743, 14, 36, 28535, 63, 8406, 63, 3022, 288, 340, 1228, 8, 12065, 12, 620, 304, 355, 14361, 275, 14361, 14, 1294, 11917, 288, 536, 275, 1543, 83, 3295, 83, 3295, 68, 7, 450, 334, 521, 14, 6205, 3647, 57, 5, 77, 5, 68, 3295, 40, 5, 45, 5, 51, 1288, 639, 2838, 14, 29789, 1062, 747, 14, 17829, 1012, 288, 291, 14, 19132, 275, 359, 736, 14, 515, 14, 904, 8, 1231, 12, 536, 9, 367, 1738, 315, 14361, 61, 288, 862, 26, 355, 367, 366, 315, 291, 14, 19132, 26, 490, 4884, 14, 8215, 63, 80, 8, 68, 9, 288, 871, 6440, 465, 325, 26, 355, 340, 6160, 14, 362, 360, 374, 63, 1832, 297, 756, 304, 490, 746, 325, 953, 291, 14, 2314, 459, 6613, 63, 7639, 418, 275, 283, 493, 22399, 435, 291, 14, 19132, 59, 16, 61, 288, 291, 14, 2314, 459, 8406, 3022, 418, 275, 291, 14, 19132, 288, 291, 14, 2314, 459, 22827, 1608, 418, 275, 4884, 14, 22827, 1608, 267, 587, 26, 288, 291, 14, 2314, 14, 873, 8, 2314, 9, 288, 340, 291, 14, 2314, 459, 22827, 1608, 418, 1137, 4884, 14, 22827, 1608, 26, 355, 746, 2186, 480, 889, 450, 83, 2808, 2, 450, 291, 14, 2314, 459, 22827, 1608, 1105, 398, 291, 14, 3799, 275, 26633, 14, 2998, 342, 398, 687, 366, 5149, 14, 8877, 492, 17507, 281, 3120, 12, 17507, 281, 3041, 267, 340, 365, 12288, 26, 288, 291, 14, 8877, 3120, 275, 17507, 281, 3120, 342, 288, 291, 14, 8877, 3120, 14, 928, 342, 288, 5552, 275, 291, 14, 8877, 3120, 14, 2697, 288, 2589, 14, 2683, 360, 13652, 11404, 297, 5552, 9, 267, 587, 26, 288, 5552, 275, 2589, 14, 362, 360, 13652, 11404, 358, 398, 291, 14, 8877, 3041, 275, 17507, 281, 3041, 8, 2697, 9, 398, 687, 366, 5149, 14, 1637, 492, 11977, 13652, 267, 291, 14, 1637, 13652, 275, 11977, 13652, 342, 398, 687, 366, 5149, 14, 11777, 492, 10111, 1173, 19779, 12, 9672, 2959, 13652, 267, 10111, 1173, 19779, 14, 8489, 8, 374, 12288, 9, 267, 291, 14, 1130, 2959, 13652, 275, 9672, 2959, 13652, 342, 267, 687, 366, 5149, 14, 11777, 492, 27311, 19779, 11135, 281, 267, 291, 14, 11777, 11135, 281, 275, 27311, 19779, 11135, 281, 8, 18, 9, 398, 687, 366, 5149, 14, 10786, 492, 1343, 63, 2609, 267, 1343, 63, 2609, 8, 374, 12288, 9, 398, 291, 14, 8924, 275, 715, 267, 2512, 14, 1757, 480, 1813, 8239, 531, 339, 347, 3631, 8, 277, 304, 267, 340, 440, 2519, 8, 277, 12, 283, 8924, 297, 756, 304, 288, 372, 267, 2512, 14, 1757, 480, 2379, 2589, 315, 450, 83, 401, 747, 14, 17829, 1012, 267, 291, 14, 11777, 11135, 281, 14, 2379, 342, 267, 291, 14, 1637, 13652, 14, 2379, 342, 267, 291, 14, 1130, 2959, 13652, 14, 2379, 342, 267, 340, 291, 14, 374, 12288, 26, 288, 291, 14, 8877, 3120, 14, 2379, 342, 267, 687, 366, 5149, 14, 10786, 492, 3631, 63, 2609, 267, 3631, 63, 2609, 342, 398, 2512, 14, 1757, 480, 3118, 316, 1736, 694, 2263, 531, 267, 367, 366, 315, 291, 14, 19132, 26, 288, 5145, 14, 9242, 8, 68, 12, 715, 9, 267, 2512, 14, 1757, 480, 4456, 2685, 398, 291, 14, 8924, 275, 756, 199, 199, 1813, 275, 577, 5149, 7744, 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 ]
[ 747, 199, 646, 2050, 199, 646, 900, 199, 646, 2838, 199, 646, 5145, 199, 199, 646, 26633, 199, 199, 504, 366, 5149, 492, 4884, 199, 646, 366, 5149, 14, 2190, 465, 3743, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 577, 5149, 7744, 26, 272, 6160, 275, 1052, 339, 768, 3744, 272, 347, 2274, 8, 1886, 12, 536, 12, 574, 304, 267, 843, 14, 2314, 59, 354, 61, 275, 574, 339, 768, 3744, 272, 347, 664, 8, 1886, 12, 536, 12, 849, 29, 403, 304, 267, 372, 843, 14, 2314, 14, 362, 8, 354, 12, 849, 9, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 8924, 275, 756, 339, 347, 1343, 8, 277, 12, 365, 12288, 12, 6160, 16420, 267, 340, 291, 14, 8924, 26, 288, 372, 267, 2512, 14, 1757, 480, 928, 2589, 315, 450, 83, 26, 450, 83, 450, 83, 401, 747, 14, 17829, 1062, 365, 12288, 12, 6160, 9, 267, 291, 14, 374, 12288, 275, 365, 12288, 267, 340, 365, 12288, 26, 288, 14361, 275, 3743, 14, 36, 28535, 63, 8406, 63, 3022, 288, 340, 1228, 8, 12065, 12, 620, 304, 355, 14361, 275, 14361, 14, 1294, 11917, 288, 536, 275, 1543, 83, 3295, 83, 3295, 68, 7, 450, 334, 521, 14, 6205, 3647, 57, 5, 77, 5, 68, 3295, 40, 5, 45, 5, 51, 1288, 639, 2838, 14, 29789, 1062, 747, 14, 17829, 1012, 288, 291, 14, 19132, 275, 359, 736, 14, 515, 14, 904, 8, 1231, 12, 536, 9, 367, 1738, 315, 14361, 61, 288, 862, 26, 355, 367, 366, 315, 291, 14, 19132, 26, 490, 4884, 14, 8215, 63, 80, 8, 68, 9, 288, 871, 6440, 465, 325, 26, 355, 340, 6160, 14, 362, 360, 374, 63, 1832, 297, 756, 304, 490, 746, 325, 953, 291, 14, 2314, 459, 6613, 63, 7639, 418, 275, 283, 493, 22399, 435, 291, 14, 19132, 59, 16, 61, 288, 291, 14, 2314, 459, 8406, 3022, 418, 275, 291, 14, 19132, 288, 291, 14, 2314, 459, 22827, 1608, 418, 275, 4884, 14, 22827, 1608, 267, 587, 26, 288, 291, 14, 2314, 14, 873, 8, 2314, 9, 288, 340, 291, 14, 2314, 459, 22827, 1608, 418, 1137, 4884, 14, 22827, 1608, 26, 355, 746, 2186, 480, 889, 450, 83, 2808, 2, 450, 291, 14, 2314, 459, 22827, 1608, 1105, 398, 291, 14, 3799, 275, 26633, 14, 2998, 342, 398, 687, 366, 5149, 14, 8877, 492, 17507, 281, 3120, 12, 17507, 281, 3041, 267, 340, 365, 12288, 26, 288, 291, 14, 8877, 3120, 275, 17507, 281, 3120, 342, 288, 291, 14, 8877, 3120, 14, 928, 342, 288, 5552, 275, 291, 14, 8877, 3120, 14, 2697, 288, 2589, 14, 2683, 360, 13652, 11404, 297, 5552, 9, 267, 587, 26, 288, 5552, 275, 2589, 14, 362, 360, 13652, 11404, 358, 398, 291, 14, 8877, 3041, 275, 17507, 281, 3041, 8, 2697, 9, 398, 687, 366, 5149, 14, 1637, 492, 11977, 13652, 267, 291, 14, 1637, 13652, 275, 11977, 13652, 342, 398, 687, 366, 5149, 14, 11777, 492, 10111, 1173, 19779, 12, 9672, 2959, 13652, 267, 10111, 1173, 19779, 14, 8489, 8, 374, 12288, 9, 267, 291, 14, 1130, 2959, 13652, 275, 9672, 2959, 13652, 342, 267, 687, 366, 5149, 14, 11777, 492, 27311, 19779, 11135, 281, 267, 291, 14, 11777, 11135, 281, 275, 27311, 19779, 11135, 281, 8, 18, 9, 398, 687, 366, 5149, 14, 10786, 492, 1343, 63, 2609, 267, 1343, 63, 2609, 8, 374, 12288, 9, 398, 291, 14, 8924, 275, 715, 267, 2512, 14, 1757, 480, 1813, 8239, 531, 339, 347, 3631, 8, 277, 304, 267, 340, 440, 2519, 8, 277, 12, 283, 8924, 297, 756, 304, 288, 372, 267, 2512, 14, 1757, 480, 2379, 2589, 315, 450, 83, 401, 747, 14, 17829, 1012, 267, 291, 14, 11777, 11135, 281, 14, 2379, 342, 267, 291, 14, 1637, 13652, 14, 2379, 342, 267, 291, 14, 1130, 2959, 13652, 14, 2379, 342, 267, 340, 291, 14, 374, 12288, 26, 288, 291, 14, 8877, 3120, 14, 2379, 342, 267, 687, 366, 5149, 14, 10786, 492, 3631, 63, 2609, 267, 3631, 63, 2609, 342, 398, 2512, 14, 1757, 480, 3118, 316, 1736, 694, 2263, 531, 267, 367, 366, 315, 291, 14, 19132, 26, 288, 5145, 14, 9242, 8, 68, 12, 715, 9, 267, 2512, 14, 1757, 480, 4456, 2685, 398, 291, 14, 8924, 275, 756, 199, 199, 1813, 275, 577, 5149, 7744, 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, 32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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
spoqa/settei
tests/base_test.py
1
17192
import enum import pathlib import typing # noqa import warnings from pytest import mark, raises from .utils import os_environ from settei.base import (ConfigKeyError, ConfigTypeError, Configuration, ConfigValueError, ConfigWarning, config_object_property, config_property, get_union_types) class Enum1(enum.Enum): apple = 'apple' banana = 'banana' cherry = 'cherry' class Enum2(enum.Enum): apple = 'apple' bear = 'bear' candy = 'candy' def test_get_union_types(): assert get_union_types(typing.Union[int, str]) == (int, str) assert get_union_types(typing.Union[bool, list, set]) == (bool, list, set) assert get_union_types(str) is None assert get_union_types('asdf') is None def test_package_level_api_compatibility(): import settei assert settei.Configuration is Configuration assert settei.ConfigWarning is ConfigWarning assert settei.config_property is config_property class TestConfig(dict): depth1_required = config_property('key', int) depth1_optional = config_property('key', int, default='') depth1_warn = config_property('key', int, default='', default_warning=True) depth1_default_func = config_property( 'key', int, default_func=lambda self: self.depth1_optional ) depth1_default_func_warn = config_property( 'key', int, default_func=lambda self: self.depth1_optional, default_warning=True ) depth2_required = config_property('section.key', str) depth2_optional = config_property('section.key', str, default=None) depth2_warn = config_property('section.key', str, default=None, default_warning=True) union = config_property('union', typing.Union[int, str]) class EnumTestConfig(dict): enum = config_property('enum', Enum1, default=Enum1.apple) enum_union = config_property('enum_union', typing.Union[Enum1, Enum2, str]) class TestAppConfig(Configuration): database_url = config_property( 'database.url', str, default='sqlite:///test_app.db', default_warning=True ) @mark.parametrize('union_value', [123, 'string']) def test_config_property(union_value: typing.Union[int, str]): c = TestConfig(key=123, section={'key': 'val'}, union=union_value) assert c.depth1_required == 123 with warnings.catch_warnings(record=True) as w: assert c.depth1_optional == 123 assert len(w) == 0 with warnings.catch_warnings(record=True) as w: assert c.depth1_warn == 123 assert len(w) == 0 with warnings.catch_warnings(record=True) as w: assert c.depth1_default_func == 123 assert len(w) == 0 with warnings.catch_warnings(record=True) as w: assert c.depth1_default_func_warn == 123 assert len(w) == 0 assert c.depth2_required == 'val' with warnings.catch_warnings(record=True) as w: assert c.depth2_optional == 'val' assert len(w) == 0 with warnings.catch_warnings(record=True) as w: assert c.depth2_warn == 'val' assert len(w) == 0 assert c.union == union_value def test_enum_config_property(): c1 = EnumTestConfig(enum='apple', enum_union='banana') c2 = EnumTestConfig(enum='banana', enum_union='candy') c3 = EnumTestConfig(enum='dragonfruit', enum_union='apple') c4 = EnumTestConfig(enum='cherry', enum_union='foo') assert c1.enum == Enum1.apple assert c2.enum == Enum1.banana assert c1.enum_union == Enum1.banana assert c2.enum_union == Enum2.candy with raises(ConfigTypeError) as ex: c3.enum assert ex.value.args[0] == 'Invalid value dragonfruit in <enum \'Enum1\'>. Candidates are: apple, banana, cherry' # noqa with raises(ConfigTypeError) as ex: c3.enum_union assert ex.value.args[0] == 'Ambiguous enum type for value apple: <Enum1.apple: \'apple\'>, <Enum2.apple: \'apple\'>' # noqa assert c4.enum_union == 'foo' def test_config_property_absence(): c = TestConfig() with raises(ConfigKeyError): c.depth1_required with warnings.catch_warnings(record=True) as w: assert c.depth1_optional == '' assert len(w) == 0 with warnings.catch_warnings(record=True) as w: assert c.depth1_warn == '' assert len(w) == 1 assert issubclass(w[-1].category, ConfigWarning) with warnings.catch_warnings(record=True) as w: assert c.depth1_default_func == '' assert len(w) == 0 with warnings.catch_warnings(record=True) as w: assert c.depth1_default_func_warn == '' assert len(w) == 1 assert issubclass(w[-1].category, ConfigWarning) with raises(ConfigKeyError): c.depth2_required with warnings.catch_warnings(record=True) as w: assert c.depth2_optional is None assert len(w) == 0 with warnings.catch_warnings(record=True) as w: assert c.depth2_warn is None assert len(w) == 1 assert issubclass(w[-1].category, ConfigWarning) with raises(ConfigKeyError): c.union def test_config_property_absence_2nd_depth(): c = TestConfig(section={}) with raises(ConfigKeyError): c.depth2_required with warnings.catch_warnings(record=True) as w: assert c.depth2_optional is None assert len(w) == 0 with warnings.catch_warnings(record=True) as w: assert c.depth2_warn is None assert len(w) == 1 assert issubclass(w[-1].category, ConfigWarning) def test_config_property_type_error(): c = TestConfig(key='not an integer') with raises(ConfigTypeError): c.depth1_required c2 = TestConfig() assert isinstance(c2.depth1_optional, str), \ 'default should be possible to bypass typecheck' assert isinstance(c2.depth1_default_func, str), \ 'default_func should be possible to bypass typecheck' class SampleInterface: pass class Impl(SampleInterface): def __init__(self, *args, **kwargs) -> None: self.args = args self.kwargs = kwargs def __repr__(self) -> str: args = ', '.join(repr(arg) for arg in self.args) kwargs = ', '.join('{0}={1!r}'.format(k, v) for k, v in self.kwargs.items()) if kwargs: args += (', ' if args else '') + kwargs return '{0.__module__}.{0.__name__}({1})'.format(type(self), args) class TestAppConfigObject(Configuration): no_default = config_object_property('sample.a', SampleInterface) with_default = config_object_property('sample.b', SampleInterface, default=Impl('default')) recursive = config_object_property('sample.c', SampleInterface, recurse=True) cached = config_object_property('sample.a', SampleInterface, cached=True) cached_with_default = config_object_property('sample.b', SampleInterface, default=Impl('default'), cached=True) def test_config_object_property(): c = TestAppConfigObject(sample={ 'a': { 'class': __name__ + ':Impl', '*': ['a', 'b', 'c'], 'd': 4, 'e': 5, 'f': { 'class': __name__ + ':Impl', 'nested': True, 'recursive': { 'class': __name__ + ':Impl', 'nested': True, } }, }, }) v = c.no_default assert isinstance(v, Impl) assert v.args == ('a', 'b', 'c') assert v.kwargs == { 'd': 4, 'e': 5, 'f': { 'class': __name__ + ':Impl', 'nested': True, 'recursive': { 'class': __name__ + ':Impl', 'nested': True, } }, } assert c.no_default is not c.no_default vv = c.with_default assert isinstance(vv, Impl) assert vv.args == ('default',) assert vv.kwargs == {} def test_config_object_property_recurse(): c = TestAppConfigObject(sample={ 'a': {'class': __name__ + ':Impl'}, 'c': { 'class': __name__ + ':Impl', '*': ['a', 'b', 'c'], 'd': 4, 'e': 5, 'f': { 'class': __name__ + ':Impl', 'nested': True, 'recursive': { 'class': __name__ + ':Impl', 'nested': True, } }, }, }) v = c.recursive assert isinstance(v, Impl) assert v.args == ('a', 'b', 'c') assert frozenset(v.kwargs) == frozenset({'d', 'e', 'f'}) assert v.kwargs['d'] == 4 assert v.kwargs['e'] == 5 f = v.kwargs['f'] assert isinstance(f, Impl) assert f.args == () assert frozenset(f.kwargs) == frozenset({'nested', 'recursive'}) assert f.kwargs['nested'] is True r = f.kwargs['recursive'] assert isinstance(r, Impl) assert r.args == () assert r.kwargs == {'nested': True} def test_config_object_property_not_dict_error(): c = TestAppConfigObject(sample={'a': 'Not dict'}) with raises(ConfigTypeError): c.no_default def test_config_object_property_no_class_field_error(): c = TestAppConfigObject(sample={'a': {}}) with raises(ConfigValueError): c.no_default def test_config_object_property_invalid_class_field_error(): invalid_syntax = TestAppConfigObject(sample={ 'a': {'class': 'invalid.import.path'}, }) with raises(ConfigValueError): invalid_syntax.no_default invalid_type = TestAppConfigObject(sample={ 'a': {'class': 'os.path:supports_unicode_filenames'}, }) with raises(ConfigValueError): invalid_type.no_default def test_config_object_property_invalid_args_error(): non_list = TestAppConfigObject(sample={ 'a': { 'class': __name__ + ':Impl', '*': 123, # must be a list, but it's an integer, which is wrong }, }) with raises(ConfigValueError): non_list.no_default string = TestAppConfigObject(sample={ 'a': { 'class': __name__ + ':Impl', '*': 'abc', # string is not valid either }, }) with raises(ConfigValueError): string.no_default def test_app_from_file(tmpdir): path = tmpdir.join('cfg.toml') path.write(''' [database] url = "sqlite:///a.db" ''') with path.open() as f: cfg = TestAppConfig.from_file(f) assert cfg.database_url == 'sqlite:///a.db' def test_app_from_path(tmpdir): path = tmpdir.join('cfg.toml') path.write(''' [database] url = "sqlite:///b.db" ''') cfg = TestAppConfig.from_path(pathlib.Path(path.strpath)) assert cfg.database_url == 'sqlite:///b.db' def test_config_object_property_cached(): c = TestAppConfigObject(sample={ 'a': { 'class': __name__ + ':Impl', '*': ['a', 'b', 'c'], 'd': 4, 'e': 5, }, }) assert c.cached is c.cached assert isinstance(c.cached, Impl) assert c.cached.args == ('a', 'b', 'c') assert c.cached.kwargs == {'d': 4, 'e': 5} assert isinstance(c.cached_with_default, Impl) assert c.cached_with_default.args == ('default',) assert c.cached_with_default.kwargs == {} def parse_foo(d: typing.Mapping[str, str]): r = d.copy() r.update({ '*': [int(x) for x in d['*'][0]], 'foo': float(d['foo']), }) return r class TestEnvAppConfig(Configuration): env_list = config_property('foo.list', list, lookup_env=True) env_dict = config_property('foo.dict', dict, lookup_env=True) env_list_recurse = config_property('foo.list_recurse', list, lookup_env=True) env_lookup = config_property('foo.bar', str, lookup_env=True) env_false = config_property('foo.qux', str, lookup_env=False) env_error = config_property('foo.quux', str, lookup_env=True) given_first = config_property('foo.quuz', str, lookup_env=True) parse = config_property('foo.parse', bool, lookup_env=True, parse_env=lambda x: x == 'True') empty_text = config_property('foo.empty', str, lookup_env=True) env_object = config_object_property('foo.obj', SampleInterface) recursiveobj = config_object_property('foo.recurse', SampleInterface, recurse=True) parse_object = config_object_property( 'foo.parse', SampleInterface, parse_env=parse_foo, lookup_env=True ) overlay_with_env = config_property( 'foo.overlay_env', dict, lookup_env=True ) def test_config_property_lookup_env(): with os_environ({ 'FOO__DICT__FOO': 'foo', 'FOO__DICT__BAR': 'bar', 'FOO__LIST__SETTEIENVLIST__0': 'foo', 'FOO__LIST__SETTEIENVLIST__1': 'bar', 'FOO__LIST_RECURSE__SETTEIENVLIST__0__FOO': 'foo', 'FOO__LIST_RECURSE__SETTEIENVLIST__0__BAR': 'bar', 'FOO__LIST_RECURSE__SETTEIENVLIST__1__BAZ': 'baz', 'FOO__LIST_RECURSE__SETTEIENVLIST__2__SETTEIENVLIST__0': 'foo', 'FOO__BAR': 'hi', 'FOO__QUX': 'qux', 'FOO__QUUZ': 'quuz', 'FOO__EMPTY': '', }): c = TestEnvAppConfig(foo={'quuz': 'gl'}) assert c.env_list == ['foo', 'bar'] assert c.env_list_recurse == [ {'foo': 'foo', 'bar': 'bar'}, {'baz': 'baz'}, ['foo'], ] assert c.env_dict == {'foo': 'foo', 'bar': 'bar'} assert c.env_lookup == 'hi', \ 'Get env var when given configuration is missing.' assert c.given_first == 'gl', \ 'Get given configuration even if env var is exist.' # no look up env, no configration = Error with raises(ConfigKeyError): c.env_false # no env, no configration = Error with raises(ConfigKeyError): c.env_error # should allow empty text assert c.empty_text == '' def test_config_property_convert_func(): with os_environ({ 'FOO__PARSE': 'True', }): c = TestEnvAppConfig() assert c.parse with os_environ({ 'FOO__PARSE': 'False', }): c = TestEnvAppConfig() assert not c.parse def test_config_object_property_env(): with os_environ({ 'FOO__OBJ__CLASS': __name__ + ':Impl', 'FOO__OBJ__FOO': 'foo', 'FOO__OBJ__BAR': 'bar', 'FOO__OBJ__BAZ__SETTEIENVLIST__0__FOO': 'foo', 'FOO__OBJ__BAZ__SETTEIENVLIST__0__BAR': 'bar', 'FOO__OBJ__BAZ__SETTEIENVLIST__1__BAZ': 'baz', 'FOO__OBJ__BAZ__SETTEIENVLIST__2__SETTEIENVLIST__0': 'foo', }): c = TestEnvAppConfig() assert c.env_object.kwargs == { 'foo': 'foo', 'bar': 'bar', 'baz': [ {'foo': 'foo', 'bar': 'bar'}, {'baz': 'baz'}, ['foo'], ], } def test_config_object_property_env_recurse(): with os_environ({ 'FOO__RECURSE__CLASS': __name__ + ':Impl', 'FOO__RECURSE__ASTERISK__0': 'lorem', 'FOO__RECURSE__F__CLASS': __name__ + ':Impl', 'FOO__RECURSE__F__NESTED': 'true', 'FOO__RECURSE__F__RECURSIVE__CLASS': __name__ + ':Impl', 'FOO__RECURSE__F__RECURSIVE__NESTED': 'true', 'FOO__RECURSE__F__RECURSIVE__ASTERISK__0': 'hi', 'FOO__RECURSE__F__RECURSIVE__ASTERISK__1': 'mi', 'FOO__RECURSE__F__RECURSIVE__ASTERISK__2': 'me', 'FOO__RECURSE__F__RECURSIVE__ASTERISK__3__SETTEIENVLIST__0': 'you', }): c = TestEnvAppConfig() v = c.recursiveobj assert isinstance(v, Impl) assert frozenset(v.kwargs) == frozenset({'f'}) assert v.args == ('lorem', ) f = v.kwargs['f'] assert isinstance(f, Impl) assert f.args == () assert frozenset(f.kwargs) == frozenset({'nested', 'recursive'}) assert f.kwargs['nested'] == 'true' r = f.kwargs['recursive'] assert isinstance(r, Impl) assert r.args == ('hi', 'mi', 'me', ['you']) assert r.kwargs == {'nested': 'true'} def test_config_object_property_env_parse(): with os_environ({ 'FOO__PARSE__CLASS': __name__ + ':Impl', 'FOO__PARSE__ASTERISK__0': '1', 'FOO__PARSE__FOO': '3.14', }): c = TestEnvAppConfig() assert c.parse_object.args == (1, ) assert c.parse_object.kwargs == {'foo': 3.14} def test_config_property_overlay_env(): with os_environ({'FOO__OVERLAY_ENV__FOO': '1'}): c = TestEnvAppConfig(foo={'overlay_env': {'bar': '2'}}) assert c.overlay_with_env == {'foo': '1', 'bar': '2'} with os_environ({ 'FOO__OVERLAY_ENV__FOO': '1', 'FOO__OVERLAY_ENV__BAR': '2' }): c = TestEnvAppConfig(foo={'overlay_env': {'bar': '3'}}) assert c.overlay_with_env == {'foo': '1', 'bar': '3'}
apache-2.0
[ 646, 4952, 199, 646, 32212, 199, 646, 14090, 221, 327, 8151, 199, 646, 3598, 199, 199, 504, 4613, 492, 2216, 12, 6534, 199, 199, 504, 1275, 1208, 492, 747, 63, 2314, 199, 504, 663, 266, 73, 14, 1095, 492, 334, 2028, 10230, 12, 4094, 4333, 12, 586, 11595, 12, 4094, 3393, 12, 4094, 3849, 12, 586, 1101, 63, 785, 63, 1829, 12, 1101, 63, 1829, 12, 586, 664, 63, 8888, 63, 1313, 9, 421, 199, 533, 11305, 17, 8, 4869, 14, 5081, 304, 272, 1145, 274, 275, 283, 12820, 7, 272, 30354, 6738, 275, 283, 13206, 6738, 7, 272, 12907, 651, 275, 283, 7641, 651, 7, 421, 199, 533, 11305, 18, 8, 4869, 14, 5081, 304, 272, 1145, 274, 275, 283, 12820, 7, 272, 506, 285, 275, 283, 31796, 7, 272, 28269, 89, 275, 283, 67, 460, 89, 7, 421, 199, 318, 511, 63, 362, 63, 8888, 63, 1313, 837, 272, 702, 664, 63, 8888, 63, 1313, 8, 29747, 14, 15540, 59, 442, 12, 620, 566, 508, 334, 442, 12, 620, 9, 272, 702, 664, 63, 8888, 63, 1313, 8, 29747, 14, 15540, 59, 2245, 12, 769, 12, 663, 566, 508, 334, 2245, 12, 769, 12, 663, 9, 272, 702, 664, 63, 8888, 63, 1313, 8, 495, 9, 365, 488, 272, 702, 664, 63, 8888, 63, 1313, 360, 18196, 358, 365, 488, 421, 199, 318, 511, 63, 2491, 63, 1896, 63, 1246, 63, 15390, 837, 272, 492, 663, 266, 73, 272, 702, 663, 266, 73, 14, 5688, 365, 11595, 272, 702, 663, 266, 73, 14, 2028, 3849, 365, 4094, 3849, 272, 702, 663, 266, 73, 14, 888, 63, 1829, 365, 1101, 63, 1829, 421, 199, 533, 1379, 2028, 8, 807, 304, 272, 5818, 17, 63, 2427, 275, 1101, 63, 1829, 360, 498, 297, 1109, 9, 272, 5818, 17, 63, 4144, 275, 1101, 63, 1829, 360, 498, 297, 1109, 12, 849, 13275, 272, 5818, 17, 63, 4050, 275, 1101, 63, 1829, 360, 498, 297, 1109, 12, 849, 4581, 849, 63, 3764, 29, 549, 9, 272, 5818, 17, 63, 885, 63, 1532, 275, 1101, 63, 1829, 8, 267, 283, 498, 297, 1109, 12, 267, 849, 63, 1532, 29, 2734, 291, 26, 291, 14, 4631, 17, 63, 4144, 272, 776, 272, 5818, 17, 63, 885, 63, 1532, 63, 4050, 275, 1101, 63, 1829, 8, 267, 283, 498, 297, 1109, 12, 267, 849, 63, 1532, 29, 2734, 291, 26, 291, 14, 4631, 17, 63, 4144, 12, 267, 849, 63, 3764, 29, 549, 272, 776, 272, 5818, 18, 63, 2427, 275, 1101, 63, 1829, 360, 2792, 14, 498, 297, 620, 9, 272, 5818, 18, 63, 4144, 275, 1101, 63, 1829, 360, 2792, 14, 498, 297, 620, 12, 849, 29, 403, 9, 272, 5818, 18, 63, 4050, 275, 1101, 63, 1829, 360, 2792, 14, 498, 297, 620, 12, 3303, 849, 29, 403, 12, 849, 63, 3764, 29, 549, 9, 272, 13629, 275, 1101, 63, 1829, 360, 8888, 297, 14090, 14, 15540, 59, 442, 12, 620, 566, 421, 199, 533, 11305, 774, 2028, 8, 807, 304, 272, 4952, 275, 1101, 63, 1829, 360, 4869, 297, 11305, 17, 12, 849, 29, 5081, 17, 14, 12820, 9, 272, 4952, 63, 8888, 275, 1101, 63, 1829, 360, 4869, 63, 8888, 297, 14090, 14, 15540, 59, 5081, 17, 12, 11305, 18, 12, 620, 566, 421, 199, 533, 1379, 2640, 2028, 8, 5688, 304, 272, 3050, 63, 633, 275, 1101, 63, 1829, 8, 267, 283, 4659, 14, 633, 297, 620, 12, 267, 849, 534, 10659, 24436, 396, 63, 571, 14, 697, 297, 849, 63, 3764, 29, 549, 272, 776, 421, 199, 32, 1657, 14, 10396, 360, 8888, 63, 585, 297, 359, 4288, 12, 283, 875, 1105, 199, 318, 511, 63, 888, 63, 1829, 8, 8888, 63, 585, 26, 14090, 14, 15540, 59, 442, 12, 620, 4682, 272, 286, 275, 1379, 2028, 8, 498, 29, 4288, 12, 3420, 3713, 498, 356, 283, 637, 2267, 13629, 29, 8888, 63, 585, 9, 272, 702, 286, 14, 4631, 17, 63, 2427, 508, 11869, 272, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 267, 702, 286, 14, 4631, 17, 63, 4144, 508, 11869, 267, 702, 822, 8, 87, 9, 508, 378, 272, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 267, 702, 286, 14, 4631, 17, 63, 4050, 508, 11869, 267, 702, 822, 8, 87, 9, 508, 378, 272, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 267, 702, 286, 14, 4631, 17, 63, 885, 63, 1532, 508, 11869, 267, 702, 822, 8, 87, 9, 508, 378, 272, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 267, 702, 286, 14, 4631, 17, 63, 885, 63, 1532, 63, 4050, 508, 11869, 267, 702, 822, 8, 87, 9, 508, 378, 272, 702, 286, 14, 4631, 18, 63, 2427, 508, 283, 637, 7, 272, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 267, 702, 286, 14, 4631, 18, 63, 4144, 508, 283, 637, 7, 267, 702, 822, 8, 87, 9, 508, 378, 272, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 267, 702, 286, 14, 4631, 18, 63, 4050, 508, 283, 637, 7, 267, 702, 822, 8, 87, 9, 508, 378, 272, 702, 286, 14, 8888, 508, 13629, 63, 585, 421, 199, 318, 511, 63, 4869, 63, 888, 63, 1829, 837, 272, 286, 17, 275, 11305, 774, 2028, 8, 4869, 534, 12820, 297, 4952, 63, 8888, 534, 13206, 6738, 358, 272, 286, 18, 275, 11305, 774, 2028, 8, 4869, 534, 13206, 6738, 297, 4952, 63, 8888, 534, 67, 460, 89, 358, 272, 286, 19, 275, 11305, 774, 2028, 8, 4869, 534, 14479, 265, 4391, 4993, 297, 4952, 63, 8888, 534, 12820, 358, 272, 286, 20, 275, 11305, 774, 2028, 8, 4869, 534, 7641, 651, 297, 4952, 63, 8888, 534, 1421, 358, 272, 702, 286, 17, 14, 4869, 508, 11305, 17, 14, 12820, 272, 702, 286, 18, 14, 4869, 508, 11305, 17, 14, 13206, 6738, 272, 702, 286, 17, 14, 4869, 63, 8888, 508, 11305, 17, 14, 13206, 6738, 272, 702, 286, 18, 14, 4869, 63, 8888, 508, 11305 ]
[ 4952, 199, 646, 32212, 199, 646, 14090, 221, 327, 8151, 199, 646, 3598, 199, 199, 504, 4613, 492, 2216, 12, 6534, 199, 199, 504, 1275, 1208, 492, 747, 63, 2314, 199, 504, 663, 266, 73, 14, 1095, 492, 334, 2028, 10230, 12, 4094, 4333, 12, 586, 11595, 12, 4094, 3393, 12, 4094, 3849, 12, 586, 1101, 63, 785, 63, 1829, 12, 1101, 63, 1829, 12, 586, 664, 63, 8888, 63, 1313, 9, 421, 199, 533, 11305, 17, 8, 4869, 14, 5081, 304, 272, 1145, 274, 275, 283, 12820, 7, 272, 30354, 6738, 275, 283, 13206, 6738, 7, 272, 12907, 651, 275, 283, 7641, 651, 7, 421, 199, 533, 11305, 18, 8, 4869, 14, 5081, 304, 272, 1145, 274, 275, 283, 12820, 7, 272, 506, 285, 275, 283, 31796, 7, 272, 28269, 89, 275, 283, 67, 460, 89, 7, 421, 199, 318, 511, 63, 362, 63, 8888, 63, 1313, 837, 272, 702, 664, 63, 8888, 63, 1313, 8, 29747, 14, 15540, 59, 442, 12, 620, 566, 508, 334, 442, 12, 620, 9, 272, 702, 664, 63, 8888, 63, 1313, 8, 29747, 14, 15540, 59, 2245, 12, 769, 12, 663, 566, 508, 334, 2245, 12, 769, 12, 663, 9, 272, 702, 664, 63, 8888, 63, 1313, 8, 495, 9, 365, 488, 272, 702, 664, 63, 8888, 63, 1313, 360, 18196, 358, 365, 488, 421, 199, 318, 511, 63, 2491, 63, 1896, 63, 1246, 63, 15390, 837, 272, 492, 663, 266, 73, 272, 702, 663, 266, 73, 14, 5688, 365, 11595, 272, 702, 663, 266, 73, 14, 2028, 3849, 365, 4094, 3849, 272, 702, 663, 266, 73, 14, 888, 63, 1829, 365, 1101, 63, 1829, 421, 199, 533, 1379, 2028, 8, 807, 304, 272, 5818, 17, 63, 2427, 275, 1101, 63, 1829, 360, 498, 297, 1109, 9, 272, 5818, 17, 63, 4144, 275, 1101, 63, 1829, 360, 498, 297, 1109, 12, 849, 13275, 272, 5818, 17, 63, 4050, 275, 1101, 63, 1829, 360, 498, 297, 1109, 12, 849, 4581, 849, 63, 3764, 29, 549, 9, 272, 5818, 17, 63, 885, 63, 1532, 275, 1101, 63, 1829, 8, 267, 283, 498, 297, 1109, 12, 267, 849, 63, 1532, 29, 2734, 291, 26, 291, 14, 4631, 17, 63, 4144, 272, 776, 272, 5818, 17, 63, 885, 63, 1532, 63, 4050, 275, 1101, 63, 1829, 8, 267, 283, 498, 297, 1109, 12, 267, 849, 63, 1532, 29, 2734, 291, 26, 291, 14, 4631, 17, 63, 4144, 12, 267, 849, 63, 3764, 29, 549, 272, 776, 272, 5818, 18, 63, 2427, 275, 1101, 63, 1829, 360, 2792, 14, 498, 297, 620, 9, 272, 5818, 18, 63, 4144, 275, 1101, 63, 1829, 360, 2792, 14, 498, 297, 620, 12, 849, 29, 403, 9, 272, 5818, 18, 63, 4050, 275, 1101, 63, 1829, 360, 2792, 14, 498, 297, 620, 12, 3303, 849, 29, 403, 12, 849, 63, 3764, 29, 549, 9, 272, 13629, 275, 1101, 63, 1829, 360, 8888, 297, 14090, 14, 15540, 59, 442, 12, 620, 566, 421, 199, 533, 11305, 774, 2028, 8, 807, 304, 272, 4952, 275, 1101, 63, 1829, 360, 4869, 297, 11305, 17, 12, 849, 29, 5081, 17, 14, 12820, 9, 272, 4952, 63, 8888, 275, 1101, 63, 1829, 360, 4869, 63, 8888, 297, 14090, 14, 15540, 59, 5081, 17, 12, 11305, 18, 12, 620, 566, 421, 199, 533, 1379, 2640, 2028, 8, 5688, 304, 272, 3050, 63, 633, 275, 1101, 63, 1829, 8, 267, 283, 4659, 14, 633, 297, 620, 12, 267, 849, 534, 10659, 24436, 396, 63, 571, 14, 697, 297, 849, 63, 3764, 29, 549, 272, 776, 421, 199, 32, 1657, 14, 10396, 360, 8888, 63, 585, 297, 359, 4288, 12, 283, 875, 1105, 199, 318, 511, 63, 888, 63, 1829, 8, 8888, 63, 585, 26, 14090, 14, 15540, 59, 442, 12, 620, 4682, 272, 286, 275, 1379, 2028, 8, 498, 29, 4288, 12, 3420, 3713, 498, 356, 283, 637, 2267, 13629, 29, 8888, 63, 585, 9, 272, 702, 286, 14, 4631, 17, 63, 2427, 508, 11869, 272, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 267, 702, 286, 14, 4631, 17, 63, 4144, 508, 11869, 267, 702, 822, 8, 87, 9, 508, 378, 272, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 267, 702, 286, 14, 4631, 17, 63, 4050, 508, 11869, 267, 702, 822, 8, 87, 9, 508, 378, 272, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 267, 702, 286, 14, 4631, 17, 63, 885, 63, 1532, 508, 11869, 267, 702, 822, 8, 87, 9, 508, 378, 272, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 267, 702, 286, 14, 4631, 17, 63, 885, 63, 1532, 63, 4050, 508, 11869, 267, 702, 822, 8, 87, 9, 508, 378, 272, 702, 286, 14, 4631, 18, 63, 2427, 508, 283, 637, 7, 272, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 267, 702, 286, 14, 4631, 18, 63, 4144, 508, 283, 637, 7, 267, 702, 822, 8, 87, 9, 508, 378, 272, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 267, 702, 286, 14, 4631, 18, 63, 4050, 508, 283, 637, 7, 267, 702, 822, 8, 87, 9, 508, 378, 272, 702, 286, 14, 8888, 508, 13629, 63, 585, 421, 199, 318, 511, 63, 4869, 63, 888, 63, 1829, 837, 272, 286, 17, 275, 11305, 774, 2028, 8, 4869, 534, 12820, 297, 4952, 63, 8888, 534, 13206, 6738, 358, 272, 286, 18, 275, 11305, 774, 2028, 8, 4869, 534, 13206, 6738, 297, 4952, 63, 8888, 534, 67, 460, 89, 358, 272, 286, 19, 275, 11305, 774, 2028, 8, 4869, 534, 14479, 265, 4391, 4993, 297, 4952, 63, 8888, 534, 12820, 358, 272, 286, 20, 275, 11305, 774, 2028, 8, 4869, 534, 7641, 651, 297, 4952, 63, 8888, 534, 1421, 358, 272, 702, 286, 17, 14, 4869, 508, 11305, 17, 14, 12820, 272, 702, 286, 18, 14, 4869, 508, 11305, 17, 14, 13206, 6738, 272, 702, 286, 17, 14, 4869, 63, 8888, 508, 11305, 17, 14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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
markshao/pytest
testing/test_runner_xunit.py
2
7526
""" test correct setup/teardowns at module, class, and instance level """ import pytest def test_module_and_function_setup(testdir): reprec = testdir.inline_runsource( """ modlevel = [] def setup_module(module): assert not modlevel module.modlevel.append(42) def teardown_module(module): modlevel.pop() def setup_function(function): function.answer = 17 def teardown_function(function): del function.answer def test_modlevel(): assert modlevel[0] == 42 assert test_modlevel.answer == 17 class TestFromClass(object): def test_module(self): assert modlevel[0] == 42 assert not hasattr(test_modlevel, 'answer') """ ) rep = reprec.matchreport("test_modlevel") assert rep.passed rep = reprec.matchreport("test_module") assert rep.passed def test_module_setup_failure_no_teardown(testdir): reprec = testdir.inline_runsource( """ values = [] def setup_module(module): values.append(1) 0/0 def test_nothing(): pass def teardown_module(module): values.append(2) """ ) reprec.assertoutcome(failed=1) calls = reprec.getcalls("pytest_runtest_setup") assert calls[0].item.module.values == [1] def test_setup_function_failure_no_teardown(testdir): reprec = testdir.inline_runsource( """ modlevel = [] def setup_function(function): modlevel.append(1) 0/0 def teardown_function(module): modlevel.append(2) def test_func(): pass """ ) calls = reprec.getcalls("pytest_runtest_setup") assert calls[0].item.module.modlevel == [1] def test_class_setup(testdir): reprec = testdir.inline_runsource( """ class TestSimpleClassSetup(object): clslevel = [] def setup_class(cls): cls.clslevel.append(23) def teardown_class(cls): cls.clslevel.pop() def test_classlevel(self): assert self.clslevel[0] == 23 class TestInheritedClassSetupStillWorks(TestSimpleClassSetup): def test_classlevel_anothertime(self): assert self.clslevel == [23] def test_cleanup(): assert not TestSimpleClassSetup.clslevel assert not TestInheritedClassSetupStillWorks.clslevel """ ) reprec.assertoutcome(passed=1 + 2 + 1) def test_class_setup_failure_no_teardown(testdir): reprec = testdir.inline_runsource( """ class TestSimpleClassSetup(object): clslevel = [] def setup_class(cls): 0/0 def teardown_class(cls): cls.clslevel.append(1) def test_classlevel(self): pass def test_cleanup(): assert not TestSimpleClassSetup.clslevel """ ) reprec.assertoutcome(failed=1, passed=1) def test_method_setup(testdir): reprec = testdir.inline_runsource( """ class TestSetupMethod(object): def setup_method(self, meth): self.methsetup = meth def teardown_method(self, meth): del self.methsetup def test_some(self): assert self.methsetup == self.test_some def test_other(self): assert self.methsetup == self.test_other """ ) reprec.assertoutcome(passed=2) def test_method_setup_failure_no_teardown(testdir): reprec = testdir.inline_runsource( """ class TestMethodSetup(object): clslevel = [] def setup_method(self, method): self.clslevel.append(1) 0/0 def teardown_method(self, method): self.clslevel.append(2) def test_method(self): pass def test_cleanup(): assert TestMethodSetup.clslevel == [1] """ ) reprec.assertoutcome(failed=1, passed=1) def test_method_setup_uses_fresh_instances(testdir): reprec = testdir.inline_runsource( """ class TestSelfState1(object): memory = [] def test_hello(self): self.memory.append(self) def test_afterhello(self): assert self != self.memory[0] """ ) reprec.assertoutcome(passed=2, failed=0) def test_setup_that_skips_calledagain(testdir): p = testdir.makepyfile( """ import pytest def setup_module(mod): pytest.skip("x") def test_function1(): pass def test_function2(): pass """ ) reprec = testdir.inline_run(p) reprec.assertoutcome(skipped=2) def test_setup_fails_again_on_all_tests(testdir): p = testdir.makepyfile( """ import pytest def setup_module(mod): raise ValueError(42) def test_function1(): pass def test_function2(): pass """ ) reprec = testdir.inline_run(p) reprec.assertoutcome(failed=2) def test_setup_funcarg_setup_when_outer_scope_fails(testdir): p = testdir.makepyfile( """ import pytest def setup_module(mod): raise ValueError(42) @pytest.fixture def hello(request): raise ValueError("xyz43") def test_function1(hello): pass def test_function2(hello): pass """ ) result = testdir.runpytest(p) result.stdout.fnmatch_lines( [ "*function1*", "*ValueError*42*", "*function2*", "*ValueError*42*", "*2 errors*", ] ) result.stdout.no_fnmatch_line("*xyz43*") @pytest.mark.parametrize("arg", ["", "arg"]) def test_setup_teardown_function_level_with_optional_argument( testdir, monkeypatch, arg ): """parameter to setup/teardown xunit-style functions parameter is now optional (#1728).""" import sys trace_setups_teardowns = [] monkeypatch.setattr( sys, "trace_setups_teardowns", trace_setups_teardowns, raising=False ) p = testdir.makepyfile( """ import pytest import sys trace = sys.trace_setups_teardowns.append def setup_module({arg}): trace('setup_module') def teardown_module({arg}): trace('teardown_module') def setup_function({arg}): trace('setup_function') def teardown_function({arg}): trace('teardown_function') def test_function_1(): pass def test_function_2(): pass class Test(object): def setup_method(self, {arg}): trace('setup_method') def teardown_method(self, {arg}): trace('teardown_method') def test_method_1(self): pass def test_method_2(self): pass """.format( arg=arg ) ) result = testdir.inline_run(p) result.assertoutcome(passed=4) expected = [ "setup_module", "setup_function", "teardown_function", "setup_function", "teardown_function", "setup_method", "teardown_method", "setup_method", "teardown_method", "teardown_module", ] assert trace_setups_teardowns == expected
mit
[ 624, 199, 511, 3211, 3272, 15, 266, 1005, 23311, 737, 199, 859, 12, 1021, 12, 436, 1256, 2166, 199, 624, 199, 646, 4613, 421, 199, 318, 511, 63, 578, 63, 460, 63, 1593, 63, 2758, 8, 16634, 304, 272, 22571, 275, 7368, 14, 6460, 63, 1065, 1365, 8, 267, 408, 267, 3413, 1896, 275, 942, 267, 347, 3272, 63, 578, 8, 578, 304, 288, 702, 440, 3413, 1896, 288, 859, 14, 1494, 1896, 14, 740, 8, 2260, 9, 398, 347, 17558, 63, 578, 8, 578, 304, 288, 3413, 1896, 14, 1935, 342, 398, 347, 3272, 63, 1593, 8, 1593, 304, 288, 805, 14, 5934, 275, 5557, 398, 347, 17558, 63, 1593, 8, 1593, 304, 288, 2150, 805, 14, 5934, 398, 347, 511, 63, 1494, 1896, 837, 288, 702, 3413, 1896, 59, 16, 61, 508, 5685, 288, 702, 511, 63, 1494, 1896, 14, 5934, 508, 5557, 398, 1021, 1379, 2532, 2543, 8, 785, 304, 288, 347, 511, 63, 578, 8, 277, 304, 355, 702, 3413, 1896, 59, 16, 61, 508, 5685, 355, 702, 440, 2688, 8, 396, 63, 1494, 1896, 12, 283, 5934, 358, 272, 408, 272, 776, 272, 1833, 275, 22571, 14, 1431, 3070, 480, 396, 63, 1494, 1896, 531, 272, 702, 1833, 14, 12070, 272, 1833, 275, 22571, 14, 1431, 3070, 480, 396, 63, 578, 531, 272, 702, 1833, 14, 12070, 421, 199, 318, 511, 63, 578, 63, 2758, 63, 5328, 63, 889, 63, 15236, 8, 16634, 304, 272, 22571, 275, 7368, 14, 6460, 63, 1065, 1365, 8, 267, 408, 267, 1338, 275, 942, 267, 347, 3272, 63, 578, 8, 578, 304, 288, 1338, 14, 740, 8, 17, 9, 288, 378, 15, 16, 398, 347, 511, 63, 16323, 837, 288, 986, 398, 347, 17558, 63, 578, 8, 578, 304, 288, 1338, 14, 740, 8, 18, 9, 272, 408, 272, 776, 272, 22571, 14, 479, 17502, 8, 4892, 29, 17, 9, 272, 4882, 275, 22571, 14, 362, 5352, 480, 4462, 63, 1065, 396, 63, 2758, 531, 272, 702, 4882, 59, 16, 1055, 1053, 14, 578, 14, 1459, 508, 359, 17, 61, 421, 199, 318, 511, 63, 2758, 63, 1593, 63, 5328, 63, 889, 63, 15236, 8, 16634, 304, 272, 22571, 275, 7368, 14, 6460, 63, 1065, 1365, 8, 267, 408, 267, 3413, 1896, 275, 942, 267, 347, 3272, 63, 1593, 8, 1593, 304, 288, 3413, 1896, 14, 740, 8, 17, 9, 288, 378, 15, 16, 398, 347, 17558, 63, 1593, 8, 578, 304, 288, 3413, 1896, 14, 740, 8, 18, 9, 398, 347, 511, 63, 1532, 837, 288, 986, 272, 408, 272, 776, 272, 4882, 275, 22571, 14, 362, 5352, 480, 4462, 63, 1065, 396, 63, 2758, 531, 272, 702, 4882, 59, 16, 1055, 1053, 14, 578, 14, 1494, 1896, 508, 359, 17, 61, 421, 199, 318, 511, 63, 533, 63, 2758, 8, 16634, 304, 272, 22571, 275, 7368, 14, 6460, 63, 1065, 1365, 8, 267, 408, 267, 1021, 1379, 3184, 2543, 8555, 8, 785, 304, 288, 843, 1896, 275, 942, 288, 347, 3272, 63, 533, 8, 1886, 304, 355, 843, 14, 1886, 1896, 14, 740, 8, 1789, 9, 953, 347, 17558, 63, 533, 8, 1886, 304, 355, 843, 14, 1886, 1896, 14, 1935, 342, 953, 347, 511, 63, 533, 1896, 8, 277, 304, 355, 702, 291, 14, 1886, 1896, 59, 16, 61, 508, 6546, 398, 1021, 1379, 607, 8829, 2543, 8555, 51, 12587, 25348, 8, 774, 3184, 2543, 8555, 304, 288, 347, 511, 63, 533, 1896, 63, 13565, 521, 8, 277, 304, 355, 702, 291, 14, 1886, 1896, 508, 359, 1789, 61, 398, 347, 511, 63, 7661, 837, 288, 702, 440, 1379, 3184, 2543, 8555, 14, 1886, 1896, 288, 702, 440, 1379, 607, 8829, 2543, 8555, 51, 12587, 25348, 14, 1886, 1896, 272, 408, 272, 776, 272, 22571, 14, 479, 17502, 8, 12070, 29, 17, 435, 499, 435, 413, 9, 421, 199, 318, 511, 63, 533, 63, 2758, 63, 5328, 63, 889, 63, 15236, 8, 16634, 304, 272, 22571, 275, 7368, 14, 6460, 63, 1065, 1365, 8, 267, 408, 267, 1021, 1379, 3184, 2543, 8555, 8, 785, 304, 288, 843, 1896, 275, 942, 288, 347, 3272, 63, 533, 8, 1886, 304, 355, 378, 15, 16, 953, 347, 17558, 63, 533, 8, 1886, 304, 355, 843, 14, 1886, 1896, 14, 740, 8, 17, 9, 953, 347, 511, 63, 533, 1896, 8, 277, 304, 355, 986, 398, 347, 511, 63, 7661, 837, 288, 702, 440, 1379, 3184, 2543, 8555, 14, 1886, 1896, 272, 408, 272, 776, 272, 22571, 14, 479, 17502, 8, 4892, 29, 17, 12, 3032, 29, 17, 9, 421, 199, 318, 511, 63, 765, 63, 2758, 8, 16634, 304, 272, 22571, 275, 7368, 14, 6460, 63, 1065, 1365, 8, 267, 408, 267, 1021, 1379, 8555, 3767, 8, 785, 304, 288, 347, 3272, 63, 765, 8, 277, 12, 12750, 304, 355, 291, 14, 5247, 2758, 275, 12750, 288, 347, 17558, 63, 765, 8, 277, 12, 12750, 304, 355, 2150, 291, 14, 5247, 2758, 953, 347, 511, 63, 3972, 8, 277, 304, 355, 702, 291, 14, 5247, 2758, 508, 291, 14, 396, 63, 3972, 953, 347, 511, 63, 1848, 8, 277, 304, 355, 702, 291, 14, 5247, 2758, 508, 291, 14, 396, 63, 1848, 272, 408, 272, 776, 272, 22571, 14, 479, 17502, 8, 12070, 29, 18, 9, 421, 199, 318, 511, 63, 765, 63, 2758, 63, 5328, 63, 889, 63, 15236, 8, 16634, 304, 272, 22571, 275, 7368, 14, 6460, 63, 1065, 1365, 8, 267, 408, 267, 1021, 1379, 3767, 8555, 8, 785, 304, 288, 843, 1896, 275, 942, 288, 347, 3272, 63, 765, 8, 277, 12, 1083, 304, 355, 291, 14, 1886, 1896, 14, 740, 8, 17, 9, 355, 378, 15, 16, 953, 347, 17558, 63, 765, 8, 277, 12, 1083, 304, 355, 291, 14, 1886, 1896, 14, 740, 8, 18, 9, 953, 347, 511, 63, 765, 8, 277, 304, 355, 986, 398, 347, 511, 63, 7661, 837, 288, 702, 1379, 3767, 8555, 14, 1886, 1896, 508, 359, 17, 61, 272, 408, 272, 776, 272, 22571, 14, 479, 17502, 8, 4892, 29, 17, 12, 3032, 29, 17, 9, 421, 199, 318, 511, 63, 765, 63, 2758, 63, 5589, 63, 25488, 63, 5990, 8, 16634, 304, 272, 22571, 275, 7368, 14, 6460, 63, 1065 ]
[ 199, 511, 3211, 3272, 15, 266, 1005, 23311, 737, 199, 859, 12, 1021, 12, 436, 1256, 2166, 199, 624, 199, 646, 4613, 421, 199, 318, 511, 63, 578, 63, 460, 63, 1593, 63, 2758, 8, 16634, 304, 272, 22571, 275, 7368, 14, 6460, 63, 1065, 1365, 8, 267, 408, 267, 3413, 1896, 275, 942, 267, 347, 3272, 63, 578, 8, 578, 304, 288, 702, 440, 3413, 1896, 288, 859, 14, 1494, 1896, 14, 740, 8, 2260, 9, 398, 347, 17558, 63, 578, 8, 578, 304, 288, 3413, 1896, 14, 1935, 342, 398, 347, 3272, 63, 1593, 8, 1593, 304, 288, 805, 14, 5934, 275, 5557, 398, 347, 17558, 63, 1593, 8, 1593, 304, 288, 2150, 805, 14, 5934, 398, 347, 511, 63, 1494, 1896, 837, 288, 702, 3413, 1896, 59, 16, 61, 508, 5685, 288, 702, 511, 63, 1494, 1896, 14, 5934, 508, 5557, 398, 1021, 1379, 2532, 2543, 8, 785, 304, 288, 347, 511, 63, 578, 8, 277, 304, 355, 702, 3413, 1896, 59, 16, 61, 508, 5685, 355, 702, 440, 2688, 8, 396, 63, 1494, 1896, 12, 283, 5934, 358, 272, 408, 272, 776, 272, 1833, 275, 22571, 14, 1431, 3070, 480, 396, 63, 1494, 1896, 531, 272, 702, 1833, 14, 12070, 272, 1833, 275, 22571, 14, 1431, 3070, 480, 396, 63, 578, 531, 272, 702, 1833, 14, 12070, 421, 199, 318, 511, 63, 578, 63, 2758, 63, 5328, 63, 889, 63, 15236, 8, 16634, 304, 272, 22571, 275, 7368, 14, 6460, 63, 1065, 1365, 8, 267, 408, 267, 1338, 275, 942, 267, 347, 3272, 63, 578, 8, 578, 304, 288, 1338, 14, 740, 8, 17, 9, 288, 378, 15, 16, 398, 347, 511, 63, 16323, 837, 288, 986, 398, 347, 17558, 63, 578, 8, 578, 304, 288, 1338, 14, 740, 8, 18, 9, 272, 408, 272, 776, 272, 22571, 14, 479, 17502, 8, 4892, 29, 17, 9, 272, 4882, 275, 22571, 14, 362, 5352, 480, 4462, 63, 1065, 396, 63, 2758, 531, 272, 702, 4882, 59, 16, 1055, 1053, 14, 578, 14, 1459, 508, 359, 17, 61, 421, 199, 318, 511, 63, 2758, 63, 1593, 63, 5328, 63, 889, 63, 15236, 8, 16634, 304, 272, 22571, 275, 7368, 14, 6460, 63, 1065, 1365, 8, 267, 408, 267, 3413, 1896, 275, 942, 267, 347, 3272, 63, 1593, 8, 1593, 304, 288, 3413, 1896, 14, 740, 8, 17, 9, 288, 378, 15, 16, 398, 347, 17558, 63, 1593, 8, 578, 304, 288, 3413, 1896, 14, 740, 8, 18, 9, 398, 347, 511, 63, 1532, 837, 288, 986, 272, 408, 272, 776, 272, 4882, 275, 22571, 14, 362, 5352, 480, 4462, 63, 1065, 396, 63, 2758, 531, 272, 702, 4882, 59, 16, 1055, 1053, 14, 578, 14, 1494, 1896, 508, 359, 17, 61, 421, 199, 318, 511, 63, 533, 63, 2758, 8, 16634, 304, 272, 22571, 275, 7368, 14, 6460, 63, 1065, 1365, 8, 267, 408, 267, 1021, 1379, 3184, 2543, 8555, 8, 785, 304, 288, 843, 1896, 275, 942, 288, 347, 3272, 63, 533, 8, 1886, 304, 355, 843, 14, 1886, 1896, 14, 740, 8, 1789, 9, 953, 347, 17558, 63, 533, 8, 1886, 304, 355, 843, 14, 1886, 1896, 14, 1935, 342, 953, 347, 511, 63, 533, 1896, 8, 277, 304, 355, 702, 291, 14, 1886, 1896, 59, 16, 61, 508, 6546, 398, 1021, 1379, 607, 8829, 2543, 8555, 51, 12587, 25348, 8, 774, 3184, 2543, 8555, 304, 288, 347, 511, 63, 533, 1896, 63, 13565, 521, 8, 277, 304, 355, 702, 291, 14, 1886, 1896, 508, 359, 1789, 61, 398, 347, 511, 63, 7661, 837, 288, 702, 440, 1379, 3184, 2543, 8555, 14, 1886, 1896, 288, 702, 440, 1379, 607, 8829, 2543, 8555, 51, 12587, 25348, 14, 1886, 1896, 272, 408, 272, 776, 272, 22571, 14, 479, 17502, 8, 12070, 29, 17, 435, 499, 435, 413, 9, 421, 199, 318, 511, 63, 533, 63, 2758, 63, 5328, 63, 889, 63, 15236, 8, 16634, 304, 272, 22571, 275, 7368, 14, 6460, 63, 1065, 1365, 8, 267, 408, 267, 1021, 1379, 3184, 2543, 8555, 8, 785, 304, 288, 843, 1896, 275, 942, 288, 347, 3272, 63, 533, 8, 1886, 304, 355, 378, 15, 16, 953, 347, 17558, 63, 533, 8, 1886, 304, 355, 843, 14, 1886, 1896, 14, 740, 8, 17, 9, 953, 347, 511, 63, 533, 1896, 8, 277, 304, 355, 986, 398, 347, 511, 63, 7661, 837, 288, 702, 440, 1379, 3184, 2543, 8555, 14, 1886, 1896, 272, 408, 272, 776, 272, 22571, 14, 479, 17502, 8, 4892, 29, 17, 12, 3032, 29, 17, 9, 421, 199, 318, 511, 63, 765, 63, 2758, 8, 16634, 304, 272, 22571, 275, 7368, 14, 6460, 63, 1065, 1365, 8, 267, 408, 267, 1021, 1379, 8555, 3767, 8, 785, 304, 288, 347, 3272, 63, 765, 8, 277, 12, 12750, 304, 355, 291, 14, 5247, 2758, 275, 12750, 288, 347, 17558, 63, 765, 8, 277, 12, 12750, 304, 355, 2150, 291, 14, 5247, 2758, 953, 347, 511, 63, 3972, 8, 277, 304, 355, 702, 291, 14, 5247, 2758, 508, 291, 14, 396, 63, 3972, 953, 347, 511, 63, 1848, 8, 277, 304, 355, 702, 291, 14, 5247, 2758, 508, 291, 14, 396, 63, 1848, 272, 408, 272, 776, 272, 22571, 14, 479, 17502, 8, 12070, 29, 18, 9, 421, 199, 318, 511, 63, 765, 63, 2758, 63, 5328, 63, 889, 63, 15236, 8, 16634, 304, 272, 22571, 275, 7368, 14, 6460, 63, 1065, 1365, 8, 267, 408, 267, 1021, 1379, 3767, 8555, 8, 785, 304, 288, 843, 1896, 275, 942, 288, 347, 3272, 63, 765, 8, 277, 12, 1083, 304, 355, 291, 14, 1886, 1896, 14, 740, 8, 17, 9, 355, 378, 15, 16, 953, 347, 17558, 63, 765, 8, 277, 12, 1083, 304, 355, 291, 14, 1886, 1896, 14, 740, 8, 18, 9, 953, 347, 511, 63, 765, 8, 277, 304, 355, 986, 398, 347, 511, 63, 7661, 837, 288, 702, 1379, 3767, 8555, 14, 1886, 1896, 508, 359, 17, 61, 272, 408, 272, 776, 272, 22571, 14, 479, 17502, 8, 4892, 29, 17, 12, 3032, 29, 17, 9, 421, 199, 318, 511, 63, 765, 63, 2758, 63, 5589, 63, 25488, 63, 5990, 8, 16634, 304, 272, 22571, 275, 7368, 14, 6460, 63, 1065, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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/env python2 # vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai from __future__ import (unicode_literals, division, absolute_import, print_function) __license__ = 'GPL v3' __copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>' __docformat__ = 'restructuredtext en' def base64_decode(raw): from io import BytesIO from base64 import b64decode # First try the python implementation as it is faster try: return b64decode(raw) except TypeError: pass # Try a more robust version (adapted from FBReader sources) A, Z, a, z, zero, nine, plus, slash, equal = bytearray(b'AZaz09+/=') raw = bytearray(raw) out = BytesIO() pos = 0 while pos < len(raw): tot = 0 i = 0 while i < 4 and pos < len(raw): byt = raw[pos] pos += 1 num = 0 if A <= byt <= Z: num = byt - A elif a <= byt <= z: num = byt - a + 26 elif zero <= byt <= nine: num = byt - zero + 52 else: num = {plus:62, slash:63, equal:64}.get(byt, None) if num is None: # Ignore this byte continue tot += num << (6 * (3 - i)) i += 1 triple = bytearray(3) for j in (2, 1, 0): triple[j] = tot & 0xff tot >>= 8 out.write(bytes(triple)) return out.getvalue()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 6695, 26, 493, 2991, 29, 6610, 13, 24, 26, 1086, 29, 20, 26, 3519, 29, 20, 26, 1207, 26, 386, 26, 10329, 29, 20, 26, 5789, 199, 504, 636, 2443, 363, 492, 334, 2975, 63, 5955, 12, 4629, 12, 3679, 63, 646, 12, 717, 870, 63, 1593, 9, 199, 199, 363, 1682, 363, 257, 275, 283, 12006, 373, 19, 7, 199, 363, 7307, 363, 275, 283, 7409, 12, 1804, 79, 5017, 3971, 31876, 665, 7697, 5017, 32, 7697, 5017, 1939, 31876, 14, 846, 3524, 199, 363, 21841, 363, 275, 283, 26854, 655, 7, 199, 199, 318, 1300, 772, 63, 2708, 8, 1773, 304, 272, 687, 5890, 492, 11808, 272, 687, 1300, 772, 492, 330, 772, 2708, 339, 327, 7758, 862, 314, 2366, 4514, 465, 652, 365, 12930, 272, 862, 26, 267, 372, 330, 772, 2708, 8, 1773, 9, 272, 871, 3146, 26, 267, 986, 339, 327, 7649, 282, 1655, 23399, 1015, 334, 350, 18309, 687, 481, 34, 5929, 5274, 9, 272, 437, 12, 3107, 12, 282, 12, 1315, 12, 4697, 12, 302, 1132, 12, 12254, 12, 14457, 12, 4472, 275, 11640, 8, 66, 7, 17613, 4651, 1643, 19616, 14619, 272, 3066, 275, 11640, 8, 1773, 9, 272, 734, 275, 11808, 342, 272, 2086, 275, 378, 272, 1830, 2086, 665, 822, 8, 1773, 304, 267, 12657, 275, 378, 267, 284, 275, 378, 267, 1830, 284, 665, 841, 436, 2086, 665, 822, 8, 1773, 304, 288, 701, 84, 275, 3066, 59, 1712, 61, 288, 2086, 847, 413, 288, 1967, 275, 378, 288, 340, 437, 2695, 701, 84, 2695, 3107, 26, 355, 1967, 275, 701, 84, 446, 437, 288, 916, 282, 2695, 701, 84, 2695, 1315, 26, 355, 1967, 275, 701, 84, 446, 282, 435, 7875, 288, 916, 4697, 2695, 701, 84, 2695, 302, 1132, 26, 355, 1967, 275, 701, 84, 446, 4697, 435, 14589, 288, 587, 26, 355, 1967, 275, 469, 6666, 26, 2789, 12, 14457, 26, 2766, 12, 4472, 26, 772, 5565, 362, 8, 991, 84, 12, 488, 9, 355, 340, 1967, 365, 488, 26, 490, 327, 14092, 642, 3696, 490, 1980, 288, 12657, 847, 1967, 5213, 334, 22, 627, 334, 19, 446, 284, 430, 288, 284, 847, 413, 267, 19671, 275, 11640, 8, 19, 9, 267, 367, 1335, 315, 334, 18, 12, 413, 12, 378, 304, 288, 19671, 59, 74, 61, 275, 12657, 1253, 378, 3581, 288, 12657, 4331, 29, 1695, 267, 734, 14, 952, 8, 2394, 8, 19956, 430, 272, 372, 734, 14, 7150, 342, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 18, 199, 3, 6695, 26, 493, 2991, 29, 6610, 13, 24, 26, 1086, 29, 20, 26, 3519, 29, 20, 26, 1207, 26, 386, 26, 10329, 29, 20, 26, 5789, 199, 504, 636, 2443, 363, 492, 334, 2975, 63, 5955, 12, 4629, 12, 3679, 63, 646, 12, 717, 870, 63, 1593, 9, 199, 199, 363, 1682, 363, 257, 275, 283, 12006, 373, 19, 7, 199, 363, 7307, 363, 275, 283, 7409, 12, 1804, 79, 5017, 3971, 31876, 665, 7697, 5017, 32, 7697, 5017, 1939, 31876, 14, 846, 3524, 199, 363, 21841, 363, 275, 283, 26854, 655, 7, 199, 199, 318, 1300, 772, 63, 2708, 8, 1773, 304, 272, 687, 5890, 492, 11808, 272, 687, 1300, 772, 492, 330, 772, 2708, 339, 327, 7758, 862, 314, 2366, 4514, 465, 652, 365, 12930, 272, 862, 26, 267, 372, 330, 772, 2708, 8, 1773, 9, 272, 871, 3146, 26, 267, 986, 339, 327, 7649, 282, 1655, 23399, 1015, 334, 350, 18309, 687, 481, 34, 5929, 5274, 9, 272, 437, 12, 3107, 12, 282, 12, 1315, 12, 4697, 12, 302, 1132, 12, 12254, 12, 14457, 12, 4472, 275, 11640, 8, 66, 7, 17613, 4651, 1643, 19616, 14619, 272, 3066, 275, 11640, 8, 1773, 9, 272, 734, 275, 11808, 342, 272, 2086, 275, 378, 272, 1830, 2086, 665, 822, 8, 1773, 304, 267, 12657, 275, 378, 267, 284, 275, 378, 267, 1830, 284, 665, 841, 436, 2086, 665, 822, 8, 1773, 304, 288, 701, 84, 275, 3066, 59, 1712, 61, 288, 2086, 847, 413, 288, 1967, 275, 378, 288, 340, 437, 2695, 701, 84, 2695, 3107, 26, 355, 1967, 275, 701, 84, 446, 437, 288, 916, 282, 2695, 701, 84, 2695, 1315, 26, 355, 1967, 275, 701, 84, 446, 282, 435, 7875, 288, 916, 4697, 2695, 701, 84, 2695, 302, 1132, 26, 355, 1967, 275, 701, 84, 446, 4697, 435, 14589, 288, 587, 26, 355, 1967, 275, 469, 6666, 26, 2789, 12, 14457, 26, 2766, 12, 4472, 26, 772, 5565, 362, 8, 991, 84, 12, 488, 9, 355, 340, 1967, 365, 488, 26, 490, 327, 14092, 642, 3696, 490, 1980, 288, 12657, 847, 1967, 5213, 334, 22, 627, 334, 19, 446, 284, 430, 288, 284, 847, 413, 267, 19671, 275, 11640, 8, 19, 9, 267, 367, 1335, 315, 334, 18, 12, 413, 12, 378, 304, 288, 19671, 59, 74, 61, 275, 12657, 1253, 378, 3581, 288, 12657, 4331, 29, 1695, 267, 734, 14, 952, 8, 2394, 8, 19956, 430, 272, 372, 734, 14, 7150, 342, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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eug/local.py
97
14123
# -*- coding: utf-8 -*- """ werkzeug.local ~~~~~~~~~~~~~~ This module implements context-local objects. :copyright: (c) 2014 by the Werkzeug Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ from functools import update_wrapper from werkzeug.wsgi import ClosingIterator from werkzeug._compat import PY2, implements_bool # since each thread has its own greenlet we can just use those as identifiers # for the context. If greenlets are not available we fall back to the # current thread ident depending on where it is. try: from greenlet import getcurrent as get_ident except ImportError: try: from thread import get_ident except ImportError: from _thread import get_ident def release_local(local): """Releases the contents of the local for the current context. This makes it possible to use locals without a manager. Example:: >>> loc = Local() >>> loc.foo = 42 >>> release_local(loc) >>> hasattr(loc, 'foo') False With this function one can release :class:`Local` objects as well as :class:`LocalStack` objects. However it is not possible to release data held by proxies that way, one always has to retain a reference to the underlying local object in order to be able to release it. .. versionadded:: 0.6.1 """ local.__release_local__() class Local(object): __slots__ = ('__storage__', '__ident_func__') def __init__(self): object.__setattr__(self, '__storage__', {}) object.__setattr__(self, '__ident_func__', get_ident) def __iter__(self): return iter(self.__storage__.items()) def __call__(self, proxy): """Create a proxy for a name.""" return LocalProxy(self, proxy) def __release_local__(self): self.__storage__.pop(self.__ident_func__(), None) def __getattr__(self, name): try: return self.__storage__[self.__ident_func__()][name] except KeyError: raise AttributeError(name) def __setattr__(self, name, value): ident = self.__ident_func__() storage = self.__storage__ try: storage[ident][name] = value except KeyError: storage[ident] = {name: value} def __delattr__(self, name): try: del self.__storage__[self.__ident_func__()][name] except KeyError: raise AttributeError(name) class LocalStack(object): """This class works similar to a :class:`Local` but keeps a stack of objects instead. This is best explained with an example:: >>> ls = LocalStack() >>> ls.push(42) >>> ls.top 42 >>> ls.push(23) >>> ls.top 23 >>> ls.pop() 23 >>> ls.top 42 They can be force released by using a :class:`LocalManager` or with the :func:`release_local` function but the correct way is to pop the item from the stack after using. When the stack is empty it will no longer be bound to the current context (and as such released). By calling the stack without arguments it returns a proxy that resolves to the topmost item on the stack. .. versionadded:: 0.6.1 """ def __init__(self): self._local = Local() def __release_local__(self): self._local.__release_local__() def _get__ident_func__(self): return self._local.__ident_func__ def _set__ident_func__(self, value): object.__setattr__(self._local, '__ident_func__', value) __ident_func__ = property(_get__ident_func__, _set__ident_func__) del _get__ident_func__, _set__ident_func__ def __call__(self): def _lookup(): rv = self.top if rv is None: raise RuntimeError('object unbound') return rv return LocalProxy(_lookup) def push(self, obj): """Pushes a new item to the stack""" rv = getattr(self._local, 'stack', None) if rv is None: self._local.stack = rv = [] rv.append(obj) return rv def pop(self): """Removes the topmost item from the stack, will return the old value or `None` if the stack was already empty. """ stack = getattr(self._local, 'stack', None) if stack is None: return None elif len(stack) == 1: release_local(self._local) return stack[-1] else: return stack.pop() @property def top(self): """The topmost item on the stack. If the stack is empty, `None` is returned. """ try: return self._local.stack[-1] except (AttributeError, IndexError): return None class LocalManager(object): """Local objects cannot manage themselves. For that you need a local manager. You can pass a local manager multiple locals or add them later by appending them to `manager.locals`. Everytime the manager cleans up it, will clean up all the data left in the locals for this context. The `ident_func` parameter can be added to override the default ident function for the wrapped locals. .. versionchanged:: 0.6.1 Instead of a manager the :func:`release_local` function can be used as well. .. versionchanged:: 0.7 `ident_func` was added. """ def __init__(self, locals=None, ident_func=None): if locals is None: self.locals = [] elif isinstance(locals, Local): self.locals = [locals] else: self.locals = list(locals) if ident_func is not None: self.ident_func = ident_func for local in self.locals: object.__setattr__(local, '__ident_func__', ident_func) else: self.ident_func = get_ident def get_ident(self): """Return the context identifier the local objects use internally for this context. You cannot override this method to change the behavior but use it to link other context local objects (such as SQLAlchemy's scoped sessions) to the Werkzeug locals. .. versionchanged:: 0.7 You can pass a different ident function to the local manager that will then be propagated to all the locals passed to the constructor. """ return self.ident_func() def cleanup(self): """Manually clean up the data in the locals for this context. Call this at the end of the request or use `make_middleware()`. """ for local in self.locals: release_local(local) def make_middleware(self, app): """Wrap a WSGI application so that cleaning up happens after request end. """ def application(environ, start_response): return ClosingIterator(app(environ, start_response), self.cleanup) return application def middleware(self, func): """Like `make_middleware` but for decorating functions. Example usage:: @manager.middleware def application(environ, start_response): ... The difference to `make_middleware` is that the function passed will have all the arguments copied from the inner application (name, docstring, module). """ return update_wrapper(self.make_middleware(func), func) def __repr__(self): return '<%s storages: %d>' % ( self.__class__.__name__, len(self.locals) ) @implements_bool class LocalProxy(object): """Acts as a proxy for a werkzeug local. Forwards all operations to a proxied object. The only operations not supported for forwarding are right handed operands and any kind of assignment. Example usage:: from werkzeug.local import Local l = Local() # these are proxies request = l('request') user = l('user') from werkzeug.local import LocalStack _response_local = LocalStack() # this is a proxy response = _response_local() Whenever something is bound to l.user / l.request the proxy objects will forward all operations. If no object is bound a :exc:`RuntimeError` will be raised. To create proxies to :class:`Local` or :class:`LocalStack` objects, call the object as shown above. If you want to have a proxy to an object looked up by a function, you can (as of Werkzeug 0.6.1) pass a function to the :class:`LocalProxy` constructor:: session = LocalProxy(lambda: get_current_request().session) .. versionchanged:: 0.6.1 The class can be instanciated with a callable as well now. """ __slots__ = ('__local', '__dict__', '__name__') def __init__(self, local, name=None): object.__setattr__(self, '_LocalProxy__local', local) object.__setattr__(self, '__name__', name) def _get_current_object(self): """Return the current object. This is useful if you want the real object behind the proxy at a time for performance reasons or because you want to pass the object into a different context. """ if not hasattr(self.__local, '__release_local__'): return self.__local() try: return getattr(self.__local, self.__name__) except AttributeError: raise RuntimeError('no object bound to %s' % self.__name__) @property def __dict__(self): try: return self._get_current_object().__dict__ except RuntimeError: raise AttributeError('__dict__') def __repr__(self): try: obj = self._get_current_object() except RuntimeError: return '<%s unbound>' % self.__class__.__name__ return repr(obj) def __bool__(self): try: return bool(self._get_current_object()) except RuntimeError: return False def __unicode__(self): try: return unicode(self._get_current_object()) # noqa except RuntimeError: return repr(self) def __dir__(self): try: return dir(self._get_current_object()) except RuntimeError: return [] def __getattr__(self, name): if name == '__members__': return dir(self._get_current_object()) return getattr(self._get_current_object(), name) def __setitem__(self, key, value): self._get_current_object()[key] = value def __delitem__(self, key): del self._get_current_object()[key] if PY2: __getslice__ = lambda x, i, j: x._get_current_object()[i:j] def __setslice__(self, i, j, seq): self._get_current_object()[i:j] = seq def __delslice__(self, i, j): del self._get_current_object()[i:j] __setattr__ = lambda x, n, v: setattr(x._get_current_object(), n, v) __delattr__ = lambda x, n: delattr(x._get_current_object(), n) __str__ = lambda x: str(x._get_current_object()) __lt__ = lambda x, o: x._get_current_object() < o __le__ = lambda x, o: x._get_current_object() <= o __eq__ = lambda x, o: x._get_current_object() == o __ne__ = lambda x, o: x._get_current_object() != o __gt__ = lambda x, o: x._get_current_object() > o __ge__ = lambda x, o: x._get_current_object() >= o __cmp__ = lambda x, o: cmp(x._get_current_object(), o) # noqa __hash__ = lambda x: hash(x._get_current_object()) __call__ = lambda x, *a, **kw: x._get_current_object()(*a, **kw) __len__ = lambda x: len(x._get_current_object()) __getitem__ = lambda x, i: x._get_current_object()[i] __iter__ = lambda x: iter(x._get_current_object()) __contains__ = lambda x, i: i in x._get_current_object() __add__ = lambda x, o: x._get_current_object() + o __sub__ = lambda x, o: x._get_current_object() - o __mul__ = lambda x, o: x._get_current_object() * o __floordiv__ = lambda x, o: x._get_current_object() // o __mod__ = lambda x, o: x._get_current_object() % o __divmod__ = lambda x, o: x._get_current_object().__divmod__(o) __pow__ = lambda x, o: x._get_current_object() ** o __lshift__ = lambda x, o: x._get_current_object() << o __rshift__ = lambda x, o: x._get_current_object() >> o __and__ = lambda x, o: x._get_current_object() & o __xor__ = lambda x, o: x._get_current_object() ^ o __or__ = lambda x, o: x._get_current_object() | o __div__ = lambda x, o: x._get_current_object().__div__(o) __truediv__ = lambda x, o: x._get_current_object().__truediv__(o) __neg__ = lambda x: -(x._get_current_object()) __pos__ = lambda x: +(x._get_current_object()) __abs__ = lambda x: abs(x._get_current_object()) __invert__ = lambda x: ~(x._get_current_object()) __complex__ = lambda x: complex(x._get_current_object()) __int__ = lambda x: int(x._get_current_object()) __long__ = lambda x: long(x._get_current_object()) # noqa __float__ = lambda x: float(x._get_current_object()) __oct__ = lambda x: oct(x._get_current_object()) __hex__ = lambda x: hex(x._get_current_object()) __index__ = lambda x: x._get_current_object().__index__() __coerce__ = lambda x, o: x._get_current_object().__coerce__(x, o) __enter__ = lambda x: x._get_current_object().__enter__() __exit__ = lambda x, *a, **kw: x._get_current_object().__exit__(*a, **kw) __radd__ = lambda x, o: o + x._get_current_object() __rsub__ = lambda x, o: o - x._get_current_object() __rmul__ = lambda x, o: o * x._get_current_object() __rdiv__ = lambda x, o: o / x._get_current_object() if PY2: __rtruediv__ = lambda x, o: x._get_current_object().__rtruediv__(o) else: __rtruediv__ = __rdiv__ __rfloordiv__ = lambda x, o: o // x._get_current_object() __rmod__ = lambda x, o: o % x._get_current_object() __rdivmod__ = lambda x, o: x._get_current_object().__rdivmod__(o)
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 1832, 272, 32202, 1714, 339, 961, 859, 9031, 1067, 13, 1832, 2251, 14, 339, 520, 7307, 26, 334, 67, 9, 6927, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 504, 9143, 492, 1678, 63, 5029, 199, 504, 10380, 14, 6508, 492, 5980, 1044, 3585, 199, 504, 10380, 423, 5819, 492, 7843, 18, 12, 9031, 63, 2245, 199, 199, 3, 3967, 1924, 2462, 965, 2399, 5705, 12431, 2723, 781, 883, 2951, 675, 5204, 465, 14154, 199, 3, 367, 314, 1067, 14, 221, 982, 12431, 16537, 787, 440, 2808, 781, 11264, 1771, 370, 314, 199, 3, 1453, 2462, 12893, 10298, 641, 2382, 652, 365, 14, 199, 893, 26, 272, 687, 12431, 2723, 492, 664, 1818, 465, 664, 63, 5425, 199, 2590, 3545, 26, 272, 862, 26, 267, 687, 2462, 492, 664, 63, 5425, 272, 871, 3545, 26, 267, 687, 485, 2671, 492, 664, 63, 5425, 421, 199, 318, 4683, 63, 1832, 8, 1832, 304, 272, 408, 9625, 83, 314, 4072, 402, 314, 2257, 367, 314, 1453, 1067, 14, 272, 961, 7704, 652, 3962, 370, 675, 9480, 1928, 282, 5256, 14, 339, 5679, 447, 398, 1306, 4355, 275, 10111, 342, 267, 1306, 4355, 14, 1421, 275, 5685, 267, 1306, 4683, 63, 1832, 8, 2102, 9, 267, 1306, 2688, 8, 2102, 12, 283, 1421, 358, 267, 756, 339, 8777, 642, 805, 1373, 883, 4683, 520, 533, 1705, 5339, 64, 2251, 465, 5521, 272, 465, 520, 533, 1705, 5339, 4851, 64, 2251, 14, 221, 9738, 652, 365, 440, 3962, 370, 272, 4683, 666, 23608, 701, 14942, 626, 4340, 12, 1373, 3544, 965, 370, 8074, 272, 282, 3659, 370, 314, 8793, 2257, 909, 315, 1865, 370, 506, 7688, 272, 370, 4683, 652, 14, 339, 2508, 7445, 447, 378, 14, 22, 14, 17, 272, 408, 272, 2257, 855, 3221, 63, 1832, 4533, 421, 199, 533, 10111, 8, 785, 304, 272, 636, 7257, 363, 275, 25038, 3494, 7500, 2560, 5425, 63, 1532, 13766, 339, 347, 636, 826, 721, 277, 304, 267, 909, 855, 10202, 721, 277, 12, 2560, 3494, 7500, 5009, 267, 909, 855, 10202, 721, 277, 12, 2560, 5425, 63, 1532, 7500, 664, 63, 5425, 9, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 855, 3494, 4343, 1744, 1012, 339, 347, 636, 1250, 721, 277, 12, 4566, 304, 267, 408, 2499, 282, 4566, 367, 282, 536, 1041, 267, 372, 10111, 4936, 8, 277, 12, 4566, 9, 339, 347, 636, 3221, 63, 1832, 721, 277, 304, 267, 291, 855, 3494, 4343, 1935, 8, 277, 855, 5425, 63, 1532, 29709, 488, 9, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 862, 26, 288, 372, 291, 855, 3494, 12298, 277, 855, 5425, 63, 1532, 4533, 1527, 354, 61, 267, 871, 4067, 26, 288, 746, 4281, 8, 354, 9, 339, 347, 636, 10202, 721, 277, 12, 536, 12, 574, 304, 267, 12893, 275, 291, 855, 5425, 63, 1532, 4533, 267, 4887, 275, 291, 855, 3494, 363, 267, 862, 26, 288, 4887, 59, 5425, 1527, 354, 61, 275, 574, 267, 871, 4067, 26, 288, 4887, 59, 5425, 61, 275, 469, 354, 26, 574, 93, 339, 347, 636, 30831, 721, 277, 12, 536, 304, 267, 862, 26, 288, 2150, 291, 855, 3494, 12298, 277, 855, 5425, 63, 1532, 4533, 1527, 354, 61, 267, 871, 4067, 26, 288, 746, 4281, 8, 354, 9, 421, 199, 533, 10111, 4851, 8, 785, 304, 339, 408, 2765, 1021, 5419, 8545, 370, 282, 520, 533, 1705, 5339, 64, 1325, 18578, 282, 3464, 272, 402, 2251, 3140, 14, 221, 961, 365, 5526, 1437, 23918, 543, 376, 2893, 447, 398, 1306, 9100, 275, 10111, 4851, 342, 267, 1306, 9100, 14, 5335, 8, 2260, 9, 267, 1306, 9100, 14, 2119, 267, 5685, 267, 1306, 9100, 14, 5335, 8, 1789, 9, 267, 1306, 9100, 14, 2119, 267, 6546, 267, 1306, 9100, 14, 1935, 342, 267, 6546, 267, 1306, 9100, 14, 2119, 267, 5685, 339, 9322, 883, 506, 3542, 14286, 701, 1808, 282, 520, 533, 1705, 5339, 2988, 64, 503, 543, 272, 314, 520, 1532, 1705, 3221, 63, 1832, 64, 805, 1325, 314, 3211, 4340, 365, 370, 4560, 314, 272, 1242, 687, 314, 3464, 2410, 1808, 14, 221, 3979, 314, 3464, 365, 2701, 652, 911, 272, 949, 8088, 506, 3914, 370, 314, 1453, 1067, 334, 460, 465, 4066, 14286, 680, 339, 4885, 6358, 314, 3464, 1928, 2368, 652, 2529, 282, 4566, 626, 32253, 370, 272, 314, 2746, 2786, 1242, 641, 314, 3464, 14, 339, 2508, 7445, 447, 378, 14, 22, 14, 17, 272, 408, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 1832, 275, 10111, 342, 339, 347, 636, 3221, 63, 1832, 721, 277, 304, 267, 291, 423, 1832, 855, 3221, 63, 1832, 4533, 339, 347, 485, 362, 363, 5425, 63, 1532, 721, 277, 304, 267, 372, 291, 423, 1832, 855, 5425, 63, 1532, 363, 339, 347, 485, 409, 363, 5425, 63, 1532, 721, 277, 12, 574, 304, 267, 909, 855, 10202, 721, 277, 423, 1832, 12, 2560, 5425, 63, 1532, 7500, 574, 9, 272, 636, 5425, 63, 1532, 363, 275, 3324, 1547, 362, 363, 5425, 63, 1532, 3108, 485, 409, 363, 5425, 63, 1532, 3368, 272, 2150, 485, 362, 363, 5425, 63, 1532, 3108, 485, 409, 363, 5425, 63, 1532, 363, 339, 347, 636, 1250, 721, 277, 304, 267, 347, 485, 3892, 837, 288, 4336, 275, 291, 14, 2119, 288, 340, 4336, 365, 488, 26, 355, 746, 6064, 360, 785, 22334, 358, 288, 372, 4336, 267, 372, 10111, 4936, 1547, 3892, 9, 339, 347, 6675, 8, 277, 12, 1559, 304, 267, 408, 10731, 397, 282, 892, 1242, 370, 314, 3464, 624, 267, 4336, 275, 2519, 8, 277, 423, 1832, 12, 283, 2340, 297, 488, 9, 267, 340, 4336, 365, 488, 26, 288, 291, 423, 1832, 14, 2340, 275, 4336, 275, 942, 267, 4336, 14, 740, 8, 1113, 9, 267, 372, 4336, 339, 347, 4560, 8, 277, 304, 267, 408, 22948, 314, 2746, 2786, 1242, 687, 314, 3464, 12, 911, 372, 314, 267, 2269, 574, 503, 658, 403, 64, 340, 314, 3464, 1990, 2575, 2701, 14, 267, 408 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 1832, 272, 32202, 1714, 339, 961, 859, 9031, 1067, 13, 1832, 2251, 14, 339, 520, 7307, 26, 334, 67, 9, 6927, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 504, 9143, 492, 1678, 63, 5029, 199, 504, 10380, 14, 6508, 492, 5980, 1044, 3585, 199, 504, 10380, 423, 5819, 492, 7843, 18, 12, 9031, 63, 2245, 199, 199, 3, 3967, 1924, 2462, 965, 2399, 5705, 12431, 2723, 781, 883, 2951, 675, 5204, 465, 14154, 199, 3, 367, 314, 1067, 14, 221, 982, 12431, 16537, 787, 440, 2808, 781, 11264, 1771, 370, 314, 199, 3, 1453, 2462, 12893, 10298, 641, 2382, 652, 365, 14, 199, 893, 26, 272, 687, 12431, 2723, 492, 664, 1818, 465, 664, 63, 5425, 199, 2590, 3545, 26, 272, 862, 26, 267, 687, 2462, 492, 664, 63, 5425, 272, 871, 3545, 26, 267, 687, 485, 2671, 492, 664, 63, 5425, 421, 199, 318, 4683, 63, 1832, 8, 1832, 304, 272, 408, 9625, 83, 314, 4072, 402, 314, 2257, 367, 314, 1453, 1067, 14, 272, 961, 7704, 652, 3962, 370, 675, 9480, 1928, 282, 5256, 14, 339, 5679, 447, 398, 1306, 4355, 275, 10111, 342, 267, 1306, 4355, 14, 1421, 275, 5685, 267, 1306, 4683, 63, 1832, 8, 2102, 9, 267, 1306, 2688, 8, 2102, 12, 283, 1421, 358, 267, 756, 339, 8777, 642, 805, 1373, 883, 4683, 520, 533, 1705, 5339, 64, 2251, 465, 5521, 272, 465, 520, 533, 1705, 5339, 4851, 64, 2251, 14, 221, 9738, 652, 365, 440, 3962, 370, 272, 4683, 666, 23608, 701, 14942, 626, 4340, 12, 1373, 3544, 965, 370, 8074, 272, 282, 3659, 370, 314, 8793, 2257, 909, 315, 1865, 370, 506, 7688, 272, 370, 4683, 652, 14, 339, 2508, 7445, 447, 378, 14, 22, 14, 17, 272, 408, 272, 2257, 855, 3221, 63, 1832, 4533, 421, 199, 533, 10111, 8, 785, 304, 272, 636, 7257, 363, 275, 25038, 3494, 7500, 2560, 5425, 63, 1532, 13766, 339, 347, 636, 826, 721, 277, 304, 267, 909, 855, 10202, 721, 277, 12, 2560, 3494, 7500, 5009, 267, 909, 855, 10202, 721, 277, 12, 2560, 5425, 63, 1532, 7500, 664, 63, 5425, 9, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 855, 3494, 4343, 1744, 1012, 339, 347, 636, 1250, 721, 277, 12, 4566, 304, 267, 408, 2499, 282, 4566, 367, 282, 536, 1041, 267, 372, 10111, 4936, 8, 277, 12, 4566, 9, 339, 347, 636, 3221, 63, 1832, 721, 277, 304, 267, 291, 855, 3494, 4343, 1935, 8, 277, 855, 5425, 63, 1532, 29709, 488, 9, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 862, 26, 288, 372, 291, 855, 3494, 12298, 277, 855, 5425, 63, 1532, 4533, 1527, 354, 61, 267, 871, 4067, 26, 288, 746, 4281, 8, 354, 9, 339, 347, 636, 10202, 721, 277, 12, 536, 12, 574, 304, 267, 12893, 275, 291, 855, 5425, 63, 1532, 4533, 267, 4887, 275, 291, 855, 3494, 363, 267, 862, 26, 288, 4887, 59, 5425, 1527, 354, 61, 275, 574, 267, 871, 4067, 26, 288, 4887, 59, 5425, 61, 275, 469, 354, 26, 574, 93, 339, 347, 636, 30831, 721, 277, 12, 536, 304, 267, 862, 26, 288, 2150, 291, 855, 3494, 12298, 277, 855, 5425, 63, 1532, 4533, 1527, 354, 61, 267, 871, 4067, 26, 288, 746, 4281, 8, 354, 9, 421, 199, 533, 10111, 4851, 8, 785, 304, 339, 408, 2765, 1021, 5419, 8545, 370, 282, 520, 533, 1705, 5339, 64, 1325, 18578, 282, 3464, 272, 402, 2251, 3140, 14, 221, 961, 365, 5526, 1437, 23918, 543, 376, 2893, 447, 398, 1306, 9100, 275, 10111, 4851, 342, 267, 1306, 9100, 14, 5335, 8, 2260, 9, 267, 1306, 9100, 14, 2119, 267, 5685, 267, 1306, 9100, 14, 5335, 8, 1789, 9, 267, 1306, 9100, 14, 2119, 267, 6546, 267, 1306, 9100, 14, 1935, 342, 267, 6546, 267, 1306, 9100, 14, 2119, 267, 5685, 339, 9322, 883, 506, 3542, 14286, 701, 1808, 282, 520, 533, 1705, 5339, 2988, 64, 503, 543, 272, 314, 520, 1532, 1705, 3221, 63, 1832, 64, 805, 1325, 314, 3211, 4340, 365, 370, 4560, 314, 272, 1242, 687, 314, 3464, 2410, 1808, 14, 221, 3979, 314, 3464, 365, 2701, 652, 911, 272, 949, 8088, 506, 3914, 370, 314, 1453, 1067, 334, 460, 465, 4066, 14286, 680, 339, 4885, 6358, 314, 3464, 1928, 2368, 652, 2529, 282, 4566, 626, 32253, 370, 272, 314, 2746, 2786, 1242, 641, 314, 3464, 14, 339, 2508, 7445, 447, 378, 14, 22, 14, 17, 272, 408, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 1832, 275, 10111, 342, 339, 347, 636, 3221, 63, 1832, 721, 277, 304, 267, 291, 423, 1832, 855, 3221, 63, 1832, 4533, 339, 347, 485, 362, 363, 5425, 63, 1532, 721, 277, 304, 267, 372, 291, 423, 1832, 855, 5425, 63, 1532, 363, 339, 347, 485, 409, 363, 5425, 63, 1532, 721, 277, 12, 574, 304, 267, 909, 855, 10202, 721, 277, 423, 1832, 12, 2560, 5425, 63, 1532, 7500, 574, 9, 272, 636, 5425, 63, 1532, 363, 275, 3324, 1547, 362, 363, 5425, 63, 1532, 3108, 485, 409, 363, 5425, 63, 1532, 3368, 272, 2150, 485, 362, 363, 5425, 63, 1532, 3108, 485, 409, 363, 5425, 63, 1532, 363, 339, 347, 636, 1250, 721, 277, 304, 267, 347, 485, 3892, 837, 288, 4336, 275, 291, 14, 2119, 288, 340, 4336, 365, 488, 26, 355, 746, 6064, 360, 785, 22334, 358, 288, 372, 4336, 267, 372, 10111, 4936, 1547, 3892, 9, 339, 347, 6675, 8, 277, 12, 1559, 304, 267, 408, 10731, 397, 282, 892, 1242, 370, 314, 3464, 624, 267, 4336, 275, 2519, 8, 277, 423, 1832, 12, 283, 2340, 297, 488, 9, 267, 340, 4336, 365, 488, 26, 288, 291, 423, 1832, 14, 2340, 275, 4336, 275, 942, 267, 4336, 14, 740, 8, 1113, 9, 267, 372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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 ]
bosstb/HaberPush
youtube_dl/extractor/cda.py
11
5302
# coding: utf-8 from __future__ import unicode_literals import codecs import re from .common import InfoExtractor from ..utils import ( ExtractorError, float_or_none, int_or_none, parse_duration, ) class CDAIE(InfoExtractor): _VALID_URL = r'https?://(?:(?:www\.)?cda\.pl/video|ebd\.cda\.pl/[0-9]+x[0-9]+)/(?P<id>[0-9a-z]+)' _BASE_URL = 'http://www.cda.pl/' _TESTS = [{ 'url': 'http://www.cda.pl/video/5749950c', 'md5': '6f844bf51b15f31fae165365707ae970', 'info_dict': { 'id': '5749950c', 'ext': 'mp4', 'height': 720, 'title': 'Oto dlaczego przed zakrętem należy zwolnić.', 'description': 'md5:269ccd135d550da90d1662651fcb9772', 'thumbnail': r're:^https?://.*\.jpg$', 'average_rating': float, 'duration': 39 } }, { 'url': 'http://www.cda.pl/video/57413289', 'md5': 'a88828770a8310fc00be6c95faf7f4d5', 'info_dict': { 'id': '57413289', 'ext': 'mp4', 'title': 'Lądowanie na lotnisku na Maderze', 'description': 'md5:60d76b71186dcce4e0ba6d4bbdb13e1a', 'thumbnail': r're:^https?://.*\.jpg$', 'uploader': 'crash404', 'view_count': int, 'average_rating': float, 'duration': 137 } }, { 'url': 'http://ebd.cda.pl/0x0/5749950c', 'only_matching': True, }] def _real_extract(self, url): video_id = self._match_id(url) self._set_cookie('cda.pl', 'cda.player', 'html5') webpage = self._download_webpage( self._BASE_URL + '/video/' + video_id, video_id) if 'Ten film jest dostępny dla użytkowników premium' in webpage: raise ExtractorError('This video is only available for premium users.', expected=True) formats = [] uploader = self._search_regex(r'''(?x) <(span|meta)[^>]+itemprop=(["\'])author\2[^>]*> (?:<\1[^>]*>[^<]*</\1>|(?!</\1>)(?:.|\n))*? <(span|meta)[^>]+itemprop=(["\'])name\4[^>]*>(?P<uploader>[^<]+)</\3> ''', webpage, 'uploader', default=None, group='uploader') view_count = self._search_regex( r'Odsłony:(?:\s|&nbsp;)*([0-9]+)', webpage, 'view_count', default=None) average_rating = self._search_regex( r'<(?:span|meta)[^>]+itemprop=(["\'])ratingValue\1[^>]*>(?P<rating_value>[0-9.]+)', webpage, 'rating', fatal=False, group='rating_value') info_dict = { 'id': video_id, 'title': self._og_search_title(webpage), 'description': self._og_search_description(webpage), 'uploader': uploader, 'view_count': int_or_none(view_count), 'average_rating': float_or_none(average_rating), 'thumbnail': self._og_search_thumbnail(webpage), 'formats': formats, 'duration': None, } def extract_format(page, version): json_str = self._search_regex( r'player_data=(\\?["\'])(?P<player_data>.+?)\1', page, '%s player_json' % version, fatal=False, group='player_data') if not json_str: return player_data = self._parse_json( json_str, '%s player_data' % version, fatal=False) if not player_data: return video = player_data.get('video') if not video or 'file' not in video: self.report_warning('Unable to extract %s version information' % version) return if video['file'].startswith('uggc'): video['file'] = codecs.decode(video['file'], 'rot_13') if video['file'].endswith('adc.mp4'): video['file'] = video['file'].replace('adc.mp4', '.mp4') f = { 'url': video['file'], } m = re.search( r'<a[^>]+data-quality="(?P<format_id>[^"]+)"[^>]+href="[^"]+"[^>]+class="[^"]*quality-btn-active[^"]*">(?P<height>[0-9]+)p', page) if m: f.update({ 'format_id': m.group('format_id'), 'height': int(m.group('height')), }) info_dict['formats'].append(f) if not info_dict['duration']: info_dict['duration'] = parse_duration(video.get('duration')) extract_format(webpage, 'default') for href, resolution in re.findall( r'<a[^>]+data-quality="[^"]+"[^>]+href="([^"]+)"[^>]+class="quality-btn"[^>]*>([0-9]+p)', webpage): webpage = self._download_webpage( self._BASE_URL + href, video_id, 'Downloading %s version information' % resolution, fatal=False) if not webpage: # Manually report warning because empty page is returned when # invalid version is requested. self.report_warning('Unable to download %s version information' % resolution) continue extract_format(webpage, resolution) self._sort_formats(formats) return info_dict
mit
[ 3, 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 6010, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 19783, 12, 272, 2069, 63, 269, 63, 3592, 12, 272, 1109, 63, 269, 63, 3592, 12, 272, 2198, 63, 5553, 12, 199, 9, 421, 199, 533, 445, 8980, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 5169, 1544, 20316, 67, 983, 4537, 1168, 15, 3722, 92, 2871, 68, 4537, 67, 983, 4537, 1168, 32418, 16, 13, 25, 2807, 88, 59, 16, 13, 25, 24598, 2229, 48, 28, 344, 9514, 16, 13, 25, 65, 13, 90, 29716, 272, 485, 5825, 63, 2632, 275, 283, 1014, 921, 1544, 14, 67, 983, 14, 1168, 4805, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 67, 983, 14, 1168, 15, 3722, 15, 10950, 1020, 1400, 67, 297, 267, 283, 1064, 21, 356, 283, 22, 70, 16042, 4361, 2869, 66, 1046, 70, 2192, 667, 69, 10355, 1344, 1641, 1780, 3624, 20598, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 10950, 1020, 1400, 67, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 3333, 356, 29692, 12, 288, 283, 1213, 356, 283, 47, 475, 366, 416, 67, 806, 1939, 5448, 7068, 1315, 1151, 82, 129, 248, 563, 302, 1895, 130, 121, 89, 1315, 87, 393, 8445, 129, 230, 3130, 288, 283, 1802, 356, 283, 1064, 21, 26, 12442, 30013, 8312, 68, 16859, 983, 2710, 68, 10642, 1479, 2869, 70, 2894, 25, 19518, 297, 288, 283, 8311, 356, 519, 3984, 23497, 2859, 32569, 8476, 4268, 288, 283, 8536, 63, 10417, 356, 2069, 12, 288, 283, 5553, 356, 10551, 267, 789, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 67, 983, 14, 1168, 15, 3722, 15, 10950, 6557, 1407, 297, 267, 283, 1064, 21, 356, 283, 65, 13997, 1651, 17902, 65, 2658, 709, 3003, 383, 1235, 22, 67, 2720, 667, 70, 23, 70, 20, 68, 21, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 10950, 6557, 1407, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 44, 129, 228, 68, 583, 290, 1873, 11802, 560, 5889, 374, 20661, 11802, 603, 669, 806, 297, 288, 283, 1802, 356, 283, 1064, 21, 26, 2259, 68, 2114, 66, 32748, 1184, 3833, 301, 20, 69, 16, 2470, 22, 68, 20, 2501, 697, 969, 69, 17, 65, 297, 288, 283, 8311, 356, 519, 3984, 23497, 2859, 32569, 8476, 4268, 288, 283, 13671, 356, 283, 14807, 5188, 297, 288, 283, 1345, 63, 835, 356, 1109, 12, 288, 283, 8536, 63, 10417, 356, 2069, 12, 288, 283, 5553, 356, 27750, 267, 789, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 2871, 68, 14, 67, 983, 14, 1168, 15, 16, 88, 16, 15, 10950, 1020, 1400, 67, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 14877, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 267, 291, 423, 409, 63, 5306, 360, 67, 983, 14, 1168, 297, 283, 67, 983, 14, 6147, 297, 283, 1360, 21, 358, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 288, 291, 423, 5825, 63, 2632, 435, 1994, 3722, 4805, 435, 3991, 63, 344, 12, 3991, 63, 344, 9, 398, 340, 283, 22216, 1794, 77, 1335, 597, 886, 270, 129, 248, 4812, 89, 366, 416, 399, 130, 121, 89, 2663, 944, 3258, 11980, 87, 876, 23481, 7, 315, 9248, 26, 288, 746, 19783, 360, 2765, 3991, 365, 1454, 2808, 367, 876, 23481, 4390, 3130, 1420, 29, 549, 9, 398, 6752, 275, 942, 398, 25257, 275, 291, 423, 1733, 63, 3821, 8, 82, 2344, 2229, 88, 9, 288, 665, 8, 3751, 92, 2024, 2788, 62, 30, 2807, 73, 808, 2675, 30982, 3212, 1105, 2502, 60, 18, 28959, 30, 288, 16697, 31873, 17, 28959, 13489, 28, 3672, 1108, 60, 17, 21521, 26313, 1108, 60, 17, 18956, 5169, 14, 6113, 78, 430, 15279, 288, 665, 8, 3751, 92, 2024, 2788, 62, 30, 2807, 73, 808, 2675, 30982, 3212, 1105, 354, 60, 20, 28959, 30, 2229, 48, 28, 13671, 13489, 28, 11896, 1108, 60, 19, 30, 267, 21281, 9248, 12, 283, 13671, 297, 849, 29, 403, 12, 1572, 534, 13671, 358, 267, 2455, 63, 835, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 7, 47, 795, 130, 225, 5220, 26, 15840, 83, 92, 6, 10758, 27, 3342, 779, 16, 13, 25, 28798, 9248, 12, 288, 283, 1345, 63, 835, 297, 849, 29, 403, 9, 267, 8095, 63, 10417, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 7601, 5169, 3751, 92, 2024, 2788, 62, 30, 2807, 73, 808, 2675, 30982, 3212, 1105, 10417, 1110, 60, 17, 28959, 30, 2229, 48, 28, 10417, 63, 585, 9514, 16, 13, 25, 14, 28798, 288, 9248, 12, 283, 10417, 297, 14294, 29, 797, 12, 1572, 534, 10417, 63, 585, 358, 398, 2256, 63, 807, 275, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 1213, 356, 291, 423, 974, 63, 1733, 63, 1213, 8, 12022, 395, 288, 283, 1802, 356, 291, 423, 974, 63, 1733, 63, 1802, 8, 12022, 395, 288, 283, 13671, 356, 25257, 12, 288, 283, 1345, 63, 835, 356, 1109, 63, 269, 63, 3592, 8, 1345, 63, 835, 395, 288, 283, 8536, 63, 10417, 356, 2069, 63, 269, 63, 3592, 8, 8536, 63, 10417, 395, 288, 283, 8311, 356, 291, 423, 974, 63, 1733, 63, 8311, 8, 12022, 395, 288, 283, 6321, 356, 6752, 12, 288, 283, 5553, 356, 488, 12, 267, 789, 398, 347, 5536, 63, 908, 8, 1606, 12, 1015, 304, 288, 2022, 63, 495, 275, 291, 423, 1733, 63, 3821, 8, 355, 519, 7, 6147, 63, 576, 2687, 1103, 31, 905, 60, 1105, 2229, 48, 28, 6147, 63, 576, 29587, 2862, 17, 297, 2034, 12, 355, 1543, 83, 7748, 63, 1001, 7, 450, 1015, 12, 14294, 29, 797, 12, 1572, 534, 6147, 63, 576, 358, 288, 340, 440, 2022, 63, 495, 26, 355, 372, 288, 7748 ]
[ 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 6010, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 19783, 12, 272, 2069, 63, 269, 63, 3592, 12, 272, 1109, 63, 269, 63, 3592, 12, 272, 2198, 63, 5553, 12, 199, 9, 421, 199, 533, 445, 8980, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 5169, 1544, 20316, 67, 983, 4537, 1168, 15, 3722, 92, 2871, 68, 4537, 67, 983, 4537, 1168, 32418, 16, 13, 25, 2807, 88, 59, 16, 13, 25, 24598, 2229, 48, 28, 344, 9514, 16, 13, 25, 65, 13, 90, 29716, 272, 485, 5825, 63, 2632, 275, 283, 1014, 921, 1544, 14, 67, 983, 14, 1168, 4805, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 67, 983, 14, 1168, 15, 3722, 15, 10950, 1020, 1400, 67, 297, 267, 283, 1064, 21, 356, 283, 22, 70, 16042, 4361, 2869, 66, 1046, 70, 2192, 667, 69, 10355, 1344, 1641, 1780, 3624, 20598, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 10950, 1020, 1400, 67, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 3333, 356, 29692, 12, 288, 283, 1213, 356, 283, 47, 475, 366, 416, 67, 806, 1939, 5448, 7068, 1315, 1151, 82, 129, 248, 563, 302, 1895, 130, 121, 89, 1315, 87, 393, 8445, 129, 230, 3130, 288, 283, 1802, 356, 283, 1064, 21, 26, 12442, 30013, 8312, 68, 16859, 983, 2710, 68, 10642, 1479, 2869, 70, 2894, 25, 19518, 297, 288, 283, 8311, 356, 519, 3984, 23497, 2859, 32569, 8476, 4268, 288, 283, 8536, 63, 10417, 356, 2069, 12, 288, 283, 5553, 356, 10551, 267, 789, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 67, 983, 14, 1168, 15, 3722, 15, 10950, 6557, 1407, 297, 267, 283, 1064, 21, 356, 283, 65, 13997, 1651, 17902, 65, 2658, 709, 3003, 383, 1235, 22, 67, 2720, 667, 70, 23, 70, 20, 68, 21, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 10950, 6557, 1407, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 44, 129, 228, 68, 583, 290, 1873, 11802, 560, 5889, 374, 20661, 11802, 603, 669, 806, 297, 288, 283, 1802, 356, 283, 1064, 21, 26, 2259, 68, 2114, 66, 32748, 1184, 3833, 301, 20, 69, 16, 2470, 22, 68, 20, 2501, 697, 969, 69, 17, 65, 297, 288, 283, 8311, 356, 519, 3984, 23497, 2859, 32569, 8476, 4268, 288, 283, 13671, 356, 283, 14807, 5188, 297, 288, 283, 1345, 63, 835, 356, 1109, 12, 288, 283, 8536, 63, 10417, 356, 2069, 12, 288, 283, 5553, 356, 27750, 267, 789, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 2871, 68, 14, 67, 983, 14, 1168, 15, 16, 88, 16, 15, 10950, 1020, 1400, 67, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 14877, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 267, 291, 423, 409, 63, 5306, 360, 67, 983, 14, 1168, 297, 283, 67, 983, 14, 6147, 297, 283, 1360, 21, 358, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 288, 291, 423, 5825, 63, 2632, 435, 1994, 3722, 4805, 435, 3991, 63, 344, 12, 3991, 63, 344, 9, 398, 340, 283, 22216, 1794, 77, 1335, 597, 886, 270, 129, 248, 4812, 89, 366, 416, 399, 130, 121, 89, 2663, 944, 3258, 11980, 87, 876, 23481, 7, 315, 9248, 26, 288, 746, 19783, 360, 2765, 3991, 365, 1454, 2808, 367, 876, 23481, 4390, 3130, 1420, 29, 549, 9, 398, 6752, 275, 942, 398, 25257, 275, 291, 423, 1733, 63, 3821, 8, 82, 2344, 2229, 88, 9, 288, 665, 8, 3751, 92, 2024, 2788, 62, 30, 2807, 73, 808, 2675, 30982, 3212, 1105, 2502, 60, 18, 28959, 30, 288, 16697, 31873, 17, 28959, 13489, 28, 3672, 1108, 60, 17, 21521, 26313, 1108, 60, 17, 18956, 5169, 14, 6113, 78, 430, 15279, 288, 665, 8, 3751, 92, 2024, 2788, 62, 30, 2807, 73, 808, 2675, 30982, 3212, 1105, 354, 60, 20, 28959, 30, 2229, 48, 28, 13671, 13489, 28, 11896, 1108, 60, 19, 30, 267, 21281, 9248, 12, 283, 13671, 297, 849, 29, 403, 12, 1572, 534, 13671, 358, 267, 2455, 63, 835, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 7, 47, 795, 130, 225, 5220, 26, 15840, 83, 92, 6, 10758, 27, 3342, 779, 16, 13, 25, 28798, 9248, 12, 288, 283, 1345, 63, 835, 297, 849, 29, 403, 9, 267, 8095, 63, 10417, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 7601, 5169, 3751, 92, 2024, 2788, 62, 30, 2807, 73, 808, 2675, 30982, 3212, 1105, 10417, 1110, 60, 17, 28959, 30, 2229, 48, 28, 10417, 63, 585, 9514, 16, 13, 25, 14, 28798, 288, 9248, 12, 283, 10417, 297, 14294, 29, 797, 12, 1572, 534, 10417, 63, 585, 358, 398, 2256, 63, 807, 275, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 1213, 356, 291, 423, 974, 63, 1733, 63, 1213, 8, 12022, 395, 288, 283, 1802, 356, 291, 423, 974, 63, 1733, 63, 1802, 8, 12022, 395, 288, 283, 13671, 356, 25257, 12, 288, 283, 1345, 63, 835, 356, 1109, 63, 269, 63, 3592, 8, 1345, 63, 835, 395, 288, 283, 8536, 63, 10417, 356, 2069, 63, 269, 63, 3592, 8, 8536, 63, 10417, 395, 288, 283, 8311, 356, 291, 423, 974, 63, 1733, 63, 8311, 8, 12022, 395, 288, 283, 6321, 356, 6752, 12, 288, 283, 5553, 356, 488, 12, 267, 789, 398, 347, 5536, 63, 908, 8, 1606, 12, 1015, 304, 288, 2022, 63, 495, 275, 291, 423, 1733, 63, 3821, 8, 355, 519, 7, 6147, 63, 576, 2687, 1103, 31, 905, 60, 1105, 2229, 48, 28, 6147, 63, 576, 29587, 2862, 17, 297, 2034, 12, 355, 1543, 83, 7748, 63, 1001, 7, 450, 1015, 12, 14294, 29, 797, 12, 1572, 534, 6147, 63, 576, 358, 288, 340, 440, 2022, 63, 495, 26, 355, 372, 288, 7748, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
wilseypa/warped2-models
scripts/plotBags.py
1
12059
#!/usr/bin/python # Calculates statistics and plots the bag metrics from raw data from __future__ import print_function import csv import os, sys import numpy as np import scipy as sp import scipy.stats as sps import pandas as pd import re, shutil, tempfile import itertools, operator import subprocess import Gnuplot import Gnuplot.funcutils ###### Settings go here ###### searchAttrsList = [ { 'groupby': ['Worker_Thread_Count', 'Static_Window_Size'], 'filter' : 'Fraction_of_Total_Window', 'model' : 'Model', 'lpcount': 'Number_of_Objects', 'output' : 'threads_vs_staticwindow_key_fractionwindow_' }, { 'groupby': ['Worker_Thread_Count', 'Fraction_of_Total_Window'], 'filter' : 'Static_Window_Size', 'model' : 'Model', 'lpcount': 'Number_of_Objects', 'output' : 'threads_vs_fractionwindow_key_staticwindow_' } ] ''' List of metrics available: Event_Commitment_Ratio Total_Rollbacks Simulation_Runtime_(secs.) Average_Memory_Usage_(MB) Event_Processing_Rate_(per_sec) Speedup_w.r.t._Sequential_Simulation ''' metricList = [ { 'name' : 'Event_Processing_Rate_(per_sec)', 'ystart': 0, 'yend' : 1000000, 'ytics' : 100000 }, { 'name' : 'Simulation_Runtime_(secs.)', 'ystart': 0, 'yend' : 150, 'ytics' : 10 }, { 'name' : 'Event_Commitment_Ratio', 'ystart': 1, 'yend' : 2, 'ytics' : 0.1 }, { 'name' : 'Speedup_w.r.t._Sequential_Simulation', 'ystart': 0, 'yend' : 10, 'ytics' : 1 } ] rawDataFileName = 'bags' statType = [ 'Mean', 'CI_Lower', 'CI_Upper', 'Median', 'Lower_Quartile', 'Upper_Quartile' ] ###### Don't edit below here ###### def mean_confidence_interval(data, confidence=0.95): # check the input is not empty if not data: raise RuntimeError('mean_ci - no data points passed') a = 1.0*np.array(data) n = len(a) m, se = np.mean(a), sps.sem(a) h = se * sps.t._ppf((1+confidence)/2., n-1) return m, m-h, m+h def median(data): # check the input is not empty if not data: raise RuntimeError('median - no data points passed') return np.median(np.array(data)) def quartiles(data): # check the input is not empty if not data: raise RuntimeError('quartiles - no data points passed') sorts = sorted(data) mid = len(sorts) / 2 if (len(sorts) % 2 == 0): # even lowerQ = median(sorts[:mid]) upperQ = median(sorts[mid:]) else: # odd lowerQ = median(sorts[:mid]) # same as even upperQ = median(sorts[mid+1:]) return lowerQ, upperQ def statistics(data): # check the input is not empty if not data: raise RuntimeError('statistics - no data points passed') mean = ci_lower = ci_upper = med = lower_quartile = upper_quartile = data[0] if len(data) > 1: mean, ci_lower, ci_upper = mean_confidence_interval(data) med = median(data) lower_quartile, upper_quartile = quartiles(data) statList = (str(mean), str(ci_lower), str(ci_upper), str(med), str(lower_quartile), str(upper_quartile)) return ",".join(statList) def sed_inplace(filename, pattern, repl): # For efficiency, precompile the passed regular expression. pattern_compiled = re.compile(pattern) # For portability, NamedTemporaryFile() defaults to mode "w+b" (i.e., binary # writing with updating). In this case, binary writing imposes non-trivial # encoding constraints resolved by switching to text writing. with tempfile.NamedTemporaryFile(mode='w', delete=False) as tmp_file: with open(filename) as src_file: for line in src_file: tmp_file.write(pattern_compiled.sub(repl, line)) # Overwrite the original file with the temporary file in a # manner preserving file attributes (e.g., permissions). shutil.copystat(filename, tmp_file.name) shutil.move(tmp_file.name, filename) def getIndex(aList, text): '''Returns the index of the requested text in the given list''' for i,x in enumerate(aList): if x == text: return i def plot(data, fileName, title, subtitle, xaxisLabel, yaxisLabel, ystart, yend, ytics, linePreface): # Replace '_' with ' ' g = Gnuplot.Gnuplot() multiLineTitle = title.replace("_", " ") + '\\n '+ subtitle.replace("_", " ") g.title(multiLineTitle) g("set terminal svg noenhanced background rgb 'white' size 1000,800 fname 'Helvetica' fsize 16") g("set key box outside center top horizontal font ',12' ") g("set autoscale xy") #g("set yrange [{0}:{1}]".format(unicode(ystart), unicode(yend))) #g("set ytics {}".format(unicode(ytics))) g("set grid") g.xlabel(xaxisLabel.replace("_", " ")) g.ylabel(yaxisLabel.replace("_", " ")) g('set output "' + fileName + '"') d = [] for key in sorted(data[statType[0]]): result = Gnuplot.Data( data['header'][key],data[statType[0]][key],\ data[statType[1]][key],data[statType[2]][key],\ with_="yerrorlines",title=linePreface+key ) d.append(result) g.plot(*d) def plot_stats(dirPath, fileName, xaxisLabel, keyLabel, filterLabel, filterValue, model, lpCount): # Read the stats csv inFile = dirPath + 'stats/' + rawDataFileName + '/' + fileName + '.csv' reader = csv.reader(open(inFile,'rb')) header = reader.next() # Get Column Values for use below xaxis = getIndex(header, xaxisLabel) kid = getIndex(header, keyLabel) reader = sorted(reader, key=lambda x: int(x[xaxis]), reverse=False) reader = sorted(reader, key=lambda x: x[kid], reverse=False) for param in metricList: metric = param['name'] ystart = param['ystart'] yend = param['yend'] ytics = param['ytics'] outData = {'header':{}} # Populate the header for kindex, kdata in itertools.groupby(reader, lambda x: x[kid]): if kindex not in outData['header']: outData['header'][kindex] = [] for xindex, data in itertools.groupby(kdata, lambda x: x[xaxis]): outData['header'][kindex].append(xindex) # Populate the statistical data for stat in statType: columnName = metric + '_' + stat columnIndex = getIndex(header, columnName) if stat not in outData: outData[stat] = {} for xindex, data in itertools.groupby(reader, lambda x: x[xaxis]): for kindex, kdata in itertools.groupby(data, lambda x: x[kid]): if kindex not in outData[stat]: outData[stat][kindex] = [] value = [item[columnIndex] for item in kdata][0] outData[stat][kindex].append(value) # Plot the statistical data title = model.upper() + ' model with ' + str("{:,}".format(lpCount)) + ' LPs' subtitle = 'key = ' + keyLabel outDir = dirPath + 'plots/' + rawDataFileName + '/' outFile = outDir + fileName + "_" + metric + '.svg' yaxisLabel = metric + '_(C.I._=_95%)' plot(outData, outFile, title, subtitle, xaxisLabel, yaxisLabel, ystart, yend, ytics, '') # Convert svg to pdf and delete svg outPDF = outDir + fileName + "_" + metric + '.pdf' subprocess.call(['inkscape', outFile, '--export-pdf', outPDF]) subprocess.call(['rm', outFile]) def calc_and_plot(dirPath): # Load the sequential simulation time seqFile = dirPath + 'sequential.dat' if not os.path.exists(seqFile): print('Sequential data not available') sys.exit() seqFp = open(seqFile, 'r') seqCount, _, seqTime = seqFp.readline().split() seqFp.close() # Load data from csv file inFile = dirPath + rawDataFileName + '.csv' if not os.path.exists(inFile): print(rawDataFileName.upper() + ' raw data not available') sys.exit() data = pd.read_csv(inFile, sep=',') data['Event_Commitment_Ratio'] = \ data['Events_Processed'] / data['Events_Committed'] data['Total_Rollbacks'] = \ data['Primary_Rollbacks'] + data['Secondary_Rollbacks'] data['Event_Processing_Rate_(per_sec)'] = \ data['Events_Processed'] / data['Simulation_Runtime_(secs.)'] data['Speedup_w.r.t._Sequential_Simulation'] = \ float(seqTime) / data['Simulation_Runtime_(secs.)'] # Create the plots directory (if needed) outDir = dirPath + 'plots/' if not os.path.exists(outDir): os.makedirs(outDir) outName = outDir + rawDataFileName + '/' subprocess.call(['rm', '-rf', outName]) subprocess.call(['mkdir', outName]) # Create the stats directory (if needed) outDir = dirPath + 'stats/' if not os.path.exists(outDir): os.makedirs(outDir) outName = outDir + rawDataFileName + '/' subprocess.call(['rm', '-rf', outName]) subprocess.call(['mkdir', outName]) for searchAttrs in searchAttrsList: groupbyList = searchAttrs['groupby'] filterName = searchAttrs['filter'] model = searchAttrs['model'] lpcount = searchAttrs['lpcount'] output = searchAttrs['output'] groupbyList.append(filterName) # Read unique values for the filter filterValues = data[filterName].unique().tolist() # Read the model name and LP count modelName = data[model].unique().tolist() lpCount = data[lpcount].unique().tolist() for filterValue in filterValues: # Filter data for each filterValue filteredData = data[data[filterName] == filterValue] groupedData = filteredData.groupby(groupbyList) columnNames = list(groupbyList) # Generate stats result = pd.DataFrame() for param in metricList: metric = param['name'] columnNames += [metric + '_' + x for x in statType] stats = groupedData.apply(lambda x : statistics(x[metric].tolist())) result = pd.concat([result, stats], axis=1) # Write to the csv fileName = output + str(filterValue) outFile = outName + fileName + '.csv' statFile = open(outFile,'w') for colName in columnNames: statFile.write(colName + ',') statFile.write("\n") statFile.close() result.to_csv(outFile, mode='a', header=False, sep=',') # Remove " from the newly created csv file # Note: It is needed since pandas package has an unresolved bug for # quoting arg which retains the double quotes for column attributes. sed_inplace(outFile, r'"', '') # Plot the statistics plot_stats( dirPath, fileName, groupbyList[0], groupbyList[1], filterName, filterValue, modelName[0], lpCount[0] ) def main(): dirPath = sys.argv[1] if not os.path.exists(dirPath): print('Invalid path to source') sys.exit() calc_and_plot(dirPath) if __name__ == "__main__": main()
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 3, 28562, 11076, 436, 19695, 314, 330, 643, 7186, 687, 3066, 666, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 7392, 199, 646, 747, 12, 984, 199, 646, 2680, 465, 980, 199, 646, 7026, 465, 2249, 199, 646, 7026, 14, 3200, 465, 308, 1190, 199, 646, 10634, 465, 6454, 199, 646, 295, 12, 5145, 12, 5549, 199, 646, 7975, 12, 4182, 199, 646, 3873, 199, 646, 598, 16690, 199, 646, 598, 16690, 14, 1532, 1208, 199, 199, 3726, 13303, 2621, 2348, 221, 3726, 199, 199, 1733, 21368, 1296, 275, 257, 359, 717, 469, 257, 283, 16968, 356, 788, 12678, 63, 4436, 63, 2353, 297, 283, 9278, 63, 4301, 63, 2320, 995, 1169, 283, 1541, 7, 520, 283, 27217, 63, 1618, 63, 7316, 63, 4301, 297, 1169, 283, 1238, 7, 221, 520, 283, 1685, 297, 1169, 283, 10343, 835, 356, 283, 3259, 63, 1618, 63, 11188, 297, 1169, 283, 1199, 7, 520, 283, 6962, 63, 3122, 63, 1986, 3806, 63, 498, 63, 13054, 3806, 8650, 221, 1660, 9453, 469, 257, 283, 16968, 356, 788, 12678, 63, 4436, 63, 2353, 297, 283, 27217, 63, 1618, 63, 7316, 63, 4301, 995, 1169, 283, 1541, 7, 520, 283, 9278, 63, 4301, 63, 2320, 297, 1169, 283, 1238, 7, 221, 520, 283, 1685, 297, 1169, 283, 10343, 835, 356, 283, 3259, 63, 1618, 63, 11188, 297, 1169, 283, 1199, 7, 520, 283, 6962, 63, 3122, 63, 13054, 3806, 63, 498, 63, 1986, 3806, 8650, 257, 789, 490, 1622, 199, 199, 2344, 199, 1296, 402, 7186, 2808, 26, 339, 6763, 63, 11421, 434, 63, 13971, 272, 19271, 63, 24363, 894, 83, 272, 10751, 5332, 63, 14357, 2531, 4855, 4959, 272, 437, 3652, 63, 8628, 63, 7692, 2531, 4567, 9, 272, 6763, 63, 9589, 63, 6621, 2531, 529, 63, 3321, 9, 272, 428, 4536, 384, 63, 87, 14, 82, 14, 84, 423, 18509, 63, 31728, 199, 2344, 199, 5165, 1296, 420, 275, 257, 359, 717, 469, 257, 283, 354, 7, 221, 520, 283, 2390, 63, 9589, 63, 6621, 2531, 529, 63, 3321, 3196, 1169, 283, 89, 928, 356, 378, 12, 1169, 283, 89, 500, 7, 221, 520, 19492, 12, 1169, 283, 89, 7769, 7, 520, 25761, 259, 1660, 9453, 469, 257, 283, 354, 7, 221, 520, 283, 31728, 63, 14357, 2531, 4855, 14, 3196, 1169, 283, 89, 928, 356, 378, 12, 1169, 283, 89, 500, 7, 221, 520, 14711, 12, 1169, 283, 89, 7769, 7, 520, 1616, 263, 1660, 9453, 469, 257, 283, 354, 7, 221, 520, 283, 2390, 63, 11421, 434, 63, 13971, 297, 1169, 283, 89, 928, 356, 413, 12, 1169, 283, 89, 500, 7, 221, 520, 499, 12, 1169, 283, 89, 7769, 7, 520, 378, 14, 17, 755, 1660, 9453, 469, 257, 283, 354, 7, 221, 520, 283, 15146, 384, 63, 87, 14, 82, 14, 84, 423, 18509, 63, 31728, 297, 1169, 283, 89, 928, 356, 378, 12, 1169, 283, 89, 500, 7, 221, 520, 1616, 12, 1169, 283, 89, 7769, 7, 520, 413, 260, 789, 490, 1622, 199, 199, 1773, 1451, 7733, 275, 283, 2470, 458, 7, 199, 199, 3736, 804, 263, 275, 359, 283, 14825, 297, 490, 283, 3553, 63, 17846, 297, 490, 283, 3553, 63, 19316, 297, 490, 283, 1352, 6268, 297, 490, 283, 17846, 63, 2371, 285, 7172, 297, 490, 283, 19316, 63, 2371, 285, 7172, 7, 2116, 1622, 421, 199, 3726, 7529, 1133, 5283, 5084, 2348, 221, 3726, 199, 199, 318, 4615, 63, 13969, 63, 4284, 8, 576, 12, 15197, 29, 16, 14, 2720, 304, 272, 327, 1104, 314, 1324, 365, 440, 2701, 272, 340, 440, 666, 26, 267, 746, 6064, 360, 3670, 63, 559, 446, 949, 666, 4501, 3032, 358, 272, 282, 275, 413, 14, 16, 10, 1590, 14, 1144, 8, 576, 9, 272, 302, 275, 822, 8, 65, 9, 272, 333, 12, 542, 275, 980, 14, 3670, 8, 65, 395, 308, 1190, 14, 21678, 8, 65, 9, 272, 394, 275, 542, 627, 308, 1190, 14, 84, 423, 802, 70, 1332, 17, 11, 13969, 2447, 18, 2020, 302, 13, 17, 9, 272, 372, 333, 12, 333, 13, 72, 12, 333, 11, 72, 199, 199, 318, 17312, 8, 576, 304, 272, 327, 1104, 314, 1324, 365, 440, 2701, 272, 340, 440, 666, 26, 267, 746, 6064, 360, 13106, 446, 949, 666, 4501, 3032, 358, 272, 372, 980, 14, 13106, 8, 1590, 14, 1144, 8, 576, 430, 199, 199, 318, 2173, 285, 18819, 8, 576, 304, 272, 327, 1104, 314, 1324, 365, 440, 2701, 272, 340, 440, 666, 26, 267, 746, 6064, 360, 30438, 18819, 446, 949, 666, 4501, 3032, 358, 272, 30313, 275, 3355, 8, 576, 9, 272, 10887, 275, 822, 8, 3191, 83, 9, 1182, 499, 272, 340, 334, 552, 8, 3191, 83, 9, 450, 499, 508, 378, 304, 267, 327, 2755, 267, 5117, 49, 275, 17312, 8, 3191, 83, 1491, 8523, 566, 267, 7008, 49, 275, 17312, 8, 3191, 83, 59, 8523, 5728, 272, 587, 26, 267, 327, 16699, 267, 5117, 49, 275, 17312, 8, 3191, 83, 1491, 8523, 566, 221, 327, 2011, 465, 2755, 267, 7008, 49, 275, 17312, 8, 3191, 83, 59, 8523, 11, 17, 5728, 272, 372, 5117, 49, 12, 7008, 49, 199, 199, 318, 11076, 8, 576, 304, 272, 327, 1104, 314, 1324, 365, 440, 2701, 272, 340, 440, 666, 26, 267, 746, 6064, 360, 13724, 446, 949, 666, 4501, 3032, 358, 339, 4615, 275, 16279, 63, 2325, 275, 16279, 63, 4142, 275, 562, 68, 275, 5117, 63, 30438, 7172, 275, 7008, 63, 30438, 7172, 275, 666, 59, 16, 61, 272, 340, 822, 8, 576, 9, 690, 413, 26, 267, 4615, 12, 16279, 63, 2325, 12, 16279, 63, 4142, 275, 4615, 63, 13969, 63, 4284, 8, 576, 9, 267, 562, 68, 275, 17312, 8, 576, 9, 267, 5117, 63, 30438, 7172, 12, 7008, 63, 30438, 7172, 275, 2173, 285, 18819, 8, 576, 9, 339, 5672, 1296, 275, 334, 495, 8, 3670, 395, 620, 8, 559, 63, 2325, 395, 620, 8, 559, 63, 4142, 395, 620, 8, 3594, 395, 620, 8, 2325, 63, 30438, 7172, 395, 620, 8, 4142, 63, 30438, 7172, 430, 272, 372, 19089, 904, 8, 3736, 1296, 9, 199, 199, 318, 542, 68 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 3, 28562, 11076, 436, 19695, 314, 330, 643, 7186, 687, 3066, 666, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 7392, 199, 646, 747, 12, 984, 199, 646, 2680, 465, 980, 199, 646, 7026, 465, 2249, 199, 646, 7026, 14, 3200, 465, 308, 1190, 199, 646, 10634, 465, 6454, 199, 646, 295, 12, 5145, 12, 5549, 199, 646, 7975, 12, 4182, 199, 646, 3873, 199, 646, 598, 16690, 199, 646, 598, 16690, 14, 1532, 1208, 199, 199, 3726, 13303, 2621, 2348, 221, 3726, 199, 199, 1733, 21368, 1296, 275, 257, 359, 717, 469, 257, 283, 16968, 356, 788, 12678, 63, 4436, 63, 2353, 297, 283, 9278, 63, 4301, 63, 2320, 995, 1169, 283, 1541, 7, 520, 283, 27217, 63, 1618, 63, 7316, 63, 4301, 297, 1169, 283, 1238, 7, 221, 520, 283, 1685, 297, 1169, 283, 10343, 835, 356, 283, 3259, 63, 1618, 63, 11188, 297, 1169, 283, 1199, 7, 520, 283, 6962, 63, 3122, 63, 1986, 3806, 63, 498, 63, 13054, 3806, 8650, 221, 1660, 9453, 469, 257, 283, 16968, 356, 788, 12678, 63, 4436, 63, 2353, 297, 283, 27217, 63, 1618, 63, 7316, 63, 4301, 995, 1169, 283, 1541, 7, 520, 283, 9278, 63, 4301, 63, 2320, 297, 1169, 283, 1238, 7, 221, 520, 283, 1685, 297, 1169, 283, 10343, 835, 356, 283, 3259, 63, 1618, 63, 11188, 297, 1169, 283, 1199, 7, 520, 283, 6962, 63, 3122, 63, 13054, 3806, 63, 498, 63, 1986, 3806, 8650, 257, 789, 490, 1622, 199, 199, 2344, 199, 1296, 402, 7186, 2808, 26, 339, 6763, 63, 11421, 434, 63, 13971, 272, 19271, 63, 24363, 894, 83, 272, 10751, 5332, 63, 14357, 2531, 4855, 4959, 272, 437, 3652, 63, 8628, 63, 7692, 2531, 4567, 9, 272, 6763, 63, 9589, 63, 6621, 2531, 529, 63, 3321, 9, 272, 428, 4536, 384, 63, 87, 14, 82, 14, 84, 423, 18509, 63, 31728, 199, 2344, 199, 5165, 1296, 420, 275, 257, 359, 717, 469, 257, 283, 354, 7, 221, 520, 283, 2390, 63, 9589, 63, 6621, 2531, 529, 63, 3321, 3196, 1169, 283, 89, 928, 356, 378, 12, 1169, 283, 89, 500, 7, 221, 520, 19492, 12, 1169, 283, 89, 7769, 7, 520, 25761, 259, 1660, 9453, 469, 257, 283, 354, 7, 221, 520, 283, 31728, 63, 14357, 2531, 4855, 14, 3196, 1169, 283, 89, 928, 356, 378, 12, 1169, 283, 89, 500, 7, 221, 520, 14711, 12, 1169, 283, 89, 7769, 7, 520, 1616, 263, 1660, 9453, 469, 257, 283, 354, 7, 221, 520, 283, 2390, 63, 11421, 434, 63, 13971, 297, 1169, 283, 89, 928, 356, 413, 12, 1169, 283, 89, 500, 7, 221, 520, 499, 12, 1169, 283, 89, 7769, 7, 520, 378, 14, 17, 755, 1660, 9453, 469, 257, 283, 354, 7, 221, 520, 283, 15146, 384, 63, 87, 14, 82, 14, 84, 423, 18509, 63, 31728, 297, 1169, 283, 89, 928, 356, 378, 12, 1169, 283, 89, 500, 7, 221, 520, 1616, 12, 1169, 283, 89, 7769, 7, 520, 413, 260, 789, 490, 1622, 199, 199, 1773, 1451, 7733, 275, 283, 2470, 458, 7, 199, 199, 3736, 804, 263, 275, 359, 283, 14825, 297, 490, 283, 3553, 63, 17846, 297, 490, 283, 3553, 63, 19316, 297, 490, 283, 1352, 6268, 297, 490, 283, 17846, 63, 2371, 285, 7172, 297, 490, 283, 19316, 63, 2371, 285, 7172, 7, 2116, 1622, 421, 199, 3726, 7529, 1133, 5283, 5084, 2348, 221, 3726, 199, 199, 318, 4615, 63, 13969, 63, 4284, 8, 576, 12, 15197, 29, 16, 14, 2720, 304, 272, 327, 1104, 314, 1324, 365, 440, 2701, 272, 340, 440, 666, 26, 267, 746, 6064, 360, 3670, 63, 559, 446, 949, 666, 4501, 3032, 358, 272, 282, 275, 413, 14, 16, 10, 1590, 14, 1144, 8, 576, 9, 272, 302, 275, 822, 8, 65, 9, 272, 333, 12, 542, 275, 980, 14, 3670, 8, 65, 395, 308, 1190, 14, 21678, 8, 65, 9, 272, 394, 275, 542, 627, 308, 1190, 14, 84, 423, 802, 70, 1332, 17, 11, 13969, 2447, 18, 2020, 302, 13, 17, 9, 272, 372, 333, 12, 333, 13, 72, 12, 333, 11, 72, 199, 199, 318, 17312, 8, 576, 304, 272, 327, 1104, 314, 1324, 365, 440, 2701, 272, 340, 440, 666, 26, 267, 746, 6064, 360, 13106, 446, 949, 666, 4501, 3032, 358, 272, 372, 980, 14, 13106, 8, 1590, 14, 1144, 8, 576, 430, 199, 199, 318, 2173, 285, 18819, 8, 576, 304, 272, 327, 1104, 314, 1324, 365, 440, 2701, 272, 340, 440, 666, 26, 267, 746, 6064, 360, 30438, 18819, 446, 949, 666, 4501, 3032, 358, 272, 30313, 275, 3355, 8, 576, 9, 272, 10887, 275, 822, 8, 3191, 83, 9, 1182, 499, 272, 340, 334, 552, 8, 3191, 83, 9, 450, 499, 508, 378, 304, 267, 327, 2755, 267, 5117, 49, 275, 17312, 8, 3191, 83, 1491, 8523, 566, 267, 7008, 49, 275, 17312, 8, 3191, 83, 59, 8523, 5728, 272, 587, 26, 267, 327, 16699, 267, 5117, 49, 275, 17312, 8, 3191, 83, 1491, 8523, 566, 221, 327, 2011, 465, 2755, 267, 7008, 49, 275, 17312, 8, 3191, 83, 59, 8523, 11, 17, 5728, 272, 372, 5117, 49, 12, 7008, 49, 199, 199, 318, 11076, 8, 576, 304, 272, 327, 1104, 314, 1324, 365, 440, 2701, 272, 340, 440, 666, 26, 267, 746, 6064, 360, 13724, 446, 949, 666, 4501, 3032, 358, 339, 4615, 275, 16279, 63, 2325, 275, 16279, 63, 4142, 275, 562, 68, 275, 5117, 63, 30438, 7172, 275, 7008, 63, 30438, 7172, 275, 666, 59, 16, 61, 272, 340, 822, 8, 576, 9, 690, 413, 26, 267, 4615, 12, 16279, 63, 2325, 12, 16279, 63, 4142, 275, 4615, 63, 13969, 63, 4284, 8, 576, 9, 267, 562, 68, 275, 17312, 8, 576, 9, 267, 5117, 63, 30438, 7172, 12, 7008, 63, 30438, 7172, 275, 2173, 285, 18819, 8, 576, 9, 339, 5672, 1296, 275, 334, 495, 8, 3670, 395, 620, 8, 559, 63, 2325, 395, 620, 8, 559, 63, 4142, 395, 620, 8, 3594, 395, 620, 8, 2325, 63, 30438, 7172, 395, 620, 8, 4142, 63, 30438, 7172, 430, 272, 372, 19089, 904, 8, 3736, 1296, 9, 199, 199, 318, 542, 68, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
thomasvs/morituri
morituri/test/test_common_encode.py
2
4799
# -*- Mode: Python; test-case-name: morituri.test.test_common_encode -*- # vi:si:et:sw=4:sts=4:ts=4 import os import tempfile import gobject gobject.threads_init() import gst from morituri.common import encode from morituri.extern.task import task, gstreamer from morituri.test import common class PathTestCase(common.TestCase): def _testSuffix(self, suffix): # because of https://bugzilla.gnome.org/show_bug.cgi?id=688625 # we first create the file with a 'normal' filename, then rename self.runner = task.SyncRunner(verbose=False) fd, path = tempfile.mkstemp() cmd = "gst-launch " \ "audiotestsrc num-buffers=100 samplesperbuffer=1024 ! " \ "audioconvert ! audio/x-raw-int,width=16,depth=16,channels =2 ! " \ "wavenc ! " \ "filesink location=\"%s\" > /dev/null 2>&1" % ( gstreamer.quoteParse(path).encode('utf-8'), ) self.debug('Running cmd %r' % cmd) os.system(cmd) self.failUnless(os.path.exists(path)) os.close(fd) fd, newpath = tempfile.mkstemp(suffix=suffix) os.rename(path, newpath) encodetask = encode.EncodeTask(newpath, newpath + '.out', encode.WavProfile()) self.runner.run(encodetask, verbose=False) os.close(fd) os.unlink(newpath) os.unlink(newpath + '.out') class UnicodePathTestCase(PathTestCase, common.UnicodeTestMixin): def testUnicodePath(self): # this test makes sure we can checksum a unicode path self._testSuffix(u'.morituri.test_encode.B\xeate Noire') class NormalPathTestCase(PathTestCase): def testSingleQuote(self): self._testSuffix(u".morituri.test_encode.Guns 'N Roses") def testDoubleQuote(self): self._testSuffix(u'.morituri.test_encode.12" edit') class TagReadTestCase(common.TestCase): def testRead(self): path = os.path.join(os.path.dirname(__file__), u'track.flac') self.runner = task.SyncRunner(verbose=False) t = encode.TagReadTask(path) self.runner.run(t) self.failUnless(t.taglist) self.assertEquals(t.taglist['audio-codec'], 'FLAC') self.assertEquals(t.taglist['description'], 'audiotest wave') class TagWriteTestCase(common.TestCase): def testWrite(self): fd, inpath = tempfile.mkstemp(suffix=u'.morituri.tagwrite.flac') # wave is pink-noise because a pure sine is encoded too efficiently # by flacenc and triggers not enough frames in parsing # FIXME: file a bug for this in GStreamer os.system('gst-launch ' 'audiotestsrc ' 'wave=pink-noise num-buffers=10 samplesperbuffer=588 ! ' 'audioconvert ! ' 'audio/x-raw-int,channels=2,width=16,height=16,rate=44100 ! ' 'flacenc ! filesink location=%s > /dev/null 2>&1' % inpath) os.close(fd) fd, outpath = tempfile.mkstemp(suffix=u'.morituri.tagwrite.flac') self.runner = task.SyncRunner(verbose=False) taglist = gst.TagList() taglist[gst.TAG_ARTIST] = 'Artist' taglist[gst.TAG_TITLE] = 'Title' t = encode.TagWriteTask(inpath, outpath, taglist) self.runner.run(t) t = encode.TagReadTask(outpath) self.runner.run(t) self.failUnless(t.taglist) self.assertEquals(t.taglist['audio-codec'], 'FLAC') self.assertEquals(t.taglist['description'], 'audiotest wave') self.assertEquals(t.taglist[gst.TAG_ARTIST], 'Artist') self.assertEquals(t.taglist[gst.TAG_TITLE], 'Title') os.unlink(inpath) os.unlink(outpath) class SafeRetagTestCase(common.TestCase): def setUp(self): self._fd, self._path = tempfile.mkstemp(suffix=u'.morituri.retag.flac') os.system('gst-launch ' 'audiotestsrc ' 'num-buffers=40 samplesperbuffer=588 wave=pink-noise ! ' 'audioconvert ! ' 'audio/x-raw-int,channels=2,width=16,height=16,rate=44100 ! ' 'flacenc ! filesink location=%s > /dev/null 2>&1' % self._path) os.close(self._fd) self.runner = task.SyncRunner(verbose=False) def tearDown(self): os.unlink(self._path) def testNoChange(self): taglist = gst.TagList() taglist[gst.TAG_DESCRIPTION] = 'audiotest wave' taglist[gst.TAG_AUDIO_CODEC] = 'FLAC' t = encode.SafeRetagTask(self._path, taglist) self.runner.run(t) def testChange(self): taglist = gst.TagList() taglist[gst.TAG_DESCRIPTION] = 'audiotest retagged' taglist[gst.TAG_AUDIO_CODEC] = 'FLAC' taglist[gst.TAG_ARTIST] = 'Artist' t = encode.SafeRetagTask(self._path, taglist) self.runner.run(t)
gpl-3.0
[ 3, 1882, 4900, 26, 2018, 27, 511, 13, 2546, 13, 354, 26, 21333, 390, 2302, 14, 396, 14, 396, 63, 2330, 63, 2143, 1882, 199, 3, 1321, 26, 338, 26, 386, 26, 3519, 29, 20, 26, 10329, 29, 20, 26, 1086, 29, 20, 199, 199, 646, 747, 199, 646, 5549, 199, 199, 646, 25595, 199, 71, 785, 14, 6962, 63, 826, 342, 199, 199, 646, 486, 270, 199, 199, 504, 21333, 390, 2302, 14, 2330, 492, 3752, 199, 199, 504, 21333, 390, 2302, 14, 18587, 14, 1765, 492, 2120, 12, 486, 270, 24362, 199, 199, 504, 21333, 390, 2302, 14, 396, 492, 2863, 421, 199, 533, 6912, 1746, 8, 2330, 14, 1746, 304, 339, 347, 485, 396, 20126, 8, 277, 12, 4739, 304, 267, 327, 2952, 402, 4178, 921, 29220, 14, 784, 1377, 14, 1308, 15, 2384, 63, 1266, 14, 13814, 31, 344, 29, 2333, 1184, 821, 267, 327, 781, 1642, 1218, 314, 570, 543, 282, 283, 3302, 7, 1788, 12, 2066, 11441, 267, 291, 14, 5933, 275, 2120, 14, 10878, 7446, 8, 3832, 29, 797, 9, 267, 6111, 12, 931, 275, 5549, 14, 17721, 342, 398, 2088, 275, 298, 23908, 13, 9850, 298, 971, 288, 298, 8130, 396, 2164, 1967, 13, 17389, 29, 1960, 5845, 529, 2738, 29, 7727, 8546, 298, 971, 288, 298, 8130, 3916, 8546, 10491, 15, 88, 13, 1773, 13, 442, 12, 2063, 29, 975, 12, 4631, 29, 975, 12, 6324, 275, 18, 8546, 298, 971, 288, 298, 758, 1856, 67, 8546, 298, 971, 288, 298, 1725, 2292, 2909, 26766, 83, 4451, 690, 1182, 2374, 15, 2307, 499, 18181, 17, 2, 450, 334, 288, 486, 270, 24362, 14, 3513, 4003, 8, 515, 680, 2143, 360, 1624, 13, 24, 659, 776, 267, 291, 14, 1757, 360, 9602, 2088, 450, 82, 7, 450, 2088, 9, 267, 747, 14, 2253, 8, 1760, 9, 267, 291, 14, 7589, 8, 736, 14, 515, 14, 2444, 8, 515, 430, 267, 747, 14, 1600, 8, 2592, 9, 398, 6111, 12, 30965, 275, 5549, 14, 17721, 8, 4511, 29, 4511, 9, 267, 747, 14, 8165, 8, 515, 12, 30965, 9, 398, 3752, 1765, 275, 3752, 14, 9686, 4476, 8, 1222, 515, 12, 30965, 435, 1987, 548, 297, 288, 3752, 14, 55, 1214, 5736, 1012, 267, 291, 14, 5933, 14, 1065, 8, 2143, 1765, 12, 3376, 29, 797, 9, 267, 747, 14, 1600, 8, 2592, 9, 267, 747, 14, 7162, 8, 1222, 515, 9, 267, 747, 14, 7162, 8, 1222, 515, 435, 1987, 548, 358, 421, 199, 533, 6140, 2042, 1746, 8, 2042, 1746, 12, 2863, 14, 7087, 22060, 304, 339, 347, 511, 7087, 2042, 8, 277, 304, 267, 327, 642, 511, 7704, 3238, 781, 883, 9040, 282, 2649, 931, 267, 291, 423, 396, 20126, 8, 85, 1370, 12416, 390, 2302, 14, 396, 63, 2143, 14, 34, 60, 1845, 323, 3091, 3621, 358, 421, 199, 533, 11514, 2042, 1746, 8, 2042, 1746, 304, 339, 347, 511, 7200, 12838, 8, 277, 304, 267, 291, 423, 396, 20126, 8, 85, 1674, 12416, 390, 2302, 14, 396, 63, 2143, 14, 39, 324, 83, 283, 46, 6848, 874, 531, 339, 347, 511, 7281, 12838, 8, 277, 304, 267, 291, 423, 396, 20126, 8, 85, 1370, 12416, 390, 2302, 14, 396, 63, 2143, 14, 713, 2, 5283, 358, 421, 199, 533, 8053, 3284, 1746, 8, 2330, 14, 1746, 304, 339, 347, 511, 3284, 8, 277, 304, 267, 931, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 399, 1133, 8085, 14, 14163, 67, 358, 267, 291, 14, 5933, 275, 2120, 14, 10878, 7446, 8, 3832, 29, 797, 9, 267, 307, 275, 3752, 14, 1931, 3284, 4476, 8, 515, 9, 267, 291, 14, 5933, 14, 1065, 8, 84, 9, 267, 291, 14, 7589, 8, 84, 14, 1450, 513, 9, 267, 291, 14, 2947, 8, 84, 14, 1450, 513, 459, 8130, 13, 9276, 995, 283, 3143, 1348, 358, 267, 291, 14, 2947, 8, 84, 14, 1450, 513, 459, 1802, 995, 283, 8130, 396, 12204, 358, 421, 199, 533, 8053, 3534, 1746, 8, 2330, 14, 1746, 304, 339, 347, 511, 3534, 8, 277, 304, 267, 6111, 12, 315, 515, 275, 5549, 14, 17721, 8, 4511, 29, 85, 1370, 12416, 390, 2302, 14, 1450, 952, 14, 14163, 67, 358, 398, 327, 12204, 365, 299, 2292, 13, 11838, 2952, 282, 15111, 308, 1132, 365, 5737, 4634, 30427, 267, 327, 701, 17566, 2497, 67, 436, 18899, 440, 8321, 11223, 315, 6057, 267, 327, 7600, 26, 570, 282, 6519, 367, 642, 315, 598, 933, 24362, 267, 747, 14, 2253, 360, 23908, 13, 9850, 283, 288, 283, 8130, 396, 2164, 283, 355, 283, 10024, 29, 26591, 13, 11838, 1967, 13, 17389, 29, 709, 5845, 529, 2738, 29, 29043, 8546, 283, 288, 283, 8130, 3916, 8546, 283, 288, 283, 8130, 15, 88, 13, 1773, 13, 442, 12, 6324, 29, 18, 12, 2063, 29, 975, 12, 3333, 29, 975, 12, 1866, 29, 1602, 1960, 8546, 283, 288, 283, 14163, 2497, 67, 8546, 1584, 2292, 2909, 2458, 83, 690, 1182, 2374, 15, 2307, 499, 18181, 17, 7, 450, 315, 515, 9, 267, 747, 14, 1600, 8, 2592, 9, 398, 6111, 12, 734, 515, 275, 5549, 14, 17721, 8, 4511, 29, 85, 1370, 12416, 390, 2302, 14, 1450, 952, 14, 14163, 67, 358, 267, 291, 14, 5933, 275, 2120, 14, 10878, 7446, 8, 3832, 29, 797, 9, 267, 1947, 513, 275, 486, 270, 14, 7552, 342, 267, 1947, 513, 59, 23908, 14, 6967, 63, 2294, 6225, 61, 275, 283, 27711, 7, 267, 1947, 513, 59, 23908, 14, 6967, 63, 19091, 61, 275, 283, 6888, 7, 398, 307, 275, 3752, 14, 1931, 3534, 4476, 8, 262, 515, 12, 734, 515, 12, 1947, 513, 9, 267, 291, 14, 5933, 14, 1065, 8, 84, 9, 398, 307, 275, 3752, 14, 1931, 3284, 4476, 8, 548, 515, 9, 267, 291, 14, 5933, 14, 1065, 8, 84, 9, 267, 291, 14, 7589, 8, 84, 14, 1450, 513, 9, 267, 291, 14, 2947, 8, 84, 14, 1450, 513, 459, 8130, 13, 9276, 995, 283, 3143, 1348, 358, 267, 291, 14, 2947, 8, 84, 14, 1450, 513, 459, 1802, 995, 283, 8130, 396, 12204, 358, 267, 291, 14, 2947, 8, 84, 14, 1450, 513, 59, 23908, 14 ]
[ 1882, 4900, 26, 2018, 27, 511, 13, 2546, 13, 354, 26, 21333, 390, 2302, 14, 396, 14, 396, 63, 2330, 63, 2143, 1882, 199, 3, 1321, 26, 338, 26, 386, 26, 3519, 29, 20, 26, 10329, 29, 20, 26, 1086, 29, 20, 199, 199, 646, 747, 199, 646, 5549, 199, 199, 646, 25595, 199, 71, 785, 14, 6962, 63, 826, 342, 199, 199, 646, 486, 270, 199, 199, 504, 21333, 390, 2302, 14, 2330, 492, 3752, 199, 199, 504, 21333, 390, 2302, 14, 18587, 14, 1765, 492, 2120, 12, 486, 270, 24362, 199, 199, 504, 21333, 390, 2302, 14, 396, 492, 2863, 421, 199, 533, 6912, 1746, 8, 2330, 14, 1746, 304, 339, 347, 485, 396, 20126, 8, 277, 12, 4739, 304, 267, 327, 2952, 402, 4178, 921, 29220, 14, 784, 1377, 14, 1308, 15, 2384, 63, 1266, 14, 13814, 31, 344, 29, 2333, 1184, 821, 267, 327, 781, 1642, 1218, 314, 570, 543, 282, 283, 3302, 7, 1788, 12, 2066, 11441, 267, 291, 14, 5933, 275, 2120, 14, 10878, 7446, 8, 3832, 29, 797, 9, 267, 6111, 12, 931, 275, 5549, 14, 17721, 342, 398, 2088, 275, 298, 23908, 13, 9850, 298, 971, 288, 298, 8130, 396, 2164, 1967, 13, 17389, 29, 1960, 5845, 529, 2738, 29, 7727, 8546, 298, 971, 288, 298, 8130, 3916, 8546, 10491, 15, 88, 13, 1773, 13, 442, 12, 2063, 29, 975, 12, 4631, 29, 975, 12, 6324, 275, 18, 8546, 298, 971, 288, 298, 758, 1856, 67, 8546, 298, 971, 288, 298, 1725, 2292, 2909, 26766, 83, 4451, 690, 1182, 2374, 15, 2307, 499, 18181, 17, 2, 450, 334, 288, 486, 270, 24362, 14, 3513, 4003, 8, 515, 680, 2143, 360, 1624, 13, 24, 659, 776, 267, 291, 14, 1757, 360, 9602, 2088, 450, 82, 7, 450, 2088, 9, 267, 747, 14, 2253, 8, 1760, 9, 267, 291, 14, 7589, 8, 736, 14, 515, 14, 2444, 8, 515, 430, 267, 747, 14, 1600, 8, 2592, 9, 398, 6111, 12, 30965, 275, 5549, 14, 17721, 8, 4511, 29, 4511, 9, 267, 747, 14, 8165, 8, 515, 12, 30965, 9, 398, 3752, 1765, 275, 3752, 14, 9686, 4476, 8, 1222, 515, 12, 30965, 435, 1987, 548, 297, 288, 3752, 14, 55, 1214, 5736, 1012, 267, 291, 14, 5933, 14, 1065, 8, 2143, 1765, 12, 3376, 29, 797, 9, 267, 747, 14, 1600, 8, 2592, 9, 267, 747, 14, 7162, 8, 1222, 515, 9, 267, 747, 14, 7162, 8, 1222, 515, 435, 1987, 548, 358, 421, 199, 533, 6140, 2042, 1746, 8, 2042, 1746, 12, 2863, 14, 7087, 22060, 304, 339, 347, 511, 7087, 2042, 8, 277, 304, 267, 327, 642, 511, 7704, 3238, 781, 883, 9040, 282, 2649, 931, 267, 291, 423, 396, 20126, 8, 85, 1370, 12416, 390, 2302, 14, 396, 63, 2143, 14, 34, 60, 1845, 323, 3091, 3621, 358, 421, 199, 533, 11514, 2042, 1746, 8, 2042, 1746, 304, 339, 347, 511, 7200, 12838, 8, 277, 304, 267, 291, 423, 396, 20126, 8, 85, 1674, 12416, 390, 2302, 14, 396, 63, 2143, 14, 39, 324, 83, 283, 46, 6848, 874, 531, 339, 347, 511, 7281, 12838, 8, 277, 304, 267, 291, 423, 396, 20126, 8, 85, 1370, 12416, 390, 2302, 14, 396, 63, 2143, 14, 713, 2, 5283, 358, 421, 199, 533, 8053, 3284, 1746, 8, 2330, 14, 1746, 304, 339, 347, 511, 3284, 8, 277, 304, 267, 931, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 399, 1133, 8085, 14, 14163, 67, 358, 267, 291, 14, 5933, 275, 2120, 14, 10878, 7446, 8, 3832, 29, 797, 9, 267, 307, 275, 3752, 14, 1931, 3284, 4476, 8, 515, 9, 267, 291, 14, 5933, 14, 1065, 8, 84, 9, 267, 291, 14, 7589, 8, 84, 14, 1450, 513, 9, 267, 291, 14, 2947, 8, 84, 14, 1450, 513, 459, 8130, 13, 9276, 995, 283, 3143, 1348, 358, 267, 291, 14, 2947, 8, 84, 14, 1450, 513, 459, 1802, 995, 283, 8130, 396, 12204, 358, 421, 199, 533, 8053, 3534, 1746, 8, 2330, 14, 1746, 304, 339, 347, 511, 3534, 8, 277, 304, 267, 6111, 12, 315, 515, 275, 5549, 14, 17721, 8, 4511, 29, 85, 1370, 12416, 390, 2302, 14, 1450, 952, 14, 14163, 67, 358, 398, 327, 12204, 365, 299, 2292, 13, 11838, 2952, 282, 15111, 308, 1132, 365, 5737, 4634, 30427, 267, 327, 701, 17566, 2497, 67, 436, 18899, 440, 8321, 11223, 315, 6057, 267, 327, 7600, 26, 570, 282, 6519, 367, 642, 315, 598, 933, 24362, 267, 747, 14, 2253, 360, 23908, 13, 9850, 283, 288, 283, 8130, 396, 2164, 283, 355, 283, 10024, 29, 26591, 13, 11838, 1967, 13, 17389, 29, 709, 5845, 529, 2738, 29, 29043, 8546, 283, 288, 283, 8130, 3916, 8546, 283, 288, 283, 8130, 15, 88, 13, 1773, 13, 442, 12, 6324, 29, 18, 12, 2063, 29, 975, 12, 3333, 29, 975, 12, 1866, 29, 1602, 1960, 8546, 283, 288, 283, 14163, 2497, 67, 8546, 1584, 2292, 2909, 2458, 83, 690, 1182, 2374, 15, 2307, 499, 18181, 17, 7, 450, 315, 515, 9, 267, 747, 14, 1600, 8, 2592, 9, 398, 6111, 12, 734, 515, 275, 5549, 14, 17721, 8, 4511, 29, 85, 1370, 12416, 390, 2302, 14, 1450, 952, 14, 14163, 67, 358, 267, 291, 14, 5933, 275, 2120, 14, 10878, 7446, 8, 3832, 29, 797, 9, 267, 1947, 513, 275, 486, 270, 14, 7552, 342, 267, 1947, 513, 59, 23908, 14, 6967, 63, 2294, 6225, 61, 275, 283, 27711, 7, 267, 1947, 513, 59, 23908, 14, 6967, 63, 19091, 61, 275, 283, 6888, 7, 398, 307, 275, 3752, 14, 1931, 3534, 4476, 8, 262, 515, 12, 734, 515, 12, 1947, 513, 9, 267, 291, 14, 5933, 14, 1065, 8, 84, 9, 398, 307, 275, 3752, 14, 1931, 3284, 4476, 8, 548, 515, 9, 267, 291, 14, 5933, 14, 1065, 8, 84, 9, 267, 291, 14, 7589, 8, 84, 14, 1450, 513, 9, 267, 291, 14, 2947, 8, 84, 14, 1450, 513, 459, 8130, 13, 9276, 995, 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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 ]
nitzmahone/ansible
lib/ansible/modules/cloud/amazon/iam_role_facts.py
50
8111
#!/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: iam_role_facts short_description: Gather information on IAM roles description: - Gathers information about IAM roles version_added: "2.5" requirements: [ boto3 ] author: - "Will Thames (@willthames)" options: name: description: - Name of a role to search for - Mutually exclusive with C(prefix) aliases: - role_name path_prefix: description: - Prefix of role I(path) to restrict IAM role search for - Mutually exclusive with C(name) extends_documentation_fragment: - aws - ec2 ''' EXAMPLES = ''' # find all existing IAM roles - iam_role_facts: register: result # describe a single role - iam_role_facts: name: MyIAMRole # describe all roles matching a path prefix - iam_role_facts: path_prefix: /application/path ''' RETURN = ''' iam_roles: description: List of IAM roles returned: always type: complex contains: arn: description: Amazon Resource Name for IAM role returned: always type: string sample: arn:aws:iam::123456789012:role/AnsibleTestRole assume_role_policy_document: description: Policy Document describing what can assume the role returned: always type: string create_date: description: Date IAM role was created returned: always type: string sample: '2017-10-23T00:05:08+00:00' inline_policies: description: List of names of inline policies returned: always type: list sample: [] managed_policies: description: List of attached managed policies returned: always type: complex contains: policy_arn: description: Amazon Resource Name for the policy returned: always type: string sample: arn:aws:iam::123456789012:policy/AnsibleTestEC2Policy policy_name: description: Name of managed policy returned: always type: string sample: AnsibleTestEC2Policy instance_profiles: description: List of attached instance profiles returned: always type: complex contains: arn: description: Amazon Resource Name for the instance profile returned: always type: string sample: arn:aws:iam::123456789012:instance-profile/AnsibleTestEC2Policy create_date: description: Date instance profile was created returned: always type: string sample: '2017-10-23T00:05:08+00:00' instance_profile_id: description: Amazon Identifier for the instance profile returned: always type: string sample: AROAII7ABCD123456EFGH instance_profile_name: description: Name of instance profile returned: always type: string sample: AnsibleTestEC2Policy path: description: Path of instance profile returned: always type: string sample: / roles: description: List of roles associated with this instance profile returned: always type: list sample: [] path: description: Path of role returned: always type: string sample: / role_id: description: Amazon Identifier for the role returned: always type: string sample: AROAII7ABCD123456EFGH role_name: description: Name of the role returned: always type: string sample: AnsibleTestRole ''' try: import botocore except ImportError: pass # caught by AnsibleAWSModule from ansible.module_utils.aws.core import AnsibleAWSModule from ansible.module_utils.ec2 import boto3_conn, get_aws_connection_info, ec2_argument_spec, AWSRetry from ansible.module_utils.ec2 import camel_dict_to_snake_dict @AWSRetry.exponential_backoff() def list_iam_roles_with_backoff(client, **kwargs): paginator = client.get_paginator('list_roles') return paginator.paginate(**kwargs).build_full_result() @AWSRetry.exponential_backoff() def list_iam_role_policies_with_backoff(client, role_name): paginator = client.get_paginator('list_role_policies') return paginator.paginate(RoleName=role_name).build_full_result()['PolicyNames'] @AWSRetry.exponential_backoff() def list_iam_attached_role_policies_with_backoff(client, role_name): paginator = client.get_paginator('list_attached_role_policies') return paginator.paginate(RoleName=role_name).build_full_result()['AttachedPolicies'] @AWSRetry.exponential_backoff() def list_iam_instance_profiles_for_role_with_backoff(client, role_name): paginator = client.get_paginator('list_instance_profiles_for_role') return paginator.paginate(RoleName=role_name).build_full_result()['InstanceProfiles'] def describe_iam_role(module, client, role): name = role['RoleName'] try: role['InlinePolicies'] = list_iam_role_policies_with_backoff(client, name) except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: module.fail_json_aws(e, msg="Couldn't get inline policies for role %s" % name) try: role['ManagedPolicies'] = list_iam_attached_role_policies_with_backoff(client, name) except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: module.fail_json_aws(e, msg="Couldn't get managed policies for role %s" % name) try: role['InstanceProfiles'] = list_iam_instance_profiles_for_role_with_backoff(client, name) except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: module.fail_json_aws(e, msg="Couldn't get instance profiles for role %s" % name) return role def describe_iam_roles(module, client): name = module.params['name'] path_prefix = module.params['path_prefix'] if name: try: roles = [client.get_role(RoleName=name)['Role']] except botocore.exceptions.ClientError as e: if e.response['Error']['Code'] == 'NoSuchEntity': return [] else: module.fail_json_aws(e, msg="Couldn't get IAM role %s" % name) except botocore.exceptions.BotoCoreError as e: module.fail_json_aws(e, msg="Couldn't get IAM role %s" % name) else: params = dict() if path_prefix: if not path_prefix.startswith('/'): path_prefix = '/' + path_prefix if not path_prefix.endswith('/'): path_prefix = path_prefix + '/' params['PathPrefix'] = path_prefix try: roles = list_iam_roles_with_backoff(client, **params)['Roles'] except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: module.fail_json_aws(e, msg="Couldn't list IAM roles") return [camel_dict_to_snake_dict(describe_iam_role(module, client, role)) for role in roles] def main(): """ Module action handler """ argument_spec = ec2_argument_spec() argument_spec.update(dict( name=dict(aliases=['role_name']), path_prefix=dict(), )) module = AnsibleAWSModule(argument_spec=argument_spec, supports_check_mode=True, mutually_exclusive=[['name', 'path_prefix']]) region, ec2_url, aws_connect_params = get_aws_connection_info(module, boto3=True) client = boto3_conn(module, conn_type='client', resource='iam', region=region, endpoint=ec2_url, **aws_connect_params) module.exit_json(changed=False, iam_roles=describe_iam_roles(module, client)) 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, 22361, 63, 3756, 63, 5047, 199, 3612, 63, 1802, 26, 19634, 2556, 641, 28155, 11689, 199, 1802, 26, 272, 446, 19634, 83, 2556, 3595, 28155, 11689, 199, 1023, 63, 3270, 26, 298, 18, 14, 21, 2, 199, 7538, 26, 359, 6055, 19, 1622, 199, 2502, 26, 272, 446, 298, 20326, 3868, 14015, 8593, 14117, 273, 14015, 2924, 199, 1419, 26, 272, 536, 26, 267, 1369, 26, 288, 446, 2812, 402, 282, 4719, 370, 2754, 367, 288, 446, 26550, 3163, 13914, 543, 445, 8, 1861, 9, 267, 5481, 26, 288, 446, 4719, 63, 354, 272, 931, 63, 1861, 26, 267, 1369, 26, 288, 446, 25110, 402, 4719, 473, 8, 515, 9, 370, 18152, 28155, 4719, 2754, 367, 288, 446, 26550, 3163, 13914, 543, 445, 8, 354, 9, 199, 11036, 63, 9970, 63, 7677, 26, 523, 446, 11488, 523, 446, 7062, 18, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2342, 1006, 3411, 28155, 11689, 199, 13, 22361, 63, 3756, 63, 5047, 26, 523, 2274, 26, 754, 199, 199, 3, 13743, 282, 2849, 4719, 199, 13, 22361, 63, 3756, 63, 5047, 26, 272, 536, 26, 4932, 41, 1156, 7422, 199, 199, 3, 13743, 1006, 11689, 4877, 282, 931, 2403, 199, 13, 22361, 63, 3756, 63, 5047, 26, 272, 931, 63, 1861, 26, 1182, 3578, 15, 515, 199, 2344, 199, 199, 9677, 275, 1449, 199, 17741, 63, 8050, 26, 523, 1369, 26, 3820, 402, 28155, 11689, 523, 2138, 26, 3544, 523, 730, 26, 6114, 523, 3509, 26, 272, 601, 78, 26, 489, 1369, 26, 14347, 7337, 2812, 367, 28155, 4719, 489, 2138, 26, 3544, 489, 730, 26, 1059, 489, 2690, 26, 601, 78, 26, 7231, 26, 17741, 447, 11272, 11533, 26, 3756, 15, 10047, 774, 7422, 272, 5534, 63, 3756, 63, 3185, 63, 3554, 26, 489, 1369, 26, 18141, 7543, 13660, 4052, 883, 5534, 314, 4719, 489, 2138, 26, 3544, 489, 730, 26, 1059, 272, 1218, 63, 602, 26, 489, 1369, 26, 6148, 28155, 4719, 1990, 2737, 489, 2138, 26, 3544, 489, 730, 26, 1059, 489, 2690, 26, 283, 10680, 13, 709, 13, 1789, 52, 383, 26, 1717, 26, 2036, 11, 383, 26, 383, 7, 272, 8308, 63, 11767, 26, 489, 1369, 26, 3820, 402, 1561, 402, 8308, 14118, 489, 2138, 26, 3544, 489, 730, 26, 769, 489, 2690, 26, 942, 272, 12883, 63, 11767, 26, 489, 1369, 26, 3820, 402, 10102, 12883, 14118, 489, 2138, 26, 3544, 489, 730, 26, 6114, 489, 3509, 26, 267, 4592, 63, 1060, 26, 881, 1369, 26, 14347, 7337, 2812, 367, 314, 4592, 881, 2138, 26, 3544, 881, 730, 26, 1059, 881, 2690, 26, 601, 78, 26, 7231, 26, 17741, 447, 11272, 11533, 26, 3185, 15, 10047, 774, 4220, 18, 4845, 267, 4592, 63, 354, 26, 881, 1369, 26, 2812, 402, 12883, 4592, 881, 2138, 26, 3544, 881, 730, 26, 1059, 881, 2690, 26, 2622, 774, 4220, 18, 4845, 272, 1256, 63, 11225, 26, 489, 1369, 26, 3820, 402, 10102, 1256, 17390, 489, 2138, 26, 3544, 489, 730, 26, 6114, 489, 3509, 26, 267, 601, 78, 26, 881, 1369, 26, 14347, 7337, 2812, 367, 314, 1256, 4690, 881, 2138, 26, 3544, 881, 730, 26, 1059, 881, 2690, 26, 601, 78, 26, 7231, 26, 17741, 447, 11272, 11533, 26, 842, 13, 2913, 15, 10047, 774, 4220, 18, 4845, 267, 1218, 63, 602, 26, 881, 1369, 26, 6148, 1256, 4690, 1990, 2737, 881, 2138, 26, 3544, 881, 730, 26, 1059, 881, 2690, 26, 283, 10680, 13, 709, 13, 1789, 52, 383, 26, 1717, 26, 2036, 11, 383, 26, 383, 7, 267, 1256, 63, 2913, 63, 344, 26, 881, 1369, 26, 14347, 23285, 367, 314, 1256, 4690, 881, 2138, 26, 3544, 881, 730, 26, 1059, 881, 2690, 26, 437, 1092, 7730, 41, 23, 31578, 19060, 14153, 31916, 267, 1256, 63, 2913, 63, 354, 26, 881, 1369, 26, 2812, 402, 1256, 4690, 881, 2138, 26, 3544, 881, 730, 26, 1059, 881, 2690, 26, 2622, 774, 4220, 18, 4845, 267, 931, 26, 881, 1369, 26, 6912, 402, 1256, 4690, 881, 2138, 26, 3544, 881, 730, 26, 1059, 881, 2690, 26, 1182, 267, 11689, 26, 881, 1369, 26, 3820, 402, 11689, 4568, 543, 642, 1256, 4690, 881, 2138, 26, 3544, 881, 730, 26, 769, 881, 2690, 26, 942, 272, 931, 26, 489, 1369, 26, 6912, 402, 4719, 489, 2138, 26, 3544, 489, 730, 26, 1059, 489, 2690, 26, 1182, 272, 4719, 63, 344, 26, 489, 1369, 26, 14347, 23285, 367, 314, 4719, 489, 2138, 26, 3544, 489, 730, 26, 1059, 489, 2690, 26, 437, 1092, 7730, 41, 23, 31578, 19060, 14153, 31916, 272, 4719, 63, 354, 26, 489, 1369, 26, 2812, 402, 314, 4719, 489, 2138, 26, 3544, 489, 730, 26, 1059, 489, 2690, 26, 2622, 774, 7422, 199, 2344, 199, 199, 893, 26, 272, 492, 21199, 199, 2590, 3545, 26, 272, 986, 221, 327, 15604, 701, 2622, 13226, 2377, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 7231, 14, 1018, 492, 2622, 13226, 2377, 199, 504, 3242, 14, 578, 63, 1208, 14, 825, 18, 492, 6055, 19, 63, 1631, 12, 664, 63, 7231, 63, 2105, 63, 815, 12, 7062, 18, 63, 2094, 63, 1650, 12, 10168, 12989, 199, 504, 3242, 14, 578, 63, 1208, 14, 825, 18, 492, 31129, 63, 807, 63, 475, 63, 21415, 63, 807, 421, 199, 32, 13226, 12989, 14, 27093, 63, 21061, 342, 199, 318, 769, 63, 17741, 63, 8050, 63, 1045, 63, 21061, 8, 1258, 12, 1011, 958, 304, 272, 21398, 275, 1890, 14, 362, 63, 22073, 360, 513, 63, 8050, 358, 272, 372, 21398, 14, 30979, 3682, 958, 680 ]
[ 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, 22361, 63, 3756, 63, 5047, 199, 3612, 63, 1802, 26, 19634, 2556, 641, 28155, 11689, 199, 1802, 26, 272, 446, 19634, 83, 2556, 3595, 28155, 11689, 199, 1023, 63, 3270, 26, 298, 18, 14, 21, 2, 199, 7538, 26, 359, 6055, 19, 1622, 199, 2502, 26, 272, 446, 298, 20326, 3868, 14015, 8593, 14117, 273, 14015, 2924, 199, 1419, 26, 272, 536, 26, 267, 1369, 26, 288, 446, 2812, 402, 282, 4719, 370, 2754, 367, 288, 446, 26550, 3163, 13914, 543, 445, 8, 1861, 9, 267, 5481, 26, 288, 446, 4719, 63, 354, 272, 931, 63, 1861, 26, 267, 1369, 26, 288, 446, 25110, 402, 4719, 473, 8, 515, 9, 370, 18152, 28155, 4719, 2754, 367, 288, 446, 26550, 3163, 13914, 543, 445, 8, 354, 9, 199, 11036, 63, 9970, 63, 7677, 26, 523, 446, 11488, 523, 446, 7062, 18, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2342, 1006, 3411, 28155, 11689, 199, 13, 22361, 63, 3756, 63, 5047, 26, 523, 2274, 26, 754, 199, 199, 3, 13743, 282, 2849, 4719, 199, 13, 22361, 63, 3756, 63, 5047, 26, 272, 536, 26, 4932, 41, 1156, 7422, 199, 199, 3, 13743, 1006, 11689, 4877, 282, 931, 2403, 199, 13, 22361, 63, 3756, 63, 5047, 26, 272, 931, 63, 1861, 26, 1182, 3578, 15, 515, 199, 2344, 199, 199, 9677, 275, 1449, 199, 17741, 63, 8050, 26, 523, 1369, 26, 3820, 402, 28155, 11689, 523, 2138, 26, 3544, 523, 730, 26, 6114, 523, 3509, 26, 272, 601, 78, 26, 489, 1369, 26, 14347, 7337, 2812, 367, 28155, 4719, 489, 2138, 26, 3544, 489, 730, 26, 1059, 489, 2690, 26, 601, 78, 26, 7231, 26, 17741, 447, 11272, 11533, 26, 3756, 15, 10047, 774, 7422, 272, 5534, 63, 3756, 63, 3185, 63, 3554, 26, 489, 1369, 26, 18141, 7543, 13660, 4052, 883, 5534, 314, 4719, 489, 2138, 26, 3544, 489, 730, 26, 1059, 272, 1218, 63, 602, 26, 489, 1369, 26, 6148, 28155, 4719, 1990, 2737, 489, 2138, 26, 3544, 489, 730, 26, 1059, 489, 2690, 26, 283, 10680, 13, 709, 13, 1789, 52, 383, 26, 1717, 26, 2036, 11, 383, 26, 383, 7, 272, 8308, 63, 11767, 26, 489, 1369, 26, 3820, 402, 1561, 402, 8308, 14118, 489, 2138, 26, 3544, 489, 730, 26, 769, 489, 2690, 26, 942, 272, 12883, 63, 11767, 26, 489, 1369, 26, 3820, 402, 10102, 12883, 14118, 489, 2138, 26, 3544, 489, 730, 26, 6114, 489, 3509, 26, 267, 4592, 63, 1060, 26, 881, 1369, 26, 14347, 7337, 2812, 367, 314, 4592, 881, 2138, 26, 3544, 881, 730, 26, 1059, 881, 2690, 26, 601, 78, 26, 7231, 26, 17741, 447, 11272, 11533, 26, 3185, 15, 10047, 774, 4220, 18, 4845, 267, 4592, 63, 354, 26, 881, 1369, 26, 2812, 402, 12883, 4592, 881, 2138, 26, 3544, 881, 730, 26, 1059, 881, 2690, 26, 2622, 774, 4220, 18, 4845, 272, 1256, 63, 11225, 26, 489, 1369, 26, 3820, 402, 10102, 1256, 17390, 489, 2138, 26, 3544, 489, 730, 26, 6114, 489, 3509, 26, 267, 601, 78, 26, 881, 1369, 26, 14347, 7337, 2812, 367, 314, 1256, 4690, 881, 2138, 26, 3544, 881, 730, 26, 1059, 881, 2690, 26, 601, 78, 26, 7231, 26, 17741, 447, 11272, 11533, 26, 842, 13, 2913, 15, 10047, 774, 4220, 18, 4845, 267, 1218, 63, 602, 26, 881, 1369, 26, 6148, 1256, 4690, 1990, 2737, 881, 2138, 26, 3544, 881, 730, 26, 1059, 881, 2690, 26, 283, 10680, 13, 709, 13, 1789, 52, 383, 26, 1717, 26, 2036, 11, 383, 26, 383, 7, 267, 1256, 63, 2913, 63, 344, 26, 881, 1369, 26, 14347, 23285, 367, 314, 1256, 4690, 881, 2138, 26, 3544, 881, 730, 26, 1059, 881, 2690, 26, 437, 1092, 7730, 41, 23, 31578, 19060, 14153, 31916, 267, 1256, 63, 2913, 63, 354, 26, 881, 1369, 26, 2812, 402, 1256, 4690, 881, 2138, 26, 3544, 881, 730, 26, 1059, 881, 2690, 26, 2622, 774, 4220, 18, 4845, 267, 931, 26, 881, 1369, 26, 6912, 402, 1256, 4690, 881, 2138, 26, 3544, 881, 730, 26, 1059, 881, 2690, 26, 1182, 267, 11689, 26, 881, 1369, 26, 3820, 402, 11689, 4568, 543, 642, 1256, 4690, 881, 2138, 26, 3544, 881, 730, 26, 769, 881, 2690, 26, 942, 272, 931, 26, 489, 1369, 26, 6912, 402, 4719, 489, 2138, 26, 3544, 489, 730, 26, 1059, 489, 2690, 26, 1182, 272, 4719, 63, 344, 26, 489, 1369, 26, 14347, 23285, 367, 314, 4719, 489, 2138, 26, 3544, 489, 730, 26, 1059, 489, 2690, 26, 437, 1092, 7730, 41, 23, 31578, 19060, 14153, 31916, 272, 4719, 63, 354, 26, 489, 1369, 26, 2812, 402, 314, 4719, 489, 2138, 26, 3544, 489, 730, 26, 1059, 489, 2690, 26, 2622, 774, 7422, 199, 2344, 199, 199, 893, 26, 272, 492, 21199, 199, 2590, 3545, 26, 272, 986, 221, 327, 15604, 701, 2622, 13226, 2377, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 7231, 14, 1018, 492, 2622, 13226, 2377, 199, 504, 3242, 14, 578, 63, 1208, 14, 825, 18, 492, 6055, 19, 63, 1631, 12, 664, 63, 7231, 63, 2105, 63, 815, 12, 7062, 18, 63, 2094, 63, 1650, 12, 10168, 12989, 199, 504, 3242, 14, 578, 63, 1208, 14, 825, 18, 492, 31129, 63, 807, 63, 475, 63, 21415, 63, 807, 421, 199, 32, 13226, 12989, 14, 27093, 63, 21061, 342, 199, 318, 769, 63, 17741, 63, 8050, 63, 1045, 63, 21061, 8, 1258, 12, 1011, 958, 304, 272, 21398, 275, 1890, 14, 362, 63, 22073, 360, 513, 63, 8050, 358, 272, 372, 21398, 14, 30979, 3682, 958, 680, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
EDUlib/edx-platform
cms/djangoapps/contentstore/outlines.py
1
8767
""" This is where Studio interacts with the learning_sequences application, which is responsible for holding course outline data. Studio _pushes_ that data into learning_sequences at publish time. """ from datetime import timezone from typing import List, Tuple from edx_django_utils.monitoring import function_trace, set_custom_attribute from openedx.core.djangoapps.content.learning_sequences.api import replace_course_outline from openedx.core.djangoapps.content.learning_sequences.data import ( ContentErrorData, CourseLearningSequenceData, CourseOutlineData, CourseSectionData, CourseVisibility, ExamData, VisibilityData ) from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.django import modulestore def _remove_version_info(usage_key): """ When we ask modulestore for the published branch in the Studio process after catching a publish signal, the items that have been changed will return UsageKeys that have full version information in their attached CourseKeys. This makes them hash and serialize differently. We want to strip this information and have everything use a CourseKey with no version information attached. The fact that this versioned CourseKey appears is likely an unintended side-effect, rather than an intentional part of the API contract. It also likely doesn't happen when the modulestore is being processed from a different process than the one doing the writing (e.g. a celery task running on any environment other than devstack). But stripping this version information out is necessary to make devstack and tests work properly. """ unversioned_course_key = usage_key.course_key.replace(branch=None, version_guid=None) return usage_key.map_into_course(unversioned_course_key) def _error_for_not_section(not_section): """ ContentErrorData when we run into a child of <course> that's not a Section. Has to be phrased in a way that makes sense to course teams. """ return ContentErrorData( message=( f'<course> contains a <{not_section.location.block_type}> tag with ' f'url_name="{not_section.location.block_id}" and ' f'display_name="{getattr(not_section, "display_name", "")}". ' f'Expected <chapter> tag instead.' ), usage_key=_remove_version_info(not_section.location), ) def _error_for_not_sequence(section, not_sequence): """ ContentErrorData when we run into a child of Section that's not a Sequence. Has to be phrased in a way that makes sense to course teams. """ return ContentErrorData( message=( f'<chapter> with url_name="{section.location.block_id}" and ' f'display_name="{section.display_name}" contains a ' f'<{not_sequence.location.block_type}> tag with ' f'url_name="{not_sequence.location.block_id}" and ' f'display_name="{getattr(not_sequence, "display_name", "")}". ' f'Expected a <sequential> tag instead.' ), usage_key=_remove_version_info(not_sequence.location), ) def _make_section_data(section): """ Return a (CourseSectionData, List[ContentDataError]) from a SectionBlock. Can return None for CourseSectionData if it's not really a SectionBlock that was passed in. This method does a lot of the work to convert modulestore fields to an input that the learning_sequences app expects. OLX import permits structures that are much less constrained than Studio's UI allows for, so whenever we run into something that does not meet our Course -> Section -> Subsection hierarchy expectations, we add a support-team-readable error message to our list of ContentDataErrors to pass back. At this point in the code, everything has already been deserialized into SectionBlocks and SequenceBlocks, but we're going to phrase our messages in ways that would make sense to someone looking at the import OLX, since that is the layer that the course teams and support teams are working with. """ section_errors = [] # First check if it's not a section at all, and short circuit if it isn't. if section.location.block_type != 'chapter': section_errors.append(_error_for_not_section(section)) return (None, section_errors) # We haven't officially killed off problemset and videosequence yet, so # treat them as equivalent to sequential for now. valid_sequence_tags = ['sequential', 'problemset', 'videosequence'] sequences_data = [] for sequence in section.get_children(): if sequence.location.block_type not in valid_sequence_tags: section_errors.append(_error_for_not_sequence(section, sequence)) continue sequences_data.append( CourseLearningSequenceData( usage_key=_remove_version_info(sequence.location), title=sequence.display_name_with_default, inaccessible_after_due=sequence.hide_after_due, exam=ExamData( is_practice_exam=sequence.is_practice_exam, is_proctored_enabled=sequence.is_proctored_enabled, is_time_limited=sequence.is_time_limited, ), visibility=VisibilityData( hide_from_toc=sequence.hide_from_toc, visible_to_staff_only=sequence.visible_to_staff_only, ), ) ) section_data = CourseSectionData( usage_key=_remove_version_info(section.location), title=section.display_name_with_default, sequences=sequences_data, visibility=VisibilityData( hide_from_toc=section.hide_from_toc, visible_to_staff_only=section.visible_to_staff_only, ), ) return section_data, section_errors @function_trace('get_outline_from_modulestore') def get_outline_from_modulestore(course_key) -> Tuple[CourseOutlineData, List[ContentErrorData]]: """ Return a CourseOutlineData and list of ContentErrorData for param:course_key This function does not write any data as a side-effect. It generates a CourseOutlineData by inspecting the contents in the modulestore, but does not push that data anywhere. This function only operates on the published branch, and will not work on Old Mongo courses. """ store = modulestore() content_errors = [] with store.branch_setting(ModuleStoreEnum.Branch.published_only, course_key): course = store.get_course(course_key, depth=2) sections_data = [] for section in course.get_children(): section_data, section_errors = _make_section_data(section) if section_data: sections_data.append(section_data) content_errors.extend(section_errors) course_outline_data = CourseOutlineData( course_key=course_key, title=course.display_name_with_default, # subtree_edited_on has a tzinfo of bson.tz_util.FixedOffset (which # maps to UTC), but for consistency, we're going to use the standard # python timezone.utc (which is what the learning_sequence app will # return from MySQL). They will compare as equal. published_at=course.subtree_edited_on.replace(tzinfo=timezone.utc), # .course_version is a BSON obj, so we convert to str (MongoDB- # specific objects don't go into CourseOutlineData). published_version=str(course.course_version), entrance_exam_id=course.entrance_exam_id, days_early_for_beta=course.days_early_for_beta, sections=sections_data, self_paced=course.self_paced, course_visibility=CourseVisibility(course.course_visibility), ) return (course_outline_data, content_errors) def update_outline_from_modulestore(course_key): """ Update the CourseOutlineData for course_key in the learning_sequences with ModuleStore data (i.e. what was most recently published in Studio). """ # Set the course_id attribute first so that if getting the information # from the modulestore errors out, we still have the course_key reported in # New Relic for easier trace debugging. set_custom_attribute('course_id', str(course_key)) course_outline_data, content_errors = get_outline_from_modulestore(course_key) set_custom_attribute('num_sequences', len(course_outline_data.sequences)) set_custom_attribute('num_content_errors', len(content_errors)) replace_course_outline(course_outline_data, content_errors=content_errors)
agpl-3.0
[ 624, 199, 2765, 365, 2382, 13225, 17232, 83, 543, 314, 9328, 63, 13436, 4223, 12, 1314, 199, 374, 17845, 367, 17573, 2518, 17964, 666, 14, 13225, 485, 5335, 397, 63, 626, 666, 1901, 199, 10546, 63, 13436, 737, 2780, 900, 14, 199, 624, 199, 504, 2197, 492, 7137, 199, 504, 14090, 492, 3820, 12, 11634, 199, 199, 504, 22435, 63, 1176, 63, 1208, 14, 20554, 492, 805, 63, 3446, 12, 663, 63, 4229, 63, 3215, 199, 199, 504, 22709, 14, 1018, 14, 16432, 14, 1317, 14, 10546, 63, 13436, 14, 1246, 492, 3350, 63, 1972, 63, 11550, 199, 504, 22709, 14, 1018, 14, 16432, 14, 1317, 14, 10546, 63, 13436, 14, 576, 492, 334, 272, 6646, 547, 1451, 12, 272, 5531, 25519, 5826, 1451, 12, 272, 5531, 21432, 1451, 12, 272, 5531, 8660, 1451, 12, 272, 5531, 24735, 12, 272, 1316, 455, 1451, 12, 272, 6561, 4783, 1451, 199, 9, 199, 504, 9872, 14, 10012, 492, 23431, 199, 504, 9872, 14, 10012, 14, 1176, 492, 10996, 421, 199, 318, 485, 2168, 63, 1023, 63, 815, 8, 3807, 63, 498, 304, 272, 408, 272, 3979, 781, 7198, 10996, 367, 314, 3267, 5246, 315, 314, 13225, 2112, 272, 2410, 8579, 316, 282, 2780, 4673, 12, 314, 2974, 626, 1172, 2757, 2896, 911, 272, 372, 11028, 6340, 626, 1172, 2615, 1015, 2556, 315, 3932, 10102, 272, 5531, 6340, 14, 961, 7704, 3062, 2631, 436, 8437, 23142, 14, 2136, 2934, 370, 272, 6202, 642, 2556, 436, 1172, 8137, 675, 282, 22574, 543, 949, 272, 1015, 2556, 10102, 14, 339, 710, 10572, 626, 642, 31792, 22574, 11337, 365, 12060, 376, 625, 262, 6943, 272, 5366, 13, 5881, 12, 7830, 2419, 376, 25343, 279, 1777, 402, 314, 3261, 16077, 14, 2779, 272, 2597, 12060, 3181, 1133, 5992, 1380, 314, 10996, 365, 3769, 7686, 687, 272, 282, 3365, 2112, 2419, 314, 1373, 9689, 314, 3575, 334, 69, 14, 71, 14, 282, 22748, 2120, 272, 3879, 641, 1263, 3734, 1163, 2419, 4866, 2340, 680, 11017, 4024, 3637, 642, 272, 1015, 2556, 734, 365, 5784, 370, 1852, 4866, 2340, 436, 2295, 1736, 272, 7684, 14, 272, 408, 272, 625, 24155, 63, 1972, 63, 498, 275, 4503, 63, 498, 14, 1972, 63, 498, 14, 1814, 8, 4694, 29, 403, 12, 1015, 63, 9473, 29, 403, 9, 272, 372, 4503, 63, 498, 14, 1130, 63, 9924, 63, 1972, 8, 324, 24155, 63, 1972, 63, 498, 9, 421, 199, 318, 485, 705, 63, 509, 63, 1397, 63, 2792, 8, 1397, 63, 2792, 304, 272, 408, 272, 6646, 547, 1451, 1380, 781, 1255, 1901, 282, 1982, 402, 665, 1972, 30, 626, 1159, 440, 282, 15247, 14, 339, 13481, 370, 506, 3945, 345, 939, 315, 282, 4340, 626, 7704, 12249, 370, 2518, 25823, 14, 272, 408, 272, 372, 6646, 547, 1451, 8, 267, 1245, 2687, 288, 289, 7601, 1972, 30, 3509, 282, 665, 91, 1397, 63, 2792, 14, 1985, 14, 1457, 63, 466, 93, 30, 1947, 543, 283, 288, 289, 7, 633, 63, 354, 18448, 1397, 63, 2792, 14, 1985, 14, 1457, 63, 344, 7063, 436, 283, 288, 289, 5121, 374, 2802, 63, 354, 18448, 5675, 8, 1397, 63, 2792, 12, 298, 2918, 63, 354, 401, 6899, 5469, 283, 288, 289, 7, 6964, 665, 11316, 30, 1947, 3140, 3530, 267, 2318, 267, 4503, 63, 498, 3699, 2168, 63, 1023, 63, 815, 8, 1397, 63, 2792, 14, 1985, 395, 272, 776, 421, 199, 318, 485, 705, 63, 509, 63, 1397, 63, 4041, 8, 2792, 12, 440, 63, 4041, 304, 272, 408, 272, 6646, 547, 1451, 1380, 781, 1255, 1901, 282, 1982, 402, 15247, 626, 1159, 440, 282, 10975, 14, 339, 13481, 370, 506, 3945, 345, 939, 315, 282, 4340, 626, 7704, 12249, 370, 2518, 25823, 14, 272, 408, 272, 372, 6646, 547, 1451, 8, 267, 1245, 2687, 288, 289, 7601, 11316, 30, 543, 1166, 63, 354, 18448, 2792, 14, 1985, 14, 1457, 63, 344, 7063, 436, 283, 288, 289, 5121, 374, 2802, 63, 354, 18448, 2792, 14, 2918, 63, 354, 7063, 3509, 282, 283, 288, 289, 7601, 91, 1397, 63, 4041, 14, 1985, 14, 1457, 63, 466, 93, 30, 1947, 543, 283, 288, 289, 7, 633, 63, 354, 18448, 1397, 63, 4041, 14, 1985, 14, 1457, 63, 344, 7063, 436, 283, 288, 289, 5121, 374, 2802, 63, 354, 18448, 5675, 8, 1397, 63, 4041, 12, 298, 2918, 63, 354, 401, 6899, 5469, 283, 288, 289, 7, 6964, 282, 665, 16211, 30, 1947, 3140, 3530, 267, 2318, 267, 4503, 63, 498, 3699, 2168, 63, 1023, 63, 815, 8, 1397, 63, 4041, 14, 1985, 395, 272, 776, 421, 199, 318, 485, 1875, 63, 2792, 63, 576, 8, 2792, 304, 272, 408, 272, 1432, 282, 334, 6979, 8660, 1451, 12, 3820, 59, 2714, 1451, 547, 566, 687, 282, 15247, 3142, 14, 339, 6855, 372, 488, 367, 5531, 8660, 1451, 340, 652, 1159, 440, 7710, 282, 15247, 3142, 626, 272, 1990, 3032, 315, 14, 339, 961, 1083, 1630, 282, 13918, 402, 314, 1736, 370, 3957, 10996, 1504, 370, 376, 1324, 272, 626, 314, 9328, 63, 13436, 1145, 14292, 14, 593, 44, 56, 492, 11291, 83, 13955, 626, 272, 787, 8298, 6656, 28483, 2419, 13225, 1159, 14041, 6127, 367, 12, 880, 18119, 781, 1255, 272, 1901, 6020, 626, 1630, 440, 26743, 4154, 5531, 1035, 15247, 1035, 4804, 2792, 272, 14446, 21851, 12, 781, 1050, 282, 2291, 13, 5969, 13, 11875, 1125, 1245, 370, 4154, 272, 769, 402, 6646, 1451, 9298, 370, 986, 1771, 14, 339, 2854, 642, 2376, 315, 314, 1233, 12, 8137, 965, 2575, 2757, 13256, 1901, 272, 15247, 24996, 436, 10975, 24996, 12, 1325, 781, 3984, 9995, 370, 21621, 4154, 3788, 315, 272, 15217, 626, 3955, 1852, 12249, 370, 17122, 10023, 737, 314, 492, 593, 44, 56, 12, 3967, 626, 272, 365, 314, 4045, 626, 314, 2518, 25823, 436, 2291, 25823, 787, 6449, 543, 14, 272, 408, 272, 3420, 63, 2550, 275, 942, 339, 327, 7758, 1104, 340, 652, 1159, 440, 282, 3420, 737, 1006, 12, 436, 3974, 20304, 340, 652, 5712, 1133, 14, 272, 340, 3420, 14, 1985, 14, 1457, 63, 466, 1137, 283, 11316, 356, 267, 3420, 63, 2550, 14, 740, 1547, 705, 63, 509, 63, 1397, 63, 2792, 8, 2792, 430, 267, 372, 334, 403, 12, 3420, 63, 2550 ]
[ 199, 2765, 365, 2382, 13225, 17232, 83, 543, 314, 9328, 63, 13436, 4223, 12, 1314, 199, 374, 17845, 367, 17573, 2518, 17964, 666, 14, 13225, 485, 5335, 397, 63, 626, 666, 1901, 199, 10546, 63, 13436, 737, 2780, 900, 14, 199, 624, 199, 504, 2197, 492, 7137, 199, 504, 14090, 492, 3820, 12, 11634, 199, 199, 504, 22435, 63, 1176, 63, 1208, 14, 20554, 492, 805, 63, 3446, 12, 663, 63, 4229, 63, 3215, 199, 199, 504, 22709, 14, 1018, 14, 16432, 14, 1317, 14, 10546, 63, 13436, 14, 1246, 492, 3350, 63, 1972, 63, 11550, 199, 504, 22709, 14, 1018, 14, 16432, 14, 1317, 14, 10546, 63, 13436, 14, 576, 492, 334, 272, 6646, 547, 1451, 12, 272, 5531, 25519, 5826, 1451, 12, 272, 5531, 21432, 1451, 12, 272, 5531, 8660, 1451, 12, 272, 5531, 24735, 12, 272, 1316, 455, 1451, 12, 272, 6561, 4783, 1451, 199, 9, 199, 504, 9872, 14, 10012, 492, 23431, 199, 504, 9872, 14, 10012, 14, 1176, 492, 10996, 421, 199, 318, 485, 2168, 63, 1023, 63, 815, 8, 3807, 63, 498, 304, 272, 408, 272, 3979, 781, 7198, 10996, 367, 314, 3267, 5246, 315, 314, 13225, 2112, 272, 2410, 8579, 316, 282, 2780, 4673, 12, 314, 2974, 626, 1172, 2757, 2896, 911, 272, 372, 11028, 6340, 626, 1172, 2615, 1015, 2556, 315, 3932, 10102, 272, 5531, 6340, 14, 961, 7704, 3062, 2631, 436, 8437, 23142, 14, 2136, 2934, 370, 272, 6202, 642, 2556, 436, 1172, 8137, 675, 282, 22574, 543, 949, 272, 1015, 2556, 10102, 14, 339, 710, 10572, 626, 642, 31792, 22574, 11337, 365, 12060, 376, 625, 262, 6943, 272, 5366, 13, 5881, 12, 7830, 2419, 376, 25343, 279, 1777, 402, 314, 3261, 16077, 14, 2779, 272, 2597, 12060, 3181, 1133, 5992, 1380, 314, 10996, 365, 3769, 7686, 687, 272, 282, 3365, 2112, 2419, 314, 1373, 9689, 314, 3575, 334, 69, 14, 71, 14, 282, 22748, 2120, 272, 3879, 641, 1263, 3734, 1163, 2419, 4866, 2340, 680, 11017, 4024, 3637, 642, 272, 1015, 2556, 734, 365, 5784, 370, 1852, 4866, 2340, 436, 2295, 1736, 272, 7684, 14, 272, 408, 272, 625, 24155, 63, 1972, 63, 498, 275, 4503, 63, 498, 14, 1972, 63, 498, 14, 1814, 8, 4694, 29, 403, 12, 1015, 63, 9473, 29, 403, 9, 272, 372, 4503, 63, 498, 14, 1130, 63, 9924, 63, 1972, 8, 324, 24155, 63, 1972, 63, 498, 9, 421, 199, 318, 485, 705, 63, 509, 63, 1397, 63, 2792, 8, 1397, 63, 2792, 304, 272, 408, 272, 6646, 547, 1451, 1380, 781, 1255, 1901, 282, 1982, 402, 665, 1972, 30, 626, 1159, 440, 282, 15247, 14, 339, 13481, 370, 506, 3945, 345, 939, 315, 282, 4340, 626, 7704, 12249, 370, 2518, 25823, 14, 272, 408, 272, 372, 6646, 547, 1451, 8, 267, 1245, 2687, 288, 289, 7601, 1972, 30, 3509, 282, 665, 91, 1397, 63, 2792, 14, 1985, 14, 1457, 63, 466, 93, 30, 1947, 543, 283, 288, 289, 7, 633, 63, 354, 18448, 1397, 63, 2792, 14, 1985, 14, 1457, 63, 344, 7063, 436, 283, 288, 289, 5121, 374, 2802, 63, 354, 18448, 5675, 8, 1397, 63, 2792, 12, 298, 2918, 63, 354, 401, 6899, 5469, 283, 288, 289, 7, 6964, 665, 11316, 30, 1947, 3140, 3530, 267, 2318, 267, 4503, 63, 498, 3699, 2168, 63, 1023, 63, 815, 8, 1397, 63, 2792, 14, 1985, 395, 272, 776, 421, 199, 318, 485, 705, 63, 509, 63, 1397, 63, 4041, 8, 2792, 12, 440, 63, 4041, 304, 272, 408, 272, 6646, 547, 1451, 1380, 781, 1255, 1901, 282, 1982, 402, 15247, 626, 1159, 440, 282, 10975, 14, 339, 13481, 370, 506, 3945, 345, 939, 315, 282, 4340, 626, 7704, 12249, 370, 2518, 25823, 14, 272, 408, 272, 372, 6646, 547, 1451, 8, 267, 1245, 2687, 288, 289, 7601, 11316, 30, 543, 1166, 63, 354, 18448, 2792, 14, 1985, 14, 1457, 63, 344, 7063, 436, 283, 288, 289, 5121, 374, 2802, 63, 354, 18448, 2792, 14, 2918, 63, 354, 7063, 3509, 282, 283, 288, 289, 7601, 91, 1397, 63, 4041, 14, 1985, 14, 1457, 63, 466, 93, 30, 1947, 543, 283, 288, 289, 7, 633, 63, 354, 18448, 1397, 63, 4041, 14, 1985, 14, 1457, 63, 344, 7063, 436, 283, 288, 289, 5121, 374, 2802, 63, 354, 18448, 5675, 8, 1397, 63, 4041, 12, 298, 2918, 63, 354, 401, 6899, 5469, 283, 288, 289, 7, 6964, 282, 665, 16211, 30, 1947, 3140, 3530, 267, 2318, 267, 4503, 63, 498, 3699, 2168, 63, 1023, 63, 815, 8, 1397, 63, 4041, 14, 1985, 395, 272, 776, 421, 199, 318, 485, 1875, 63, 2792, 63, 576, 8, 2792, 304, 272, 408, 272, 1432, 282, 334, 6979, 8660, 1451, 12, 3820, 59, 2714, 1451, 547, 566, 687, 282, 15247, 3142, 14, 339, 6855, 372, 488, 367, 5531, 8660, 1451, 340, 652, 1159, 440, 7710, 282, 15247, 3142, 626, 272, 1990, 3032, 315, 14, 339, 961, 1083, 1630, 282, 13918, 402, 314, 1736, 370, 3957, 10996, 1504, 370, 376, 1324, 272, 626, 314, 9328, 63, 13436, 1145, 14292, 14, 593, 44, 56, 492, 11291, 83, 13955, 626, 272, 787, 8298, 6656, 28483, 2419, 13225, 1159, 14041, 6127, 367, 12, 880, 18119, 781, 1255, 272, 1901, 6020, 626, 1630, 440, 26743, 4154, 5531, 1035, 15247, 1035, 4804, 2792, 272, 14446, 21851, 12, 781, 1050, 282, 2291, 13, 5969, 13, 11875, 1125, 1245, 370, 4154, 272, 769, 402, 6646, 1451, 9298, 370, 986, 1771, 14, 339, 2854, 642, 2376, 315, 314, 1233, 12, 8137, 965, 2575, 2757, 13256, 1901, 272, 15247, 24996, 436, 10975, 24996, 12, 1325, 781, 3984, 9995, 370, 21621, 4154, 3788, 315, 272, 15217, 626, 3955, 1852, 12249, 370, 17122, 10023, 737, 314, 492, 593, 44, 56, 12, 3967, 626, 272, 365, 314, 4045, 626, 314, 2518, 25823, 436, 2291, 25823, 787, 6449, 543, 14, 272, 408, 272, 3420, 63, 2550, 275, 942, 339, 327, 7758, 1104, 340, 652, 1159, 440, 282, 3420, 737, 1006, 12, 436, 3974, 20304, 340, 652, 5712, 1133, 14, 272, 340, 3420, 14, 1985, 14, 1457, 63, 466, 1137, 283, 11316, 356, 267, 3420, 63, 2550, 14, 740, 1547, 705, 63, 509, 63, 1397, 63, 2792, 8, 2792, 430, 267,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Aorjoa/aiyara-ceph-dash
.tox/py27/lib/python2.7/site-packages/werkzeug/testapp.py
364
9396
# -*- coding: utf-8 -*- """ werkzeug.testapp ~~~~~~~~~~~~~~~~ Provide a small test application that can be used to test a WSGI server and check it for WSGI compliance. :copyright: (c) 2014 by the Werkzeug Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ import os import sys import werkzeug from textwrap import wrap from werkzeug.wrappers import BaseRequest as Request, BaseResponse as Response from werkzeug.utils import escape import base64 logo = Response(base64.b64decode(''' R0lGODlhoACgAOMIAAEDACwpAEpCAGdgAJaKAM28AOnVAP3rAP///////// //////////////////////yH5BAEKAAgALAAAAACgAKAAAAT+EMlJq704680R+F0ojmRpnuj0rWnrv nB8rbRs33gu0bzu/0AObxgsGn3D5HHJbCUFyqZ0ukkSDlAidctNFg7gbI9LZlrBaHGtzAae0eloe25 7w9EDOX2fst/xenyCIn5/gFqDiVVDV4aGeYiKkhSFjnCQY5OTlZaXgZp8nJ2ekaB0SQOjqphrpnOiq ncEn65UsLGytLVmQ6m4sQazpbtLqL/HwpnER8bHyLrLOc3Oz8PRONPU1crXN9na263dMt/g4SzjMeX m5yDpLqgG7OzJ4u8lT/P69ej3JPn69kHzN2OIAHkB9RUYSFCFQYQJFTIkCDBiwoXWGnowaLEjRm7+G p9A7Hhx4rUkAUaSLJlxHMqVMD/aSycSZkyTplCqtGnRAM5NQ1Ly5OmzZc6gO4d6DGAUKA+hSocWYAo SlM6oUWX2O/o0KdaVU5vuSQLAa0ADwQgMEMB2AIECZhVSnTno6spgbtXmHcBUrQACcc2FrTrWS8wAf 78cMFBgwIBgbN+qvTt3ayikRBk7BoyGAGABAdYyfdzRQGV3l4coxrqQ84GpUBmrdR3xNIDUPAKDBSA ADIGDhhqTZIWaDcrVX8EsbNzbkvCOxG8bN5w8ly9H8jyTJHC6DFndQydbguh2e/ctZJFXRxMAqqPVA tQH5E64SPr1f0zz7sQYjA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YKOr6iK3fE4MaS+DsvBsGOBaMb0Y6IxADaJhFICaOLmiWTlDAnY1KzDG4ambL cWBA8mUzjJsN2KjSaSXGqMCVXYpYkj33mcIApyhQf6YqgeNAmNvuC0t4CsDbSshZJkCS1eNisKqlyG cF8G2JeiDX6tO6Mv0SmjCa3MFb0bJaGPMU0X7c8XcpvMaOQmCajwSeY9G0WqbBmKv34DsMIEztU6Y2 KiDlFdt6jnCSqx7Dmt6XnqSKaFFHNO5+FmODxMCWBEaco77lNDGXBM0ECYB/+s7nKFdwSF5hgXumQe EZ7amRg39RHy3zIjyRCykQh8Zo2iviRKyTDn/zx6EefptJj2Cw+Ep2FSc01U5ry4KLPYsTyWnVGnvb UpyGlhjBUljyjHhWpf8OFaXwhp9O4T1gU9UeyPPa8A2l0p1kNqPXEVRm1AOs1oAGZU596t6SOR2mcB Oco1srWtkaVrMUzIErrKri85keKqRQYX9VX0/eAUK1hrSu6HMEX3Qh2sCh0q0D2CtnUqS4hj62sE/z aDs2Sg7MBS6xnQeooc2R2tC9YrKpEi9pLXfYXp20tDCpSP8rKlrD4axprb9u1Df5hSbz9QU0cRpfgn kiIzwKucd0wsEHlLpe5yHXuc6FrNelOl7pY2+11kTWx7VpRu97dXA3DO1vbkhcb4zyvERYajQgAADs ='''), mimetype='image/png') TEMPLATE = u'''\ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <title>WSGI Information</title> <style type="text/css"> @import url(http://fonts.googleapis.com/css?family=Ubuntu); body { font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva', 'Verdana', sans-serif; background-color: white; color: #000; font-size: 15px; text-align: center; } #logo { float: right; padding: 0 0 10px 10px; } div.box { text-align: left; width: 45em; margin: auto; padding: 50px 0; background-color: white; } h1, h2 { font-family: 'Ubuntu', 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva', 'Verdana', sans-serif; font-weight: normal; } h1 { margin: 0 0 30px 0; } h2 { font-size: 1.4em; margin: 1em 0 0.5em 0; } table { width: 100%%; border-collapse: collapse; border: 1px solid #AFC5C9 } table th { background-color: #AFC1C4; color: white; font-size: 0.72em; font-weight: normal; width: 18em; vertical-align: top; padding: 0.5em 0 0.1em 0.5em; } table td { border: 1px solid #AFC5C9; padding: 0.1em 0 0.1em 0.5em; } code { font-family: 'Consolas', 'Monaco', 'Bitstream Vera Sans Mono', monospace; font-size: 0.7em; } ul li { line-height: 1.5em; } ul.path { font-size: 0.7em; margin: 0 -30px; padding: 8px 30px; list-style: none; background: #E8EFF0; } ul.path li { line-height: 1.6em; } li.virtual { color: #999; text-decoration: underline; } li.exp { background: white; } </style> <div class="box"> <img src="?resource=logo" id="logo" alt="[The Werkzeug Logo]" /> <h1>WSGI Information</h1> <p> This page displays all available information about the WSGI server and the underlying Python interpreter. <h2 id="python-interpreter">Python Interpreter</h2> <table> <tr> <th>Python Version <td>%(python_version)s <tr> <th>Platform <td>%(platform)s [%(os)s] <tr> <th>API Version <td>%(api_version)s <tr> <th>Byteorder <td>%(byteorder)s <tr> <th>Werkzeug Version <td>%(werkzeug_version)s </table> <h2 id="wsgi-environment">WSGI Environment</h2> <table>%(wsgi_env)s</table> <h2 id="installed-eggs">Installed Eggs</h2> <p> The following python packages were installed on the system as Python eggs: <ul>%(python_eggs)s</ul> <h2 id="sys-path">System Path</h2> <p> The following paths are the current contents of the load path. The following entries are looked up for Python packages. Note that not all items in this path are folders. Gray and underlined items are entries pointing to invalid resources or used by custom import hooks such as the zip importer. <p> Items with a bright background were expanded for display from a relative path. If you encounter such paths in the output you might want to check your setup as relative paths are usually problematic in multithreaded environments. <ul class="path">%(sys_path)s</ul> </div> ''' def iter_sys_path(): if os.name == 'posix': def strip(x): prefix = os.path.expanduser('~') if x.startswith(prefix): x = '~' + x[len(prefix):] return x else: strip = lambda x: x cwd = os.path.abspath(os.getcwd()) for item in sys.path: path = os.path.join(cwd, item or os.path.curdir) yield strip(os.path.normpath(path)), \ not os.path.isdir(path), path != item def render_testapp(req): try: import pkg_resources except ImportError: eggs = () else: eggs = sorted(pkg_resources.working_set, key=lambda x: x.project_name.lower()) python_eggs = [] for egg in eggs: try: version = egg.version except (ValueError, AttributeError): version = 'unknown' python_eggs.append('<li>%s <small>[%s]</small>' % ( escape(egg.project_name), escape(version) )) wsgi_env = [] sorted_environ = sorted(req.environ.items(), key=lambda x: repr(x[0]).lower()) for key, value in sorted_environ: wsgi_env.append('<tr><th>%s<td><code>%s</code>' % ( escape(str(key)), ' '.join(wrap(escape(repr(value)))) )) sys_path = [] for item, virtual, expanded in iter_sys_path(): class_ = [] if virtual: class_.append('virtual') if expanded: class_.append('exp') sys_path.append('<li%s>%s' % ( class_ and ' class="%s"' % ' '.join(class_) or '', escape(item) )) return (TEMPLATE % { 'python_version': '<br>'.join(escape(sys.version).splitlines()), 'platform': escape(sys.platform), 'os': escape(os.name), 'api_version': sys.api_version, 'byteorder': sys.byteorder, 'werkzeug_version': werkzeug.__version__, 'python_eggs': '\n'.join(python_eggs), 'wsgi_env': '\n'.join(wsgi_env), 'sys_path': '\n'.join(sys_path) }).encode('utf-8') def test_app(environ, start_response): """Simple test application that dumps the environment. You can use it to check if Werkzeug is working properly: .. sourcecode:: pycon >>> from werkzeug.serving import run_simple >>> from werkzeug.testapp import test_app >>> run_simple('localhost', 3000, test_app) * Running on http://localhost:3000/ The application displays important information from the WSGI environment, the Python interpreter and the installed libraries. """ req = Request(environ, populate_request=False) if req.args.get('resource') == 'logo': response = logo else: response = Response(render_testapp(req), mimetype='text/html') return response(environ, start_response) if __name__ == '__main__': from werkzeug.serving import run_simple run_simple('localhost', 5000, test_app, use_reloader=True)
bsd-2-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 19700, 272, 18294, 339, 22896, 282, 7425, 511, 4223, 626, 883, 506, 1202, 370, 511, 282, 9279, 1654, 272, 436, 1104, 652, 367, 9279, 4151, 14, 339, 520, 7307, 26, 334, 67, 9, 6927, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 747, 199, 646, 984, 199, 646, 10380, 199, 504, 13390, 492, 4816, 199, 504, 10380, 14, 21148, 492, 3523, 2017, 465, 4784, 12, 3523, 2364, 465, 7232, 199, 504, 10380, 14, 1208, 492, 4772, 199, 646, 1300, 772, 199, 199, 9733, 275, 7232, 8, 1095, 772, 14, 66, 772, 2708, 10505, 199, 50, 16, 76, 13160, 22904, 526, 1348, 14993, 7474, 41, 2276, 1149, 1348, 14649, 12500, 80, 12170, 13279, 31064, 65, 43, 1156, 1651, 33, 3314, 54, 1282, 19, 82, 1282, 1368, 15, 199, 2321, 8331, 89, 40, 21, 4134, 11959, 2276, 71, 748, 6151, 1348, 71, 7872, 10985, 619, 11, 2769, 76, 42, 81, 23, 13702, 1257, 50, 11, 38, 16, 79, 74, 77, 50, 4812, 17189, 16, 82, 55, 78, 6310, 199, 78, 34, 24, 4848, 28868, 1153, 6051, 16, 10582, 85, 15, 16, 33, 11394, 88, 458, 39, 78, 19, 36, 21, 10213, 42, 66, 35, 27363, 89, 81, 58, 16, 3210, 75, 3693, 76, 33, 344, 319, 19749, 71, 23, 4908, 41, 25, 44, 58, 7493, 13864, 31442, 3903, 33, 3624, 16, 69, 320, 69, 821, 199, 23, 87, 25, 1149, 29544, 18, 15624, 15, 13615, 89, 35, 607, 21, 15, 71, 38, 81, 1341, 17578, 6741, 20, 65, 4240, 21001, 43, 21889, 13107, 24016, 25370, 57, 21, 1387, 76, 13163, 56, 71, 58, 80, 24, 78, 42, 18, 5711, 65, 34, 16, 18445, 47, 74, 81, 838, 4599, 78, 47, 9962, 199, 7966, 1327, 2182, 23642, 44, 39, 24264, 44, 17402, 49, 22, 77, 20, 83, 49, 4651, 3317, 84, 44, 81, 44, 15, 24482, 4812, 540, 24, 66, 21568, 44, 82, 1484, 67, 19, 47, 90, 24, 3311, 615, 6903, 17, 1556, 56, 46, 25, 3540, 14622, 68, 45, 84, 15, 71, 20, 51, 90, 74, 1352, 56, 199, 77, 21, 89, 36, 80, 44, 81, 71, 39, 23, 47, 90, 42, 20, 85, 24, 76, 52, 15, 48, 1876, 69, 74, 19, 15819, 78, 1876, 75, 13026, 46, 18, 47, 13033, 40, 75, 34, 25, 9500, 20238, 4161, 27629, 57, 49, 42, 2161, 41, 75, 35, 2846, 73, 2027, 56, 55, 39, 2131, 65, 906, 74, 31330, 23, 11, 39, 199, 80, 25, 33, 23, 23626, 88, 20, 28978, 75, 9331, 65, 4929, 42, 23605, 27699, 81, 54, 5127, 15, 65, 4323, 67, 18101, 10562, 52, 1168, 35, 8440, 39, 78, 30839, 21, 46, 49, 17, 27480, 21, 47, 28808, 58, 67, 22, 71, 47, 20, 68, 22, 29173, 9331, 19606, 11, 72, 51, 679, 55, 57, 31707, 199, 11592, 45, 22, 79, 53, 16783, 18, 47, 15, 79, 16, 43, 983, 54, 53, 21, 86, 85, 4657, 33, 65, 16, 1554, 87, 49, 71, 10293, 34, 18, 7730, 4220, 12674, 7428, 78, 52, 889, 22, 681, 4908, 84, 56, 77, 40, 67, 2910, 82, 49, 1348, 2055, 18, 13848, 14064, 5035, 24, 87, 14799, 199, 2277, 67, 45, 8223, 8392, 2100, 4908, 46, 11, 81, 86, 52, 84, 19, 1187, 3258, 16567, 75, 23, 2208, 89, 39, 1254, 1217, 2767, 30694, 2592, 90, 50, 49, 14876, 19, 76, 20, 331, 88, 5098, 49, 1349, 39, 80, 2533, 77, 6883, 50, 19, 31985, 998, 2160, 7872, 2846, 4251, 199, 1554, 1277, 36, 12156, 81, 14226, 22275, 65, 36, 1556, 28493, 24, 37, 9264, 46, 20176, 11475, 1439, 88, 39, 24, 66, 46, 21, 87, 24, 590, 25, 40, 24, 24589, 52, 42, 28460, 22, 3888, 977, 49, 89, 697, 6051, 72, 18, 69, 15, 319, 58, 42, 38, 12297, 88, 2054, 16672, 48, 15162, 199, 84, 27088, 21, 37, 772, 5763, 82, 17, 70, 16, 4348, 23, 83, 49, 57, 74, 20755, 71, 16, 607, 11, 42, 49, 845, 11, 46, 18, 34, 16, 2483, 34, 1024, 26184, 71, 21338, 38, 88, 20, 84, 81, 34, 1378, 73, 9735, 86, 16, 57, 23571, 49, 86, 24, 42, 81, 33, 22, 6773, 70, 22, 50, 72, 56, 88, 199, 87, 17, 742, 72, 16567, 78, 24918, 24, 319, 1438, 20, 18505, 18, 26698, 19, 65, 29355, 67, 49, 6389, 18, 2430, 590, 52, 11446, 89, 57, 53, 55, 86, 2662, 18256, 36, 89, 2679, 39, 16215, 38, 74, 15156, 8921, 2322, 65, 974, 5663, 90, 15, 35, 364, 53, 25500, 758, 36, 88, 199, 76, 52, 458, 65, 47, 74, 22781, 72, 19674, 42, 49, 68, 11, 76, 15563, 1254, 75, 24, 11394, 3561, 41, 16, 7351, 23596, 11, 18015, 21, 3345, 40, 19, 5012, 11, 18367, 75, 24388, 1254, 12226, 49, 23643, 25500, 90, 18, 48, 15, 67, 22620, 44, 17077, 38, 2528, 49, 69, 51, 66, 2322, 199, 42, 87, 2207, 11, 85, 19366, 40, 76, 81, 47, 58, 80, 47, 69, 42, 80, 5487, 58, 21, 42, 11, 23992, 33, 75, 38, 74, 49, 16, 46, 17, 502, 72, 23, 42, 11378, 58, 27363, 2438, 82, 415, 42, 53, 42, 10535, 73, 24, 74, 11552, 11959, 41, 72, 24974, 676, 78, 35, 3328, 53, 79, 11, 16170, 199, 7566, 65, 42, 21, 1307, 1590, 607, 4656, 72, 20, 84, 22, 58, 5058, 17295, 6087, 77, 565, 81, 11538, 2175, 26135, 57, 76, 24, 84, 1510, 16, 838, 15068, 82, 15907, 45, 5035, 86, 11, 26278, 81, 40, 9681, 40, 1299, 1151, 21, 14272, 58, 757, 14307, 54, 42, 7952, 199, 18256, 2277, 83, 17, 38, 5032, 18070, 22, 89, 13371, 82, 54, 22, 9734, 1649, 9503, 85, 39, 11, 49, 90, 3263, 934, 66, 35, 14114, 25, 51, 5682, 1698, 90, 43, 22, 80, 11, 1938, 40, 88, 23, 3888, 11, 1533, 70, 22153, 81, 23, 30478, 2976, 6651, 25, 73, 22, 2226, 87, 1789, 82, 199, 344, 78, 58, 19616, 5757, 16, 65, 1020, 3317, 32602, 42, 75, 496, 25370, 2054, 1196, 1938, 39, 22, 9648, 81, 19, 30031 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 19700, 272, 18294, 339, 22896, 282, 7425, 511, 4223, 626, 883, 506, 1202, 370, 511, 282, 9279, 1654, 272, 436, 1104, 652, 367, 9279, 4151, 14, 339, 520, 7307, 26, 334, 67, 9, 6927, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 747, 199, 646, 984, 199, 646, 10380, 199, 504, 13390, 492, 4816, 199, 504, 10380, 14, 21148, 492, 3523, 2017, 465, 4784, 12, 3523, 2364, 465, 7232, 199, 504, 10380, 14, 1208, 492, 4772, 199, 646, 1300, 772, 199, 199, 9733, 275, 7232, 8, 1095, 772, 14, 66, 772, 2708, 10505, 199, 50, 16, 76, 13160, 22904, 526, 1348, 14993, 7474, 41, 2276, 1149, 1348, 14649, 12500, 80, 12170, 13279, 31064, 65, 43, 1156, 1651, 33, 3314, 54, 1282, 19, 82, 1282, 1368, 15, 199, 2321, 8331, 89, 40, 21, 4134, 11959, 2276, 71, 748, 6151, 1348, 71, 7872, 10985, 619, 11, 2769, 76, 42, 81, 23, 13702, 1257, 50, 11, 38, 16, 79, 74, 77, 50, 4812, 17189, 16, 82, 55, 78, 6310, 199, 78, 34, 24, 4848, 28868, 1153, 6051, 16, 10582, 85, 15, 16, 33, 11394, 88, 458, 39, 78, 19, 36, 21, 10213, 42, 66, 35, 27363, 89, 81, 58, 16, 3210, 75, 3693, 76, 33, 344, 319, 19749, 71, 23, 4908, 41, 25, 44, 58, 7493, 13864, 31442, 3903, 33, 3624, 16, 69, 320, 69, 821, 199, 23, 87, 25, 1149, 29544, 18, 15624, 15, 13615, 89, 35, 607, 21, 15, 71, 38, 81, 1341, 17578, 6741, 20, 65, 4240, 21001, 43, 21889, 13107, 24016, 25370, 57, 21, 1387, 76, 13163, 56, 71, 58, 80, 24, 78, 42, 18, 5711, 65, 34, 16, 18445, 47, 74, 81, 838, 4599, 78, 47, 9962, 199, 7966, 1327, 2182, 23642, 44, 39, 24264, 44, 17402, 49, 22, 77, 20, 83, 49, 4651, 3317, 84, 44, 81, 44, 15, 24482, 4812, 540, 24, 66, 21568, 44, 82, 1484, 67, 19, 47, 90, 24, 3311, 615, 6903, 17, 1556, 56, 46, 25, 3540, 14622, 68, 45, 84, 15, 71, 20, 51, 90, 74, 1352, 56, 199, 77, 21, 89, 36, 80, 44, 81, 71, 39, 23, 47, 90, 42, 20, 85, 24, 76, 52, 15, 48, 1876, 69, 74, 19, 15819, 78, 1876, 75, 13026, 46, 18, 47, 13033, 40, 75, 34, 25, 9500, 20238, 4161, 27629, 57, 49, 42, 2161, 41, 75, 35, 2846, 73, 2027, 56, 55, 39, 2131, 65, 906, 74, 31330, 23, 11, 39, 199, 80, 25, 33, 23, 23626, 88, 20, 28978, 75, 9331, 65, 4929, 42, 23605, 27699, 81, 54, 5127, 15, 65, 4323, 67, 18101, 10562, 52, 1168, 35, 8440, 39, 78, 30839, 21, 46, 49, 17, 27480, 21, 47, 28808, 58, 67, 22, 71, 47, 20, 68, 22, 29173, 9331, 19606, 11, 72, 51, 679, 55, 57, 31707, 199, 11592, 45, 22, 79, 53, 16783, 18, 47, 15, 79, 16, 43, 983, 54, 53, 21, 86, 85, 4657, 33, 65, 16, 1554, 87, 49, 71, 10293, 34, 18, 7730, 4220, 12674, 7428, 78, 52, 889, 22, 681, 4908, 84, 56, 77, 40, 67, 2910, 82, 49, 1348, 2055, 18, 13848, 14064, 5035, 24, 87, 14799, 199, 2277, 67, 45, 8223, 8392, 2100, 4908, 46, 11, 81, 86, 52, 84, 19, 1187, 3258, 16567, 75, 23, 2208, 89, 39, 1254, 1217, 2767, 30694, 2592, 90, 50, 49, 14876, 19, 76, 20, 331, 88, 5098, 49, 1349, 39, 80, 2533, 77, 6883, 50, 19, 31985, 998, 2160, 7872, 2846, 4251, 199, 1554, 1277, 36, 12156, 81, 14226, 22275, 65, 36, 1556, 28493, 24, 37, 9264, 46, 20176, 11475, 1439, 88, 39, 24, 66, 46, 21, 87, 24, 590, 25, 40, 24, 24589, 52, 42, 28460, 22, 3888, 977, 49, 89, 697, 6051, 72, 18, 69, 15, 319, 58, 42, 38, 12297, 88, 2054, 16672, 48, 15162, 199, 84, 27088, 21, 37, 772, 5763, 82, 17, 70, 16, 4348, 23, 83, 49, 57, 74, 20755, 71, 16, 607, 11, 42, 49, 845, 11, 46, 18, 34, 16, 2483, 34, 1024, 26184, 71, 21338, 38, 88, 20, 84, 81, 34, 1378, 73, 9735, 86, 16, 57, 23571, 49, 86, 24, 42, 81, 33, 22, 6773, 70, 22, 50, 72, 56, 88, 199, 87, 17, 742, 72, 16567, 78, 24918, 24, 319, 1438, 20, 18505, 18, 26698, 19, 65, 29355, 67, 49, 6389, 18, 2430, 590, 52, 11446, 89, 57, 53, 55, 86, 2662, 18256, 36, 89, 2679, 39, 16215, 38, 74, 15156, 8921, 2322, 65, 974, 5663, 90, 15, 35, 364, 53, 25500, 758, 36, 88, 199, 76, 52, 458, 65, 47, 74, 22781, 72, 19674, 42, 49, 68, 11, 76, 15563, 1254, 75, 24, 11394, 3561, 41, 16, 7351, 23596, 11, 18015, 21, 3345, 40, 19, 5012, 11, 18367, 75, 24388, 1254, 12226, 49, 23643, 25500, 90, 18, 48, 15, 67, 22620, 44, 17077, 38, 2528, 49, 69, 51, 66, 2322, 199, 42, 87, 2207, 11, 85, 19366, 40, 76, 81, 47, 58, 80, 47, 69, 42, 80, 5487, 58, 21, 42, 11, 23992, 33, 75, 38, 74, 49, 16, 46, 17, 502, 72, 23, 42, 11378, 58, 27363, 2438, 82, 415, 42, 53, 42, 10535, 73, 24, 74, 11552, 11959, 41, 72, 24974, 676, 78, 35, 3328, 53, 79, 11, 16170, 199, 7566, 65, 42, 21, 1307, 1590, 607, 4656, 72, 20, 84, 22, 58, 5058, 17295, 6087, 77, 565, 81, 11538, 2175, 26135, 57, 76, 24, 84, 1510, 16, 838, 15068, 82, 15907, 45, 5035, 86, 11, 26278, 81, 40, 9681, 40, 1299, 1151, 21, 14272, 58, 757, 14307, 54, 42, 7952, 199, 18256, 2277, 83, 17, 38, 5032, 18070, 22, 89, 13371, 82, 54, 22, 9734, 1649, 9503, 85, 39, 11, 49, 90, 3263, 934, 66, 35, 14114, 25, 51, 5682, 1698, 90, 43, 22, 80, 11, 1938, 40, 88, 23, 3888, 11, 1533, 70, 22153, 81, 23, 30478, 2976, 6651, 25, 73, 22, 2226, 87, 1789, 82, 199, 344, 78, 58, 19616, 5757, 16, 65, 1020, 3317, 32602, 42, 75, 496, 25370, 2054, 1196, 1938, 39, 22, 9648, 81, 19, 30031, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
yamila-moreno/django
django/conf/locale/ru/formats.py
1059
1267
# -*- 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 = 'G:i' DATETIME_FORMAT = 'j E Y г. G:i' YEAR_MONTH_FORMAT = 'F Y г.' MONTH_DAY_FORMAT = 'j F' SHORT_DATE_FORMAT = 'd.m.Y' SHORT_DATETIME_FORMAT = 'd.m.Y H:i' 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', # '25.10.2006' '%d.%m.%y', # '25.10.06' ] 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' '%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 = '\xa0' # non-breaking space 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, 662, 1488, 7038, 112, 3530, 199, 4961, 63, 4807, 275, 283, 39, 26, 73, 7, 199, 12488, 63, 4807, 275, 283, 74, 662, 1488, 7038, 112, 14, 598, 26, 73, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 7038, 112, 3530, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 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, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 221, 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, 359, 272, 1543, 68, 4111, 77, 4111, 57, 297, 221, 327, 283, 821, 14, 709, 14, 7968, 7, 272, 1543, 68, 4111, 77, 4111, 89, 297, 221, 327, 283, 821, 14, 709, 14, 1690, 7, 199, 61, 199, 12488, 63, 7321, 63, 14019, 275, 359, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 297, 258, 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, 221, 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, 263, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 297, 4519, 327, 283, 821, 14, 709, 14, 7968, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 297, 4519, 327, 283, 821, 14, 709, 14, 1690, 7, 199, 61, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 1557, 1800, 16, 7, 221, 327, 2222, 13, 4785, 316, 4601, 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 ]
[ 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, 662, 1488, 7038, 112, 3530, 199, 4961, 63, 4807, 275, 283, 39, 26, 73, 7, 199, 12488, 63, 4807, 275, 283, 74, 662, 1488, 7038, 112, 14, 598, 26, 73, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 7038, 112, 3530, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 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, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 221, 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, 359, 272, 1543, 68, 4111, 77, 4111, 57, 297, 221, 327, 283, 821, 14, 709, 14, 7968, 7, 272, 1543, 68, 4111, 77, 4111, 89, 297, 221, 327, 283, 821, 14, 709, 14, 1690, 7, 199, 61, 199, 12488, 63, 7321, 63, 14019, 275, 359, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 297, 258, 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, 221, 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, 263, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 297, 4519, 327, 283, 821, 14, 709, 14, 7968, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 297, 4519, 327, 283, 821, 14, 709, 14, 1690, 7, 199, 61, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 1557, 1800, 16, 7, 221, 327, 2222, 13, 4785, 316, 4601, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ghgr/BetFair_Arbitrer
estimator.py
1
4553
""" The MIT License (MIT) Copyright (c) 2015 Eduardo Pena Vina 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 pyodds reload(pyodds) import sys sys.dont_write_bytecode=True import numpy as np import pprint class Estimator: def __init__(self,odds_dict, homeTeam, awayTeam,log): self.odds = odds_dict self.log=log self.homeTeam = homeTeam self.awayTeam = awayTeam # estimate_params self.lambda_home_ft, self.lambda_away_ft = pyodds.getLambdas(self.odds, self.homeTeam, self.awayTeam, self.log) self.log.log("estimator","Home lambda (FT):", self.lambda_home_ft) self.log.log("estimator","Away lambda (FT):", self.lambda_away_ft) self.lambda_home_ht = 0.5 * self.lambda_home_ft self.lambda_away_ht = 0.5 * self.lambda_away_ft def market_Full_Time(self): return pyodds.market_Full_Time(self.lambda_home_ft,self.lambda_away_ft, self.homeTeam, self.awayTeam, self.log) def market_CorrectScore(self): return pyodds.market_CorrectScore(self.lambda_home_ft,self.lambda_away_ft, self.log) def market_Over_Under_0_5(self): return pyodds.market_Over_Under_0_5(self.lambda_home_ft,self.lambda_away_ft,self.log) def market_Over_Under_1_5(self): return pyodds.market_Over_Under_1_5(self.lambda_home_ft,self.lambda_away_ft,self.log) def market_Over_Under_2_5(self): return pyodds.market_Over_Under_2_5(self.lambda_home_ft,self.lambda_away_ft,self.log) def market_Over_Under_3_5(self): return pyodds.market_Over_Under_3_5(self.lambda_home_ft,self.lambda_away_ft,self.log) def market_Over_Under_4_5(self): return pyodds.market_Over_Under_4_5(self.lambda_home_ft,self.lambda_away_ft,self.log) def market_Over_Under_5_5(self): return pyodds.market_Over_Under_5_5(self.lambda_home_ft,self.lambda_away_ft,self.log) def market_Over_Under_6_5(self): return pyodds.market_Over_Under_6_5(self.lambda_home_ft,self.lambda_away_ft,self.log) def market_Over_Under_7_5(self): return pyodds.market_Over_Under_7_5(self.lambda_home_ft,self.lambda_away_ft,self.log) def market_Over_Under_8_5(self): return pyodds.market_Over_Under_8_5(self.lambda_home_ft,self.lambda_away_ft,self.log) def market_Half_Time_Over_Under_0_5(self): return pyodds.market_Half_Time_Over_Under_0_5(self.lambda_home_ht,self.lambda_away_ht,self.log) def market_Half_Time_Over_Under_1_5(self): return pyodds.market_Half_Time_Over_Under_1_5(self.lambda_home_ht,self.lambda_away_ht,self.log) def market_Half_Time(self): return pyodds.market_Half_Time(self.lambda_home_ht,self.lambda_away_ht, self.homeTeam, self.awayTeam, self.log) def market_HT_FT(self): return pyodds.market_HT_FT(self.lambda_home_ht,self.lambda_away_ht, self.homeTeam, self.awayTeam,self.log) def market_Half_Time_Score(self): return pyodds.market_Half_Time_Score(self.lambda_home_ht,self.lambda_away_ht, self.log) def market_CorrectScore2Home(self): return pyodds.market_CorrectScore2Home(self.lambda_home_ft, self.lambda_away_ft, self.log) def market_CorrectScore2Away(self): return pyodds.market_CorrectScore2Away(self.lambda_home_ft, self.lambda_away_ft, self.log) def market_BothTeamsToScore(self): return pyodds.market_BothTeamsToScore(self.lambda_home_ft, self.lambda_away_ft, self.log) def market_First_Goal(self): return pyodds.market_First_Goal(self.lambda_home_ft, self.lambda_away_ft, self.homeTeam, self.awayTeam,self.log) def market_Draw_No_Bet(self): return pyodds.market_draw_no_bet(self.lambda_home_ft, self.lambda_away_ft, self.homeTeam, self.awayTeam,self.log) if __name__=="__main__": m = Estimator("Madrid","Barca",4.4,1.59,6.6,4.6,1.60,7.0)
mit
[ 624, 199, 1918, 10697, 844, 334, 13965, 9, 199, 199, 7384, 334, 67, 9, 6900, 662, 2033, 1005, 79, 510, 287, 65, 812, 13765, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 1618, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 262, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 475, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 16847, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 70, 13399, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 199, 1918, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 1006, 199, 16847, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 18061, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 8947, 5177, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 38, 3061, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 5580, 4149, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 2673, 2477, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 1877, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 199, 26734, 14, 199, 624, 199, 199, 646, 1134, 364, 795, 199, 9233, 8, 647, 364, 795, 9, 199, 646, 984, 199, 1274, 14, 18671, 63, 952, 63, 19812, 29, 549, 199, 646, 2680, 465, 980, 199, 646, 10933, 199, 199, 533, 28992, 26, 421, 198, 318, 636, 826, 721, 277, 12, 364, 795, 63, 807, 12, 5629, 13126, 12, 13437, 13126, 12, 793, 304, 2742, 198, 277, 14, 364, 795, 275, 16699, 83, 63, 807, 2742, 198, 277, 14, 793, 29, 793, 507, 198, 277, 14, 4219, 13126, 275, 5629, 13126, 507, 198, 277, 14, 22703, 13126, 275, 13437, 13126, 2742, 198, 3, 14497, 63, 1162, 507, 198, 277, 14, 2734, 63, 4219, 63, 856, 12, 291, 14, 2734, 63, 22703, 63, 856, 275, 1134, 364, 795, 14, 362, 44, 455, 3691, 305, 8, 277, 14, 364, 795, 12, 291, 14, 4219, 13126, 12, 291, 14, 22703, 13126, 12, 291, 14, 793, 9, 507, 198, 277, 14, 793, 14, 793, 480, 8627, 2266, 12054, 2400, 334, 2161, 304, 401, 291, 14, 2734, 63, 4219, 63, 856, 9, 507, 198, 277, 14, 793, 14, 793, 480, 8627, 2266, 33, 3316, 2400, 334, 2161, 304, 401, 291, 14, 2734, 63, 22703, 63, 856, 9, 2742, 198, 277, 14, 2734, 63, 4219, 63, 517, 275, 378, 14, 21, 627, 291, 14, 2734, 63, 4219, 63, 856, 507, 198, 277, 14, 2734, 63, 22703, 63, 517, 275, 378, 14, 21, 627, 291, 14, 2734, 63, 22703, 63, 856, 421, 198, 318, 26584, 63, 9042, 63, 1366, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 9042, 63, 1366, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 291, 14, 4219, 13126, 12, 291, 14, 22703, 13126, 12, 291, 14, 793, 9, 199, 198, 318, 26584, 63, 19993, 12642, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 19993, 12642, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 291, 14, 793, 9, 199, 198, 318, 26584, 63, 5674, 63, 16001, 63, 16, 63, 21, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 5674, 63, 16001, 63, 16, 63, 21, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 277, 14, 793, 9, 199, 198, 318, 26584, 63, 5674, 63, 16001, 63, 17, 63, 21, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 5674, 63, 16001, 63, 17, 63, 21, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 277, 14, 793, 9, 199, 198, 318, 26584, 63, 5674, 63, 16001, 63, 18, 63, 21, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 5674, 63, 16001, 63, 18, 63, 21, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 277, 14, 793, 9, 199, 198, 318, 26584, 63, 5674, 63, 16001, 63, 19, 63, 21, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 5674, 63, 16001, 63, 19, 63, 21, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 277, 14, 793, 9, 199, 198, 318, 26584, 63, 5674, 63, 16001, 63, 20, 63, 21, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 5674, 63, 16001, 63, 20, 63, 21, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 277, 14, 793, 9, 199, 198, 318, 26584, 63, 5674, 63, 16001, 63, 21, 63, 21, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 5674, 63, 16001, 63, 21, 63, 21, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 277, 14, 793, 9, 199, 198, 318, 26584, 63, 5674, 63, 16001, 63, 22, 63, 21, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 5674, 63, 16001, 63, 22, 63, 21, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 277, 14, 793, 9, 199, 198, 318, 26584, 63, 5674, 63, 16001, 63, 23, 63, 21, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 5674, 63, 16001, 63, 23, 63, 21, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 277, 14, 793, 9, 199, 198, 318, 26584, 63, 5674, 63, 16001, 63, 24, 63, 21, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 5674, 63, 16001, 63, 24, 63 ]
[ 199, 1918, 10697, 844, 334, 13965, 9, 199, 199, 7384, 334, 67, 9, 6900, 662, 2033, 1005, 79, 510, 287, 65, 812, 13765, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 1618, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 262, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 475, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 16847, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 70, 13399, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 199, 1918, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 1006, 199, 16847, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 18061, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 8947, 5177, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 38, 3061, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 5580, 4149, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 2673, 2477, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 1877, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 199, 26734, 14, 199, 624, 199, 199, 646, 1134, 364, 795, 199, 9233, 8, 647, 364, 795, 9, 199, 646, 984, 199, 1274, 14, 18671, 63, 952, 63, 19812, 29, 549, 199, 646, 2680, 465, 980, 199, 646, 10933, 199, 199, 533, 28992, 26, 421, 198, 318, 636, 826, 721, 277, 12, 364, 795, 63, 807, 12, 5629, 13126, 12, 13437, 13126, 12, 793, 304, 2742, 198, 277, 14, 364, 795, 275, 16699, 83, 63, 807, 2742, 198, 277, 14, 793, 29, 793, 507, 198, 277, 14, 4219, 13126, 275, 5629, 13126, 507, 198, 277, 14, 22703, 13126, 275, 13437, 13126, 2742, 198, 3, 14497, 63, 1162, 507, 198, 277, 14, 2734, 63, 4219, 63, 856, 12, 291, 14, 2734, 63, 22703, 63, 856, 275, 1134, 364, 795, 14, 362, 44, 455, 3691, 305, 8, 277, 14, 364, 795, 12, 291, 14, 4219, 13126, 12, 291, 14, 22703, 13126, 12, 291, 14, 793, 9, 507, 198, 277, 14, 793, 14, 793, 480, 8627, 2266, 12054, 2400, 334, 2161, 304, 401, 291, 14, 2734, 63, 4219, 63, 856, 9, 507, 198, 277, 14, 793, 14, 793, 480, 8627, 2266, 33, 3316, 2400, 334, 2161, 304, 401, 291, 14, 2734, 63, 22703, 63, 856, 9, 2742, 198, 277, 14, 2734, 63, 4219, 63, 517, 275, 378, 14, 21, 627, 291, 14, 2734, 63, 4219, 63, 856, 507, 198, 277, 14, 2734, 63, 22703, 63, 517, 275, 378, 14, 21, 627, 291, 14, 2734, 63, 22703, 63, 856, 421, 198, 318, 26584, 63, 9042, 63, 1366, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 9042, 63, 1366, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 291, 14, 4219, 13126, 12, 291, 14, 22703, 13126, 12, 291, 14, 793, 9, 199, 198, 318, 26584, 63, 19993, 12642, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 19993, 12642, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 291, 14, 793, 9, 199, 198, 318, 26584, 63, 5674, 63, 16001, 63, 16, 63, 21, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 5674, 63, 16001, 63, 16, 63, 21, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 277, 14, 793, 9, 199, 198, 318, 26584, 63, 5674, 63, 16001, 63, 17, 63, 21, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 5674, 63, 16001, 63, 17, 63, 21, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 277, 14, 793, 9, 199, 198, 318, 26584, 63, 5674, 63, 16001, 63, 18, 63, 21, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 5674, 63, 16001, 63, 18, 63, 21, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 277, 14, 793, 9, 199, 198, 318, 26584, 63, 5674, 63, 16001, 63, 19, 63, 21, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 5674, 63, 16001, 63, 19, 63, 21, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 277, 14, 793, 9, 199, 198, 318, 26584, 63, 5674, 63, 16001, 63, 20, 63, 21, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 5674, 63, 16001, 63, 20, 63, 21, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 277, 14, 793, 9, 199, 198, 318, 26584, 63, 5674, 63, 16001, 63, 21, 63, 21, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 5674, 63, 16001, 63, 21, 63, 21, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 277, 14, 793, 9, 199, 198, 318, 26584, 63, 5674, 63, 16001, 63, 22, 63, 21, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 5674, 63, 16001, 63, 22, 63, 21, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 277, 14, 793, 9, 199, 198, 318, 26584, 63, 5674, 63, 16001, 63, 23, 63, 21, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 5674, 63, 16001, 63, 23, 63, 21, 8, 277, 14, 2734, 63, 4219, 63, 856, 12, 277, 14, 2734, 63, 22703, 63, 856, 12, 277, 14, 793, 9, 199, 198, 318, 26584, 63, 5674, 63, 16001, 63, 24, 63, 21, 8, 277, 304, 507, 198, 1107, 1134, 364, 795, 14, 22270, 63, 5674, 63, 16001, 63, 24, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
cuongnv23/ansible
lib/ansible/modules/network/lenovo/cnos_portchannel.py
26
22094
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright (C) 2017 Lenovo, Inc. # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # # Module to send Port channel commands to Lenovo Switches # Lenovo Networking # ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: cnos_portchannel author: "Dave Kasberg (@dkasberg)" short_description: Manage portchannel (port aggregation) configuration on devices running Lenovo CNOS description: - This module allows you to work with port aggregation related configurations. The operators used are overloaded to ensure control over switch port aggregation configurations. Apart from the regular device connection related attributes, there are five LAG arguments which are overloaded variables that will perform further configurations. They are interfaceArg1, interfaceArg2, interfaceArg3, interfaceArg4, and interfaceArg5. For more details on how to use these arguments, see [Overloaded Variables]. This module uses SSH to manage network device configuration. The results of the operation will be placed in a directory named 'results' that must be created by the user in their local directory to where the playbook is run. For more information about this module from Lenovo and customizing it usage for your use cases, please U(http://systemx.lenovofiles.com/help/index.jsp?topic=%2Fcom.lenovo.switchmgt.ansible.doc%2Fcnos_portchannel.html) version_added: "2.3" extends_documentation_fragment: cnos options: interfaceRange: description: - This specifies the interface range in which the port aggregation is envisaged required: Yes default: Null interfaceArg1: description: - This is an overloaded Port Channel first argument. Usage of this argument can be found is the User Guide referenced above. required: Yes default: Null choices: [aggregation-group, bfd, bridgeport, description, duplex, flowcontrol, ip, ipv6, lacp, lldp, load-interval, mac, mac-address, mac-learn, microburst-detection, mtu, service, service-policy, shutdown, snmp, spanning-tree, speed, storm-control, vlan, vrrp, port-aggregation] interfaceArg2: description: - This is an overloaded Port Channel second argument. Usage of this argument can be found is the User Guide referenced above. required: No default: Null choices: [aggregation-group number, access or mode or trunk, description, auto or full or half, receive or send, port-priority, suspend-individual, timeout, receive or transmit or trap-notification, tlv-select, Load interval delay in seconds, counter, Name for the MAC Access List, mac-address in HHHH.HHHH.HHHH format, THRESHOLD Value in unit of buffer cell, <64-9216> MTU in bytes-<64-9216> for L2 packet,<576-9216> for L3 IPv4 packet, <1280-9216> for L3 IPv6 packet, enter the instance id, input or output, copp-system-policy, type, 1000 or 10000 or 40000 or auto, broadcast or multicast or unicast, disable or enable or egress-only, Virtual router identifier, destination-ip or destination-mac or destination-port or source-dest-ip or source-dest-mac or source-dest-port or source-interface or source-ip or source-mac or source-port] interfaceArg3: description: - This is an overloaded Port Channel third argument. Usage of this argument can be found is the User Guide referenced above. required: No default: Null choices: [active or on or passive, on or off, LACP port priority, long or short, link-aggregation or mac-phy-status or management-address or max-frame-size or port-description or port-protocol-vlan or port-vlan or power-mdi or protocol-identity or system-capabilities or system-description or system-name or vid-management or vlan-name, counter for load interval, policy input name, all or Copp class name to attach, qos, queueing, Enter the allowed traffic level, ipv6] interfaceArg4: description: - This is an overloaded Port Channel fourth argument. Usage of this argument can be found is the User Guide referenced above. required: No default: Null choices: [key-chain, key-id, keyed-md5 or keyed-sha1 or meticulous-keyed-md5 or meticulous-keyed-sha1 or simple, Interval value in milliseconds, Destination IP (Both IPV4 and IPV6),in or out, MAC address, Time-out value in seconds, class-id, request, Specify the IPv4 address, OSPF area ID as a decimal value, OSPF area ID in IP address format, anycast or secondary, ethernet, vlan, MAC (hardware) address in HHHH.HHHH.HHHH format, Load interval delay in seconds, Specify policy input name, input or output, cost, port-priority, BFD minimum receive interval,source-interface] interfaceArg5: description: - This is an overloaded Port Channel fifth argument. Usage of this argument can be found is the User Guide referenced above. required: No default: Null choices: [name of key-chain, key-Id Value, key-chain , key-id, BFD minimum receive interval, Value of Hello Multiplier, admin-down or multihop or non-persistent, Vendor class-identifier name, bootfile-name or host-name or log-server or ntp-server or tftp-server-name, Slot/chassis number, Vlan interface, Specify policy input name, Port path cost or auto, Port priority increments of 32] interfaceArg6: description: - This is an overloaded Port Channel sixth argument. Usage of this argument can be found is the User Guide referenced above. required: No default: Null choices: [Authentication key string, name of key-chain, key-Id Value, Value of Hello Multiplier, admin-down or non-persistent] interfaceArg7: description: - This is an overloaded Port Channel seventh argument. Usage of this argument can be found is the User Guide referenced above. required: No default: Null choices: [Authentication key string, admin-down] ''' EXAMPLES = ''' Tasks : The following are examples of using the module cnos_portchannel. These are written in the main.yml file of the tasks directory. --- - name: Test Port Channel - aggregation-group cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "aggregation-group" interfaceArg2: 33 interfaceArg3: "on" - name: Test Port Channel - aggregation-group - Interface Range cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: "1/1-2" interfaceArg1: "aggregation-group" interfaceArg2: 33 interfaceArg3: "on" - name: Test Port Channel - bridge-port cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "bridge-port" interfaceArg2: "access" interfaceArg3: 33 - name: Test Port Channel - bridgeport mode cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "bridge-port" interfaceArg2: "mode" interfaceArg3: "access" - name: Test Port Channel - Description cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "description" interfaceArg2: "Hentammoo " - name: Test Port Channel - Duplex cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "duplex" interfaceArg2: "auto" - name: Test Port Channel - flowcontrol cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "flowcontrol" interfaceArg2: "send" interfaceArg3: "off" - name: Test Port Channel - lacp cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "lacp" interfaceArg2: "port-priority" interfaceArg3: 33 - name: Test Port Channel - lldp cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "lldp" interfaceArg2: "tlv-select" interfaceArg3: "max-frame-size" - name: Test Port Channel - load-interval cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "load-interval" interfaceArg2: "counter" interfaceArg3: 2 interfaceArg4: 33 #- name: Test Port Channel - mac # cnos_portchannel: # host: "{{ inventory_hostname }}" # username: "{{ hostvars[inventory_hostname]['username'] }}" # password: "{{ hostvars[inventory_hostname]['password'] }}" # deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" # outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" # interfaceRange: 33, # interfaceArg1: "mac" # interfaceArg2: "copp-system-acl-vlag-hc" - name: Test Port Channel - microburst-detection cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "microburst-detection" interfaceArg2: 25 - name: Test Port Channel - mtu cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "mtu" interfaceArg2: 66 - name: Test Port Channel - service-policy cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "service-policy" interfaceArg2: "input" interfaceArg3: "Anil" - name: Test Port Channel - speed cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "speed" interfaceArg2: "auto" - name: Test Port Channel - storm cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "storm-control" interfaceArg2: "broadcast" interfaceArg3: 12.5 #- name: Test Port Channel - vlan # cnos_portchannel: # host: "{{ inventory_hostname }}" # username: "{{ hostvars[inventory_hostname]['username'] }}" # password: "{{ hostvars[inventory_hostname]['password'] }}" # deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" # outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" # interfaceRange: 33 # interfaceArg1: "vlan" # interfaceArg2: "disable" - name: Test Port Channel - vrrp cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "vrrp" interfaceArg2: 33 - name: Test Port Channel - spanning tree1 cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "spanning-tree" interfaceArg2: "bpduguard" interfaceArg3: "enable" - name: Test Port Channel - spanning tree 2 cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "spanning-tree" interfaceArg2: "mst" interfaceArg3: "33-35" interfaceArg4: "cost" interfaceArg5: 33 - name: Test Port Channel - ip1 cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "ip" interfaceArg2: "access-group" interfaceArg3: "anil" interfaceArg4: "in" - name: Test Port Channel - ip2 cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "ip" interfaceArg2: "port" interfaceArg3: "anil" - name: Test Port Channel - bfd cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "bfd" interfaceArg2: "interval" interfaceArg3: 55 interfaceArg4: 55 interfaceArg5: 33 - name: Test Port Channel - bfd cnos_portchannel: host: "{{ inventory_hostname }}" username: "{{ hostvars[inventory_hostname]['username'] }}" password: "{{ hostvars[inventory_hostname]['password'] }}" deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}" outputfile: "./results/test_portchannel_{{ inventory_hostname }}_output.txt" interfaceRange: 33 interfaceArg1: "bfd" interfaceArg2: "ipv4" interfaceArg3: "authentication" interfaceArg4: "meticulous-keyed-md5" interfaceArg5: "key-chain" interfaceArg6: "mychain" ''' RETURN = ''' msg: description: Success or failure message returned: always type: string sample: "Port Channel configurations accomplished" ''' import sys import paramiko import time import argparse import socket import array import json import time import re try: from ansible.module_utils import cnos HAS_LIB = True except: HAS_LIB = False from ansible.module_utils.basic import AnsibleModule from collections import defaultdict def main(): module = AnsibleModule( argument_spec=dict( outputfile=dict(required=True), host=dict(required=True), username=dict(required=True), password=dict(required=True, no_log=True), enablePassword=dict(required=False, no_log=True), deviceType=dict(required=True), interfaceRange=dict(required=False), interfaceArg1=dict(required=True), interfaceArg2=dict(required=False), interfaceArg3=dict(required=False), interfaceArg4=dict(required=False), interfaceArg5=dict(required=False), interfaceArg6=dict(required=False), interfaceArg7=dict(required=False),), supports_check_mode=False) username = module.params['username'] password = module.params['password'] enablePassword = module.params['enablePassword'] interfaceRange = module.params['interfaceRange'] interfaceArg1 = module.params['interfaceArg1'] interfaceArg2 = module.params['interfaceArg2'] interfaceArg3 = module.params['interfaceArg3'] interfaceArg4 = module.params['interfaceArg4'] interfaceArg5 = module.params['interfaceArg5'] interfaceArg6 = module.params['interfaceArg6'] interfaceArg7 = module.params['interfaceArg7'] outputfile = module.params['outputfile'] hostIP = module.params['host'] deviceType = module.params['deviceType'] output = "" # Create instance of SSHClient object remote_conn_pre = paramiko.SSHClient() # Automatically add untrusted hosts (make sure okay for security policy in your environment) remote_conn_pre.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # initiate SSH connection with the switch remote_conn_pre.connect(hostIP, username=username, password=password) time.sleep(2) # Use invoke_shell to establish an 'interactive session' remote_conn = remote_conn_pre.invoke_shell() time.sleep(2) # Enable and enter configure terminal then send command output = output + cnos.waitForDeviceResponse("\n", ">", 2, remote_conn) output = output + cnos.enterEnableModeForDevice(enablePassword, 3, remote_conn) # Make terminal length = 0 output = output + cnos.waitForDeviceResponse("terminal length 0\n", "#", 2, remote_conn) # Go to config mode output = output + cnos.waitForDeviceResponse("configure d\n", "(config)#", 2, remote_conn) # Send the CLi command if(interfaceArg1 == "port-aggregation"): output = output + cnos.portChannelConfig(remote_conn, deviceType, "(config)#", 2, interfaceArg1, interfaceArg2, interfaceArg3, interfaceArg4, interfaceArg5, interfaceArg6, interfaceArg7) else: output = output + cnos.interfaceConfig(remote_conn, deviceType, "(config)#", 2, "port-aggregation", interfaceRange, interfaceArg1, interfaceArg2, interfaceArg3, interfaceArg4, interfaceArg5, interfaceArg6, interfaceArg7) # Save it into the file file = open(outputfile, "a") file.write(output) file.close() # Logic to check when changes occur or not errorMsg = cnos.checkOutputForError(output) if(errorMsg is None): module.exit_json(changed=True, msg="Port Aggregation configuration is done") else: module.fail_json(msg=errorMsg) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 9708, 15757, 31445, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 3, 5673, 370, 3222, 10977, 3623, 3718, 370, 15757, 31445, 17711, 397, 199, 3, 15757, 31445, 7220, 316, 199, 3, 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, 32535, 63, 719, 2775, 199, 2502, 26, 298, 36, 811, 1804, 305, 14630, 8593, 6341, 305, 14630, 2924, 199, 3612, 63, 1802, 26, 14944, 1844, 2775, 334, 719, 18384, 9, 2897, 641, 7256, 3879, 15757, 31445, 445, 23141, 199, 1802, 26, 272, 446, 961, 859, 6127, 1265, 370, 1736, 543, 1844, 18384, 4048, 13422, 14, 710, 10211, 1362, 1202, 787, 1806, 4591, 370, 4868, 3304, 1806, 6258, 1844, 18384, 13422, 14, 437, 2064, 1362, 687, 314, 5578, 2243, 1950, 4048, 3004, 12, 2337, 787, 24187, 491, 1254, 2368, 1314, 787, 1362, 1806, 4591, 2860, 626, 911, 5147, 9848, 13422, 14, 9322, 787, 3217, 6373, 17, 12, 3217, 6373, 18, 12, 1362, 3217, 6373, 19, 12, 3217, 6373, 20, 12, 436, 3217, 6373, 21, 14, 2104, 1655, 2436, 641, 4212, 370, 675, 3520, 2368, 12, 1937, 1362, 359, 5674, 4591, 17198, 1055, 1362, 961, 859, 4440, 12027, 370, 9635, 2784, 2243, 2897, 14, 1362, 710, 2058, 402, 314, 3439, 911, 506, 15090, 315, 282, 2082, 4310, 283, 2604, 7, 1362, 626, 1471, 506, 2737, 701, 314, 922, 315, 3932, 2257, 2082, 370, 2382, 314, 15695, 365, 1255, 14, 1362, 2104, 1655, 2556, 3595, 642, 859, 687, 15757, 31445, 436, 3537, 9147, 652, 4503, 367, 2195, 1362, 675, 5560, 12, 8749, 738, 8, 1014, 921, 2253, 88, 14, 552, 31445, 1725, 14, 957, 15, 3437, 15, 1080, 14, 74, 681, 31, 5746, 2458, 18, 38, 957, 14, 552, 31445, 14, 5656, 77, 3308, 14, 4853, 14, 1301, 5, 18, 38, 6413, 736, 63, 719, 2775, 14, 1360, 9, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 11036, 63, 9970, 63, 7677, 26, 32535, 199, 1419, 26, 272, 3217, 4709, 26, 267, 1369, 26, 288, 446, 961, 9314, 314, 3217, 1425, 315, 1314, 314, 1844, 18384, 365, 2589, 374, 6028, 267, 1415, 26, 29715, 267, 849, 26, 12119, 272, 3217, 6373, 17, 26, 267, 1369, 26, 288, 446, 961, 365, 376, 1806, 4591, 10977, 17270, 1642, 1423, 14, 11028, 402, 642, 1423, 883, 506, 1911, 365, 314, 2876, 15423, 11812, 3432, 14, 267, 1415, 26, 29715, 267, 849, 26, 12119, 267, 3415, 26, 359, 21016, 13, 923, 12, 330, 2592, 12, 13928, 719, 12, 1369, 12, 366, 26646, 12, 6369, 2785, 12, 3384, 12, 3278, 22, 12, 1127, 1850, 12, 28768, 12, 267, 2248, 13, 4284, 12, 4497, 12, 4497, 13, 1562, 12, 4497, 13, 4643, 12, 9967, 26420, 13, 11934, 12, 28270, 12, 2435, 12, 2435, 13, 3185, 12, 267, 12842, 12, 20143, 12, 2249, 11495, 13, 2350, 12, 8112, 12, 410, 1025, 13, 2785, 12, 10119, 12, 29928, 12, 1844, 13, 21016, 61, 272, 3217, 6373, 18, 26, 267, 1369, 26, 288, 446, 961, 365, 376, 1806, 4591, 10977, 17270, 3499, 1423, 14, 11028, 402, 642, 1423, 883, 506, 1911, 365, 314, 2876, 15423, 11812, 3432, 14, 267, 1415, 26, 3091, 267, 849, 26, 12119, 267, 3415, 26, 359, 21016, 13, 923, 1329, 12, 2879, 503, 818, 503, 24764, 12, 1369, 12, 2599, 503, 2615, 503, 12995, 12, 267, 9128, 503, 3222, 12, 1844, 13, 6693, 12, 20288, 13, 23001, 12, 2653, 12, 258, 9128, 503, 27754, 503, 22514, 13, 6761, 12, 267, 307, 6371, 13, 2416, 12, 7190, 6252, 7339, 315, 4696, 12, 7055, 12, 2812, 367, 314, 13347, 11003, 3820, 12, 4497, 13, 1562, 315, 869, 10213, 40, 14, 10213, 10213, 14, 10213, 10213, 1475, 12, 267, 4221, 15098, 5104, 221, 1594, 315, 4137, 402, 3335, 4917, 12, 665, 772, 13, 2942, 975, 30, 221, 603, 21364, 315, 2783, 13, 28, 772, 13, 2942, 975, 30, 367, 491, 18, 3644, 30027, 12255, 13, 2942, 975, 30, 367, 267, 491, 19, 6509, 20, 3644, 12, 665, 713, 1257, 13, 2942, 975, 30, 367, 491, 19, 6509, 22, 3644, 12, 9509, 314, 1256, 1305, 12, 1324, 503, 1072, 12, 4870, 80, 13, 2253, 13, 3185, 12, 267, 730, 12, 5198, 221, 503, 221, 11630, 221, 503, 257, 841, 993, 503, 257, 2599, 12, 11180, 503, 28321, 503, 625, 530, 1810, 12, 3507, 503, 4756, 503, 325, 3313, 13, 2118, 12, 267, 13311, 6197, 5148, 12, 5724, 13, 711, 503, 5724, 13, 3088, 503, 5724, 13, 719, 503, 1350, 13, 2614, 13, 711, 503, 267, 1350, 13, 2614, 13, 3088, 503, 1350, 13, 2614, 13, 719, 503, 1350, 13, 3266, 503, 1350, 13, 711, 503, 1350, 13, 3088, 503, 1350, 13, 719, 61, 272, 3217, 6373, 19, 26, 267, 1369, 26, 288, 446, 961, 365, 376, 1806, 4591, 10977, 17270, 10919, 1423, 14, 11028, 402, 642, 1423, 883, 506, 1911, 365, 314, 2876, 15423, 11812, 3432, 14, 267, 1415, 26, 3091, 267, 849, 26, 12119, 267, 3415, 26, 359, 2682, 503, 641 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 9708, 15757, 31445, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 3, 5673, 370, 3222, 10977, 3623, 3718, 370, 15757, 31445, 17711, 397, 199, 3, 15757, 31445, 7220, 316, 199, 3, 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, 32535, 63, 719, 2775, 199, 2502, 26, 298, 36, 811, 1804, 305, 14630, 8593, 6341, 305, 14630, 2924, 199, 3612, 63, 1802, 26, 14944, 1844, 2775, 334, 719, 18384, 9, 2897, 641, 7256, 3879, 15757, 31445, 445, 23141, 199, 1802, 26, 272, 446, 961, 859, 6127, 1265, 370, 1736, 543, 1844, 18384, 4048, 13422, 14, 710, 10211, 1362, 1202, 787, 1806, 4591, 370, 4868, 3304, 1806, 6258, 1844, 18384, 13422, 14, 437, 2064, 1362, 687, 314, 5578, 2243, 1950, 4048, 3004, 12, 2337, 787, 24187, 491, 1254, 2368, 1314, 787, 1362, 1806, 4591, 2860, 626, 911, 5147, 9848, 13422, 14, 9322, 787, 3217, 6373, 17, 12, 3217, 6373, 18, 12, 1362, 3217, 6373, 19, 12, 3217, 6373, 20, 12, 436, 3217, 6373, 21, 14, 2104, 1655, 2436, 641, 4212, 370, 675, 3520, 2368, 12, 1937, 1362, 359, 5674, 4591, 17198, 1055, 1362, 961, 859, 4440, 12027, 370, 9635, 2784, 2243, 2897, 14, 1362, 710, 2058, 402, 314, 3439, 911, 506, 15090, 315, 282, 2082, 4310, 283, 2604, 7, 1362, 626, 1471, 506, 2737, 701, 314, 922, 315, 3932, 2257, 2082, 370, 2382, 314, 15695, 365, 1255, 14, 1362, 2104, 1655, 2556, 3595, 642, 859, 687, 15757, 31445, 436, 3537, 9147, 652, 4503, 367, 2195, 1362, 675, 5560, 12, 8749, 738, 8, 1014, 921, 2253, 88, 14, 552, 31445, 1725, 14, 957, 15, 3437, 15, 1080, 14, 74, 681, 31, 5746, 2458, 18, 38, 957, 14, 552, 31445, 14, 5656, 77, 3308, 14, 4853, 14, 1301, 5, 18, 38, 6413, 736, 63, 719, 2775, 14, 1360, 9, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 11036, 63, 9970, 63, 7677, 26, 32535, 199, 1419, 26, 272, 3217, 4709, 26, 267, 1369, 26, 288, 446, 961, 9314, 314, 3217, 1425, 315, 1314, 314, 1844, 18384, 365, 2589, 374, 6028, 267, 1415, 26, 29715, 267, 849, 26, 12119, 272, 3217, 6373, 17, 26, 267, 1369, 26, 288, 446, 961, 365, 376, 1806, 4591, 10977, 17270, 1642, 1423, 14, 11028, 402, 642, 1423, 883, 506, 1911, 365, 314, 2876, 15423, 11812, 3432, 14, 267, 1415, 26, 29715, 267, 849, 26, 12119, 267, 3415, 26, 359, 21016, 13, 923, 12, 330, 2592, 12, 13928, 719, 12, 1369, 12, 366, 26646, 12, 6369, 2785, 12, 3384, 12, 3278, 22, 12, 1127, 1850, 12, 28768, 12, 267, 2248, 13, 4284, 12, 4497, 12, 4497, 13, 1562, 12, 4497, 13, 4643, 12, 9967, 26420, 13, 11934, 12, 28270, 12, 2435, 12, 2435, 13, 3185, 12, 267, 12842, 12, 20143, 12, 2249, 11495, 13, 2350, 12, 8112, 12, 410, 1025, 13, 2785, 12, 10119, 12, 29928, 12, 1844, 13, 21016, 61, 272, 3217, 6373, 18, 26, 267, 1369, 26, 288, 446, 961, 365, 376, 1806, 4591, 10977, 17270, 3499, 1423, 14, 11028, 402, 642, 1423, 883, 506, 1911, 365, 314, 2876, 15423, 11812, 3432, 14, 267, 1415, 26, 3091, 267, 849, 26, 12119, 267, 3415, 26, 359, 21016, 13, 923, 1329, 12, 2879, 503, 818, 503, 24764, 12, 1369, 12, 2599, 503, 2615, 503, 12995, 12, 267, 9128, 503, 3222, 12, 1844, 13, 6693, 12, 20288, 13, 23001, 12, 2653, 12, 258, 9128, 503, 27754, 503, 22514, 13, 6761, 12, 267, 307, 6371, 13, 2416, 12, 7190, 6252, 7339, 315, 4696, 12, 7055, 12, 2812, 367, 314, 13347, 11003, 3820, 12, 4497, 13, 1562, 315, 869, 10213, 40, 14, 10213, 10213, 14, 10213, 10213, 1475, 12, 267, 4221, 15098, 5104, 221, 1594, 315, 4137, 402, 3335, 4917, 12, 665, 772, 13, 2942, 975, 30, 221, 603, 21364, 315, 2783, 13, 28, 772, 13, 2942, 975, 30, 367, 491, 18, 3644, 30027, 12255, 13, 2942, 975, 30, 367, 267, 491, 19, 6509, 20, 3644, 12, 665, 713, 1257, 13, 2942, 975, 30, 367, 491, 19, 6509, 22, 3644, 12, 9509, 314, 1256, 1305, 12, 1324, 503, 1072, 12, 4870, 80, 13, 2253, 13, 3185, 12, 267, 730, 12, 5198, 221, 503, 221, 11630, 221, 503, 257, 841, 993, 503, 257, 2599, 12, 11180, 503, 28321, 503, 625, 530, 1810, 12, 3507, 503, 4756, 503, 325, 3313, 13, 2118, 12, 267, 13311, 6197, 5148, 12, 5724, 13, 711, 503, 5724, 13, 3088, 503, 5724, 13, 719, 503, 1350, 13, 2614, 13, 711, 503, 267, 1350, 13, 2614, 13, 3088, 503, 1350, 13, 2614, 13, 719, 503, 1350, 13, 3266, 503, 1350, 13, 711, 503, 1350, 13, 3088, 503, 1350, 13, 719, 61, 272, 3217, 6373, 19, 26, 267, 1369, 26, 288, 446, 961, 365, 376, 1806, 4591, 10977, 17270, 10919, 1423, 14, 11028, 402, 642, 1423, 883, 506, 1911, 365, 314, 2876, 15423, 11812, 3432, 14, 267, 1415, 26, 3091, 267, 849, 26, 12119, 267, 3415, 26, 359, 2682, 503, 641, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
srickardti/openthread
third_party/mbedtls/repo/tests/scripts/mbedtls_test.py
9
13403
# Greentea host test script for Mbed TLS on-target test suite testing. # # Copyright (C) 2018, Arm Limited, All Rights Reserved # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # This file is part of Mbed TLS (https://tls.mbed.org) """ Mbed TLS on-target test suite tests are implemented as Greentea tests. Greentea tests are implemented in two parts: target test and host test. Target test is a C application that is built for the target platform and executes on the target. Host test is a Python class derived from mbed_host_tests.BaseHostTest. Target communicates with the host over serial for the test data and sends back the result. Python tool mbedgt (Greentea) is responsible for flashing the test binary on to the target and dynamically loading this host test module. Greentea documentation can be found here: https://github.com/ARMmbed/greentea """ import re import os import binascii from mbed_host_tests import BaseHostTest, event_callback class TestDataParserError(Exception): """Indicates error in test data, read from .data file.""" pass class TestDataParser(object): """ Parses test name, dependencies, test function name and test parameters from the data file. """ def __init__(self): """ Constructor """ self.tests = [] def parse(self, data_file): """ Data file parser. :param data_file: Data file path """ with open(data_file, 'r') as data_f: self.__parse(data_f) @staticmethod def __escaped_split(inp_str, split_char): """ Splits inp_str on split_char except when escaped. :param inp_str: String to split :param split_char: Split character :return: List of splits """ if len(split_char) > 1: raise ValueError('Expected split character. Found string!') out = re.sub(r'(\\.)|' + split_char, lambda m: m.group(1) or '\n', inp_str, len(inp_str)).split('\n') out = [x for x in out if x] return out def __parse(self, data_f): """ Parses data file using supplied file object. :param data_f: Data file object :return: """ for line in data_f: line = line.strip() if not line: continue # Read test name name = line # Check dependencies dependencies = [] line = data_f.next().strip() match = re.search('depends_on:(.*)', line) if match: dependencies = [int(x) for x in match.group(1).split(':')] line = data_f.next().strip() # Read test vectors line = line.replace('\\n', '\n') parts = self.__escaped_split(line, ':') function_name = int(parts[0]) args = parts[1:] args_count = len(args) if args_count % 2 != 0: raise TestDataParserError("Number of test arguments should " "be even: %s" % line) grouped_args = [(args[i * 2], args[(i * 2) + 1]) for i in range(len(args)/2)] self.tests.append((name, function_name, dependencies, grouped_args)) def get_test_data(self): """ Returns test data. """ return self.tests class MbedTlsTest(BaseHostTest): """ Host test for Mbed TLS unit tests. This script is loaded at run time by Greentea for executing Mbed TLS test suites. Each communication from the target is received in this object as an event, which is then handled by the event handler method decorated by the associated event. Ex: @event_callback('GO'). Target test sends requests for dispatching next test. It reads tests from the intermediate data file and sends test function identifier, dependency identifiers, expression identifiers and the test data in binary form. Target test checks dependencies , evaluate integer constant expressions and dispatches the test function with received test parameters. After test function is finished, target sends the result. This class handles the result event and prints verdict in the form that Greentea understands. """ # status/error codes from suites/helpers.function DEPENDENCY_SUPPORTED = 0 KEY_VALUE_MAPPING_FOUND = DEPENDENCY_SUPPORTED DISPATCH_TEST_SUCCESS = DEPENDENCY_SUPPORTED KEY_VALUE_MAPPING_NOT_FOUND = -1 # Expression Id not found. DEPENDENCY_NOT_SUPPORTED = -2 # Dependency not supported. DISPATCH_TEST_FN_NOT_FOUND = -3 # Test function not found. DISPATCH_INVALID_TEST_DATA = -4 # Invalid parameter type. DISPATCH_UNSUPPORTED_SUITE = -5 # Test suite not supported/enabled. def __init__(self): """ Constructor initialises test index to 0. """ super(MbedTlsTest, self).__init__() self.tests = [] self.test_index = -1 self.dep_index = 0 self.error_str = dict() self.error_str[self.DEPENDENCY_SUPPORTED] = \ 'DEPENDENCY_SUPPORTED' self.error_str[self.KEY_VALUE_MAPPING_NOT_FOUND] = \ 'KEY_VALUE_MAPPING_NOT_FOUND' self.error_str[self.DEPENDENCY_NOT_SUPPORTED] = \ 'DEPENDENCY_NOT_SUPPORTED' self.error_str[self.DISPATCH_TEST_FN_NOT_FOUND] = \ 'DISPATCH_TEST_FN_NOT_FOUND' self.error_str[self.DISPATCH_INVALID_TEST_DATA] = \ 'DISPATCH_INVALID_TEST_DATA' self.error_str[self.DISPATCH_UNSUPPORTED_SUITE] = \ 'DISPATCH_UNSUPPORTED_SUITE' def setup(self): """ Setup hook implementation. Reads test suite data file and parses out tests. """ binary_path = self.get_config_item('image_path') script_dir = os.path.split(os.path.abspath(__file__))[0] suite_name = os.path.splitext(os.path.basename(binary_path))[0] data_file = ".".join((suite_name, 'data')) data_file = os.path.join(script_dir, '..', 'mbedtls', suite_name, data_file) if os.path.exists(data_file): self.log("Running tests from %s" % data_file) parser = TestDataParser() parser.parse(data_file) self.tests = parser.get_test_data() self.print_test_info() else: self.log("Data file not found: %s" % data_file) self.notify_complete(False) def print_test_info(self): """ Prints test summary read by Greentea to detect test cases. """ self.log('{{__testcase_count;%d}}' % len(self.tests)) for name, _, _, _ in self.tests: self.log('{{__testcase_name;%s}}' % name) @staticmethod def align_32bit(data_bytes): """ 4 byte aligns input byte array. :return: """ data_bytes += bytearray((4 - (len(data_bytes))) % 4) @staticmethod def hex_str_bytes(hex_str): """ Converts Hex string representation to byte array :param hex_str: Hex in string format. :return: Output Byte array """ if hex_str[0] != '"' or hex_str[len(hex_str) - 1] != '"': raise TestDataParserError("HEX test parameter missing '\"':" " %s" % hex_str) hex_str = hex_str.strip('"') if len(hex_str) % 2 != 0: raise TestDataParserError("HEX parameter len should be mod of " "2: %s" % hex_str) data_bytes = binascii.unhexlify(hex_str) return data_bytes @staticmethod def int32_to_big_endian_bytes(i): """ Coverts i to byte array in big endian format. :param i: Input integer :return: Output bytes array in big endian or network order """ data_bytes = bytearray([((i >> x) & 0xff) for x in [24, 16, 8, 0]]) return data_bytes def test_vector_to_bytes(self, function_id, dependencies, parameters): """ Converts test vector into a byte array that can be sent to the target. :param function_id: Test Function Identifier :param dependencies: Dependency list :param parameters: Test function input parameters :return: Byte array and its length """ data_bytes = bytearray([len(dependencies)]) if dependencies: data_bytes += bytearray(dependencies) data_bytes += bytearray([function_id, len(parameters)]) for typ, param in parameters: if typ == 'int' or typ == 'exp': i = int(param) data_bytes += 'I' if typ == 'int' else 'E' self.align_32bit(data_bytes) data_bytes += self.int32_to_big_endian_bytes(i) elif typ == 'char*': param = param.strip('"') i = len(param) + 1 # + 1 for null termination data_bytes += 'S' self.align_32bit(data_bytes) data_bytes += self.int32_to_big_endian_bytes(i) data_bytes += bytearray(list(param)) data_bytes += '\0' # Null terminate elif typ == 'hex': binary_data = self.hex_str_bytes(param) data_bytes += 'H' self.align_32bit(data_bytes) i = len(binary_data) data_bytes += self.int32_to_big_endian_bytes(i) data_bytes += binary_data length = self.int32_to_big_endian_bytes(len(data_bytes)) return data_bytes, length def run_next_test(self): """ Fetch next test information and execute the test. """ self.test_index += 1 self.dep_index = 0 if self.test_index < len(self.tests): name, function_id, dependencies, args = self.tests[self.test_index] self.run_test(name, function_id, dependencies, args) else: self.notify_complete(True) def run_test(self, name, function_id, dependencies, args): """ Execute the test on target by sending next test information. :param name: Test name :param function_id: function identifier :param dependencies: Dependencies list :param args: test parameters :return: """ self.log("Running: %s" % name) param_bytes, length = self.test_vector_to_bytes(function_id, dependencies, args) self.send_kv(length, param_bytes) @staticmethod def get_result(value): """ Converts result from string type to integer :param value: Result code in string :return: Integer result code. Value is from the test status constants defined under the MbedTlsTest class. """ try: return int(value) except ValueError: ValueError("Result should return error number. " "Instead received %s" % value) @event_callback('GO') def on_go(self, _key, _value, _timestamp): """ Sent by the target to start first test. :param _key: Event key :param _value: Value. ignored :param _timestamp: Timestamp ignored. :return: """ self.run_next_test() @event_callback("R") def on_result(self, _key, value, _timestamp): """ Handle result. Prints test start, finish required by Greentea to detect test execution. :param _key: Event key :param value: Value. ignored :param _timestamp: Timestamp ignored. :return: """ int_val = self.get_result(value) name, _, _, _ = self.tests[self.test_index] self.log('{{__testcase_start;%s}}' % name) self.log('{{__testcase_finish;%s;%d;%d}}' % (name, int_val == 0, int_val != 0)) self.run_next_test() @event_callback("F") def on_failure(self, _key, value, _timestamp): """ Handles test execution failure. That means dependency not supported or Test function not supported. Hence marking test as skipped. :param _key: Event key :param value: Value. ignored :param _timestamp: Timestamp ignored. :return: """ int_val = self.get_result(value) if int_val in self.error_str: err = self.error_str[int_val] else: err = 'Unknown error' # For skip status, do not write {{__testcase_finish;...}} self.log("Error: %s" % err) self.run_next_test()
bsd-3-clause
[ 3, 32585, 266, 65, 1591, 511, 2884, 367, 603, 6123, 12213, 641, 13, 1375, 511, 5241, 5343, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 14894, 12, 1952, 77, 23954, 12, 2900, 5924, 5702, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 3668, 13, 18, 14, 16, 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, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 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, 3, 961, 570, 365, 1777, 402, 603, 6123, 12213, 334, 2859, 921, 9945, 14, 3665, 14, 1308, 9, 421, 199, 624, 199, 45, 6123, 12213, 641, 13, 1375, 511, 5241, 2295, 787, 6366, 465, 32585, 266, 65, 199, 2219, 14, 32585, 266, 65, 2295, 787, 6366, 315, 2877, 4184, 26, 1347, 511, 436, 199, 1102, 511, 14, 10256, 511, 365, 282, 445, 4223, 626, 365, 6137, 367, 314, 199, 1375, 4298, 436, 24956, 641, 314, 1347, 14, 10891, 511, 365, 282, 2018, 199, 533, 7131, 687, 333, 6123, 63, 1102, 63, 2219, 14, 1563, 4965, 774, 14, 10256, 13882, 2335, 199, 1045, 314, 1591, 1806, 3012, 367, 314, 511, 666, 436, 16178, 1771, 314, 754, 14, 199, 199, 4718, 4744, 333, 6123, 3308, 334, 19456, 266, 65, 9, 365, 17845, 367, 14775, 316, 314, 511, 199, 3008, 641, 370, 314, 1347, 436, 18774, 8697, 642, 1591, 511, 859, 14, 199, 199, 19456, 266, 65, 3794, 883, 506, 1911, 2348, 26, 199, 2859, 921, 5031, 14, 957, 15, 12482, 3665, 15, 7731, 266, 65, 199, 624, 421, 199, 646, 295, 199, 646, 747, 199, 646, 14755, 199, 504, 333, 6123, 63, 1102, 63, 2219, 492, 3523, 4965, 774, 12, 1566, 63, 3058, 421, 199, 533, 1379, 1451, 21811, 8, 1726, 304, 272, 408, 607, 16292, 1125, 315, 511, 666, 12, 1586, 687, 1275, 576, 570, 1041, 272, 986, 421, 199, 533, 1379, 1451, 2842, 8, 785, 304, 272, 408, 272, 29968, 511, 536, 12, 5124, 12, 511, 805, 536, 436, 511, 2633, 272, 687, 314, 666, 570, 14, 272, 408, 339, 347, 636, 826, 721, 277, 304, 267, 408, 267, 20297, 267, 408, 267, 291, 14, 2219, 275, 942, 339, 347, 2198, 8, 277, 12, 666, 63, 493, 304, 267, 408, 267, 3918, 570, 1798, 14, 398, 520, 635, 666, 63, 493, 26, 3918, 570, 931, 267, 408, 267, 543, 1551, 8, 576, 63, 493, 12, 283, 82, 358, 465, 666, 63, 70, 26, 288, 291, 855, 1122, 8, 576, 63, 70, 9, 339, 768, 4639, 272, 347, 636, 13572, 63, 1294, 8, 11416, 63, 495, 12, 3715, 63, 1560, 304, 267, 408, 267, 11740, 83, 10702, 63, 495, 641, 3715, 63, 1560, 871, 1380, 11077, 14, 398, 520, 635, 10702, 63, 495, 26, 2624, 370, 3715, 267, 520, 635, 3715, 63, 1560, 26, 11740, 4528, 267, 520, 1107, 26, 3820, 402, 19115, 267, 408, 267, 340, 822, 8, 1294, 63, 1560, 9, 690, 413, 26, 288, 746, 1722, 360, 6964, 3715, 4528, 14, 2643, 1059, 10916, 267, 734, 275, 295, 14, 954, 8, 82, 6774, 1103, 4959, 5227, 435, 3715, 63, 1560, 12, 2151, 2400, 333, 26, 333, 14, 923, 8, 17, 9, 503, 1557, 78, 297, 10702, 63, 495, 12, 2151, 822, 8, 11416, 63, 495, 4992, 1294, 2258, 78, 358, 267, 734, 275, 359, 88, 367, 671, 315, 734, 340, 671, 61, 267, 372, 734, 339, 347, 636, 1122, 8, 277, 12, 666, 63, 70, 304, 267, 408, 267, 29968, 666, 570, 1808, 6841, 570, 909, 14, 398, 520, 635, 666, 63, 70, 26, 3918, 570, 909, 267, 520, 1107, 26, 267, 408, 267, 367, 1004, 315, 666, 63, 70, 26, 288, 1004, 275, 1004, 14, 1913, 342, 288, 340, 440, 1004, 26, 355, 1980, 288, 327, 5574, 511, 536, 288, 536, 275, 1004, 953, 327, 2670, 5124, 288, 5124, 275, 942, 288, 1004, 275, 666, 63, 70, 14, 2184, 1252, 1913, 342, 288, 1336, 275, 295, 14, 1733, 360, 8912, 63, 265, 26, 19276, 3196, 1004, 9, 288, 340, 1336, 26, 355, 5124, 275, 359, 442, 8, 88, 9, 367, 671, 315, 1336, 14, 923, 8, 17, 680, 1294, 6176, 5440, 355, 1004, 275, 666, 63, 70, 14, 2184, 1252, 1913, 342, 953, 327, 5574, 511, 11102, 288, 1004, 275, 1004, 14, 1814, 11671, 78, 297, 1557, 78, 358, 288, 4184, 275, 291, 855, 13572, 63, 1294, 8, 604, 12, 7596, 358, 288, 805, 63, 354, 275, 1109, 8, 4181, 59, 16, 566, 288, 1249, 275, 4184, 59, 17, 2938, 288, 1249, 63, 835, 275, 822, 8, 589, 9, 288, 340, 1249, 63, 835, 450, 499, 1137, 378, 26, 355, 746, 1379, 1451, 21811, 480, 3259, 402, 511, 2368, 1077, 298, 5101, 298, 1235, 2755, 26, 450, 83, 2, 450, 1004, 9, 288, 16251, 63, 589, 275, 3842, 589, 59, 73, 627, 499, 467, 1249, 7528, 73, 627, 499, 9, 435, 413, 566, 1169, 367, 284, 315, 1425, 8, 552, 8, 589, 2447, 18, 1874, 288, 291, 14, 2219, 14, 740, 1332, 354, 12, 805, 63, 354, 12, 5124, 12, 3044, 16251, 63, 589, 430, 339, 347, 664, 63, 396, 63, 576, 8, 277, 304, 267, 408, 267, 1803, 511, 666, 14, 267, 408, 267, 372, 291, 14, 2219, 421, 199, 533, 603, 6123, 52, 478, 774, 8, 1563, 4965, 774, 304, 272, 408, 272, 10891, 511, 367, 603, 6123, 12213, 4137, 2295, 14, 961, 2884, 365, 6511, 737, 272, 1255, 900, 701, 32585, 266, 65, 367, 14043, 603, 6123, 12213, 511, 24203, 14, 7048, 272, 23506, 687, 314, 1347, 365, 3086, 315, 642, 909, 465, 272, 376, 1566 ]
[ 32585, 266, 65, 1591, 511, 2884, 367, 603, 6123, 12213, 641, 13, 1375, 511, 5241, 5343, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 14894, 12, 1952, 77, 23954, 12, 2900, 5924, 5702, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 3668, 13, 18, 14, 16, 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, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 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, 3, 961, 570, 365, 1777, 402, 603, 6123, 12213, 334, 2859, 921, 9945, 14, 3665, 14, 1308, 9, 421, 199, 624, 199, 45, 6123, 12213, 641, 13, 1375, 511, 5241, 2295, 787, 6366, 465, 32585, 266, 65, 199, 2219, 14, 32585, 266, 65, 2295, 787, 6366, 315, 2877, 4184, 26, 1347, 511, 436, 199, 1102, 511, 14, 10256, 511, 365, 282, 445, 4223, 626, 365, 6137, 367, 314, 199, 1375, 4298, 436, 24956, 641, 314, 1347, 14, 10891, 511, 365, 282, 2018, 199, 533, 7131, 687, 333, 6123, 63, 1102, 63, 2219, 14, 1563, 4965, 774, 14, 10256, 13882, 2335, 199, 1045, 314, 1591, 1806, 3012, 367, 314, 511, 666, 436, 16178, 1771, 314, 754, 14, 199, 199, 4718, 4744, 333, 6123, 3308, 334, 19456, 266, 65, 9, 365, 17845, 367, 14775, 316, 314, 511, 199, 3008, 641, 370, 314, 1347, 436, 18774, 8697, 642, 1591, 511, 859, 14, 199, 199, 19456, 266, 65, 3794, 883, 506, 1911, 2348, 26, 199, 2859, 921, 5031, 14, 957, 15, 12482, 3665, 15, 7731, 266, 65, 199, 624, 421, 199, 646, 295, 199, 646, 747, 199, 646, 14755, 199, 504, 333, 6123, 63, 1102, 63, 2219, 492, 3523, 4965, 774, 12, 1566, 63, 3058, 421, 199, 533, 1379, 1451, 21811, 8, 1726, 304, 272, 408, 607, 16292, 1125, 315, 511, 666, 12, 1586, 687, 1275, 576, 570, 1041, 272, 986, 421, 199, 533, 1379, 1451, 2842, 8, 785, 304, 272, 408, 272, 29968, 511, 536, 12, 5124, 12, 511, 805, 536, 436, 511, 2633, 272, 687, 314, 666, 570, 14, 272, 408, 339, 347, 636, 826, 721, 277, 304, 267, 408, 267, 20297, 267, 408, 267, 291, 14, 2219, 275, 942, 339, 347, 2198, 8, 277, 12, 666, 63, 493, 304, 267, 408, 267, 3918, 570, 1798, 14, 398, 520, 635, 666, 63, 493, 26, 3918, 570, 931, 267, 408, 267, 543, 1551, 8, 576, 63, 493, 12, 283, 82, 358, 465, 666, 63, 70, 26, 288, 291, 855, 1122, 8, 576, 63, 70, 9, 339, 768, 4639, 272, 347, 636, 13572, 63, 1294, 8, 11416, 63, 495, 12, 3715, 63, 1560, 304, 267, 408, 267, 11740, 83, 10702, 63, 495, 641, 3715, 63, 1560, 871, 1380, 11077, 14, 398, 520, 635, 10702, 63, 495, 26, 2624, 370, 3715, 267, 520, 635, 3715, 63, 1560, 26, 11740, 4528, 267, 520, 1107, 26, 3820, 402, 19115, 267, 408, 267, 340, 822, 8, 1294, 63, 1560, 9, 690, 413, 26, 288, 746, 1722, 360, 6964, 3715, 4528, 14, 2643, 1059, 10916, 267, 734, 275, 295, 14, 954, 8, 82, 6774, 1103, 4959, 5227, 435, 3715, 63, 1560, 12, 2151, 2400, 333, 26, 333, 14, 923, 8, 17, 9, 503, 1557, 78, 297, 10702, 63, 495, 12, 2151, 822, 8, 11416, 63, 495, 4992, 1294, 2258, 78, 358, 267, 734, 275, 359, 88, 367, 671, 315, 734, 340, 671, 61, 267, 372, 734, 339, 347, 636, 1122, 8, 277, 12, 666, 63, 70, 304, 267, 408, 267, 29968, 666, 570, 1808, 6841, 570, 909, 14, 398, 520, 635, 666, 63, 70, 26, 3918, 570, 909, 267, 520, 1107, 26, 267, 408, 267, 367, 1004, 315, 666, 63, 70, 26, 288, 1004, 275, 1004, 14, 1913, 342, 288, 340, 440, 1004, 26, 355, 1980, 288, 327, 5574, 511, 536, 288, 536, 275, 1004, 953, 327, 2670, 5124, 288, 5124, 275, 942, 288, 1004, 275, 666, 63, 70, 14, 2184, 1252, 1913, 342, 288, 1336, 275, 295, 14, 1733, 360, 8912, 63, 265, 26, 19276, 3196, 1004, 9, 288, 340, 1336, 26, 355, 5124, 275, 359, 442, 8, 88, 9, 367, 671, 315, 1336, 14, 923, 8, 17, 680, 1294, 6176, 5440, 355, 1004, 275, 666, 63, 70, 14, 2184, 1252, 1913, 342, 953, 327, 5574, 511, 11102, 288, 1004, 275, 1004, 14, 1814, 11671, 78, 297, 1557, 78, 358, 288, 4184, 275, 291, 855, 13572, 63, 1294, 8, 604, 12, 7596, 358, 288, 805, 63, 354, 275, 1109, 8, 4181, 59, 16, 566, 288, 1249, 275, 4184, 59, 17, 2938, 288, 1249, 63, 835, 275, 822, 8, 589, 9, 288, 340, 1249, 63, 835, 450, 499, 1137, 378, 26, 355, 746, 1379, 1451, 21811, 480, 3259, 402, 511, 2368, 1077, 298, 5101, 298, 1235, 2755, 26, 450, 83, 2, 450, 1004, 9, 288, 16251, 63, 589, 275, 3842, 589, 59, 73, 627, 499, 467, 1249, 7528, 73, 627, 499, 9, 435, 413, 566, 1169, 367, 284, 315, 1425, 8, 552, 8, 589, 2447, 18, 1874, 288, 291, 14, 2219, 14, 740, 1332, 354, 12, 805, 63, 354, 12, 5124, 12, 3044, 16251, 63, 589, 430, 339, 347, 664, 63, 396, 63, 576, 8, 277, 304, 267, 408, 267, 1803, 511, 666, 14, 267, 408, 267, 372, 291, 14, 2219, 421, 199, 533, 603, 6123, 52, 478, 774, 8, 1563, 4965, 774, 304, 272, 408, 272, 10891, 511, 367, 603, 6123, 12213, 4137, 2295, 14, 961, 2884, 365, 6511, 737, 272, 1255, 900, 701, 32585, 266, 65, 367, 14043, 603, 6123, 12213, 511, 24203, 14, 7048, 272, 23506, 687, 314, 1347, 365, 3086, 315, 642, 909, 465, 272, 376, 1566, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
karibou/sosreport
sos/plugins/ds.py
8
2933
# Copyright (C) 2007 Red Hat, Inc., Kent Lamb <klamb@redhat.com> # Copyright (C) 2014 Red Hat, Inc., Bryn M. Reeves <bmr@redhat.com> # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. from sos.plugins import Plugin, RedHatPlugin import os class DirectoryServer(Plugin, RedHatPlugin): """Directory Server """ plugin_name = 'directoryserver' profiles = ('identity',) files = ('/etc/dirsrv', '/opt/redhat-ds') packages = ('redhat-ds-base', 'redhat-ds-7') def check_version(self): if self.is_installed("redhat-ds-base") or \ os.path.exists("/etc/dirsrv"): return "ds8" elif self.is_installed("redhat-ds-7") or \ os.path.exists("/opt/redhat-ds"): return "ds7" return False def setup(self): self.add_forbidden_path("/etc/dirsrv/slapd*/pin.txt") self.add_forbidden_path("/etc/dirsrv/slapd*/key3.db") self.add_forbidden_path("/etc/dirsrv/slapd*/pwfile.txt") self.add_forbidden_path("/etc/dirsrv/slapd*/*passw*") self.add_forbidden_path("/etc/dirsrv/admin-serv/key3.db") self.add_forbidden_path("/etc/dirsrv/admin-serv/admpw") self.add_forbidden_path("/etc/dirsrv/admin-serv/password.conf") try: for d in os.listdir("/etc/dirsrv"): if d[0:5] == 'slapd': certpath = os.path.join("/etc/dirsrv", d) self.add_cmd_output("certutil -L -d %s" % certpath) except: self._log_warn("could not list /etc/dirsrv") if not self.check_version(): self.add_alert("Directory Server not found.") elif "ds8" in self.check_version(): self.add_copy_spec([ "/etc/dirsrv/slapd*/cert8.db", "/etc/dirsrv/slapd*/certmap.conf", "/etc/dirsrv/slapd*/dse.ldif", "/etc/dirsrv/slapd*/dse.ldif.startOK", "/etc/dirsrv/slapd*/secmod.db", "/etc/dirsrv/slapd*/schema/*.ldif", "/var/log/dirsrv/*" ]) elif "ds7" in self.check_version(): self.add_copy_spec([ "/opt/redhat-ds/slapd-*/config", "/opt/redhat-ds/slapd-*/logs" ]) # vim: set et ts=4 sw=4 :
gpl-2.0
[ 3, 1898, 334, 35, 9, 10219, 9572, 13002, 12, 3277, 2020, 1804, 484, 491, 11020, 665, 75, 416, 887, 32, 17164, 14, 957, 30, 199, 3, 1898, 334, 35, 9, 6927, 9572, 13002, 12, 3277, 2020, 699, 651, 78, 603, 14, 799, 69, 2310, 665, 12648, 82, 32, 17164, 14, 957, 30, 199, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 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, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 1227, 2194, 603, 405, 437, 432, 12, 445, 455, 9528, 12, 4828, 12497, 7491, 12, 8217, 14, 199, 199, 504, 308, 736, 14, 5265, 492, 11349, 12, 9572, 40, 292, 5061, 199, 646, 747, 421, 199, 533, 15191, 3120, 8, 5061, 12, 9572, 40, 292, 5061, 304, 272, 408, 6231, 7146, 272, 408, 339, 3589, 63, 354, 275, 283, 3619, 1000, 7, 272, 17390, 275, 661, 5582, 9538, 339, 1584, 275, 14606, 6839, 15, 3220, 6310, 297, 1994, 2992, 15, 17164, 13, 795, 358, 272, 6117, 275, 661, 17164, 13, 795, 13, 1095, 297, 283, 17164, 13, 795, 13, 23, 358, 339, 347, 1104, 63, 1023, 8, 277, 304, 267, 340, 291, 14, 374, 63, 7657, 480, 17164, 13, 795, 13, 1095, 531, 503, 971, 355, 747, 14, 515, 14, 2444, 4769, 6839, 15, 3220, 6310, 2349, 288, 372, 298, 795, 24, 2, 267, 916, 291, 14, 374, 63, 7657, 480, 17164, 13, 795, 13, 23, 531, 503, 971, 355, 747, 14, 515, 14, 2444, 4769, 2992, 15, 17164, 13, 795, 2349, 288, 372, 298, 795, 23, 2, 267, 372, 756, 339, 347, 3272, 8, 277, 304, 267, 291, 14, 525, 63, 29293, 63, 515, 4769, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 15870, 7751, 14, 2424, 531, 267, 291, 14, 525, 63, 29293, 63, 515, 4769, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 15870, 498, 19, 14, 697, 531, 267, 291, 14, 525, 63, 29293, 63, 515, 4769, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 15870, 8796, 493, 14, 2424, 531, 267, 291, 14, 525, 63, 29293, 63, 515, 4769, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 10, 6331, 1529, 87, 10, 531, 267, 291, 14, 525, 63, 29293, 63, 515, 4769, 6839, 15, 3220, 6310, 15, 2113, 13, 7297, 15, 498, 19, 14, 697, 531, 267, 291, 14, 525, 63, 29293, 63, 515, 4769, 6839, 15, 3220, 6310, 15, 2113, 13, 7297, 15, 350, 311, 87, 531, 267, 291, 14, 525, 63, 29293, 63, 515, 4769, 6839, 15, 3220, 6310, 15, 2113, 13, 7297, 15, 2060, 14, 2190, 531, 267, 862, 26, 288, 367, 366, 315, 747, 14, 7374, 4769, 6839, 15, 3220, 6310, 2349, 355, 340, 366, 59, 16, 26, 21, 61, 508, 283, 83, 4762, 68, 356, 490, 6250, 515, 275, 747, 14, 515, 14, 904, 4769, 6839, 15, 3220, 6310, 401, 366, 9, 490, 291, 14, 525, 63, 1760, 63, 1199, 480, 4736, 1974, 446, 44, 446, 68, 450, 83, 2, 450, 6250, 515, 9, 267, 871, 26, 288, 291, 423, 793, 63, 4050, 480, 15153, 440, 769, 1182, 6839, 15, 3220, 6310, 531, 398, 340, 440, 291, 14, 1074, 63, 1023, 837, 288, 291, 14, 525, 63, 9241, 480, 6231, 7146, 440, 1911, 2685, 267, 916, 298, 795, 24, 2, 315, 291, 14, 1074, 63, 1023, 837, 288, 291, 14, 525, 63, 1574, 63, 1650, 779, 355, 3286, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 15870, 4736, 24, 14, 697, 401, 355, 3286, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 15870, 4736, 1130, 14, 2190, 401, 355, 3286, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 15870, 68, 261, 14, 76, 7330, 401, 355, 3286, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 15870, 68, 261, 14, 76, 7330, 14, 928, 3593, 401, 355, 3286, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 15870, 3321, 1494, 14, 697, 401, 355, 3286, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 15870, 3629, 20362, 76, 7330, 401, 355, 3286, 1391, 15, 793, 15, 3220, 6310, 6331, 2, 288, 4794, 267, 916, 298, 795, 23, 2, 315, 291, 14, 1074, 63, 1023, 837, 288, 291, 14, 525, 63, 1574, 63, 1650, 779, 355, 3286, 2992, 15, 17164, 13, 795, 15, 83, 4762, 68, 13, 15870, 888, 401, 355, 3286, 2992, 15, 17164, 13, 795, 15, 83, 4762, 68, 13, 15870, 7270, 2, 288, 4794, 199, 199, 3, 6695, 26, 663, 10844, 6714, 29, 20, 5584, 29, 20, 520, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 35, 9, 10219, 9572, 13002, 12, 3277, 2020, 1804, 484, 491, 11020, 665, 75, 416, 887, 32, 17164, 14, 957, 30, 199, 3, 1898, 334, 35, 9, 6927, 9572, 13002, 12, 3277, 2020, 699, 651, 78, 603, 14, 799, 69, 2310, 665, 12648, 82, 32, 17164, 14, 957, 30, 199, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 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, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 1227, 2194, 603, 405, 437, 432, 12, 445, 455, 9528, 12, 4828, 12497, 7491, 12, 8217, 14, 199, 199, 504, 308, 736, 14, 5265, 492, 11349, 12, 9572, 40, 292, 5061, 199, 646, 747, 421, 199, 533, 15191, 3120, 8, 5061, 12, 9572, 40, 292, 5061, 304, 272, 408, 6231, 7146, 272, 408, 339, 3589, 63, 354, 275, 283, 3619, 1000, 7, 272, 17390, 275, 661, 5582, 9538, 339, 1584, 275, 14606, 6839, 15, 3220, 6310, 297, 1994, 2992, 15, 17164, 13, 795, 358, 272, 6117, 275, 661, 17164, 13, 795, 13, 1095, 297, 283, 17164, 13, 795, 13, 23, 358, 339, 347, 1104, 63, 1023, 8, 277, 304, 267, 340, 291, 14, 374, 63, 7657, 480, 17164, 13, 795, 13, 1095, 531, 503, 971, 355, 747, 14, 515, 14, 2444, 4769, 6839, 15, 3220, 6310, 2349, 288, 372, 298, 795, 24, 2, 267, 916, 291, 14, 374, 63, 7657, 480, 17164, 13, 795, 13, 23, 531, 503, 971, 355, 747, 14, 515, 14, 2444, 4769, 2992, 15, 17164, 13, 795, 2349, 288, 372, 298, 795, 23, 2, 267, 372, 756, 339, 347, 3272, 8, 277, 304, 267, 291, 14, 525, 63, 29293, 63, 515, 4769, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 15870, 7751, 14, 2424, 531, 267, 291, 14, 525, 63, 29293, 63, 515, 4769, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 15870, 498, 19, 14, 697, 531, 267, 291, 14, 525, 63, 29293, 63, 515, 4769, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 15870, 8796, 493, 14, 2424, 531, 267, 291, 14, 525, 63, 29293, 63, 515, 4769, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 10, 6331, 1529, 87, 10, 531, 267, 291, 14, 525, 63, 29293, 63, 515, 4769, 6839, 15, 3220, 6310, 15, 2113, 13, 7297, 15, 498, 19, 14, 697, 531, 267, 291, 14, 525, 63, 29293, 63, 515, 4769, 6839, 15, 3220, 6310, 15, 2113, 13, 7297, 15, 350, 311, 87, 531, 267, 291, 14, 525, 63, 29293, 63, 515, 4769, 6839, 15, 3220, 6310, 15, 2113, 13, 7297, 15, 2060, 14, 2190, 531, 267, 862, 26, 288, 367, 366, 315, 747, 14, 7374, 4769, 6839, 15, 3220, 6310, 2349, 355, 340, 366, 59, 16, 26, 21, 61, 508, 283, 83, 4762, 68, 356, 490, 6250, 515, 275, 747, 14, 515, 14, 904, 4769, 6839, 15, 3220, 6310, 401, 366, 9, 490, 291, 14, 525, 63, 1760, 63, 1199, 480, 4736, 1974, 446, 44, 446, 68, 450, 83, 2, 450, 6250, 515, 9, 267, 871, 26, 288, 291, 423, 793, 63, 4050, 480, 15153, 440, 769, 1182, 6839, 15, 3220, 6310, 531, 398, 340, 440, 291, 14, 1074, 63, 1023, 837, 288, 291, 14, 525, 63, 9241, 480, 6231, 7146, 440, 1911, 2685, 267, 916, 298, 795, 24, 2, 315, 291, 14, 1074, 63, 1023, 837, 288, 291, 14, 525, 63, 1574, 63, 1650, 779, 355, 3286, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 15870, 4736, 24, 14, 697, 401, 355, 3286, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 15870, 4736, 1130, 14, 2190, 401, 355, 3286, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 15870, 68, 261, 14, 76, 7330, 401, 355, 3286, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 15870, 68, 261, 14, 76, 7330, 14, 928, 3593, 401, 355, 3286, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 15870, 3321, 1494, 14, 697, 401, 355, 3286, 6839, 15, 3220, 6310, 15, 83, 4762, 68, 15870, 3629, 20362, 76, 7330, 401, 355, 3286, 1391, 15, 793, 15, 3220, 6310, 6331, 2, 288, 4794, 267, 916, 298, 795, 23, 2, 315, 291, 14, 1074, 63, 1023, 837, 288, 291, 14, 525, 63, 1574, 63, 1650, 779, 355, 3286, 2992, 15, 17164, 13, 795, 15, 83, 4762, 68, 13, 15870, 888, 401, 355, 3286, 2992, 15, 17164, 13, 795, 15, 83, 4762, 68, 13, 15870, 7270, 2, 288, 4794, 199, 199, 3, 6695, 26, 663, 10844, 6714, 29, 20, 5584, 29, 20, 520, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
xiaoixa/python
neo1218/0023/web/migrations/env.py
185
2221
from __future__ import with_statement from alembic import context from sqlalchemy import engine_from_config, pool from logging.config import fileConfig # this is the Alembic Config object, which provides # access to the values within the .ini file in use. config = context.config # Interpret the config file for Python logging. # This line sets up loggers basically. fileConfig(config.config_file_name) # add your model's MetaData object here # for 'autogenerate' support # from myapp import mymodel # target_metadata = mymodel.Base.metadata from flask import current_app config.set_main_option('sqlalchemy.url', current_app.config.get('SQLALCHEMY_DATABASE_URI')) target_metadata = current_app.extensions['migrate'].db.metadata # other values from the config, defined by the needs of env.py, # can be acquired: # my_important_option = config.get_main_option("my_important_option") # ... etc. def run_migrations_offline(): """Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the given string to the script output. """ url = config.get_main_option("sqlalchemy.url") context.configure(url=url) with context.begin_transaction(): context.run_migrations() def run_migrations_online(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ engine = engine_from_config(config.get_section(config.config_ini_section), prefix='sqlalchemy.', poolclass=pool.NullPool) connection = engine.connect() context.configure(connection=connection, target_metadata=target_metadata, **current_app.extensions['migrate'].configure_args) try: with context.begin_transaction(): context.run_migrations() finally: connection.close() if context.is_offline_mode(): run_migrations_offline() else: run_migrations_online()
mit
[ 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 504, 30960, 20596, 492, 1067, 199, 504, 8335, 492, 6869, 63, 504, 63, 888, 12, 4203, 199, 504, 2050, 14, 888, 492, 570, 2028, 199, 199, 3, 642, 365, 314, 6832, 20596, 4094, 909, 12, 1314, 6571, 199, 3, 2879, 370, 314, 1338, 4453, 314, 1275, 2730, 570, 315, 675, 14, 199, 888, 275, 1067, 14, 888, 199, 199, 3, 6551, 25133, 314, 1101, 570, 367, 2018, 2050, 14, 199, 3, 961, 1004, 5951, 1536, 23445, 26014, 14, 199, 493, 2028, 8, 888, 14, 888, 63, 493, 63, 354, 9, 199, 199, 3, 1050, 2195, 1402, 1159, 24905, 909, 2348, 199, 3, 367, 283, 6898, 974, 22978, 7, 2291, 199, 3, 687, 3002, 571, 492, 3002, 1238, 199, 3, 1347, 63, 2343, 275, 3002, 1238, 14, 1563, 14, 2343, 199, 504, 7209, 492, 1453, 63, 571, 199, 888, 14, 409, 63, 973, 63, 1422, 360, 14536, 14, 633, 297, 1453, 63, 571, 14, 888, 14, 362, 360, 4657, 748, 1244, 2769, 57, 63, 17873, 63, 7639, 1333, 199, 1375, 63, 2343, 275, 1453, 63, 571, 14, 5359, 459, 8462, 2278, 697, 14, 2343, 199, 199, 3, 1163, 1338, 687, 314, 1101, 12, 3247, 701, 314, 4839, 402, 2589, 14, 647, 12, 199, 3, 883, 506, 28320, 26, 199, 3, 3002, 63, 19559, 63, 1422, 275, 1101, 14, 362, 63, 973, 63, 1422, 480, 1662, 63, 19559, 63, 1422, 531, 199, 3, 2263, 5423, 14, 421, 199, 318, 1255, 63, 7685, 63, 18430, 837, 272, 408, 2540, 6180, 315, 283, 18430, 7, 818, 14, 339, 961, 1101, 1482, 314, 1067, 543, 2951, 282, 2851, 272, 436, 440, 376, 12580, 12, 10617, 376, 12580, 365, 14712, 272, 2348, 465, 5521, 14, 221, 4885, 16068, 314, 12580, 7143, 272, 781, 2793, 1133, 2755, 1929, 282, 27980, 370, 506, 2808, 14, 339, 28055, 370, 1067, 14, 2526, 342, 2348, 8689, 314, 1627, 1059, 370, 314, 272, 2884, 1072, 14, 339, 408, 272, 1166, 275, 1101, 14, 362, 63, 973, 63, 1422, 480, 14536, 14, 633, 531, 272, 1067, 14, 6472, 8, 633, 29, 633, 9, 339, 543, 1067, 14, 5037, 63, 5945, 837, 267, 1067, 14, 1065, 63, 7685, 342, 421, 199, 318, 1255, 63, 7685, 63, 15178, 837, 272, 408, 2540, 6180, 315, 283, 15178, 7, 818, 14, 339, 1010, 642, 15728, 781, 1929, 370, 1218, 376, 12580, 272, 436, 20133, 282, 1950, 543, 314, 1067, 14, 339, 408, 272, 6869, 275, 6869, 63, 504, 63, 888, 8, 888, 14, 362, 63, 2792, 8, 888, 14, 888, 63, 2730, 63, 2792, 395, 1816, 2403, 534, 14536, 3130, 1816, 4203, 533, 29, 2293, 14, 8849, 5453, 9, 339, 1950, 275, 6869, 14, 2242, 342, 272, 1067, 14, 6472, 8, 2105, 29, 2105, 12, 1993, 1347, 63, 2343, 29, 1375, 63, 2343, 12, 1993, 1011, 1818, 63, 571, 14, 5359, 459, 8462, 2278, 6472, 63, 589, 9, 339, 862, 26, 267, 543, 1067, 14, 5037, 63, 5945, 837, 288, 1067, 14, 1065, 63, 7685, 342, 272, 3753, 26, 267, 1950, 14, 1600, 342, 199, 199, 692, 1067, 14, 374, 63, 18430, 63, 632, 837, 272, 1255, 63, 7685, 63, 18430, 342, 199, 2836, 26, 272, 1255, 63, 7685, 63, 15178, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 543, 63, 6242, 199, 504, 30960, 20596, 492, 1067, 199, 504, 8335, 492, 6869, 63, 504, 63, 888, 12, 4203, 199, 504, 2050, 14, 888, 492, 570, 2028, 199, 199, 3, 642, 365, 314, 6832, 20596, 4094, 909, 12, 1314, 6571, 199, 3, 2879, 370, 314, 1338, 4453, 314, 1275, 2730, 570, 315, 675, 14, 199, 888, 275, 1067, 14, 888, 199, 199, 3, 6551, 25133, 314, 1101, 570, 367, 2018, 2050, 14, 199, 3, 961, 1004, 5951, 1536, 23445, 26014, 14, 199, 493, 2028, 8, 888, 14, 888, 63, 493, 63, 354, 9, 199, 199, 3, 1050, 2195, 1402, 1159, 24905, 909, 2348, 199, 3, 367, 283, 6898, 974, 22978, 7, 2291, 199, 3, 687, 3002, 571, 492, 3002, 1238, 199, 3, 1347, 63, 2343, 275, 3002, 1238, 14, 1563, 14, 2343, 199, 504, 7209, 492, 1453, 63, 571, 199, 888, 14, 409, 63, 973, 63, 1422, 360, 14536, 14, 633, 297, 1453, 63, 571, 14, 888, 14, 362, 360, 4657, 748, 1244, 2769, 57, 63, 17873, 63, 7639, 1333, 199, 1375, 63, 2343, 275, 1453, 63, 571, 14, 5359, 459, 8462, 2278, 697, 14, 2343, 199, 199, 3, 1163, 1338, 687, 314, 1101, 12, 3247, 701, 314, 4839, 402, 2589, 14, 647, 12, 199, 3, 883, 506, 28320, 26, 199, 3, 3002, 63, 19559, 63, 1422, 275, 1101, 14, 362, 63, 973, 63, 1422, 480, 1662, 63, 19559, 63, 1422, 531, 199, 3, 2263, 5423, 14, 421, 199, 318, 1255, 63, 7685, 63, 18430, 837, 272, 408, 2540, 6180, 315, 283, 18430, 7, 818, 14, 339, 961, 1101, 1482, 314, 1067, 543, 2951, 282, 2851, 272, 436, 440, 376, 12580, 12, 10617, 376, 12580, 365, 14712, 272, 2348, 465, 5521, 14, 221, 4885, 16068, 314, 12580, 7143, 272, 781, 2793, 1133, 2755, 1929, 282, 27980, 370, 506, 2808, 14, 339, 28055, 370, 1067, 14, 2526, 342, 2348, 8689, 314, 1627, 1059, 370, 314, 272, 2884, 1072, 14, 339, 408, 272, 1166, 275, 1101, 14, 362, 63, 973, 63, 1422, 480, 14536, 14, 633, 531, 272, 1067, 14, 6472, 8, 633, 29, 633, 9, 339, 543, 1067, 14, 5037, 63, 5945, 837, 267, 1067, 14, 1065, 63, 7685, 342, 421, 199, 318, 1255, 63, 7685, 63, 15178, 837, 272, 408, 2540, 6180, 315, 283, 15178, 7, 818, 14, 339, 1010, 642, 15728, 781, 1929, 370, 1218, 376, 12580, 272, 436, 20133, 282, 1950, 543, 314, 1067, 14, 339, 408, 272, 6869, 275, 6869, 63, 504, 63, 888, 8, 888, 14, 362, 63, 2792, 8, 888, 14, 888, 63, 2730, 63, 2792, 395, 1816, 2403, 534, 14536, 3130, 1816, 4203, 533, 29, 2293, 14, 8849, 5453, 9, 339, 1950, 275, 6869, 14, 2242, 342, 272, 1067, 14, 6472, 8, 2105, 29, 2105, 12, 1993, 1347, 63, 2343, 29, 1375, 63, 2343, 12, 1993, 1011, 1818, 63, 571, 14, 5359, 459, 8462, 2278, 6472, 63, 589, 9, 339, 862, 26, 267, 543, 1067, 14, 5037, 63, 5945, 837, 288, 1067, 14, 1065, 63, 7685, 342, 272, 3753, 26, 267, 1950, 14, 1600, 342, 199, 199, 692, 1067, 14, 374, 63, 18430, 63, 632, 837, 272, 1255, 63, 7685, 63, 18430, 342, 199, 2836, 26, 272, 1255, 63, 7685, 63, 15178, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ideasiii/ControllerPlatform
Controller-WheelPies/extLibs/mongo-cxx-driver/src/mongo/base/generate_error_codes.py
6
8992
#!/usr/bin/python # Copyright 2012 10gen 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. # """Generate error_codes.{h,cpp} from error_codes.err. Format of error_codes.err: error_code("symbol1", code1) error_code("symbol2", code2) ... error_class("class1", ["symbol1", "symbol2, ..."]) Usage: python generate_error_codes.py <path to error_codes.err> <header file path> <source file path> """ import sys def main(argv): if len(argv) != 4: usage("Wrong number of arguments.") error_codes, error_classes = parse_error_definitions_from_file(argv[1]) check_for_conflicts(error_codes, error_classes) generate_header(argv[2], error_codes, error_classes) generate_source(argv[3], error_codes, error_classes) def die(message=None): sys.stderr.write(message or "Fatal error\n") sys.exit(1) def usage(message=None): sys.stderr.write(__doc__) die(message) def parse_error_definitions_from_file(errors_filename): errors_file = open(errors_filename, 'r') errors_code = compile(errors_file.read(), errors_filename, 'exec') error_codes = [] error_classes = [] eval(errors_code, dict(error_code=lambda *args: error_codes.append(args), error_class=lambda *args: error_classes.append(args))) error_codes.sort(key=lambda x: x[1]) return error_codes, error_classes def check_for_conflicts(error_codes, error_classes): failed = has_duplicate_error_codes(error_codes) if has_duplicate_error_classes(error_classes): failed = True if has_missing_error_codes(error_codes, error_classes): failed = True if failed: die() def has_duplicate_error_codes(error_codes): sorted_by_name = sorted(error_codes, key=lambda x: x[0]) sorted_by_code = sorted(error_codes, key=lambda x: x[1]) failed = False prev_name, prev_code = sorted_by_name[0] for name, code in sorted_by_name[1:]: if name == prev_name: sys.stdout.write('Duplicate name %s with codes %s and %s\n' % (name, code, prev_code)) failed = True prev_name, prev_code = name, code prev_name, prev_code = sorted_by_code[0] for name, code in sorted_by_code[1:]: if code == prev_code: sys.stdout.write('Duplicate code %s with names %s and %s\n' % (code, name, prev_name)) failed = True prev_name, prev_code = name, code return failed def has_duplicate_error_classes(error_classes): names = sorted(ec[0] for ec in error_classes) failed = False prev_name = names[0] for name in names[1:]: if prev_name == name: sys.stdout.write('Duplicate error class name %s\n' % name) failed = True prev_name = name return failed def has_missing_error_codes(error_codes, error_classes): code_names = set(ec[0] for ec in error_codes) failed = False for class_name, class_code_names in error_classes: for name in class_code_names: if name not in code_names: sys.stdout.write('Undeclared error code %s in class %s\n' % (name, class_name)) failed = True return failed def generate_header(filename, error_codes, error_classes): enum_declarations = ',\n '.join('%s = %s' % ec for ec in error_codes) predicate_declarations = ';\n '.join( 'static bool is%s(Error err)' % ec[0] for ec in error_classes) open(filename, 'wb').write(header_template % dict( error_code_enum_declarations=enum_declarations, error_code_class_predicate_declarations=predicate_declarations)) def generate_source(filename, error_codes, error_classes): symbol_to_string_cases = ';\n '.join( 'case %s: return "%s"' % (ec[0], ec[0]) for ec in error_codes) string_to_symbol_cases = ';\n '.join( 'if (name == "%s") return %s' % (ec[0], ec[0]) for ec in error_codes) int_to_symbol_cases = ';\n '.join( 'case %s: return %s' % (ec[0], ec[0]) for ec in error_codes) predicate_definitions = '\n '.join( generate_error_class_predicate_definition(*ec) for ec in error_classes) open(filename, 'wb').write(source_template % dict( symbol_to_string_cases=symbol_to_string_cases, string_to_symbol_cases=string_to_symbol_cases, int_to_symbol_cases=int_to_symbol_cases, error_code_class_predicate_definitions=predicate_definitions)) def generate_error_class_predicate_definition(class_name, code_names): cases = '\n '.join('case %s:' % c for c in code_names) return error_class_predicate_template % dict(class_name=class_name, cases=cases) header_template = '''// AUTO-GENERATED FILE DO NOT EDIT // See src/mongo/base/generate_error_codes.py /* Copyright 2012 10gen 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. */ #pragma once #include <string> #include "mongo/base/string_data.h" #include "mongo/client/export_macros.h" namespace mongo { /** * This is a generated class containing a table of error codes and their corresponding error * strings. The class is derived from the definitions in src/mongo/base/error_codes.err file. * * Do not update this file directly. Update src/mongo/base/error_codes.err instead. */ class MONGO_CLIENT_API ErrorCodes { public: enum Error { %(error_code_enum_declarations)s, MaxError }; static std::string MONGO_CLIENT_FUNC errorString(Error err); /** * Parses an Error from its "name". Returns UnknownError if "name" is unrecognized. * * NOTE: Also returns UnknownError for the string "UnknownError". */ static Error MONGO_CLIENT_FUNC fromString(const StringData& name); /** * Casts an integer "code" to an Error. Unrecognized codes are preserved, meaning * that the result of a call to fromInt() may not be one of the values in the * Error enumeration. */ static Error MONGO_CLIENT_FUNC fromInt(int code); %(error_code_class_predicate_declarations)s; }; } // namespace mongo ''' source_template = '''// AUTO-GENERATED FILE DO NOT EDIT // See src/mongo/base/generate_error_codes.py /* Copyright 2012 10gen 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. */ #include "mongo/base/error_codes.h" #include <boost/static_assert.hpp> #include "mongo/util/mongoutils/str.h" namespace mongo { std::string ErrorCodes::errorString(Error err) { switch (err) { %(symbol_to_string_cases)s; default: return mongoutils::str::stream() << "Location" << err; } } ErrorCodes::Error ErrorCodes::fromString(const StringData& name) { %(string_to_symbol_cases)s; return UnknownError; } ErrorCodes::Error ErrorCodes::fromInt(int code) { return static_cast<Error>(code); } %(error_code_class_predicate_definitions)s namespace { BOOST_STATIC_ASSERT(sizeof(ErrorCodes::Error) == sizeof(int)); } // namespace } // namespace mongo ''' error_class_predicate_template = '''bool ErrorCodes::is%(class_name)s(Error err) { switch (err) { %(cases)s return true; default: return false; } } ''' if __name__ == '__main__': main(sys.argv)
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 3, 259, 1898, 6029, 1616, 2268, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 259, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 259, 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, 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, 199, 3, 259, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 259, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 259, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 624, 6864, 1125, 63, 6021, 23379, 72, 12, 5910, 93, 687, 1125, 63, 6021, 14, 1508, 14, 199, 199, 3484, 402, 1125, 63, 6021, 14, 1508, 26, 199, 199, 705, 63, 600, 480, 5155, 17, 401, 1233, 17, 9, 199, 705, 63, 600, 480, 5155, 18, 401, 1233, 18, 9, 199, 1396, 199, 705, 63, 533, 480, 533, 17, 401, 2097, 5155, 17, 401, 298, 5155, 18, 12, 2263, 3135, 199, 199, 7692, 26, 272, 2366, 3550, 63, 705, 63, 6021, 14, 647, 665, 515, 370, 1125, 63, 6021, 14, 1508, 30, 665, 1291, 570, 931, 30, 665, 1365, 570, 931, 30, 199, 624, 199, 199, 646, 984, 199, 199, 318, 2446, 8, 3020, 304, 272, 340, 822, 8, 3020, 9, 1137, 841, 26, 267, 4503, 480, 14858, 1329, 402, 2368, 2685, 339, 1125, 63, 6021, 12, 1125, 63, 2888, 275, 2198, 63, 705, 63, 15388, 63, 504, 63, 493, 8, 3020, 59, 17, 566, 272, 1104, 63, 509, 63, 22654, 8, 705, 63, 6021, 12, 1125, 63, 2888, 9, 272, 3550, 63, 1291, 8, 3020, 59, 18, 467, 1125, 63, 6021, 12, 1125, 63, 2888, 9, 272, 3550, 63, 1365, 8, 3020, 59, 19, 467, 1125, 63, 6021, 12, 1125, 63, 2888, 9, 199, 199, 318, 18833, 8, 1188, 29, 403, 304, 272, 984, 14, 3083, 14, 952, 8, 1188, 503, 298, 19507, 1125, 60, 78, 531, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 318, 4503, 8, 1188, 29, 403, 304, 272, 984, 14, 3083, 14, 952, 3460, 1301, 3368, 272, 18833, 8, 1188, 9, 199, 199, 318, 2198, 63, 705, 63, 15388, 63, 504, 63, 493, 8, 2550, 63, 1501, 304, 272, 2552, 63, 493, 275, 1551, 8, 2550, 63, 1501, 12, 283, 82, 358, 272, 2552, 63, 600, 275, 6555, 8, 2550, 63, 493, 14, 739, 1062, 2552, 63, 1501, 12, 283, 1628, 358, 272, 1125, 63, 6021, 275, 942, 272, 1125, 63, 2888, 275, 942, 272, 3468, 8, 2550, 63, 600, 12, 1211, 8, 705, 63, 600, 29, 2734, 627, 589, 26, 1125, 63, 6021, 14, 740, 8, 589, 395, 2574, 1125, 63, 533, 29, 2734, 627, 589, 26, 1125, 63, 2888, 14, 740, 8, 589, 1724, 272, 1125, 63, 6021, 14, 3191, 8, 498, 29, 2734, 671, 26, 671, 59, 17, 566, 272, 372, 1125, 63, 6021, 12, 1125, 63, 2888, 199, 199, 318, 1104, 63, 509, 63, 22654, 8, 705, 63, 6021, 12, 1125, 63, 2888, 304, 272, 3405, 275, 965, 63, 11081, 63, 705, 63, 6021, 8, 705, 63, 6021, 9, 272, 340, 965, 63, 11081, 63, 705, 63, 2888, 8, 705, 63, 2888, 304, 267, 3405, 275, 715, 272, 340, 965, 63, 4752, 63, 705, 63, 6021, 8, 705, 63, 6021, 12, 1125, 63, 2888, 304, 267, 3405, 275, 715, 272, 340, 3405, 26, 267, 18833, 342, 199, 199, 318, 965, 63, 11081, 63, 705, 63, 6021, 8, 705, 63, 6021, 304, 272, 3355, 63, 991, 63, 354, 275, 3355, 8, 705, 63, 6021, 12, 790, 29, 2734, 671, 26, 671, 59, 16, 566, 272, 3355, 63, 991, 63, 600, 275, 3355, 8, 705, 63, 6021, 12, 790, 29, 2734, 671, 26, 671, 59, 17, 566, 339, 3405, 275, 756, 272, 5071, 63, 354, 12, 5071, 63, 600, 275, 3355, 63, 991, 63, 354, 59, 16, 61, 272, 367, 536, 12, 1233, 315, 3355, 63, 991, 63, 354, 59, 17, 10688, 267, 340, 536, 508, 5071, 63, 354, 26, 288, 984, 14, 2703, 14, 952, 360, 14773, 536, 450, 83, 543, 9479, 450, 83, 436, 450, 83, 60, 78, 7, 450, 334, 354, 12, 1233, 12, 5071, 63, 600, 430, 288, 3405, 275, 715, 267, 5071, 63, 354, 12, 5071, 63, 600, 275, 536, 12, 1233, 339, 5071, 63, 354, 12, 5071, 63, 600, 275, 3355, 63, 991, 63, 600, 59, 16, 61, 272, 367, 536, 12, 1233, 315, 3355, 63, 991, 63, 600, 59, 17, 10688, 267, 340, 1233, 508, 5071, 63, 600, 26, 288, 984, 14, 2703, 14, 952, 360, 14773, 1233, 450, 83, 543, 1561, 450, 83, 436, 450, 83, 60, 78, 7, 450, 334, 600, 12, 536, 12, 5071, 63, 354, 430, 288, 3405, 275, 715, 267, 5071, 63, 354, 12, 5071, 63, 600, 275, 536, 12, 1233, 339, 372, 3405, 199, 199, 318, 965, 63, 11081, 63, 705, 63, 2888, 8, 705, 63, 2888, 304, 272, 1561, 275, 3355, 8, 825, 59, 16, 61, 367, 7062, 315, 1125, 63, 2888, 9, 339, 3405, 275, 756, 272, 5071, 63, 354, 275, 1561, 59, 16, 61, 272, 367, 536, 315, 1561, 59, 17, 10688, 267, 340, 5071, 63, 354, 508, 536, 26, 288, 984, 14, 2703, 14, 952, 360, 14773, 1125, 1021, 536, 450, 83, 60, 78, 7, 450, 536, 9, 288, 3405, 275, 715, 267, 5071, 63, 354, 275, 536, 272, 372, 3405, 199, 199, 318, 965, 63, 4752, 63, 705, 63, 6021, 8, 705, 63, 6021, 12, 1125, 63, 2888, 304, 272, 1233, 63, 1247, 275, 663, 8, 825, 59, 16, 61, 367, 7062, 315, 1125, 63, 6021, 9, 272, 3405, 275, 756, 272, 367, 1021, 63, 354, 12, 1021, 63, 600, 63, 1247, 315, 1125, 63, 2888, 26, 267, 367, 536, 315, 1021, 63, 600, 63, 1247, 26, 288 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 3, 259, 1898, 6029, 1616, 2268, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 259, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 259, 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, 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, 199, 3, 259, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 259, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 259, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 624, 6864, 1125, 63, 6021, 23379, 72, 12, 5910, 93, 687, 1125, 63, 6021, 14, 1508, 14, 199, 199, 3484, 402, 1125, 63, 6021, 14, 1508, 26, 199, 199, 705, 63, 600, 480, 5155, 17, 401, 1233, 17, 9, 199, 705, 63, 600, 480, 5155, 18, 401, 1233, 18, 9, 199, 1396, 199, 705, 63, 533, 480, 533, 17, 401, 2097, 5155, 17, 401, 298, 5155, 18, 12, 2263, 3135, 199, 199, 7692, 26, 272, 2366, 3550, 63, 705, 63, 6021, 14, 647, 665, 515, 370, 1125, 63, 6021, 14, 1508, 30, 665, 1291, 570, 931, 30, 665, 1365, 570, 931, 30, 199, 624, 199, 199, 646, 984, 199, 199, 318, 2446, 8, 3020, 304, 272, 340, 822, 8, 3020, 9, 1137, 841, 26, 267, 4503, 480, 14858, 1329, 402, 2368, 2685, 339, 1125, 63, 6021, 12, 1125, 63, 2888, 275, 2198, 63, 705, 63, 15388, 63, 504, 63, 493, 8, 3020, 59, 17, 566, 272, 1104, 63, 509, 63, 22654, 8, 705, 63, 6021, 12, 1125, 63, 2888, 9, 272, 3550, 63, 1291, 8, 3020, 59, 18, 467, 1125, 63, 6021, 12, 1125, 63, 2888, 9, 272, 3550, 63, 1365, 8, 3020, 59, 19, 467, 1125, 63, 6021, 12, 1125, 63, 2888, 9, 199, 199, 318, 18833, 8, 1188, 29, 403, 304, 272, 984, 14, 3083, 14, 952, 8, 1188, 503, 298, 19507, 1125, 60, 78, 531, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 318, 4503, 8, 1188, 29, 403, 304, 272, 984, 14, 3083, 14, 952, 3460, 1301, 3368, 272, 18833, 8, 1188, 9, 199, 199, 318, 2198, 63, 705, 63, 15388, 63, 504, 63, 493, 8, 2550, 63, 1501, 304, 272, 2552, 63, 493, 275, 1551, 8, 2550, 63, 1501, 12, 283, 82, 358, 272, 2552, 63, 600, 275, 6555, 8, 2550, 63, 493, 14, 739, 1062, 2552, 63, 1501, 12, 283, 1628, 358, 272, 1125, 63, 6021, 275, 942, 272, 1125, 63, 2888, 275, 942, 272, 3468, 8, 2550, 63, 600, 12, 1211, 8, 705, 63, 600, 29, 2734, 627, 589, 26, 1125, 63, 6021, 14, 740, 8, 589, 395, 2574, 1125, 63, 533, 29, 2734, 627, 589, 26, 1125, 63, 2888, 14, 740, 8, 589, 1724, 272, 1125, 63, 6021, 14, 3191, 8, 498, 29, 2734, 671, 26, 671, 59, 17, 566, 272, 372, 1125, 63, 6021, 12, 1125, 63, 2888, 199, 199, 318, 1104, 63, 509, 63, 22654, 8, 705, 63, 6021, 12, 1125, 63, 2888, 304, 272, 3405, 275, 965, 63, 11081, 63, 705, 63, 6021, 8, 705, 63, 6021, 9, 272, 340, 965, 63, 11081, 63, 705, 63, 2888, 8, 705, 63, 2888, 304, 267, 3405, 275, 715, 272, 340, 965, 63, 4752, 63, 705, 63, 6021, 8, 705, 63, 6021, 12, 1125, 63, 2888, 304, 267, 3405, 275, 715, 272, 340, 3405, 26, 267, 18833, 342, 199, 199, 318, 965, 63, 11081, 63, 705, 63, 6021, 8, 705, 63, 6021, 304, 272, 3355, 63, 991, 63, 354, 275, 3355, 8, 705, 63, 6021, 12, 790, 29, 2734, 671, 26, 671, 59, 16, 566, 272, 3355, 63, 991, 63, 600, 275, 3355, 8, 705, 63, 6021, 12, 790, 29, 2734, 671, 26, 671, 59, 17, 566, 339, 3405, 275, 756, 272, 5071, 63, 354, 12, 5071, 63, 600, 275, 3355, 63, 991, 63, 354, 59, 16, 61, 272, 367, 536, 12, 1233, 315, 3355, 63, 991, 63, 354, 59, 17, 10688, 267, 340, 536, 508, 5071, 63, 354, 26, 288, 984, 14, 2703, 14, 952, 360, 14773, 536, 450, 83, 543, 9479, 450, 83, 436, 450, 83, 60, 78, 7, 450, 334, 354, 12, 1233, 12, 5071, 63, 600, 430, 288, 3405, 275, 715, 267, 5071, 63, 354, 12, 5071, 63, 600, 275, 536, 12, 1233, 339, 5071, 63, 354, 12, 5071, 63, 600, 275, 3355, 63, 991, 63, 600, 59, 16, 61, 272, 367, 536, 12, 1233, 315, 3355, 63, 991, 63, 600, 59, 17, 10688, 267, 340, 1233, 508, 5071, 63, 600, 26, 288, 984, 14, 2703, 14, 952, 360, 14773, 1233, 450, 83, 543, 1561, 450, 83, 436, 450, 83, 60, 78, 7, 450, 334, 600, 12, 536, 12, 5071, 63, 354, 430, 288, 3405, 275, 715, 267, 5071, 63, 354, 12, 5071, 63, 600, 275, 536, 12, 1233, 339, 372, 3405, 199, 199, 318, 965, 63, 11081, 63, 705, 63, 2888, 8, 705, 63, 2888, 304, 272, 1561, 275, 3355, 8, 825, 59, 16, 61, 367, 7062, 315, 1125, 63, 2888, 9, 339, 3405, 275, 756, 272, 5071, 63, 354, 275, 1561, 59, 16, 61, 272, 367, 536, 315, 1561, 59, 17, 10688, 267, 340, 5071, 63, 354, 508, 536, 26, 288, 984, 14, 2703, 14, 952, 360, 14773, 1125, 1021, 536, 450, 83, 60, 78, 7, 450, 536, 9, 288, 3405, 275, 715, 267, 5071, 63, 354, 275, 536, 272, 372, 3405, 199, 199, 318, 965, 63, 4752, 63, 705, 63, 6021, 8, 705, 63, 6021, 12, 1125, 63, 2888, 304, 272, 1233, 63, 1247, 275, 663, 8, 825, 59, 16, 61, 367, 7062, 315, 1125, 63, 6021, 9, 272, 3405, 275, 756, 272, 367, 1021, 63, 354, 12, 1021, 63, 600, 63, 1247, 315, 1125, 63, 2888, 26, 267, 367, 536, 315, 1021, 63, 600, 63, 1247, 26, 288, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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