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
gg7/diamond
src/collectors/dseopscenter/test/testdseopscenter.py
31
1852
#!/usr/bin/python # coding=utf-8 ########################################################################## from test import CollectorTestCase from test import get_collector_config from mock import Mock from mock import patch from diamond.collector import Collector from dseopscenter import DseOpsCenterCollector ########################################################################## class TestDseOpsCenterCollector(CollectorTestCase): def setUp(self): config = get_collector_config('DseOpsCenterCollector', {'cluster_id': 'MyTestCluster'}) self.collector = DseOpsCenterCollector(config, None) def test_import(self): self.assertTrue(DseOpsCenterCollector) @patch.object(Collector, 'publish') def test_should_work_with_real_data(self, publish_mock): urlopen_mock1 = patch('urllib2.urlopen', Mock( side_effect=lambda *args: self.getFixture('keyspaces.json'))) urlopen_mock1.start() self.collector._get_schema() urlopen_mock1.stop() urlopen_mock2 = patch('urllib2.urlopen', Mock( side_effect=lambda *args: self.getFixture('new-metrics.json'))) urlopen_mock2.start() self.collector.collect() urlopen_mock2.stop() metrics = { 'cf-bf-false-positives.dse_system.leases': 0, 'key-cache-requests': 38.28847822050253, 'key-cache-hits': 9.114316945274672, 'nonheap-max': 136314880, 'nonheap-used': 48491696.666666664, 'read-ops': 55.91526222229004, } self.setDocExample(collector=self.collector.__class__.__name__, metrics=metrics, defaultpath=self.collector.config['path']) self.assertPublishedMany(publish_mock, metrics)
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 2803, 29, 1624, 13, 24, 199, 26863, 199, 199, 504, 511, 492, 3626, 3283, 1746, 199, 504, 511, 492, 664, 63, 10946, 63, 888, 199, 504, 1683, 492, 4420, 199, 504, 1683, 492, 3371, 199, 199, 504, 487, 24940, 14, 10946, 492, 3626, 3283, 199, 199, 504, 366, 261, 411, 551, 4200, 492, 577, 261, 16452, 13551, 12852, 199, 199, 26863, 421, 199, 533, 1379, 36, 261, 16452, 13551, 12852, 8, 12852, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1101, 275, 664, 63, 10946, 63, 888, 360, 36, 261, 16452, 13551, 12852, 297, 4228, 791, 4201, 63, 344, 356, 283, 5713, 774, 9581, 3071, 398, 291, 14, 10946, 275, 577, 261, 16452, 13551, 12852, 8, 888, 12, 488, 9, 339, 347, 511, 63, 646, 8, 277, 304, 267, 291, 14, 1815, 8, 36, 261, 16452, 13551, 12852, 9, 339, 768, 2068, 14, 785, 8, 12852, 12, 283, 4763, 358, 272, 347, 511, 63, 5626, 63, 800, 63, 1045, 63, 3093, 63, 576, 8, 277, 12, 2780, 63, 1805, 304, 267, 18279, 63, 1805, 17, 275, 3371, 360, 4078, 18, 14, 10890, 297, 4420, 8, 288, 5366, 63, 5881, 29, 2734, 627, 589, 26, 291, 14, 362, 12812, 360, 1612, 4285, 14, 1001, 7058, 267, 18279, 63, 1805, 17, 14, 928, 342, 267, 291, 14, 10946, 423, 362, 63, 3629, 342, 267, 18279, 63, 1805, 17, 14, 2379, 342, 267, 18279, 63, 1805, 18, 275, 3371, 360, 4078, 18, 14, 10890, 297, 4420, 8, 288, 5366, 63, 5881, 29, 2734, 627, 589, 26, 291, 14, 362, 12812, 360, 1222, 13, 6759, 14, 1001, 7058, 267, 18279, 63, 1805, 18, 14, 928, 342, 267, 291, 14, 10946, 14, 7112, 342, 267, 18279, 63, 1805, 18, 14, 2379, 342, 398, 7186, 275, 469, 288, 283, 2177, 13, 4361, 13, 3910, 13, 32181, 14, 68, 261, 63, 2253, 14, 1756, 83, 356, 378, 12, 288, 283, 498, 13, 1637, 13, 6615, 356, 10448, 14, 10740, 31622, 11174, 1400, 3781, 12, 288, 283, 498, 13, 1637, 13, 16595, 356, 1749, 14, 845, 2824, 10143, 2322, 9014, 20298, 12, 288, 283, 2865, 12492, 13, 988, 356, 27208, 8988, 30321, 12, 288, 283, 2865, 12492, 13, 2972, 356, 841, 14866, 975, 2534, 14, 6997, 11829, 772, 12, 288, 283, 739, 13, 1483, 356, 12766, 14, 32532, 1479, 9993, 1398, 7979, 12, 267, 789, 398, 291, 14, 409, 3768, 9846, 8, 10946, 29, 277, 14, 10946, 855, 533, 4914, 354, 3108, 2574, 7186, 29, 6759, 12, 2574, 849, 515, 29, 277, 14, 10946, 14, 888, 459, 515, 1105, 267, 291, 14, 479, 27862, 4089, 8, 4763, 63, 1805, 12, 7186, 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 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 2803, 29, 1624, 13, 24, 199, 26863, 199, 199, 504, 511, 492, 3626, 3283, 1746, 199, 504, 511, 492, 664, 63, 10946, 63, 888, 199, 504, 1683, 492, 4420, 199, 504, 1683, 492, 3371, 199, 199, 504, 487, 24940, 14, 10946, 492, 3626, 3283, 199, 199, 504, 366, 261, 411, 551, 4200, 492, 577, 261, 16452, 13551, 12852, 199, 199, 26863, 421, 199, 533, 1379, 36, 261, 16452, 13551, 12852, 8, 12852, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1101, 275, 664, 63, 10946, 63, 888, 360, 36, 261, 16452, 13551, 12852, 297, 4228, 791, 4201, 63, 344, 356, 283, 5713, 774, 9581, 3071, 398, 291, 14, 10946, 275, 577, 261, 16452, 13551, 12852, 8, 888, 12, 488, 9, 339, 347, 511, 63, 646, 8, 277, 304, 267, 291, 14, 1815, 8, 36, 261, 16452, 13551, 12852, 9, 339, 768, 2068, 14, 785, 8, 12852, 12, 283, 4763, 358, 272, 347, 511, 63, 5626, 63, 800, 63, 1045, 63, 3093, 63, 576, 8, 277, 12, 2780, 63, 1805, 304, 267, 18279, 63, 1805, 17, 275, 3371, 360, 4078, 18, 14, 10890, 297, 4420, 8, 288, 5366, 63, 5881, 29, 2734, 627, 589, 26, 291, 14, 362, 12812, 360, 1612, 4285, 14, 1001, 7058, 267, 18279, 63, 1805, 17, 14, 928, 342, 267, 291, 14, 10946, 423, 362, 63, 3629, 342, 267, 18279, 63, 1805, 17, 14, 2379, 342, 267, 18279, 63, 1805, 18, 275, 3371, 360, 4078, 18, 14, 10890, 297, 4420, 8, 288, 5366, 63, 5881, 29, 2734, 627, 589, 26, 291, 14, 362, 12812, 360, 1222, 13, 6759, 14, 1001, 7058, 267, 18279, 63, 1805, 18, 14, 928, 342, 267, 291, 14, 10946, 14, 7112, 342, 267, 18279, 63, 1805, 18, 14, 2379, 342, 398, 7186, 275, 469, 288, 283, 2177, 13, 4361, 13, 3910, 13, 32181, 14, 68, 261, 63, 2253, 14, 1756, 83, 356, 378, 12, 288, 283, 498, 13, 1637, 13, 6615, 356, 10448, 14, 10740, 31622, 11174, 1400, 3781, 12, 288, 283, 498, 13, 1637, 13, 16595, 356, 1749, 14, 845, 2824, 10143, 2322, 9014, 20298, 12, 288, 283, 2865, 12492, 13, 988, 356, 27208, 8988, 30321, 12, 288, 283, 2865, 12492, 13, 2972, 356, 841, 14866, 975, 2534, 14, 6997, 11829, 772, 12, 288, 283, 739, 13, 1483, 356, 12766, 14, 32532, 1479, 9993, 1398, 7979, 12, 267, 789, 398, 291, 14, 409, 3768, 9846, 8, 10946, 29, 277, 14, 10946, 855, 533, 4914, 354, 3108, 2574, 7186, 29, 6759, 12, 2574, 849, 515, 29, 277, 14, 10946, 14, 888, 459, 515, 1105, 267, 291, 14, 479, 27862, 4089, 8, 4763, 63, 1805, 12, 7186, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Bourneer/scrapy
tests/test_closespider.py
140
2413
from twisted.internet import defer from twisted.trial.unittest import TestCase from scrapy.utils.test import get_crawler from tests.spiders import FollowAllSpider, ItemSpider, ErrorSpider from tests.mockserver import MockServer class TestCloseSpider(TestCase): def setUp(self): self.mockserver = MockServer() self.mockserver.__enter__() def tearDown(self): self.mockserver.__exit__(None, None, None) @defer.inlineCallbacks def test_closespider_itemcount(self): close_on = 5 crawler = get_crawler(ItemSpider, {'CLOSESPIDER_ITEMCOUNT': close_on}) yield crawler.crawl() reason = crawler.spider.meta['close_reason'] self.assertEqual(reason, 'closespider_itemcount') itemcount = crawler.stats.get_value('item_scraped_count') self.assertTrue(itemcount >= close_on) @defer.inlineCallbacks def test_closespider_pagecount(self): close_on = 5 crawler = get_crawler(FollowAllSpider, {'CLOSESPIDER_PAGECOUNT': close_on}) yield crawler.crawl() reason = crawler.spider.meta['close_reason'] self.assertEqual(reason, 'closespider_pagecount') pagecount = crawler.stats.get_value('response_received_count') self.assertTrue(pagecount >= close_on) @defer.inlineCallbacks def test_closespider_errorcount(self): close_on = 5 crawler = get_crawler(ErrorSpider, {'CLOSESPIDER_ERRORCOUNT': close_on}) yield crawler.crawl(total=1000000) reason = crawler.spider.meta['close_reason'] self.assertEqual(reason, 'closespider_errorcount') key = 'spider_exceptions/{name}'\ .format(name=crawler.spider.exception_cls.__name__) errorcount = crawler.stats.get_value(key) self.assertTrue(errorcount >= close_on) @defer.inlineCallbacks def test_closespider_timeout(self): close_on = 0.1 crawler = get_crawler(FollowAllSpider, {'CLOSESPIDER_TIMEOUT': close_on}) yield crawler.crawl(total=1000000) reason = crawler.spider.meta['close_reason'] self.assertEqual(reason, 'closespider_timeout') stats = crawler.stats start = stats.get_value('start_time') stop = stats.get_value('finish_time') diff = stop - start total_seconds = diff.seconds + diff.microseconds self.assertTrue(total_seconds >= close_on)
bsd-3-clause
[ 504, 7390, 14, 4901, 492, 10133, 199, 504, 7390, 14, 14443, 14, 2796, 492, 7640, 199, 504, 18918, 14, 1208, 14, 396, 492, 664, 63, 23972, 199, 504, 2295, 14, 8721, 7735, 492, 21876, 2422, 25157, 12, 7020, 25157, 12, 4520, 25157, 199, 504, 2295, 14, 1805, 1000, 492, 4420, 3120, 421, 199, 533, 1379, 4724, 25157, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 1805, 1000, 275, 4420, 3120, 342, 267, 291, 14, 1805, 1000, 855, 4200, 4533, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 1805, 1000, 855, 2224, 721, 403, 12, 488, 12, 488, 9, 339, 768, 11610, 14, 24813, 272, 347, 511, 63, 1600, 12856, 63, 1053, 835, 8, 277, 304, 267, 4002, 63, 265, 275, 959, 267, 29550, 275, 664, 63, 23972, 8, 2081, 25157, 12, 791, 10353, 51, 7613, 998, 540, 63, 10439, 8760, 356, 4002, 63, 265, 1552, 267, 1995, 29550, 14, 67, 22910, 342, 267, 4499, 275, 29550, 14, 12856, 14, 2024, 459, 1600, 63, 5764, 418, 267, 291, 14, 629, 8, 5764, 12, 283, 1600, 12856, 63, 1053, 835, 358, 267, 1242, 835, 275, 29550, 14, 3200, 14, 362, 63, 585, 360, 1053, 63, 26478, 63, 835, 358, 267, 291, 14, 1815, 8, 1053, 835, 2356, 4002, 63, 265, 9, 339, 768, 11610, 14, 24813, 272, 347, 511, 63, 1600, 12856, 63, 1606, 835, 8, 277, 304, 267, 4002, 63, 265, 275, 959, 267, 29550, 275, 664, 63, 23972, 8, 18696, 2422, 25157, 12, 791, 10353, 51, 7613, 998, 540, 63, 12898, 8760, 356, 4002, 63, 265, 1552, 267, 1995, 29550, 14, 67, 22910, 342, 267, 4499, 275, 29550, 14, 12856, 14, 2024, 459, 1600, 63, 5764, 418, 267, 291, 14, 629, 8, 5764, 12, 283, 1600, 12856, 63, 1606, 835, 358, 267, 2034, 835, 275, 29550, 14, 3200, 14, 362, 63, 585, 360, 1310, 63, 9226, 63, 835, 358, 267, 291, 14, 1815, 8, 1606, 835, 2356, 4002, 63, 265, 9, 339, 768, 11610, 14, 24813, 272, 347, 511, 63, 1600, 12856, 63, 705, 835, 8, 277, 304, 267, 4002, 63, 265, 275, 959, 267, 29550, 275, 664, 63, 23972, 8, 547, 25157, 12, 791, 10353, 51, 7613, 998, 540, 63, 3170, 8760, 356, 4002, 63, 265, 1552, 267, 1995, 29550, 14, 67, 22910, 8, 2923, 29, 22589, 9, 267, 4499, 275, 29550, 14, 12856, 14, 2024, 459, 1600, 63, 5764, 418, 267, 291, 14, 629, 8, 5764, 12, 283, 1600, 12856, 63, 705, 835, 358, 267, 790, 275, 283, 12856, 63, 3924, 5321, 354, 93, 1154, 355, 1275, 908, 8, 354, 29, 23972, 14, 12856, 14, 1971, 63, 1886, 855, 354, 3368, 267, 1125, 835, 275, 29550, 14, 3200, 14, 362, 63, 585, 8, 498, 9, 267, 291, 14, 1815, 8, 705, 835, 2356, 4002, 63, 265, 9, 339, 768, 11610, 14, 24813, 272, 347, 511, 63, 1600, 12856, 63, 2593, 8, 277, 304, 267, 4002, 63, 265, 275, 378, 14, 17, 267, 29550, 275, 664, 63, 23972, 8, 18696, 2422, 25157, 12, 791, 10353, 51, 7613, 998, 540, 63, 8899, 356, 4002, 63, 265, 1552, 267, 1995, 29550, 14, 67, 22910, 8, 2923, 29, 22589, 9, 267, 4499, 275, 29550, 14, 12856, 14, 2024, 459, 1600, 63, 5764, 418, 267, 291, 14, 629, 8, 5764, 12, 283, 1600, 12856, 63, 2593, 358, 267, 5020, 275, 29550, 14, 3200, 267, 1343, 275, 5020, 14, 362, 63, 585, 360, 928, 63, 521, 358, 267, 3631, 275, 5020, 14, 362, 63, 585, 360, 8192, 63, 521, 358, 267, 3915, 275, 3631, 446, 1343, 267, 3141, 63, 4515, 275, 3915, 14, 4515, 435, 3915, 14, 18144, 267, 291, 14, 1815, 8, 2923, 63, 4515, 2356, 4002, 63, 265, 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 ]
[ 7390, 14, 4901, 492, 10133, 199, 504, 7390, 14, 14443, 14, 2796, 492, 7640, 199, 504, 18918, 14, 1208, 14, 396, 492, 664, 63, 23972, 199, 504, 2295, 14, 8721, 7735, 492, 21876, 2422, 25157, 12, 7020, 25157, 12, 4520, 25157, 199, 504, 2295, 14, 1805, 1000, 492, 4420, 3120, 421, 199, 533, 1379, 4724, 25157, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 1805, 1000, 275, 4420, 3120, 342, 267, 291, 14, 1805, 1000, 855, 4200, 4533, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 1805, 1000, 855, 2224, 721, 403, 12, 488, 12, 488, 9, 339, 768, 11610, 14, 24813, 272, 347, 511, 63, 1600, 12856, 63, 1053, 835, 8, 277, 304, 267, 4002, 63, 265, 275, 959, 267, 29550, 275, 664, 63, 23972, 8, 2081, 25157, 12, 791, 10353, 51, 7613, 998, 540, 63, 10439, 8760, 356, 4002, 63, 265, 1552, 267, 1995, 29550, 14, 67, 22910, 342, 267, 4499, 275, 29550, 14, 12856, 14, 2024, 459, 1600, 63, 5764, 418, 267, 291, 14, 629, 8, 5764, 12, 283, 1600, 12856, 63, 1053, 835, 358, 267, 1242, 835, 275, 29550, 14, 3200, 14, 362, 63, 585, 360, 1053, 63, 26478, 63, 835, 358, 267, 291, 14, 1815, 8, 1053, 835, 2356, 4002, 63, 265, 9, 339, 768, 11610, 14, 24813, 272, 347, 511, 63, 1600, 12856, 63, 1606, 835, 8, 277, 304, 267, 4002, 63, 265, 275, 959, 267, 29550, 275, 664, 63, 23972, 8, 18696, 2422, 25157, 12, 791, 10353, 51, 7613, 998, 540, 63, 12898, 8760, 356, 4002, 63, 265, 1552, 267, 1995, 29550, 14, 67, 22910, 342, 267, 4499, 275, 29550, 14, 12856, 14, 2024, 459, 1600, 63, 5764, 418, 267, 291, 14, 629, 8, 5764, 12, 283, 1600, 12856, 63, 1606, 835, 358, 267, 2034, 835, 275, 29550, 14, 3200, 14, 362, 63, 585, 360, 1310, 63, 9226, 63, 835, 358, 267, 291, 14, 1815, 8, 1606, 835, 2356, 4002, 63, 265, 9, 339, 768, 11610, 14, 24813, 272, 347, 511, 63, 1600, 12856, 63, 705, 835, 8, 277, 304, 267, 4002, 63, 265, 275, 959, 267, 29550, 275, 664, 63, 23972, 8, 547, 25157, 12, 791, 10353, 51, 7613, 998, 540, 63, 3170, 8760, 356, 4002, 63, 265, 1552, 267, 1995, 29550, 14, 67, 22910, 8, 2923, 29, 22589, 9, 267, 4499, 275, 29550, 14, 12856, 14, 2024, 459, 1600, 63, 5764, 418, 267, 291, 14, 629, 8, 5764, 12, 283, 1600, 12856, 63, 705, 835, 358, 267, 790, 275, 283, 12856, 63, 3924, 5321, 354, 93, 1154, 355, 1275, 908, 8, 354, 29, 23972, 14, 12856, 14, 1971, 63, 1886, 855, 354, 3368, 267, 1125, 835, 275, 29550, 14, 3200, 14, 362, 63, 585, 8, 498, 9, 267, 291, 14, 1815, 8, 705, 835, 2356, 4002, 63, 265, 9, 339, 768, 11610, 14, 24813, 272, 347, 511, 63, 1600, 12856, 63, 2593, 8, 277, 304, 267, 4002, 63, 265, 275, 378, 14, 17, 267, 29550, 275, 664, 63, 23972, 8, 18696, 2422, 25157, 12, 791, 10353, 51, 7613, 998, 540, 63, 8899, 356, 4002, 63, 265, 1552, 267, 1995, 29550, 14, 67, 22910, 8, 2923, 29, 22589, 9, 267, 4499, 275, 29550, 14, 12856, 14, 2024, 459, 1600, 63, 5764, 418, 267, 291, 14, 629, 8, 5764, 12, 283, 1600, 12856, 63, 2593, 358, 267, 5020, 275, 29550, 14, 3200, 267, 1343, 275, 5020, 14, 362, 63, 585, 360, 928, 63, 521, 358, 267, 3631, 275, 5020, 14, 362, 63, 585, 360, 8192, 63, 521, 358, 267, 3915, 275, 3631, 446, 1343, 267, 3141, 63, 4515, 275, 3915, 14, 4515, 435, 3915, 14, 18144, 267, 291, 14, 1815, 8, 2923, 63, 4515, 2356, 4002, 63, 265, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
pilou-/ansible
contrib/inventory/nsot.py
14
9857
#!/usr/bin/env python ''' nsot ==== Ansible Dynamic Inventory to pull hosts from NSoT, a flexible CMDB by Dropbox Features -------- * Define host groups in form of NSoT device attribute criteria * All parameters defined by the spec as of 2015-09-05 are supported. + ``--list``: Returns JSON hash of host groups -> hosts and top-level ``_meta`` -> ``hostvars`` which correspond to all device attributes. Group vars can be specified in the YAML configuration, noted below. + ``--host <hostname>``: Returns JSON hash where every item is a device attribute. * In addition to all attributes assigned to resource being returned, script will also append ``site_id`` and ``id`` as facts to utilize. Confguration ------------ Since it'd be annoying and failure prone to guess where you're configuration file is, use ``NSOT_INVENTORY_CONFIG`` to specify the path to it. This file should adhere to the YAML spec. All top-level variable must be desired Ansible group-name hashed with single 'query' item to define the NSoT attribute query. Queries follow the normal NSoT query syntax, `shown here`_ .. _shown here: https://github.com/dropbox/pynsot#set-queries .. code:: yaml routers: query: 'deviceType=ROUTER' vars: a: b c: d juniper_fw: query: 'deviceType=FIREWALL manufacturer=JUNIPER' not_f10: query: '-manufacturer=FORCE10' The inventory will automatically use your ``.pynsotrc`` like normal pynsot from cli would, so make sure that's configured appropriately. .. note:: Attributes I'm showing above are influenced from ones that the Trigger project likes. As is the spirit of NSoT, use whichever attributes work best for your workflow. If config file is blank or absent, the following default groups will be created: * ``routers``: deviceType=ROUTER * ``switches``: deviceType=SWITCH * ``firewalls``: deviceType=FIREWALL These are likely not useful for everyone so please use the configuration. :) .. note:: By default, resources will only be returned for what your default site is set for in your ``~/.pynsotrc``. If you want to specify, add an extra key under the group for ``site: n``. Output Examples --------------- Here are some examples shown from just calling the command directly:: $ NSOT_INVENTORY_CONFIG=$PWD/test.yaml ansible_nsot --list | jq '.' { "routers": { "hosts": [ "test1.example.com" ], "vars": { "cool_level": "very", "group": "routers" } }, "firewalls": { "hosts": [ "test2.example.com" ], "vars": { "cool_level": "enough", "group": "firewalls" } }, "_meta": { "hostvars": { "test2.example.com": { "make": "SRX", "site_id": 1, "id": 108 }, "test1.example.com": { "make": "MX80", "site_id": 1, "id": 107 } } }, "rtr_and_fw": { "hosts": [ "test1.example.com", "test2.example.com" ], "vars": {} } } $ NSOT_INVENTORY_CONFIG=$PWD/test.yaml ansible_nsot --host test1 | jq '.' { "make": "MX80", "site_id": 1, "id": 107 } ''' from __future__ import print_function import sys import os import pkg_resources import argparse import json import yaml from textwrap import dedent from pynsot.client import get_api_client from pynsot.app import HttpServerError from click.exceptions import UsageError from ansible.module_utils.six import string_types def warning(*objs): print("WARNING: ", *objs, file=sys.stderr) class NSoTInventory(object): '''NSoT Client object for gather inventory''' def __init__(self): self.config = dict() config_env = os.environ.get('NSOT_INVENTORY_CONFIG') if config_env: try: config_file = os.path.abspath(config_env) except IOError: # If file non-existent, use default config self._config_default() except Exception as e: sys.exit('%s\n' % e) with open(config_file) as f: try: self.config.update(yaml.safe_load(f)) except TypeError: # If empty file, use default config warning('Empty config file') self._config_default() except Exception as e: sys.exit('%s\n' % e) else: # Use defaults if env var missing self._config_default() self.groups = self.config.keys() self.client = get_api_client() self._meta = {'hostvars': dict()} def _config_default(self): default_yaml = ''' --- routers: query: deviceType=ROUTER switches: query: deviceType=SWITCH firewalls: query: deviceType=FIREWALL ''' self.config = yaml.safe_load(dedent(default_yaml)) def do_list(self): '''Direct callback for when ``--list`` is provided Relies on the configuration generated from init to run _inventory_group() ''' inventory = dict() for group, contents in self.config.items(): group_response = self._inventory_group(group, contents) inventory.update(group_response) inventory.update({'_meta': self._meta}) return json.dumps(inventory) def do_host(self, host): return json.dumps(self._hostvars(host)) def _hostvars(self, host): '''Return dictionary of all device attributes Depending on number of devices in NSoT, could be rather slow since this has to request every device resource to filter through ''' device = [i for i in self.client.devices.get() if host in i['hostname']][0] attributes = device['attributes'] attributes.update({'site_id': device['site_id'], 'id': device['id']}) return attributes def _inventory_group(self, group, contents): '''Takes a group and returns inventory for it as dict :param group: Group name :type group: str :param contents: The contents of the group's YAML config :type contents: dict contents param should look like:: { 'query': 'xx', 'vars': 'a': 'b' } Will return something like:: { group: { hosts: [], vars: {}, } ''' query = contents.get('query') hostvars = contents.get('vars', dict()) site = contents.get('site', dict()) obj = {group: dict()} obj[group]['hosts'] = [] obj[group]['vars'] = hostvars try: assert isinstance(query, string_types) except Exception: sys.exit('ERR: Group queries must be a single string\n' ' Group: %s\n' ' Query: %s\n' % (group, query) ) try: if site: site = self.client.sites(site) devices = site.devices.query.get(query=query) else: devices = self.client.devices.query.get(query=query) except HttpServerError as e: if '500' in str(e.response): _site = 'Correct site id?' _attr = 'Queried attributes actually exist?' questions = _site + '\n' + _attr sys.exit('ERR: 500 from server.\n%s' % questions) else: raise except UsageError: sys.exit('ERR: Could not connect to server. Running?') # Would do a list comprehension here, but would like to save code/time # and also acquire attributes in this step for host in devices: # Iterate through each device that matches query, assign hostname # to the group's hosts array and then use this single iteration as # a chance to update self._meta which will be used in the final # return hostname = host['hostname'] obj[group]['hosts'].append(hostname) attributes = host['attributes'] attributes.update({'site_id': host['site_id'], 'id': host['id']}) self._meta['hostvars'].update({hostname: attributes}) return obj def parse_args(): desc = __doc__.splitlines()[4] # Just to avoid being redundant # Establish parser with options and error out if no action provided parser = argparse.ArgumentParser( description=desc, conflict_handler='resolve', ) # Arguments # # Currently accepting (--list | -l) and (--host | -h) # These must not be allowed together parser.add_argument( '--list', '-l', help='Print JSON object containing hosts to STDOUT', action='store_true', dest='list_', # Avoiding syntax highlighting for list ) parser.add_argument( '--host', '-h', help='Print JSON object containing hostvars for <host>', action='store', ) args = parser.parse_args() if not args.list_ and not args.host: # Require at least one option parser.exit(status=1, message='No action requested') if args.list_ and args.host: # Do not allow multiple options parser.exit(status=1, message='Too many actions requested') return args def main(): '''Set up argument handling and callback routing''' args = parse_args() client = NSoTInventory() # Callback condition if args.list_: print(client.do_list()) elif args.host: print(client.do_host(args.host)) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 2344, 199, 561, 357, 199, 532, 199, 199, 10047, 21907, 19337, 370, 10299, 7057, 687, 653, 5158, 52, 12, 282, 26841, 445, 45, 2846, 701, 18110, 1977, 199, 199, 10807, 199, 518, 199, 199, 10, 13930, 1591, 4652, 315, 1824, 402, 653, 5158, 52, 2243, 2225, 15647, 199, 199, 10, 2900, 2633, 3247, 701, 314, 3158, 465, 402, 6900, 13, 1643, 13, 1717, 787, 3748, 14, 819, 435, 1124, 306, 513, 18983, 1803, 4840, 2631, 402, 1591, 4652, 1035, 7057, 436, 2746, 13, 1896, 272, 24507, 2024, 1040, 1035, 1124, 23265, 1040, 1314, 17118, 370, 1006, 2243, 3004, 14, 339, 5611, 6802, 883, 506, 2013, 315, 314, 18916, 2897, 12, 949, 471, 5084, 14, 819, 435, 1124, 306, 1102, 665, 4269, 30, 18983, 1803, 4840, 2631, 2382, 4036, 1242, 365, 282, 2243, 272, 2225, 14, 199, 199, 10, 1010, 10234, 370, 1006, 3004, 7943, 370, 2073, 3769, 2138, 12, 2884, 523, 911, 2597, 5666, 1124, 2124, 63, 344, 1040, 436, 1124, 344, 1040, 465, 9036, 370, 7678, 13559, 14, 421, 199, 8930, 71, 1542, 199, 4559, 199, 199, 24430, 652, 5121, 506, 22984, 22440, 436, 5988, 5448, 368, 370, 9519, 2382, 1265, 3984, 2897, 199, 493, 365, 12, 675, 1124, 2709, 1387, 63, 568, 4554, 5347, 63, 5569, 1040, 370, 4165, 314, 931, 370, 652, 14, 199, 199, 2765, 570, 1077, 1503, 1681, 370, 314, 18916, 3158, 14, 2900, 2746, 13, 1896, 1750, 1471, 506, 199, 16035, 2622, 1572, 13, 354, 19871, 543, 2849, 283, 1131, 7, 1242, 370, 5627, 314, 653, 5158, 52, 199, 3215, 1827, 14, 199, 199, 13611, 2035, 314, 3293, 653, 5158, 52, 1827, 6302, 12, 658, 24422, 2348, 18417, 199, 199, 703, 485, 24422, 2348, 26, 4178, 921, 5031, 14, 957, 15, 32118, 15, 647, 561, 357, 3, 409, 13, 10590, 199, 199, 703, 1233, 447, 8864, 8410, 24464, 26, 1362, 1827, 26, 283, 1782, 804, 29, 19281, 7, 1362, 6802, 26, 2126, 282, 26, 330, 2126, 286, 26, 366, 8410, 1335, 5411, 529, 63, 8835, 26, 1362, 1827, 26, 283, 1782, 804, 29, 1976, 907, 55, 1761, 2169, 21087, 29, 42, 1734, 1772, 540, 7, 8410, 440, 63, 70, 709, 26, 1362, 1827, 26, 2475, 32214, 29, 27240, 709, 7, 199, 199, 1918, 8200, 911, 5847, 675, 2195, 21502, 647, 561, 357, 1195, 1040, 2839, 3293, 1134, 561, 357, 687, 199, 2764, 3955, 12, 880, 1852, 3238, 626, 1159, 7526, 22497, 14, 199, 199, 703, 5317, 447, 339, 9382, 473, 6704, 21207, 3432, 787, 315, 24585, 68, 687, 7869, 626, 314, 24015, 272, 2199, 1212, 9246, 14, 3709, 365, 314, 19441, 11133, 402, 653, 5158, 52, 12, 675, 704, 73, 595, 422, 3004, 1736, 5526, 272, 367, 2195, 10431, 14, 199, 199, 3917, 1101, 570, 365, 4596, 503, 9552, 12, 314, 2569, 849, 4652, 911, 506, 199, 3966, 26, 199, 199, 10, 1124, 17292, 18983, 31343, 29, 19281, 199, 10, 1124, 32332, 18983, 31343, 29, 18079, 199, 10, 1124, 10794, 83, 18983, 31343, 29, 1976, 907, 55, 1761, 199, 199, 20676, 787, 12060, 440, 2997, 367, 4036, 368, 880, 8749, 675, 314, 2897, 14, 32428, 199, 199, 703, 5317, 447, 339, 4885, 849, 12, 5944, 911, 1454, 506, 2138, 367, 4052, 2195, 849, 272, 4770, 365, 663, 367, 315, 2195, 1124, 94, 8083, 647, 561, 357, 1195, 4345, 339, 982, 1265, 2934, 370, 4165, 12, 1050, 376, 2402, 790, 1334, 314, 1572, 367, 1124, 2124, 26, 302, 4345, 199, 199, 2959, 6058, 199, 18964, 199, 199, 21741, 787, 2005, 7251, 9164, 687, 2951, 6358, 314, 1414, 5370, 447, 8410, 2672, 9380, 1387, 63, 568, 4554, 5347, 63, 5569, 28617, 10780, 36, 15, 396, 14, 5963, 3242, 63, 561, 357, 1553, 513, 1204, 1335, 81, 7815, 2043, 469, 1362, 298, 17292, 582, 469, 2126, 298, 5146, 582, 359, 268, 298, 396, 17, 14, 2694, 14, 957, 2, 2126, 2156, 2126, 298, 2936, 582, 469, 268, 298, 18499, 63, 1896, 582, 298, 2588, 401, 268, 298, 923, 582, 298, 17292, 2, 2126, 789, 1362, 1660, 1362, 298, 10794, 83, 582, 469, 2126, 298, 5146, 582, 359, 268, 298, 396, 18, 14, 2694, 14, 957, 2, 2126, 2156, 2126, 298, 2936, 582, 469, 268, 298, 18499, 63, 1896, 582, 298, 30881, 401, 268, 298, 923, 582, 298, 10794, 83, 2, 2126, 789, 1362, 1660, 1362, 2668, 2024, 582, 469, 2126, 298, 23265, 582, 469, 268, 298, 396, 18, 14, 2694, 14, 957, 582, 469, 1779, 298, 1875, 582, 298, 5943, 56, 401, 1779, 298, 2124, 63, 344, 582, 413, 12, 1779, 298, 344, 582, 24579, 268, 1660, 268, 298, 396, 17, 14, 2694, 14, 957, 582, 469, 1779, 298, 1875, 582, 298, 17401, 1257, 401, 1779, 298, 2124, 63, 344, 582, 413, 12, 1779, 298, 344, 582, 23543, 268, 789, 2126, 789, 1362, 1660, 1362, 298, 82, 454, 63, 460, 63, 8835, 582, 469, 2126, 298, 5146, 582, 359, 268, 298, 396, 17, 14, 2694, 14, 957, 401, 268, 298, 396, 18, 14, 2694, 14, 957, 2, 2126, 2156, 2126, 298, 2936, 582, 1052, 1362, 789, 2043, 789, 27974, 2672, 9380, 1387, 63, 568, 4554, 5347, 63, 5569, 28617, 10780, 36, 15, 396, 14, 5963, 3242, 63, 561, 357, 1553, 1102, 511, 17, 1204, 1335, 81, 7815, 2043, 469, 489, 298, 1875, 582, 298, 17401, 1257, 401, 489, 298, 2124, 63, 344, 582, 413, 12, 489, 298, 344, 582, 23543, 2043, 789, 199, 199, 2344, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 984, 199, 646, 747, 199, 646, 5496, 63, 4435, 199, 646, 7534, 199, 646, 2022, 199, 646, 8864, 199, 504, 13390, 492, 22622, 199, 504, 1134, 561, 357, 14, 1258, 492, 664, 63, 1246, 63, 1258, 199, 504, 1134, 561, 357, 14, 571, 492, 4760, 17692, 199, 504, 8968, 14, 3924, 492, 11028, 547, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 1059, 63, 1313, 421, 199, 318, 5721, 2031, 8718, 304, 272, 870, 480, 9171, 26, 3872, 627, 8718, 12, 570, 29, 1274, 14, 3083, 9, 421, 199, 533, 653, 5158, 52, 19304, 8, 785, 304, 272, 1449, 2709, 79, 52, 6810, 909, 367, 13082, 8200, 2344, 339, 347, 636, 826 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 2344, 199, 561, 357, 199, 532, 199, 199, 10047, 21907, 19337, 370, 10299, 7057, 687, 653, 5158, 52, 12, 282, 26841, 445, 45, 2846, 701, 18110, 1977, 199, 199, 10807, 199, 518, 199, 199, 10, 13930, 1591, 4652, 315, 1824, 402, 653, 5158, 52, 2243, 2225, 15647, 199, 199, 10, 2900, 2633, 3247, 701, 314, 3158, 465, 402, 6900, 13, 1643, 13, 1717, 787, 3748, 14, 819, 435, 1124, 306, 513, 18983, 1803, 4840, 2631, 402, 1591, 4652, 1035, 7057, 436, 2746, 13, 1896, 272, 24507, 2024, 1040, 1035, 1124, 23265, 1040, 1314, 17118, 370, 1006, 2243, 3004, 14, 339, 5611, 6802, 883, 506, 2013, 315, 314, 18916, 2897, 12, 949, 471, 5084, 14, 819, 435, 1124, 306, 1102, 665, 4269, 30, 18983, 1803, 4840, 2631, 2382, 4036, 1242, 365, 282, 2243, 272, 2225, 14, 199, 199, 10, 1010, 10234, 370, 1006, 3004, 7943, 370, 2073, 3769, 2138, 12, 2884, 523, 911, 2597, 5666, 1124, 2124, 63, 344, 1040, 436, 1124, 344, 1040, 465, 9036, 370, 7678, 13559, 14, 421, 199, 8930, 71, 1542, 199, 4559, 199, 199, 24430, 652, 5121, 506, 22984, 22440, 436, 5988, 5448, 368, 370, 9519, 2382, 1265, 3984, 2897, 199, 493, 365, 12, 675, 1124, 2709, 1387, 63, 568, 4554, 5347, 63, 5569, 1040, 370, 4165, 314, 931, 370, 652, 14, 199, 199, 2765, 570, 1077, 1503, 1681, 370, 314, 18916, 3158, 14, 2900, 2746, 13, 1896, 1750, 1471, 506, 199, 16035, 2622, 1572, 13, 354, 19871, 543, 2849, 283, 1131, 7, 1242, 370, 5627, 314, 653, 5158, 52, 199, 3215, 1827, 14, 199, 199, 13611, 2035, 314, 3293, 653, 5158, 52, 1827, 6302, 12, 658, 24422, 2348, 18417, 199, 199, 703, 485, 24422, 2348, 26, 4178, 921, 5031, 14, 957, 15, 32118, 15, 647, 561, 357, 3, 409, 13, 10590, 199, 199, 703, 1233, 447, 8864, 8410, 24464, 26, 1362, 1827, 26, 283, 1782, 804, 29, 19281, 7, 1362, 6802, 26, 2126, 282, 26, 330, 2126, 286, 26, 366, 8410, 1335, 5411, 529, 63, 8835, 26, 1362, 1827, 26, 283, 1782, 804, 29, 1976, 907, 55, 1761, 2169, 21087, 29, 42, 1734, 1772, 540, 7, 8410, 440, 63, 70, 709, 26, 1362, 1827, 26, 2475, 32214, 29, 27240, 709, 7, 199, 199, 1918, 8200, 911, 5847, 675, 2195, 21502, 647, 561, 357, 1195, 1040, 2839, 3293, 1134, 561, 357, 687, 199, 2764, 3955, 12, 880, 1852, 3238, 626, 1159, 7526, 22497, 14, 199, 199, 703, 5317, 447, 339, 9382, 473, 6704, 21207, 3432, 787, 315, 24585, 68, 687, 7869, 626, 314, 24015, 272, 2199, 1212, 9246, 14, 3709, 365, 314, 19441, 11133, 402, 653, 5158, 52, 12, 675, 704, 73, 595, 422, 3004, 1736, 5526, 272, 367, 2195, 10431, 14, 199, 199, 3917, 1101, 570, 365, 4596, 503, 9552, 12, 314, 2569, 849, 4652, 911, 506, 199, 3966, 26, 199, 199, 10, 1124, 17292, 18983, 31343, 29, 19281, 199, 10, 1124, 32332, 18983, 31343, 29, 18079, 199, 10, 1124, 10794, 83, 18983, 31343, 29, 1976, 907, 55, 1761, 199, 199, 20676, 787, 12060, 440, 2997, 367, 4036, 368, 880, 8749, 675, 314, 2897, 14, 32428, 199, 199, 703, 5317, 447, 339, 4885, 849, 12, 5944, 911, 1454, 506, 2138, 367, 4052, 2195, 849, 272, 4770, 365, 663, 367, 315, 2195, 1124, 94, 8083, 647, 561, 357, 1195, 4345, 339, 982, 1265, 2934, 370, 4165, 12, 1050, 376, 2402, 790, 1334, 314, 1572, 367, 1124, 2124, 26, 302, 4345, 199, 199, 2959, 6058, 199, 18964, 199, 199, 21741, 787, 2005, 7251, 9164, 687, 2951, 6358, 314, 1414, 5370, 447, 8410, 2672, 9380, 1387, 63, 568, 4554, 5347, 63, 5569, 28617, 10780, 36, 15, 396, 14, 5963, 3242, 63, 561, 357, 1553, 513, 1204, 1335, 81, 7815, 2043, 469, 1362, 298, 17292, 582, 469, 2126, 298, 5146, 582, 359, 268, 298, 396, 17, 14, 2694, 14, 957, 2, 2126, 2156, 2126, 298, 2936, 582, 469, 268, 298, 18499, 63, 1896, 582, 298, 2588, 401, 268, 298, 923, 582, 298, 17292, 2, 2126, 789, 1362, 1660, 1362, 298, 10794, 83, 582, 469, 2126, 298, 5146, 582, 359, 268, 298, 396, 18, 14, 2694, 14, 957, 2, 2126, 2156, 2126, 298, 2936, 582, 469, 268, 298, 18499, 63, 1896, 582, 298, 30881, 401, 268, 298, 923, 582, 298, 10794, 83, 2, 2126, 789, 1362, 1660, 1362, 2668, 2024, 582, 469, 2126, 298, 23265, 582, 469, 268, 298, 396, 18, 14, 2694, 14, 957, 582, 469, 1779, 298, 1875, 582, 298, 5943, 56, 401, 1779, 298, 2124, 63, 344, 582, 413, 12, 1779, 298, 344, 582, 24579, 268, 1660, 268, 298, 396, 17, 14, 2694, 14, 957, 582, 469, 1779, 298, 1875, 582, 298, 17401, 1257, 401, 1779, 298, 2124, 63, 344, 582, 413, 12, 1779, 298, 344, 582, 23543, 268, 789, 2126, 789, 1362, 1660, 1362, 298, 82, 454, 63, 460, 63, 8835, 582, 469, 2126, 298, 5146, 582, 359, 268, 298, 396, 17, 14, 2694, 14, 957, 401, 268, 298, 396, 18, 14, 2694, 14, 957, 2, 2126, 2156, 2126, 298, 2936, 582, 1052, 1362, 789, 2043, 789, 27974, 2672, 9380, 1387, 63, 568, 4554, 5347, 63, 5569, 28617, 10780, 36, 15, 396, 14, 5963, 3242, 63, 561, 357, 1553, 1102, 511, 17, 1204, 1335, 81, 7815, 2043, 469, 489, 298, 1875, 582, 298, 17401, 1257, 401, 489, 298, 2124, 63, 344, 582, 413, 12, 489, 298, 344, 582, 23543, 2043, 789, 199, 199, 2344, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 984, 199, 646, 747, 199, 646, 5496, 63, 4435, 199, 646, 7534, 199, 646, 2022, 199, 646, 8864, 199, 504, 13390, 492, 22622, 199, 504, 1134, 561, 357, 14, 1258, 492, 664, 63, 1246, 63, 1258, 199, 504, 1134, 561, 357, 14, 571, 492, 4760, 17692, 199, 504, 8968, 14, 3924, 492, 11028, 547, 199, 199, 504, 3242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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 ]
stargaser/astropy
examples/io/split-jpeg-to-fits.py
3
2472
# -*- coding: utf-8 -*- """ ===================================================== Convert a 3-color image (JPG) to separate FITS images ===================================================== This example opens an RGB JPEG image and writes out each channel as a separate FITS (image) file. This example uses `pillow <http://python-pillow.org>`_ to read the image, `matplotlib.pyplot` to display the image, and `astropy.io.fits` to save FITS files. *By: Erik Bray, Adrian Price-Whelan* *License: BSD* """ import numpy as np from PIL import Image from astropy.io import fits ############################################################################## # Set up matplotlib and use a nicer set of plot parameters import matplotlib.pyplot as plt from astropy.visualization import astropy_mpl_style plt.style.use(astropy_mpl_style) ############################################################################## # Load and display the original 3-color jpeg image: image = Image.open('Hs-2009-14-a-web.jpg') xsize, ysize = image.size print("Image size: {} x {}".format(xsize, ysize)) plt.imshow(image) ############################################################################## # Split the three channels (RGB) and get the data as Numpy arrays. The arrays # are flattened, so they are 1-dimensional: r, g, b = image.split() r_data = np.array(r.getdata()) # data is now an array of length ysize*xsize g_data = np.array(g.getdata()) b_data = np.array(b.getdata()) print(r_data.shape) ############################################################################## # Reshape the image arrays to be 2-dimensional: r_data = r_data.reshape(ysize, xsize) g_data = g_data.reshape(ysize, xsize) b_data = b_data.reshape(ysize, xsize) ############################################################################## # Write out the channels as separate FITS images red = fits.PrimaryHDU(data=r_data) red.header['LATOBS'] = "32:11:56" # add spurious header info red.header['LONGOBS'] = "110:56" red.writeto('red.fits') green = fits.PrimaryHDU(data=g_data) green.header['LATOBS'] = "32:11:56" green.header['LONGOBS'] = "110:56" green.writeto('green.fits') blue = fits.PrimaryHDU(data=b_data) blue.header['LATOBS'] = "32:11:56" blue.header['LONGOBS'] = "110:56" blue.writeto('blue.fits') ############################################################################## # Delete the files created import os os.remove('red.fits') os.remove('green.fits') os.remove('blue.fits')
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 12813, 19989, 199, 7306, 282, 650, 13, 2326, 1834, 334, 42, 11115, 9, 370, 7396, 481, 5930, 5935, 199, 12813, 19989, 199, 199, 2765, 2893, 30848, 376, 19013, 1603, 17557, 1834, 436, 14511, 734, 1924, 3623, 465, 282, 7396, 199, 9037, 334, 1569, 9, 570, 14, 199, 199, 2765, 2893, 4440, 658, 80, 382, 674, 665, 1014, 921, 1548, 13, 80, 382, 674, 14, 1308, 18740, 370, 1586, 314, 1834, 12, 199, 64, 16440, 14, 13563, 64, 370, 2929, 314, 1834, 12, 436, 658, 1810, 7537, 14, 2308, 14, 14948, 64, 370, 3354, 481, 5930, 1584, 14, 421, 199, 10, 2175, 26, 662, 25844, 699, 803, 12, 4431, 18429, 20276, 13, 5879, 352, 290, 10, 199, 199, 10, 3761, 26, 6289, 10, 421, 199, 624, 199, 199, 646, 2680, 465, 980, 199, 504, 14937, 492, 6047, 199, 504, 28753, 14, 2308, 492, 20147, 199, 199, 4605, 199, 3, 2494, 1536, 8027, 436, 675, 282, 30023, 663, 402, 5137, 2633, 199, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 28753, 14, 16948, 2072, 492, 28753, 63, 2421, 63, 2487, 199, 6003, 14, 2487, 14, 1180, 8, 1810, 7537, 63, 2421, 63, 2487, 9, 199, 199, 4605, 199, 3, 7190, 436, 2929, 314, 3379, 650, 13, 2326, 1335, 11997, 1834, 26, 199, 199, 1569, 275, 6047, 14, 1490, 360, 40, 83, 13, 8664, 13, 1079, 13, 65, 13, 2520, 14, 8476, 358, 199, 88, 890, 12, 612, 890, 275, 1834, 14, 890, 199, 1361, 480, 3491, 1568, 26, 1052, 671, 8352, 908, 8, 88, 890, 12, 612, 890, 430, 199, 6003, 14, 20413, 8, 1569, 9, 199, 199, 4605, 199, 3, 11740, 314, 7795, 9245, 334, 12067, 9, 436, 664, 314, 666, 465, 20535, 6572, 14, 710, 6572, 199, 3, 787, 18767, 12, 880, 2985, 787, 413, 13, 13014, 26, 199, 199, 82, 12, 486, 12, 330, 275, 1834, 14, 1294, 342, 199, 82, 63, 576, 275, 980, 14, 1144, 8, 82, 14, 29160, 1012, 327, 666, 365, 3063, 376, 1625, 402, 2582, 612, 890, 10, 88, 890, 199, 71, 63, 576, 275, 980, 14, 1144, 8, 71, 14, 29160, 1012, 199, 66, 63, 576, 275, 980, 14, 1144, 8, 66, 14, 29160, 1012, 199, 1361, 8, 82, 63, 576, 14, 1392, 9, 199, 199, 4605, 199, 3, 3591, 15221, 314, 1834, 6572, 370, 506, 499, 13, 13014, 26, 199, 199, 82, 63, 576, 275, 519, 63, 576, 14, 5217, 8, 89, 890, 12, 671, 890, 9, 199, 71, 63, 576, 275, 486, 63, 576, 14, 5217, 8, 89, 890, 12, 671, 890, 9, 199, 66, 63, 576, 275, 330, 63, 576, 14, 5217, 8, 89, 890, 12, 671, 890, 9, 199, 199, 4605, 199, 3, 6990, 734, 314, 9245, 465, 7396, 481, 5930, 5935, 199, 199, 581, 275, 20147, 14, 14908, 40, 4980, 8, 576, 29, 82, 63, 576, 9, 199, 581, 14, 1291, 459, 20307, 5488, 51, 418, 275, 298, 708, 26, 845, 26, 1367, 2, 327, 1050, 2249, 2302, 1785, 1406, 2256, 199, 581, 14, 1291, 459, 12375, 5488, 51, 418, 275, 298, 6019, 26, 1367, 2, 199, 581, 14, 952, 475, 360, 581, 14, 14948, 358, 199, 199, 7731, 275, 20147, 14, 14908, 40, 4980, 8, 576, 29, 71, 63, 576, 9, 199, 7731, 14, 1291, 459, 20307, 5488, 51, 418, 275, 298, 708, 26, 845, 26, 1367, 2, 199, 7731, 14, 1291, 459, 12375, 5488, 51, 418, 275, 298, 6019, 26, 1367, 2, 199, 7731, 14, 952, 475, 360, 7731, 14, 14948, 358, 199, 199, 6304, 275, 20147, 14, 14908, 40, 4980, 8, 576, 29, 66, 63, 576, 9, 199, 6304, 14, 1291, 459, 20307, 5488, 51, 418, 275, 298, 708, 26, 845, 26, 1367, 2, 199, 6304, 14, 1291, 459, 12375, 5488, 51, 418, 275, 298, 6019, 26, 1367, 2, 199, 6304, 14, 952, 475, 360, 6304, 14, 14948, 358, 199, 199, 4605, 199, 3, 8496, 314, 1584, 2737, 199, 646, 747, 199, 736, 14, 2168, 360, 581, 14, 14948, 358, 199, 736, 14, 2168, 360, 7731, 14, 14948, 358, 199, 736, 14, 2168, 360, 6304, 14, 14948, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 12813, 19989, 199, 7306, 282, 650, 13, 2326, 1834, 334, 42, 11115, 9, 370, 7396, 481, 5930, 5935, 199, 12813, 19989, 199, 199, 2765, 2893, 30848, 376, 19013, 1603, 17557, 1834, 436, 14511, 734, 1924, 3623, 465, 282, 7396, 199, 9037, 334, 1569, 9, 570, 14, 199, 199, 2765, 2893, 4440, 658, 80, 382, 674, 665, 1014, 921, 1548, 13, 80, 382, 674, 14, 1308, 18740, 370, 1586, 314, 1834, 12, 199, 64, 16440, 14, 13563, 64, 370, 2929, 314, 1834, 12, 436, 658, 1810, 7537, 14, 2308, 14, 14948, 64, 370, 3354, 481, 5930, 1584, 14, 421, 199, 10, 2175, 26, 662, 25844, 699, 803, 12, 4431, 18429, 20276, 13, 5879, 352, 290, 10, 199, 199, 10, 3761, 26, 6289, 10, 421, 199, 624, 199, 199, 646, 2680, 465, 980, 199, 504, 14937, 492, 6047, 199, 504, 28753, 14, 2308, 492, 20147, 199, 199, 4605, 199, 3, 2494, 1536, 8027, 436, 675, 282, 30023, 663, 402, 5137, 2633, 199, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 28753, 14, 16948, 2072, 492, 28753, 63, 2421, 63, 2487, 199, 6003, 14, 2487, 14, 1180, 8, 1810, 7537, 63, 2421, 63, 2487, 9, 199, 199, 4605, 199, 3, 7190, 436, 2929, 314, 3379, 650, 13, 2326, 1335, 11997, 1834, 26, 199, 199, 1569, 275, 6047, 14, 1490, 360, 40, 83, 13, 8664, 13, 1079, 13, 65, 13, 2520, 14, 8476, 358, 199, 88, 890, 12, 612, 890, 275, 1834, 14, 890, 199, 1361, 480, 3491, 1568, 26, 1052, 671, 8352, 908, 8, 88, 890, 12, 612, 890, 430, 199, 6003, 14, 20413, 8, 1569, 9, 199, 199, 4605, 199, 3, 11740, 314, 7795, 9245, 334, 12067, 9, 436, 664, 314, 666, 465, 20535, 6572, 14, 710, 6572, 199, 3, 787, 18767, 12, 880, 2985, 787, 413, 13, 13014, 26, 199, 199, 82, 12, 486, 12, 330, 275, 1834, 14, 1294, 342, 199, 82, 63, 576, 275, 980, 14, 1144, 8, 82, 14, 29160, 1012, 327, 666, 365, 3063, 376, 1625, 402, 2582, 612, 890, 10, 88, 890, 199, 71, 63, 576, 275, 980, 14, 1144, 8, 71, 14, 29160, 1012, 199, 66, 63, 576, 275, 980, 14, 1144, 8, 66, 14, 29160, 1012, 199, 1361, 8, 82, 63, 576, 14, 1392, 9, 199, 199, 4605, 199, 3, 3591, 15221, 314, 1834, 6572, 370, 506, 499, 13, 13014, 26, 199, 199, 82, 63, 576, 275, 519, 63, 576, 14, 5217, 8, 89, 890, 12, 671, 890, 9, 199, 71, 63, 576, 275, 486, 63, 576, 14, 5217, 8, 89, 890, 12, 671, 890, 9, 199, 66, 63, 576, 275, 330, 63, 576, 14, 5217, 8, 89, 890, 12, 671, 890, 9, 199, 199, 4605, 199, 3, 6990, 734, 314, 9245, 465, 7396, 481, 5930, 5935, 199, 199, 581, 275, 20147, 14, 14908, 40, 4980, 8, 576, 29, 82, 63, 576, 9, 199, 581, 14, 1291, 459, 20307, 5488, 51, 418, 275, 298, 708, 26, 845, 26, 1367, 2, 327, 1050, 2249, 2302, 1785, 1406, 2256, 199, 581, 14, 1291, 459, 12375, 5488, 51, 418, 275, 298, 6019, 26, 1367, 2, 199, 581, 14, 952, 475, 360, 581, 14, 14948, 358, 199, 199, 7731, 275, 20147, 14, 14908, 40, 4980, 8, 576, 29, 71, 63, 576, 9, 199, 7731, 14, 1291, 459, 20307, 5488, 51, 418, 275, 298, 708, 26, 845, 26, 1367, 2, 199, 7731, 14, 1291, 459, 12375, 5488, 51, 418, 275, 298, 6019, 26, 1367, 2, 199, 7731, 14, 952, 475, 360, 7731, 14, 14948, 358, 199, 199, 6304, 275, 20147, 14, 14908, 40, 4980, 8, 576, 29, 66, 63, 576, 9, 199, 6304, 14, 1291, 459, 20307, 5488, 51, 418, 275, 298, 708, 26, 845, 26, 1367, 2, 199, 6304, 14, 1291, 459, 12375, 5488, 51, 418, 275, 298, 6019, 26, 1367, 2, 199, 6304, 14, 952, 475, 360, 6304, 14, 14948, 358, 199, 199, 4605, 199, 3, 8496, 314, 1584, 2737, 199, 646, 747, 199, 736, 14, 2168, 360, 581, 14, 14948, 358, 199, 736, 14, 2168, 360, 7731, 14, 14948, 358, 199, 736, 14, 2168, 360, 6304, 14, 14948, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
indictranstech/reciphergroup-frappe
frappe/translate.py
14
17396
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # MIT License. See license.txt from __future__ import unicode_literals """ frappe.translate ~~~~~~~~~~~~~~~~ Translation tools for frappe """ import frappe, os, re, codecs, json from frappe.utils.jinja import render_include from jinja2 import TemplateError import itertools, operator def guess_language(lang_codes): """Set `frappe.local.lang` from HTTP headers at beginning of request""" if not lang_codes: return frappe.local.lang guess = None lang_list = get_all_languages() or [] for l in lang_codes: code = l.strip() if code in lang_list or code == "en": guess = code break # check if parent language (pt) is setup, if variant (pt-BR) if "-" in code: code = code.split("-")[0] if code in lang_list: guess = code break return guess or frappe.local.lang def get_user_lang(user=None): """Set frappe.local.lang from user preferences on session beginning or resumption""" if not user: user = frappe.session.user # via cache lang = frappe.cache().hget("lang", user) if not lang: # if defined in user profile user_lang = frappe.db.get_value("User", user, "language") if user_lang and user_lang!="Loading...": lang = get_lang_dict().get(user_lang) or frappe.local.lang else: default_lang = frappe.db.get_default("lang") lang = default_lang or frappe.local.lang frappe.cache().hset("lang", user, lang or "en") return lang def set_default_language(language): """Set Global default language""" lang = get_lang_dict()[language] frappe.db.set_default("lang", lang) frappe.local.lang = lang def get_all_languages(): """Returns all language codes ar, ch etc""" return [a.split()[0] for a in get_lang_info()] def get_lang_dict(): """Returns all languages in dict format, full name is the key e.g. `{"english":"en"}`""" return dict([[a[1], a[0]] for a in [a.split(None, 1) for a in get_lang_info()]]) def get_language_from_code(lang): return dict(a.split(None, 1) for a in get_lang_info()).get(lang) def get_lang_info(): """Returns a listified version of `apps/languages.txt`""" return frappe.cache().get_value("langinfo", lambda:frappe.get_file_items(os.path.join(frappe.local.sites_path, "languages.txt"))) def get_dict(fortype, name=None): """Returns translation dict for a type of object. :param fortype: must be one of `doctype`, `page`, `report`, `include`, `jsfile`, `boot` :param name: name of the document for which assets are to be returned. """ fortype = fortype.lower() cache = frappe.cache() asset_key = fortype + ":" + (name or "-") translation_assets = cache.hget("translation_assets", frappe.local.lang) or {} if not asset_key in translation_assets: if fortype=="doctype": messages = get_messages_from_doctype(name) elif fortype=="page": messages = get_messages_from_page(name) elif fortype=="report": messages = get_messages_from_report(name) elif fortype=="include": messages = get_messages_from_include_files() elif fortype=="jsfile": messages = get_messages_from_file(name) elif fortype=="boot": messages = get_messages_from_include_files() messages += frappe.db.sql("select 'DocType:', name from tabDocType") messages += frappe.db.sql("select 'Role:', name from tabRole") messages += frappe.db.sql("select 'Module:', name from `tabModule Def`") translation_assets[asset_key] = make_dict_from_messages(messages) translation_assets[asset_key].update(get_dict_from_hooks(fortype, name)) cache.hset("translation_assets", frappe.local.lang, translation_assets) return translation_assets[asset_key] def get_dict_from_hooks(fortype, name): translated_dict = {} hooks = frappe.get_hooks("get_translated_dict") for (hook_fortype, fortype_name) in hooks: if hook_fortype == fortype and fortype_name == name: for method in hooks[(hook_fortype, fortype_name)]: translated_dict.update(frappe.get_attr(method)()) return translated_dict def add_lang_dict(code): """Extracts messages and returns Javascript code snippet to be appened at the end of the given script :param code: Javascript code snippet to which translations needs to be appended.""" messages = extract_messages_from_code(code) messages = [message for pos, message in messages] code += "\n\n$.extend(frappe._messages, %s)" % json.dumps(make_dict_from_messages(messages)) return code def make_dict_from_messages(messages, full_dict=None): """Returns translated messages as a dict in Language specified in `frappe.local.lang` :param messages: List of untranslated messages """ out = {} if full_dict==None: full_dict = get_full_dict(frappe.local.lang) for m in messages: if m[1] in full_dict: out[m[1]] = full_dict[m[1]] return out def get_lang_js(fortype, name): """Returns code snippet to be appended at the end of a JS script. :param fortype: Type of object, e.g. `DocType` :param name: Document name """ return "\n\n$.extend(frappe._messages, %s)" % json.dumps(get_dict(fortype, name)) def get_full_dict(lang): """Load and return the entire translations dictionary for a language from :meth:`frape.cache` :param lang: Language Code, e.g. `hi` """ if not lang or lang == "en": return {} if not frappe.local.lang_full_dict: frappe.local.lang_full_dict = frappe.cache().hget("lang_full_dict", lang) if not frappe.local.lang_full_dict: frappe.local.lang_full_dict = load_lang(lang) # cache lang frappe.cache().hset("lang_full_dict", lang, frappe.local.lang_full_dict) return frappe.local.lang_full_dict def load_lang(lang, apps=None): """Combine all translations from `.csv` files in all `apps`""" out = {} for app in (apps or frappe.get_all_apps(True)): path = os.path.join(frappe.get_pymodule_path(app), "translations", lang + ".csv") if os.path.exists(path): csv_content = read_csv_file(path) cleaned = {} for item in csv_content: if len(item)==3: # with file and line numbers cleaned[item[1]] = item[2] elif len(item)==2: cleaned[item[0]] = item[1] else: raise Exception("Bad translation in '{app}' for language '{lang}': {values}".format( app=app, lang=lang, values=repr(item).encode("utf-8") )) out.update(cleaned) return out def clear_cache(): """Clear all translation assets from :meth:`frappe.cache`""" cache = frappe.cache() cache.delete_key("langinfo") cache.delete_key("lang_full_dict") cache.delete_key("translation_assets") def get_messages_for_app(app): """Returns all messages (list) for a specified `app`""" messages = [] modules = ", ".join(['"{}"'.format(m.title().replace("_", " ")) \ for m in frappe.local.app_modules[app]]) # doctypes if modules: for name in frappe.db.sql_list("""select name from tabDocType where module in ({})""".format(modules)): messages.extend(get_messages_from_doctype(name)) # pages for name, title in frappe.db.sql("""select name, title from tabPage where module in ({})""".format(modules)): messages.append((None, title or name)) messages.extend(get_messages_from_page(name)) # reports for name in frappe.db.sql_list("""select tabReport.name from tabDocType, tabReport where tabReport.ref_doctype = tabDocType.name and tabDocType.module in ({})""".format(modules)): messages.append((None, name)) messages.extend(get_messages_from_report(name)) for i in messages: if not isinstance(i, tuple): raise Exception # app_include_files messages.extend(get_messages_from_include_files(app)) # server_messages messages.extend(get_server_messages(app)) return deduplicate_messages(messages) def get_messages_from_doctype(name): """Extract all translatable messages for a doctype. Includes labels, Python code, Javascript code, html templates""" messages = [] meta = frappe.get_meta(name) messages = [meta.name, meta.module] if meta.description: messages.append(meta.description) # translations of field labels, description and options for d in meta.get("fields"): messages.extend([d.label, d.description]) if d.fieldtype=='Select' and d.options: options = d.options.split('\n') if not "icon" in options[0]: messages.extend(options) # translations of roles for d in meta.get("permissions"): if d.role: messages.append(d.role) messages = [message for message in messages if message] messages = [('DocType: ' + name, message) for message in messages if is_translatable(message)] # extract from js, py files doctype_file_path = frappe.get_module_path(meta.module, "doctype", meta.name, meta.name) messages.extend(get_messages_from_file(doctype_file_path + ".js")) messages.extend(get_messages_from_file(doctype_file_path + "_list.js")) messages.extend(get_messages_from_file(doctype_file_path + "_list.html")) messages.extend(get_messages_from_file(doctype_file_path + "_calendar.js")) return messages def get_messages_from_page(name): """Returns all translatable strings from a :class:`frappe.core.doctype.Page`""" return _get_messages_from_page_or_report("Page", name) def get_messages_from_report(name): """Returns all translatable strings from a :class:`frappe.core.doctype.Report`""" report = frappe.get_doc("Report", name) messages = _get_messages_from_page_or_report("Report", name, frappe.db.get_value("DocType", report.ref_doctype, "module")) # TODO position here! if report.query: messages.extend([(None, message) for message in re.findall('"([^:,^"]*):', report.query) if is_translatable(message)]) messages.append((None,report.report_name)) return messages def _get_messages_from_page_or_report(doctype, name, module=None): if not module: module = frappe.db.get_value(doctype, name, "module") doc_path = frappe.get_module_path(module, doctype, name) messages = get_messages_from_file(os.path.join(doc_path, name +".py")) if os.path.exists(doc_path): for filename in os.listdir(doc_path): if filename.endswith(".js") or filename.endswith(".html"): messages += get_messages_from_file(os.path.join(doc_path, filename)) return messages def get_server_messages(app): """Extracts all translatable strings (tagged with :func:`frappe._`) from Python modules inside an app""" messages = [] for basepath, folders, files in os.walk(frappe.get_pymodule_path(app)): for dontwalk in (".git", "public", "locale"): if dontwalk in folders: folders.remove(dontwalk) for f in files: if f.endswith(".py") or f.endswith(".html") or f.endswith(".js"): messages.extend(get_messages_from_file(os.path.join(basepath, f))) return messages def get_messages_from_include_files(app_name=None): """Extracts all translatable strings from Javascript app files""" messages = [] for file in (frappe.get_hooks("app_include_js", app_name=app_name) or []) + (frappe.get_hooks("web_include_js", app_name=app_name) or []): messages.extend(get_messages_from_file(os.path.join(frappe.local.sites_path, file))) return messages def get_messages_from_file(path): """Returns a list of transatable strings from a code file :param path: path of the code file """ apps_path = get_bench_dir() if os.path.exists(path): with open(path, 'r') as sourcefile: return [(os.path.relpath(" +".join([path, str(pos)]), apps_path), message) for pos, message in extract_messages_from_code(sourcefile.read(), path.endswith(".py"))] else: return [] def extract_messages_from_code(code, is_py=False): """Extracts translatable srings from a code file :param code: code from which translatable files are to be extracted :param is_py: include messages in triple quotes e.g. `_('''message''')`""" try: code = render_include(code) except TemplateError: # Exception will occur when it encounters John Resig's microtemplating code pass messages = [] messages += [(m.start(), m.groups()[0]) for m in re.compile('_\("([^"]*)"').finditer(code)] messages += [(m.start(), m.groups()[0]) for m in re.compile("_\('([^']*)'").finditer(code)] if is_py: messages += [(m.start(), m.groups()[0]) for m in re.compile('_\("{3}([^"]*)"{3}.*\)').finditer(code)] messages = [(pos, message) for pos, message in messages if is_translatable(message)] return pos_to_line_no(messages, code) def is_translatable(m): if re.search("[a-z]", m) and not m.startswith("icon-") and not m.endswith("px") and not m.startswith("eval:"): return True return False def pos_to_line_no(messages, code): ret = [] messages = sorted(messages, key=lambda x: x[0]) newlines = [m.start() for m in re.compile('\\n').finditer(code)] line = 1 newline_i = 0 for pos, message in messages: while newline_i < len(newlines) and pos > newlines[newline_i]: line+=1 newline_i+= 1 ret.append((line, message)) return ret def read_csv_file(path): """Read CSV file and return as list of list :param path: File path""" from csv import reader with codecs.open(path, 'r', 'utf-8') as msgfile: data = msgfile.read() # for japanese! #wtf data = data.replace(chr(28), "").replace(chr(29), "") data = reader([r.encode('utf-8') for r in data.splitlines()]) newdata = [[unicode(val, 'utf-8') for val in row] for row in data] return newdata def write_csv_file(path, app_messages, lang_dict): """Write translation CSV file. :param path: File path, usually `[app]/translations`. :param app_messages: Translatable strings for this app. :param lang_dict: Full translated dict. """ app_messages.sort() from csv import writer with open(path, 'wb') as msgfile: w = writer(msgfile, lineterminator='\n') for p, m in app_messages: t = lang_dict.get(m, '') # strip whitespaces t = re.sub('{\s?([0-9]+)\s?}', "{\g<1>}", t) w.writerow([p.encode('utf-8') if p else '', m.encode('utf-8'), t.encode('utf-8')]) def get_untranslated(lang, untranslated_file, get_all=False): """Returns all untranslated strings for a language and writes in a file :param lang: Language code. :param untranslated_file: Output file path. :param get_all: Return all strings, translated or not.""" clear_cache() apps = frappe.get_all_apps(True) messages = [] untranslated = [] for app in apps: messages.extend(get_messages_for_app(app)) messages = deduplicate_messages(messages) def escape_newlines(s): return (s.replace("\\\n", "|||||") .replace("\\n", "||||") .replace("\n", "|||")) if get_all: print str(len(messages)) + " messages" with open(untranslated_file, "w") as f: for m in messages: # replace \n with ||| so that internal linebreaks don't get split f.write((escape_newlines(m[1]) + os.linesep).encode("utf-8")) else: full_dict = get_full_dict(lang) for m in messages: if not full_dict.get(m[1]): untranslated.append(m[1]) if untranslated: print str(len(untranslated)) + " missing translations of " + str(len(messages)) with open(untranslated_file, "w") as f: for m in untranslated: # replace \n with ||| so that internal linebreaks don't get split f.write((escape_newlines(m) + os.linesep).encode("utf-8")) else: print "all translated!" def update_translations(lang, untranslated_file, translated_file): """Update translations from a source and target file for a given language. :param lang: Language code (e.g. `en`). :param untranslated_file: File path with the messages in English. :param translated_file: File path with messages in language to be updated.""" clear_cache() full_dict = get_full_dict(lang) def restore_newlines(s): return (s.replace("|||||", "\\\n") .replace("| | | | |", "\\\n") .replace("||||", "\\n") .replace("| | | |", "\\n") .replace("|||", "\n") .replace("| | |", "\n")) translation_dict = {} for key, value in zip(frappe.get_file_items(untranslated_file, ignore_empty_lines=False), frappe.get_file_items(translated_file, ignore_empty_lines=False)): # undo hack in get_untranslated translation_dict[restore_newlines(key)] = restore_newlines(value) full_dict.update(translation_dict) for app in frappe.get_all_apps(True): write_translations_file(app, lang, full_dict) def rebuild_all_translation_files(): """Rebuild all translation files: `[app]/translations/[lang].csv`.""" for lang in get_all_languages(): for app in frappe.get_all_apps(): write_translations_file(app, lang) def write_translations_file(app, lang, full_dict=None, app_messages=None): """Write a translation file for a given language. :param app: `app` for which translations are to be written. :param lang: Language code. :param full_dict: Full translated langauge dict (optional). :param app_messages: Source strings (optional). """ if not app_messages: app_messages = get_messages_for_app(app) if not app_messages: return tpath = frappe.get_pymodule_path(app, "translations") frappe.create_folder(tpath) write_csv_file(os.path.join(tpath, lang + ".csv"), app_messages, full_dict or get_full_dict(lang)) def send_translations(translation_dict): """Append translated dict in `frappe.local.response`""" if "__messages" not in frappe.local.response: frappe.local.response["__messages"] = {} frappe.local.response["__messages"].update(translation_dict) def deduplicate_messages(messages): ret = [] op = operator.itemgetter(1) messages = sorted(messages, key=op) for k, g in itertools.groupby(messages, op): ret.append(g.next()) return ret def get_bench_dir(): return os.path.join(frappe.__file__, '..', '..', '..', '..')
mit
[ 3, 1898, 334, 67, 9, 6900, 12, 481, 5034, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 10697, 844, 14, 1666, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 624, 199, 198, 9098, 14, 5275, 199, 198, 9753, 421, 198, 18483, 7249, 367, 6950, 199, 624, 199, 199, 646, 6950, 12, 747, 12, 295, 12, 6010, 12, 2022, 199, 504, 6950, 14, 1208, 14, 12264, 492, 3795, 63, 2613, 199, 504, 10321, 18, 492, 5458, 547, 199, 646, 7975, 12, 4182, 199, 199, 318, 9519, 63, 3671, 8, 4159, 63, 6021, 304, 199, 198, 624, 1084, 658, 9098, 14, 1832, 14, 4159, 64, 687, 3101, 2323, 737, 9608, 402, 1056, 624, 199, 198, 692, 440, 6339, 63, 6021, 26, 507, 198, 1107, 6950, 14, 1832, 14, 4159, 421, 198, 11636, 275, 488, 199, 198, 4159, 63, 513, 275, 664, 63, 452, 63, 13209, 342, 503, 942, 421, 198, 509, 634, 315, 6339, 63, 6021, 26, 507, 198, 600, 275, 634, 14, 1913, 342, 507, 198, 692, 1233, 315, 6339, 63, 513, 503, 1233, 508, 298, 287, 582, 686, 198, 11636, 275, 1233, 686, 198, 4785, 2742, 198, 3, 1104, 340, 1676, 2637, 334, 541, 9, 365, 3272, 12, 340, 9854, 334, 541, 13, 7184, 9, 507, 198, 692, 17155, 315, 1233, 26, 686, 198, 600, 275, 1233, 14, 1294, 6096, 9981, 16, 61, 686, 198, 692, 1233, 315, 6339, 63, 513, 26, 1585, 198, 11636, 275, 1233, 1585, 198, 4785, 421, 198, 1107, 9519, 503, 6950, 14, 1832, 14, 4159, 199, 199, 318, 664, 63, 751, 63, 4159, 8, 751, 29, 403, 304, 199, 198, 624, 1084, 6950, 14, 1832, 14, 4159, 687, 922, 23453, 641, 2351, 9608, 503, 522, 15052, 624, 199, 198, 692, 440, 922, 26, 507, 198, 751, 275, 6950, 14, 1730, 14, 751, 421, 198, 3, 4799, 2581, 199, 198, 4159, 275, 6950, 14, 1637, 1252, 72, 362, 480, 4159, 401, 922, 9, 421, 198, 692, 440, 6339, 26, 2742, 198, 3, 340, 3247, 315, 922, 4690, 507, 198, 751, 63, 4159, 275, 6950, 14, 697, 14, 362, 63, 585, 480, 1899, 401, 922, 12, 298, 3671, 531, 507, 198, 692, 922, 63, 4159, 436, 922, 63, 4159, 1, 628, 19236, 1396, 582, 686, 198, 4159, 275, 664, 63, 4159, 63, 807, 1252, 362, 8, 751, 63, 4159, 9, 503, 6950, 14, 1832, 14, 4159, 507, 198, 2836, 26, 686, 198, 885, 63, 4159, 275, 6950, 14, 697, 14, 362, 63, 885, 480, 4159, 531, 686, 198, 4159, 275, 849, 63, 4159, 503, 6950, 14, 1832, 14, 4159, 2742, 198, 9098, 14, 1637, 1252, 72, 409, 480, 4159, 401, 922, 12, 6339, 503, 298, 287, 531, 421, 198, 1107, 6339, 199, 199, 318, 663, 63, 885, 63, 3671, 8, 3671, 304, 199, 198, 624, 1084, 13641, 849, 2637, 624, 199, 198, 4159, 275, 664, 63, 4159, 63, 807, 3430, 3671, 61, 199, 198, 9098, 14, 697, 14, 409, 63, 885, 480, 4159, 401, 6339, 9, 199, 198, 9098, 14, 1832, 14, 4159, 275, 6339, 199, 199, 318, 664, 63, 452, 63, 13209, 837, 199, 198, 624, 3407, 1006, 2637, 9479, 601, 12, 682, 5423, 624, 199, 198, 1107, 359, 65, 14, 1294, 3430, 16, 61, 367, 282, 315, 664, 63, 4159, 63, 815, 5106, 199, 199, 318, 664, 63, 4159, 63, 807, 837, 199, 198, 624, 3407, 1006, 10815, 315, 1211, 1475, 12, 2615, 536, 365, 314, 790, 325, 14, 71, 14, 658, 6641, 17872, 5122, 287, 3570, 64, 624, 199, 198, 1107, 1211, 4038, 65, 59, 17, 467, 282, 59, 16, 2677, 367, 282, 315, 359, 65, 14, 1294, 8, 403, 12, 413, 9, 367, 282, 315, 664, 63, 4159, 63, 815, 342, 3934, 199, 199, 318, 664, 63, 3671, 63, 504, 63, 600, 8, 4159, 304, 199, 198, 1107, 1211, 8, 65, 14, 1294, 8, 403, 12, 413, 9, 367, 282, 315, 664, 63, 4159, 63, 815, 8801, 362, 8, 4159, 9, 199, 199, 318, 664, 63, 4159, 63, 815, 837, 199, 198, 624, 3407, 282, 769, 4541, 1015, 402, 658, 5181, 15, 13209, 14, 2424, 64, 624, 199, 198, 1107, 6950, 14, 1637, 1252, 362, 63, 585, 480, 4159, 815, 401, 507, 198, 2734, 26, 9098, 14, 362, 63, 493, 63, 1744, 8, 736, 14, 515, 14, 904, 8, 9098, 14, 1832, 14, 8619, 63, 515, 12, 298, 13209, 14, 2424, 13324, 199, 199, 318, 664, 63, 807, 8, 10279, 514, 12, 536, 29, 403, 304, 199, 198, 624, 3407, 7761, 1211, 367, 282, 730, 402, 909, 14, 2742, 520, 635, 289, 361, 514, 26, 1471, 506, 1373, 402, 658, 6356, 3559, 658, 1606, 3559, 658, 3070, 3559, 658, 2613, 3559, 658, 3596, 493, 3559, 658, 4930, 64, 507, 520, 635, 536, 26, 536, 402, 314, 2213, 367, 1314, 17202, 787, 370, 506, 2138, 14, 507, 408, 199, 198, 10279, 514, 275, 289, 361, 514, 14, 2325, 342, 199, 198, 1637, 275, 6950, 14, 1637, 342, 199, 198, 6562, 63, 498, 275, 289, 361, 514, 435, 14725, 435, 334, 354, 503, 3905, 531, 199, 198, 6893, 63, 12186, 275, 2581, 14, 72, 362, 480, 6893, 63, 12186, 401, 6950, 14, 1832, 14, 4159, 9, 503, 1052, 421, 198, 692, 440, 8977, 63, 498, 315, 7761, 63, 12186, 26, 507, 198, 692, 289, 361, 514, 11800, 6356, 582, 686, 198, 3431, 275, 664, 63, 3431, 63, 504, 63, 6356, 8, 354, 9, 507, 198, 4164, 289, 361, 514, 11800, 1606, 582, 686, 198, 3431, 275, 664, 63, 3431, 63, 504, 63, 1606, 8, 354, 9, 507, 198, 4164, 289, 361, 514, 11800, 3070, 582, 686, 198, 3431, 275, 664, 63, 3431, 63, 504, 63, 3070, 8, 354, 9, 507, 198, 4164, 289, 361, 514, 11800, 2613, 582, 686, 198, 3431, 275, 664, 63, 3431, 63, 504, 63, 2613, 63, 1725, 342, 507, 198, 4164, 289, 361, 514, 11800, 3596, 493, 582, 686, 198, 3431, 275, 664, 63, 3431, 63, 504, 63, 493, 8, 354, 9, 507, 198, 4164, 289, 361, 514, 11800, 4930, 582, 686, 198, 3431, 275, 664, 63, 3431, 63, 504, 63, 2613, 63, 1725, 342, 686, 198, 3431, 847, 6950, 14, 697, 14, 3009, 480, 2416, 283 ]
[ 1898, 334, 67, 9, 6900, 12, 481, 5034, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 10697, 844, 14, 1666, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 624, 199, 198, 9098, 14, 5275, 199, 198, 9753, 421, 198, 18483, 7249, 367, 6950, 199, 624, 199, 199, 646, 6950, 12, 747, 12, 295, 12, 6010, 12, 2022, 199, 504, 6950, 14, 1208, 14, 12264, 492, 3795, 63, 2613, 199, 504, 10321, 18, 492, 5458, 547, 199, 646, 7975, 12, 4182, 199, 199, 318, 9519, 63, 3671, 8, 4159, 63, 6021, 304, 199, 198, 624, 1084, 658, 9098, 14, 1832, 14, 4159, 64, 687, 3101, 2323, 737, 9608, 402, 1056, 624, 199, 198, 692, 440, 6339, 63, 6021, 26, 507, 198, 1107, 6950, 14, 1832, 14, 4159, 421, 198, 11636, 275, 488, 199, 198, 4159, 63, 513, 275, 664, 63, 452, 63, 13209, 342, 503, 942, 421, 198, 509, 634, 315, 6339, 63, 6021, 26, 507, 198, 600, 275, 634, 14, 1913, 342, 507, 198, 692, 1233, 315, 6339, 63, 513, 503, 1233, 508, 298, 287, 582, 686, 198, 11636, 275, 1233, 686, 198, 4785, 2742, 198, 3, 1104, 340, 1676, 2637, 334, 541, 9, 365, 3272, 12, 340, 9854, 334, 541, 13, 7184, 9, 507, 198, 692, 17155, 315, 1233, 26, 686, 198, 600, 275, 1233, 14, 1294, 6096, 9981, 16, 61, 686, 198, 692, 1233, 315, 6339, 63, 513, 26, 1585, 198, 11636, 275, 1233, 1585, 198, 4785, 421, 198, 1107, 9519, 503, 6950, 14, 1832, 14, 4159, 199, 199, 318, 664, 63, 751, 63, 4159, 8, 751, 29, 403, 304, 199, 198, 624, 1084, 6950, 14, 1832, 14, 4159, 687, 922, 23453, 641, 2351, 9608, 503, 522, 15052, 624, 199, 198, 692, 440, 922, 26, 507, 198, 751, 275, 6950, 14, 1730, 14, 751, 421, 198, 3, 4799, 2581, 199, 198, 4159, 275, 6950, 14, 1637, 1252, 72, 362, 480, 4159, 401, 922, 9, 421, 198, 692, 440, 6339, 26, 2742, 198, 3, 340, 3247, 315, 922, 4690, 507, 198, 751, 63, 4159, 275, 6950, 14, 697, 14, 362, 63, 585, 480, 1899, 401, 922, 12, 298, 3671, 531, 507, 198, 692, 922, 63, 4159, 436, 922, 63, 4159, 1, 628, 19236, 1396, 582, 686, 198, 4159, 275, 664, 63, 4159, 63, 807, 1252, 362, 8, 751, 63, 4159, 9, 503, 6950, 14, 1832, 14, 4159, 507, 198, 2836, 26, 686, 198, 885, 63, 4159, 275, 6950, 14, 697, 14, 362, 63, 885, 480, 4159, 531, 686, 198, 4159, 275, 849, 63, 4159, 503, 6950, 14, 1832, 14, 4159, 2742, 198, 9098, 14, 1637, 1252, 72, 409, 480, 4159, 401, 922, 12, 6339, 503, 298, 287, 531, 421, 198, 1107, 6339, 199, 199, 318, 663, 63, 885, 63, 3671, 8, 3671, 304, 199, 198, 624, 1084, 13641, 849, 2637, 624, 199, 198, 4159, 275, 664, 63, 4159, 63, 807, 3430, 3671, 61, 199, 198, 9098, 14, 697, 14, 409, 63, 885, 480, 4159, 401, 6339, 9, 199, 198, 9098, 14, 1832, 14, 4159, 275, 6339, 199, 199, 318, 664, 63, 452, 63, 13209, 837, 199, 198, 624, 3407, 1006, 2637, 9479, 601, 12, 682, 5423, 624, 199, 198, 1107, 359, 65, 14, 1294, 3430, 16, 61, 367, 282, 315, 664, 63, 4159, 63, 815, 5106, 199, 199, 318, 664, 63, 4159, 63, 807, 837, 199, 198, 624, 3407, 1006, 10815, 315, 1211, 1475, 12, 2615, 536, 365, 314, 790, 325, 14, 71, 14, 658, 6641, 17872, 5122, 287, 3570, 64, 624, 199, 198, 1107, 1211, 4038, 65, 59, 17, 467, 282, 59, 16, 2677, 367, 282, 315, 359, 65, 14, 1294, 8, 403, 12, 413, 9, 367, 282, 315, 664, 63, 4159, 63, 815, 342, 3934, 199, 199, 318, 664, 63, 3671, 63, 504, 63, 600, 8, 4159, 304, 199, 198, 1107, 1211, 8, 65, 14, 1294, 8, 403, 12, 413, 9, 367, 282, 315, 664, 63, 4159, 63, 815, 8801, 362, 8, 4159, 9, 199, 199, 318, 664, 63, 4159, 63, 815, 837, 199, 198, 624, 3407, 282, 769, 4541, 1015, 402, 658, 5181, 15, 13209, 14, 2424, 64, 624, 199, 198, 1107, 6950, 14, 1637, 1252, 362, 63, 585, 480, 4159, 815, 401, 507, 198, 2734, 26, 9098, 14, 362, 63, 493, 63, 1744, 8, 736, 14, 515, 14, 904, 8, 9098, 14, 1832, 14, 8619, 63, 515, 12, 298, 13209, 14, 2424, 13324, 199, 199, 318, 664, 63, 807, 8, 10279, 514, 12, 536, 29, 403, 304, 199, 198, 624, 3407, 7761, 1211, 367, 282, 730, 402, 909, 14, 2742, 520, 635, 289, 361, 514, 26, 1471, 506, 1373, 402, 658, 6356, 3559, 658, 1606, 3559, 658, 3070, 3559, 658, 2613, 3559, 658, 3596, 493, 3559, 658, 4930, 64, 507, 520, 635, 536, 26, 536, 402, 314, 2213, 367, 1314, 17202, 787, 370, 506, 2138, 14, 507, 408, 199, 198, 10279, 514, 275, 289, 361, 514, 14, 2325, 342, 199, 198, 1637, 275, 6950, 14, 1637, 342, 199, 198, 6562, 63, 498, 275, 289, 361, 514, 435, 14725, 435, 334, 354, 503, 3905, 531, 199, 198, 6893, 63, 12186, 275, 2581, 14, 72, 362, 480, 6893, 63, 12186, 401, 6950, 14, 1832, 14, 4159, 9, 503, 1052, 421, 198, 692, 440, 8977, 63, 498, 315, 7761, 63, 12186, 26, 507, 198, 692, 289, 361, 514, 11800, 6356, 582, 686, 198, 3431, 275, 664, 63, 3431, 63, 504, 63, 6356, 8, 354, 9, 507, 198, 4164, 289, 361, 514, 11800, 1606, 582, 686, 198, 3431, 275, 664, 63, 3431, 63, 504, 63, 1606, 8, 354, 9, 507, 198, 4164, 289, 361, 514, 11800, 3070, 582, 686, 198, 3431, 275, 664, 63, 3431, 63, 504, 63, 3070, 8, 354, 9, 507, 198, 4164, 289, 361, 514, 11800, 2613, 582, 686, 198, 3431, 275, 664, 63, 3431, 63, 504, 63, 2613, 63, 1725, 342, 507, 198, 4164, 289, 361, 514, 11800, 3596, 493, 582, 686, 198, 3431, 275, 664, 63, 3431, 63, 504, 63, 493, 8, 354, 9, 507, 198, 4164, 289, 361,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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 ]
glaubitz/fs-uae-debian
launcher/OpenGL/GLES2/EXT/occlusion_query_boolean.py
8
1111
'''OpenGL extension EXT.occlusion_query_boolean This module customises the behaviour of the OpenGL.raw.GLES2.EXT.occlusion_query_boolean to provide a more Python-friendly API The official definition of this extension is available here: http://www.opengl.org/registry/specs/EXT/occlusion_query_boolean.txt ''' from OpenGL import platform, constant, arrays from OpenGL import extensions, wrapper import ctypes from OpenGL.raw.GLES2 import _types, _glgets from OpenGL.raw.GLES2.EXT.occlusion_query_boolean import * from OpenGL.raw.GLES2.EXT.occlusion_query_boolean import _EXTENSION_NAME def glInitOcclusionQueryBooleanEXT(): '''Return boolean indicating whether this extension is available''' from OpenGL import extensions return extensions.hasGLExtension( _EXTENSION_NAME ) # INPUT glGenQueriesEXT.ids size not checked against n glGenQueriesEXT=wrapper.wrapper(glGenQueriesEXT).setInputArraySize( 'ids', None ) # INPUT glDeleteQueriesEXT.ids size not checked against n glDeleteQueriesEXT=wrapper.wrapper(glDeleteQueriesEXT).setInputArraySize( 'ids', None ) ### END AUTOGENERATED SECTION
gpl-2.0
[ 2344, 4299, 2226, 3329, 20203, 14, 679, 10248, 63, 1131, 63, 4871, 199, 199, 2765, 859, 3537, 1388, 314, 13942, 402, 314, 221, 199, 4299, 2226, 14, 1773, 14, 2226, 654, 18, 14, 2472, 14, 679, 10248, 63, 1131, 63, 4871, 370, 5647, 282, 1655, 221, 199, 4718, 13, 17317, 3261, 199, 199, 1918, 25410, 5492, 402, 642, 3329, 365, 2808, 2348, 26, 199, 1014, 921, 1544, 14, 32477, 14, 1308, 15, 5189, 15, 7273, 15, 2472, 15, 679, 10248, 63, 1131, 63, 4871, 14, 2424, 199, 2344, 199, 504, 24374, 492, 4298, 12, 4413, 12, 6572, 199, 504, 24374, 492, 5478, 12, 4975, 199, 646, 5577, 199, 504, 24374, 14, 1773, 14, 2226, 654, 18, 492, 485, 1313, 12, 485, 3528, 24894, 199, 504, 24374, 14, 1773, 14, 2226, 654, 18, 14, 2472, 14, 679, 10248, 63, 1131, 63, 4871, 492, 627, 199, 504, 24374, 14, 1773, 14, 2226, 654, 18, 14, 2472, 14, 679, 10248, 63, 1131, 63, 4871, 492, 485, 15498, 63, 2339, 199, 199, 318, 6482, 9346, 16184, 10248, 3227, 4082, 2472, 837, 272, 1449, 1767, 5046, 9297, 3775, 642, 3329, 365, 2808, 2344, 272, 687, 24374, 492, 5478, 272, 372, 5478, 14, 1989, 12827, 88, 724, 438, 8, 485, 15498, 63, 2339, 776, 199, 199, 3, 21955, 6482, 8168, 13611, 2472, 14, 1580, 1568, 440, 7923, 6169, 302, 199, 3528, 8168, 13611, 2472, 29, 5029, 14, 5029, 8, 3528, 8168, 13611, 2472, 680, 409, 3205, 3836, 2320, 8, 272, 283, 1580, 297, 488, 199, 9, 199, 3, 21955, 6482, 5392, 13611, 2472, 14, 1580, 1568, 440, 7923, 6169, 302, 199, 3528, 5392, 13611, 2472, 29, 5029, 14, 5029, 8, 3528, 5392, 13611, 2472, 680, 409, 3205, 3836, 2320, 8, 272, 283, 1580, 297, 488, 199, 9, 199, 5680, 7729, 25420, 12795, 6989, 29074, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4299, 2226, 3329, 20203, 14, 679, 10248, 63, 1131, 63, 4871, 199, 199, 2765, 859, 3537, 1388, 314, 13942, 402, 314, 221, 199, 4299, 2226, 14, 1773, 14, 2226, 654, 18, 14, 2472, 14, 679, 10248, 63, 1131, 63, 4871, 370, 5647, 282, 1655, 221, 199, 4718, 13, 17317, 3261, 199, 199, 1918, 25410, 5492, 402, 642, 3329, 365, 2808, 2348, 26, 199, 1014, 921, 1544, 14, 32477, 14, 1308, 15, 5189, 15, 7273, 15, 2472, 15, 679, 10248, 63, 1131, 63, 4871, 14, 2424, 199, 2344, 199, 504, 24374, 492, 4298, 12, 4413, 12, 6572, 199, 504, 24374, 492, 5478, 12, 4975, 199, 646, 5577, 199, 504, 24374, 14, 1773, 14, 2226, 654, 18, 492, 485, 1313, 12, 485, 3528, 24894, 199, 504, 24374, 14, 1773, 14, 2226, 654, 18, 14, 2472, 14, 679, 10248, 63, 1131, 63, 4871, 492, 627, 199, 504, 24374, 14, 1773, 14, 2226, 654, 18, 14, 2472, 14, 679, 10248, 63, 1131, 63, 4871, 492, 485, 15498, 63, 2339, 199, 199, 318, 6482, 9346, 16184, 10248, 3227, 4082, 2472, 837, 272, 1449, 1767, 5046, 9297, 3775, 642, 3329, 365, 2808, 2344, 272, 687, 24374, 492, 5478, 272, 372, 5478, 14, 1989, 12827, 88, 724, 438, 8, 485, 15498, 63, 2339, 776, 199, 199, 3, 21955, 6482, 8168, 13611, 2472, 14, 1580, 1568, 440, 7923, 6169, 302, 199, 3528, 8168, 13611, 2472, 29, 5029, 14, 5029, 8, 3528, 8168, 13611, 2472, 680, 409, 3205, 3836, 2320, 8, 272, 283, 1580, 297, 488, 199, 9, 199, 3, 21955, 6482, 5392, 13611, 2472, 14, 1580, 1568, 440, 7923, 6169, 302, 199, 3528, 5392, 13611, 2472, 29, 5029, 14, 5029, 8, 3528, 5392, 13611, 2472, 680, 409, 3205, 3836, 2320, 8, 272, 283, 1580, 297, 488, 199, 9, 199, 5680, 7729, 25420, 12795, 6989, 29074, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
pongem/python-bot-project
appengine/standard/botapp/env/lib/python2.7/site-packages/pip/_vendor/html5lib/treewalkers/genshi.py
508
2309
from __future__ import absolute_import, division, unicode_literals from genshi.core import QName from genshi.core import START, END, XML_NAMESPACE, DOCTYPE, TEXT from genshi.core import START_NS, END_NS, START_CDATA, END_CDATA, PI, COMMENT from . import base from ..constants import voidElements, namespaces class TreeWalker(base.TreeWalker): def __iter__(self): # Buffer the events so we can pass in the following one previous = None for event in self.tree: if previous is not None: for token in self.tokens(previous, event): yield token previous = event # Don't forget the final event! if previous is not None: for token in self.tokens(previous, None): yield token def tokens(self, event, next): kind, data, _ = event if kind == START: tag, attribs = data name = tag.localname namespace = tag.namespace converted_attribs = {} for k, v in attribs: if isinstance(k, QName): converted_attribs[(k.namespace, k.localname)] = v else: converted_attribs[(None, k)] = v if namespace == namespaces["html"] and name in voidElements: for token in self.emptyTag(namespace, name, converted_attribs, not next or next[0] != END or next[1] != tag): yield token else: yield self.startTag(namespace, name, converted_attribs) elif kind == END: name = data.localname namespace = data.namespace if namespace != namespaces["html"] or name not in voidElements: yield self.endTag(namespace, name) elif kind == COMMENT: yield self.comment(data) elif kind == TEXT: for token in self.text(data): yield token elif kind == DOCTYPE: yield self.doctype(*data) elif kind in (XML_NAMESPACE, DOCTYPE, START_NS, END_NS, START_CDATA, END_CDATA, PI): pass else: yield self.unknown(kind)
apache-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 199, 504, 3805, 19377, 14, 1018, 492, 1413, 985, 199, 504, 3805, 19377, 14, 1018, 492, 13910, 12, 7729, 12, 4692, 63, 13001, 12, 3506, 7540, 12, 11951, 199, 504, 3805, 19377, 14, 1018, 492, 13910, 63, 2709, 12, 7729, 63, 2709, 12, 13910, 63, 14049, 12, 7729, 63, 14049, 12, 16678, 12, 25071, 199, 199, 504, 1275, 492, 1300, 199, 199, 504, 2508, 5559, 492, 2309, 6255, 12, 10747, 421, 199, 533, 12178, 26020, 8, 1095, 14, 3987, 26020, 304, 272, 347, 636, 1661, 721, 277, 304, 267, 327, 26661, 314, 4474, 880, 781, 883, 986, 315, 314, 2569, 1373, 267, 4136, 275, 488, 267, 367, 1566, 315, 291, 14, 2350, 26, 288, 340, 4136, 365, 440, 488, 26, 355, 367, 1526, 315, 291, 14, 4504, 8, 6352, 12, 1566, 304, 490, 1995, 1526, 288, 4136, 275, 1566, 398, 327, 7529, 1133, 19459, 314, 4242, 1566, 1, 267, 340, 4136, 365, 440, 488, 26, 288, 367, 1526, 315, 291, 14, 4504, 8, 6352, 12, 488, 304, 355, 1995, 1526, 339, 347, 4645, 8, 277, 12, 1566, 12, 2163, 304, 267, 4928, 12, 666, 12, 485, 275, 1566, 267, 340, 4928, 508, 13910, 26, 288, 1947, 12, 737, 19577, 275, 666, 288, 536, 275, 1947, 14, 1832, 354, 288, 3231, 275, 1947, 14, 3251, 288, 6702, 63, 30674, 275, 1052, 288, 367, 1022, 12, 373, 315, 737, 19577, 26, 355, 340, 1228, 8, 75, 12, 1413, 985, 304, 490, 6702, 63, 30674, 7528, 75, 14, 3251, 12, 1022, 14, 1832, 354, 1874, 275, 373, 355, 587, 26, 490, 6702, 63, 30674, 7528, 403, 12, 1022, 1874, 275, 373, 953, 340, 3231, 508, 10747, 905, 1360, 937, 436, 536, 315, 2309, 6255, 26, 355, 367, 1526, 315, 291, 14, 1667, 1931, 8, 3251, 12, 536, 12, 6702, 63, 30674, 12, 5644, 440, 2163, 503, 2163, 59, 16, 61, 1137, 7729, 503, 5644, 2163, 59, 17, 61, 1137, 1947, 304, 490, 1995, 1526, 288, 587, 26, 355, 1995, 291, 14, 16252, 8, 3251, 12, 536, 12, 6702, 63, 30674, 9, 398, 916, 4928, 508, 7729, 26, 288, 536, 275, 666, 14, 1832, 354, 288, 3231, 275, 666, 14, 3251, 288, 340, 3231, 1137, 10747, 905, 1360, 937, 503, 536, 440, 315, 2309, 6255, 26, 355, 1995, 291, 14, 18755, 8, 3251, 12, 536, 9, 398, 916, 4928, 508, 25071, 26, 288, 1995, 291, 14, 3349, 8, 576, 9, 398, 916, 4928, 508, 11951, 26, 288, 367, 1526, 315, 291, 14, 505, 8, 576, 304, 355, 1995, 1526, 398, 916, 4928, 508, 3506, 7540, 26, 288, 1995, 291, 14, 6356, 2031, 576, 9, 398, 916, 4928, 315, 334, 4317, 63, 13001, 12, 3506, 7540, 12, 13910, 63, 2709, 12, 7729, 63, 2709, 12, 1993, 13910, 63, 14049, 12, 7729, 63, 14049, 12, 16678, 304, 288, 986, 398, 587, 26, 288, 1995, 291, 14, 5187, 8, 5091, 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 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 199, 504, 3805, 19377, 14, 1018, 492, 1413, 985, 199, 504, 3805, 19377, 14, 1018, 492, 13910, 12, 7729, 12, 4692, 63, 13001, 12, 3506, 7540, 12, 11951, 199, 504, 3805, 19377, 14, 1018, 492, 13910, 63, 2709, 12, 7729, 63, 2709, 12, 13910, 63, 14049, 12, 7729, 63, 14049, 12, 16678, 12, 25071, 199, 199, 504, 1275, 492, 1300, 199, 199, 504, 2508, 5559, 492, 2309, 6255, 12, 10747, 421, 199, 533, 12178, 26020, 8, 1095, 14, 3987, 26020, 304, 272, 347, 636, 1661, 721, 277, 304, 267, 327, 26661, 314, 4474, 880, 781, 883, 986, 315, 314, 2569, 1373, 267, 4136, 275, 488, 267, 367, 1566, 315, 291, 14, 2350, 26, 288, 340, 4136, 365, 440, 488, 26, 355, 367, 1526, 315, 291, 14, 4504, 8, 6352, 12, 1566, 304, 490, 1995, 1526, 288, 4136, 275, 1566, 398, 327, 7529, 1133, 19459, 314, 4242, 1566, 1, 267, 340, 4136, 365, 440, 488, 26, 288, 367, 1526, 315, 291, 14, 4504, 8, 6352, 12, 488, 304, 355, 1995, 1526, 339, 347, 4645, 8, 277, 12, 1566, 12, 2163, 304, 267, 4928, 12, 666, 12, 485, 275, 1566, 267, 340, 4928, 508, 13910, 26, 288, 1947, 12, 737, 19577, 275, 666, 288, 536, 275, 1947, 14, 1832, 354, 288, 3231, 275, 1947, 14, 3251, 288, 6702, 63, 30674, 275, 1052, 288, 367, 1022, 12, 373, 315, 737, 19577, 26, 355, 340, 1228, 8, 75, 12, 1413, 985, 304, 490, 6702, 63, 30674, 7528, 75, 14, 3251, 12, 1022, 14, 1832, 354, 1874, 275, 373, 355, 587, 26, 490, 6702, 63, 30674, 7528, 403, 12, 1022, 1874, 275, 373, 953, 340, 3231, 508, 10747, 905, 1360, 937, 436, 536, 315, 2309, 6255, 26, 355, 367, 1526, 315, 291, 14, 1667, 1931, 8, 3251, 12, 536, 12, 6702, 63, 30674, 12, 5644, 440, 2163, 503, 2163, 59, 16, 61, 1137, 7729, 503, 5644, 2163, 59, 17, 61, 1137, 1947, 304, 490, 1995, 1526, 288, 587, 26, 355, 1995, 291, 14, 16252, 8, 3251, 12, 536, 12, 6702, 63, 30674, 9, 398, 916, 4928, 508, 7729, 26, 288, 536, 275, 666, 14, 1832, 354, 288, 3231, 275, 666, 14, 3251, 288, 340, 3231, 1137, 10747, 905, 1360, 937, 503, 536, 440, 315, 2309, 6255, 26, 355, 1995, 291, 14, 18755, 8, 3251, 12, 536, 9, 398, 916, 4928, 508, 25071, 26, 288, 1995, 291, 14, 3349, 8, 576, 9, 398, 916, 4928, 508, 11951, 26, 288, 367, 1526, 315, 291, 14, 505, 8, 576, 304, 355, 1995, 1526, 398, 916, 4928, 508, 3506, 7540, 26, 288, 1995, 291, 14, 6356, 2031, 576, 9, 398, 916, 4928, 315, 334, 4317, 63, 13001, 12, 3506, 7540, 12, 13910, 63, 2709, 12, 7729, 63, 2709, 12, 1993, 13910, 63, 14049, 12, 7729, 63, 14049, 12, 16678, 304, 288, 986, 398, 587, 26, 288, 1995, 291, 14, 5187, 8, 5091, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
guewen/stock-logistics-tracking
__unported__/stock_inventory_sequence/inventory.py
4
1324
# -*- coding: utf-8 -*- ################################################################################# # # OpenERP, Open Source Management Solution # Copyright (C) 2011 Julius Network Solutions SARL <contact@julius.fr> # # 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/>. # ################################################################################# from openerp.osv import fields, osv, orm from openerp.tools.translate import _ class stock_inventory(orm.Model): _inherit = 'stock.inventory' _defaults = { 'name': lambda x, y, z, c: x.pool.get('ir.sequence').next_by_code(y, z, 'stock.inventory') or '/' } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 327, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 13289, 3, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 7760, 1603, 13987, 527, 7220, 17991, 8653, 428, 689, 44, 665, 7811, 32, 74, 13987, 527, 14, 4391, 30, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 13289, 3, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 12, 9813, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 533, 10952, 63, 7212, 8, 1025, 14, 1685, 304, 272, 485, 6486, 275, 283, 6088, 14, 7212, 7, 272, 485, 4322, 275, 469, 267, 283, 354, 356, 2400, 671, 12, 612, 12, 1315, 12, 286, 26, 671, 14, 2293, 14, 362, 360, 723, 14, 4041, 1959, 2184, 63, 991, 63, 600, 8, 89, 12, 1315, 12, 283, 6088, 14, 7212, 358, 503, 7324, 272, 789, 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, 13289, 3, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 7760, 1603, 13987, 527, 7220, 17991, 8653, 428, 689, 44, 665, 7811, 32, 74, 13987, 527, 14, 4391, 30, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 13289, 3, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 12, 9813, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 533, 10952, 63, 7212, 8, 1025, 14, 1685, 304, 272, 485, 6486, 275, 283, 6088, 14, 7212, 7, 272, 485, 4322, 275, 469, 267, 283, 354, 356, 2400, 671, 12, 612, 12, 1315, 12, 286, 26, 671, 14, 2293, 14, 362, 360, 723, 14, 4041, 1959, 2184, 63, 991, 63, 600, 8, 89, 12, 1315, 12, 283, 6088, 14, 7212, 358, 503, 7324, 272, 789, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
cewood/ansible
lib/ansible/compat/tests/mock.py
258
1241
# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type ''' Compat module for Python3.x's unittest.mock module ''' # Python 2.7 # Note: Could use the pypi mock library on python3.x as well as python2.x. It # is the same as the python3 stdlib mock library try: from unittest.mock import * except ImportError: # Python 2 try: from mock import * except ImportError: print('You need the mock library installed on python2.x to run tests')
gpl-3.0
[ 3, 334, 67, 9, 6927, 12, 4005, 609, 2308, 1804, 300, 4188, 73, 665, 2663, 300, 4188, 73, 32, 4853, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 2344, 199, 2404, 292, 859, 367, 2018, 19, 14, 88, 1159, 2882, 14, 1805, 859, 199, 2344, 199, 199, 3, 2018, 499, 14, 23, 199, 199, 3, 3390, 26, 18615, 675, 314, 1134, 1038, 1683, 3555, 641, 2366, 19, 14, 88, 465, 5521, 465, 2366, 18, 14, 88, 14, 221, 2779, 199, 3, 365, 314, 2011, 465, 314, 2366, 19, 26678, 1683, 3555, 199, 199, 893, 26, 272, 687, 2882, 14, 1805, 492, 627, 199, 2590, 3545, 26, 272, 327, 2018, 499, 272, 862, 26, 267, 687, 1683, 492, 627, 272, 871, 3545, 26, 267, 870, 360, 5556, 1929, 314, 1683, 3555, 4903, 641, 2366, 18, 14, 88, 370, 1255, 2295, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 334, 67, 9, 6927, 12, 4005, 609, 2308, 1804, 300, 4188, 73, 665, 2663, 300, 4188, 73, 32, 4853, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 2344, 199, 2404, 292, 859, 367, 2018, 19, 14, 88, 1159, 2882, 14, 1805, 859, 199, 2344, 199, 199, 3, 2018, 499, 14, 23, 199, 199, 3, 3390, 26, 18615, 675, 314, 1134, 1038, 1683, 3555, 641, 2366, 19, 14, 88, 465, 5521, 465, 2366, 18, 14, 88, 14, 221, 2779, 199, 3, 365, 314, 2011, 465, 314, 2366, 19, 26678, 1683, 3555, 199, 199, 893, 26, 272, 687, 2882, 14, 1805, 492, 627, 199, 2590, 3545, 26, 272, 327, 2018, 499, 272, 862, 26, 267, 687, 1683, 492, 627, 272, 871, 3545, 26, 267, 870, 360, 5556, 1929, 314, 1683, 3555, 4903, 641, 2366, 18, 14, 88, 370, 1255, 2295, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
dahlstrom-g/intellij-community
python/helpers/py2only/docutils/writers/xetex/__init__.py
86
5230
#!/usr/bin/env python # -*- coding: utf-8 -*- # :Author: Günter Milde <milde@users.sourceforge.net> # :Revision: $Revision: 7668 $ # :Date: $Date: 2013-06-04 14:46:30 +0200 (Die, 04. Jun 2013) $ # :Copyright: © 2010 Günter Milde. # :License: Released under the terms of the `2-Clause BSD license`_, in short: # # Copying and distribution of this file, with or without modification, # are permitted in any medium without royalty provided the copyright # notice and this notice are preserved. # This file is offered as-is, without any warranty. # # .. _2-Clause BSD license: http://www.spdx.org/licenses/BSD-2-Clause """ XeLaTeX document tree Writer. A variant of Docutils' standard 'latex2e' writer producing output suited for processing with XeLaTeX (http://tug.org/xetex/). """ __docformat__ = 'reStructuredText' import os import os.path import re import docutils from docutils import frontend, nodes, utils, writers, languages from docutils.writers import latex2e class Writer(latex2e.Writer): """A writer for Unicode-based LaTeX variants (XeTeX, LuaTeX)""" supported = ('xetex','xelatex','luatex') """Formats this writer supports.""" default_template = 'xelatex.tex' default_preamble = '\n'.join([ r'% Linux Libertine (free, wide coverage, not only for Linux)', r'\setmainfont{Linux Libertine O}', r'\setsansfont{Linux Biolinum O}', r'\setmonofont[HyphenChar=None,Scale=MatchLowercase]{DejaVu Sans Mono}', ]) config_section = 'xetex writer' config_section_dependencies = ('writers', 'latex2e writer') settings_spec = frontend.filter_settings_spec( latex2e.Writer.settings_spec, 'font_encoding', template=('Template file. Default: "%s".' % default_template, ['--template'], {'default': default_template, 'metavar': '<file>'}), latex_preamble=('Customization by LaTeX code in the preamble. ' 'Default: select PDF standard fonts (Times, Helvetica, Courier).', ['--latex-preamble'], {'default': default_preamble}), ) def __init__(self): latex2e.Writer.__init__(self) self.settings_defaults.update({'fontencoding': ''}) # use default (EU1 or EU2) self.translator_class = XeLaTeXTranslator class Babel(latex2e.Babel): """Language specifics for XeTeX. Use `polyglossia` instead of `babel` and adapt settings. """ language_codes = latex2e.Babel.language_codes.copy() # Additionally supported or differently named languages: language_codes.update({ # code Polyglossia-name comment 'cop': 'coptic', 'de': 'german', # new spelling (de_1996) 'de-1901': 'ogerman', # old spelling 'dv': 'divehi', # Maldivian 'dsb': 'lsorbian', 'el-polyton': 'polygreek', 'fa': 'farsi', 'grc': 'ancientgreek', 'hsb': 'usorbian', 'sh-Cyrl': 'serbian', # Serbo-Croatian, Cyrillic script 'sh-Latn': 'croatian', # Serbo-Croatian, Latin script 'sq': 'albanian', 'sr': 'serbian', # Cyrillic script (sr-Cyrl) 'th': 'thai', 'vi': 'vietnamese', # zh-Latn: ??? # Chinese Pinyin }) # normalize (downcase) keys language_codes = dict([(k.lower(), v) for (k,v) in language_codes.items()]) # Languages without Polyglossia support: for key in ('af', # 'afrikaans', 'de-AT', # 'naustrian', 'de-AT-1901', # 'austrian', 'fr-CA', # 'canadien', 'grc-ibycus', # 'ibycus', (Greek Ibycus encoding) 'sr-Latn', # 'serbian script=latin' ): del(language_codes[key.lower()]) def __init__(self, language_code, reporter): self.language_code = language_code self.reporter = reporter self.language = self.language_name(language_code) self.otherlanguages = {} self.warn_msg = 'Language "%s" not supported by XeTeX (polyglossia).' self.quote_index = 0 self.quotes = ('"', '"') # language dependent configuration: # double quotes are "active" in some languages (e.g. German). self.literal_double_quote = u'"' # TODO: use \textquotedbl def __call__(self): setup = [r'\usepackage{polyglossia}', r'\setdefaultlanguage{%s}' % self.language] if self.otherlanguages: setup.append(r'\setotherlanguages{%s}' % ','.join(sorted(self.otherlanguages.keys()))) return '\n'.join(setup) class XeLaTeXTranslator(latex2e.LaTeXTranslator): def __init__(self, document): self.is_xetex = True # typeset with XeTeX or LuaTeX engine latex2e.LaTeXTranslator.__init__(self, document, Babel) if self.latex_encoding == 'utf8': self.requirements.pop('_inputenc', None) else: self.requirements['_inputenc'] = (r'\XeTeXinputencoding %s ' % self.latex_encoding)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 520, 5949, 26, 598, 17709, 78, 351, 603, 24446, 665, 77, 24446, 32, 3707, 14, 22943, 14, 846, 30, 199, 3, 520, 12714, 26, 2672, 12714, 26, 1520, 16654, 2672, 199, 3, 520, 2506, 26, 2672, 2506, 26, 6171, 13, 1690, 13, 966, 4329, 26, 2466, 26, 1216, 435, 24215, 334, 1341, 69, 12, 28527, 14, 1603, 324, 6171, 9, 2672, 199, 3, 520, 7384, 26, 22405, 103, 7129, 598, 17709, 78, 351, 603, 24446, 14, 199, 3, 520, 3761, 26, 17646, 68, 1334, 314, 2895, 402, 314, 658, 18, 13, 16009, 6289, 4190, 64, 3131, 315, 3974, 26, 199, 3, 221, 199, 3, 259, 11247, 316, 436, 4084, 402, 642, 570, 12, 543, 503, 1928, 7100, 12, 199, 3, 259, 787, 8211, 315, 1263, 21576, 1928, 882, 89, 13248, 2741, 314, 4248, 199, 3, 259, 4245, 436, 642, 4245, 787, 17731, 14, 199, 3, 259, 961, 570, 365, 402, 22941, 465, 13, 374, 12, 1928, 1263, 3750, 14, 199, 3, 221, 199, 3, 2508, 485, 18, 13, 16009, 6289, 4190, 26, 1455, 921, 1544, 14, 681, 8373, 14, 1308, 15, 2383, 15, 15400, 13, 18, 13, 16009, 199, 199, 624, 199, 56, 69, 7833, 12589, 2213, 3123, 24441, 14, 199, 199, 33, 9854, 402, 5454, 1208, 7, 4465, 283, 7572, 18, 69, 7, 7060, 27955, 1072, 199, 83, 1907, 471, 367, 6661, 543, 1323, 69, 7833, 12589, 334, 1014, 921, 84, 1518, 14, 1308, 15, 1845, 3858, 15, 680, 199, 624, 199, 199, 363, 21841, 363, 275, 283, 264, 27486, 1872, 7, 199, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 295, 199, 199, 646, 18382, 199, 504, 18382, 492, 22523, 12, 3380, 12, 3778, 12, 2211, 878, 12, 10815, 199, 504, 18382, 14, 26224, 492, 15571, 18, 69, 199, 199, 533, 24441, 8, 7572, 18, 69, 14, 6261, 304, 272, 408, 33, 7060, 367, 6140, 13, 6788, 14081, 21169, 334, 56, 69, 12589, 12, 491, 1458, 12589, 9471, 339, 3748, 275, 661, 1845, 3858, 1673, 31418, 24026, 1673, 76, 4767, 88, 358, 272, 408, 29717, 642, 7060, 5171, 1041, 339, 849, 63, 1160, 275, 283, 31418, 24026, 14, 3858, 7, 272, 849, 63, 17918, 275, 1557, 78, 1370, 904, 779, 267, 519, 5956, 10130, 24157, 12504, 1132, 334, 4624, 12, 20239, 11745, 12, 440, 1454, 367, 10130, 3196, 267, 519, 1154, 409, 973, 4246, 91, 14091, 24157, 12504, 1132, 593, 7293, 267, 519, 1154, 2193, 796, 4246, 91, 14091, 31012, 393, 262, 453, 593, 7293, 267, 519, 1154, 409, 2106, 1618, 1888, 59, 21568, 17579, 1610, 29, 403, 12, 9944, 29, 4486, 17846, 2546, 8194, 872, 3387, 32308, 428, 796, 10953, 79, 7293, 272, 4794, 339, 1101, 63, 2792, 275, 283, 1845, 3858, 7060, 7, 272, 1101, 63, 2792, 63, 5714, 275, 661, 26224, 297, 283, 7572, 18, 69, 7060, 358, 339, 2202, 63, 1650, 275, 22523, 14, 1541, 63, 1751, 63, 1650, 8, 267, 15571, 18, 69, 14, 6261, 14, 1751, 63, 1650, 12, 267, 283, 4246, 63, 2991, 297, 267, 1978, 7782, 4231, 570, 14, 3758, 26, 2071, 83, 24217, 450, 849, 63, 1160, 12, 881, 14574, 1160, 995, 791, 885, 356, 849, 63, 1160, 12, 283, 23303, 356, 2650, 493, 30, 1604, 267, 15571, 63, 17918, 7782, 7223, 2072, 701, 14081, 1233, 315, 314, 19789, 14, 283, 881, 283, 2698, 26, 3504, 15537, 4465, 26219, 334, 17687, 12, 869, 25911, 12, 445, 567, 4446, 680, 297, 881, 14574, 7572, 13, 17918, 995, 881, 791, 885, 356, 849, 63, 17918, 8688, 267, 776, 339, 347, 636, 826, 721, 277, 304, 267, 15571, 18, 69, 14, 6261, 855, 826, 721, 277, 9, 267, 291, 14, 1751, 63, 4322, 14, 873, 3252, 70, 265, 28139, 356, 283, 3071, 327, 675, 849, 334, 23539, 17, 503, 26007, 18, 9, 267, 291, 14, 29346, 63, 533, 275, 1323, 69, 7833, 12589, 26059, 421, 199, 533, 699, 902, 8, 7572, 18, 69, 14, 34, 902, 304, 272, 408, 8493, 1106, 329, 1259, 367, 1323, 69, 12589, 14, 339, 3645, 658, 2515, 5016, 11560, 10971, 64, 3140, 402, 658, 66, 902, 64, 436, 19520, 2202, 14, 272, 408, 272, 2637, 63, 6021, 275, 15571, 18, 69, 14, 34, 902, 14, 3671, 63, 6021, 14, 1574, 342, 272, 327, 25448, 3748, 503, 23142, 4310, 10815, 26, 272, 2637, 63, 6021, 14, 873, 2561, 267, 327, 1233, 3515, 8467, 5016, 11560, 10971, 13, 354, 755, 3721, 267, 283, 26950, 356, 3515, 283, 26950, 764, 297, 267, 283, 271, 356, 3698, 283, 836, 1237, 297, 327, 892, 27928, 334, 271, 63, 7155, 22, 9, 267, 283, 271, 13, 1167, 614, 356, 420, 283, 79, 836, 1237, 297, 327, 2269, 27928, 267, 283, 8398, 356, 3698, 283, 28021, 5812, 297, 221, 327, 29936, 328, 433, 290, 267, 283, 795, 66, 356, 3515, 283, 478, 269, 9662, 297, 267, 283, 352, 13, 6023, 1860, 356, 257, 283, 2515, 5016, 14291, 297, 267, 283, 667, 356, 3698, 283, 15315, 338, 297, 267, 283, 71, 1195, 356, 3515, 283, 290, 559, 484, 32007, 297, 267, 283, 4213, 66, 356, 3515, 283, 527, 269, 9662, 297, 267, 283, 609, 13, 9156, 4308, 356, 420, 283, 332, 9662, 297, 327, 3739, 656, 13, 35, 293, 2159, 290, 12, 18461, 11909, 2884, 267, 283, 609, 13, 22510, 78, 356, 420, 283, 67, 293, 2159, 290, 297, 327, 3739, 656, 13, 35, 293, 2159, 290, 12, 23864, 2884, 267, 283, 3526, 356, 3698, 283, 279, 13206, 5653, 297, 267, 283, 5474, 356, 3698, 283, 332, 9662, 297, 327, 18461, 11909, 2884, 334, 5474, 13, 9156, 4308, 9, 267, 283, 273, 356, 3698, 283, 24825, 297, 267, 283, 433, 356, 3698, 283, 433, 386, 354, 261, 297, 267, 327, 1315, 72, 13, 22510, 78, 26, 420, 5805, 10674, 263, 327, 258, 2799, 26883, 510, 8952, 262, 267, 3828, 272, 327, 7666, 334, 2110, 2546, 9, 2883, 272, 2637, 63, 6021, 275, 1211, 7694, 75, 14, 2325, 1062, 373, 9, 367, 334, 75, 12, 86, 9, 315, 2637, 63, 6021, 14, 1744, 9383, 339, 327, 8466, 83, 1928, 8467, 5016, 11560, 10971, 2291, 26, 272, 367, 790, 315 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 520, 5949, 26, 598, 17709, 78, 351, 603, 24446, 665, 77, 24446, 32, 3707, 14, 22943, 14, 846, 30, 199, 3, 520, 12714, 26, 2672, 12714, 26, 1520, 16654, 2672, 199, 3, 520, 2506, 26, 2672, 2506, 26, 6171, 13, 1690, 13, 966, 4329, 26, 2466, 26, 1216, 435, 24215, 334, 1341, 69, 12, 28527, 14, 1603, 324, 6171, 9, 2672, 199, 3, 520, 7384, 26, 22405, 103, 7129, 598, 17709, 78, 351, 603, 24446, 14, 199, 3, 520, 3761, 26, 17646, 68, 1334, 314, 2895, 402, 314, 658, 18, 13, 16009, 6289, 4190, 64, 3131, 315, 3974, 26, 199, 3, 221, 199, 3, 259, 11247, 316, 436, 4084, 402, 642, 570, 12, 543, 503, 1928, 7100, 12, 199, 3, 259, 787, 8211, 315, 1263, 21576, 1928, 882, 89, 13248, 2741, 314, 4248, 199, 3, 259, 4245, 436, 642, 4245, 787, 17731, 14, 199, 3, 259, 961, 570, 365, 402, 22941, 465, 13, 374, 12, 1928, 1263, 3750, 14, 199, 3, 221, 199, 3, 2508, 485, 18, 13, 16009, 6289, 4190, 26, 1455, 921, 1544, 14, 681, 8373, 14, 1308, 15, 2383, 15, 15400, 13, 18, 13, 16009, 199, 199, 624, 199, 56, 69, 7833, 12589, 2213, 3123, 24441, 14, 199, 199, 33, 9854, 402, 5454, 1208, 7, 4465, 283, 7572, 18, 69, 7, 7060, 27955, 1072, 199, 83, 1907, 471, 367, 6661, 543, 1323, 69, 7833, 12589, 334, 1014, 921, 84, 1518, 14, 1308, 15, 1845, 3858, 15, 680, 199, 624, 199, 199, 363, 21841, 363, 275, 283, 264, 27486, 1872, 7, 199, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 295, 199, 199, 646, 18382, 199, 504, 18382, 492, 22523, 12, 3380, 12, 3778, 12, 2211, 878, 12, 10815, 199, 504, 18382, 14, 26224, 492, 15571, 18, 69, 199, 199, 533, 24441, 8, 7572, 18, 69, 14, 6261, 304, 272, 408, 33, 7060, 367, 6140, 13, 6788, 14081, 21169, 334, 56, 69, 12589, 12, 491, 1458, 12589, 9471, 339, 3748, 275, 661, 1845, 3858, 1673, 31418, 24026, 1673, 76, 4767, 88, 358, 272, 408, 29717, 642, 7060, 5171, 1041, 339, 849, 63, 1160, 275, 283, 31418, 24026, 14, 3858, 7, 272, 849, 63, 17918, 275, 1557, 78, 1370, 904, 779, 267, 519, 5956, 10130, 24157, 12504, 1132, 334, 4624, 12, 20239, 11745, 12, 440, 1454, 367, 10130, 3196, 267, 519, 1154, 409, 973, 4246, 91, 14091, 24157, 12504, 1132, 593, 7293, 267, 519, 1154, 2193, 796, 4246, 91, 14091, 31012, 393, 262, 453, 593, 7293, 267, 519, 1154, 409, 2106, 1618, 1888, 59, 21568, 17579, 1610, 29, 403, 12, 9944, 29, 4486, 17846, 2546, 8194, 872, 3387, 32308, 428, 796, 10953, 79, 7293, 272, 4794, 339, 1101, 63, 2792, 275, 283, 1845, 3858, 7060, 7, 272, 1101, 63, 2792, 63, 5714, 275, 661, 26224, 297, 283, 7572, 18, 69, 7060, 358, 339, 2202, 63, 1650, 275, 22523, 14, 1541, 63, 1751, 63, 1650, 8, 267, 15571, 18, 69, 14, 6261, 14, 1751, 63, 1650, 12, 267, 283, 4246, 63, 2991, 297, 267, 1978, 7782, 4231, 570, 14, 3758, 26, 2071, 83, 24217, 450, 849, 63, 1160, 12, 881, 14574, 1160, 995, 791, 885, 356, 849, 63, 1160, 12, 283, 23303, 356, 2650, 493, 30, 1604, 267, 15571, 63, 17918, 7782, 7223, 2072, 701, 14081, 1233, 315, 314, 19789, 14, 283, 881, 283, 2698, 26, 3504, 15537, 4465, 26219, 334, 17687, 12, 869, 25911, 12, 445, 567, 4446, 680, 297, 881, 14574, 7572, 13, 17918, 995, 881, 791, 885, 356, 849, 63, 17918, 8688, 267, 776, 339, 347, 636, 826, 721, 277, 304, 267, 15571, 18, 69, 14, 6261, 855, 826, 721, 277, 9, 267, 291, 14, 1751, 63, 4322, 14, 873, 3252, 70, 265, 28139, 356, 283, 3071, 327, 675, 849, 334, 23539, 17, 503, 26007, 18, 9, 267, 291, 14, 29346, 63, 533, 275, 1323, 69, 7833, 12589, 26059, 421, 199, 533, 699, 902, 8, 7572, 18, 69, 14, 34, 902, 304, 272, 408, 8493, 1106, 329, 1259, 367, 1323, 69, 12589, 14, 339, 3645, 658, 2515, 5016, 11560, 10971, 64, 3140, 402, 658, 66, 902, 64, 436, 19520, 2202, 14, 272, 408, 272, 2637, 63, 6021, 275, 15571, 18, 69, 14, 34, 902, 14, 3671, 63, 6021, 14, 1574, 342, 272, 327, 25448, 3748, 503, 23142, 4310, 10815, 26, 272, 2637, 63, 6021, 14, 873, 2561, 267, 327, 1233, 3515, 8467, 5016, 11560, 10971, 13, 354, 755, 3721, 267, 283, 26950, 356, 3515, 283, 26950, 764, 297, 267, 283, 271, 356, 3698, 283, 836, 1237, 297, 327, 892, 27928, 334, 271, 63, 7155, 22, 9, 267, 283, 271, 13, 1167, 614, 356, 420, 283, 79, 836, 1237, 297, 327, 2269, 27928, 267, 283, 8398, 356, 3698, 283, 28021, 5812, 297, 221, 327, 29936, 328, 433, 290, 267, 283, 795, 66, 356, 3515, 283, 478, 269, 9662, 297, 267, 283, 352, 13, 6023, 1860, 356, 257, 283, 2515, 5016, 14291, 297, 267, 283, 667, 356, 3698, 283, 15315, 338, 297, 267, 283, 71, 1195, 356, 3515, 283, 290, 559, 484, 32007, 297, 267, 283, 4213, 66, 356, 3515, 283, 527, 269, 9662, 297, 267, 283, 609, 13, 9156, 4308, 356, 420, 283, 332, 9662, 297, 327, 3739, 656, 13, 35, 293, 2159, 290, 12, 18461, 11909, 2884, 267, 283, 609, 13, 22510, 78, 356, 420, 283, 67, 293, 2159, 290, 297, 327, 3739, 656, 13, 35, 293, 2159, 290, 12, 23864, 2884, 267, 283, 3526, 356, 3698, 283, 279, 13206, 5653, 297, 267, 283, 5474, 356, 3698, 283, 332, 9662, 297, 327, 18461, 11909, 2884, 334, 5474, 13, 9156, 4308, 9, 267, 283, 273, 356, 3698, 283, 24825, 297, 267, 283, 433, 356, 3698, 283, 433, 386, 354, 261, 297, 267, 327, 1315, 72, 13, 22510, 78, 26, 420, 5805, 10674, 263, 327, 258, 2799, 26883, 510, 8952, 262, 267, 3828, 272, 327, 7666, 334, 2110, 2546, 9, 2883, 272, 2637, 63, 6021, 275, 1211, 7694, 75, 14, 2325, 1062, 373, 9, 367, 334, 75, 12, 86, 9, 315, 2637, 63, 6021, 14, 1744, 9383, 339, 327, 8466, 83, 1928, 8467, 5016, 11560, 10971, 2291, 26, 272, 367, 790, 315, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
milaq/android_kernel_htc_kovsky
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py
802
2710
# Core.py - Python extension for perf trace, core functions # # Copyright (C) 2010 by Tom Zanussi <tzanussi@gmail.com> # # This software may be distributed under the terms of the GNU General # Public License ("GPL") version 2 as published by the Free Software # Foundation. from collections import defaultdict def autodict(): return defaultdict(autodict) flag_fields = autodict() symbolic_fields = autodict() def define_flag_field(event_name, field_name, delim): flag_fields[event_name][field_name]['delim'] = delim def define_flag_value(event_name, field_name, value, field_str): flag_fields[event_name][field_name]['values'][value] = field_str def define_symbolic_field(event_name, field_name): # nothing to do, really pass def define_symbolic_value(event_name, field_name, value, field_str): symbolic_fields[event_name][field_name]['values'][value] = field_str def flag_str(event_name, field_name, value): string = "" if flag_fields[event_name][field_name]: print_delim = 0 keys = flag_fields[event_name][field_name]['values'].keys() keys.sort() for idx in keys: if not value and not idx: string += flag_fields[event_name][field_name]['values'][idx] break if idx and (value & idx) == idx: if print_delim and flag_fields[event_name][field_name]['delim']: string += " " + flag_fields[event_name][field_name]['delim'] + " " string += flag_fields[event_name][field_name]['values'][idx] print_delim = 1 value &= ~idx return string def symbol_str(event_name, field_name, value): string = "" if symbolic_fields[event_name][field_name]: keys = symbolic_fields[event_name][field_name]['values'].keys() keys.sort() for idx in keys: if not value and not idx: string = symbolic_fields[event_name][field_name]['values'][idx] break if (value == idx): string = symbolic_fields[event_name][field_name]['values'][idx] break return string trace_flags = { 0x00: "NONE", \ 0x01: "IRQS_OFF", \ 0x02: "IRQS_NOSUPPORT", \ 0x04: "NEED_RESCHED", \ 0x08: "HARDIRQ", \ 0x10: "SOFTIRQ" } def trace_flag_str(value): string = "" print_delim = 0 keys = trace_flags.keys() for idx in keys: if not value and not idx: string += "NONE" break if idx and (value & idx) == idx: if print_delim: string += " | "; string += trace_flags[idx] print_delim = 1 value &= ~idx return string
gpl-2.0
[ 3, 11672, 14, 647, 446, 2018, 3329, 367, 8582, 3307, 12, 6170, 3423, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 701, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2032, 1443, 506, 1854, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 1689, 12006, 531, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 14, 199, 199, 504, 5055, 492, 10018, 199, 199, 318, 27477, 837, 272, 372, 10018, 8, 2495, 807, 9, 199, 199, 4173, 63, 955, 275, 27477, 342, 199, 22836, 63, 955, 275, 27477, 342, 199, 199, 318, 5627, 63, 4173, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 21799, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 275, 21799, 199, 199, 318, 5627, 63, 4173, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 5627, 63, 22836, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 304, 272, 327, 6548, 370, 886, 12, 7710, 272, 986, 199, 199, 318, 5627, 63, 22836, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 3305, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 199, 198, 1361, 63, 15966, 275, 378, 267, 2883, 275, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 288, 340, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 355, 340, 870, 63, 15966, 436, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 2565, 490, 1059, 847, 298, 298, 435, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 435, 298, 298, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 870, 63, 15966, 275, 413, 355, 574, 18415, 6146, 2996, 339, 372, 1059, 199, 199, 318, 5272, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 267, 2883, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 6722, 340, 334, 585, 508, 4280, 304, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 339, 372, 1059, 199, 199, 3446, 63, 2469, 275, 469, 378, 88, 383, 26, 298, 9185, 401, 971, 490, 378, 88, 614, 26, 298, 3927, 23298, 63, 7517, 401, 971, 490, 378, 88, 996, 26, 298, 3927, 23298, 63, 2826, 10640, 401, 971, 490, 378, 88, 966, 26, 298, 28888, 63, 3830, 22492, 401, 971, 490, 378, 88, 2036, 26, 298, 30958, 3022, 49, 401, 971, 490, 378, 88, 709, 26, 298, 26999, 3927, 49, 2, 789, 199, 199, 318, 3307, 63, 4173, 63, 495, 8, 585, 304, 272, 1059, 275, 3087, 272, 870, 63, 15966, 275, 378, 339, 2883, 275, 3307, 63, 2469, 14, 1612, 342, 339, 367, 4280, 315, 2883, 26, 199, 198, 692, 440, 574, 436, 440, 4280, 26, 6722, 1059, 847, 298, 9185, 2, 6722, 2059, 421, 198, 692, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 6722, 340, 870, 63, 15966, 26, 507, 198, 875, 847, 298, 1204, 28036, 6722, 1059, 847, 3307, 63, 2469, 59, 2996, 61, 6722, 870, 63, 15966, 275, 413, 6722, 574, 18415, 6146, 2996, 339, 372, 1059, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 11672, 14, 647, 446, 2018, 3329, 367, 8582, 3307, 12, 6170, 3423, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 701, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2032, 1443, 506, 1854, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 1689, 12006, 531, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 14, 199, 199, 504, 5055, 492, 10018, 199, 199, 318, 27477, 837, 272, 372, 10018, 8, 2495, 807, 9, 199, 199, 4173, 63, 955, 275, 27477, 342, 199, 22836, 63, 955, 275, 27477, 342, 199, 199, 318, 5627, 63, 4173, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 21799, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 275, 21799, 199, 199, 318, 5627, 63, 4173, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 5627, 63, 22836, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 304, 272, 327, 6548, 370, 886, 12, 7710, 272, 986, 199, 199, 318, 5627, 63, 22836, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 3305, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 199, 198, 1361, 63, 15966, 275, 378, 267, 2883, 275, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 288, 340, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 355, 340, 870, 63, 15966, 436, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 2565, 490, 1059, 847, 298, 298, 435, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 435, 298, 298, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 870, 63, 15966, 275, 413, 355, 574, 18415, 6146, 2996, 339, 372, 1059, 199, 199, 318, 5272, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 267, 2883, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 6722, 340, 334, 585, 508, 4280, 304, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 339, 372, 1059, 199, 199, 3446, 63, 2469, 275, 469, 378, 88, 383, 26, 298, 9185, 401, 971, 490, 378, 88, 614, 26, 298, 3927, 23298, 63, 7517, 401, 971, 490, 378, 88, 996, 26, 298, 3927, 23298, 63, 2826, 10640, 401, 971, 490, 378, 88, 966, 26, 298, 28888, 63, 3830, 22492, 401, 971, 490, 378, 88, 2036, 26, 298, 30958, 3022, 49, 401, 971, 490, 378, 88, 709, 26, 298, 26999, 3927, 49, 2, 789, 199, 199, 318, 3307, 63, 4173, 63, 495, 8, 585, 304, 272, 1059, 275, 3087, 272, 870, 63, 15966, 275, 378, 339, 2883, 275, 3307, 63, 2469, 14, 1612, 342, 339, 367, 4280, 315, 2883, 26, 199, 198, 692, 440, 574, 436, 440, 4280, 26, 6722, 1059, 847, 298, 9185, 2, 6722, 2059, 421, 198, 692, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 6722, 340, 870, 63, 15966, 26, 507, 198, 875, 847, 298, 1204, 28036, 6722, 1059, 847, 3307, 63, 2469, 59, 2996, 61, 6722, 870, 63, 15966, 275, 413, 6722, 574, 18415, 6146, 2996, 339, 372, 1059, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
ashishnitinpatil/django_appengine_project_template
django/conf/urls/__init__.py
107
2601
from django.core.urlresolvers import (RegexURLPattern, RegexURLResolver, LocaleRegexURLResolver) from django.core.exceptions import ImproperlyConfigured from django.utils.importlib import import_module from django.utils import six __all__ = ['handler400', 'handler403', 'handler404', 'handler500', 'include', 'patterns', 'url'] handler400 = 'django.views.defaults.bad_request' handler403 = 'django.views.defaults.permission_denied' handler404 = 'django.views.defaults.page_not_found' handler500 = 'django.views.defaults.server_error' def include(arg, namespace=None, app_name=None): if isinstance(arg, tuple): # callable returning a namespace hint if namespace: raise ImproperlyConfigured('Cannot override the namespace for a dynamic module that provides a namespace') urlconf_module, app_name, namespace = arg else: # No namespace hint - use manually provided namespace urlconf_module = arg if isinstance(urlconf_module, six.string_types): urlconf_module = import_module(urlconf_module) patterns = getattr(urlconf_module, 'urlpatterns', urlconf_module) # Make sure we can iterate through the patterns (without this, some # testcases will break). if isinstance(patterns, (list, tuple)): for url_pattern in patterns: # Test if the LocaleRegexURLResolver is used within the include; # this should throw an error since this is not allowed! if isinstance(url_pattern, LocaleRegexURLResolver): raise ImproperlyConfigured( 'Using i18n_patterns in an included URLconf is not allowed.') return (urlconf_module, app_name, namespace) def patterns(prefix, *args): pattern_list = [] for t in args: if isinstance(t, (list, tuple)): t = url(prefix=prefix, *t) elif isinstance(t, RegexURLPattern): t.add_prefix(prefix) pattern_list.append(t) return pattern_list def url(regex, view, kwargs=None, name=None, prefix=''): if isinstance(view, (list,tuple)): # For include(...) processing. urlconf_module, app_name, namespace = view return RegexURLResolver(regex, urlconf_module, kwargs, app_name=app_name, namespace=namespace) else: if isinstance(view, six.string_types): if not view: raise ImproperlyConfigured('Empty URL pattern view name not permitted (for pattern %r)' % regex) if prefix: view = prefix + '.' + view return RegexURLPattern(regex, view, kwargs, name)
bsd-2-clause
[ 504, 1639, 14, 1018, 14, 16522, 492, 334, 5103, 2632, 9959, 12, 272, 12939, 2632, 12407, 12, 28298, 5103, 2632, 12407, 9, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1208, 14, 25893, 492, 492, 63, 578, 199, 504, 1639, 14, 1208, 492, 3816, 421, 199, 363, 452, 363, 275, 788, 2232, 5303, 297, 283, 2232, 13353, 297, 283, 2232, 5188, 297, 283, 2232, 5783, 297, 283, 2613, 297, 283, 7435, 297, 283, 633, 418, 199, 199, 2232, 5303, 275, 283, 1176, 14, 4196, 14, 4322, 14, 4087, 63, 1069, 7, 199, 2232, 13353, 275, 283, 1176, 14, 4196, 14, 4322, 14, 5693, 63, 28180, 7, 199, 2232, 5188, 275, 283, 1176, 14, 4196, 14, 4322, 14, 1606, 63, 1397, 63, 4214, 7, 199, 2232, 5783, 275, 283, 1176, 14, 4196, 14, 4322, 14, 1000, 63, 705, 7, 199, 199, 318, 2387, 8, 1273, 12, 3231, 29, 403, 12, 1145, 63, 354, 29, 403, 304, 272, 340, 1228, 8, 1273, 12, 2008, 304, 267, 327, 4550, 8152, 282, 3231, 8328, 267, 340, 3231, 26, 288, 746, 11897, 360, 6612, 4278, 314, 3231, 367, 282, 8336, 859, 626, 6571, 282, 3231, 358, 267, 30009, 63, 578, 12, 1145, 63, 354, 12, 3231, 275, 1680, 272, 587, 26, 267, 327, 3091, 3231, 8328, 446, 675, 10250, 2741, 3231, 267, 30009, 63, 578, 275, 1680, 339, 340, 1228, 8, 21801, 63, 578, 12, 3816, 14, 875, 63, 1313, 304, 267, 30009, 63, 578, 275, 492, 63, 578, 8, 21801, 63, 578, 9, 272, 7970, 275, 2519, 8, 21801, 63, 578, 12, 283, 20050, 297, 30009, 63, 578, 9, 339, 327, 4155, 3238, 781, 883, 13974, 4012, 314, 7970, 334, 7395, 642, 12, 2005, 272, 327, 511, 9403, 911, 2059, 680, 272, 340, 1228, 8, 7435, 12, 334, 513, 12, 2008, 2298, 267, 367, 1166, 63, 3401, 315, 7970, 26, 288, 327, 1379, 340, 314, 28298, 5103, 2632, 12407, 365, 1202, 4453, 314, 2387, 27, 288, 327, 642, 1077, 7978, 376, 1125, 3967, 642, 365, 440, 4370, 1, 288, 340, 1228, 8, 633, 63, 3401, 12, 28298, 5103, 2632, 12407, 304, 355, 746, 11897, 8, 490, 283, 10369, 284, 1085, 78, 63, 7435, 315, 376, 5120, 2851, 2190, 365, 440, 4370, 2659, 339, 372, 334, 21801, 63, 578, 12, 1145, 63, 354, 12, 3231, 9, 199, 199, 318, 7970, 8, 1861, 12, 627, 589, 304, 272, 3851, 63, 513, 275, 942, 272, 367, 307, 315, 1249, 26, 267, 340, 1228, 8, 84, 12, 334, 513, 12, 2008, 2298, 288, 307, 275, 1166, 8, 1861, 29, 1861, 12, 627, 84, 9, 267, 916, 1228, 8, 84, 12, 12939, 2632, 9959, 304, 288, 307, 14, 525, 63, 1861, 8, 1861, 9, 267, 3851, 63, 513, 14, 740, 8, 84, 9, 272, 372, 3851, 63, 513, 199, 199, 318, 1166, 8, 3821, 12, 2455, 12, 2074, 29, 403, 12, 536, 29, 403, 12, 2403, 9280, 272, 340, 1228, 8, 1345, 12, 334, 513, 12, 2960, 2298, 267, 327, 2104, 2387, 20186, 6661, 14, 267, 30009, 63, 578, 12, 1145, 63, 354, 12, 3231, 275, 2455, 267, 372, 12939, 2632, 12407, 8, 3821, 12, 30009, 63, 578, 12, 2074, 12, 1145, 63, 354, 29, 571, 63, 354, 12, 3231, 29, 3251, 9, 272, 587, 26, 267, 340, 1228, 8, 1345, 12, 3816, 14, 875, 63, 1313, 304, 288, 340, 440, 2455, 26, 355, 746, 11897, 360, 4699, 2851, 3851, 2455, 536, 440, 8211, 334, 509, 3851, 450, 82, 3171, 450, 5163, 9, 288, 340, 2403, 26, 355, 2455, 275, 2403, 435, 7815, 435, 2455, 267, 372, 12939, 2632, 9959, 8, 3821, 12, 2455, 12, 2074, 12, 536, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 14, 1018, 14, 16522, 492, 334, 5103, 2632, 9959, 12, 272, 12939, 2632, 12407, 12, 28298, 5103, 2632, 12407, 9, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1208, 14, 25893, 492, 492, 63, 578, 199, 504, 1639, 14, 1208, 492, 3816, 421, 199, 363, 452, 363, 275, 788, 2232, 5303, 297, 283, 2232, 13353, 297, 283, 2232, 5188, 297, 283, 2232, 5783, 297, 283, 2613, 297, 283, 7435, 297, 283, 633, 418, 199, 199, 2232, 5303, 275, 283, 1176, 14, 4196, 14, 4322, 14, 4087, 63, 1069, 7, 199, 2232, 13353, 275, 283, 1176, 14, 4196, 14, 4322, 14, 5693, 63, 28180, 7, 199, 2232, 5188, 275, 283, 1176, 14, 4196, 14, 4322, 14, 1606, 63, 1397, 63, 4214, 7, 199, 2232, 5783, 275, 283, 1176, 14, 4196, 14, 4322, 14, 1000, 63, 705, 7, 199, 199, 318, 2387, 8, 1273, 12, 3231, 29, 403, 12, 1145, 63, 354, 29, 403, 304, 272, 340, 1228, 8, 1273, 12, 2008, 304, 267, 327, 4550, 8152, 282, 3231, 8328, 267, 340, 3231, 26, 288, 746, 11897, 360, 6612, 4278, 314, 3231, 367, 282, 8336, 859, 626, 6571, 282, 3231, 358, 267, 30009, 63, 578, 12, 1145, 63, 354, 12, 3231, 275, 1680, 272, 587, 26, 267, 327, 3091, 3231, 8328, 446, 675, 10250, 2741, 3231, 267, 30009, 63, 578, 275, 1680, 339, 340, 1228, 8, 21801, 63, 578, 12, 3816, 14, 875, 63, 1313, 304, 267, 30009, 63, 578, 275, 492, 63, 578, 8, 21801, 63, 578, 9, 272, 7970, 275, 2519, 8, 21801, 63, 578, 12, 283, 20050, 297, 30009, 63, 578, 9, 339, 327, 4155, 3238, 781, 883, 13974, 4012, 314, 7970, 334, 7395, 642, 12, 2005, 272, 327, 511, 9403, 911, 2059, 680, 272, 340, 1228, 8, 7435, 12, 334, 513, 12, 2008, 2298, 267, 367, 1166, 63, 3401, 315, 7970, 26, 288, 327, 1379, 340, 314, 28298, 5103, 2632, 12407, 365, 1202, 4453, 314, 2387, 27, 288, 327, 642, 1077, 7978, 376, 1125, 3967, 642, 365, 440, 4370, 1, 288, 340, 1228, 8, 633, 63, 3401, 12, 28298, 5103, 2632, 12407, 304, 355, 746, 11897, 8, 490, 283, 10369, 284, 1085, 78, 63, 7435, 315, 376, 5120, 2851, 2190, 365, 440, 4370, 2659, 339, 372, 334, 21801, 63, 578, 12, 1145, 63, 354, 12, 3231, 9, 199, 199, 318, 7970, 8, 1861, 12, 627, 589, 304, 272, 3851, 63, 513, 275, 942, 272, 367, 307, 315, 1249, 26, 267, 340, 1228, 8, 84, 12, 334, 513, 12, 2008, 2298, 288, 307, 275, 1166, 8, 1861, 29, 1861, 12, 627, 84, 9, 267, 916, 1228, 8, 84, 12, 12939, 2632, 9959, 304, 288, 307, 14, 525, 63, 1861, 8, 1861, 9, 267, 3851, 63, 513, 14, 740, 8, 84, 9, 272, 372, 3851, 63, 513, 199, 199, 318, 1166, 8, 3821, 12, 2455, 12, 2074, 29, 403, 12, 536, 29, 403, 12, 2403, 9280, 272, 340, 1228, 8, 1345, 12, 334, 513, 12, 2960, 2298, 267, 327, 2104, 2387, 20186, 6661, 14, 267, 30009, 63, 578, 12, 1145, 63, 354, 12, 3231, 275, 2455, 267, 372, 12939, 2632, 12407, 8, 3821, 12, 30009, 63, 578, 12, 2074, 12, 1145, 63, 354, 29, 571, 63, 354, 12, 3231, 29, 3251, 9, 272, 587, 26, 267, 340, 1228, 8, 1345, 12, 3816, 14, 875, 63, 1313, 304, 288, 340, 440, 2455, 26, 355, 746, 11897, 360, 4699, 2851, 3851, 2455, 536, 440, 8211, 334, 509, 3851, 450, 82, 3171, 450, 5163, 9, 288, 340, 2403, 26, 355, 2455, 275, 2403, 435, 7815, 435, 2455, 267, 372, 12939, 2632, 9959, 8, 3821, 12, 2455, 12, 2074, 12, 536, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
cxysteven/Paddle
demo/quick_start/trainer_config.emb.py
13
1802
# edit-mode: -*- python -*- # Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from paddle.trainer_config_helpers import * dict_file = "./data/dict.txt" word_dict = dict() with open(dict_file, 'r') as f: for i, line in enumerate(f): w = line.strip().split()[0] word_dict[w] = i is_predict = get_config_arg('is_predict', bool, False) trn = 'data/train.list' if not is_predict else None tst = 'data/test.list' if not is_predict else 'data/pred.list' process = 'process' if not is_predict else 'process_predict' define_py_data_sources2( train_list=trn, test_list=tst, module="dataprovider_emb", obj=process, args={"dictionary": word_dict}) batch_size = 128 if not is_predict else 1 settings( batch_size=batch_size, learning_rate=2e-3, learning_method=AdamOptimizer()) data = data_layer(name="word", size=len(word_dict)) embedding = embedding_layer(input=data, size=128) avg = pooling_layer(input=embedding, pooling_type=AvgPooling()) output = fc_layer(input=avg, size=2, act=SoftmaxActivation()) if is_predict: maxid = maxid_layer(output) outputs([maxid, output]) else: label = data_layer(name="label", size=2) cls = classification_cost(input=output, label=label) outputs(cls)
apache-2.0
[ 3, 5283, 13, 632, 26, 1882, 2366, 1882, 199, 199, 3, 1898, 334, 67, 9, 7800, 510, 20101, 48, 20101, 6642, 14, 2900, 5924, 5702, 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, 504, 28525, 14, 2834, 281, 63, 888, 63, 7546, 492, 627, 199, 199, 807, 63, 493, 275, 26069, 576, 15, 807, 14, 2424, 2, 199, 1027, 63, 807, 275, 1211, 342, 199, 1045, 1551, 8, 807, 63, 493, 12, 283, 82, 358, 465, 289, 26, 272, 367, 284, 12, 1004, 315, 3874, 8, 70, 304, 267, 336, 275, 1004, 14, 1913, 1252, 1294, 3430, 16, 61, 267, 4349, 63, 807, 59, 87, 61, 275, 284, 199, 199, 374, 63, 6892, 275, 664, 63, 888, 63, 1273, 360, 374, 63, 6892, 297, 2155, 12, 756, 9, 199, 454, 78, 275, 283, 576, 15, 2834, 14, 513, 7, 340, 440, 365, 63, 6892, 587, 488, 199, 84, 270, 275, 283, 576, 15, 396, 14, 513, 7, 340, 440, 365, 63, 6892, 587, 283, 576, 15, 5991, 14, 513, 7, 199, 1412, 275, 283, 1412, 7, 340, 440, 365, 63, 6892, 587, 283, 1412, 63, 6892, 7, 199, 4640, 63, 647, 63, 576, 63, 4553, 18, 8, 272, 3560, 63, 513, 29, 454, 78, 12, 272, 511, 63, 513, 29, 84, 270, 12, 272, 859, 628, 576, 3780, 63, 18847, 401, 272, 1559, 29, 1412, 12, 272, 1249, 8871, 9086, 582, 4349, 63, 807, 1552, 199, 199, 2912, 63, 890, 275, 7960, 340, 440, 365, 63, 6892, 587, 413, 199, 1751, 8, 272, 3522, 63, 890, 29, 2912, 63, 890, 12, 9328, 63, 1866, 29, 18, 69, 13, 19, 12, 9328, 63, 765, 29, 32408, 13946, 1012, 199, 199, 576, 275, 666, 63, 1897, 8, 354, 628, 1027, 401, 1568, 29, 552, 8, 1027, 63, 807, 430, 199, 14275, 275, 12452, 63, 1897, 8, 1210, 29, 576, 12, 1568, 29, 3933, 9, 199, 8595, 275, 20699, 63, 1897, 8, 1210, 29, 14275, 12, 20699, 63, 466, 29, 16650, 22349, 1012, 199, 1199, 275, 10821, 63, 1897, 8, 1210, 29, 8595, 12, 1568, 29, 18, 12, 2454, 29, 19302, 988, 19535, 1012, 199, 692, 365, 63, 6892, 26, 272, 1390, 344, 275, 1390, 344, 63, 1897, 8, 1199, 9, 272, 4704, 779, 988, 344, 12, 1072, 566, 199, 2836, 26, 272, 1768, 275, 666, 63, 1897, 8, 354, 628, 1302, 401, 1568, 29, 18, 9, 272, 843, 275, 12505, 63, 6336, 8, 1210, 29, 1199, 12, 1768, 29, 1302, 9, 272, 4704, 8, 1886, 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 ]
[ 5283, 13, 632, 26, 1882, 2366, 1882, 199, 199, 3, 1898, 334, 67, 9, 7800, 510, 20101, 48, 20101, 6642, 14, 2900, 5924, 5702, 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, 504, 28525, 14, 2834, 281, 63, 888, 63, 7546, 492, 627, 199, 199, 807, 63, 493, 275, 26069, 576, 15, 807, 14, 2424, 2, 199, 1027, 63, 807, 275, 1211, 342, 199, 1045, 1551, 8, 807, 63, 493, 12, 283, 82, 358, 465, 289, 26, 272, 367, 284, 12, 1004, 315, 3874, 8, 70, 304, 267, 336, 275, 1004, 14, 1913, 1252, 1294, 3430, 16, 61, 267, 4349, 63, 807, 59, 87, 61, 275, 284, 199, 199, 374, 63, 6892, 275, 664, 63, 888, 63, 1273, 360, 374, 63, 6892, 297, 2155, 12, 756, 9, 199, 454, 78, 275, 283, 576, 15, 2834, 14, 513, 7, 340, 440, 365, 63, 6892, 587, 488, 199, 84, 270, 275, 283, 576, 15, 396, 14, 513, 7, 340, 440, 365, 63, 6892, 587, 283, 576, 15, 5991, 14, 513, 7, 199, 1412, 275, 283, 1412, 7, 340, 440, 365, 63, 6892, 587, 283, 1412, 63, 6892, 7, 199, 4640, 63, 647, 63, 576, 63, 4553, 18, 8, 272, 3560, 63, 513, 29, 454, 78, 12, 272, 511, 63, 513, 29, 84, 270, 12, 272, 859, 628, 576, 3780, 63, 18847, 401, 272, 1559, 29, 1412, 12, 272, 1249, 8871, 9086, 582, 4349, 63, 807, 1552, 199, 199, 2912, 63, 890, 275, 7960, 340, 440, 365, 63, 6892, 587, 413, 199, 1751, 8, 272, 3522, 63, 890, 29, 2912, 63, 890, 12, 9328, 63, 1866, 29, 18, 69, 13, 19, 12, 9328, 63, 765, 29, 32408, 13946, 1012, 199, 199, 576, 275, 666, 63, 1897, 8, 354, 628, 1027, 401, 1568, 29, 552, 8, 1027, 63, 807, 430, 199, 14275, 275, 12452, 63, 1897, 8, 1210, 29, 576, 12, 1568, 29, 3933, 9, 199, 8595, 275, 20699, 63, 1897, 8, 1210, 29, 14275, 12, 20699, 63, 466, 29, 16650, 22349, 1012, 199, 1199, 275, 10821, 63, 1897, 8, 1210, 29, 8595, 12, 1568, 29, 18, 12, 2454, 29, 19302, 988, 19535, 1012, 199, 692, 365, 63, 6892, 26, 272, 1390, 344, 275, 1390, 344, 63, 1897, 8, 1199, 9, 272, 4704, 779, 988, 344, 12, 1072, 566, 199, 2836, 26, 272, 1768, 275, 666, 63, 1897, 8, 354, 628, 1302, 401, 1568, 29, 18, 9, 272, 843, 275, 12505, 63, 6336, 8, 1210, 29, 1199, 12, 1768, 29, 1302, 9, 272, 4704, 8, 1886, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
Averroes/statsmodels
statsmodels/tsa/statespace/tests/test_tools.py
19
4268
""" Tests for tools Author: Chad Fulton License: Simplified-BSD """ from __future__ import division, absolute_import, print_function import numpy as np import pandas as pd from statsmodels.tsa.statespace import tools # from .results import results_sarimax from numpy.testing import ( assert_equal, assert_array_equal, assert_almost_equal, assert_raises ) class TestCompanionMatrix(object): cases = [ (2, np.array([[0,1],[0,0]])), ([1,-1,-2], np.array([[1,1],[2,0]])), ([1,-1,-2,-3], np.array([[1,1,0],[2,0,1],[3,0,0]])) ] def test_cases(self): for polynomial, result in self.cases: assert_equal(tools.companion_matrix(polynomial), result) class TestDiff(object): x = np.arange(10) cases = [ # diff = 1 ([1,2,3], 1, None, 1, [1, 1]), # diff = 2 (x, 2, None, 1, [0]*8), # diff = 1, seasonal_diff=1, k_seasons=4 (x, 1, 1, 4, [0]*5), (x**2, 1, 1, 4, [8]*5), (x**3, 1, 1, 4, [60, 84, 108, 132, 156]), # diff = 1, seasonal_diff=2, k_seasons=2 (x, 1, 2, 2, [0]*5), (x**2, 1, 2, 2, [0]*5), (x**3, 1, 2, 2, [24]*5), (x**4, 1, 2, 2, [240, 336, 432, 528, 624]), ] def test_cases(self): # Basic cases for series, diff, seasonal_diff, k_seasons, result in self.cases: # Test numpy array x = tools.diff(series, diff, seasonal_diff, k_seasons) assert_almost_equal(x, result) # Test as Pandas Series series = pd.Series(series) # Rewrite to test as n-dimensional array series = np.c_[series, series] result = np.c_[result, result] # Test Numpy array x = tools.diff(series, diff, seasonal_diff, k_seasons) assert_almost_equal(x, result) # Test as Pandas Dataframe series = pd.DataFrame(series) x = tools.diff(series, diff, seasonal_diff, k_seasons) assert_almost_equal(x, result) class TestIsInvertible(object): cases = [ ([1, -0.5], True), ([1, 1-1e-9], True), ([1, 1], False), ([1, 0.9,0.1], True), (np.array([1,0.9,0.1]), True), (pd.Series([1,0.9,0.1]), True) ] def test_cases(self): for polynomial, invertible in self.cases: assert_equal(tools.is_invertible(polynomial), invertible) class TestConstrainStationaryUnivariate(object): cases = [ (np.array([2.]), -2./((1+2.**2)**0.5)) ] def test_cases(self): for unconstrained, constrained in self.cases: result = tools.constrain_stationary_univariate(unconstrained) assert_equal(result, constrained) class TestValidateMatrixShape(object): # name, shape, nrows, ncols, nobs valid = [ ('TEST', (5,2), 5, 2, None), ('TEST', (5,2), 5, 2, 10), ('TEST', (5,2,10), 5, 2, 10), ] invalid = [ ('TEST', (5,), 5, None, None), ('TEST', (5,1,1,1), 5, 1, None), ('TEST', (5,2), 10, 2, None), ('TEST', (5,2), 5, 1, None), ('TEST', (5,2,10), 5, 2, None), ('TEST', (5,2,10), 5, 2, 5), ] def test_valid_cases(self): for args in self.valid: # Just testing that no exception is raised tools.validate_matrix_shape(*args) def test_invalid_cases(self): for args in self.invalid: assert_raises( ValueError, tools.validate_matrix_shape, *args ) class TestValidateVectorShape(object): # name, shape, nrows, ncols, nobs valid = [ ('TEST', (5,), 5, None), ('TEST', (5,), 5, 10), ('TEST', (5,10), 5, 10), ] invalid = [ ('TEST', (5,2,10), 5, 10), ('TEST', (5,), 10, None), ('TEST', (5,10), 5, None), ('TEST', (5,10), 5, 5), ] def test_valid_cases(self): for args in self.valid: # Just testing that no exception is raised tools.validate_vector_shape(*args) def test_invalid_cases(self): for args in self.invalid: assert_raises( ValueError, tools.validate_vector_shape, *args )
bsd-3-clause
[ 624, 199, 2925, 367, 7249, 199, 199, 5949, 26, 2799, 350, 481, 427, 265, 199, 3761, 26, 29094, 30200, 13, 15400, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 646, 10634, 465, 6454, 199, 199, 504, 5020, 992, 14, 1086, 65, 14, 929, 2638, 492, 7249, 199, 3, 687, 1275, 2604, 492, 2058, 63, 83, 759, 988, 199, 504, 2680, 14, 4776, 492, 334, 272, 702, 63, 1452, 12, 702, 63, 1144, 63, 1452, 12, 702, 63, 4398, 63, 1452, 12, 702, 63, 3536, 199, 9, 199, 199, 533, 1379, 2404, 32012, 6443, 8, 785, 304, 339, 5560, 275, 359, 267, 334, 18, 12, 980, 14, 1144, 4038, 16, 12, 17, 6922, 16, 12, 16, 3934, 395, 267, 7287, 17, 3057, 17, 3057, 18, 467, 980, 14, 1144, 4038, 17, 12, 17, 6922, 18, 12, 16, 3934, 395, 267, 7287, 17, 3057, 17, 3057, 18, 3057, 19, 467, 980, 14, 1144, 4038, 17, 12, 17, 12, 16, 6922, 18, 12, 16, 12, 17, 6922, 19, 12, 16, 12, 16, 17723, 272, 1622, 339, 347, 511, 63, 9403, 8, 277, 304, 267, 367, 11849, 12, 754, 315, 291, 14, 9403, 26, 288, 702, 63, 1452, 8, 2537, 14, 863, 32012, 63, 3642, 8, 22104, 395, 754, 9, 199, 199, 533, 1379, 10746, 8, 785, 304, 339, 671, 275, 980, 14, 5605, 8, 709, 9, 272, 5560, 275, 359, 267, 327, 3915, 275, 413, 267, 7287, 17, 12, 18, 12, 19, 467, 413, 12, 488, 12, 413, 12, 359, 17, 12, 413, 2522, 267, 327, 3915, 275, 499, 267, 334, 88, 12, 499, 12, 488, 12, 413, 12, 359, 16, 3672, 24, 395, 267, 327, 3915, 275, 413, 12, 14718, 279, 63, 3028, 29, 17, 12, 1022, 63, 12605, 83, 29, 20, 267, 334, 88, 12, 413, 12, 413, 12, 841, 12, 359, 16, 3672, 21, 395, 267, 334, 88, 538, 18, 12, 413, 12, 413, 12, 841, 12, 359, 24, 3672, 21, 395, 267, 334, 88, 538, 19, 12, 413, 12, 413, 12, 841, 12, 359, 2259, 12, 8264, 12, 24579, 12, 27207, 12, 32609, 2522, 267, 327, 3915, 275, 413, 12, 14718, 279, 63, 3028, 29, 18, 12, 1022, 63, 12605, 83, 29, 18, 267, 334, 88, 12, 413, 12, 499, 12, 499, 12, 359, 16, 3672, 21, 395, 267, 334, 88, 538, 18, 12, 413, 12, 499, 12, 499, 12, 359, 16, 3672, 21, 395, 267, 334, 88, 538, 19, 12, 413, 12, 499, 12, 499, 12, 359, 1194, 3672, 21, 395, 267, 334, 88, 538, 20, 12, 413, 12, 499, 12, 499, 12, 359, 9873, 12, 650, 1344, 12, 841, 708, 12, 959, 1651, 12, 1227, 1194, 2522, 272, 1622, 339, 347, 511, 63, 9403, 8, 277, 304, 267, 327, 10082, 5560, 267, 367, 6779, 12, 3915, 12, 14718, 279, 63, 3028, 12, 1022, 63, 12605, 83, 12, 754, 315, 291, 14, 9403, 26, 7846, 327, 1379, 2680, 1625, 288, 671, 275, 7249, 14, 3028, 8, 5602, 12, 3915, 12, 14718, 279, 63, 3028, 12, 1022, 63, 12605, 83, 9, 288, 702, 63, 4398, 63, 1452, 8, 88, 12, 754, 9, 953, 327, 1379, 465, 510, 7683, 12403, 288, 6779, 275, 6454, 14, 9641, 8, 5602, 9, 953, 327, 799, 952, 370, 511, 465, 302, 13, 13014, 1625, 288, 6779, 275, 980, 14, 67, 9925, 5602, 12, 6779, 61, 288, 754, 275, 980, 14, 67, 9925, 1099, 12, 754, 61, 953, 327, 1379, 20535, 1625, 288, 671, 275, 7249, 14, 3028, 8, 5602, 12, 3915, 12, 14718, 279, 63, 3028, 12, 1022, 63, 12605, 83, 9, 288, 702, 63, 4398, 63, 1452, 8, 88, 12, 754, 9, 953, 327, 1379, 465, 510, 7683, 3918, 1943, 288, 6779, 275, 6454, 14, 9205, 8, 5602, 9, 288, 671, 275, 7249, 14, 3028, 8, 5602, 12, 3915, 12, 14718, 279, 63, 3028, 12, 1022, 63, 12605, 83, 9, 288, 702, 63, 4398, 63, 1452, 8, 88, 12, 754, 9, 199, 199, 533, 1379, 1831, 607, 12101, 830, 8, 785, 304, 339, 5560, 275, 359, 267, 7287, 17, 12, 446, 16, 14, 21, 467, 715, 395, 267, 7287, 17, 12, 413, 13, 17, 69, 13, 25, 467, 715, 395, 267, 7287, 17, 12, 413, 467, 756, 395, 267, 7287, 17, 12, 378, 14, 25, 12, 16, 14, 17, 467, 715, 395, 267, 334, 1590, 14, 1144, 779, 17, 12, 16, 14, 25, 12, 16, 14, 17, 2522, 715, 395, 267, 334, 8961, 14, 9641, 779, 17, 12, 16, 14, 25, 12, 16, 14, 17, 2522, 715, 9, 272, 1622, 339, 347, 511, 63, 9403, 8, 277, 304, 267, 367, 11849, 12, 315, 12101, 830, 315, 291, 14, 9403, 26, 288, 702, 63, 1452, 8, 2537, 14, 374, 63, 262, 12101, 830, 8, 22104, 395, 315, 12101, 830, 9, 199, 199, 533, 1379, 6361, 6322, 8517, 695, 1358, 23225, 8, 785, 304, 339, 5560, 275, 359, 267, 334, 1590, 14, 1144, 779, 18, 14, 2522, 446, 18, 13186, 1332, 17, 11, 18, 14, 538, 18, 6422, 16, 14, 21, 430, 272, 1622, 339, 347, 511, 63, 9403, 8, 277, 304, 267, 367, 625, 25990, 12, 28483, 315, 291, 14, 9403, 26, 288, 754, 275, 7249, 14, 1297, 6322, 63, 10600, 695, 63, 324, 23225, 8, 324, 25990, 9, 288, 702, 63, 1452, 8, 1099, 12, 28483, 9, 199, 199, 533, 1379, 12584, 6443, 7238, 8, 785, 304, 272, 327, 536, 12, 2215, 12, 30497, 12, 302, 4574, 12, 949, 1533, 272, 1686, 275, 359, 267, 661, 2864, 297, 334, 21, 12, 18, 395, 959, 12, 499, 12, 488, 395, 267, 661, 2864, 297, 334, 21, 12, 18, 395, 959, 12, 499, 12, 1616, 395, 267, 661, 2864, 297, 334, 21, 12, 18, 12, 709, 395, 959, 12, 499, 12, 1616, 395, 272, 1622, 272, 3866, 275, 359, 267, 661, 2864, 297, 334, 21, 4706, 959, 12, 488, 12, 488, 395, 267, 661, 2864, 297, 334, 21, 12, 17, 12, 17, 12, 17, 395, 959, 12, 413, 12, 488, 395, 267, 661, 2864, 297, 334, 21, 12, 18, 395, 1616, 12, 499, 12, 488, 395, 267, 661, 2864, 297, 334, 21, 12 ]
[ 199, 2925, 367, 7249, 199, 199, 5949, 26, 2799, 350, 481, 427, 265, 199, 3761, 26, 29094, 30200, 13, 15400, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 646, 10634, 465, 6454, 199, 199, 504, 5020, 992, 14, 1086, 65, 14, 929, 2638, 492, 7249, 199, 3, 687, 1275, 2604, 492, 2058, 63, 83, 759, 988, 199, 504, 2680, 14, 4776, 492, 334, 272, 702, 63, 1452, 12, 702, 63, 1144, 63, 1452, 12, 702, 63, 4398, 63, 1452, 12, 702, 63, 3536, 199, 9, 199, 199, 533, 1379, 2404, 32012, 6443, 8, 785, 304, 339, 5560, 275, 359, 267, 334, 18, 12, 980, 14, 1144, 4038, 16, 12, 17, 6922, 16, 12, 16, 3934, 395, 267, 7287, 17, 3057, 17, 3057, 18, 467, 980, 14, 1144, 4038, 17, 12, 17, 6922, 18, 12, 16, 3934, 395, 267, 7287, 17, 3057, 17, 3057, 18, 3057, 19, 467, 980, 14, 1144, 4038, 17, 12, 17, 12, 16, 6922, 18, 12, 16, 12, 17, 6922, 19, 12, 16, 12, 16, 17723, 272, 1622, 339, 347, 511, 63, 9403, 8, 277, 304, 267, 367, 11849, 12, 754, 315, 291, 14, 9403, 26, 288, 702, 63, 1452, 8, 2537, 14, 863, 32012, 63, 3642, 8, 22104, 395, 754, 9, 199, 199, 533, 1379, 10746, 8, 785, 304, 339, 671, 275, 980, 14, 5605, 8, 709, 9, 272, 5560, 275, 359, 267, 327, 3915, 275, 413, 267, 7287, 17, 12, 18, 12, 19, 467, 413, 12, 488, 12, 413, 12, 359, 17, 12, 413, 2522, 267, 327, 3915, 275, 499, 267, 334, 88, 12, 499, 12, 488, 12, 413, 12, 359, 16, 3672, 24, 395, 267, 327, 3915, 275, 413, 12, 14718, 279, 63, 3028, 29, 17, 12, 1022, 63, 12605, 83, 29, 20, 267, 334, 88, 12, 413, 12, 413, 12, 841, 12, 359, 16, 3672, 21, 395, 267, 334, 88, 538, 18, 12, 413, 12, 413, 12, 841, 12, 359, 24, 3672, 21, 395, 267, 334, 88, 538, 19, 12, 413, 12, 413, 12, 841, 12, 359, 2259, 12, 8264, 12, 24579, 12, 27207, 12, 32609, 2522, 267, 327, 3915, 275, 413, 12, 14718, 279, 63, 3028, 29, 18, 12, 1022, 63, 12605, 83, 29, 18, 267, 334, 88, 12, 413, 12, 499, 12, 499, 12, 359, 16, 3672, 21, 395, 267, 334, 88, 538, 18, 12, 413, 12, 499, 12, 499, 12, 359, 16, 3672, 21, 395, 267, 334, 88, 538, 19, 12, 413, 12, 499, 12, 499, 12, 359, 1194, 3672, 21, 395, 267, 334, 88, 538, 20, 12, 413, 12, 499, 12, 499, 12, 359, 9873, 12, 650, 1344, 12, 841, 708, 12, 959, 1651, 12, 1227, 1194, 2522, 272, 1622, 339, 347, 511, 63, 9403, 8, 277, 304, 267, 327, 10082, 5560, 267, 367, 6779, 12, 3915, 12, 14718, 279, 63, 3028, 12, 1022, 63, 12605, 83, 12, 754, 315, 291, 14, 9403, 26, 7846, 327, 1379, 2680, 1625, 288, 671, 275, 7249, 14, 3028, 8, 5602, 12, 3915, 12, 14718, 279, 63, 3028, 12, 1022, 63, 12605, 83, 9, 288, 702, 63, 4398, 63, 1452, 8, 88, 12, 754, 9, 953, 327, 1379, 465, 510, 7683, 12403, 288, 6779, 275, 6454, 14, 9641, 8, 5602, 9, 953, 327, 799, 952, 370, 511, 465, 302, 13, 13014, 1625, 288, 6779, 275, 980, 14, 67, 9925, 5602, 12, 6779, 61, 288, 754, 275, 980, 14, 67, 9925, 1099, 12, 754, 61, 953, 327, 1379, 20535, 1625, 288, 671, 275, 7249, 14, 3028, 8, 5602, 12, 3915, 12, 14718, 279, 63, 3028, 12, 1022, 63, 12605, 83, 9, 288, 702, 63, 4398, 63, 1452, 8, 88, 12, 754, 9, 953, 327, 1379, 465, 510, 7683, 3918, 1943, 288, 6779, 275, 6454, 14, 9205, 8, 5602, 9, 288, 671, 275, 7249, 14, 3028, 8, 5602, 12, 3915, 12, 14718, 279, 63, 3028, 12, 1022, 63, 12605, 83, 9, 288, 702, 63, 4398, 63, 1452, 8, 88, 12, 754, 9, 199, 199, 533, 1379, 1831, 607, 12101, 830, 8, 785, 304, 339, 5560, 275, 359, 267, 7287, 17, 12, 446, 16, 14, 21, 467, 715, 395, 267, 7287, 17, 12, 413, 13, 17, 69, 13, 25, 467, 715, 395, 267, 7287, 17, 12, 413, 467, 756, 395, 267, 7287, 17, 12, 378, 14, 25, 12, 16, 14, 17, 467, 715, 395, 267, 334, 1590, 14, 1144, 779, 17, 12, 16, 14, 25, 12, 16, 14, 17, 2522, 715, 395, 267, 334, 8961, 14, 9641, 779, 17, 12, 16, 14, 25, 12, 16, 14, 17, 2522, 715, 9, 272, 1622, 339, 347, 511, 63, 9403, 8, 277, 304, 267, 367, 11849, 12, 315, 12101, 830, 315, 291, 14, 9403, 26, 288, 702, 63, 1452, 8, 2537, 14, 374, 63, 262, 12101, 830, 8, 22104, 395, 315, 12101, 830, 9, 199, 199, 533, 1379, 6361, 6322, 8517, 695, 1358, 23225, 8, 785, 304, 339, 5560, 275, 359, 267, 334, 1590, 14, 1144, 779, 18, 14, 2522, 446, 18, 13186, 1332, 17, 11, 18, 14, 538, 18, 6422, 16, 14, 21, 430, 272, 1622, 339, 347, 511, 63, 9403, 8, 277, 304, 267, 367, 625, 25990, 12, 28483, 315, 291, 14, 9403, 26, 288, 754, 275, 7249, 14, 1297, 6322, 63, 10600, 695, 63, 324, 23225, 8, 324, 25990, 9, 288, 702, 63, 1452, 8, 1099, 12, 28483, 9, 199, 199, 533, 1379, 12584, 6443, 7238, 8, 785, 304, 272, 327, 536, 12, 2215, 12, 30497, 12, 302, 4574, 12, 949, 1533, 272, 1686, 275, 359, 267, 661, 2864, 297, 334, 21, 12, 18, 395, 959, 12, 499, 12, 488, 395, 267, 661, 2864, 297, 334, 21, 12, 18, 395, 959, 12, 499, 12, 1616, 395, 267, 661, 2864, 297, 334, 21, 12, 18, 12, 709, 395, 959, 12, 499, 12, 1616, 395, 272, 1622, 272, 3866, 275, 359, 267, 661, 2864, 297, 334, 21, 4706, 959, 12, 488, 12, 488, 395, 267, 661, 2864, 297, 334, 21, 12, 17, 12, 17, 12, 17, 395, 959, 12, 413, 12, 488, 395, 267, 661, 2864, 297, 334, 21, 12, 18, 395, 1616, 12, 499, 12, 488, 395, 267, 661, 2864, 297, 334, 21, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
aroche/django
tests/model_formsets/models.py
143
7751
from __future__ import unicode_literals import datetime import uuid from django.db import models from django.utils import six from django.utils.encoding import python_2_unicode_compatible @python_2_unicode_compatible class Author(models.Model): name = models.CharField(max_length=100) class Meta: ordering = ('name',) def __str__(self): return self.name class BetterAuthor(Author): write_speed = models.IntegerField() @python_2_unicode_compatible class Book(models.Model): author = models.ForeignKey(Author, models.CASCADE) title = models.CharField(max_length=100) class Meta: unique_together = ( ('author', 'title'), ) ordering = ['id'] def __str__(self): return self.title @python_2_unicode_compatible class BookWithCustomPK(models.Model): my_pk = models.DecimalField(max_digits=5, decimal_places=0, primary_key=True) author = models.ForeignKey(Author, models.CASCADE) title = models.CharField(max_length=100) def __str__(self): return '%s: %s' % (self.my_pk, self.title) class Editor(models.Model): name = models.CharField(max_length=100) @python_2_unicode_compatible class BookWithOptionalAltEditor(models.Model): author = models.ForeignKey(Author, models.CASCADE) # Optional secondary author alt_editor = models.ForeignKey(Editor, models.SET_NULL, blank=True, null=True) title = models.CharField(max_length=100) class Meta: unique_together = ( ('author', 'title', 'alt_editor'), ) def __str__(self): return self.title @python_2_unicode_compatible class AlternateBook(Book): notes = models.CharField(max_length=100) def __str__(self): return '%s - %s' % (self.title, self.notes) @python_2_unicode_compatible class AuthorMeeting(models.Model): name = models.CharField(max_length=100) authors = models.ManyToManyField(Author) created = models.DateField(editable=False) def __str__(self): return self.name class CustomPrimaryKey(models.Model): my_pk = models.CharField(max_length=10, primary_key=True) some_field = models.CharField(max_length=100) # models for inheritance tests. @python_2_unicode_compatible class Place(models.Model): name = models.CharField(max_length=50) city = models.CharField(max_length=50) def __str__(self): return self.name @python_2_unicode_compatible class Owner(models.Model): auto_id = models.AutoField(primary_key=True) name = models.CharField(max_length=100) place = models.ForeignKey(Place, models.CASCADE) def __str__(self): return "%s at %s" % (self.name, self.place) class Location(models.Model): place = models.ForeignKey(Place, models.CASCADE, unique=True) # this is purely for testing the data doesn't matter here :) lat = models.CharField(max_length=100) lon = models.CharField(max_length=100) @python_2_unicode_compatible class OwnerProfile(models.Model): owner = models.OneToOneField(Owner, models.CASCADE, primary_key=True) age = models.PositiveIntegerField() def __str__(self): return "%s is %d" % (self.owner.name, self.age) @python_2_unicode_compatible class Restaurant(Place): serves_pizza = models.BooleanField(default=False) def __str__(self): return self.name @python_2_unicode_compatible class Product(models.Model): slug = models.SlugField(unique=True) def __str__(self): return self.slug @python_2_unicode_compatible class Price(models.Model): price = models.DecimalField(max_digits=10, decimal_places=2) quantity = models.PositiveIntegerField() def __str__(self): return "%s for %s" % (self.quantity, self.price) class Meta: unique_together = (('price', 'quantity'),) class MexicanRestaurant(Restaurant): serves_tacos = models.BooleanField(default=False) class ClassyMexicanRestaurant(MexicanRestaurant): restaurant = models.OneToOneField(MexicanRestaurant, models.CASCADE, parent_link=True, primary_key=True) tacos_are_yummy = models.BooleanField(default=False) # models for testing unique_together validation when a fk is involved and # using inlineformset_factory. @python_2_unicode_compatible class Repository(models.Model): name = models.CharField(max_length=25) def __str__(self): return self.name @python_2_unicode_compatible class Revision(models.Model): repository = models.ForeignKey(Repository, models.CASCADE) revision = models.CharField(max_length=40) class Meta: unique_together = (("repository", "revision"),) def __str__(self): return "%s (%s)" % (self.revision, six.text_type(self.repository)) # models for testing callable defaults (see bug #7975). If you define a model # with a callable default value, you cannot rely on the initial value in a # form. class Person(models.Model): name = models.CharField(max_length=128) class Membership(models.Model): person = models.ForeignKey(Person, models.CASCADE) date_joined = models.DateTimeField(default=datetime.datetime.now) karma = models.IntegerField() # models for testing a null=True fk to a parent class Team(models.Model): name = models.CharField(max_length=100) @python_2_unicode_compatible class Player(models.Model): team = models.ForeignKey(Team, models.SET_NULL, null=True) name = models.CharField(max_length=100) def __str__(self): return self.name # Models for testing custom ModelForm save methods in formsets and inline formsets @python_2_unicode_compatible class Poet(models.Model): name = models.CharField(max_length=100) def __str__(self): return self.name @python_2_unicode_compatible class Poem(models.Model): poet = models.ForeignKey(Poet, models.CASCADE) name = models.CharField(max_length=100) def __str__(self): return self.name @python_2_unicode_compatible class Post(models.Model): title = models.CharField(max_length=50, unique_for_date='posted', blank=True) slug = models.CharField(max_length=50, unique_for_year='posted', blank=True) subtitle = models.CharField(max_length=50, unique_for_month='posted', blank=True) posted = models.DateField() def __str__(self): return self.name # Models for testing UUID primary keys class UUIDPKParent(models.Model): uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) name = models.CharField(max_length=255) class UUIDPKChild(models.Model): uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) name = models.CharField(max_length=255) parent = models.ForeignKey(UUIDPKParent, models.CASCADE) class ChildWithEditablePK(models.Model): name = models.CharField(max_length=255, primary_key=True) parent = models.ForeignKey(UUIDPKParent, models.CASCADE) class AutoPKChildOfUUIDPKParent(models.Model): name = models.CharField(max_length=255) parent = models.ForeignKey(UUIDPKParent, models.CASCADE) class AutoPKParent(models.Model): name = models.CharField(max_length=255) class UUIDPKChildOfAutoPKParent(models.Model): uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) name = models.CharField(max_length=255) parent = models.ForeignKey(AutoPKParent, models.CASCADE) class ParentWithUUIDAlternateKey(models.Model): uuid = models.UUIDField(unique=True, default=uuid.uuid4, editable=False) name = models.CharField(max_length=50) class ChildRelatedViaAK(models.Model): name = models.CharField(max_length=255) parent = models.ForeignKey(ParentWithUUIDAlternateKey, models.CASCADE, to_field='uuid')
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 646, 5377, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 6529, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 1021, 6288, 26, 267, 7794, 275, 661, 354, 9538, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 533, 31535, 351, 5949, 8, 5949, 304, 272, 2218, 63, 7625, 275, 1709, 14, 3901, 342, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8944, 8, 992, 14, 1685, 304, 272, 4132, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 9, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 1021, 6288, 26, 267, 3747, 63, 6314, 275, 334, 288, 661, 2502, 297, 283, 1213, 659, 267, 776, 267, 7794, 275, 788, 344, 418, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1213, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8944, 3007, 7223, 8884, 8, 992, 14, 1685, 304, 272, 3002, 63, 2051, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 21, 12, 6107, 63, 10696, 29, 16, 12, 5062, 63, 498, 29, 549, 9, 272, 4132, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 9, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 83, 26, 450, 83, 7, 450, 334, 277, 14, 1662, 63, 2051, 12, 291, 14, 1213, 9, 421, 199, 533, 30318, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8944, 3007, 7012, 16985, 10423, 8, 992, 14, 1685, 304, 272, 4132, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 9, 272, 327, 4879, 13851, 4132, 272, 8791, 63, 7515, 275, 1709, 14, 3190, 8, 10423, 12, 1709, 14, 3597, 63, 8084, 12, 4596, 29, 549, 12, 2973, 29, 549, 9, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 1021, 6288, 26, 267, 3747, 63, 6314, 275, 334, 288, 661, 2502, 297, 283, 1213, 297, 283, 4478, 63, 7515, 659, 267, 776, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1213, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 17669, 323, 8696, 8, 8696, 304, 272, 12681, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 83, 446, 450, 83, 7, 450, 334, 277, 14, 1213, 12, 291, 14, 5983, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 6529, 1352, 13800, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 11462, 275, 1709, 14, 7624, 8, 5949, 9, 272, 2737, 275, 1709, 14, 14071, 8, 10820, 29, 797, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 533, 8388, 29457, 8, 992, 14, 1685, 304, 272, 3002, 63, 2051, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 709, 12, 5062, 63, 498, 29, 549, 9, 272, 2005, 63, 698, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 421, 199, 3, 1709, 367, 15433, 2295, 14, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 10902, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 14492, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 593, 4977, 8, 992, 14, 1685, 304, 272, 2599, 63, 344, 275, 1709, 14, 4378, 8, 3327, 63, 498, 29, 549, 9, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 4192, 275, 1709, 14, 3190, 8, 11613, 12, 1709, 14, 10855, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2071, 83, 737, 450, 83, 2, 450, 334, 277, 14, 354, 12, 291, 14, 2778, 9, 421, 199, 533, 12625, 8, 992, 14, 1685, 304, 272, 4192, 275, 1709, 14, 3190, 8, 11613, 12, 1709, 14, 10855, 12, 3747, 29, 549, 9, 272, 327, 642, 365, 15111, 590, 367, 5343, 314, 666, 3181, 1133, 17247, 2348, 32428, 272, 8396, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 6132, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 593, 4977, 5736, 8, 992, 14, 1685, 304, 272, 5771, 275, 1709, 14, 14298, 8, 14919, 12, 1709, 14, 10855, 12, 5062, 63, 498, 29, 549, 9, 272, 11437, 275, 1709, 14, 8591, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2071, 83, 365, 450, 68, 2, 450, 334, 277, 14, 4597, 14, 354, 12, 291, 14, 474, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 799, 14436, 8, 11613, 304, 272, 23739, 63, 80, 30937, 275, 1709, 14, 5036, 8, 885, 29, 797, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 12705, 8, 992, 14, 1685, 304, 272, 8889, 275, 1709, 14, 17315, 8, 3235, 29, 549, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 5464, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 20276, 8, 992, 14, 1685, 304, 272, 8033, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 709, 12, 6107, 63, 10696, 29, 18, 9, 272, 12524, 275, 1709, 14, 8591, 342, 339, 347, 636, 495, 721, 277 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 646, 5377, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 6529, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 1021, 6288, 26, 267, 7794, 275, 661, 354, 9538, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 533, 31535, 351, 5949, 8, 5949, 304, 272, 2218, 63, 7625, 275, 1709, 14, 3901, 342, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8944, 8, 992, 14, 1685, 304, 272, 4132, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 9, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 1021, 6288, 26, 267, 3747, 63, 6314, 275, 334, 288, 661, 2502, 297, 283, 1213, 659, 267, 776, 267, 7794, 275, 788, 344, 418, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1213, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8944, 3007, 7223, 8884, 8, 992, 14, 1685, 304, 272, 3002, 63, 2051, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 21, 12, 6107, 63, 10696, 29, 16, 12, 5062, 63, 498, 29, 549, 9, 272, 4132, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 9, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 83, 26, 450, 83, 7, 450, 334, 277, 14, 1662, 63, 2051, 12, 291, 14, 1213, 9, 421, 199, 533, 30318, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8944, 3007, 7012, 16985, 10423, 8, 992, 14, 1685, 304, 272, 4132, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 9, 272, 327, 4879, 13851, 4132, 272, 8791, 63, 7515, 275, 1709, 14, 3190, 8, 10423, 12, 1709, 14, 3597, 63, 8084, 12, 4596, 29, 549, 12, 2973, 29, 549, 9, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 1021, 6288, 26, 267, 3747, 63, 6314, 275, 334, 288, 661, 2502, 297, 283, 1213, 297, 283, 4478, 63, 7515, 659, 267, 776, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1213, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 17669, 323, 8696, 8, 8696, 304, 272, 12681, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 83, 446, 450, 83, 7, 450, 334, 277, 14, 1213, 12, 291, 14, 5983, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 6529, 1352, 13800, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 11462, 275, 1709, 14, 7624, 8, 5949, 9, 272, 2737, 275, 1709, 14, 14071, 8, 10820, 29, 797, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 533, 8388, 29457, 8, 992, 14, 1685, 304, 272, 3002, 63, 2051, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 709, 12, 5062, 63, 498, 29, 549, 9, 272, 2005, 63, 698, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 421, 199, 3, 1709, 367, 15433, 2295, 14, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 10902, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 14492, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 593, 4977, 8, 992, 14, 1685, 304, 272, 2599, 63, 344, 275, 1709, 14, 4378, 8, 3327, 63, 498, 29, 549, 9, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 4192, 275, 1709, 14, 3190, 8, 11613, 12, 1709, 14, 10855, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2071, 83, 737, 450, 83, 2, 450, 334, 277, 14, 354, 12, 291, 14, 2778, 9, 421, 199, 533, 12625, 8, 992, 14, 1685, 304, 272, 4192, 275, 1709, 14, 3190, 8, 11613, 12, 1709, 14, 10855, 12, 3747, 29, 549, 9, 272, 327, 642, 365, 15111, 590, 367, 5343, 314, 666, 3181, 1133, 17247, 2348, 32428, 272, 8396, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 6132, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 593, 4977, 5736, 8, 992, 14, 1685, 304, 272, 5771, 275, 1709, 14, 14298, 8, 14919, 12, 1709, 14, 10855, 12, 5062, 63, 498, 29, 549, 9, 272, 11437, 275, 1709, 14, 8591, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2071, 83, 365, 450, 68, 2, 450, 334, 277, 14, 4597, 14, 354, 12, 291, 14, 474, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 799, 14436, 8, 11613, 304, 272, 23739, 63, 80, 30937, 275, 1709, 14, 5036, 8, 885, 29, 797, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 12705, 8, 992, 14, 1685, 304, 272, 8889, 275, 1709, 14, 17315, 8, 3235, 29, 549, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 5464, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 20276, 8, 992, 14, 1685, 304, 272, 8033, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 709, 12, 6107, 63, 10696, 29, 18, 9, 272, 12524, 275, 1709, 14, 8591, 342, 339, 347, 636, 495, 721, 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, 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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 ]
mrkm4ntr/incubator-airflow
tests/providers/microsoft/azure/transfers/test_file_to_wasb.py
7
2577
# # 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 datetime import unittest from unittest import mock from airflow.models.dag import DAG from airflow.providers.microsoft.azure.transfers.file_to_wasb import FileToWasbOperator class TestFileToWasbOperator(unittest.TestCase): _config = { 'file_path': 'file', 'container_name': 'container', 'blob_name': 'blob', 'wasb_conn_id': 'wasb_default', 'retries': 3, } def setUp(self): args = {'owner': 'airflow', 'start_date': datetime.datetime(2017, 1, 1)} self.dag = DAG('test_dag_id', default_args=args) def test_init(self): operator = FileToWasbOperator(task_id='wasb_operator_1', dag=self.dag, **self._config) self.assertEqual(operator.file_path, self._config['file_path']) self.assertEqual(operator.container_name, self._config['container_name']) self.assertEqual(operator.blob_name, self._config['blob_name']) self.assertEqual(operator.wasb_conn_id, self._config['wasb_conn_id']) self.assertEqual(operator.load_options, {}) self.assertEqual(operator.retries, self._config['retries']) operator = FileToWasbOperator( task_id='wasb_operator_2', dag=self.dag, load_options={'timeout': 2}, **self._config ) self.assertEqual(operator.load_options, {'timeout': 2}) @mock.patch('airflow.providers.microsoft.azure.transfers.file_to_wasb.WasbHook', autospec=True) def test_execute(self, mock_hook): mock_instance = mock_hook.return_value operator = FileToWasbOperator( task_id='wasb_sensor', dag=self.dag, load_options={'timeout': 2}, **self._config ) operator.execute(None) mock_instance.load_file.assert_called_once_with('file', 'container', 'blob', timeout=2)
apache-2.0
[ 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 2197, 199, 646, 2882, 199, 504, 2882, 492, 1683, 199, 199, 504, 16321, 14, 992, 14, 7406, 492, 19666, 199, 504, 16321, 14, 9710, 14, 17040, 14, 9078, 14, 1515, 70, 1192, 14, 493, 63, 475, 63, 10274, 66, 492, 3814, 1378, 55, 305, 66, 7961, 421, 199, 533, 1379, 1173, 1378, 55, 305, 66, 7961, 8, 2796, 14, 1746, 304, 339, 485, 888, 275, 469, 267, 283, 493, 63, 515, 356, 283, 493, 297, 267, 283, 3600, 63, 354, 356, 283, 3600, 297, 267, 283, 6582, 63, 354, 356, 283, 6582, 297, 267, 283, 10274, 66, 63, 1631, 63, 344, 356, 283, 10274, 66, 63, 885, 297, 267, 283, 10937, 356, 650, 12, 272, 789, 339, 347, 3613, 8, 277, 304, 267, 1249, 275, 791, 4597, 356, 283, 15815, 297, 283, 928, 63, 602, 356, 2197, 14, 2083, 8, 10680, 12, 413, 12, 413, 6769, 267, 291, 14, 7406, 275, 19666, 360, 396, 63, 7406, 63, 344, 297, 849, 63, 589, 29, 589, 9, 339, 347, 511, 63, 826, 8, 277, 304, 267, 4182, 275, 3814, 1378, 55, 305, 66, 7961, 8, 1765, 63, 344, 534, 10274, 66, 63, 3856, 63, 17, 297, 10158, 29, 277, 14, 7406, 12, 1011, 277, 423, 888, 9, 267, 291, 14, 629, 8, 3856, 14, 493, 63, 515, 12, 291, 423, 888, 459, 493, 63, 515, 1105, 267, 291, 14, 629, 8, 3856, 14, 3600, 63, 354, 12, 291, 423, 888, 459, 3600, 63, 354, 1105, 267, 291, 14, 629, 8, 3856, 14, 6582, 63, 354, 12, 291, 423, 888, 459, 6582, 63, 354, 1105, 267, 291, 14, 629, 8, 3856, 14, 10274, 66, 63, 1631, 63, 344, 12, 291, 423, 888, 459, 10274, 66, 63, 1631, 63, 344, 1105, 267, 291, 14, 629, 8, 3856, 14, 912, 63, 1419, 12, 5009, 267, 291, 14, 629, 8, 3856, 14, 10937, 12, 291, 423, 888, 459, 10937, 1105, 398, 4182, 275, 3814, 1378, 55, 305, 66, 7961, 8, 288, 2120, 63, 344, 534, 10274, 66, 63, 3856, 63, 18, 297, 10158, 29, 277, 14, 7406, 12, 2248, 63, 1419, 3713, 2593, 356, 499, 1386, 1011, 277, 423, 888, 267, 776, 267, 291, 14, 629, 8, 3856, 14, 912, 63, 1419, 12, 791, 2593, 356, 499, 1552, 339, 768, 1805, 14, 2068, 360, 15815, 14, 9710, 14, 17040, 14, 9078, 14, 1515, 70, 1192, 14, 493, 63, 475, 63, 10274, 66, 14, 55, 305, 66, 8481, 297, 18052, 29, 549, 9, 272, 347, 511, 63, 2526, 8, 277, 12, 1683, 63, 3664, 304, 267, 1683, 63, 842, 275, 1683, 63, 3664, 14, 1107, 63, 585, 267, 4182, 275, 3814, 1378, 55, 305, 66, 7961, 8, 288, 2120, 63, 344, 534, 10274, 66, 63, 8956, 297, 10158, 29, 277, 14, 7406, 12, 2248, 63, 1419, 3713, 2593, 356, 499, 1386, 1011, 277, 423, 888, 267, 776, 267, 4182, 14, 2526, 8, 403, 9, 267, 1683, 63, 842, 14, 912, 63, 493, 14, 479, 63, 3527, 63, 5089, 63, 1045, 360, 493, 297, 283, 3600, 297, 283, 6582, 297, 2653, 29, 18, 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 ]
[ 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 2197, 199, 646, 2882, 199, 504, 2882, 492, 1683, 199, 199, 504, 16321, 14, 992, 14, 7406, 492, 19666, 199, 504, 16321, 14, 9710, 14, 17040, 14, 9078, 14, 1515, 70, 1192, 14, 493, 63, 475, 63, 10274, 66, 492, 3814, 1378, 55, 305, 66, 7961, 421, 199, 533, 1379, 1173, 1378, 55, 305, 66, 7961, 8, 2796, 14, 1746, 304, 339, 485, 888, 275, 469, 267, 283, 493, 63, 515, 356, 283, 493, 297, 267, 283, 3600, 63, 354, 356, 283, 3600, 297, 267, 283, 6582, 63, 354, 356, 283, 6582, 297, 267, 283, 10274, 66, 63, 1631, 63, 344, 356, 283, 10274, 66, 63, 885, 297, 267, 283, 10937, 356, 650, 12, 272, 789, 339, 347, 3613, 8, 277, 304, 267, 1249, 275, 791, 4597, 356, 283, 15815, 297, 283, 928, 63, 602, 356, 2197, 14, 2083, 8, 10680, 12, 413, 12, 413, 6769, 267, 291, 14, 7406, 275, 19666, 360, 396, 63, 7406, 63, 344, 297, 849, 63, 589, 29, 589, 9, 339, 347, 511, 63, 826, 8, 277, 304, 267, 4182, 275, 3814, 1378, 55, 305, 66, 7961, 8, 1765, 63, 344, 534, 10274, 66, 63, 3856, 63, 17, 297, 10158, 29, 277, 14, 7406, 12, 1011, 277, 423, 888, 9, 267, 291, 14, 629, 8, 3856, 14, 493, 63, 515, 12, 291, 423, 888, 459, 493, 63, 515, 1105, 267, 291, 14, 629, 8, 3856, 14, 3600, 63, 354, 12, 291, 423, 888, 459, 3600, 63, 354, 1105, 267, 291, 14, 629, 8, 3856, 14, 6582, 63, 354, 12, 291, 423, 888, 459, 6582, 63, 354, 1105, 267, 291, 14, 629, 8, 3856, 14, 10274, 66, 63, 1631, 63, 344, 12, 291, 423, 888, 459, 10274, 66, 63, 1631, 63, 344, 1105, 267, 291, 14, 629, 8, 3856, 14, 912, 63, 1419, 12, 5009, 267, 291, 14, 629, 8, 3856, 14, 10937, 12, 291, 423, 888, 459, 10937, 1105, 398, 4182, 275, 3814, 1378, 55, 305, 66, 7961, 8, 288, 2120, 63, 344, 534, 10274, 66, 63, 3856, 63, 18, 297, 10158, 29, 277, 14, 7406, 12, 2248, 63, 1419, 3713, 2593, 356, 499, 1386, 1011, 277, 423, 888, 267, 776, 267, 291, 14, 629, 8, 3856, 14, 912, 63, 1419, 12, 791, 2593, 356, 499, 1552, 339, 768, 1805, 14, 2068, 360, 15815, 14, 9710, 14, 17040, 14, 9078, 14, 1515, 70, 1192, 14, 493, 63, 475, 63, 10274, 66, 14, 55, 305, 66, 8481, 297, 18052, 29, 549, 9, 272, 347, 511, 63, 2526, 8, 277, 12, 1683, 63, 3664, 304, 267, 1683, 63, 842, 275, 1683, 63, 3664, 14, 1107, 63, 585, 267, 4182, 275, 3814, 1378, 55, 305, 66, 7961, 8, 288, 2120, 63, 344, 534, 10274, 66, 63, 8956, 297, 10158, 29, 277, 14, 7406, 12, 2248, 63, 1419, 3713, 2593, 356, 499, 1386, 1011, 277, 423, 888, 267, 776, 267, 4182, 14, 2526, 8, 403, 9, 267, 1683, 63, 842, 14, 912, 63, 493, 14, 479, 63, 3527, 63, 5089, 63, 1045, 360, 493, 297, 283, 3600, 297, 283, 6582, 297, 2653, 29, 18, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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= "int('qwe')" excinfo = pytest.raises(ValueError, source) code = excinfo.traceback[-1].frame.code s = str(code.fullsource) assert s == source def test_raises_exec(self): pytest.raises(ValueError, "a,x = []") def test_raises_syntax_error(self): pytest.raises(SyntaxError, "qwe qwe qwe") def test_raises_function(self): pytest.raises(ValueError, int, 'hello') def test_raises_callable_no_exception(self): class A: def __call__(self): pass try: pytest.raises(ValueError, A()) except pytest.raises.Exception: pass def test_raises_flip_builtin_AssertionError(self): # we replace AssertionError on python level # however c code might still raise the builtin one from _pytest.assertion.util import BuiltinAssertionError # noqa pytest.raises(AssertionError,""" raise BuiltinAssertionError """) def test_raises_as_contextmanager(self, testdir): testdir.makepyfile(""" from __future__ import with_statement import py, pytest import _pytest._code def test_simple(): with pytest.raises(ZeroDivisionError) as excinfo: assert isinstance(excinfo, _pytest._code.ExceptionInfo) 1/0 print (excinfo) assert excinfo.type == ZeroDivisionError assert isinstance(excinfo.value, ZeroDivisionError) def test_noraise(): with pytest.raises(pytest.raises.Exception): with pytest.raises(ValueError): int() def test_raise_wrong_exception_passes_by(): with pytest.raises(ZeroDivisionError): with pytest.raises(ValueError): 1/0 """) result = testdir.runpytest() result.stdout.fnmatch_lines([ '*3 passed*', ]) def test_noclass(self): with pytest.raises(TypeError): pytest.raises('wrong', lambda: None) def test_tuple(self): with pytest.raises((KeyError, ValueError)): raise KeyError('oops') def test_no_raise_message(self): try: pytest.raises(ValueError, int, '0') except pytest.raises.Exception as e: assert e.msg == "DID NOT RAISE {0}".format(repr(ValueError))
mpl-2.0
[ 646, 4613, 199, 199, 533, 1379, 1811, 26, 272, 347, 511, 63, 3536, 8, 277, 304, 267, 1350, 275, 298, 442, 360, 81, 1129, 19124, 267, 21596, 275, 4613, 14, 3536, 8, 3393, 12, 1350, 9, 267, 1233, 275, 21596, 14, 6894, 1988, 17, 1055, 1943, 14, 600, 267, 308, 275, 620, 8, 600, 14, 28418, 616, 9, 267, 702, 308, 508, 1350, 339, 347, 511, 63, 3536, 63, 1628, 8, 277, 304, 267, 4613, 14, 3536, 8, 3393, 12, 298, 65, 12, 88, 275, 942, 531, 339, 347, 511, 63, 3536, 63, 7093, 63, 705, 8, 277, 304, 267, 4613, 14, 3536, 8, 9294, 12, 298, 81, 1129, 1894, 1129, 1894, 1129, 531, 339, 347, 511, 63, 3536, 63, 1593, 8, 277, 304, 267, 4613, 14, 3536, 8, 3393, 12, 1109, 12, 283, 5006, 358, 339, 347, 511, 63, 3536, 63, 8296, 63, 889, 63, 1971, 8, 277, 304, 267, 1021, 437, 26, 288, 347, 636, 1250, 721, 277, 304, 355, 986, 267, 862, 26, 288, 4613, 14, 3536, 8, 3393, 12, 437, 1012, 267, 871, 4613, 14, 3536, 14, 1726, 26, 288, 986, 339, 347, 511, 63, 3536, 63, 16114, 63, 5351, 63, 14844, 8, 277, 304, 267, 327, 781, 3350, 9070, 641, 2366, 2166, 267, 327, 13432, 286, 1233, 5594, 5139, 746, 314, 6762, 1373, 267, 687, 485, 4462, 14, 18487, 14, 1974, 492, 22422, 14844, 327, 8151, 267, 4613, 14, 3536, 8, 14844, 12, 624, 288, 746, 22422, 14844, 267, 7857, 339, 347, 511, 63, 3536, 63, 305, 63, 14237, 8, 277, 12, 7368, 304, 267, 7368, 14, 17358, 4852, 288, 687, 636, 2443, 363, 492, 543, 63, 6242, 288, 492, 1134, 12, 4613, 288, 492, 485, 4462, 423, 600, 953, 347, 511, 63, 4129, 837, 355, 543, 4613, 14, 3536, 8, 31000, 9, 465, 21596, 26, 490, 702, 1228, 8, 27447, 12, 485, 4462, 423, 600, 14, 1726, 2354, 9, 490, 413, 15, 16, 355, 870, 334, 27447, 9, 355, 702, 21596, 14, 466, 508, 25838, 355, 702, 1228, 8, 27447, 14, 585, 12, 25838, 9, 953, 347, 511, 63, 6505, 65, 572, 837, 355, 543, 4613, 14, 3536, 8, 4462, 14, 3536, 14, 1726, 304, 490, 543, 4613, 14, 3536, 8, 3393, 304, 2574, 1109, 342, 953, 347, 511, 63, 3730, 63, 10603, 63, 1971, 63, 16027, 63, 991, 837, 355, 543, 4613, 14, 3536, 8, 31000, 304, 490, 543, 4613, 14, 3536, 8, 3393, 304, 2574, 413, 15, 16, 267, 7857, 267, 754, 275, 7368, 14, 19889, 342, 267, 754, 14, 2703, 14, 15359, 63, 1278, 779, 288, 6438, 19, 3032, 7693, 267, 4794, 339, 347, 511, 63, 889, 533, 8, 277, 304, 267, 543, 4613, 14, 3536, 8, 4333, 304, 288, 4613, 14, 3536, 360, 10603, 297, 2400, 26, 488, 9, 339, 347, 511, 63, 2960, 8, 277, 304, 267, 543, 4613, 14, 3536, 1332, 10230, 12, 1722, 2298, 288, 746, 4067, 360, 79, 1483, 358, 339, 347, 511, 63, 889, 63, 3730, 63, 1188, 8, 277, 304, 267, 862, 26, 288, 4613, 14, 3536, 8, 3393, 12, 1109, 12, 283, 16, 358, 267, 871, 4613, 14, 3536, 14, 1726, 465, 325, 26, 288, 702, 325, 14, 1328, 508, 298, 36, 998, 2845, 31632, 4971, 469, 16, 5469, 908, 8, 2722, 8, 3393, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4613, 199, 199, 533, 1379, 1811, 26, 272, 347, 511, 63, 3536, 8, 277, 304, 267, 1350, 275, 298, 442, 360, 81, 1129, 19124, 267, 21596, 275, 4613, 14, 3536, 8, 3393, 12, 1350, 9, 267, 1233, 275, 21596, 14, 6894, 1988, 17, 1055, 1943, 14, 600, 267, 308, 275, 620, 8, 600, 14, 28418, 616, 9, 267, 702, 308, 508, 1350, 339, 347, 511, 63, 3536, 63, 1628, 8, 277, 304, 267, 4613, 14, 3536, 8, 3393, 12, 298, 65, 12, 88, 275, 942, 531, 339, 347, 511, 63, 3536, 63, 7093, 63, 705, 8, 277, 304, 267, 4613, 14, 3536, 8, 9294, 12, 298, 81, 1129, 1894, 1129, 1894, 1129, 531, 339, 347, 511, 63, 3536, 63, 1593, 8, 277, 304, 267, 4613, 14, 3536, 8, 3393, 12, 1109, 12, 283, 5006, 358, 339, 347, 511, 63, 3536, 63, 8296, 63, 889, 63, 1971, 8, 277, 304, 267, 1021, 437, 26, 288, 347, 636, 1250, 721, 277, 304, 355, 986, 267, 862, 26, 288, 4613, 14, 3536, 8, 3393, 12, 437, 1012, 267, 871, 4613, 14, 3536, 14, 1726, 26, 288, 986, 339, 347, 511, 63, 3536, 63, 16114, 63, 5351, 63, 14844, 8, 277, 304, 267, 327, 781, 3350, 9070, 641, 2366, 2166, 267, 327, 13432, 286, 1233, 5594, 5139, 746, 314, 6762, 1373, 267, 687, 485, 4462, 14, 18487, 14, 1974, 492, 22422, 14844, 327, 8151, 267, 4613, 14, 3536, 8, 14844, 12, 624, 288, 746, 22422, 14844, 267, 7857, 339, 347, 511, 63, 3536, 63, 305, 63, 14237, 8, 277, 12, 7368, 304, 267, 7368, 14, 17358, 4852, 288, 687, 636, 2443, 363, 492, 543, 63, 6242, 288, 492, 1134, 12, 4613, 288, 492, 485, 4462, 423, 600, 953, 347, 511, 63, 4129, 837, 355, 543, 4613, 14, 3536, 8, 31000, 9, 465, 21596, 26, 490, 702, 1228, 8, 27447, 12, 485, 4462, 423, 600, 14, 1726, 2354, 9, 490, 413, 15, 16, 355, 870, 334, 27447, 9, 355, 702, 21596, 14, 466, 508, 25838, 355, 702, 1228, 8, 27447, 14, 585, 12, 25838, 9, 953, 347, 511, 63, 6505, 65, 572, 837, 355, 543, 4613, 14, 3536, 8, 4462, 14, 3536, 14, 1726, 304, 490, 543, 4613, 14, 3536, 8, 3393, 304, 2574, 1109, 342, 953, 347, 511, 63, 3730, 63, 10603, 63, 1971, 63, 16027, 63, 991, 837, 355, 543, 4613, 14, 3536, 8, 31000, 304, 490, 543, 4613, 14, 3536, 8, 3393, 304, 2574, 413, 15, 16, 267, 7857, 267, 754, 275, 7368, 14, 19889, 342, 267, 754, 14, 2703, 14, 15359, 63, 1278, 779, 288, 6438, 19, 3032, 7693, 267, 4794, 339, 347, 511, 63, 889, 533, 8, 277, 304, 267, 543, 4613, 14, 3536, 8, 4333, 304, 288, 4613, 14, 3536, 360, 10603, 297, 2400, 26, 488, 9, 339, 347, 511, 63, 2960, 8, 277, 304, 267, 543, 4613, 14, 3536, 1332, 10230, 12, 1722, 2298, 288, 746, 4067, 360, 79, 1483, 358, 339, 347, 511, 63, 889, 63, 3730, 63, 1188, 8, 277, 304, 267, 862, 26, 288, 4613, 14, 3536, 8, 3393, 12, 1109, 12, 283, 16, 358, 267, 871, 4613, 14, 3536, 14, 1726, 465, 325, 26, 288, 702, 325, 14, 1328, 508, 298, 36, 998, 2845, 31632, 4971, 469, 16, 5469, 908, 8, 2722, 8, 3393, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Danielhiversen/home-assistant
homeassistant/components/sensor/starlingbank.py
5
3333
""" Support for balance data via the Starling Bank API. For more details about this platform, please refer to the documentation at https://www.home-assistant.io/components/sensor.starlingbank/ """ import logging import requests import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import CONF_ACCESS_TOKEN, CONF_NAME import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity REQUIREMENTS = ['starlingbank==1.2'] _LOGGER = logging.getLogger(__name__) BALANCE_TYPES = ['cleared_balance', 'effective_balance'] CONF_ACCOUNTS = 'accounts' CONF_BALANCE_TYPES = 'balance_types' CONF_SANDBOX = 'sandbox' DEFAULT_SANDBOX = False DEFAULT_ACCOUNT_NAME = 'Starling' ICON = 'mdi:currency-gbp' ACCOUNT_SCHEMA = vol.Schema({ vol.Required(CONF_ACCESS_TOKEN): cv.string, vol.Optional(CONF_BALANCE_TYPES, default=BALANCE_TYPES): vol.All(cv.ensure_list, [vol.In(BALANCE_TYPES)]), vol.Optional(CONF_NAME, default=DEFAULT_ACCOUNT_NAME): cv.string, vol.Optional(CONF_SANDBOX, default=DEFAULT_SANDBOX): cv.boolean, }) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_ACCOUNTS): vol.Schema([ACCOUNT_SCHEMA]), }) def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Sterling Bank sensor platform.""" from starlingbank import StarlingAccount sensors = [] for account in config[CONF_ACCOUNTS]: try: starling_account = StarlingAccount( account[CONF_ACCESS_TOKEN], sandbox=account[CONF_SANDBOX]) for balance_type in account[CONF_BALANCE_TYPES]: sensors.append(StarlingBalanceSensor( starling_account, account[CONF_NAME], balance_type)) except requests.exceptions.HTTPError as error: _LOGGER.error( "Unable to set up Starling account '%s': %s", account[CONF_NAME], error) add_devices(sensors, True) class StarlingBalanceSensor(Entity): """Representation of a Starling balance sensor.""" def __init__(self, starling_account, account_name, balance_data_type): """Initialize the sensor.""" self._starling_account = starling_account self._balance_data_type = balance_data_type self._state = None self._account_name = account_name @property def name(self): """Return the name of the sensor.""" return "{0} {1}".format( self._account_name, self._balance_data_type.replace('_', ' ').capitalize()) @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement.""" return self._starling_account.currency @property def icon(self): """Return the entity icon.""" return ICON def update(self): """Fetch new state data for the sensor.""" self._starling_account.balance.update() if self._balance_data_type == 'cleared_balance': self._state = self._starling_account.balance.cleared_balance elif self._balance_data_type == 'effective_balance': self._state = self._starling_account.balance.effective_balance
mit
[ 624, 199, 11532, 367, 14094, 666, 4799, 314, 1933, 285, 2983, 28721, 3261, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 1544, 14, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 8956, 14, 7848, 2983, 9860, 15, 199, 624, 199, 646, 2050, 199, 199, 646, 4145, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 4608, 14, 8956, 492, 21966, 63, 10926, 199, 504, 8846, 14, 1297, 492, 6392, 63, 11074, 63, 8803, 12, 6392, 63, 2339, 199, 646, 8846, 14, 7546, 14, 888, 63, 6136, 465, 6277, 199, 504, 8846, 14, 7546, 14, 4502, 492, 17680, 199, 199, 29168, 20967, 275, 788, 7848, 2983, 9860, 389, 17, 14, 18, 418, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 31232, 7140, 63, 7893, 275, 788, 2265, 2899, 63, 7358, 297, 283, 20427, 63, 7358, 418, 199, 199, 3103, 63, 18928, 51, 275, 283, 8370, 7, 199, 3103, 63, 31232, 7140, 63, 7893, 275, 283, 7358, 63, 1313, 7, 199, 3103, 63, 51, 879, 2846, 29544, 275, 283, 16647, 7, 199, 199, 3472, 63, 51, 879, 2846, 29544, 275, 756, 199, 3472, 63, 18928, 63, 2339, 275, 283, 23197, 2983, 7, 199, 199, 15903, 275, 283, 20208, 26, 4968, 13, 4908, 80, 7, 199, 199, 18928, 63, 10926, 275, 5236, 14, 6700, 2561, 272, 5236, 14, 8030, 8, 3103, 63, 11074, 63, 8803, 304, 6277, 14, 875, 12, 272, 5236, 14, 7012, 8, 3103, 63, 31232, 7140, 63, 7893, 12, 849, 29, 31232, 7140, 63, 7893, 304, 267, 5236, 14, 2422, 8, 5107, 14, 7505, 63, 513, 12, 359, 5650, 14, 607, 8, 31232, 7140, 63, 7893, 16636, 272, 5236, 14, 7012, 8, 3103, 63, 2339, 12, 849, 29, 3472, 63, 18928, 63, 2339, 304, 6277, 14, 875, 12, 272, 5236, 14, 7012, 8, 3103, 63, 51, 879, 2846, 29544, 12, 849, 29, 3472, 63, 51, 879, 2846, 29544, 304, 6277, 14, 4871, 12, 199, 1552, 199, 199, 17805, 63, 10926, 275, 21966, 63, 10926, 14, 2880, 2561, 272, 5236, 14, 8030, 8, 3103, 63, 18928, 51, 304, 5236, 14, 6700, 779, 18928, 63, 10926, 2522, 199, 1552, 421, 199, 318, 3272, 63, 3246, 8, 5387, 12, 1101, 12, 1050, 63, 6410, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 1084, 1536, 314, 428, 351, 2983, 28721, 8778, 4298, 1041, 272, 687, 14664, 2983, 9860, 492, 1933, 285, 2983, 6009, 339, 19678, 275, 942, 272, 367, 2933, 315, 1101, 59, 3103, 63, 18928, 51, 2189, 267, 862, 26, 288, 14664, 2983, 63, 2048, 275, 1933, 285, 2983, 6009, 8, 355, 2933, 59, 3103, 63, 11074, 63, 8803, 467, 19699, 29, 2048, 59, 3103, 63, 51, 879, 2846, 29544, 566, 288, 367, 14094, 63, 466, 315, 2933, 59, 3103, 63, 31232, 7140, 63, 7893, 2189, 355, 19678, 14, 740, 8, 23197, 2983, 27106, 10160, 8, 490, 14664, 2983, 63, 2048, 12, 2933, 59, 3103, 63, 2339, 467, 14094, 63, 466, 430, 267, 871, 4145, 14, 3924, 14, 12815, 465, 1125, 26, 288, 485, 10186, 14, 705, 8, 355, 298, 6005, 370, 663, 1536, 1933, 285, 2983, 2933, 1543, 83, 356, 450, 83, 401, 355, 2933, 59, 3103, 63, 2339, 467, 1125, 9, 339, 1050, 63, 6410, 8, 22675, 12, 715, 9, 421, 199, 533, 1933, 285, 2983, 27106, 10160, 8, 7302, 304, 272, 408, 20609, 402, 282, 1933, 285, 2983, 14094, 8778, 1041, 339, 347, 636, 826, 721, 277, 12, 14664, 2983, 63, 2048, 12, 2933, 63, 354, 12, 14094, 63, 576, 63, 466, 304, 267, 408, 9345, 314, 8778, 1041, 267, 291, 423, 7848, 2983, 63, 2048, 275, 14664, 2983, 63, 2048, 267, 291, 423, 7358, 63, 576, 63, 466, 275, 14094, 63, 576, 63, 466, 267, 291, 423, 929, 275, 488, 267, 291, 423, 2048, 63, 354, 275, 2933, 63, 354, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 8778, 1041, 267, 372, 5310, 16, 93, 469, 17, 5469, 908, 8, 288, 291, 423, 2048, 63, 354, 12, 288, 291, 423, 7358, 63, 576, 63, 466, 14, 1814, 20928, 283, 27274, 18351, 1012, 339, 768, 1829, 272, 347, 1174, 8, 277, 304, 267, 408, 1767, 314, 1174, 402, 314, 8778, 1041, 267, 372, 291, 423, 929, 339, 768, 1829, 272, 347, 4137, 63, 1618, 63, 17912, 8, 277, 304, 267, 408, 1767, 314, 4137, 402, 18216, 1041, 267, 372, 291, 423, 7848, 2983, 63, 2048, 14, 4968, 339, 768, 1829, 272, 347, 7016, 8, 277, 304, 267, 408, 1767, 314, 4642, 7016, 1041, 267, 372, 473, 1864, 339, 347, 1678, 8, 277, 304, 267, 408, 11135, 892, 1174, 666, 367, 314, 8778, 1041, 267, 291, 423, 7848, 2983, 63, 2048, 14, 7358, 14, 873, 342, 267, 340, 291, 423, 7358, 63, 576, 63, 466, 508, 283, 2265, 2899, 63, 7358, 356, 288, 291, 423, 929, 275, 291, 423, 7848, 2983, 63, 2048, 14, 7358, 14, 2265, 2899, 63, 7358, 267, 916, 291, 423, 7358, 63, 576, 63, 466, 508, 283, 20427, 63, 7358, 356, 288, 291, 423, 929, 275, 291, 423, 7848, 2983, 63, 2048, 14, 7358, 14, 20427, 63, 7358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 14094, 666, 4799, 314, 1933, 285, 2983, 28721, 3261, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 1544, 14, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 8956, 14, 7848, 2983, 9860, 15, 199, 624, 199, 646, 2050, 199, 199, 646, 4145, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 4608, 14, 8956, 492, 21966, 63, 10926, 199, 504, 8846, 14, 1297, 492, 6392, 63, 11074, 63, 8803, 12, 6392, 63, 2339, 199, 646, 8846, 14, 7546, 14, 888, 63, 6136, 465, 6277, 199, 504, 8846, 14, 7546, 14, 4502, 492, 17680, 199, 199, 29168, 20967, 275, 788, 7848, 2983, 9860, 389, 17, 14, 18, 418, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 31232, 7140, 63, 7893, 275, 788, 2265, 2899, 63, 7358, 297, 283, 20427, 63, 7358, 418, 199, 199, 3103, 63, 18928, 51, 275, 283, 8370, 7, 199, 3103, 63, 31232, 7140, 63, 7893, 275, 283, 7358, 63, 1313, 7, 199, 3103, 63, 51, 879, 2846, 29544, 275, 283, 16647, 7, 199, 199, 3472, 63, 51, 879, 2846, 29544, 275, 756, 199, 3472, 63, 18928, 63, 2339, 275, 283, 23197, 2983, 7, 199, 199, 15903, 275, 283, 20208, 26, 4968, 13, 4908, 80, 7, 199, 199, 18928, 63, 10926, 275, 5236, 14, 6700, 2561, 272, 5236, 14, 8030, 8, 3103, 63, 11074, 63, 8803, 304, 6277, 14, 875, 12, 272, 5236, 14, 7012, 8, 3103, 63, 31232, 7140, 63, 7893, 12, 849, 29, 31232, 7140, 63, 7893, 304, 267, 5236, 14, 2422, 8, 5107, 14, 7505, 63, 513, 12, 359, 5650, 14, 607, 8, 31232, 7140, 63, 7893, 16636, 272, 5236, 14, 7012, 8, 3103, 63, 2339, 12, 849, 29, 3472, 63, 18928, 63, 2339, 304, 6277, 14, 875, 12, 272, 5236, 14, 7012, 8, 3103, 63, 51, 879, 2846, 29544, 12, 849, 29, 3472, 63, 51, 879, 2846, 29544, 304, 6277, 14, 4871, 12, 199, 1552, 199, 199, 17805, 63, 10926, 275, 21966, 63, 10926, 14, 2880, 2561, 272, 5236, 14, 8030, 8, 3103, 63, 18928, 51, 304, 5236, 14, 6700, 779, 18928, 63, 10926, 2522, 199, 1552, 421, 199, 318, 3272, 63, 3246, 8, 5387, 12, 1101, 12, 1050, 63, 6410, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 1084, 1536, 314, 428, 351, 2983, 28721, 8778, 4298, 1041, 272, 687, 14664, 2983, 9860, 492, 1933, 285, 2983, 6009, 339, 19678, 275, 942, 272, 367, 2933, 315, 1101, 59, 3103, 63, 18928, 51, 2189, 267, 862, 26, 288, 14664, 2983, 63, 2048, 275, 1933, 285, 2983, 6009, 8, 355, 2933, 59, 3103, 63, 11074, 63, 8803, 467, 19699, 29, 2048, 59, 3103, 63, 51, 879, 2846, 29544, 566, 288, 367, 14094, 63, 466, 315, 2933, 59, 3103, 63, 31232, 7140, 63, 7893, 2189, 355, 19678, 14, 740, 8, 23197, 2983, 27106, 10160, 8, 490, 14664, 2983, 63, 2048, 12, 2933, 59, 3103, 63, 2339, 467, 14094, 63, 466, 430, 267, 871, 4145, 14, 3924, 14, 12815, 465, 1125, 26, 288, 485, 10186, 14, 705, 8, 355, 298, 6005, 370, 663, 1536, 1933, 285, 2983, 2933, 1543, 83, 356, 450, 83, 401, 355, 2933, 59, 3103, 63, 2339, 467, 1125, 9, 339, 1050, 63, 6410, 8, 22675, 12, 715, 9, 421, 199, 533, 1933, 285, 2983, 27106, 10160, 8, 7302, 304, 272, 408, 20609, 402, 282, 1933, 285, 2983, 14094, 8778, 1041, 339, 347, 636, 826, 721, 277, 12, 14664, 2983, 63, 2048, 12, 2933, 63, 354, 12, 14094, 63, 576, 63, 466, 304, 267, 408, 9345, 314, 8778, 1041, 267, 291, 423, 7848, 2983, 63, 2048, 275, 14664, 2983, 63, 2048, 267, 291, 423, 7358, 63, 576, 63, 466, 275, 14094, 63, 576, 63, 466, 267, 291, 423, 929, 275, 488, 267, 291, 423, 2048, 63, 354, 275, 2933, 63, 354, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 8778, 1041, 267, 372, 5310, 16, 93, 469, 17, 5469, 908, 8, 288, 291, 423, 2048, 63, 354, 12, 288, 291, 423, 7358, 63, 576, 63, 466, 14, 1814, 20928, 283, 27274, 18351, 1012, 339, 768, 1829, 272, 347, 1174, 8, 277, 304, 267, 408, 1767, 314, 1174, 402, 314, 8778, 1041, 267, 372, 291, 423, 929, 339, 768, 1829, 272, 347, 4137, 63, 1618, 63, 17912, 8, 277, 304, 267, 408, 1767, 314, 4137, 402, 18216, 1041, 267, 372, 291, 423, 7848, 2983, 63, 2048, 14, 4968, 339, 768, 1829, 272, 347, 7016, 8, 277, 304, 267, 408, 1767, 314, 4642, 7016, 1041, 267, 372, 473, 1864, 339, 347, 1678, 8, 277, 304, 267, 408, 11135, 892, 1174, 666, 367, 314, 8778, 1041, 267, 291, 423, 7848, 2983, 63, 2048, 14, 7358, 14, 873, 342, 267, 340, 291, 423, 7358, 63, 576, 63, 466, 508, 283, 2265, 2899, 63, 7358, 356, 288, 291, 423, 929, 275, 291, 423, 7848, 2983, 63, 2048, 14, 7358, 14, 2265, 2899, 63, 7358, 267, 916, 291, 423, 7358, 63, 576, 63, 466, 508, 283, 20427, 63, 7358, 356, 288, 291, 423, 929, 275, 291, 423, 7848, 2983, 63, 2048, 14, 7358, 14, 20427, 63, 7358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
badreddinetahir/pwn_plug_sources
src/fasttrack/bin/menu/sqlinjector.py
16
1116
#!/usr/bin/env python import os,sys,time definepath=os.getcwd() sys.path.append("%s/bin/ftsrc/" % (definepath)) import include while 1==1: include.print_banner() menu=raw_input(""" Enter which SQL Injector you want to use: 1. SQL Injector - Query String Parameter Attack 2. SQL Injector - POST Parameter Attack 3. SQL Injector - GET FTP Payload Attack 4. SQL Injector - GET Manual Setup Binary Payload Attack (q)uit Enter your choice: """) if menu == 'quit' or menu == 'q': break # Start query string attack if menu == '1': try: reload(sqlbinarypayload) except Exception: pass import sqlbinarypayload # POST ATTACK if menu == '2': try: reload(sqlbinarypayloadpost) except Exception: pass import sqlbinarypayloadpost # Reverse FTP if menu == '3': try: reload(sqlftppayload) except Exception: pass import sqlftppayload # manual setup if menu == '4': try: reload(sqlmanual) except Exception: pass import sqlmanual
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 646, 747, 12, 1274, 12, 521, 199, 4640, 515, 29, 736, 14, 9458, 342, 199, 1274, 14, 515, 14, 740, 3647, 83, 15, 1393, 15, 856, 2164, 6687, 450, 334, 4640, 515, 430, 199, 646, 2387, 199, 6710, 413, 389, 17, 26, 2043, 2387, 14, 1361, 63, 13066, 342, 2043, 6269, 29, 1773, 63, 1210, 4852, 199, 8468, 1314, 5385, 1010, 19625, 1265, 2934, 370, 675, 26, 339, 413, 14, 5385, 1010, 19625, 446, 8133, 2624, 12009, 2854, 13058, 272, 499, 14, 5385, 1010, 19625, 446, 8761, 12009, 2854, 13058, 272, 650, 14, 5385, 1010, 19625, 446, 9576, 23125, 15911, 912, 2854, 13058, 272, 841, 14, 5385, 1010, 19625, 446, 9576, 30247, 12439, 14161, 15911, 912, 2854, 13058, 339, 334, 81, 9, 4993, 339, 16401, 2195, 7141, 26, 7857, 2043, 340, 6269, 508, 283, 10589, 7, 503, 6269, 508, 283, 81, 356, 2059, 2043, 327, 7707, 1827, 1059, 23326, 2043, 340, 6269, 508, 283, 17, 356, 489, 862, 26, 268, 13101, 8, 3009, 3008, 4749, 9, 489, 871, 2186, 26, 268, 986, 489, 492, 3875, 3008, 4749, 2043, 327, 8761, 10395, 3099, 2043, 340, 6269, 508, 283, 18, 356, 489, 862, 26, 268, 13101, 8, 3009, 3008, 4749, 1932, 9, 489, 871, 2186, 26, 268, 986, 489, 492, 3875, 3008, 4749, 1932, 8410, 327, 22734, 23125, 2043, 340, 6269, 508, 283, 19, 356, 489, 862, 26, 268, 13101, 8, 3526, 276, 683, 4749, 9, 489, 871, 2186, 26, 268, 986, 489, 492, 5295, 276, 683, 4749, 2043, 327, 8722, 3272, 2043, 340, 6269, 508, 283, 20, 356, 489, 862, 26, 268, 13101, 8, 3009, 9285, 9, 489, 871, 2186, 26, 268, 986, 489, 492, 3875, 9285, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 646, 747, 12, 1274, 12, 521, 199, 4640, 515, 29, 736, 14, 9458, 342, 199, 1274, 14, 515, 14, 740, 3647, 83, 15, 1393, 15, 856, 2164, 6687, 450, 334, 4640, 515, 430, 199, 646, 2387, 199, 6710, 413, 389, 17, 26, 2043, 2387, 14, 1361, 63, 13066, 342, 2043, 6269, 29, 1773, 63, 1210, 4852, 199, 8468, 1314, 5385, 1010, 19625, 1265, 2934, 370, 675, 26, 339, 413, 14, 5385, 1010, 19625, 446, 8133, 2624, 12009, 2854, 13058, 272, 499, 14, 5385, 1010, 19625, 446, 8761, 12009, 2854, 13058, 272, 650, 14, 5385, 1010, 19625, 446, 9576, 23125, 15911, 912, 2854, 13058, 272, 841, 14, 5385, 1010, 19625, 446, 9576, 30247, 12439, 14161, 15911, 912, 2854, 13058, 339, 334, 81, 9, 4993, 339, 16401, 2195, 7141, 26, 7857, 2043, 340, 6269, 508, 283, 10589, 7, 503, 6269, 508, 283, 81, 356, 2059, 2043, 327, 7707, 1827, 1059, 23326, 2043, 340, 6269, 508, 283, 17, 356, 489, 862, 26, 268, 13101, 8, 3009, 3008, 4749, 9, 489, 871, 2186, 26, 268, 986, 489, 492, 3875, 3008, 4749, 2043, 327, 8761, 10395, 3099, 2043, 340, 6269, 508, 283, 18, 356, 489, 862, 26, 268, 13101, 8, 3009, 3008, 4749, 1932, 9, 489, 871, 2186, 26, 268, 986, 489, 492, 3875, 3008, 4749, 1932, 8410, 327, 22734, 23125, 2043, 340, 6269, 508, 283, 19, 356, 489, 862, 26, 268, 13101, 8, 3526, 276, 683, 4749, 9, 489, 871, 2186, 26, 268, 986, 489, 492, 5295, 276, 683, 4749, 2043, 327, 8722, 3272, 2043, 340, 6269, 508, 283, 20, 356, 489, 862, 26, 268, 13101, 8, 3009, 9285, 9, 489, 871, 2186, 26, 268, 986, 489, 492, 3875, 9285, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
peterhenderson/python-enunciate-samples
familytree.py
1
5994
try: import json except ImportError: import simplejson as json def parse(input): """Parse specified file or string and return a FamilyTree object created from it.""" if hasattr(input, "read"): data = json.load(input) else: data = json.loads(input) return FamilyTree(data) class JSONBase: """Base class for all JSON-related objects""" def to_json(self): return json.dumps(self.to_json_dict()) def __repr__(self): return self.to_json() class FamilyTree(JSONBase): def __init__(self, o): if "statusCode" in o: self.statusCode = o["statusCode"] if "statusMessage" in o: self.statusMessage = o["statusMessage"] if "version" in o: self.version = o["version"] if "pedigrees" in o: self.pedigrees = [] for item in o["pedigrees"]: self.pedigrees.append(Pedigree(item)) def to_json_dict(self): d = {} if hasattr(self, "statusCode"): d["statusCode"] = self.statusCode if hasattr(self, "statusMessage"): d["statusMessage"] = self.statusMessage if hasattr(self, "version"): d["version"] = self.version if hasattr(self, "pedigrees"): a = [] for item in self.pedigrees: a.append(item.to_json_dict()) d["pedigrees"] = a return d class Pedigree(JSONBase): def __init__(self, o): if "id" in o: self.id = o["id"] if "requestedId" in o: self.requestedId = o["requestedId"] if "persons" in o: self.persons = [] for item in o["persons"]: self.persons.append(Person(item)) def to_json_dict(self): d = {} if hasattr(self, "id"): d["id"] = self.id if hasattr(self, "requestedId"): d["requestedId"] = self.requestedId if hasattr(self, "persons"): a = [] for item in self.persons: a.append(item.to_json_dict()) d["persons"] = a return d class Person(JSONBase): def __init__(self, o): if "id" in o: self.id = o["id"] if "assertions" in o: self.assertions = PersonAssertions(o["assertions"]) if "parents" in o: self.parents = [] for item in o["parents"]: self.parents.append(ParentsReference(item)) def to_json_dict(self): d = {} if hasattr(self, "id"): d["id"] = self.id if hasattr(self, "assertions"): d["assertions"] = self.assertions.to_json_dict() if hasattr(self, "parents"): a = [] for item in self.parents: a.append(item.to_json_dict()) d["parents"] = a return d class PersonAssertions(JSONBase): def __init__(self, o): if "names" in o: self.names = [] for item in o["names"]: self.names.append(NameAssertion(item)) if "genders" in o: self.genders = [] for item in o["genders"]: self.genders.append(GenderAssertion(item)) def to_json_dict(self): d = {} if hasattr(self, "names"): a = [] for item in self.names: a.append(item.to_json_dict()) d["names"] = a if hasattr(self, "genders"): a = [] for item in self.genders: a.append(item.to_json_dict()) d["genders"] = a return d class NameAssertion(JSONBase): def __init__(self, o): if "value" in o: self.value = NameValue(o["value"]) def to_json_dict(self): d = {} if hasattr(self, "value"): d["value"] = self.value.to_json_dict() return d class NameValue(JSONBase): def __init__(self, o): if "forms" in o: self.forms = [] for item in o["forms"]: self.forms.append(NameForm(item)) def to_json_dict(self): d = {} if hasattr(self, "forms"): a = [] for item in self.forms: a.append(item.to_json_dict()) d["forms"] = a return d class NameForm(JSONBase): def __init__(self, o): if "fullText" in o: self.fullText = o["fullText"] def to_json_dict(self): d = {} if hasattr(self, "fullText"): d["fullText"] = self.fullText return d class GenderAssertion(JSONBase): def __init__(self, o): if "value" in o: self.value = GenderValue(o["value"]) def to_json_dict(self): d = {} if hasattr(self, "value"): d["value"] = self.value.to_json_dict() return d class GenderValue(JSONBase): def __init__(self, o): if "type" in o: self.type = o["type"] def to_json_dict(self): d = {} if hasattr(self, "type"): d["type"] = self.type return d class ParentsReference(JSONBase): def __init__(self, o): if "parent" in o: self.parents = [] for item in o["parent"]: self.parents.append(PersonReference(item)) def to_json_dict(self): d = {} if hasattr(self, "parents"): a = [] for item in self.parents: a.append(item.to_json_dict()) d["parent"] = a d["parents"] = a return d class PersonReference(JSONBase): def __init__(self, o): if "id" in o: self.id = o["id"] if "gender" in o: self.gender = o["gender"] def to_json_dict(self): d = {} if hasattr(self, "id"): d["id"] = self.id if hasattr(self, "gender"): d["gender"] = self.gender return d
apache-2.0
[ 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 492, 13804, 465, 2022, 421, 199, 318, 2198, 8, 1210, 304, 272, 408, 4003, 2013, 570, 503, 1059, 436, 372, 282, 481, 4632, 3987, 909, 2737, 687, 652, 1041, 272, 340, 2688, 8, 1210, 12, 298, 739, 2349, 267, 666, 275, 2022, 14, 912, 8, 1210, 9, 272, 587, 26, 267, 666, 275, 2022, 14, 3640, 8, 1210, 9, 272, 372, 481, 4632, 3987, 8, 576, 9, 421, 199, 533, 4840, 1563, 26, 272, 408, 1563, 1021, 367, 1006, 4840, 13, 2407, 2251, 624, 272, 347, 370, 63, 1001, 8, 277, 304, 267, 372, 2022, 14, 4180, 8, 277, 14, 475, 63, 1001, 63, 807, 1012, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 291, 14, 475, 63, 1001, 342, 421, 199, 533, 481, 4632, 3987, 8, 6243, 1563, 304, 272, 347, 636, 826, 721, 277, 12, 312, 304, 267, 340, 298, 1205, 3034, 2, 315, 312, 26, 288, 291, 14, 1205, 3034, 275, 312, 905, 1205, 3034, 937, 267, 340, 298, 1205, 2209, 2, 315, 312, 26, 288, 291, 14, 1205, 2209, 275, 312, 905, 1205, 2209, 937, 267, 340, 298, 1023, 2, 315, 312, 26, 288, 291, 14, 1023, 275, 312, 905, 1023, 937, 267, 340, 298, 321, 18367, 5710, 2, 315, 312, 26, 288, 291, 14, 321, 18367, 5710, 275, 942, 288, 367, 1242, 315, 312, 905, 321, 18367, 5710, 6229, 355, 291, 14, 321, 18367, 5710, 14, 740, 8, 48, 6297, 71, 850, 8, 1053, 430, 339, 347, 370, 63, 1001, 63, 807, 8, 277, 304, 267, 366, 275, 1052, 267, 340, 2688, 8, 277, 12, 298, 1205, 3034, 2349, 288, 366, 905, 1205, 3034, 937, 275, 291, 14, 1205, 3034, 267, 340, 2688, 8, 277, 12, 298, 1205, 2209, 2349, 288, 366, 905, 1205, 2209, 937, 275, 291, 14, 1205, 2209, 267, 340, 2688, 8, 277, 12, 298, 1023, 2349, 288, 366, 905, 1023, 937, 275, 291, 14, 1023, 267, 340, 2688, 8, 277, 12, 298, 321, 18367, 5710, 2349, 288, 282, 275, 942, 288, 367, 1242, 315, 291, 14, 321, 18367, 5710, 26, 355, 282, 14, 740, 8, 1053, 14, 475, 63, 1001, 63, 807, 1012, 288, 366, 905, 321, 18367, 5710, 937, 275, 282, 267, 372, 366, 421, 199, 533, 510, 6297, 71, 850, 8, 6243, 1563, 304, 272, 347, 636, 826, 721, 277, 12, 312, 304, 267, 340, 298, 344, 2, 315, 312, 26, 288, 291, 14, 344, 275, 312, 905, 344, 937, 267, 340, 298, 11151, 1304, 2, 315, 312, 26, 288, 291, 14, 11151, 1304, 275, 312, 905, 11151, 1304, 937, 267, 340, 298, 32146, 2, 315, 312, 26, 288, 291, 14, 32146, 275, 942, 288, 367, 1242, 315, 312, 905, 32146, 6229, 355, 291, 14, 32146, 14, 740, 8, 7344, 8, 1053, 430, 339, 347, 370, 63, 1001, 63, 807, 8, 277, 304, 267, 366, 275, 1052, 267, 340, 2688, 8, 277, 12, 298, 344, 2349, 288, 366, 905, 344, 937, 275, 291, 14, 344, 267, 340, 2688, 8, 277, 12, 298, 11151, 1304, 2349, 288, 366, 905, 11151, 1304, 937, 275, 291, 14, 11151, 1304, 267, 340, 2688, 8, 277, 12, 298, 32146, 2349, 288, 282, 275, 942, 288, 367, 1242, 315, 291, 14, 32146, 26, 355, 282, 14, 740, 8, 1053, 14, 475, 63, 1001, 63, 807, 1012, 288, 366, 905, 32146, 937, 275, 282, 267, 372, 366, 421, 199, 533, 8028, 8, 6243, 1563, 304, 272, 347, 636, 826, 721, 277, 12, 312, 304, 267, 340, 298, 344, 2, 315, 312, 26, 288, 291, 14, 344, 275, 312, 905, 344, 937, 267, 340, 298, 305, 13049, 2, 315, 312, 26, 288, 291, 14, 305, 13049, 275, 8028, 2822, 13049, 8, 79, 905, 305, 13049, 3135, 267, 340, 298, 8859, 2, 315, 312, 26, 288, 291, 14, 8859, 275, 942, 288, 367, 1242, 315, 312, 905, 8859, 6229, 355, 291, 14, 8859, 14, 740, 8, 6652, 83, 5083, 8, 1053, 430, 339, 347, 370, 63, 1001, 63, 807, 8, 277, 304, 267, 366, 275, 1052, 267, 340, 2688, 8, 277, 12, 298, 344, 2349, 288, 366, 905, 344, 937, 275, 291, 14, 344, 267, 340, 2688, 8, 277, 12, 298, 305, 13049, 2349, 288, 366, 905, 305, 13049, 937, 275, 291, 14, 305, 13049, 14, 475, 63, 1001, 63, 807, 342, 267, 340, 2688, 8, 277, 12, 298, 8859, 2349, 288, 282, 275, 942, 288, 367, 1242, 315, 291, 14, 8859, 26, 355, 282, 14, 740, 8, 1053, 14, 475, 63, 1001, 63, 807, 1012, 288, 366, 905, 8859, 937, 275, 282, 267, 372, 366, 421, 199, 533, 8028, 2822, 13049, 8, 6243, 1563, 304, 272, 347, 636, 826, 721, 277, 12, 312, 304, 267, 340, 298, 1247, 2, 315, 312, 26, 288, 291, 14, 1247, 275, 942, 288, 367, 1242, 315, 312, 905, 1247, 6229, 355, 291, 14, 1247, 14, 740, 8, 985, 26860, 8, 1053, 430, 267, 340, 298, 2268, 7735, 2, 315, 312, 26, 288, 291, 14, 2268, 7735, 275, 942, 288, 367, 1242, 315, 312, 905, 2268, 7735, 6229, 355, 291, 14, 2268, 7735, 14, 740, 8, 8168, 424, 26860, 8, 1053, 430, 339, 347, 370, 63, 1001, 63, 807, 8, 277, 304, 267, 366, 275, 1052, 267, 340, 2688, 8, 277, 12, 298, 1247, 2349, 288, 282, 275, 942, 288, 367, 1242, 315, 291, 14, 1247, 26, 355, 282, 14, 740, 8, 1053, 14, 475, 63, 1001, 63, 807, 1012, 288, 366, 905, 1247, 937, 275, 282, 267, 340, 2688, 8, 277, 12, 298, 2268, 7735, 2349, 288, 282, 275, 942, 288, 367, 1242, 315, 291, 14, 2268, 7735, 26, 355, 282, 14, 740, 8, 1053, 14, 475, 63, 1001, 63, 807, 1012, 288, 366, 905, 2268, 7735, 937, 275, 282, 267, 372, 366, 421, 199, 533, 2812, 26860, 8, 6243, 1563, 304, 272, 347, 636, 826, 721, 277, 12, 312, 304, 267, 340, 298, 585, 2, 315, 312, 26, 288, 291, 14, 585, 275, 2812, 1110, 8, 79, 905, 585, 3135, 339, 347, 370, 63, 1001, 63, 807, 8, 277, 304, 267, 366, 275, 1052, 267, 340, 2688, 8, 277, 12, 298, 585, 2349, 288, 366, 905, 585, 937, 275, 291, 14, 585, 14 ]
[ 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 492, 13804, 465, 2022, 421, 199, 318, 2198, 8, 1210, 304, 272, 408, 4003, 2013, 570, 503, 1059, 436, 372, 282, 481, 4632, 3987, 909, 2737, 687, 652, 1041, 272, 340, 2688, 8, 1210, 12, 298, 739, 2349, 267, 666, 275, 2022, 14, 912, 8, 1210, 9, 272, 587, 26, 267, 666, 275, 2022, 14, 3640, 8, 1210, 9, 272, 372, 481, 4632, 3987, 8, 576, 9, 421, 199, 533, 4840, 1563, 26, 272, 408, 1563, 1021, 367, 1006, 4840, 13, 2407, 2251, 624, 272, 347, 370, 63, 1001, 8, 277, 304, 267, 372, 2022, 14, 4180, 8, 277, 14, 475, 63, 1001, 63, 807, 1012, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 291, 14, 475, 63, 1001, 342, 421, 199, 533, 481, 4632, 3987, 8, 6243, 1563, 304, 272, 347, 636, 826, 721, 277, 12, 312, 304, 267, 340, 298, 1205, 3034, 2, 315, 312, 26, 288, 291, 14, 1205, 3034, 275, 312, 905, 1205, 3034, 937, 267, 340, 298, 1205, 2209, 2, 315, 312, 26, 288, 291, 14, 1205, 2209, 275, 312, 905, 1205, 2209, 937, 267, 340, 298, 1023, 2, 315, 312, 26, 288, 291, 14, 1023, 275, 312, 905, 1023, 937, 267, 340, 298, 321, 18367, 5710, 2, 315, 312, 26, 288, 291, 14, 321, 18367, 5710, 275, 942, 288, 367, 1242, 315, 312, 905, 321, 18367, 5710, 6229, 355, 291, 14, 321, 18367, 5710, 14, 740, 8, 48, 6297, 71, 850, 8, 1053, 430, 339, 347, 370, 63, 1001, 63, 807, 8, 277, 304, 267, 366, 275, 1052, 267, 340, 2688, 8, 277, 12, 298, 1205, 3034, 2349, 288, 366, 905, 1205, 3034, 937, 275, 291, 14, 1205, 3034, 267, 340, 2688, 8, 277, 12, 298, 1205, 2209, 2349, 288, 366, 905, 1205, 2209, 937, 275, 291, 14, 1205, 2209, 267, 340, 2688, 8, 277, 12, 298, 1023, 2349, 288, 366, 905, 1023, 937, 275, 291, 14, 1023, 267, 340, 2688, 8, 277, 12, 298, 321, 18367, 5710, 2349, 288, 282, 275, 942, 288, 367, 1242, 315, 291, 14, 321, 18367, 5710, 26, 355, 282, 14, 740, 8, 1053, 14, 475, 63, 1001, 63, 807, 1012, 288, 366, 905, 321, 18367, 5710, 937, 275, 282, 267, 372, 366, 421, 199, 533, 510, 6297, 71, 850, 8, 6243, 1563, 304, 272, 347, 636, 826, 721, 277, 12, 312, 304, 267, 340, 298, 344, 2, 315, 312, 26, 288, 291, 14, 344, 275, 312, 905, 344, 937, 267, 340, 298, 11151, 1304, 2, 315, 312, 26, 288, 291, 14, 11151, 1304, 275, 312, 905, 11151, 1304, 937, 267, 340, 298, 32146, 2, 315, 312, 26, 288, 291, 14, 32146, 275, 942, 288, 367, 1242, 315, 312, 905, 32146, 6229, 355, 291, 14, 32146, 14, 740, 8, 7344, 8, 1053, 430, 339, 347, 370, 63, 1001, 63, 807, 8, 277, 304, 267, 366, 275, 1052, 267, 340, 2688, 8, 277, 12, 298, 344, 2349, 288, 366, 905, 344, 937, 275, 291, 14, 344, 267, 340, 2688, 8, 277, 12, 298, 11151, 1304, 2349, 288, 366, 905, 11151, 1304, 937, 275, 291, 14, 11151, 1304, 267, 340, 2688, 8, 277, 12, 298, 32146, 2349, 288, 282, 275, 942, 288, 367, 1242, 315, 291, 14, 32146, 26, 355, 282, 14, 740, 8, 1053, 14, 475, 63, 1001, 63, 807, 1012, 288, 366, 905, 32146, 937, 275, 282, 267, 372, 366, 421, 199, 533, 8028, 8, 6243, 1563, 304, 272, 347, 636, 826, 721, 277, 12, 312, 304, 267, 340, 298, 344, 2, 315, 312, 26, 288, 291, 14, 344, 275, 312, 905, 344, 937, 267, 340, 298, 305, 13049, 2, 315, 312, 26, 288, 291, 14, 305, 13049, 275, 8028, 2822, 13049, 8, 79, 905, 305, 13049, 3135, 267, 340, 298, 8859, 2, 315, 312, 26, 288, 291, 14, 8859, 275, 942, 288, 367, 1242, 315, 312, 905, 8859, 6229, 355, 291, 14, 8859, 14, 740, 8, 6652, 83, 5083, 8, 1053, 430, 339, 347, 370, 63, 1001, 63, 807, 8, 277, 304, 267, 366, 275, 1052, 267, 340, 2688, 8, 277, 12, 298, 344, 2349, 288, 366, 905, 344, 937, 275, 291, 14, 344, 267, 340, 2688, 8, 277, 12, 298, 305, 13049, 2349, 288, 366, 905, 305, 13049, 937, 275, 291, 14, 305, 13049, 14, 475, 63, 1001, 63, 807, 342, 267, 340, 2688, 8, 277, 12, 298, 8859, 2349, 288, 282, 275, 942, 288, 367, 1242, 315, 291, 14, 8859, 26, 355, 282, 14, 740, 8, 1053, 14, 475, 63, 1001, 63, 807, 1012, 288, 366, 905, 8859, 937, 275, 282, 267, 372, 366, 421, 199, 533, 8028, 2822, 13049, 8, 6243, 1563, 304, 272, 347, 636, 826, 721, 277, 12, 312, 304, 267, 340, 298, 1247, 2, 315, 312, 26, 288, 291, 14, 1247, 275, 942, 288, 367, 1242, 315, 312, 905, 1247, 6229, 355, 291, 14, 1247, 14, 740, 8, 985, 26860, 8, 1053, 430, 267, 340, 298, 2268, 7735, 2, 315, 312, 26, 288, 291, 14, 2268, 7735, 275, 942, 288, 367, 1242, 315, 312, 905, 2268, 7735, 6229, 355, 291, 14, 2268, 7735, 14, 740, 8, 8168, 424, 26860, 8, 1053, 430, 339, 347, 370, 63, 1001, 63, 807, 8, 277, 304, 267, 366, 275, 1052, 267, 340, 2688, 8, 277, 12, 298, 1247, 2349, 288, 282, 275, 942, 288, 367, 1242, 315, 291, 14, 1247, 26, 355, 282, 14, 740, 8, 1053, 14, 475, 63, 1001, 63, 807, 1012, 288, 366, 905, 1247, 937, 275, 282, 267, 340, 2688, 8, 277, 12, 298, 2268, 7735, 2349, 288, 282, 275, 942, 288, 367, 1242, 315, 291, 14, 2268, 7735, 26, 355, 282, 14, 740, 8, 1053, 14, 475, 63, 1001, 63, 807, 1012, 288, 366, 905, 2268, 7735, 937, 275, 282, 267, 372, 366, 421, 199, 533, 2812, 26860, 8, 6243, 1563, 304, 272, 347, 636, 826, 721, 277, 12, 312, 304, 267, 340, 298, 585, 2, 315, 312, 26, 288, 291, 14, 585, 275, 2812, 1110, 8, 79, 905, 585, 3135, 339, 347, 370, 63, 1001, 63, 807, 8, 277, 304, 267, 366, 275, 1052, 267, 340, 2688, 8, 277, 12, 298, 585, 2349, 288, 366, 905, 585, 937, 275, 291, 14, 585, 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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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 ]
handroissuazo/tensorflow
tensorflow/contrib/rnn/python/kernel_tests/rnn_cell_test.py
3
43457
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for RNN cells.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import itertools import sys # TODO: #6568 Remove this hack that makes dlopen() not crash. if hasattr(sys, "getdlopenflags") and hasattr(sys, "setdlopenflags"): import ctypes sys.setdlopenflags(sys.getdlopenflags() | ctypes.RTLD_GLOBAL) import numpy as np from tensorflow.contrib.rnn.python.ops import core_rnn_cell_impl from tensorflow.contrib.rnn.python.ops import rnn_cell from tensorflow.core.protobuf import config_pb2 from tensorflow.python.client import session from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import random_seed from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import gradients_impl from tensorflow.python.ops import init_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import random_ops from tensorflow.python.ops import rnn from tensorflow.python.ops import variable_scope from tensorflow.python.ops import variables from tensorflow.python.platform import test from tensorflow.python.util import nest class RNNCellTest(test.TestCase): def testCoupledInputForgetGateLSTMCell(self): with self.test_session() as sess: num_units = 2 state_size = num_units * 2 batch_size = 3 input_size = 4 expected_output = np.array( [[0.121753, 0.121753], [0.103349, 0.103349], [0.100178, 0.100178]], dtype=np.float32) expected_state = np.array( [[0.137523, 0.137523, 0.121753, 0.121753], [0.105450, 0.105450, 0.103349, 0.103349], [0.100742, 0.100742, 0.100178, 0.100178]], dtype=np.float32) with variable_scope.variable_scope( "root", initializer=init_ops.constant_initializer(0.5)): x = array_ops.zeros([batch_size, input_size]) m = array_ops.zeros([batch_size, state_size]) output, state = rnn_cell.CoupledInputForgetGateLSTMCell( num_units=num_units, forget_bias=1.0)(x, m) sess.run([variables.global_variables_initializer()]) res = sess.run([output, state], { x.name: np.array([[1., 1., 1., 1.], [2., 2., 2., 2.], [3., 3., 3., 3.]]), m.name: 0.1 * np.ones((batch_size, state_size)) }) # This is a smoke test: Only making sure expected values didn't change. self.assertEqual(len(res), 2) self.assertAllClose(res[0], expected_output) self.assertAllClose(res[1], expected_state) def testTimeFreqLSTMCell(self): with self.test_session() as sess: num_units = 8 state_size = num_units * 2 batch_size = 3 input_size = 4 feature_size = 2 frequency_skip = 1 num_shifts = (input_size - feature_size) / frequency_skip + 1 with variable_scope.variable_scope( "root", initializer=init_ops.constant_initializer(0.5)): x = array_ops.zeros([batch_size, input_size]) m = array_ops.zeros([batch_size, state_size * num_shifts]) output, state = rnn_cell.TimeFreqLSTMCell( num_units=num_units, feature_size=feature_size, frequency_skip=frequency_skip, forget_bias=1.0)(x, m) sess.run([variables.global_variables_initializer()]) res = sess.run([output, state], { x.name: np.array([[1., 1., 1., 1.], [2., 2., 2., 2.], [3., 3., 3., 3.]]), m.name: 0.1 * np.ones((batch_size, int(state_size * (num_shifts)))) }) self.assertEqual(len(res), 2) # The numbers in results were not calculated, this is mostly just a # smoke test. self.assertEqual(res[0].shape, (batch_size, num_units * num_shifts)) self.assertEqual(res[1].shape, (batch_size, state_size * num_shifts)) # Different inputs so different outputs and states for i in range(1, batch_size): self.assertTrue( float(np.linalg.norm((res[0][0, :] - res[0][i, :]))) > 1e-6) self.assertTrue( float(np.linalg.norm((res[1][0, :] - res[1][i, :]))) > 1e-6) def testGridLSTMCell(self): with self.test_session() as sess: num_units = 8 batch_size = 3 input_size = 4 feature_size = 2 frequency_skip = 1 num_shifts = int((input_size - feature_size) / frequency_skip + 1) with variable_scope.variable_scope( "root", initializer=init_ops.constant_initializer(0.5)): cell = rnn_cell.GridLSTMCell( num_units=num_units, feature_size=feature_size, frequency_skip=frequency_skip, forget_bias=1.0, num_frequency_blocks=[num_shifts], couple_input_forget_gates=True, state_is_tuple=True) inputs = constant_op.constant( np.array( [[1., 1., 1., 1.], [2., 2., 2., 2.], [3., 3., 3., 3.]], dtype=np.float32), dtype=dtypes.float32) state_value = constant_op.constant( 0.1 * np.ones( (batch_size, num_units), dtype=np.float32), dtype=dtypes.float32) init_state = cell.state_tuple_type( *([state_value, state_value] * num_shifts)) output, state = cell(inputs, init_state) sess.run([variables.global_variables_initializer()]) res = sess.run([output, state]) self.assertEqual(len(res), 2) # The numbers in results were not calculated, this is mostly just a # smoke test. self.assertEqual(res[0].shape, (batch_size, num_units * num_shifts * 2)) for ss in res[1]: self.assertEqual(ss.shape, (batch_size, num_units)) # Different inputs so different outputs and states for i in range(1, batch_size): self.assertTrue( float(np.linalg.norm((res[0][0, :] - res[0][i, :]))) > 1e-6) self.assertTrue( float( np.linalg.norm((res[1].state_f00_b00_c[0, :] - res[1] .state_f00_b00_c[i, :]))) > 1e-6) def testGridLSTMCellWithFrequencyBlocks(self): with self.test_session() as sess: num_units = 8 batch_size = 3 input_size = 4 feature_size = 2 frequency_skip = 1 num_frequency_blocks = [1, 1] total_blocks = num_frequency_blocks[0] + num_frequency_blocks[1] start_freqindex_list = [0, 2] end_freqindex_list = [2, 4] with variable_scope.variable_scope( "root", initializer=init_ops.constant_initializer(0.5)): cell = rnn_cell.GridLSTMCell( num_units=num_units, feature_size=feature_size, frequency_skip=frequency_skip, forget_bias=1.0, num_frequency_blocks=num_frequency_blocks, start_freqindex_list=start_freqindex_list, end_freqindex_list=end_freqindex_list, couple_input_forget_gates=True, state_is_tuple=True) inputs = constant_op.constant( np.array( [[1., 1., 1., 1.], [2., 2., 2., 2.], [3., 3., 3., 3.]], dtype=np.float32), dtype=dtypes.float32) state_value = constant_op.constant( 0.1 * np.ones( (batch_size, num_units), dtype=np.float32), dtype=dtypes.float32) init_state = cell.state_tuple_type( *([state_value, state_value] * total_blocks)) output, state = cell(inputs, init_state) sess.run([variables.global_variables_initializer()]) res = sess.run([output, state]) self.assertEqual(len(res), 2) # The numbers in results were not calculated, this is mostly just a # smoke test. self.assertEqual(res[0].shape, (batch_size, num_units * total_blocks * 2)) for ss in res[1]: self.assertEqual(ss.shape, (batch_size, num_units)) # Different inputs so different outputs and states for i in range(1, batch_size): self.assertTrue( float(np.linalg.norm((res[0][0, :] - res[0][i, :]))) > 1e-6) self.assertTrue( float( np.linalg.norm((res[1].state_f00_b00_c[0, :] - res[1] .state_f00_b00_c[i, :]))) > 1e-6) def testGridLstmCellWithCoupledInputForgetGates(self): num_units = 2 batch_size = 3 input_size = 4 feature_size = 2 frequency_skip = 1 num_shifts = int((input_size - feature_size) / frequency_skip + 1) expected_output = np.array( [[0.416383, 0.416383, 0.403238, 0.403238, 0.524020, 0.524020, 0.565425, 0.565425, 0.557865, 0.557865, 0.609699, 0.609699], [0.627331, 0.627331, 0.622393, 0.622393, 0.688342, 0.688342, 0.708078, 0.708078, 0.694245, 0.694245, 0.715171, 0.715171], [0.711050, 0.711050, 0.709197, 0.709197, 0.736533, 0.736533, 0.744264, 0.744264, 0.737390, 0.737390, 0.745250, 0.745250]], dtype=np.float32) expected_state = np.array( [[0.625556, 0.625556, 0.416383, 0.416383, 0.759134, 0.759134, 0.524020, 0.524020, 0.798795, 0.798795, 0.557865, 0.557865], [0.875488, 0.875488, 0.627331, 0.627331, 0.936432, 0.936432, 0.688342, 0.688342, 0.941961, 0.941961, 0.694245, 0.694245], [0.957327, 0.957327, 0.711050, 0.711050, 0.979522, 0.979522, 0.736533, 0.736533, 0.980245, 0.980245, 0.737390, 0.737390]], dtype=np.float32) for state_is_tuple in [False, True]: with self.test_session() as sess: with variable_scope.variable_scope( "state_is_tuple" + str(state_is_tuple), initializer=init_ops.constant_initializer(0.5)): cell = rnn_cell.GridLSTMCell( num_units=num_units, feature_size=feature_size, frequency_skip=frequency_skip, forget_bias=1.0, num_frequency_blocks=[num_shifts], couple_input_forget_gates=True, state_is_tuple=state_is_tuple) inputs = constant_op.constant( np.array([[1., 1., 1., 1.], [2., 2., 2., 2.], [3., 3., 3., 3.]], dtype=np.float32), dtype=dtypes.float32) if state_is_tuple: state_value = constant_op.constant( 0.1 * np.ones( (batch_size, num_units), dtype=np.float32), dtype=dtypes.float32) init_state = cell.state_tuple_type( *([state_value, state_value] * num_shifts)) else: init_state = constant_op.constant( 0.1 * np.ones( (batch_size, num_units * num_shifts * 2), dtype=np.float32), dtype=dtypes.float32) output, state = cell(inputs, init_state) sess.run([variables.global_variables_initializer()]) res = sess.run([output, state]) # This is a smoke test: Only making sure expected values not change. self.assertEqual(len(res), 2) self.assertAllClose(res[0], expected_output) if not state_is_tuple: self.assertAllClose(res[1], expected_state) else: # There should be num_shifts * 2 states in the tuple. self.assertEqual(len(res[1]), num_shifts * 2) # Checking the shape of each state to be batch_size * num_units for ss in res[1]: self.assertEqual(ss.shape[0], batch_size) self.assertEqual(ss.shape[1], num_units) self.assertAllClose(np.concatenate(res[1], axis=1), expected_state) def testBidirectionGridLSTMCell(self): with self.test_session() as sess: num_units = 2 batch_size = 3 input_size = 4 feature_size = 2 frequency_skip = 1 num_shifts = int((input_size - feature_size) / frequency_skip + 1) expected_output = np.array( [[0.464130, 0.464130, 0.419165, 0.419165, 0.593283, 0.593283, 0.738350, 0.738350, 0.661638, 0.661638, 0.866774, 0.866774, 0.520789, 0.520789, 0.476968, 0.476968, 0.604341, 0.604341, 0.760207, 0.760207, 0.635773, 0.635773, 0.850218, 0.850218], [0.669636, 0.669636, 0.628966, 0.628966, 0.736057, 0.736057, 0.895927, 0.895927, 0.755559, 0.755559, 0.954359, 0.954359, 0.692621, 0.692621, 0.652363, 0.652363, 0.737517, 0.737517, 0.899558, 0.899558, 0.745984, 0.745984, 0.946840, 0.946840], [0.751109, 0.751109, 0.711716, 0.711716, 0.778357, 0.778357, 0.940779, 0.940779, 0.784530, 0.784530, 0.980604, 0.980604, 0.759940, 0.759940, 0.720652, 0.720652, 0.778552, 0.778552, 0.941606, 0.941606, 0.781035, 0.781035, 0.977731, 0.977731]], dtype=np.float32) expected_state = np.array( [[0.710660, 0.710660, 0.464130, 0.464130, 0.877293, 0.877293, 0.593283, 0.593283, 0.958505, 0.958505, 0.661638, 0.661638, 0.785405, 0.785405, 0.520789, 0.520789, 0.890836, 0.890836, 0.604341, 0.604341, 0.928512, 0.928512, 0.635773, 0.635773], [0.967579, 0.967579, 0.669636, 0.669636, 1.038811, 1.038811, 0.736057, 0.736057, 1.058201, 1.058201, 0.755559, 0.755559, 0.993088, 0.993088, 0.692621, 0.692621, 1.040288, 1.040288, 0.737517, 0.737517, 1.048773, 1.048773, 0.745984, 0.745984], [1.053842, 1.053842, 0.751109, 0.751109, 1.079919, 1.079919, 0.778357, 0.778357, 1.085620, 1.085620, 0.784530, 0.784530, 1.062455, 1.062455, 0.759940, 0.759940, 1.080101, 1.080101, 0.778552, 0.778552, 1.082402, 1.082402, 0.781035, 0.781035]], dtype=np.float32) with variable_scope.variable_scope( "root", initializer=init_ops.constant_initializer(0.5)): cell = rnn_cell.BidirectionalGridLSTMCell( num_units=num_units, feature_size=feature_size, share_time_frequency_weights=True, frequency_skip=frequency_skip, forget_bias=1.0, num_frequency_blocks=[num_shifts]) inputs = constant_op.constant( np.array([[1.0, 1.1, 1.2, 1.3], [2.0, 2.1, 2.2, 2.3], [3.0, 3.1, 3.2, 3.3]], dtype=np.float32), dtype=dtypes.float32) state_value = constant_op.constant( 0.1 * np.ones( (batch_size, num_units), dtype=np.float32), dtype=dtypes.float32) init_state = cell.state_tuple_type( *([state_value, state_value] * num_shifts * 2)) output, state = cell(inputs, init_state) sess.run([variables.global_variables_initializer()]) res = sess.run([output, state]) self.assertEqual(len(res), 2) # The numbers in results were not calculated, this is mostly just a # smoke test. self.assertEqual(res[0].shape, (batch_size, num_units * num_shifts * 4)) self.assertAllClose(res[0], expected_output) # There should be num_shifts * 4 states in the tuple. self.assertEqual(len(res[1]), num_shifts * 4) # Checking the shape of each state to be batch_size * num_units for ss in res[1]: self.assertEqual(ss.shape[0], batch_size) self.assertEqual(ss.shape[1], num_units) self.assertAllClose(np.concatenate(res[1], axis=1), expected_state) def testBidirectionGridLSTMCellWithSliceOffset(self): with self.test_session() as sess: num_units = 2 batch_size = 3 input_size = 4 feature_size = 2 frequency_skip = 1 num_shifts = int((input_size - feature_size) / frequency_skip + 1) expected_output = np.array( [[0.464130, 0.464130, 0.419165, 0.419165, 0.593283, 0.593283, 0.738350, 0.738350, 0.661638, 0.661638, 0.866774, 0.866774, 0.322645, 0.322645, 0.276068, 0.276068, 0.584654, 0.584654, 0.690292, 0.690292, 0.640446, 0.640446, 0.840071, 0.840071], [0.669636, 0.669636, 0.628966, 0.628966, 0.736057, 0.736057, 0.895927, 0.895927, 0.755559, 0.755559, 0.954359, 0.954359, 0.493625, 0.493625, 0.449236, 0.449236, 0.730828, 0.730828, 0.865996, 0.865996, 0.749429, 0.749429, 0.944958, 0.944958], [0.751109, 0.751109, 0.711716, 0.711716, 0.778357, 0.778357, 0.940779, 0.940779, 0.784530, 0.784530, 0.980604, 0.980604, 0.608587, 0.608587, 0.566683, 0.566683, 0.777345, 0.777345, 0.925820, 0.925820, 0.782597, 0.782597, 0.976858, 0.976858]], dtype=np.float32) expected_state = np.array( [[0.710660, 0.710660, 0.464130, 0.464130, 0.877293, 0.877293, 0.593283, 0.593283, 0.958505, 0.958505, 0.661638, 0.661638, 0.516575, 0.516575, 0.322645, 0.322645, 0.866628, 0.866628, 0.584654, 0.584654, 0.934002, 0.934002, 0.640446, 0.640446], [0.967579, 0.967579, 0.669636, 0.669636, 1.038811, 1.038811, 0.736057, 0.736057, 1.058201, 1.058201, 0.755559, 0.755559, 0.749836, 0.749836, 0.493625, 0.493625, 1.033488, 1.033488, 0.730828, 0.730828, 1.052186, 1.052186, 0.749429, 0.749429], [1.053842, 1.053842, 0.751109, 0.751109, 1.079919, 1.079919, 0.778357, 0.778357, 1.085620, 1.085620, 0.784530, 0.784530, 0.895999, 0.895999, 0.608587, 0.608587, 1.078978, 1.078978, 0.777345, 0.777345, 1.083843, 1.083843, 0.782597, 0.782597]], dtype=np.float32) with variable_scope.variable_scope( "root", initializer=init_ops.constant_initializer(0.5)): cell = rnn_cell.BidirectionalGridLSTMCell( num_units=num_units, feature_size=feature_size, share_time_frequency_weights=True, frequency_skip=frequency_skip, forget_bias=1.0, num_frequency_blocks=[num_shifts], backward_slice_offset=1) inputs = constant_op.constant( np.array([[1.0, 1.1, 1.2, 1.3], [2.0, 2.1, 2.2, 2.3], [3.0, 3.1, 3.2, 3.3]], dtype=np.float32), dtype=dtypes.float32) state_value = constant_op.constant( 0.1 * np.ones( (batch_size, num_units), dtype=np.float32), dtype=dtypes.float32) init_state = cell.state_tuple_type( *([state_value, state_value] * num_shifts * 2)) output, state = cell(inputs, init_state) sess.run([variables.global_variables_initializer()]) res = sess.run([output, state]) self.assertEqual(len(res), 2) # The numbers in results were not calculated, this is mostly just a # smoke test. self.assertEqual(res[0].shape, (batch_size, num_units * num_shifts * 4)) self.assertAllClose(res[0], expected_output) # There should be num_shifts * 4 states in the tuple. self.assertEqual(len(res[1]), num_shifts * 4) # Checking the shape of each state to be batch_size * num_units for ss in res[1]: self.assertEqual(ss.shape[0], batch_size) self.assertEqual(ss.shape[1], num_units) self.assertAllClose(np.concatenate(res[1], axis=1), expected_state) def testAttentionCellWrapperFailures(self): with self.assertRaisesRegexp(TypeError, "The parameter cell is not RNNCell."): rnn_cell.AttentionCellWrapper(None, 0) num_units = 8 for state_is_tuple in [False, True]: with ops.Graph().as_default(): lstm_cell = core_rnn_cell_impl.BasicLSTMCell( num_units, state_is_tuple=state_is_tuple) with self.assertRaisesRegexp( ValueError, "attn_length should be greater than zero, got 0"): rnn_cell.AttentionCellWrapper( lstm_cell, 0, state_is_tuple=state_is_tuple) with self.assertRaisesRegexp( ValueError, "attn_length should be greater than zero, got -1"): rnn_cell.AttentionCellWrapper( lstm_cell, -1, state_is_tuple=state_is_tuple) with ops.Graph().as_default(): lstm_cell = core_rnn_cell_impl.BasicLSTMCell( num_units, state_is_tuple=True) with self.assertRaisesRegexp( ValueError, "Cell returns tuple of states, but the flag " "state_is_tuple is not set. State size is: *"): rnn_cell.AttentionCellWrapper(lstm_cell, 4, state_is_tuple=False) def testAttentionCellWrapperZeros(self): num_units = 8 attn_length = 16 batch_size = 3 input_size = 4 for state_is_tuple in [False, True]: with ops.Graph().as_default(): with self.test_session() as sess: with variable_scope.variable_scope("state_is_tuple_" + str( state_is_tuple)): lstm_cell = core_rnn_cell_impl.BasicLSTMCell( num_units, state_is_tuple=state_is_tuple) cell = rnn_cell.AttentionCellWrapper( lstm_cell, attn_length, state_is_tuple=state_is_tuple) if state_is_tuple: zeros = array_ops.zeros([batch_size, num_units], dtype=np.float32) attn_state_zeros = array_ops.zeros( [batch_size, attn_length * num_units], dtype=np.float32) zero_state = ((zeros, zeros), zeros, attn_state_zeros) else: zero_state = array_ops.zeros( [ batch_size, num_units * 2 + attn_length * num_units + num_units ], dtype=np.float32) inputs = array_ops.zeros( [batch_size, input_size], dtype=dtypes.float32) output, state = cell(inputs, zero_state) self.assertEquals(output.get_shape(), [batch_size, num_units]) if state_is_tuple: self.assertEquals(len(state), 3) self.assertEquals(len(state[0]), 2) self.assertEquals(state[0][0].get_shape(), [batch_size, num_units]) self.assertEquals(state[0][1].get_shape(), [batch_size, num_units]) self.assertEquals(state[1].get_shape(), [batch_size, num_units]) self.assertEquals(state[2].get_shape(), [batch_size, attn_length * num_units]) tensors = [output] + list(state) else: self.assertEquals(state.get_shape(), [ batch_size, num_units * 2 + num_units + attn_length * num_units ]) tensors = [output, state] zero_result = sum( [math_ops.reduce_sum(math_ops.abs(x)) for x in tensors]) sess.run(variables.global_variables_initializer()) self.assertTrue(sess.run(zero_result) < 1e-6) def testAttentionCellWrapperValues(self): num_units = 8 attn_length = 16 batch_size = 3 for state_is_tuple in [False, True]: with ops.Graph().as_default(): with self.test_session() as sess: with variable_scope.variable_scope("state_is_tuple_" + str( state_is_tuple)): lstm_cell = core_rnn_cell_impl.BasicLSTMCell( num_units, state_is_tuple=state_is_tuple) cell = rnn_cell.AttentionCellWrapper( lstm_cell, attn_length, state_is_tuple=state_is_tuple) if state_is_tuple: zeros = constant_op.constant( 0.1 * np.ones( [batch_size, num_units], dtype=np.float32), dtype=dtypes.float32) attn_state_zeros = constant_op.constant( 0.1 * np.ones( [batch_size, attn_length * num_units], dtype=np.float32), dtype=dtypes.float32) zero_state = ((zeros, zeros), zeros, attn_state_zeros) else: zero_state = constant_op.constant( 0.1 * np.ones( [ batch_size, num_units * 2 + num_units + attn_length * num_units ], dtype=np.float32), dtype=dtypes.float32) inputs = constant_op.constant( np.array( [[1., 1., 1., 1.], [2., 2., 2., 2.], [3., 3., 3., 3.]], dtype=np.float32), dtype=dtypes.float32) output, state = cell(inputs, zero_state) if state_is_tuple: concat_state = array_ops.concat( [state[0][0], state[0][1], state[1], state[2]], 1) else: concat_state = state sess.run(variables.global_variables_initializer()) output, state = sess.run([output, concat_state]) # Different inputs so different outputs and states for i in range(1, batch_size): self.assertTrue( float(np.linalg.norm((output[0, :] - output[i, :]))) > 1e-6) self.assertTrue( float(np.linalg.norm((state[0, :] - state[i, :]))) > 1e-6) def testAttentionCellWrapperCorrectResult(self): num_units = 4 attn_length = 6 batch_size = 2 expected_output = np.array( [[1.068372, 0.45496, -0.678277, 0.340538], [1.018088, 0.378983, -0.572179, 0.268591]], dtype=np.float32) expected_state = np.array( [[0.74946702, 0.34681597, 0.26474735, 1.06485605, 0.38465962, 0.11420801, 0.10272158, 0.30925757, 0.63899988, 0.7181077, 0.47534478, 0.33715725, 0.58086717, 0.49446869, 0.7641536, 0.12814975, 0.92231739, 0.89857256, 0.21889746, 0.38442063, 0.53481543, 0.8876909, 0.45823169, 0.5905602, 0.78038228, 0.56501579, 0.03971386, 0.09870267, 0.8074435, 0.66821432, 0.99211812, 0.12295902, 1.14606023, 0.34370938, -0.79251152, 0.51843399], [0.5179342, 0.48682183, -0.25426468, 0.96810579, 0.28809637, 0.13607743, -0.11446252, 0.26792109, 0.78047138, 0.63460857, 0.49122369, 0.52007174, 0.73000264, 0.66986895, 0.73576689, 0.86301267, 0.87887371, 0.35185754, 0.93417215, 0.64732957, 0.63173044, 0.66627824, 0.53644657, 0.20477486, 0.98458421, 0.38277245, 0.03746676, 0.92510188, 0.57714164, 0.84932971, 0.36127412, 0.12125921, 1.1362772, 0.34361625, -0.78150457, 0.70582712]], dtype=np.float32) seed = 12345 random_seed.set_random_seed(seed) for state_is_tuple in [False, True]: with session.Session() as sess: with variable_scope.variable_scope( "state_is_tuple", reuse=state_is_tuple, initializer=init_ops.glorot_uniform_initializer()): lstm_cell = core_rnn_cell_impl.BasicLSTMCell( num_units, state_is_tuple=state_is_tuple) cell = rnn_cell.AttentionCellWrapper( lstm_cell, attn_length, state_is_tuple=state_is_tuple) zeros1 = random_ops.random_uniform( (batch_size, num_units), 0.0, 1.0, seed=seed + 1) zeros2 = random_ops.random_uniform( (batch_size, num_units), 0.0, 1.0, seed=seed + 2) zeros3 = random_ops.random_uniform( (batch_size, num_units), 0.0, 1.0, seed=seed + 3) attn_state_zeros = random_ops.random_uniform( (batch_size, attn_length * num_units), 0.0, 1.0, seed=seed + 4) zero_state = ((zeros1, zeros2), zeros3, attn_state_zeros) if not state_is_tuple: zero_state = array_ops.concat([ zero_state[0][0], zero_state[0][1], zero_state[1], zero_state[2] ], 1) inputs = random_ops.random_uniform( (batch_size, num_units), 0.0, 1.0, seed=seed + 5) output, state = cell(inputs, zero_state) if state_is_tuple: state = array_ops.concat( [state[0][0], state[0][1], state[1], state[2]], 1) sess.run(variables.global_variables_initializer()) self.assertAllClose(sess.run(output), expected_output) self.assertAllClose(sess.run(state), expected_state) class LayerNormBasicLSTMCellTest(test.TestCase): # NOTE: all the values in the current test case have been calculated. def testBasicLSTMCell(self): with self.test_session() as sess: with variable_scope.variable_scope( "root", initializer=init_ops.constant_initializer(0.5)): x = array_ops.zeros([1, 2]) c0 = array_ops.zeros([1, 2]) h0 = array_ops.zeros([1, 2]) state0 = core_rnn_cell_impl.LSTMStateTuple(c0, h0) c1 = array_ops.zeros([1, 2]) h1 = array_ops.zeros([1, 2]) state1 = core_rnn_cell_impl.LSTMStateTuple(c1, h1) state = (state0, state1) single_cell = lambda: rnn_cell.LayerNormBasicLSTMCell(2) cell = core_rnn_cell_impl.MultiRNNCell([single_cell() for _ in range(2)]) g, out_m = cell(x, state) sess.run([variables.global_variables_initializer()]) res = sess.run([g, out_m], { x.name: np.array([[1., 1.]]), c0.name: 0.1 * np.asarray([[0, 1]]), h0.name: 0.1 * np.asarray([[2, 3]]), c1.name: 0.1 * np.asarray([[4, 5]]), h1.name: 0.1 * np.asarray([[6, 7]]), }) expected_h = np.array([[-0.38079708, 0.38079708]]) expected_state0_c = np.array([[-1.0, 1.0]]) expected_state0_h = np.array([[-0.38079708, 0.38079708]]) expected_state1_c = np.array([[-1.0, 1.0]]) expected_state1_h = np.array([[-0.38079708, 0.38079708]]) actual_h = res[0] actual_state0_c = res[1][0].c actual_state0_h = res[1][0].h actual_state1_c = res[1][1].c actual_state1_h = res[1][1].h self.assertAllClose(actual_h, expected_h, 1e-5) self.assertAllClose(expected_state0_c, actual_state0_c, 1e-5) self.assertAllClose(expected_state0_h, actual_state0_h, 1e-5) self.assertAllClose(expected_state1_c, actual_state1_c, 1e-5) self.assertAllClose(expected_state1_h, actual_state1_h, 1e-5) with variable_scope.variable_scope( "other", initializer=init_ops.constant_initializer(0.5)): x = array_ops.zeros( [1, 3]) # Test BasicLSTMCell with input_size != num_units. c = array_ops.zeros([1, 2]) h = array_ops.zeros([1, 2]) state = core_rnn_cell_impl.LSTMStateTuple(c, h) cell = rnn_cell.LayerNormBasicLSTMCell(2) g, out_m = cell(x, state) sess.run([variables.global_variables_initializer()]) res = sess.run([g, out_m], { x.name: np.array([[1., 1., 1.]]), c.name: 0.1 * np.asarray([[0, 1]]), h.name: 0.1 * np.asarray([[2, 3]]), }) expected_h = np.array([[-0.38079708, 0.38079708]]) expected_c = np.array([[-1.0, 1.0]]) self.assertEqual(len(res), 2) self.assertAllClose(res[0], expected_h, 1e-5) self.assertAllClose(res[1].c, expected_c, 1e-5) self.assertAllClose(res[1].h, expected_h, 1e-5) def testBasicLSTMCellWithStateTuple(self): with self.test_session() as sess: with variable_scope.variable_scope( "root", initializer=init_ops.constant_initializer(0.5)): x = array_ops.zeros([1, 2]) c0 = array_ops.zeros([1, 2]) h0 = array_ops.zeros([1, 2]) state0 = core_rnn_cell_impl.LSTMStateTuple(c0, h0) c1 = array_ops.zeros([1, 2]) h1 = array_ops.zeros([1, 2]) state1 = core_rnn_cell_impl.LSTMStateTuple(c1, h1) def single_cell(): return rnn_cell.LayerNormBasicLSTMCell(2) cell = core_rnn_cell_impl.MultiRNNCell( [single_cell() for _ in range(2)]) h, (s0, s1) = cell(x, (state0, state1)) sess.run([variables.global_variables_initializer()]) res = sess.run([h, s0, s1], { x.name: np.array([[1., 1.]]), c0.name: 0.1 * np.asarray([[0, 1]]), h0.name: 0.1 * np.asarray([[2, 3]]), c1.name: 0.1 * np.asarray([[4, 5]]), h1.name: 0.1 * np.asarray([[6, 7]]), }) expected_h = np.array([[-0.38079708, 0.38079708]]) expected_h0 = np.array([[-0.38079708, 0.38079708]]) expected_c0 = np.array([[-1.0, 1.0]]) expected_h1 = np.array([[-0.38079708, 0.38079708]]) expected_c1 = np.array([[-1.0, 1.0]]) self.assertEqual(len(res), 3) self.assertAllClose(res[0], expected_h, 1e-5) self.assertAllClose(res[1].c, expected_c0, 1e-5) self.assertAllClose(res[1].h, expected_h0, 1e-5) self.assertAllClose(res[2].c, expected_c1, 1e-5) self.assertAllClose(res[2].h, expected_h1, 1e-5) def testBasicLSTMCellWithDropout(self): def _is_close(x, y, digits=4): delta = x - y return delta < 10**(-digits) def _is_close_in(x, items, digits=4): for i in items: if _is_close(x, i, digits): return True return False keep_prob = 0.5 c_high = 2.9998924946 c_low = 0.999983298578 h_low = 0.761552567265 h_high = 0.995008519604 num_units = 5 allowed_low = [2, 3] with self.test_session() as sess: with variable_scope.variable_scope( "other", initializer=init_ops.constant_initializer(1)): x = array_ops.zeros([1, 5]) c = array_ops.zeros([1, 5]) h = array_ops.zeros([1, 5]) state = core_rnn_cell_impl.LSTMStateTuple(c, h) cell = rnn_cell.LayerNormBasicLSTMCell( num_units, layer_norm=False, dropout_keep_prob=keep_prob) g, s = cell(x, state) sess.run([variables.global_variables_initializer()]) res = sess.run([g, s], { x.name: np.ones([1, 5]), c.name: np.ones([1, 5]), h.name: np.ones([1, 5]), }) # Since the returned tensors are of size [1,n] # get the first component right now. actual_h = res[0][0] actual_state_c = res[1].c[0] actual_state_h = res[1].h[0] # For each item in `c` (the cell inner state) check that # it is equal to one of the allowed values `c_high` (not # dropped out) or `c_low` (dropped out) and verify that the # corresponding item in `h` (the cell activation) is coherent. # Count the dropped activations and check that their number is # coherent with the dropout probability. dropped_count = 0 self.assertTrue((actual_h == actual_state_h).all()) for citem, hitem in zip(actual_state_c, actual_state_h): self.assertTrue(_is_close_in(citem, [c_low, c_high])) if _is_close(citem, c_low): self.assertTrue(_is_close(hitem, h_low)) dropped_count += 1 elif _is_close(citem, c_high): self.assertTrue(_is_close(hitem, h_high)) self.assertIn(dropped_count, allowed_low) def _create_multi_lstm_cell_ops(batch_size, num_units, input_depth, num_layers, max_time, compiled): with variable_scope.variable_scope( "root", initializer=init_ops.random_uniform_initializer(-0.1, 0.1, seed=2)): inputs = variable_scope.get_variable( "inputs", initializer=random_ops.random_uniform( (max_time, batch_size, input_depth), seed=1)) maybe_xla = lambda c: rnn_cell.CompiledWrapper(c) if compiled else c cell = core_rnn_cell_impl.MultiRNNCell( [maybe_xla(core_rnn_cell_impl.LSTMCell(num_units)) for _ in range(num_layers)]) initial_state = cell.zero_state( batch_size=batch_size, dtype=dtypes.float32) outputs, final_state = rnn.dynamic_rnn( cell=cell, inputs=inputs, initial_state=initial_state, time_major=True) flat_final_state = nest.flatten(final_state) trainable_variables = variables.trainable_variables() outputs_grad = gradients_impl.gradients( [outputs], trainable_variables + [inputs] + nest.flatten(initial_state)) final_state_grad = gradients_impl.gradients( flat_final_state, trainable_variables + [inputs] + nest.flatten(initial_state)) return {"outputs": outputs, "final_state": flat_final_state, "outputs_grad": outputs_grad, "final_state_grad": final_state_grad} class CompiledWrapperTest(test.TestCase): def testMultiRNNCellWithLSTMCellAndXLA(self): # TODO(b/34735319): Don't run this test if XLA is not available. batch_size = 16 num_units = 32 input_depth = 12 num_layers = 2 max_time = 20 atol = 1e-6 random_seed.set_random_seed(1234) with self.test_session(graph=ops.Graph()) as sess: xla_ops = _create_multi_lstm_cell_ops( batch_size=batch_size, num_units=num_units, input_depth=input_depth, num_layers=num_layers, max_time=max_time, compiled=True) sess.run([variables.global_variables_initializer()]) xla_results = sess.run(xla_ops) random_seed.set_random_seed(1234) with self.test_session(graph=ops.Graph()) as sess: non_xla_ops = _create_multi_lstm_cell_ops( batch_size=batch_size, num_units=num_units, input_depth=input_depth, num_layers=num_layers, max_time=max_time, compiled=False) sess.run([variables.global_variables_initializer()]) non_xla_results = sess.run(non_xla_ops) self.assertAllClose( non_xla_results["outputs"], xla_results["outputs"], atol=atol) for xla_value, non_xla_value in zip( xla_results["final_state"], non_xla_results["final_state"]): self.assertAllClose(xla_value, non_xla_value, atol=atol) for xla_g, non_xla_g in zip( xla_results["outputs_grad"], non_xla_results["outputs_grad"]): self.assertAllClose(xla_g, non_xla_g, atol=atol) for xla_g, non_xla_g in zip( xla_results["final_state_grad"], non_xla_results["final_state_grad"]): self.assertAllClose(xla_g, non_xla_g, atol=atol) def testMultiRNNCellWithStateTuple(self): with self.test_session() as sess: with variable_scope.variable_scope( "root", initializer=init_ops.constant_initializer(0.5)): x = array_ops.zeros([1, 2]) m_bad = array_ops.zeros([1, 4]) m_good = (array_ops.zeros([1, 2]), array_ops.zeros([1, 2])) # Test incorrectness of state with self.assertRaisesRegexp(ValueError, "Expected state .* a tuple"): core_rnn_cell_impl.MultiRNNCell( [core_rnn_cell_impl.GRUCell(2) for _ in range(2)], state_is_tuple=True)(x, m_bad) _, ml = core_rnn_cell_impl.MultiRNNCell( [core_rnn_cell_impl.GRUCell(2) for _ in range(2)], state_is_tuple=True)(x, m_good) sess.run([variables.global_variables_initializer()]) res = sess.run(ml, { x.name: np.array([[1., 1.]]), m_good[0].name: np.array([[0.1, 0.1]]), m_good[1].name: np.array([[0.1, 0.1]]) }) # The numbers in results were not calculated, this is just a # smoke test. However, these numbers should match those of # the test testMultiRNNCell. self.assertAllClose(res[0], [[0.175991, 0.175991]]) self.assertAllClose(res[1], [[0.13248, 0.13248]]) class BenchmarkLSTMCellXLA(test.Benchmark): def benchmarkDynamicRNNWithMultiLSTMCell(self): num_layers = 3 max_time = 50 print("benchmarkDynamicRNNWithMultiLSTMCell") print("\t" + "\t".join(["inter_th", "intra_th", "batch_size", "num_units", "input_depth", "device", "compiled", "wall_time"])) warmup_run = True for (threads, device, num_units, batch_size, input_depth, compiled) in itertools.product( [{"inter": 0, "intra": 0}, {"inter": 1, "intra": 4}], ["cpu", "gpu"], [32, 512], [1, 32, 256], [32, 512], [False, True]): if threads["inter"] != 0: # We only care about testing inter/intra op limitations on # CPU with small batch size, to mimic embedded devices. if device != "cpu" or batch_size != 1: continue if device == "cpu" and batch_size > 32: continue random_seed.set_random_seed(1234) config = config_pb2.ConfigProto( inter_op_parallelism_threads=threads["inter"], intra_op_parallelism_threads=threads["intra"], allow_soft_placement=False) with session.Session(config=config, graph=ops.Graph()) as sess: with ops.device("/%s:0" % device): ops_dict = _create_multi_lstm_cell_ops( batch_size=batch_size, num_units=num_units, input_depth=input_depth, num_layers=num_layers, max_time=max_time, compiled=compiled) sess.run([variables.global_variables_initializer()]) all_ops = nest.flatten(ops_dict.values()) all_ops_group = control_flow_ops.group(*all_ops) name_suffix = ( "inter_th_%d_intra_th_%d_bs_%d_units_%d_inputdepth_%d" "_device_%s_xla_%s" % ( threads["inter"], threads["intra"], batch_size, num_units, input_depth, device, compiled)) if warmup_run: self.run_op_benchmark( sess, all_ops_group, min_iters=30, name="ignore_warmup") warmup_run = False benchmark_results = self.run_op_benchmark( sess, all_ops_group, min_iters=50, name="benchmarkDynamicRNNWithMultiLSTMCell_%s" % name_suffix) print("\t" + "\t".join(["%s" % x for x in [ threads["inter"], threads["intra"], batch_size, num_units, input_depth, device, compiled, benchmark_results["wall_time"]]])) if __name__ == "__main__": test.main()
apache-2.0
[ 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 26009, 10106, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 7975, 199, 646, 984, 199, 199, 3, 3254, 26, 327, 22, 15085, 5852, 642, 11176, 626, 7704, 366, 8329, 342, 440, 12420, 14, 199, 692, 2688, 8, 1274, 12, 298, 362, 68, 8329, 2469, 531, 436, 2688, 8, 1274, 12, 298, 409, 68, 8329, 2469, 2349, 523, 492, 5577, 523, 984, 14, 409, 68, 8329, 2469, 8, 1274, 14, 362, 68, 8329, 2469, 342, 1204, 5577, 14, 11876, 6533, 63, 13808, 9, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 2828, 14, 12845, 14, 1548, 14, 1483, 492, 6170, 63, 12845, 63, 3890, 63, 5472, 199, 504, 3228, 14, 2828, 14, 12845, 14, 1548, 14, 1483, 492, 19433, 63, 3890, 199, 504, 3228, 14, 1018, 14, 7204, 492, 1101, 63, 3317, 18, 199, 504, 3228, 14, 1548, 14, 1258, 492, 2351, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2196, 63, 5176, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3304, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 12661, 63, 5472, 199, 504, 3228, 14, 1548, 14, 1483, 492, 4205, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2196, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 19433, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1750, 63, 2645, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 199, 504, 3228, 14, 1548, 14, 1974, 492, 10715, 421, 199, 533, 32378, 26681, 774, 8, 396, 14, 1746, 304, 819, 347, 511, 11605, 3205, 1858, 362, 13994, 29805, 7608, 1697, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 342, 465, 4043, 26, 489, 1967, 63, 5260, 275, 499, 489, 1174, 63, 890, 275, 1967, 63, 5260, 627, 499, 489, 3522, 63, 890, 275, 650, 489, 1324, 63, 890, 275, 841, 489, 1420, 63, 1199, 275, 980, 14, 1144, 8, 881, 3474, 16, 14, 713, 1196, 2481, 12, 378, 14, 713, 1196, 2481, 467, 1779, 359, 16, 14, 709, 8425, 25, 12, 378, 14, 709, 8425, 25, 467, 1779, 359, 16, 14, 1960, 11175, 12, 378, 14, 1960, 11175, 2365, 881, 2152, 29, 1590, 14, 1609, 708, 9, 489, 1420, 63, 929, 275, 980, 14, 1144, 8, 881, 3474, 16, 14, 969, 2194, 1789, 12, 378, 14, 969, 2194, 1789, 12, 378, 14, 713, 1196, 2481, 12, 378, 14, 713, 1196, 2481, 467, 1779, 359, 16, 14, 709, 1477, 1400, 12, 378, 14, 709, 1477, 1400, 12, 378, 14, 709, 8425, 25, 12, 378, 14, 709, 8425, 25, 467, 1779, 359, 16, 14, 1960, 16498, 12, 378, 14, 1960, 16498, 12, 378, 14, 1960, 11175, 12, 378, 14, 1960, 11175, 2365, 881, 2152, 29, 1590, 14, 1609, 708, 9, 489, 543, 1750, 63, 2645, 14, 1975, 63, 2645, 8, 881, 298, 1231, 401, 11130, 29, 826, 63, 1483, 14, 4083, 63, 6498, 8, 16, 14, 21, 2298, 267, 671, 275, 1625, 63, 1483, 14, 4250, 779, 2912, 63, 890, 12, 1324, 63, 890, 566, 267, 333, 275, 1625, 63, 1483, 14, 4250, 779, 2912, 63, 890, 12, 1174, 63, 890, 566, 267, 1072, 12, 1174, 275, 19433, 63, 3890, 14, 11605, 3205, 1858, 362, 13994, 29805, 7608, 1697, 8, 288, 1967, 63, 5260, 29, 1507, 63, 5260, 12, 19459, 63, 8160, 29, 17, 14, 16, 5130, 88, 12, 333, 9, 267, 4043, 14, 1065, 779, 3669, 14, 2966, 63, 3669, 63, 6498, 9383, 267, 522, 275, 4043, 14, 1065, 779, 1199, 12, 1174, 467, 469, 288, 671, 14, 354, 26, 355, 980, 14, 1144, 4038, 17, 2020, 413, 2020, 413, 2020, 413, 8333, 2079, 359, 18, 2020, 499, 2020, 499, 2020, 499, 8333, 2079, 359, 19, 2020, 650, 2020, 650, 2020, 650, 14, 13925, 288, 333, 14, 354, 26, 355, 378, 14, 17, 627, 980, 14, 4548, 1332, 2912, 63, 890, 12, 1174, 63, 890, 430, 267, 3828, 267, 327, 961, 365, 282, 308, 17767, 511, 26, 5972, 10663, 3238, 1420, 1338, 9980, 1133, 1570, 14, 267, 291, 14, 629, 8, 552, 8, 470, 395, 499, 9, 267, 291, 14, 7260, 8, 470, 59, 16, 467, 1420, 63, 1199, 9, 267, 291, 14, 7260, 8, 470, 59, 17, 467, 1420, 63, 929, 9, 819, 347, 511, 1366, 13875, 29805, 7608, 1697, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 342, 465, 4043, 26, 489, 1967, 63, 5260, 275, 1695, 489, 1174, 63, 890, 275, 1967, 63, 5260, 627, 499, 489, 3522, 63, 890, 275, 650, 489, 1324, 63, 890, 275, 841, 489, 3878, 63, 890, 275, 499, 489, 9857, 63, 2759, 275, 413, 489, 1967, 63, 26063, 1086, 275, 334, 1210, 63, 890, 446, 3878, 63, 890, 9, 1182, 9857, 63, 2759, 435, 413, 489, 543, 1750, 63, 2645, 14, 1975, 63, 2645, 8, 881, 298, 1231, 401, 11130 ]
[ 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 26009, 10106, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 7975, 199, 646, 984, 199, 199, 3, 3254, 26, 327, 22, 15085, 5852, 642, 11176, 626, 7704, 366, 8329, 342, 440, 12420, 14, 199, 692, 2688, 8, 1274, 12, 298, 362, 68, 8329, 2469, 531, 436, 2688, 8, 1274, 12, 298, 409, 68, 8329, 2469, 2349, 523, 492, 5577, 523, 984, 14, 409, 68, 8329, 2469, 8, 1274, 14, 362, 68, 8329, 2469, 342, 1204, 5577, 14, 11876, 6533, 63, 13808, 9, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 2828, 14, 12845, 14, 1548, 14, 1483, 492, 6170, 63, 12845, 63, 3890, 63, 5472, 199, 504, 3228, 14, 2828, 14, 12845, 14, 1548, 14, 1483, 492, 19433, 63, 3890, 199, 504, 3228, 14, 1018, 14, 7204, 492, 1101, 63, 3317, 18, 199, 504, 3228, 14, 1548, 14, 1258, 492, 2351, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2196, 63, 5176, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3304, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 12661, 63, 5472, 199, 504, 3228, 14, 1548, 14, 1483, 492, 4205, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2196, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 19433, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1750, 63, 2645, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 199, 504, 3228, 14, 1548, 14, 1974, 492, 10715, 421, 199, 533, 32378, 26681, 774, 8, 396, 14, 1746, 304, 819, 347, 511, 11605, 3205, 1858, 362, 13994, 29805, 7608, 1697, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 342, 465, 4043, 26, 489, 1967, 63, 5260, 275, 499, 489, 1174, 63, 890, 275, 1967, 63, 5260, 627, 499, 489, 3522, 63, 890, 275, 650, 489, 1324, 63, 890, 275, 841, 489, 1420, 63, 1199, 275, 980, 14, 1144, 8, 881, 3474, 16, 14, 713, 1196, 2481, 12, 378, 14, 713, 1196, 2481, 467, 1779, 359, 16, 14, 709, 8425, 25, 12, 378, 14, 709, 8425, 25, 467, 1779, 359, 16, 14, 1960, 11175, 12, 378, 14, 1960, 11175, 2365, 881, 2152, 29, 1590, 14, 1609, 708, 9, 489, 1420, 63, 929, 275, 980, 14, 1144, 8, 881, 3474, 16, 14, 969, 2194, 1789, 12, 378, 14, 969, 2194, 1789, 12, 378, 14, 713, 1196, 2481, 12, 378, 14, 713, 1196, 2481, 467, 1779, 359, 16, 14, 709, 1477, 1400, 12, 378, 14, 709, 1477, 1400, 12, 378, 14, 709, 8425, 25, 12, 378, 14, 709, 8425, 25, 467, 1779, 359, 16, 14, 1960, 16498, 12, 378, 14, 1960, 16498, 12, 378, 14, 1960, 11175, 12, 378, 14, 1960, 11175, 2365, 881, 2152, 29, 1590, 14, 1609, 708, 9, 489, 543, 1750, 63, 2645, 14, 1975, 63, 2645, 8, 881, 298, 1231, 401, 11130, 29, 826, 63, 1483, 14, 4083, 63, 6498, 8, 16, 14, 21, 2298, 267, 671, 275, 1625, 63, 1483, 14, 4250, 779, 2912, 63, 890, 12, 1324, 63, 890, 566, 267, 333, 275, 1625, 63, 1483, 14, 4250, 779, 2912, 63, 890, 12, 1174, 63, 890, 566, 267, 1072, 12, 1174, 275, 19433, 63, 3890, 14, 11605, 3205, 1858, 362, 13994, 29805, 7608, 1697, 8, 288, 1967, 63, 5260, 29, 1507, 63, 5260, 12, 19459, 63, 8160, 29, 17, 14, 16, 5130, 88, 12, 333, 9, 267, 4043, 14, 1065, 779, 3669, 14, 2966, 63, 3669, 63, 6498, 9383, 267, 522, 275, 4043, 14, 1065, 779, 1199, 12, 1174, 467, 469, 288, 671, 14, 354, 26, 355, 980, 14, 1144, 4038, 17, 2020, 413, 2020, 413, 2020, 413, 8333, 2079, 359, 18, 2020, 499, 2020, 499, 2020, 499, 8333, 2079, 359, 19, 2020, 650, 2020, 650, 2020, 650, 14, 13925, 288, 333, 14, 354, 26, 355, 378, 14, 17, 627, 980, 14, 4548, 1332, 2912, 63, 890, 12, 1174, 63, 890, 430, 267, 3828, 267, 327, 961, 365, 282, 308, 17767, 511, 26, 5972, 10663, 3238, 1420, 1338, 9980, 1133, 1570, 14, 267, 291, 14, 629, 8, 552, 8, 470, 395, 499, 9, 267, 291, 14, 7260, 8, 470, 59, 16, 467, 1420, 63, 1199, 9, 267, 291, 14, 7260, 8, 470, 59, 17, 467, 1420, 63, 929, 9, 819, 347, 511, 1366, 13875, 29805, 7608, 1697, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 342, 465, 4043, 26, 489, 1967, 63, 5260, 275, 1695, 489, 1174, 63, 890, 275, 1967, 63, 5260, 627, 499, 489, 3522, 63, 890, 275, 650, 489, 1324, 63, 890, 275, 841, 489, 3878, 63, 890, 275, 499, 489, 9857, 63, 2759, 275, 413, 489, 1967, 63, 26063, 1086, 275, 334, 1210, 63, 890, 446, 3878, 63, 890, 9, 1182, 9857, 63, 2759, 435, 413, 489, 543, 1750, 63, 2645, 14, 1975, 63, 2645, 8, 881, 298, 1231, 401, 11130, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
shhui/nova
nova/tests/api/openstack/compute/plugins/v3/test_consoles.py
27
10477
# Copyright 2010-2011 OpenStack Foundation # Copyright 2011 Piston Cloud Computing, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import datetime import uuid as stdlib_uuid import webob from nova.api.openstack.compute.plugins.v3 import consoles from nova.compute import vm_states from nova import console from nova import db from nova import exception from nova.openstack.common import timeutils from nova import test from nova.tests.api.openstack import fakes from nova.tests import matchers FAKE_UUID = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' class FakeInstanceDB(object): def __init__(self): self.instances_by_id = {} self.ids_by_uuid = {} self.max_id = 0 def return_server_by_id(self, context, id): if id not in self.instances_by_id: self._add_server(id=id) return dict(self.instances_by_id[id]) def return_server_by_uuid(self, context, uuid): if uuid not in self.ids_by_uuid: self._add_server(uuid=uuid) return dict(self.instances_by_id[self.ids_by_uuid[uuid]]) def _add_server(self, id=None, uuid=None): if id is None: id = self.max_id + 1 if uuid is None: uuid = str(stdlib_uuid.uuid4()) instance = stub_instance(id, uuid=uuid) self.instances_by_id[id] = instance self.ids_by_uuid[uuid] = id if id > self.max_id: self.max_id = id def stub_instance(id, user_id='fake', project_id='fake', host=None, vm_state=None, task_state=None, reservation_id="", uuid=FAKE_UUID, image_ref="10", flavor_id="1", name=None, key_name='', access_ipv4=None, access_ipv6=None, progress=0): if host is not None: host = str(host) if key_name: key_data = 'FAKE' else: key_data = '' # ReservationID isn't sent back, hack it in there. server_name = name or "server%s" % id if reservation_id != "": server_name = "reservation_%s" % (reservation_id, ) instance = { "id": int(id), "created_at": datetime.datetime(2010, 10, 10, 12, 0, 0), "updated_at": datetime.datetime(2010, 11, 11, 11, 0, 0), "admin_password": "", "user_id": user_id, "project_id": project_id, "image_ref": image_ref, "kernel_id": "", "ramdisk_id": "", "launch_index": 0, "key_name": key_name, "key_data": key_data, "vm_state": vm_state or vm_states.BUILDING, "task_state": task_state, "memory_mb": 0, "vcpus": 0, "root_gb": 0, "hostname": "", "host": host, "instance_type": {}, "user_data": "", "reservation_id": reservation_id, "mac_address": "", "scheduled_at": timeutils.utcnow(), "launched_at": timeutils.utcnow(), "terminated_at": timeutils.utcnow(), "availability_zone": "", "display_name": server_name, "display_description": "", "locked": False, "metadata": [], "access_ip_v4": access_ipv4, "access_ip_v6": access_ipv6, "uuid": uuid, "progress": progress} return instance class ConsolesControllerTest(test.NoDBTestCase): def setUp(self): super(ConsolesControllerTest, self).setUp() self.flags(verbose=True) self.instance_db = FakeInstanceDB() self.stubs.Set(db, 'instance_get', self.instance_db.return_server_by_id) self.stubs.Set(db, 'instance_get_by_uuid', self.instance_db.return_server_by_uuid) self.uuid = str(stdlib_uuid.uuid4()) self.url = '/v3/fake/servers/%s/consoles' % self.uuid self.controller = consoles.ConsolesController() def test_create_console(self): def fake_create_console(cons_self, context, instance_id): self.assertEqual(instance_id, self.uuid) return {} self.stubs.Set(console.api.API, 'create_console', fake_create_console) req = fakes.HTTPRequestV3.blank(self.url) self.controller.create(req, self.uuid, None) self.assertEqual(self.controller.create.wsgi_code, 201) def test_create_console_unknown_instance(self): def fake_create_console(cons_self, context, instance_id): raise exception.InstanceNotFound(instance_id=instance_id) self.stubs.Set(console.api.API, 'create_console', fake_create_console) req = fakes.HTTPRequestV3.blank(self.url) self.assertRaises(webob.exc.HTTPNotFound, self.controller.create, req, self.uuid, None) def test_show_console(self): def fake_get_console(cons_self, context, instance_id, console_id): self.assertEqual(instance_id, self.uuid) self.assertEqual(console_id, 20) pool = dict(console_type='fake_type', public_hostname='fake_hostname') return dict(id=console_id, password='fake_password', port='fake_port', pool=pool, instance_name='inst-0001') expected = {'console': {'id': 20, 'port': 'fake_port', 'host': 'fake_hostname', 'password': 'fake_password', 'instance_name': 'inst-0001', 'console_type': 'fake_type'}} self.stubs.Set(console.api.API, 'get_console', fake_get_console) req = fakes.HTTPRequestV3.blank(self.url + '/20') res_dict = self.controller.show(req, self.uuid, '20') self.assertThat(res_dict, matchers.DictMatches(expected)) def test_show_console_unknown_console(self): def fake_get_console(cons_self, context, instance_id, console_id): raise exception.ConsoleNotFound(console_id=console_id) self.stubs.Set(console.api.API, 'get_console', fake_get_console) req = fakes.HTTPRequestV3.blank(self.url + '/20') self.assertRaises(webob.exc.HTTPNotFound, self.controller.show, req, self.uuid, '20') def test_show_console_unknown_instance(self): def fake_get_console(cons_self, context, instance_id, console_id): raise exception.ConsoleNotFoundForInstance( instance_uuid=instance_id) self.stubs.Set(console.api.API, 'get_console', fake_get_console) req = fakes.HTTPRequestV3.blank(self.url + '/20') self.assertRaises(webob.exc.HTTPNotFound, self.controller.show, req, self.uuid, '20') def test_list_consoles(self): def fake_get_consoles(cons_self, context, instance_id): self.assertEqual(instance_id, self.uuid) pool1 = dict(console_type='fake_type', public_hostname='fake_hostname') cons1 = dict(id=10, password='fake_password', port='fake_port', pool=pool1) pool2 = dict(console_type='fake_type2', public_hostname='fake_hostname2') cons2 = dict(id=11, password='fake_password2', port='fake_port2', pool=pool2) return [cons1, cons2] expected = {'consoles': [{'id': 10, 'console_type': 'fake_type'}, {'id': 11, 'console_type': 'fake_type2'}]} self.stubs.Set(console.api.API, 'get_consoles', fake_get_consoles) req = fakes.HTTPRequestV3.blank(self.url) res_dict = self.controller.index(req, self.uuid) self.assertThat(res_dict, matchers.DictMatches(expected)) def test_list_consoles_unknown_instance(self): def fake_get_consoles(cons_self, context, instance_id): raise exception.InstanceNotFound(instance_id=instance_id) self.stubs.Set(console.api.API, 'get_consoles', fake_get_consoles) req = fakes.HTTPRequestV3.blank(self.url) self.assertRaises(webob.exc.HTTPNotFound, self.controller.index, req, self.uuid) def test_delete_console(self): def fake_get_console(cons_self, context, instance_id, console_id): self.assertEqual(instance_id, self.uuid) self.assertEqual(console_id, 20) pool = dict(console_type='fake_type', public_hostname='fake_hostname') return dict(id=console_id, password='fake_password', port='fake_port', pool=pool) def fake_delete_console(cons_self, context, instance_id, console_id): self.assertEqual(instance_id, self.uuid) self.assertEqual(console_id, 20) self.stubs.Set(console.api.API, 'get_console', fake_get_console) self.stubs.Set(console.api.API, 'delete_console', fake_delete_console) req = fakes.HTTPRequestV3.blank(self.url + '/20') self.controller.delete(req, self.uuid, '20') def test_delete_console_unknown_console(self): def fake_delete_console(cons_self, context, instance_id, console_id): raise exception.ConsoleNotFound(console_id=console_id) self.stubs.Set(console.api.API, 'delete_console', fake_delete_console) req = fakes.HTTPRequestV3.blank(self.url + '/20') self.assertRaises(webob.exc.HTTPNotFound, self.controller.delete, req, self.uuid, '20') def test_delete_console_unknown_instance(self): def fake_delete_console(cons_self, context, instance_id, console_id): raise exception.ConsoleNotFoundForInstance( instance_uuid=instance_id) self.stubs.Set(console.api.API, 'delete_console', fake_delete_console) req = fakes.HTTPRequestV3.blank(self.url + '/20') self.assertRaises(webob.exc.HTTPNotFound, self.controller.delete, req, self.uuid, '20')
apache-2.0
[ 3, 1898, 7129, 13, 8128, 14260, 2752, 199, 3, 1898, 7760, 510, 631, 265, 8142, 27799, 12, 3277, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 2197, 199, 646, 5377, 465, 26678, 63, 2580, 199, 199, 646, 14568, 199, 199, 504, 5913, 14, 1246, 14, 8512, 14, 3357, 14, 5265, 14, 86, 19, 492, 406, 1152, 2978, 199, 504, 5913, 14, 3357, 492, 4169, 63, 4981, 199, 504, 5913, 492, 8559, 199, 504, 5913, 492, 1592, 199, 504, 5913, 492, 1919, 199, 504, 5913, 14, 8512, 14, 2330, 492, 23011, 199, 504, 5913, 492, 511, 199, 504, 5913, 14, 2219, 14, 1246, 14, 8512, 492, 14063, 199, 504, 5913, 14, 2219, 492, 31679, 421, 199, 14623, 63, 8757, 275, 283, 10980, 13, 6000, 13, 6000, 13, 6000, 13, 10980, 6000, 7, 421, 199, 533, 7777, 3244, 2846, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 5990, 63, 991, 63, 344, 275, 1052, 267, 291, 14, 1580, 63, 991, 63, 2580, 275, 1052, 267, 291, 14, 988, 63, 344, 275, 378, 339, 347, 372, 63, 1000, 63, 991, 63, 344, 8, 277, 12, 1067, 12, 1305, 304, 267, 340, 1305, 440, 315, 291, 14, 5990, 63, 991, 63, 344, 26, 288, 291, 423, 525, 63, 1000, 8, 344, 29, 344, 9, 267, 372, 1211, 8, 277, 14, 5990, 63, 991, 63, 344, 59, 344, 566, 339, 347, 372, 63, 1000, 63, 991, 63, 2580, 8, 277, 12, 1067, 12, 5377, 304, 267, 340, 5377, 440, 315, 291, 14, 1580, 63, 991, 63, 2580, 26, 288, 291, 423, 525, 63, 1000, 8, 2580, 29, 2580, 9, 267, 372, 1211, 8, 277, 14, 5990, 63, 991, 63, 344, 59, 277, 14, 1580, 63, 991, 63, 2580, 59, 2580, 3934, 339, 347, 485, 525, 63, 1000, 8, 277, 12, 1305, 29, 403, 12, 5377, 29, 403, 304, 267, 340, 1305, 365, 488, 26, 288, 1305, 275, 291, 14, 988, 63, 344, 435, 413, 267, 340, 5377, 365, 488, 26, 288, 5377, 275, 620, 8, 28683, 63, 2580, 14, 2580, 20, 1012, 267, 1256, 275, 10098, 63, 842, 8, 344, 12, 5377, 29, 2580, 9, 267, 291, 14, 5990, 63, 991, 63, 344, 59, 344, 61, 275, 1256, 267, 291, 14, 1580, 63, 991, 63, 2580, 59, 2580, 61, 275, 1305, 267, 340, 1305, 690, 291, 14, 988, 63, 344, 26, 288, 291, 14, 988, 63, 344, 275, 1305, 421, 199, 318, 10098, 63, 842, 8, 344, 12, 922, 63, 344, 534, 3183, 297, 2199, 63, 344, 534, 3183, 297, 1591, 29, 403, 12, 2116, 4169, 63, 929, 29, 403, 12, 2120, 63, 929, 29, 403, 12, 2116, 25476, 63, 344, 8772, 5377, 29, 14623, 63, 8757, 12, 1834, 63, 1121, 628, 709, 401, 2116, 8541, 63, 344, 628, 17, 401, 536, 29, 403, 12, 790, 63, 354, 4581, 2116, 2879, 63, 4774, 20, 29, 403, 12, 2879, 63, 4774, 22, 29, 403, 12, 6696, 29, 16, 304, 339, 340, 1591, 365, 440, 488, 26, 267, 1591, 275, 620, 8, 1102, 9, 339, 340, 790, 63, 354, 26, 267, 790, 63, 576, 275, 283, 14623, 7, 272, 587, 26, 267, 790, 63, 576, 275, 2125, 339, 327, 799, 8213, 998, 5712, 1133, 4847, 1771, 12, 11176, 652, 315, 2337, 14, 272, 1654, 63, 354, 275, 536, 503, 298, 1000, 5, 83, 2, 450, 1305, 272, 340, 25476, 63, 344, 1137, 10812, 267, 1654, 63, 354, 275, 298, 20522, 4970, 83, 2, 450, 334, 20522, 63, 344, 12, 776, 339, 1256, 275, 469, 267, 298, 344, 582, 1109, 8, 344, 395, 267, 298, 3966, 63, 292, 582, 2197, 14, 2083, 8, 6542, 12, 1616, 12, 1616, 12, 3144, 12, 378, 12, 378, 395, 267, 298, 5334, 63, 292, 582, 2197, 14, 2083, 8, 6542, 12, 4119, 12, 4119, 12, 4119, 12, 378, 12, 378, 395, 267, 298, 2113, 63, 2060, 582, 4873, 267, 298, 751, 63, 344, 582, 922, 63, 344, 12, 267, 298, 1715, 63, 344, 582, 2199, 63, 344, 12, 267, 298, 1569, 63, 1121, 582, 1834, 63, 1121, 12, 267, 298, 4989, 63, 344, 582, 4873, 267, 298, 26541, 63, 344, 582, 4873, 267, 298, 9850, 63, 1080, 582, 378, 12, 267, 298, 498, 63, 354, 582, 790, 63, 354, 12, 267, 298, 498, 63, 576, 582, 790, 63, 576, 12, 267, 298, 2611, 63, 929, 582, 4169, 63, 929, 503, 4169, 63, 4981, 14, 8248, 1206, 12, 267, 298, 1765, 63, 929, 582, 2120, 63, 929, 12, 267, 298, 4844, 63, 887, 582, 378, 12, 267, 298, 19685, 582, 378, 12, 267, 298, 1231, 63, 4908, 582, 378, 12, 267, 298, 4269, 582, 4873, 267, 298, 1102, 582, 1591, 12, 267, 298, 842, 63, 466, 582, 5479, 267, 298, 751, 63, 576, 582, 4873, 267, 298, 20522, 63, 344, 582, 25476, 63, 344, 12, 267, 298, 3088, 63, 1562, 582, 4873, 267, 298, 19274, 63, 292, 582, 23011, 14, 10779, 1062, 267, 298, 416, 22218, 63, 292, 582, 23011, 14, 10779, 1062, 267, 298, 18375, 63, 292, 582, 23011, 14, 10779, 1062, 267, 298, 11856, 63, 2619, 582, 4873, 267, 298, 2918, 63, 354, 582, 1654, 63, 354, 12, 267, 298, 2918, 63, 1802, 582, 4873, 267, 298, 9325, 582, 756, 12, 267, 298, 2343, 582, 990, 267, 298, 2732, 63, 711, 63, 86, 20, 582, 2879, 63, 4774, 20 ]
[ 1898, 7129, 13, 8128, 14260, 2752, 199, 3, 1898, 7760, 510, 631, 265, 8142, 27799, 12, 3277, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 2197, 199, 646, 5377, 465, 26678, 63, 2580, 199, 199, 646, 14568, 199, 199, 504, 5913, 14, 1246, 14, 8512, 14, 3357, 14, 5265, 14, 86, 19, 492, 406, 1152, 2978, 199, 504, 5913, 14, 3357, 492, 4169, 63, 4981, 199, 504, 5913, 492, 8559, 199, 504, 5913, 492, 1592, 199, 504, 5913, 492, 1919, 199, 504, 5913, 14, 8512, 14, 2330, 492, 23011, 199, 504, 5913, 492, 511, 199, 504, 5913, 14, 2219, 14, 1246, 14, 8512, 492, 14063, 199, 504, 5913, 14, 2219, 492, 31679, 421, 199, 14623, 63, 8757, 275, 283, 10980, 13, 6000, 13, 6000, 13, 6000, 13, 10980, 6000, 7, 421, 199, 533, 7777, 3244, 2846, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 5990, 63, 991, 63, 344, 275, 1052, 267, 291, 14, 1580, 63, 991, 63, 2580, 275, 1052, 267, 291, 14, 988, 63, 344, 275, 378, 339, 347, 372, 63, 1000, 63, 991, 63, 344, 8, 277, 12, 1067, 12, 1305, 304, 267, 340, 1305, 440, 315, 291, 14, 5990, 63, 991, 63, 344, 26, 288, 291, 423, 525, 63, 1000, 8, 344, 29, 344, 9, 267, 372, 1211, 8, 277, 14, 5990, 63, 991, 63, 344, 59, 344, 566, 339, 347, 372, 63, 1000, 63, 991, 63, 2580, 8, 277, 12, 1067, 12, 5377, 304, 267, 340, 5377, 440, 315, 291, 14, 1580, 63, 991, 63, 2580, 26, 288, 291, 423, 525, 63, 1000, 8, 2580, 29, 2580, 9, 267, 372, 1211, 8, 277, 14, 5990, 63, 991, 63, 344, 59, 277, 14, 1580, 63, 991, 63, 2580, 59, 2580, 3934, 339, 347, 485, 525, 63, 1000, 8, 277, 12, 1305, 29, 403, 12, 5377, 29, 403, 304, 267, 340, 1305, 365, 488, 26, 288, 1305, 275, 291, 14, 988, 63, 344, 435, 413, 267, 340, 5377, 365, 488, 26, 288, 5377, 275, 620, 8, 28683, 63, 2580, 14, 2580, 20, 1012, 267, 1256, 275, 10098, 63, 842, 8, 344, 12, 5377, 29, 2580, 9, 267, 291, 14, 5990, 63, 991, 63, 344, 59, 344, 61, 275, 1256, 267, 291, 14, 1580, 63, 991, 63, 2580, 59, 2580, 61, 275, 1305, 267, 340, 1305, 690, 291, 14, 988, 63, 344, 26, 288, 291, 14, 988, 63, 344, 275, 1305, 421, 199, 318, 10098, 63, 842, 8, 344, 12, 922, 63, 344, 534, 3183, 297, 2199, 63, 344, 534, 3183, 297, 1591, 29, 403, 12, 2116, 4169, 63, 929, 29, 403, 12, 2120, 63, 929, 29, 403, 12, 2116, 25476, 63, 344, 8772, 5377, 29, 14623, 63, 8757, 12, 1834, 63, 1121, 628, 709, 401, 2116, 8541, 63, 344, 628, 17, 401, 536, 29, 403, 12, 790, 63, 354, 4581, 2116, 2879, 63, 4774, 20, 29, 403, 12, 2879, 63, 4774, 22, 29, 403, 12, 6696, 29, 16, 304, 339, 340, 1591, 365, 440, 488, 26, 267, 1591, 275, 620, 8, 1102, 9, 339, 340, 790, 63, 354, 26, 267, 790, 63, 576, 275, 283, 14623, 7, 272, 587, 26, 267, 790, 63, 576, 275, 2125, 339, 327, 799, 8213, 998, 5712, 1133, 4847, 1771, 12, 11176, 652, 315, 2337, 14, 272, 1654, 63, 354, 275, 536, 503, 298, 1000, 5, 83, 2, 450, 1305, 272, 340, 25476, 63, 344, 1137, 10812, 267, 1654, 63, 354, 275, 298, 20522, 4970, 83, 2, 450, 334, 20522, 63, 344, 12, 776, 339, 1256, 275, 469, 267, 298, 344, 582, 1109, 8, 344, 395, 267, 298, 3966, 63, 292, 582, 2197, 14, 2083, 8, 6542, 12, 1616, 12, 1616, 12, 3144, 12, 378, 12, 378, 395, 267, 298, 5334, 63, 292, 582, 2197, 14, 2083, 8, 6542, 12, 4119, 12, 4119, 12, 4119, 12, 378, 12, 378, 395, 267, 298, 2113, 63, 2060, 582, 4873, 267, 298, 751, 63, 344, 582, 922, 63, 344, 12, 267, 298, 1715, 63, 344, 582, 2199, 63, 344, 12, 267, 298, 1569, 63, 1121, 582, 1834, 63, 1121, 12, 267, 298, 4989, 63, 344, 582, 4873, 267, 298, 26541, 63, 344, 582, 4873, 267, 298, 9850, 63, 1080, 582, 378, 12, 267, 298, 498, 63, 354, 582, 790, 63, 354, 12, 267, 298, 498, 63, 576, 582, 790, 63, 576, 12, 267, 298, 2611, 63, 929, 582, 4169, 63, 929, 503, 4169, 63, 4981, 14, 8248, 1206, 12, 267, 298, 1765, 63, 929, 582, 2120, 63, 929, 12, 267, 298, 4844, 63, 887, 582, 378, 12, 267, 298, 19685, 582, 378, 12, 267, 298, 1231, 63, 4908, 582, 378, 12, 267, 298, 4269, 582, 4873, 267, 298, 1102, 582, 1591, 12, 267, 298, 842, 63, 466, 582, 5479, 267, 298, 751, 63, 576, 582, 4873, 267, 298, 20522, 63, 344, 582, 25476, 63, 344, 12, 267, 298, 3088, 63, 1562, 582, 4873, 267, 298, 19274, 63, 292, 582, 23011, 14, 10779, 1062, 267, 298, 416, 22218, 63, 292, 582, 23011, 14, 10779, 1062, 267, 298, 18375, 63, 292, 582, 23011, 14, 10779, 1062, 267, 298, 11856, 63, 2619, 582, 4873, 267, 298, 2918, 63, 354, 582, 1654, 63, 354, 12, 267, 298, 2918, 63, 1802, 582, 4873, 267, 298, 9325, 582, 756, 12, 267, 298, 2343, 582, 990, 267, 298, 2732, 63, 711, 63, 86, 20, 582, 2879, 63, 4774, 20, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
chazu/ASCIIWar
dep/pyenet/Cython/Cython/Tempita/_looper.py
136
4168
""" Helper for looping over sequences, particular in templates. Often in a loop in a template it's handy to know what's next up, previously up, if this is the first or last item in the sequence, etc. These can be awkward to manage in a normal Python loop, but using the looper you can get a better sense of the context. Use like:: >>> for loop, item in looper(['a', 'b', 'c']): ... print loop.number, item ... if not loop.last: ... print '---' 1 a --- 2 b --- 3 c """ import sys from Cython.Tempita.compat3 import basestring_ __all__ = ['looper'] class looper(object): """ Helper for looping (particularly in templates) Use this like:: for loop, item in looper(seq): if loop.first: ... """ def __init__(self, seq): self.seq = seq def __iter__(self): return looper_iter(self.seq) def __repr__(self): return '<%s for %r>' % ( self.__class__.__name__, self.seq) class looper_iter(object): def __init__(self, seq): self.seq = list(seq) self.pos = 0 def __iter__(self): return self def __next__(self): if self.pos >= len(self.seq): raise StopIteration result = loop_pos(self.seq, self.pos), self.seq[self.pos] self.pos += 1 return result if sys.version < "3": next = __next__ class loop_pos(object): def __init__(self, seq, pos): self.seq = seq self.pos = pos def __repr__(self): return '<loop pos=%r at %r>' % ( self.seq[self.pos], self.pos) def index(self): return self.pos index = property(index) def number(self): return self.pos + 1 number = property(number) def item(self): return self.seq[self.pos] item = property(item) def __next__(self): try: return self.seq[self.pos + 1] except IndexError: return None __next__ = property(__next__) if sys.version < "3": next = __next__ def previous(self): if self.pos == 0: return None return self.seq[self.pos - 1] previous = property(previous) def odd(self): return not self.pos % 2 odd = property(odd) def even(self): return self.pos % 2 even = property(even) def first(self): return self.pos == 0 first = property(first) def last(self): return self.pos == len(self.seq) - 1 last = property(last) def length(self): return len(self.seq) length = property(length) def first_group(self, getter=None): """ Returns true if this item is the start of a new group, where groups mean that some attribute has changed. The getter can be None (the item itself changes), an attribute name like ``'.attr'``, a function, or a dict key or list index. """ if self.first: return True return self._compare_group(self.item, self.previous, getter) def last_group(self, getter=None): """ Returns true if this item is the end of a new group, where groups mean that some attribute has changed. The getter can be None (the item itself changes), an attribute name like ``'.attr'``, a function, or a dict key or list index. """ if self.last: return True return self._compare_group(self.item, self.__next__, getter) def _compare_group(self, item, other, getter): if getter is None: return item != other elif (isinstance(getter, basestring_) and getter.startswith('.')): getter = getter[1:] if getter.endswith('()'): getter = getter[:-2] return getattr(item, getter)() != getattr(other, getter)() else: return getattr(item, getter) != getattr(other, getter) elif hasattr(getter, '__call__'): return getter(item) != getter(other) else: return item[getter] != other[getter]
bsd-3-clause
[ 624, 199, 4433, 367, 4438, 316, 1806, 8013, 12, 6770, 315, 7009, 14, 199, 199, 3466, 724, 315, 282, 4438, 315, 282, 1978, 652, 1159, 4926, 89, 370, 5715, 4052, 1159, 2163, 1536, 12, 199, 6352, 590, 1536, 12, 340, 642, 365, 314, 1642, 503, 2061, 1242, 315, 314, 3414, 12, 5423, 14, 199, 20676, 883, 506, 26936, 829, 1005, 370, 9635, 315, 282, 3293, 2018, 4438, 12, 1325, 1808, 314, 199, 320, 2262, 1265, 883, 664, 282, 8034, 12249, 402, 314, 1067, 14, 221, 3645, 2839, 447, 339, 1306, 367, 4438, 12, 1242, 315, 560, 2262, 2941, 65, 297, 283, 66, 297, 283, 67, 9090, 272, 2263, 258, 870, 4438, 14, 1955, 12, 1242, 272, 2263, 258, 340, 440, 4438, 14, 2019, 26, 272, 2263, 260, 870, 283, 2595, 7, 272, 413, 282, 272, 10894, 272, 499, 330, 272, 10894, 272, 650, 286, 199, 199, 624, 199, 199, 646, 984, 199, 504, 26741, 14, 6530, 21492, 14, 5819, 19, 492, 7116, 63, 199, 199, 363, 452, 363, 275, 788, 320, 2262, 418, 421, 199, 533, 560, 2262, 8, 785, 304, 272, 408, 272, 11642, 367, 4438, 316, 334, 462, 6628, 590, 315, 7009, 9, 339, 3645, 642, 2839, 447, 398, 367, 4438, 12, 1242, 315, 560, 2262, 8, 3610, 304, 288, 340, 4438, 14, 2246, 26, 355, 2263, 272, 408, 339, 347, 636, 826, 721, 277, 12, 5412, 304, 267, 291, 14, 3610, 275, 5412, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 560, 2262, 63, 1661, 8, 277, 14, 3610, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 18342, 83, 367, 450, 82, 3524, 450, 334, 288, 291, 855, 533, 4914, 354, 3108, 291, 14, 3610, 9, 421, 199, 533, 560, 2262, 63, 1661, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 5412, 304, 267, 291, 14, 3610, 275, 769, 8, 3610, 9, 267, 291, 14, 1712, 275, 378, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 291, 339, 347, 636, 2184, 721, 277, 304, 267, 340, 291, 14, 1712, 2356, 822, 8, 277, 14, 3610, 304, 288, 746, 10852, 267, 754, 275, 4438, 63, 1712, 8, 277, 14, 3610, 12, 291, 14, 1712, 395, 291, 14, 3610, 59, 277, 14, 1712, 61, 267, 291, 14, 1712, 847, 413, 267, 372, 754, 339, 340, 984, 14, 1023, 665, 298, 19, 582, 267, 2163, 275, 636, 2184, 363, 421, 199, 533, 4438, 63, 1712, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 5412, 12, 2086, 304, 267, 291, 14, 3610, 275, 5412, 267, 291, 14, 1712, 275, 2086, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 3813, 2086, 2458, 82, 737, 450, 82, 3524, 450, 334, 288, 291, 14, 3610, 59, 277, 14, 1712, 467, 291, 14, 1712, 9, 339, 347, 1478, 8, 277, 304, 267, 372, 291, 14, 1712, 272, 1478, 275, 3324, 8, 1080, 9, 339, 347, 1329, 8, 277, 304, 267, 372, 291, 14, 1712, 435, 413, 272, 1329, 275, 3324, 8, 1955, 9, 339, 347, 1242, 8, 277, 304, 267, 372, 291, 14, 3610, 59, 277, 14, 1712, 61, 272, 1242, 275, 3324, 8, 1053, 9, 339, 347, 636, 2184, 721, 277, 304, 267, 862, 26, 288, 372, 291, 14, 3610, 59, 277, 14, 1712, 435, 413, 61, 267, 871, 7888, 26, 288, 372, 488, 272, 636, 2184, 363, 275, 3324, 3460, 2184, 3368, 339, 340, 984, 14, 1023, 665, 298, 19, 582, 267, 2163, 275, 636, 2184, 363, 339, 347, 4136, 8, 277, 304, 267, 340, 291, 14, 1712, 508, 378, 26, 288, 372, 488, 267, 372, 291, 14, 3610, 59, 277, 14, 1712, 446, 413, 61, 272, 4136, 275, 3324, 8, 6352, 9, 339, 347, 16699, 8, 277, 304, 267, 372, 440, 291, 14, 1712, 450, 499, 272, 16699, 275, 3324, 8, 16216, 9, 339, 347, 2755, 8, 277, 304, 267, 372, 291, 14, 1712, 450, 499, 272, 2755, 275, 3324, 8, 12056, 9, 339, 347, 1642, 8, 277, 304, 267, 372, 291, 14, 1712, 508, 378, 272, 1642, 275, 3324, 8, 2246, 9, 339, 347, 2061, 8, 277, 304, 267, 372, 291, 14, 1712, 508, 822, 8, 277, 14, 3610, 9, 446, 413, 272, 2061, 275, 3324, 8, 2019, 9, 339, 347, 2582, 8, 277, 304, 267, 372, 822, 8, 277, 14, 3610, 9, 272, 2582, 275, 3324, 8, 1267, 9, 339, 347, 1642, 63, 923, 8, 277, 12, 15917, 29, 403, 304, 267, 408, 267, 1803, 2549, 340, 642, 1242, 365, 314, 1343, 402, 282, 892, 1572, 12, 267, 2382, 4652, 4615, 626, 2005, 2225, 965, 2896, 14, 221, 710, 15917, 267, 883, 506, 488, 334, 1589, 1242, 6337, 4493, 395, 376, 2225, 536, 2839, 267, 1124, 1370, 962, 31638, 282, 805, 12, 503, 282, 1211, 790, 503, 769, 1478, 14, 267, 408, 267, 340, 291, 14, 2246, 26, 288, 372, 715, 267, 372, 291, 423, 5785, 63, 923, 8, 277, 14, 1053, 12, 291, 14, 6352, 12, 15917, 9, 339, 347, 2061, 63, 923, 8, 277, 12, 15917, 29, 403, 304, 267, 408, 267, 1803, 2549, 340, 642, 1242, 365, 314, 1284, 402, 282, 892, 1572, 12, 267, 2382, 4652, 4615, 626, 2005, 2225, 965, 2896, 14, 221, 710, 15917, 267, 883, 506, 488, 334, 1589, 1242, 6337, 4493, 395, 376, 2225, 536, 2839, 267, 1124, 1370, 962, 31638, 282, 805, 12, 503, 282, 1211, 790, 503, 769, 1478, 14, 267, 408, 267, 340, 291, 14, 2019, 26, 288, 372, 715, 267, 372, 291, 423, 5785, 63, 923, 8, 277, 14, 1053, 12, 291, 855, 2184, 3108, 15917, 9, 339, 347, 485, 5785, 63, 923, 8, 277, 12, 1242, 12, 1163, 12, 15917, 304, 267, 340, 15917, 365, 488, 26, 288, 372, 1242, 1137, 1163, 267, 916, 334, 6074, 8, 7416, 12, 7116, 4602, 1598, 436, 15917, 14, 2460, 7563, 304, 288, 15917, 275, 15917, 59, 17, 2938, 288, 340, 15917, 14, 4130, 360, 342, 735, 355, 15917, 275, 15917, 4439, 18, 61, 355, 372, 2519, 8, 1053, 12, 15917, 16315, 1137, 2519, 8, 1848, 12, 15917, 16315, 288, 587, 26, 355, 372, 2519, 8, 1053, 12, 15917, 9, 1137, 2519, 8, 1848, 12, 15917, 9, 267, 916, 2688, 8, 7416, 12, 2560, 1250 ]
[ 199, 4433, 367, 4438, 316, 1806, 8013, 12, 6770, 315, 7009, 14, 199, 199, 3466, 724, 315, 282, 4438, 315, 282, 1978, 652, 1159, 4926, 89, 370, 5715, 4052, 1159, 2163, 1536, 12, 199, 6352, 590, 1536, 12, 340, 642, 365, 314, 1642, 503, 2061, 1242, 315, 314, 3414, 12, 5423, 14, 199, 20676, 883, 506, 26936, 829, 1005, 370, 9635, 315, 282, 3293, 2018, 4438, 12, 1325, 1808, 314, 199, 320, 2262, 1265, 883, 664, 282, 8034, 12249, 402, 314, 1067, 14, 221, 3645, 2839, 447, 339, 1306, 367, 4438, 12, 1242, 315, 560, 2262, 2941, 65, 297, 283, 66, 297, 283, 67, 9090, 272, 2263, 258, 870, 4438, 14, 1955, 12, 1242, 272, 2263, 258, 340, 440, 4438, 14, 2019, 26, 272, 2263, 260, 870, 283, 2595, 7, 272, 413, 282, 272, 10894, 272, 499, 330, 272, 10894, 272, 650, 286, 199, 199, 624, 199, 199, 646, 984, 199, 504, 26741, 14, 6530, 21492, 14, 5819, 19, 492, 7116, 63, 199, 199, 363, 452, 363, 275, 788, 320, 2262, 418, 421, 199, 533, 560, 2262, 8, 785, 304, 272, 408, 272, 11642, 367, 4438, 316, 334, 462, 6628, 590, 315, 7009, 9, 339, 3645, 642, 2839, 447, 398, 367, 4438, 12, 1242, 315, 560, 2262, 8, 3610, 304, 288, 340, 4438, 14, 2246, 26, 355, 2263, 272, 408, 339, 347, 636, 826, 721, 277, 12, 5412, 304, 267, 291, 14, 3610, 275, 5412, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 560, 2262, 63, 1661, 8, 277, 14, 3610, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 18342, 83, 367, 450, 82, 3524, 450, 334, 288, 291, 855, 533, 4914, 354, 3108, 291, 14, 3610, 9, 421, 199, 533, 560, 2262, 63, 1661, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 5412, 304, 267, 291, 14, 3610, 275, 769, 8, 3610, 9, 267, 291, 14, 1712, 275, 378, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 291, 339, 347, 636, 2184, 721, 277, 304, 267, 340, 291, 14, 1712, 2356, 822, 8, 277, 14, 3610, 304, 288, 746, 10852, 267, 754, 275, 4438, 63, 1712, 8, 277, 14, 3610, 12, 291, 14, 1712, 395, 291, 14, 3610, 59, 277, 14, 1712, 61, 267, 291, 14, 1712, 847, 413, 267, 372, 754, 339, 340, 984, 14, 1023, 665, 298, 19, 582, 267, 2163, 275, 636, 2184, 363, 421, 199, 533, 4438, 63, 1712, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 5412, 12, 2086, 304, 267, 291, 14, 3610, 275, 5412, 267, 291, 14, 1712, 275, 2086, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 3813, 2086, 2458, 82, 737, 450, 82, 3524, 450, 334, 288, 291, 14, 3610, 59, 277, 14, 1712, 467, 291, 14, 1712, 9, 339, 347, 1478, 8, 277, 304, 267, 372, 291, 14, 1712, 272, 1478, 275, 3324, 8, 1080, 9, 339, 347, 1329, 8, 277, 304, 267, 372, 291, 14, 1712, 435, 413, 272, 1329, 275, 3324, 8, 1955, 9, 339, 347, 1242, 8, 277, 304, 267, 372, 291, 14, 3610, 59, 277, 14, 1712, 61, 272, 1242, 275, 3324, 8, 1053, 9, 339, 347, 636, 2184, 721, 277, 304, 267, 862, 26, 288, 372, 291, 14, 3610, 59, 277, 14, 1712, 435, 413, 61, 267, 871, 7888, 26, 288, 372, 488, 272, 636, 2184, 363, 275, 3324, 3460, 2184, 3368, 339, 340, 984, 14, 1023, 665, 298, 19, 582, 267, 2163, 275, 636, 2184, 363, 339, 347, 4136, 8, 277, 304, 267, 340, 291, 14, 1712, 508, 378, 26, 288, 372, 488, 267, 372, 291, 14, 3610, 59, 277, 14, 1712, 446, 413, 61, 272, 4136, 275, 3324, 8, 6352, 9, 339, 347, 16699, 8, 277, 304, 267, 372, 440, 291, 14, 1712, 450, 499, 272, 16699, 275, 3324, 8, 16216, 9, 339, 347, 2755, 8, 277, 304, 267, 372, 291, 14, 1712, 450, 499, 272, 2755, 275, 3324, 8, 12056, 9, 339, 347, 1642, 8, 277, 304, 267, 372, 291, 14, 1712, 508, 378, 272, 1642, 275, 3324, 8, 2246, 9, 339, 347, 2061, 8, 277, 304, 267, 372, 291, 14, 1712, 508, 822, 8, 277, 14, 3610, 9, 446, 413, 272, 2061, 275, 3324, 8, 2019, 9, 339, 347, 2582, 8, 277, 304, 267, 372, 822, 8, 277, 14, 3610, 9, 272, 2582, 275, 3324, 8, 1267, 9, 339, 347, 1642, 63, 923, 8, 277, 12, 15917, 29, 403, 304, 267, 408, 267, 1803, 2549, 340, 642, 1242, 365, 314, 1343, 402, 282, 892, 1572, 12, 267, 2382, 4652, 4615, 626, 2005, 2225, 965, 2896, 14, 221, 710, 15917, 267, 883, 506, 488, 334, 1589, 1242, 6337, 4493, 395, 376, 2225, 536, 2839, 267, 1124, 1370, 962, 31638, 282, 805, 12, 503, 282, 1211, 790, 503, 769, 1478, 14, 267, 408, 267, 340, 291, 14, 2246, 26, 288, 372, 715, 267, 372, 291, 423, 5785, 63, 923, 8, 277, 14, 1053, 12, 291, 14, 6352, 12, 15917, 9, 339, 347, 2061, 63, 923, 8, 277, 12, 15917, 29, 403, 304, 267, 408, 267, 1803, 2549, 340, 642, 1242, 365, 314, 1284, 402, 282, 892, 1572, 12, 267, 2382, 4652, 4615, 626, 2005, 2225, 965, 2896, 14, 221, 710, 15917, 267, 883, 506, 488, 334, 1589, 1242, 6337, 4493, 395, 376, 2225, 536, 2839, 267, 1124, 1370, 962, 31638, 282, 805, 12, 503, 282, 1211, 790, 503, 769, 1478, 14, 267, 408, 267, 340, 291, 14, 2019, 26, 288, 372, 715, 267, 372, 291, 423, 5785, 63, 923, 8, 277, 14, 1053, 12, 291, 855, 2184, 3108, 15917, 9, 339, 347, 485, 5785, 63, 923, 8, 277, 12, 1242, 12, 1163, 12, 15917, 304, 267, 340, 15917, 365, 488, 26, 288, 372, 1242, 1137, 1163, 267, 916, 334, 6074, 8, 7416, 12, 7116, 4602, 1598, 436, 15917, 14, 2460, 7563, 304, 288, 15917, 275, 15917, 59, 17, 2938, 288, 340, 15917, 14, 4130, 360, 342, 735, 355, 15917, 275, 15917, 4439, 18, 61, 355, 372, 2519, 8, 1053, 12, 15917, 16315, 1137, 2519, 8, 1848, 12, 15917, 16315, 288, 587, 26, 355, 372, 2519, 8, 1053, 12, 15917, 9, 1137, 2519, 8, 1848, 12, 15917, 9, 267, 916, 2688, 8, 7416, 12, 2560, 1250, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
kiith-sa/QGIS
python/plugins/processing/gdal/polygonize.py
4
2948
# -*- coding: utf-8 -*- """ *************************************************************************** polygonize.py --------------------- Date : August 2012 Copyright : (C) 2012 by Victor Olaya Email : volayaf at gmail 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__ = 'Victor Olaya' __date__ = 'August 2012' __copyright__ = '(C) 2012, Victor Olaya' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' from PyQt4 import QtGui, QtCore from processing.core.GeoAlgorithm import GeoAlgorithm from processing.parameters.ParameterRaster import ParameterRaster from processing.parameters.ParameterString import ParameterString from processing.outputs.OutputVector import OutputVector from processing.tools.system import * from processing.gdal.GdalUtils import GdalUtils class polygonize(GeoAlgorithm): INPUT = 'INPUT' OUTPUT = 'OUTPUT' FIELD = 'FIELD' def getIcon(self): filepath = os.path.dirname(__file__) + '/icons/polygonize.png' return QtGui.QIcon(filepath) def commandLineName(self): return "gdalogr:polygonize" def defineCharacteristics(self): self.name = 'Polygonize (raster to vector)' self.group = '[GDAL] Conversion' self.addParameter(ParameterRaster(polygonize.INPUT, 'Input layer', False)) self.addParameter(ParameterString(polygonize.FIELD, 'Output field name' , 'DN')) self.addOutput(OutputVector(polygonize.OUTPUT, 'Output layer')) def processAlgorithm(self, progress): arguments = [] arguments.append(self.getParameterValue(polygonize.INPUT)) arguments.append('-f') arguments.append('ESRI Shapefile') output = self.getOutputValue(polygonize.OUTPUT) arguments.append(output) arguments.append(QtCore.QFileInfo(output).baseName()) arguments.append(self.getParameterValue(polygonize.FIELD)) commands = [] if isWindows(): commands = ['cmd.exe', '/C ', 'gdal_polygonize.bat', GdalUtils.escapeAndJoin(arguments)] else: commands = ['gdal_polygonize.py', GdalUtils.escapeAndJoin(arguments)] GdalUtils.runGdal(commands, progress)
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 17623, 272, 17248, 794, 14, 647, 272, 10652, 9858, 272, 6148, 463, 520, 25298, 833, 6029, 272, 1898, 3322, 520, 334, 35, 9, 6029, 701, 6561, 630, 593, 817, 65, 272, 11426, 4483, 520, 5236, 1187, 2756, 737, 29712, 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, 2201, 630, 593, 817, 65, 7, 199, 363, 602, 363, 275, 283, 21640, 833, 6029, 7, 199, 363, 7307, 363, 275, 8189, 35, 9, 6029, 12, 6561, 630, 593, 817, 65, 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, 199, 199, 504, 14084, 20, 492, 5928, 12, 10565, 199, 504, 6661, 14, 1018, 14, 10748, 11570, 492, 8875, 11570, 199, 504, 6661, 14, 3214, 14, 4720, 13284, 492, 12009, 13284, 199, 504, 6661, 14, 3214, 14, 4720, 1558, 492, 12009, 1558, 199, 504, 6661, 14, 4467, 14, 2959, 3646, 492, 7242, 3646, 199, 504, 6661, 14, 2537, 14, 2253, 492, 627, 199, 199, 504, 6661, 14, 11600, 14, 39, 12390, 7535, 492, 598, 12390, 7535, 421, 199, 533, 17248, 794, 8, 10748, 11570, 304, 339, 21955, 275, 283, 7321, 7, 272, 18746, 275, 283, 8414, 7, 272, 26130, 275, 283, 8609, 7, 339, 347, 664, 8954, 8, 277, 304, 267, 9911, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 435, 1994, 16471, 15, 16295, 794, 14, 4524, 7, 267, 372, 5928, 14, 26196, 8, 7218, 9, 339, 347, 1414, 3049, 985, 8, 277, 304, 267, 372, 298, 7136, 2548, 82, 26, 16295, 794, 2, 339, 347, 5627, 1610, 29867, 8, 277, 304, 267, 291, 14, 354, 275, 283, 12367, 794, 334, 20876, 370, 5477, 3171, 267, 291, 14, 923, 275, 6730, 17835, 61, 1448, 1023, 7, 267, 291, 14, 26895, 8, 4720, 13284, 8, 16295, 794, 14, 7321, 12, 283, 3205, 4045, 297, 2079, 756, 430, 267, 291, 14, 26895, 8, 4720, 1558, 8, 16295, 794, 14, 8609, 12, 283, 2959, 901, 536, 7, 2079, 2360, 283, 10872, 1333, 267, 291, 14, 525, 2959, 8, 2959, 3646, 8, 16295, 794, 14, 8414, 12, 283, 2959, 4045, 1333, 339, 347, 2112, 11570, 8, 277, 12, 6696, 304, 267, 2368, 275, 942, 267, 2368, 14, 740, 8, 277, 14, 362, 24637, 8, 16295, 794, 14, 7321, 430, 267, 2368, 14, 740, 3654, 70, 358, 267, 2368, 14, 740, 360, 654, 6129, 16528, 493, 358, 267, 1072, 275, 291, 14, 362, 2959, 1110, 8, 16295, 794, 14, 8414, 9, 267, 2368, 14, 740, 8, 1199, 9, 267, 2368, 14, 740, 8, 10901, 14, 49, 1173, 2354, 8, 1199, 680, 1095, 985, 1012, 267, 2368, 14, 740, 8, 277, 14, 362, 24637, 8, 16295, 794, 14, 8609, 430, 398, 3718, 275, 942, 267, 340, 365, 8647, 837, 288, 3718, 275, 788, 1760, 14, 5803, 297, 1994, 35, 1656, 283, 11600, 63, 16295, 794, 14, 13475, 297, 717, 598, 12390, 7535, 14, 3765, 3325, 13005, 8, 4958, 1874, 267, 587, 26, 288, 3718, 275, 788, 11600, 63, 16295, 794, 14, 647, 297, 717, 598, 12390, 7535, 14, 3765, 3325, 13005, 8, 4958, 1874, 398, 598, 12390, 7535, 14, 1065, 39, 12390, 8, 4405, 12, 6696, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 17623, 272, 17248, 794, 14, 647, 272, 10652, 9858, 272, 6148, 463, 520, 25298, 833, 6029, 272, 1898, 3322, 520, 334, 35, 9, 6029, 701, 6561, 630, 593, 817, 65, 272, 11426, 4483, 520, 5236, 1187, 2756, 737, 29712, 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, 2201, 630, 593, 817, 65, 7, 199, 363, 602, 363, 275, 283, 21640, 833, 6029, 7, 199, 363, 7307, 363, 275, 8189, 35, 9, 6029, 12, 6561, 630, 593, 817, 65, 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, 199, 199, 504, 14084, 20, 492, 5928, 12, 10565, 199, 504, 6661, 14, 1018, 14, 10748, 11570, 492, 8875, 11570, 199, 504, 6661, 14, 3214, 14, 4720, 13284, 492, 12009, 13284, 199, 504, 6661, 14, 3214, 14, 4720, 1558, 492, 12009, 1558, 199, 504, 6661, 14, 4467, 14, 2959, 3646, 492, 7242, 3646, 199, 504, 6661, 14, 2537, 14, 2253, 492, 627, 199, 199, 504, 6661, 14, 11600, 14, 39, 12390, 7535, 492, 598, 12390, 7535, 421, 199, 533, 17248, 794, 8, 10748, 11570, 304, 339, 21955, 275, 283, 7321, 7, 272, 18746, 275, 283, 8414, 7, 272, 26130, 275, 283, 8609, 7, 339, 347, 664, 8954, 8, 277, 304, 267, 9911, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 435, 1994, 16471, 15, 16295, 794, 14, 4524, 7, 267, 372, 5928, 14, 26196, 8, 7218, 9, 339, 347, 1414, 3049, 985, 8, 277, 304, 267, 372, 298, 7136, 2548, 82, 26, 16295, 794, 2, 339, 347, 5627, 1610, 29867, 8, 277, 304, 267, 291, 14, 354, 275, 283, 12367, 794, 334, 20876, 370, 5477, 3171, 267, 291, 14, 923, 275, 6730, 17835, 61, 1448, 1023, 7, 267, 291, 14, 26895, 8, 4720, 13284, 8, 16295, 794, 14, 7321, 12, 283, 3205, 4045, 297, 2079, 756, 430, 267, 291, 14, 26895, 8, 4720, 1558, 8, 16295, 794, 14, 8609, 12, 283, 2959, 901, 536, 7, 2079, 2360, 283, 10872, 1333, 267, 291, 14, 525, 2959, 8, 2959, 3646, 8, 16295, 794, 14, 8414, 12, 283, 2959, 4045, 1333, 339, 347, 2112, 11570, 8, 277, 12, 6696, 304, 267, 2368, 275, 942, 267, 2368, 14, 740, 8, 277, 14, 362, 24637, 8, 16295, 794, 14, 7321, 430, 267, 2368, 14, 740, 3654, 70, 358, 267, 2368, 14, 740, 360, 654, 6129, 16528, 493, 358, 267, 1072, 275, 291, 14, 362, 2959, 1110, 8, 16295, 794, 14, 8414, 9, 267, 2368, 14, 740, 8, 1199, 9, 267, 2368, 14, 740, 8, 10901, 14, 49, 1173, 2354, 8, 1199, 680, 1095, 985, 1012, 267, 2368, 14, 740, 8, 277, 14, 362, 24637, 8, 16295, 794, 14, 8609, 430, 398, 3718, 275, 942, 267, 340, 365, 8647, 837, 288, 3718, 275, 788, 1760, 14, 5803, 297, 1994, 35, 1656, 283, 11600, 63, 16295, 794, 14, 13475, 297, 717, 598, 12390, 7535, 14, 3765, 3325, 13005, 8, 4958, 1874, 267, 587, 26, 288, 3718, 275, 788, 11600, 63, 16295, 794, 14, 647, 297, 717, 598, 12390, 7535, 14, 3765, 3325, 13005, 8, 4958, 1874, 398, 598, 12390, 7535, 14, 1065, 39, 12390, 8, 4405, 12, 6696, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
anthrotype/nototools
nototools/emoji_ordering.py
1
16038
#!/usr/bin/env python # # 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. """Represents an ordering of emoji strings, broken into categories and subcategories. Emoji strings are sequences of emoji and related characters defined by Unicode, for example flags from pairs of regional indicator symbols, varieties of families and couples, emoji with skin tone variants, and standalone emoji. API is provided to return the categories and subcategories, the emoji strings in them, and the category, subcategory tuple for an emoji string. Functions are provided to parse three kinds of source data files. .csv file: This has three columns: Category name, emoji-strings separated by space, and subcategory name. The first row, headers, starts with a # and is ignored. emojiOrdering.txt file: This data is a bit raw, so gets validated during processing. For an example see the unicodetools svn repo, i.e. http://www.unicode.org/utility/trac/browser/trunk/unicodetools at data/emoji/3.0/source/emojiOrdering.txt .html file This data comes from unicode, e.g. http://unicode.org/emoji/charts-beta/emoji-ordering.html Note, this html file closes the table tags and the parser relies on this. """ import argparse import codecs import collections from HTMLParser import HTMLParser from itertools import chain import os from os import path import re import sys from nototools import unicode_data def _generate_emoji_to_cat_tuple(category_odict): """category_odict is an ordered dict of categories to ordered dict of subcategories to lists of emoji sequences. Returns a mapping from emoji sequence to a tuple of category, subcategory.""" result = {} for cat, subcat_odict in category_odict.items(): for subcat, emoji_sequences in subcat_odict.items(): for emoji_sequence in emoji_sequences: result[emoji_sequence] = (cat, subcat) return result class EmojiOrdering(object): def __init__(self, category_odict): """category_odict is an ordered dict of categories to ordered dict of subcategories to lists of emoji sequences. Since they're ordered we have a total ordering of all the emoji sequences.""" self._category_odict = category_odict self._emoji_to_cat_tuple = None def category_names(self): """Returns the names of the categories.""" return self._category_odict.keys() def subcategory_names(self, category_name): """Returns None if category_name is not recognized.""" subcat_odict = self._category_odict.get(category_name) return subcat_odict.keys() if subcat_odict else None def emoji_in_category(self, category_name, subcategory_name=None): cat_odict = self._category_odict.get(category_name) if not cat_odict: return None if subcategory_name: return cat_odict.get(subcategory_name) return [i for i in chain.from_iterable(cat_odict.values())] def emoji_to_category(self, emoji_string): """Emoji_string is an emoji sequence, returns a tuple of category, subcategory if present, else None.""" return self._get_emoji_to_cat_tuple().get(emoji_string, None) def emoji_strings(self): return self._get_emoji_to_cat_tuple().keys() def _get_emoji_to_cat_tuple(self): if not self._emoji_to_cat_tuple: self._emoji_to_cat_tuple = _generate_emoji_to_cat_tuple( self._category_odict) return self._emoji_to_cat_tuple def _strip_varsels(odict): """Remove fe0f from sequences in odict.""" for cat, d in odict.items(): for subcat, elist in d.items(): d[subcat] = [s.replace(u'\ufe0f', '') for s in elist] def from_file(fname, ext=None, sep=None, strip_varsel=False): """Return an EmojiOrdering from the .csv or emojiOrdering file.""" _, fext = path.splitext(fname) if not ext: ext = fext[1:] with codecs.open(fname, 'r', 'utf-8') as f: text = f.read() if ext == 'csv': odict = _category_odict_from_csv(text, sep or ',') elif ext == 'html': odict = _category_odict_from_html(text) else: odict = _category_odict_from_eo(text) if strip_varsel: _strip_varsels(odict) return EmojiOrdering(odict) def _category_odict_from_csv(text, sep=','): print 'processing csv file' text_lines = text.splitlines() result = collections.OrderedDict() category_name = None category_data = None for line in text_lines: line = line.strip() if not line or line[0] == '#': continue category, subcategory, count, estrs = line.split(sep) category = category.strip() subcategory = subcategory.strip() if category != category_name: if category_name: result[category_name] = category_data category_name = category category_data = collections.OrderedDict() data = tuple(estrs.split()) if len(data) != int(count): print '### expected %d emoji in %s/%s but got %d' % ( int(count), category, subcategory, len(data)) category_data[subcategory] = data result[category_name] = category_data return result # set to true to log parsing of file DEBUG_LOAD_EMOJI = False def _category_odict_from_eo(text): print 'processing eo file' text_lines = text.splitlines() line_re = re.compile(r'^([a-z-]+)\s+(.+)$') category = None subcategory = None result = collections.OrderedDict() category_data = None # an odict from category to a tuple of emoji_strings subcategory_data = None # a list of emoji_strings def finish_subcategory(): if not subcategory: return if DEBUG_LOAD_EMOJI: print 'finish subcategory %s' % subcategory if subcategory_data: category_data[subcategory] = tuple(subcategory_data) else: print >> sys.stderr, 'ERROR no subcategory data' def finish_category(): if not category: return finish_subcategory() if DEBUG_LOAD_EMOJI: print 'finish category %s' % category if category_data: result[category] = category_data else: print >> sys.stderr, 'ERROR no category data' COMBINING_KEYCAPS = 0x20E3 EMOJI_VARSEL = 0xFE0F ZWJ = 0x200D REG_INDICATOR_START = 0x1F1E6 REG_INDICATOR_END = 0x1F1FF FITZ_START = 0x1F3FB FITZ_END = 0x1F3FF def emoji_strs(line): strs = [] def add(str, start, limit): s = str[start:limit] if DEBUG_LOAD_EMOJI: print 'adding', '_'.join('%04x' % ord(cp) for cp in s) strs.append(s) for s in line.split(): limit = len(s) if limit == 1: strs.append(s) continue if DEBUG_LOAD_EMOJI: print 'splitting %s' % ('_'.join('%04x' % ord(cp) for cp in s)) start = 0 break_on_non_special = False have_reg_indicator = False for i in range(limit): cp = ord(s[i]) if cp == COMBINING_KEYCAPS: if i == start: print >> sys.stderr, 'error, combining keycaps with no base' add(s, start, i+1) start = i + 1 continue if cp == EMOJI_VARSEL: if i == start: print >> sys.stderr, 'error, varsel with no base' add(s, start, i + 1) start = i + 1 continue if cp == ZWJ: if i == start: print >> sys.stderr, 'error, ZWJ with no lhs' start = i + 1 else: break_on_non_special = False continue if FITZ_START <= cp <= FITZ_END: if i == start: print >> sys.stderr, 'error, fitzpatrick modifier with no base' add(s, start, i + 1) start = i + 1 else: continue if REG_INDICATOR_START <= cp <= REG_INDICATOR_END: if have_reg_indicator: add(s, start, i + 1) start = i + 1 have_reg_indicator = False else: have_reg_indicator = True continue if break_on_non_special: add(s, start, i) start = i else: break_on_non_special = True if start < limit: add(s, start, limit) return strs for line in text_lines: line = line.strip() if not line or line[0] == '#': continue if line[0] == '@': finish_category() subcategory_data = [] category_data = collections.OrderedDict() subcategory = None category = line[1:].replace('_', ' ') if DEBUG_LOAD_EMOJI: print 'start category %s' % category continue m = line_re.match(line) if m: finish_subcategory() subcategory = m.group(1) subcategory_data = emoji_strs(m.group(2)) if DEBUG_LOAD_EMOJI: print 'start subcategory %s (%d)' % (subcategory, len(subcategory_data)) else: subcategory_data.extend(emoji_strs(line)) if DEBUG_LOAD_EMOJI: print '...', len(subcategory_data) finish_category() return result _keep_varsel_estrs = frozenset([ u'\U0001f468\u200d\u2764\ufe0f\u200d\U0001f48b\u200d\U0001f468', u'\U0001f469\u200d\u2764\ufe0f\u200d\U0001f48b\u200d\U0001f469', u'\U0001f468\u200d\u2764\ufe0f\u200d\U0001f468', u'\U0001f469\u200d\u2764\ufe0f\u200d\U0001f469']) def _fix_estrs(estrs): """Add fitzpatrick colors, and remove emoji variation selectors. 1) The emoji ordering html page omits the skin color variants. Since we want to display them, we have to add them. However, we don't add them for sequences with multiple people, since we don't support multiracial groups at the moment. 2) Currently we don't include emoji variation selectors in our sequences except after heavy black heart (and we probably don't need them there either). The font will work fine without them, but some systems doing fallback might break the sequences apart if the variation selectors are not present in text. So they should be there in the text, and not there in the font. Anyway, while we clean this up, we currently strip them except for the four cases where we retain them for legacy reasons. """ new_estrs = [] for estr in estrs: if estr in _keep_varsel_estrs: nestr = estr else: if u'\u2764' in estr: print '# oops', u''.join('\\u%04x' % ord(cp) for cp in estr) nestr = u''.join(cp for cp in estr if cp != u'\ufe0f') new_estrs.append(nestr) num_bases = sum(unicode_data.is_emoji_modifier_base(ord(cp)) for cp in estr) if num_bases != 1: continue split_before = len(nestr) for i, cp in enumerate(nestr): if unicode_data.is_emoji_modifier_base(ord(cp)): split_before = i + 1 break prefix = nestr[:split_before] suffix = nestr[split_before:] for cp in range(0x1f3fb, 0x1f3ff + 1): new_estrs.append(u''.join([prefix, unichr(cp), suffix])) return new_estrs def _category_odict_from_html(text): """Build by scraping the emoji ordering html page. This leverages the fact that all tr, td, th tags have closing tags (currently, at least).""" class odict_builder(HTMLParser): def __init__(self): HTMLParser.__init__(self) self.in_table = False self.in_category = False self.is_subcat = False self.text = [] self.estrs = [] self.d = collections.OrderedDict() self.cat = None self.subcat = None def handle_starttag(self, tag, attrs): if not self.in_table: if tag == 'table': self.in_table = True elif tag == 'th': self.in_category = True self.is_subcat = True if attrs: for k, v in attrs: if k == 'class' and v == u'bighead': self.is_subcat = False break elif tag == 'img': if attrs: for k, v in attrs: if k == 'alt': self.estrs.append(v) elif tag == 'tr': # currently, all th, tr have closing tags assert not self.estrs def handle_endtag(self, tag): if not self.in_table: return if self.estrs and tag == 'tr': self.d[self.cat][self.subcat] = _fix_estrs(self.estrs) self.estrs = [] elif tag == 'th': text = ' '.join(self.text) text = text.encode('utf-8') self.text = [] if self.is_subcat: self.subcat = text else: self.cat = text self.d[self.cat] = collections.OrderedDict() self.in_category = False elif tag == 'table': self.in_table = False return def handle_data(self, data): if self.in_category: data = data.strip() if data: self.text.append(data) b = odict_builder() b.feed(text) return b.d def _name_to_str(emoji_name): return u''.join(unichr(int(n, 16)) for n in emoji_name.split('_')) def _str_to_name(emoji_str): return '_'.join('%04x' % ord(cp) for cp in emoji_str) def _compare_with_dir(eo, dirname): # problem here is we omit fe0f in our emoji image names, but the category data # doesn't. def name_to_tuple(name): return tuple(int(n, 16) for n in name.split('_')) names = set() missing_names = set() prefix = 'emoji_u' prefix_len = len(prefix) emoji_names = set() for f in sorted(os.listdir(dirname)): basename, ext = path.splitext(f) if ext != '.png': continue if not basename.startswith(prefix): print 'skipping %s' % f continue emoji_name = basename[prefix_len:] emoji_names.add(emoji_name) if not eo.emoji_to_category(_name_to_str(emoji_name)): missing_names.add(emoji_name) if missing_names: print 'missing %d names' % len(missing_names) for name in sorted(missing_names, key=name_to_tuple): print ' %s' % name print category_count = 0 for category_name in eo.category_names(): for subcategory_name in eo.subcategory_names(category_name): category_set = set( _str_to_name(s) for s in eo.emoji_in_category(category_name, subcategory_name)) category_count += len(category_set) category_set -= emoji_names if category_set: print '%s/%s is missing %d items:' % ( category_name, subcategory_name, len(category_set)) for n in sorted(category_set, key=lambda n: name_to_tuple(n)): print ' %s' % n print '%4d emoji in category set' % category_count print '%4d emoji in directory %s' % (len(emoji_names), dirname) def main(): parser = argparse.ArgumentParser() parser.add_argument( '-f', '--file', help='emoji ordering data file', metavar='fname', required=True) parser.add_argument( '--ext', help='treat file as having extension ext', metavar='ext') parser.add_argument( '--sep', help='separator for csv file', default=',', metavar='sep') parser.add_argument( '--cmpdir', help='directory of images to compare against', metavar='dir') parser.add_argument( '--dump', help='dump category lists even if we\'re comparing', action='store_true') args = parser.parse_args() eo = from_file( args.file, ext=args.ext, sep=args.sep, strip_varsel=args.cmpdir is not None) if not args.cmpdir or args.dump: print 'dumping category info' for category in eo.category_names(): print category for subcategory in eo.subcategory_names(category): print ' ', subcategory for estr in eo.emoji_in_category(category, subcategory): print ' ', '_'.join('%04x' % ord(cp) for cp in estr) if args.cmpdir: _compare_with_dir(eo, args.cmpdir) if __name__ == '__main__': main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 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, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 18089, 376, 7794, 402, 325, 20452, 3326, 12, 10529, 1901, 9695, 436, 199, 954, 8906, 14, 221, 662, 20452, 3326, 787, 8013, 402, 325, 20452, 436, 4048, 4110, 199, 4037, 701, 6140, 12, 367, 2893, 3285, 687, 6342, 402, 4897, 279, 16385, 6698, 12, 199, 3808, 69, 1417, 402, 21450, 20111, 436, 17535, 83, 12, 325, 20452, 543, 28337, 307, 368, 21169, 12, 436, 199, 20323, 325, 20452, 14, 221, 3261, 365, 2741, 370, 372, 314, 9695, 436, 1007, 8906, 12, 199, 1589, 325, 20452, 3326, 315, 3062, 12, 436, 314, 4637, 12, 1007, 3710, 2008, 367, 376, 325, 20452, 199, 875, 14, 199, 199, 13967, 787, 2741, 370, 2198, 7795, 24241, 402, 1350, 666, 1584, 14, 199, 199, 14, 4737, 570, 26, 199, 2765, 965, 7795, 4362, 26, 13573, 536, 12, 325, 20452, 13, 5465, 11673, 701, 4601, 12, 436, 199, 954, 3710, 536, 14, 221, 710, 1642, 1962, 12, 2323, 12, 9174, 543, 282, 327, 436, 365, 5525, 14, 199, 199, 26445, 4738, 316, 14, 2424, 570, 26, 199, 2765, 666, 365, 282, 4546, 3066, 12, 880, 7545, 16468, 5309, 6661, 14, 199, 1858, 376, 2893, 1937, 314, 2649, 2537, 11327, 3831, 12, 284, 14, 69, 14, 199, 1014, 921, 1544, 14, 2975, 14, 1308, 15, 16877, 15, 23047, 15, 5750, 15, 13409, 15, 2975, 2537, 199, 292, 666, 15, 26445, 15, 19, 14, 16, 15, 1365, 15, 26445, 4738, 316, 14, 2424, 199, 199, 14, 1360, 570, 199, 2765, 666, 12477, 687, 2649, 12, 325, 14, 71, 14, 199, 1014, 921, 2975, 14, 1308, 15, 26445, 15, 31522, 13, 5683, 15, 26445, 13, 7128, 14, 1360, 199, 7443, 12, 642, 3517, 570, 27811, 314, 1817, 3762, 436, 314, 1798, 25749, 641, 642, 14, 199, 624, 199, 199, 646, 7534, 199, 646, 6010, 199, 646, 5055, 199, 504, 24581, 492, 24581, 199, 504, 7975, 492, 6036, 199, 646, 747, 199, 504, 747, 492, 931, 199, 646, 295, 199, 646, 984, 199, 199, 504, 440, 3459, 1446, 492, 2649, 63, 576, 199, 199, 318, 485, 4208, 63, 26445, 63, 475, 63, 3385, 63, 2960, 8, 3710, 63, 79, 807, 304, 272, 408, 3710, 63, 79, 807, 365, 376, 7741, 1211, 402, 9695, 370, 7741, 1211, 402, 272, 1007, 8906, 370, 5548, 402, 325, 20452, 8013, 14, 221, 1803, 282, 4412, 687, 272, 325, 20452, 3414, 370, 282, 2008, 402, 4637, 12, 1007, 3710, 1041, 272, 754, 275, 1052, 272, 367, 6230, 12, 1007, 3385, 63, 79, 807, 315, 4637, 63, 79, 807, 14, 1744, 837, 489, 367, 1007, 3385, 12, 325, 20452, 63, 13436, 315, 1007, 3385, 63, 79, 807, 14, 1744, 837, 267, 367, 325, 20452, 63, 4041, 315, 325, 20452, 63, 13436, 26, 881, 754, 59, 26445, 63, 4041, 61, 275, 334, 3385, 12, 1007, 3385, 9, 272, 372, 754, 421, 199, 533, 662, 20452, 4738, 316, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 4637, 63, 79, 807, 304, 272, 408, 3710, 63, 79, 807, 365, 376, 7741, 1211, 402, 9695, 370, 7741, 1211, 402, 272, 1007, 8906, 370, 5548, 402, 325, 20452, 8013, 14, 9336, 2985, 3984, 7741, 781, 1172, 272, 282, 3141, 7794, 402, 1006, 314, 325, 20452, 8013, 1041, 272, 291, 423, 3710, 63, 79, 807, 275, 4637, 63, 79, 807, 272, 291, 423, 26445, 63, 475, 63, 3385, 63, 2960, 275, 488, 819, 347, 4637, 63, 1247, 8, 277, 304, 272, 408, 3407, 314, 1561, 402, 314, 9695, 1041, 272, 372, 291, 423, 3710, 63, 79, 807, 14, 1612, 342, 819, 347, 1007, 3710, 63, 1247, 8, 277, 12, 4637, 63, 354, 304, 272, 408, 3407, 488, 340, 4637, 63, 354, 365, 440, 18054, 1041, 272, 1007, 3385, 63, 79, 807, 275, 291, 423, 3710, 63, 79, 807, 14, 362, 8, 3710, 63, 354, 9, 272, 372, 1007, 3385, 63, 79, 807, 14, 1612, 342, 340, 1007, 3385, 63, 79, 807, 587, 488, 819, 347, 325, 20452, 63, 262, 63, 3710, 8, 277, 12, 4637, 63, 354, 12, 1007, 3710, 63, 354, 29, 403, 304, 272, 6230, 63, 79, 807, 275, 291, 423, 3710, 63, 79, 807, 14, 362, 8, 3710, 63, 354, 9, 272, 340, 440, 6230, 63, 79, 807, 26, 489, 372, 488, 272, 340, 1007, 3710, 63, 354, 26, 489, 372, 6230, 63, 79, 807, 14, 362, 8, 954, 3710, 63, 354, 9, 272, 372, 359, 73, 367, 284, 315, 6036, 14, 504, 63, 8147, 8, 3385, 63, 79, 807, 14, 1459, 24821, 819, 347, 325, 20452, 63, 475, 63, 3710, 8, 277, 12, 325, 20452, 63, 875, 304, 272, 408, 37, 20452, 63, 875, 365, 376, 325, 20452, 3414, 12, 2529, 282, 2008, 402, 272, 4637, 12, 1007, 3710, 340, 3451, 12, 587, 488, 1041, 272, 372, 291, 423, 362, 63, 26445, 63, 475, 63, 3385, 63, 2960, 1252, 362, 8, 26445, 63, 875, 12, 488, 9, 819, 347, 325, 20452, 63, 5465, 8, 277, 304, 272, 372, 291, 423, 362, 63, 26445, 63, 475, 63, 3385, 63, 2960, 1252, 1612, 342, 819, 347, 485, 362, 63, 26445, 63, 475, 63, 3385, 63, 2960, 8, 277, 304, 272, 340, 440, 291, 423, 26445, 63, 475, 63, 3385, 63, 2960, 26, 489, 291, 423, 26445, 63, 475, 63, 3385, 63, 2960, 275, 485, 4208, 63, 26445, 63 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 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, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 18089, 376, 7794, 402, 325, 20452, 3326, 12, 10529, 1901, 9695, 436, 199, 954, 8906, 14, 221, 662, 20452, 3326, 787, 8013, 402, 325, 20452, 436, 4048, 4110, 199, 4037, 701, 6140, 12, 367, 2893, 3285, 687, 6342, 402, 4897, 279, 16385, 6698, 12, 199, 3808, 69, 1417, 402, 21450, 20111, 436, 17535, 83, 12, 325, 20452, 543, 28337, 307, 368, 21169, 12, 436, 199, 20323, 325, 20452, 14, 221, 3261, 365, 2741, 370, 372, 314, 9695, 436, 1007, 8906, 12, 199, 1589, 325, 20452, 3326, 315, 3062, 12, 436, 314, 4637, 12, 1007, 3710, 2008, 367, 376, 325, 20452, 199, 875, 14, 199, 199, 13967, 787, 2741, 370, 2198, 7795, 24241, 402, 1350, 666, 1584, 14, 199, 199, 14, 4737, 570, 26, 199, 2765, 965, 7795, 4362, 26, 13573, 536, 12, 325, 20452, 13, 5465, 11673, 701, 4601, 12, 436, 199, 954, 3710, 536, 14, 221, 710, 1642, 1962, 12, 2323, 12, 9174, 543, 282, 327, 436, 365, 5525, 14, 199, 199, 26445, 4738, 316, 14, 2424, 570, 26, 199, 2765, 666, 365, 282, 4546, 3066, 12, 880, 7545, 16468, 5309, 6661, 14, 199, 1858, 376, 2893, 1937, 314, 2649, 2537, 11327, 3831, 12, 284, 14, 69, 14, 199, 1014, 921, 1544, 14, 2975, 14, 1308, 15, 16877, 15, 23047, 15, 5750, 15, 13409, 15, 2975, 2537, 199, 292, 666, 15, 26445, 15, 19, 14, 16, 15, 1365, 15, 26445, 4738, 316, 14, 2424, 199, 199, 14, 1360, 570, 199, 2765, 666, 12477, 687, 2649, 12, 325, 14, 71, 14, 199, 1014, 921, 2975, 14, 1308, 15, 26445, 15, 31522, 13, 5683, 15, 26445, 13, 7128, 14, 1360, 199, 7443, 12, 642, 3517, 570, 27811, 314, 1817, 3762, 436, 314, 1798, 25749, 641, 642, 14, 199, 624, 199, 199, 646, 7534, 199, 646, 6010, 199, 646, 5055, 199, 504, 24581, 492, 24581, 199, 504, 7975, 492, 6036, 199, 646, 747, 199, 504, 747, 492, 931, 199, 646, 295, 199, 646, 984, 199, 199, 504, 440, 3459, 1446, 492, 2649, 63, 576, 199, 199, 318, 485, 4208, 63, 26445, 63, 475, 63, 3385, 63, 2960, 8, 3710, 63, 79, 807, 304, 272, 408, 3710, 63, 79, 807, 365, 376, 7741, 1211, 402, 9695, 370, 7741, 1211, 402, 272, 1007, 8906, 370, 5548, 402, 325, 20452, 8013, 14, 221, 1803, 282, 4412, 687, 272, 325, 20452, 3414, 370, 282, 2008, 402, 4637, 12, 1007, 3710, 1041, 272, 754, 275, 1052, 272, 367, 6230, 12, 1007, 3385, 63, 79, 807, 315, 4637, 63, 79, 807, 14, 1744, 837, 489, 367, 1007, 3385, 12, 325, 20452, 63, 13436, 315, 1007, 3385, 63, 79, 807, 14, 1744, 837, 267, 367, 325, 20452, 63, 4041, 315, 325, 20452, 63, 13436, 26, 881, 754, 59, 26445, 63, 4041, 61, 275, 334, 3385, 12, 1007, 3385, 9, 272, 372, 754, 421, 199, 533, 662, 20452, 4738, 316, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 4637, 63, 79, 807, 304, 272, 408, 3710, 63, 79, 807, 365, 376, 7741, 1211, 402, 9695, 370, 7741, 1211, 402, 272, 1007, 8906, 370, 5548, 402, 325, 20452, 8013, 14, 9336, 2985, 3984, 7741, 781, 1172, 272, 282, 3141, 7794, 402, 1006, 314, 325, 20452, 8013, 1041, 272, 291, 423, 3710, 63, 79, 807, 275, 4637, 63, 79, 807, 272, 291, 423, 26445, 63, 475, 63, 3385, 63, 2960, 275, 488, 819, 347, 4637, 63, 1247, 8, 277, 304, 272, 408, 3407, 314, 1561, 402, 314, 9695, 1041, 272, 372, 291, 423, 3710, 63, 79, 807, 14, 1612, 342, 819, 347, 1007, 3710, 63, 1247, 8, 277, 12, 4637, 63, 354, 304, 272, 408, 3407, 488, 340, 4637, 63, 354, 365, 440, 18054, 1041, 272, 1007, 3385, 63, 79, 807, 275, 291, 423, 3710, 63, 79, 807, 14, 362, 8, 3710, 63, 354, 9, 272, 372, 1007, 3385, 63, 79, 807, 14, 1612, 342, 340, 1007, 3385, 63, 79, 807, 587, 488, 819, 347, 325, 20452, 63, 262, 63, 3710, 8, 277, 12, 4637, 63, 354, 12, 1007, 3710, 63, 354, 29, 403, 304, 272, 6230, 63, 79, 807, 275, 291, 423, 3710, 63, 79, 807, 14, 362, 8, 3710, 63, 354, 9, 272, 340, 440, 6230, 63, 79, 807, 26, 489, 372, 488, 272, 340, 1007, 3710, 63, 354, 26, 489, 372, 6230, 63, 79, 807, 14, 362, 8, 954, 3710, 63, 354, 9, 272, 372, 359, 73, 367, 284, 315, 6036, 14, 504, 63, 8147, 8, 3385, 63, 79, 807, 14, 1459, 24821, 819, 347, 325, 20452, 63, 475, 63, 3710, 8, 277, 12, 325, 20452, 63, 875, 304, 272, 408, 37, 20452, 63, 875, 365, 376, 325, 20452, 3414, 12, 2529, 282, 2008, 402, 272, 4637, 12, 1007, 3710, 340, 3451, 12, 587, 488, 1041, 272, 372, 291, 423, 362, 63, 26445, 63, 475, 63, 3385, 63, 2960, 1252, 362, 8, 26445, 63, 875, 12, 488, 9, 819, 347, 325, 20452, 63, 5465, 8, 277, 304, 272, 372, 291, 423, 362, 63, 26445, 63, 475, 63, 3385, 63, 2960, 1252, 1612, 342, 819, 347, 485, 362, 63, 26445, 63, 475, 63, 3385, 63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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
alihalabyah/grab
test/grab_proxy.py
12
6038
# coding: utf-8 from test.util import build_grab, TMP_FILE from test.util import (BaseGrabTestCase, TEST_SERVER_PORT, EXTRA_PORT1, EXTRA_PORT2) from test_server import TestServer import six from grab.proxylist import BaseProxySource ADDRESS = '127.0.0.1' PROXY1 = '%s:%d' % (ADDRESS, TEST_SERVER_PORT) PROXY2 = '%s:%d' % (ADDRESS, EXTRA_PORT1) PROXY3 = '%s:%d' % (ADDRESS, EXTRA_PORT2) class TestProxy(BaseGrabTestCase): def test_proxy_option(self): g = build_grab() g.setup(proxy=PROXY1, proxy_type='http', debug=True) self.server.response['get.data'] = '123' g.go('http://yandex.ru') self.assertEqual(b'123', g.response.body) self.assertEqual('yandex.ru', self.server.request['headers']['host']) def test_deprecated_setup_proxylist(self): g = build_grab() open(TMP_FILE, 'w').write(PROXY1) g.load_proxylist(TMP_FILE, 'text_file') self.server.response['get.data'] = '123' g.change_proxy() g.go('http://yandex.ru') self.assertEqual(b'123', g.response.body) self.assertEqual('yandex.ru', self.server.request['headers']['host']) def test_load_proxylist(self): content = '%s\n%s\n%s' % (PROXY1, PROXY2, PROXY3) open(TMP_FILE, 'w').write(content) # By default auto_change is True g = build_grab() g.load_proxylist(TMP_FILE, 'text_file') self.assertEqual(g.config['proxy_auto_change'], True) servers = set() for x in six.moves.range(10): g.go('http://yandex.ru') servers.add(g.config['proxy']) self.assertTrue(len(servers) > 1) # Disable auto_change # By default auto_init is True g = build_grab() g.load_proxylist(TMP_FILE, 'text_file', auto_change=False) self.assertEqual(g.config['proxy_auto_change'], False) servers = set() for x in six.moves.range(10): g.go('http://yandex.ru') servers.add(g.config['proxy']) self.assertEqual(len(servers), 1) # Disable auto_change # Disable auto_init # Proxylist will not be used by default g = build_grab() g.load_proxylist(TMP_FILE, 'text_file', auto_change=False, auto_init=False) self.assertEqual(g.config['proxy_auto_change'], False) g.go(self.server.get_url()) self.assertEqual(g.config['proxy'], None) def test_change_proxy(self): g = build_grab() g.change_proxy() self.assertEqual(g.config['proxy'], None) g = build_grab() with open(TMP_FILE, 'w') as out: for x in six.moves.range(10): out.write('server-%d:777\n' % x) g.load_proxylist(TMP_FILE, 'text_file', auto_init=False, auto_change=False) self.assertEqual(g.config['proxy'], None) g.load_proxylist(TMP_FILE, 'text_file', auto_init=False, auto_change=True) self.assertEqual(g.config['proxy'], None) g.load_proxylist(TMP_FILE, 'text_file', auto_init=True, auto_change=False) self.assertTrue('server-' in g.config['proxy']) def test_list_proxysource(self): g = build_grab() items = [PROXY1, PROXY2] g.proxylist.load_list(items) g.go('http://yandex.ru') self.assertEqual(self.server.request['headers']['host'], 'yandex.ru') self.assertTrue(g.doc.headers['listen-port'] in (str(TEST_SERVER_PORT), str(EXTRA_PORT1))) def test_custom_proxysource(self): class CustomProxySource(BaseProxySource): def load_raw_data(self): return '\n'.join((PROXY1, PROXY2 + ':foo:bar')) g = build_grab() g.setup(proxy_auto_change=False) g.proxylist.set_source(CustomProxySource()) g.use_next_proxy() g.go('http://yandex.ru') self.assertEqual(self.server.request['headers']['host'], 'yandex.ru') self.assertEqual(g.doc.headers['listen-port'], str(TEST_SERVER_PORT)) g.use_next_proxy() g.go('http://yandex.ru') self.assertEqual(self.server.request['headers']['host'], 'yandex.ru') self.assertEqual(g.doc.headers['listen-port'], str(EXTRA_PORT1)) def test_baseproxysource_constructor_arguments(self): ps = BaseProxySource() self.assertEqual(ps.config, {'proxy_type': 'http', 'proxy_userpwd': None}) ps = BaseProxySource(proxy_type='socks') self.assertEqual(ps.config, {'proxy_type': 'socks', 'proxy_userpwd': None}) ps = BaseProxySource(proxy_userpwd='foo:bar') self.assertEqual(ps.config, {'proxy_type': 'http', 'proxy_userpwd': 'foo:bar'}) ps = BaseProxySource(foo='bar') self.assertEqual(ps.config, {'proxy_type': 'http', 'proxy_userpwd': None, 'foo': 'bar'}) def test_global_proxy_userpwd_argument(self): g = build_grab() items = [PROXY1] g.proxylist.load_list(items) self.assertEquals(g.proxylist.get_next_proxy().username, None) g.proxylist.load_list(items, proxy_userpwd='foo:bar') proxy = g.proxylist.get_next_proxy() self.assertEquals(proxy.username, 'foo') self.assertEquals(proxy.password, 'bar') items = [PROXY1 + ':admin:test', PROXY2] g.proxylist.load_list(items, proxy_userpwd='foo:bar') proxy = g.proxylist.get_next_proxy() self.assertEquals(proxy.username, 'admin') self.assertEquals(proxy.password, 'test') def test_global_proxy_type_argument(self): g = build_grab() items = [PROXY1] g.proxylist.load_list(items) proxy = g.proxylist.get_next_proxy() self.assertEquals(proxy.proxy_type, 'http') g.proxylist.load_list(items, proxy_type='socks') proxy = g.proxylist.get_next_proxy() self.assertEquals(proxy.proxy_type, 'socks')
mit
[ 3, 2803, 26, 2774, 13, 24, 199, 504, 511, 14, 1974, 492, 1900, 63, 22090, 12, 377, 1658, 63, 3817, 199, 504, 511, 14, 1974, 492, 334, 1563, 5761, 66, 1746, 12, 7393, 63, 6613, 63, 3657, 12, 2432, 3651, 13954, 63, 3657, 17, 12, 3651, 13954, 63, 3657, 18, 9, 199, 504, 511, 63, 1000, 492, 1379, 3120, 199, 646, 3816, 199, 504, 18200, 14, 3280, 513, 492, 3523, 4936, 2980, 199, 199, 12368, 275, 283, 4195, 14, 16, 14, 16, 14, 17, 7, 199, 20026, 17, 275, 1543, 83, 2689, 68, 7, 450, 334, 12368, 12, 7393, 63, 6613, 63, 3657, 9, 199, 20026, 18, 275, 1543, 83, 2689, 68, 7, 450, 334, 12368, 12, 3651, 13954, 63, 3657, 17, 9, 199, 20026, 19, 275, 1543, 83, 2689, 68, 7, 450, 334, 12368, 12, 3651, 13954, 63, 3657, 18, 9, 421, 199, 533, 1379, 4936, 8, 1563, 5761, 66, 1746, 304, 272, 347, 511, 63, 3280, 63, 1422, 8, 277, 304, 267, 486, 275, 1900, 63, 22090, 342, 398, 486, 14, 2758, 8, 3280, 29, 20026, 17, 12, 4566, 63, 466, 534, 1014, 297, 3105, 29, 549, 9, 267, 291, 14, 1000, 14, 1310, 459, 362, 14, 576, 418, 275, 283, 4288, 7, 398, 486, 14, 1939, 360, 1014, 921, 89, 290, 731, 14, 6558, 358, 267, 291, 14, 629, 8, 66, 7, 4288, 297, 486, 14, 1310, 14, 2030, 9, 267, 291, 14, 629, 360, 89, 290, 731, 14, 6558, 297, 291, 14, 1000, 14, 1069, 459, 2139, 2545, 1102, 1105, 339, 347, 511, 63, 6667, 63, 2758, 63, 3280, 513, 8, 277, 304, 267, 486, 275, 1900, 63, 22090, 342, 267, 1551, 8, 17983, 63, 3817, 12, 283, 87, 1959, 952, 8, 20026, 17, 9, 267, 486, 14, 912, 63, 3280, 513, 8, 17983, 63, 3817, 12, 283, 505, 63, 493, 358, 267, 291, 14, 1000, 14, 1310, 459, 362, 14, 576, 418, 275, 283, 4288, 7, 267, 486, 14, 1461, 63, 3280, 342, 267, 486, 14, 1939, 360, 1014, 921, 89, 290, 731, 14, 6558, 358, 267, 291, 14, 629, 8, 66, 7, 4288, 297, 486, 14, 1310, 14, 2030, 9, 267, 291, 14, 629, 360, 89, 290, 731, 14, 6558, 297, 291, 14, 1000, 14, 1069, 459, 2139, 2545, 1102, 1105, 339, 347, 511, 63, 912, 63, 3280, 513, 8, 277, 304, 267, 1564, 275, 1543, 83, 60, 78, 5, 83, 60, 78, 5, 83, 7, 450, 334, 20026, 17, 12, 3611, 8195, 18, 12, 3611, 8195, 19, 9, 267, 1551, 8, 17983, 63, 3817, 12, 283, 87, 1959, 952, 8, 1317, 9, 398, 327, 4885, 849, 2599, 63, 1461, 365, 715, 267, 486, 275, 1900, 63, 22090, 342, 267, 486, 14, 912, 63, 3280, 513, 8, 17983, 63, 3817, 12, 283, 505, 63, 493, 358, 267, 291, 14, 629, 8, 71, 14, 888, 459, 3280, 63, 2495, 63, 1461, 995, 715, 9, 267, 8037, 275, 663, 342, 267, 367, 671, 315, 3816, 14, 4912, 14, 1842, 8, 709, 304, 288, 486, 14, 1939, 360, 1014, 921, 89, 290, 731, 14, 6558, 358, 288, 8037, 14, 525, 8, 71, 14, 888, 459, 3280, 1105, 398, 291, 14, 1815, 8, 552, 8, 5871, 9, 690, 413, 9, 398, 327, 17534, 2599, 63, 1461, 267, 327, 4885, 849, 2599, 63, 826, 365, 715, 267, 486, 275, 1900, 63, 22090, 342, 267, 486, 14, 912, 63, 3280, 513, 8, 17983, 63, 3817, 12, 283, 505, 63, 493, 297, 2599, 63, 1461, 29, 797, 9, 267, 291, 14, 629, 8, 71, 14, 888, 459, 3280, 63, 2495, 63, 1461, 995, 756, 9, 267, 8037, 275, 663, 342, 267, 367, 671, 315, 3816, 14, 4912, 14, 1842, 8, 709, 304, 288, 486, 14, 1939, 360, 1014, 921, 89, 290, 731, 14, 6558, 358, 288, 8037, 14, 525, 8, 71, 14, 888, 459, 3280, 1105, 267, 291, 14, 629, 8, 552, 8, 5871, 395, 413, 9, 398, 327, 17534, 2599, 63, 1461, 267, 327, 17534, 2599, 63, 826, 267, 327, 12373, 513, 911, 440, 506, 1202, 701, 849, 267, 486, 275, 1900, 63, 22090, 342, 267, 486, 14, 912, 63, 3280, 513, 8, 17983, 63, 3817, 12, 283, 505, 63, 493, 297, 2599, 63, 1461, 29, 797, 12, 586, 2599, 63, 826, 29, 797, 9, 267, 291, 14, 629, 8, 71, 14, 888, 459, 3280, 63, 2495, 63, 1461, 995, 756, 9, 267, 486, 14, 1939, 8, 277, 14, 1000, 14, 362, 63, 633, 1012, 267, 291, 14, 629, 8, 71, 14, 888, 459, 3280, 995, 488, 9, 339, 347, 511, 63, 1461, 63, 3280, 8, 277, 304, 267, 486, 275, 1900, 63, 22090, 342, 267, 486, 14, 1461, 63, 3280, 342, 267, 291, 14, 629, 8, 71, 14, 888, 459, 3280, 995, 488, 9, 398, 486, 275, 1900, 63, 22090, 342, 267, 543, 1551, 8, 17983, 63, 3817, 12, 283, 87, 358, 465, 734, 26, 288, 367, 671, 315, 3816, 14, 4912, 14, 1842, 8, 709, 304, 355, 734, 14, 952, 360, 1000, 3295, 68, 26, 11956, 60, 78, 7, 450, 671, 9, 267, 486, 14, 912, 63, 3280, 513, 8, 17983, 63, 3817, 12, 283, 505, 63, 493, 297, 2599, 63, 826, 29, 797, 12, 586, 2599, 63, 1461, 29, 797, 9, 267, 291, 14, 629, 8, 71, 14, 888, 459, 3280, 995, 488, 9, 398, 486, 14, 912, 63, 3280, 513, 8, 17983, 63, 3817, 12, 283, 505, 63, 493, 297, 2599, 63, 826, 29, 797, 12, 586, 2599, 63, 1461, 29, 549, 9, 267, 291, 14, 629, 8, 71, 14, 888, 459, 3280, 995, 488, 9, 398, 486, 14, 912, 63, 3280, 513, 8, 17983, 63, 3817, 12, 283, 505, 63, 493, 297, 2599, 63, 826, 29, 549, 12, 586, 2599, 63, 1461, 29, 797, 9, 267, 291, 14, 1815, 360, 1000, 15668, 315, 486, 14, 888, 459, 3280, 1105, 339, 347, 511, 63, 513, 63, 8221, 588, 616, 8, 277, 304, 267, 486, 275, 1900, 63, 22090, 342, 267, 2974, 275, 359, 20026, 17, 12, 3611, 8195, 18, 61, 267, 486, 14, 3280, 513, 14, 912, 63, 513, 8, 1744, 9, 267, 486, 14, 1939, 360, 1014, 921, 89, 290, 731, 14, 6558, 358, 267, 291, 14, 629, 8 ]
[ 2803, 26, 2774, 13, 24, 199, 504, 511, 14, 1974, 492, 1900, 63, 22090, 12, 377, 1658, 63, 3817, 199, 504, 511, 14, 1974, 492, 334, 1563, 5761, 66, 1746, 12, 7393, 63, 6613, 63, 3657, 12, 2432, 3651, 13954, 63, 3657, 17, 12, 3651, 13954, 63, 3657, 18, 9, 199, 504, 511, 63, 1000, 492, 1379, 3120, 199, 646, 3816, 199, 504, 18200, 14, 3280, 513, 492, 3523, 4936, 2980, 199, 199, 12368, 275, 283, 4195, 14, 16, 14, 16, 14, 17, 7, 199, 20026, 17, 275, 1543, 83, 2689, 68, 7, 450, 334, 12368, 12, 7393, 63, 6613, 63, 3657, 9, 199, 20026, 18, 275, 1543, 83, 2689, 68, 7, 450, 334, 12368, 12, 3651, 13954, 63, 3657, 17, 9, 199, 20026, 19, 275, 1543, 83, 2689, 68, 7, 450, 334, 12368, 12, 3651, 13954, 63, 3657, 18, 9, 421, 199, 533, 1379, 4936, 8, 1563, 5761, 66, 1746, 304, 272, 347, 511, 63, 3280, 63, 1422, 8, 277, 304, 267, 486, 275, 1900, 63, 22090, 342, 398, 486, 14, 2758, 8, 3280, 29, 20026, 17, 12, 4566, 63, 466, 534, 1014, 297, 3105, 29, 549, 9, 267, 291, 14, 1000, 14, 1310, 459, 362, 14, 576, 418, 275, 283, 4288, 7, 398, 486, 14, 1939, 360, 1014, 921, 89, 290, 731, 14, 6558, 358, 267, 291, 14, 629, 8, 66, 7, 4288, 297, 486, 14, 1310, 14, 2030, 9, 267, 291, 14, 629, 360, 89, 290, 731, 14, 6558, 297, 291, 14, 1000, 14, 1069, 459, 2139, 2545, 1102, 1105, 339, 347, 511, 63, 6667, 63, 2758, 63, 3280, 513, 8, 277, 304, 267, 486, 275, 1900, 63, 22090, 342, 267, 1551, 8, 17983, 63, 3817, 12, 283, 87, 1959, 952, 8, 20026, 17, 9, 267, 486, 14, 912, 63, 3280, 513, 8, 17983, 63, 3817, 12, 283, 505, 63, 493, 358, 267, 291, 14, 1000, 14, 1310, 459, 362, 14, 576, 418, 275, 283, 4288, 7, 267, 486, 14, 1461, 63, 3280, 342, 267, 486, 14, 1939, 360, 1014, 921, 89, 290, 731, 14, 6558, 358, 267, 291, 14, 629, 8, 66, 7, 4288, 297, 486, 14, 1310, 14, 2030, 9, 267, 291, 14, 629, 360, 89, 290, 731, 14, 6558, 297, 291, 14, 1000, 14, 1069, 459, 2139, 2545, 1102, 1105, 339, 347, 511, 63, 912, 63, 3280, 513, 8, 277, 304, 267, 1564, 275, 1543, 83, 60, 78, 5, 83, 60, 78, 5, 83, 7, 450, 334, 20026, 17, 12, 3611, 8195, 18, 12, 3611, 8195, 19, 9, 267, 1551, 8, 17983, 63, 3817, 12, 283, 87, 1959, 952, 8, 1317, 9, 398, 327, 4885, 849, 2599, 63, 1461, 365, 715, 267, 486, 275, 1900, 63, 22090, 342, 267, 486, 14, 912, 63, 3280, 513, 8, 17983, 63, 3817, 12, 283, 505, 63, 493, 358, 267, 291, 14, 629, 8, 71, 14, 888, 459, 3280, 63, 2495, 63, 1461, 995, 715, 9, 267, 8037, 275, 663, 342, 267, 367, 671, 315, 3816, 14, 4912, 14, 1842, 8, 709, 304, 288, 486, 14, 1939, 360, 1014, 921, 89, 290, 731, 14, 6558, 358, 288, 8037, 14, 525, 8, 71, 14, 888, 459, 3280, 1105, 398, 291, 14, 1815, 8, 552, 8, 5871, 9, 690, 413, 9, 398, 327, 17534, 2599, 63, 1461, 267, 327, 4885, 849, 2599, 63, 826, 365, 715, 267, 486, 275, 1900, 63, 22090, 342, 267, 486, 14, 912, 63, 3280, 513, 8, 17983, 63, 3817, 12, 283, 505, 63, 493, 297, 2599, 63, 1461, 29, 797, 9, 267, 291, 14, 629, 8, 71, 14, 888, 459, 3280, 63, 2495, 63, 1461, 995, 756, 9, 267, 8037, 275, 663, 342, 267, 367, 671, 315, 3816, 14, 4912, 14, 1842, 8, 709, 304, 288, 486, 14, 1939, 360, 1014, 921, 89, 290, 731, 14, 6558, 358, 288, 8037, 14, 525, 8, 71, 14, 888, 459, 3280, 1105, 267, 291, 14, 629, 8, 552, 8, 5871, 395, 413, 9, 398, 327, 17534, 2599, 63, 1461, 267, 327, 17534, 2599, 63, 826, 267, 327, 12373, 513, 911, 440, 506, 1202, 701, 849, 267, 486, 275, 1900, 63, 22090, 342, 267, 486, 14, 912, 63, 3280, 513, 8, 17983, 63, 3817, 12, 283, 505, 63, 493, 297, 2599, 63, 1461, 29, 797, 12, 586, 2599, 63, 826, 29, 797, 9, 267, 291, 14, 629, 8, 71, 14, 888, 459, 3280, 63, 2495, 63, 1461, 995, 756, 9, 267, 486, 14, 1939, 8, 277, 14, 1000, 14, 362, 63, 633, 1012, 267, 291, 14, 629, 8, 71, 14, 888, 459, 3280, 995, 488, 9, 339, 347, 511, 63, 1461, 63, 3280, 8, 277, 304, 267, 486, 275, 1900, 63, 22090, 342, 267, 486, 14, 1461, 63, 3280, 342, 267, 291, 14, 629, 8, 71, 14, 888, 459, 3280, 995, 488, 9, 398, 486, 275, 1900, 63, 22090, 342, 267, 543, 1551, 8, 17983, 63, 3817, 12, 283, 87, 358, 465, 734, 26, 288, 367, 671, 315, 3816, 14, 4912, 14, 1842, 8, 709, 304, 355, 734, 14, 952, 360, 1000, 3295, 68, 26, 11956, 60, 78, 7, 450, 671, 9, 267, 486, 14, 912, 63, 3280, 513, 8, 17983, 63, 3817, 12, 283, 505, 63, 493, 297, 2599, 63, 826, 29, 797, 12, 586, 2599, 63, 1461, 29, 797, 9, 267, 291, 14, 629, 8, 71, 14, 888, 459, 3280, 995, 488, 9, 398, 486, 14, 912, 63, 3280, 513, 8, 17983, 63, 3817, 12, 283, 505, 63, 493, 297, 2599, 63, 826, 29, 797, 12, 586, 2599, 63, 1461, 29, 549, 9, 267, 291, 14, 629, 8, 71, 14, 888, 459, 3280, 995, 488, 9, 398, 486, 14, 912, 63, 3280, 513, 8, 17983, 63, 3817, 12, 283, 505, 63, 493, 297, 2599, 63, 826, 29, 549, 12, 586, 2599, 63, 1461, 29, 797, 9, 267, 291, 14, 1815, 360, 1000, 15668, 315, 486, 14, 888, 459, 3280, 1105, 339, 347, 511, 63, 513, 63, 8221, 588, 616, 8, 277, 304, 267, 486, 275, 1900, 63, 22090, 342, 267, 2974, 275, 359, 20026, 17, 12, 3611, 8195, 18, 61, 267, 486, 14, 3280, 513, 14, 912, 63, 513, 8, 1744, 9, 267, 486, 14, 1939, 360, 1014, 921, 89, 290, 731, 14, 6558, 358, 267, 291, 14, 629, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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ent_heat_flux" make sense? (2/5/13) # Copyright (c) 2001-2014, Scott D. Peckham # # Sep 2014. Fixed sign error in update_bulk_richardson_number(). # Ability to compute separate P_snow and P_rain. # Aug 2014. New CSDMS Standard Names and clean up. # Nov 2013. Converted TopoFlow to a Python package. # # Jan 2013. Revised handling of input/output names. # Oct 2012. CSDMS Standard Names (version 0.7.9) and BMI. # May 2012. P is now a 1D array with one element and mutable, # so any comp with ref to it can see it change. # Jun 2010. update_net_shortwave_radiation(), etc. # May 2010. Changes to initialize() and read_cfg_file(). # Aug 2009 # Jan 2009. Converted from IDL. # #----------------------------------------------------------------------- # NOTES: This file defines a "base class" for meteorology # components as well as any functions used by most or # all meteorology methods. The methods of this class # should be over-ridden as necessary for different # methods of modeling meteorology. #----------------------------------------------------------------------- # Notes: Do we ever need to distinguish between a surface # temperature and snow temperature (in the snow) ? # Recall that a separate T_soil_x variable is used # to compute Qc. # # Cp_snow is from NCAR CSM Flux Coupler web page # # rho_H2O is currently not adjustable with GUI. (still true?) # #----------------------------------------------------------------------- # # class met_component (inherits from BMI_base.py) # # get_component_name() # get_attribute() # (10/26/11) # get_input_var_names() # (5/15/12) # get_output_var_names() # (5/15/12) # get_var_name() # (5/15/12) # get_var_units() # (5/15/12) # --------------------- # set_constants() # initialize() # update() # finalize() # ---------------------------- # set_computed_input_vars() # initialize_computed_vars() # ---------------------------- # update_P_integral() # update_P_max() # update_P_rain() # (9/14/14, new method) # update_P_snow() # (9/14/14, new method) # ------------------------------------ # update_bulk_richardson_number() # update_bulk_aero_conductance() # update_sensible_heat_flux() # update_saturation_vapor_pressure() # update_vapor_pressure() # update_dew_point() # (7/6/10) # update_precipitable_water_content() # (7/6/10) # ------------------------------------ # update_latent_heat_flux() # update_conduction_heat_flux() # update_advection_heat_flux() # ------------------------------------ # update_julian_day() # (7/1/10) # update_net_shortwave_radiation() # (7/1/10) # update_em_air() # (7/1/10) # update_net_longwave_radiation() # (7/1/10) # update_net_energy_flux() # ("Q_sum") # ------------------------------------ # open_input_files() # read_input_files() # close_input_files() # ------------------------------------ # update_outfile_names() # open_output_files() # write_output_files() # close_output_files() # save_grids() # save_pixel_values() # # Functions: # compare_em_air_methods() # #----------------------------------------------------------------------- import numpy as np import os from topoflow.components import solar_funcs as solar from topoflow.utils import BMI_base from topoflow.utils import model_input from topoflow.utils import model_output from topoflow.utils import rtg_files #----------------------------------------------------------------------- class met_component( BMI_base.BMI_component ): #------------------------------------------------------------------- _att_map = { 'model_name': 'TopoFlow_Meteorology', 'version': '3.1', 'author_name': 'Scott D. Peckham', 'grid_type': 'uniform', 'time_step_type': 'fixed', 'step_method': 'explicit', #------------------------------------------------------------- 'comp_name': 'Meteorology', 'model_family': 'TopoFlow', 'cfg_template_file': 'Meteorology.cfg.in', 'cfg_extension': '_meteorology.cfg', 'cmt_var_prefix': '/Meteorology/Input/Var/', 'gui_xml_file': '/home/csdms/cca/topoflow/3.1/src/share/cmt/gui/Meteorology.xml', 'dialog_title': 'Meteorology: Method 1 Parameters', 'time_units': 'seconds' } #--------------------------------------------------------- # Note that SWE = "snow water equivalent", but it really # just means "liquid_equivalent". #--------------------------------------------------------- _input_var_names = [ 'snowpack__z_mean_of_mass-per-volume_density', # rho_snow 'snowpack__depth', # h_snow 'snowpack__liquid-equivalent_depth', # h_swe 'snowpack__melt_volume_flux' ] # SM (MR used for ice?) #----------------------------------------------------------- # albedo, emissivity and transmittance are dimensionless. #----------------------------------------------------------- # "atmosphere_aerosol_dust__reduction_of_transmittance" vs. # This TF parameter comes from Dingman, App. E, p. 604. #----------------------------------------------------------- # There is an Optical_Air_Mass function in solar_funcs.py. # However, this quantity is not saved in comp state. # # "optical_path_length_ratio" vs. "optical_air_mass" OR # "airmass_factor" OR "relative_airmass" OR # "relative_optical_path_length" #----------------------------------------------------------- # Our term "liquid_equivalent_precipitation" is widely # used on the Internet, with 374,000 Google hits. #-------------------------------------------------------------- # Note: "bulk exchange coefficient" has 2460 Google hits. # It is closely related to a "transfer coefficient" # for mass, momentum or heat. There are no CF # Standard Names with "bulk", "exchange" or "transfer". # # Zhang et al. (2000) use "bulk exchange coefficient" in a # nonstandard way, with units of velocity vs. unitless. # # Dn = bulk exchange coeff for the conditions of # neutral atmospheric stability [m/s] # Dh = bulk exchange coeff for heat [m/s] # De = bulk exchange coeff for vapor [m/s] #--------------------------------------------------------------- # Now this component uses T_air to break the liquid-equivalent # precip rate into separate P_rain and P_snow components. # P_rain is used by channel_base.update_R() # P_snow is used by snow_base.update_depth() #--------------------------------------------------------------- _output_var_names = [ # 'atmosphere__optical_path_length_ratio', # M_opt [1] (in solar_funcs.py) # 'atmosphere__von_karman_constant', # kappa 'atmosphere_aerosol_dust__reduction_of_transmittance', # dust_atten ##### (from GUI) 'atmosphere_air-column_water-vapor__liquid-equivalent_depth', # W_p ("precipitable depth") 'atmosphere_bottom_air__brutsaert_emissivity_canopy_factor', # canopy_factor 'atmosphere_bottom_air__brutsaert_emissivity_cloud_factor', # cloud_factor 'atmosphere_bottom_air__bulk_latent_heat_aerodynamic_conductance', # De [m s-1], latent 'atmosphere_bottom_air__bulk_sensible_heat_aerodynamic_conductance', # Dh [m s-1], sensible 'atmosphere_bottom_air__emissivity', # em_air 'atmosphere_bottom_air__mass-per-volume_density', # rho_air 'atmosphere_bottom_air__mass-specific_isobaric_heat_capacity', # Cp_air 'atmosphere_bottom_air__neutral_bulk_aerodynamic_conductance', # Dn [m s-1], neutral 'atmosphere_bottom_air__pressure', # p0 'atmosphere_bottom_air__temperature', # T_air 'atmosphere_bottom_air_flow__bulk_richardson_number', # Ri [1] 'atmosphere_bottom_air_flow__log_law_roughness_length', # z0_air 'atmosphere_bottom_air_flow__reference-height_speed', # uz 'atmosphere_bottom_air_flow__speed_reference_height', # z 'atmosphere_bottom_air_land_net-latent-heat__energy_flux', # Qe [W m-2] 'atmosphere_bottom_air_land_net-sensible-heat__energy_flux', # Qh [W m-2] 'atmosphere_bottom_air_water-vapor__dew_point_temperature', # T_dew 'atmosphere_bottom_air_water-vapor__partial_pressure', # e_air # (insert "reference_height" ??) 'atmosphere_bottom_air_water-vapor__relative_saturation', # RH 'atmosphere_bottom_air_water-vapor__saturated_partial_pressure', # e_sat_air 'atmosphere_water__domain_time_integral_of_precipitation_leq-volume_flux', # vol_P 'atmosphere_water__domain_time_max_of_precipitation_leq-volume_flux', # P_max 'atmosphere_water__precipitation_leq-volume_flux', # P [m s-1] 'atmosphere_water__rainfall_volume_flux', # P_rain [m s-1] (liquid) 'atmosphere_water__snowfall_leq-volume_flux', # P_snow [m s-1] 'earth__standard_gravity_constant', # g [m s-2] 'land_surface__albedo', # albedo 'land_surface__aspect_angle', # alpha (from GUI) 'land_surface__emissivity', # em_surf 'land_surface__latitude', # lat_deg [degrees] 'land_surface__longitude', # lon_deg [degrees] 'land_surface__slope_angle', # beta (from GUI) 'land_surface__temperature', # T_surf ### OR JUST "land__temperature"? # 'land_surface_air__temperature', # T_air 'land_surface_air_water-vapor__partial_pressure', # e_surf # (insert "reference_height" ??) 'land_surface_air_water-vapor__saturated_partial_pressure', # e_sat_surf 'land_surface_net-longwave-radiation__energy_flux', # Qn_LW [W m-2] 'land_surface_net-shortwave-radiation__energy_flux', # Qn_SW [W m-2] 'land_surface_net-total-energy__energy_flux', # Q_sum [W w-2] 'model__time_step', # dt 'physics__stefan_boltzmann_constant', # sigma [W m-2 K-4] 'physics__von_karman_constant', # kappa [1] 'water__mass-specific_latent_fusion_heat', # Lf [J kg-1] 'water__mass-specific_latent_vaporization_heat', # Lv [J kg-1] 'water-liquid__mass-per-volume_density' ] # rho_H2O #----------------------------------------- # These are used only in solar_funcs.py # Later, create a Radiation component. #--------------------------------------------- # Should we allow "day" as a base quantity ? # "day_length" is confusing. Think about "date" also. # Maybe something like: # # "earth__mean_solar_rotation_period" # "earth__sidereal_rotation_period" # "earth__stellar_rotation_period" (relative to "fixed stars") # maybe: "earth__complete_rotation_period" ?? # # OR: # "earth_mean_solar_day__duration" # "earth_sidereal_day__duration" # "earth_stellar_day__duration" # # OR perhaps: # "earth_mean_solar_day__rotation_period" # "earth_sidereal_day__rotation_period" # "earth_stellar_day__rotation_period" # # "stellar rotation period" gives 84,500 Google hits. # "solar_rotation_period" gives 41,100 Google hits. # "sidereal_roation_period" gives 86,000 Google hits. # "stellar day" gives 136,000 Google hits (but many unrelated). # # NB! "stellar_rotation_period" is ambiguous since it is also # used for the rotation period of a star. # # "earth_mean_solar_day__hour_count" ("standard_day" ?) # "earth_sidereal_day__hour_count" # "earth_sidereal_day__duration" # "earth__rotation_period" = "sidereal_day" # # "earth_stellar_day__period" ?? # "earth_stellar_day__duration" ?? # #------------------------------------------------------------------ # For "earth__rotation_rate", it seems this should be based on # the sidereal day (23.93 hours) instead of the mean solar day. #------------------------------------------------------------------ # There are at least a few online sources that use both terms: # "equivalent latitude" and "equivalent longitude". See: # "The Construction and Application of a Martian Snowpack Model". #------------------------------------------------------------------ # Adopt the little-used term: "topographic_sunrise" ? # Or maybe "illuminated_topography", or "local_sunrise" ?? #------------------------------------------------------------------ # For angle relations between the earth and the sun, should we # just use the adjective "solar" in the quantity name or include # sun in the object name? We could also use terms like: # earth_to_sun__declination_angle # earth_to_sun__right_ascension_angle # #------------------------------------------------------------------ # The adjective "local" in "earth_local_apparent_noon__time" # may be helpful in other contexts such as: # 'earth__local_longitude' and 'land_surface__local_elevation'. #------------------------------------------------------------------ # 'earth__autumnal_equinox_date', # 'earth__autumnal_equinox_time', # 'earth_axis__ecliptic_tilt_angle', # tilt_angle # 'earth__julian_day_number', ######## # 'earth__julian_day_angle', # 'earth__local_apparent_noon_time' # 'earth__mean_radius', # 'earth__mean_solar_day_duration', # (exactly 24 hours) # 'earth_orbit__eccentricity', # 'earth_orbit__period', # (one year) # 'earth__perihelion_julian_day', ###### # 'earth__rotation_period', ###### # 'earth__rotation_rate', # Omega ###### What about Angular Velocity ? # 'earth__sidereal_day_duration', # (one rotation = 23.934470 hours) # 'earth__solar_declination_angle', # 'earth__solar_hour_angle', # 'earth__solar_irradiation_constant', ## (or "insolation_constant" ??) # 'earth__solar_right_ascension_angle', # 'earth__solar_vertical_angle', (complement of zenith angle) # 'earth__solar_zenith_angle', # 'earth__stellar_day_duration', # (relative to the "fixed stars") # 'earth__summer_solstice_date', # 'earth__summer_solstice_time', # 'earth__topographic_sunrise_equivalent_latitude', # 'earth__topographic_sunrise_equivalent_longitude', (flat_lon + offset) # 'earth__topographic_sunrise_equivalent_longitude_offset', # 'earth__topographic_sunrise_time', # 'earth__topographic_sunset_time', # 'earth_true_solar_noon___time', ##### # 'earth_clock__true_solar_noon_time' # 'earth__vernal_equinox_date', # 'earth__vernal_equinox_time', # 'earth__winter_solstice_date', # 'earth__winter_solstice_time', # # What about a "slope_corrected" or "topographic" version of K_dir ? # # 'land_surface__backscattered_shortwave_irradiation_flux', # K_bs # 'land_surface__diffuse_shortwave_irradiation_flux', # K_dif # 'land_surface__direct_shortwave_irradiation_flux', # K_dir # 'land_surface__global_shortwave_irradiation_flux', # K_glob = K_dif + K_dir #------------------------------------------------------------------ #------------------------------------------------------------------ # Maybe we should rename "z" to "z_ref" and "uz" to "uz_ref" ? #------------------------------------------------------------------ _var_name_map = { 'snowpack__z_mean_of_mass-per-volume_density': 'rho_snow', 'snowpack__depth': 'h_snow', 'snowpack__liquid-equivalent_depth': 'h_swe', 'snowpack__melt_volume_flux': 'SM', # (MR is used for ice) #----------------------------------------------------------------- #'atmosphere__optical_path_length_ratio': 'M_opt', # (in solar_funcs.py) # 'atmosphere__von_karman_constant': 'kappa', 'atmosphere_aerosol_dust__reduction_of_transmittance': 'dust_atten', 'atmosphere_air-column_water-vapor__liquid-equivalent_depth': 'W_p', ######### 'atmosphere_bottom_air__brutsaert_emissivity_canopy_factor': 'canopy_factor', 'atmosphere_bottom_air__brutsaert_emissivity_cloud_factor': 'cloud_factor', 'atmosphere_bottom_air__bulk_latent_heat_aerodynamic_conductance': 'De', 'atmosphere_bottom_air__bulk_sensible_heat_aerodynamic_conductance': 'Dh', 'atmosphere_bottom_air__emissivity': 'em_air', 'atmosphere_bottom_air__mass-per-volume_density': 'rho_air', 'atmosphere_bottom_air__mass-specific_isobaric_heat_capacity': 'Cp_air', 'atmosphere_bottom_air__neutral_bulk_heat_aerodynamic_conductance': 'Dn', 'atmosphere_bottom_air__pressure': 'p0', 'atmosphere_bottom_air__temperature': 'T_air', 'atmosphere_bottom_air_flow__bulk_richardson_number': 'Ri', 'atmosphere_bottom_air_flow__log_law_roughness_length': 'z0_air', ## (not "z0") 'atmosphere_bottom_air_flow__reference-height_speed': 'uz', 'atmosphere_bottom_air_flow__speed_reference_height': 'z', 'atmosphere_bottom_air_land_net-latent-heat__energy_flux': 'Qe', 'atmosphere_bottom_air_land_net-sensible-heat__energy_flux': 'Qh', 'atmosphere_bottom_air_water-vapor__dew_point_temperature': 'T_dew', 'atmosphere_bottom_air_water-vapor__partial_pressure': 'e_air', 'atmosphere_bottom_air_water-vapor__relative_saturation': 'RH', 'atmosphere_bottom_air_water-vapor__saturated_partial_pressure': 'e_sat_air', 'atmosphere_water__domain_time_integral_of_precipitation_leq-volume_flux': 'vol_P', 'atmosphere_water__domain_time_max_of_precipitation_leq-volume_flux': 'P_max', 'atmosphere_water__precipitation_leq-volume_flux': 'P', 'atmosphere_water__rainfall_volume_flux': 'P_rain', 'atmosphere_water__snowfall_leq-volume_flux': 'P_snow', 'earth__standard_gravity_constant': 'g', 'land_surface__albedo': 'albedo', 'land_surface__aspect_angle': 'alpha', 'land_surface__emissivity': 'em_surf', 'land_surface__latitude': 'lat_deg', 'land_surface__longitude': 'lon_deg', 'land_surface__slope_angle': 'beta', 'land_surface__temperature': 'T_surf', # 'land_surface_air__temperature': 'T_surf', 'land_surface_air_water-vapor__partial_pressure': 'e_surf', 'land_surface_air_water-vapor__saturated_partial_pressure': 'e_sat_surf', 'land_surface_net-longwave-radiation__energy_flux': 'Qn_LW', 'land_surface_net-shortwave-radiation__energy_flux': 'Qn_SW', 'land_surface_net-total-energy__energy_flux': 'Q_sum', 'model__time_step': 'dt', 'physics__stefan_boltzmann_constant': 'sigma', 'physics__von_karman_constant': 'kappa', 'water__mass-specific_latent_fusion_heat': 'Lf', 'water__mass-specific_latent_vaporization_heat': 'Lv', 'water-liquid__mass-per-volume_density': 'rho_H2O' } #----------------------------------------------------------------- # Note: The "update()" function calls several functions with the # MBAR keyword set to get units of "mbar" vs. "kPa". #----------------------------------------------------------------- # Note: We need to be careful with whether units are C or K, # for all "thermal" quantities (e.g. thermal_capacity). #----------------------------------------------------------------- # Note: ARHYTHM had 3 "bulk exchange coefficients" that are all # equal and therefore have the same units of [m s-1]. # Double-check that this is what is intended. ########## #----------------------------------------------------------------- # Note: "atmosphere_column_water__liquid_equivalent_depth" has # units of "cm", as in Dingman's book. Make sure it gets # used correctly in equations. #----------------------------------------------------------------- # Note: slope_angle and aspect_angle have units of RADIANS. # aspect_angle is measured CW from north. # RT files ending in "_mf-angle.rtg" and "fd-aspect.rtg" # contain aspect values. The former are in [0, 2 Pi] # while the latter are in [-Pi, Pi] and both measure # CCW from due east. They are converted for use here. #----------------------------------------------------------------- _var_units_map = { 'snowpack__z_mean_of_mass-per-volume_density': 'kg m-3', 'snowpack__depth': 'm', 'snowpack__liquid-equivalent_depth': 'm', 'snowpack__melt_volume_flux': 'm s-1', #------------------------------------------------------------- # 'atmosphere__optical_path_length_ratio': '1', # 'atmosphere__von_karman_constant': '1', 'atmosphere_aerosol_dust__reduction_of_transmittance': '1', 'atmosphere_air-column_water-vapor__liquid-equivalent_depth': 'cm', # (see Notes above) 'atmosphere_bottom_air__brutsaert_emissivity_canopy_factor': '1', 'atmosphere_bottom_air__brutsaert_emissivity_cloud_factor': '1', 'atmosphere_bottom_air__bulk_latent_heat_aerodynamic_conductance': 'm s-1', # (see Notes above) 'atmosphere_bottom_air__bulk_sensible_heat_aerodynamic_conductance': 'm s-1', # (see Notes above) 'atmosphere_bottom_air__emissivity': '1', 'atmosphere_bottom_air__mass-per-volume_density': 'kg m-3', 'atmosphere_bottom_air__mass-specific_isobaric_heat_capacity': 'J kg-1 K-1', # (see Notes above) 'atmosphere_bottom_air__neutral_bulk_heat_aerodynamic_conductance': 'm s-1', # (see Notes above) 'atmosphere_bottom_air__pressure': 'mbar', 'atmosphere_bottom_air__temperature': 'deg_C', # (see Notes above) 'atmosphere_bottom_air_flow__bulk_richardson_number': '1', 'atmosphere_bottom_air_flow__log_law_roughness_length': 'm', 'atmosphere_bottom_air_flow__reference-height_speed': 'm s-1', 'atmosphere_bottom_air_flow__speed_reference_height': 'm', 'atmosphere_bottom_air_land_net-latent-heat__energy_flux': 'W m-2', 'atmosphere_bottom_air_land_net-sensible-heat__energy_flux': 'W m-2', 'atmosphere_bottom_air_water-vapor__dew_point_temperature': 'deg_C', 'atmosphere_bottom_air_water-vapor__partial_pressure': 'mbar', # (see Notes above) 'atmosphere_bottom_air_water-vapor__relative_saturation': '1', 'atmosphere_bottom_air_water-vapor__saturated_partial_pressure': 'mbar', # (see Notes above) 'atmosphere_water__domain_time_integral_of_precipitation_leq-volume_flux': 'm3', 'atmosphere_water__domain_time_max_of_precipitation_leq-volume_flux': 'm s-1', 'atmosphere_water__precipitation_leq-volume_flux': 'm s-1', 'atmosphere_water__rainfall_volume_flux': 'm s-1', # (see Notes above) 'atmosphere_water__snowfall_leq-volume_flux': 'm s-1', # (see Notes above) 'earth__standard_gravity_constant': 'm s-2', 'land_surface__albedo': '1', 'land_surface__aspect_angle': 'radians', # (see Notes above) 'land_surface__emissivity': '1', 'land_surface__latitude': 'degrees', 'land_surface__longitude': 'degrees', 'land_surface__slope_angle': 'radians', 'land_surface__temperature': 'deg_C', # 'land_surface_air__temperature': 'deg_C', 'land_surface_air_water-vapor__partial_pressure': 'mbar', 'land_surface_air_water-vapor__saturated_partial_pressure': 'mbar', 'land_surface_net-longwave-radiation__energy_flux': 'W m-2', 'land_surface_net-shortwave-radiation__energy_flux': 'W m-2', 'land_surface_net-total-energy__energy_flux': 'W m-2', 'model__time_step': 's', 'physics__stefan_boltzmann_constant': 'W m-2 K-4', 'physics__von_karman_constant': '1', 'water__mass-specific_latent_fusion_heat': 'J kg-1', 'water__mass-specific_latent_vaporization_heat': 'J kg-1', 'water-liquid__mass-per-volume_density': 'kg m-3' } #------------------------------------------------ # Return NumPy string arrays vs. Python lists ? #------------------------------------------------ ## _input_var_names = np.array( _input_var_names ) ## _output_var_names = np.array( _output_var_names ) #------------------------------------------------------------------- def get_component_name(self): return 'TopoFlow_Meteorology' # get_component_name() #------------------------------------------------------------------- def get_attribute(self, att_name): try: return self._att_map[ att_name.lower() ] except: print '###################################################' print ' ERROR: Could not find attribute: ' + att_name print '###################################################' print ' ' # get_attribute() #------------------------------------------------------------------- def get_input_var_names(self): #-------------------------------------------------------- # Note: These are currently variables needed from other # components vs. those read from files or GUI. #-------------------------------------------------------- return self._input_var_names # get_input_var_names() #------------------------------------------------------------------- def get_output_var_names(self): return self._output_var_names # get_output_var_names() #------------------------------------------------------------------- def get_var_name(self, long_var_name): return self._var_name_map[ long_var_name ] # get_var_name() #------------------------------------------------------------------- def get_var_units(self, long_var_name): return self._var_units_map[ long_var_name ] # get_var_units() #------------------------------------------------------------------- ## def get_var_type(self, long_var_name): ## ## #--------------------------------------- ## # So far, all vars have type "double", ## # but use the one in BMI_base instead. ## #--------------------------------------- ## return 'float64' ## ## # get_var_type() #------------------------------------------------------------------- def set_constants(self): #--------------------------------- # Define some physical constants #--------------------------------- self.g = np.float64(9.81) # [m s-2, gravity] self.kappa = np.float64(0.408) # [1] (von Karman) self.rho_H2O = np.float64(1000) # [kg m-3] self.rho_air = np.float64(1.2614) # [kg m-3] self.Cp_air = np.float64(1005.7) # [J kg-1 K-1] self.Lv = np.float64(2500000) # [J kg-1] Latent heat of vaporiz. self.Lf = np.float64(334000) # [J kg-1 = W s kg-1], Latent heat of fusion self.sigma = np.float64(5.67E-8) # [W m-2 K-4] (Stefan-Boltzman constant) self.C_to_K = np.float64(273.15) # (add to convert deg C to K) self.twopi = np.float64(2) * np.pi self.one_seventh = np.float64(1) / 7 self.hours_per_day = np.float64(24) self.secs_per_day = np.float64(3600) * self.hours_per_day #--------------------------- # See update_latent_heat() #----------------------------------------------------------- # According to Dingman (2002, p. 273), constant should # be 0.622 instead of 0.662 (Zhang et al., 2000, p. 1002). # Is this constant actually the dimensionless ratio of # the molecular weight of water to that of dry air ? #----------------------------------------------------------- ## self.latent_heat_constant = np.float64(0.622) self.latent_heat_constant = np.float64(0.662) #---------------------------------------- # Constants related to precip (9/24/09) #---------------------------------------- self.mmph_to_mps = (np.float64(1) / np.float64(3600000)) self.mps_to_mmph = np.float64(3600000) self.forever = np.float64(999999999) # [minutes] #------------------------------------------------ # Only needed for method 1, where all rates and # durations are read as 1D arrays from GUI. # Method 1 may be removed in a future version. #------------------------------------------------ ## self.method1_rates = None ## self.method1_durations = None ## self.method1_n_rates = 0 # set_constants() #------------------------------------------------------------------- def initialize(self, cfg_file=None, mode="nondriver", SILENT=False): if not(SILENT): print ' ' print 'Meteorology component: Initializing...' self.status = 'initializing' # (OpenMI 2.0 convention) self.mode = mode self.cfg_file = cfg_file #----------------------------------------------- # Load component parameters from a config file #----------------------------------------------- self.set_constants() self.initialize_config_vars() ## print ' Calling read_grid_info()...' self.read_grid_info() ## print ' Calling initialize_basin_vars()...' self.initialize_basin_vars() # (5/14/10) #---------------------------------------------------- # NB! This read_input_files() uses self.time_index. # Also needs to be before "Disabled" test. #---------------------------------------------------- ## print ' Calling initialize_time_vars()...' self.initialize_time_vars() #------------------------------------------------- # (5/19/12) This makes P "mutable", which allows # its updated values to be seen by any component # that has a reference to it. # Note that P will typically be read from a file. #------------------------------------------------- self.P = self.initialize_var( self.P_type ) self.P_rain = self.initialize_var( self.P_type ) self.P_snow = self.initialize_var( self.P_type ) #------------------------------------------------------------ # If "Enabled", will call initialize_computed_vars() below. #------------------------------------------------------------ if (self.comp_status == 'Disabled'): if not(SILENT): print 'Meteorology component: Disabled in CFG file.' self.e_air = self.initialize_scalar(0, dtype='float64') self.e_surf = self.initialize_scalar(0, dtype='float64') self.em_air = self.initialize_scalar(0, dtype='float64') self.Qn_SW = self.initialize_scalar(0, dtype='float64') self.Qn_LW = self.initialize_scalar(0, dtype='float64') self.Q_sum = self.initialize_scalar(0, dtype='float64') self.Qc = self.initialize_scalar(0, dtype='float64') self.Qa = self.initialize_scalar(0, dtype='float64') self.DONE = True self.status = 'initialized' return #----------------------------------------------- # Read from files as needed to initialize vars #----------------------------------------------- self.open_input_files() self.read_input_files() # (initializes P) ## self.check_input_types() # (not needed so far) #----------------------- # Initialize variables #----------------------- ## print ' Calling initialize_computed_vars()...' self.initialize_computed_vars() # (after read_input_files) if not(self.PRECIP_ONLY): self.open_output_files() self.status = 'initialized' # (OpenMI 2.0 convention) # initialize() #------------------------------------------------------------------- ## def update(self, dt=-1.0, time_seconds=None): def update(self, dt=-1.0): #---------------------------------------------------------- # Note: The read_input_files() method is first called by # the initialize() method. Then, the update() # method is called one or more times, and it calls # other update_*() methods to compute additional # variables using input data that was last read. # Based on this pattern, read_input_files() should # be called at end of update() method as done here. # If the input files don't contain any additional # data, the last data read persists by default. #---------------------------------------------------------- if (self.comp_status == 'Disabled'): return self.status = 'updating' # (OpenMI 2.0 convention) #------------------------------------------- # Update computed values related to precip #------------------------------------------- self.update_P_integral() self.update_P_max() self.update_P_rain() self.update_P_snow() #------------------------- # Update computed values #------------------------- if not(self.PRECIP_ONLY): self.update_bulk_richardson_number() self.update_bulk_aero_conductance() self.update_sensible_heat_flux() self.update_saturation_vapor_pressure(MBAR=True) self.update_saturation_vapor_pressure(MBAR=True, SURFACE=True) ######## self.update_vapor_pressure(MBAR=True) self.update_dew_point() ### self.update_precipitable_water_content() ### self.update_vapor_pressure(MBAR=True, SURFACE=True) ######## self.update_latent_heat_flux() # (uses e_air and e_surf) self.update_conduction_heat_flux() self.update_advection_heat_flux() self.update_julian_day() self.update_net_shortwave_radiation() self.update_em_air() self.update_net_longwave_radiation() self.update_net_energy_flux() # (at the end) #---------------------------------------- # Read next met vars from input files ? #------------------------------------------- # Note that read_input_files() is called # by initialize() and these values must be # used for "update" calls before reading # new ones. #------------------------------------------- if (self.time_index > 0): self.read_input_files() #---------------------------------------------- # Write user-specified data to output files ? #---------------------------------------------- # Components use own self.time_sec by default. #----------------------------------------------- if not(self.PRECIP_ONLY): self.write_output_files() ## self.write_output_files( time_seconds ) #----------------------------- # Update internal clock # after write_output_files() #----------------------------- self.update_time( dt ) self.status = 'updated' # (OpenMI) # update() #------------------------------------------------------------------- def finalize(self): self.status = 'finalizing' # (OpenMI) if (self.comp_status == 'Enabled'): self.close_input_files() ## TopoFlow input "data streams" if not(self.PRECIP_ONLY): self.close_output_files() self.status = 'finalized' # (OpenMI) self.print_final_report(comp_name='Meteorology component') # finalize() #------------------------------------------------------------------- def set_computed_input_vars(self): #----------------------------------------------- # Convert precip rate units from mm/h to m/s ? #----------------------------------------------- # NB! read_input_files() does this for files. #----------------------------------------------- if (self.P_type == 'Scalar'): ## print '######## self.P_type =', self.P_type ## print '######## type(self.P) =', type(self.P) ## print '######## self.P =', self.P ## print '######## Converting scalar P from MMPH to MPS.' #----------------------------------------------------- # (2/7/13) Must use "*=" here to preserve reference. #----------------------------------------------------- self.P *= self.mmph_to_mps ## self.P = self.P * self.mmph_to_mps print 'Scalar rainrate set to:', self.P, ' [mmph]' #--------------------------------- # Process the PRECIP_ONLY toggle #--------------------------------- if not(hasattr(self, 'PRECIP_ONLY')): self.PRECIP_ONLY = False elif (self.PRECIP_ONLY.lower() == 'yes'): self.PRECIP_ONLY = True else: self.PRECIP_ONLY = False #--------------------------------------- # Print info message about PRECIP_ONLY #--------------------------------------- if (self.PRECIP_ONLY): print '-----------------------------------------' print ' NOTE: Since PRECIP_ONLY = True, output' print ' variables will not be computed' print ' or saved to files.' print '-----------------------------------------' print' ' #---------------------------------------------------- # Toggle to use SATTERLUND or BRUTSAERT methods # for computing e_air and em_air. (Not in GUI yet.) #---------------------------------------------------- if not(hasattr(self, 'SATTERLUND')): self.SATTERLUND = False #--------------------------------------------- # Convert GMT_offset from string to int # because GUI can't use ints in droplist yet #--------------------------------------------- self.GMT_offset = np.int16( self.GMT_offset ) #------------------------------------------------ # Convert start_month from string to integer # January should be 1. See solar.Julian_Day(). #------------------------------------------------ month_list = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] self.start_month = month_list.index( self.start_month ) + 1 #------------------------------- # Initialize some more toggles #------------------------------- if not(hasattr(self, 'SAVE_QSW_GRIDS')): self.SAVE_QSW_GRIDS = False if not(hasattr(self, 'SAVE_QLW_GRIDS')): self.SAVE_QLW_GRIDS = False #------------------------------------------- if not(hasattr(self, 'SAVE_QSW_PIXELS')): self.SAVE_QSW_PIXELS = False if not(hasattr(self, 'SAVE_QLW_PIXELS')): self.SAVE_QLW_PIXELS = False #--------------------------------------------------------- # Make sure that all "save_dts" are larger or equal to # the specified process dt. There is no point in saving # results more often than they change. # Issue a message to this effect if any are smaller ?? #--------------------------------------------------------- self.save_grid_dt = np.maximum(self.save_grid_dt, self.dt) self.save_pixels_dt = np.maximum(self.save_pixels_dt, self.dt) # set_computed_input_vars() #------------------------------------------------------------------- def initialize_computed_vars(self): #------------------------------------------------------ # Note: Some of these require "self.rti", which is # only stored by read_grid_info() after the # set_computed_input_vars() function is called. # So these parts can't go there. #------------------------------------------------------ #--------------------------------------- # Add self.in_directory to: # slope_grid_file & aspect_grid_file #--------------------------------------- self.slope_grid_file = (self.in_directory + self.slope_grid_file) self.aspect_grid_file = (self.in_directory + self.aspect_grid_file) #------------------------------------------------- # Read slope grid & convert to slope angle, beta # NB! RT slope grids have NaNs on edges. #------------------------------------------------- slopes = rtg_files.read_grid( self.slope_grid_file, self.rti, RTG_type='FLOAT' ) beta = np.arctan( slopes ) beta = (self.twopi + beta) % self.twopi #--------------------------------------------- w_nan = np.where( np.logical_not(np.isfinite(beta)) ) n_nan = np.size(w_nan[0]) if (n_nan != 0): beta[ w_nan ] = np.float64(0) #------------------------------------------------------------------ w_bad = np.where( np.logical_or( (beta < 0), (beta > np.pi / 2) ) ) n_bad = np.size(w_bad[0]) if (n_bad != 0): msg = array(['ERROR: Some slope angles are out of range.', ' ']) for line in msg: print line ## result = GUI_Message(msg, INFO=True, TITLE='ERROR MESSAGE') return self.beta = beta ###### #------------------------------------------------------ # Read aspect grid. Alpha must be CW from north. # NB! RT aspect grids have NaNs on edges. #--------------------------------------------------------- # RT files ending in "_mf-angle.rtg" and "fd-aspect.rtg" # contain aspect values. The former are in [0, 2 Pi] # while the latter are in [-Pi, Pi] and both measure # CCW from due east. #--------------------------------------------------------- aspects = rtg_files.read_grid( self.aspect_grid_file, self.rti, RTG_type='FLOAT' ) alpha = (np.pi / 2) - aspects alpha = (self.twopi + alpha) % self.twopi #----------------------------------------------- w_nan = np.where( np.logical_not( np.isfinite(alpha) ) ) n_nan = np.size( w_nan[0] ) if (n_nan != 0): alpha[ w_nan ] = np.float64(0) self.alpha = alpha ###### #--------------------------- # Create lon and lat grids #--------------------------- if (self.rti.pixel_geom == 0): self.lon_deg = solar.Longitude_Grid( self.rti ) self.lat_deg = solar.Latitude_Grid( self.rti ) ## print 'Lon grid =' ## print self.lon_deg ## print 'Lat grid =' ## print self.lat_deg #----------------------------- # Write grids to RTG files ? #----------------------------- ## lon_file = (self.out_directory + self.site_prefix + '_lons.bin') ## rtg_files.write_grid( self.lon_deg, lon_file, self.rti ) ## lat_file = (self.out_directory + self.site_prefix + '_lats.bin') ## rtg_files.write_grid( self.lat_deg, lat_file, self.rti ) else: print 'SORRY: Cannot yet create lon and lat grids for' print ' this DEM because it uses UTM coordinates.' print ' Will use lat/lon for Denver, Colorado.' print ' ' #-------------------------------------------- # For now, use scalar values for Denver, CO #-------------------------------------------- self.lon_deg = np.float64( -104.9841667 ) self.lat_deg = np.float64( 39.7391667 ) ## return #------------------------------------------------- # Initialize max precip rate with the first rate #------------------------------------------------ # Note: Need this here because rate may be # zero at the end of update_precip_rate() #------------------------------------------------ # vol_P is used for mass balance check. #------------------------------------------------ P_max = self.P.max() # (after read_input_files) ## self.P_max = self.P.max() self.P_max = self.initialize_scalar( P_max, dtype='float64') self.vol_P = self.initialize_scalar( 0, dtype='float64') #---------------------------------------------------------- # For using new framework which embeds references from # meteorology to snow, etc., these need to be defined # in the initialize step. However, they will most likely # change from scalar to grid during update, so we need to # check that the reference isn't broken when the dtype # changes. (5/17/12) #---------------------------------------------------------- # These depend on grids alpha and beta, so will be grids. #---------------------------------------------------------- self.Qn_SW = np.zeros([self.ny, self.nx], dtype='float64') self.Qn_LW = np.zeros([self.ny, self.nx], dtype='float64') self.Qn_tot = np.zeros([self.ny, self.nx], dtype='float64') self.Q_sum = np.zeros([self.ny, self.nx], dtype='float64') #---------------------------------------------------------- # self.Qn_SW = self.initialize_scalar( 0, dtype='float64') # self.Qn_LW = self.initialize_scalar( 0, dtype='float64') # self.Qn_tot = self.initialize_scalar( 0, dtype='float64') # self.Q_sum = self.initialize_scalar( 0, dtype='float64') #---------------------------------------------------------- # These may be scalars or grids. #--------------------------------- self.Qe = self.initialize_scalar( 0, dtype='float64') self.e_air = self.initialize_scalar( 0, dtype='float64') self.e_surf = self.initialize_scalar( 0, dtype='float64') self.em_air = self.initialize_scalar( 0, dtype='float64') self.Qc = self.initialize_scalar( 0, dtype='float64') self.Qa = self.initialize_scalar( 0, dtype='float64') #------------------------------------ # Initialize the decimal Julian day #------------------------------------ self.julian_day = solar.Julian_Day( self.start_month, self.start_day, self.start_hour ) ## print ' julian_day =', self.julian_day # initialize_computed_vars() #------------------------------------------------------------------- def update_P_integral(self): #--------------------------------------------------- # Notes: This can be used for mass balance checks, # such as now done by update_mass_totals() # in topoflow.py. The "dt" here should be # TopoFlow's "main dt" vs. the process dt. # dV[i] = P[i] * da[i] * dt, dV = sum(dV[i]) #--------------------------------------------------- if (self.DEBUG): print 'Calling update_P_integral()...' #------------------------------------------------ # Update mass total for P, sum over all pixels #------------------------------------------------ volume = np.double(self.P * self.da * self.dt) # [m^3] if (np.size(volume) == 1): self.vol_P += (volume * self.rti.n_pixels) else: self.vol_P += np.sum(volume) # update_P_integral() #------------------------------------------------------------------- def update_P_max(self): if (self.DEBUG): print 'Calling update_P_max()...' #----------------------------------------- # Save the maximum precip. rate in [m/s] #------------------------------------------- # Must use "fill()" to preserve reference. #------------------------------------------- self.P_max.fill( np.maximum(self.P_max, self.P.max()) ) ## self.P_max = np.maximum(self.P_max, self.P.max()) #--------------- # For testing #-------------- ## print '##### P =', self.P * 1000 * 3600 # (mmph) ## print '##### P_max =', self.P_max * 1000 * 3600 # (mmph) # update_P_max() #------------------------------------------------------------------- def update_P_rain(self): #----------------------------------------------------------- # Note: This routine is written so that it doesn't matter # whether P and T_air are grids or scalars. # For scalars: 1.5 * True = 1.5, 1.5 * False = 0. # Here are the possible combinations for checking. #----------------------------------------------------------- # P T_air P_rain #---------------------------- # scalar scalar scalar # scalar grid grid # grid scalar grid # grid grid grid #---------------------------- if (self.DEBUG): print 'Calling update_P_rain()...' #------------------------------------------------- # P_rain is the precip that falls as liquid that # can contribute to runoff production. #------------------------------------------------- # P_rain is used by channel_base.update_R. #------------------------------------------------- P_rain = self.P * (self.T_air > 0) self.update_var( 'P_rain', P_rain ) ## (2/14/17) # if (np.ndim( self.P_rain ) == 0): # self.P_rain.fill( P_rain ) #### (mutable scalar) # else: # self.P_rain[:] = P_rain if (self.DEBUG): if (self.P_rain.max() > 0): print ' >> Rain is falling...' #-------------- # For testing #-------------- ## print 'shape(P) =', shape(self.P) ## print 'shape(T_air) =', shape(self.T_air) ## print 'shape(P_rain) =', shape(self.P_rain) ## print 'T_air =', self.T_air ######################################### #### Old note, to remember for later. #-------------------------------------------------- # (2/7/13) We must use "*=" to preserve reference # if P is a "mutable scalar". #-------------------------------------------------- # update_P_rain() #------------------------------------------------------------------- def update_P_snow(self): #---------------------------------------------------- # Notes: Rain and snow may fall simultaneously at # different grid cells in the model domain. #---------------------------------------------------- if (self.DEBUG): print 'Calling update_P_snow()...' #------------------------------------------------- # P_snow is the precip that falls as snow or ice # that contributes to the snow depth. This snow # may melt to contribute to runoff later on. #------------------------------------------------- # P_snow is used by snow_base.update_depth. #------------------------------------------------- P_snow = self.P * (self.T_air <= 0) self.update_var( 'P_snow', P_snow ) ## (2/14/17) # if (np.ndim( self.P_snow ) == 0): # self.P_snow.fill( P_snow ) #### (mutable scalar) # else: # self.P_snow[:] = P_snow if (self.DEBUG): if (self.P_snow.max() > 0): print ' >> Snow is falling...' # update_P_snow() #------------------------------------------------------------------- def update_bulk_richardson_number(self): if (self.DEBUG): print 'Calling update_bulk_richardson_number()...' #--------------------------------------------------------------- # (9/6/14) Found a typo in the Zhang et al. (2000) paper, # in the definition of Ri. Also see Price and Dunne (1976). # We should have (Ri > 0) and (T_surf > T_air) when STABLE. # This also removes problems/singularities in the corrections # for the stable and unstable cases in the next function. #--------------------------------------------------------------- # Notes: Other definitions are possible, such as the one given # by Dingman (2002, p. 599). However, this one is the # one given by Zhang et al. (2000) and is meant for use # with the stability criterion also given there. #--------------------------------------------------------------- #### top = self.g * self.z * (self.T_air - self.T_surf) # BUG. top = self.g * self.z * (self.T_surf - self.T_air) bot = (self.uz)**2.0 * (self.T_air + np.float64(273.15)) self.Ri = (top / bot) # update_bulk_richardson_number() #------------------------------------------------------------------- def update_bulk_aero_conductance(self): if (self.DEBUG): print 'Calling update_bulk_aero_conductance()...' #---------------------------------------------------------------- # Notes: Dn = bulk exchange coeff for the conditions of # neutral atmospheric stability [m/s] # Dh = bulk exchange coeff for heat [m/s] # De = bulk exchange coeff for vapor [m/s] # h_snow = snow depth [m] # z0_air = surface roughness length scale [m] # (includes vegetation not covered by snow) # z = height that has wind speed uz [m] # uz = wind speed at height z [m/s] # kappa = 0.408 = von Karman's constant [unitless] # RI = Richardson's number (see function) #---------------------------------------------------------------- h_snow = self.h_snow # (ref from new framework) #--------------------------------------------------- # Compute bulk exchange coeffs (neutral stability) # using the logarithm "law of the wall". #----------------------------------------------------- # Note that "arg" = the drag coefficient (unitless). #----------------------------------------------------- arg = self.kappa / np.log((self.z - h_snow) / self.z0_air) Dn = self.uz * (arg)**2.0 #----------------------------------------------- # NB! Dn could be a scalar or a grid, so this # must be written to handle both cases. # Note that WHERE can be used on a scalar: # IDL> a = 1 # IDL> print, size(a) # IDL> w = where(a ge 1, nw) # IDL> print, nw # IDL> a[w] = 2 # IDL> print, a # IDL> print, size(a) #----------------------------------------------- ########################################################### # NB! If T_air and T_surf are both scalars, then next # few lines won't work because we can't index the # resulting empty "w" (even if T_air == T_surf). ########################################################### ## w = np.where(self.T_air != self.T_surf) ## nw = np.size(w[0]) ## ## nw = np.size(w,0) # (doesn't work if 2 equal scalars) #---------------------------------------------------------- T_AIR_SCALAR = (np.ndim( self.T_air ) == 0) T_SURF_SCALAR = (np.ndim( self.T_surf ) == 0) if (T_AIR_SCALAR and T_SURF_SCALAR): if (self.T_air == self.T_surf): nw=1 else: nw=0 else: w = np.where(self.T_air != self.T_surf) nw = np.size(w[0]) if (nw == 0): #-------------------------------------------- # All pixels are neutral. Set Dh = De = Dn. #-------------------------------------------- self.Dn = Dn self.Dh = Dn self.De = Dn return #------------------------------------- # One or more pixels are not neutral # so make a correction using RI #--------------------------------------------- # NB! RI could be a grid when Dn is a # scalar, and this will change Dn to a grid. #--------------------------------------------- # Ri = Richardson_Number(z, uz, T_air, T_surf) #-------------------------------------------- # Before 12/21/07. Has bug if RI is a grid #-------------------------------------------- # w_stable = where(*T_air gt *T_surf, n_stable) # if (n_stable ne 0) then begin # Dn[w_stable] = Dn[w_stable]/(1d + (10d * RI)) # endif # w_unstable = where(*T_air lt *T_surf, n_unstable) # if (n_unstable ne 0) then begin #---------------------------------------------- # Multiplication and substraction vs. opposites # for the stable case. Zhang et al. (2000) # Hopefully not just a typo. #---------------------------------------------- # Dn[w_unstable] = Dn[w_unstable]*(1d - (10d * self.Ri)) # endif #----------------- # After 12/21/07 #------------------------------------------------------------ # If T_air, T_surf or uz is a grid, then Ri will be a grid. # This version makes only one call to WHERE, so its faster. #------------------------------------------------------------ # Multiplication and substraction vs. opposites for the # stable case (Zhang et al., 2000); hopefully not a typo. # It plots as a smooth curve through Ri=0. #------------------------------------------------------------ # (9/7/14) Modified so that Dn is saved, but Dh = De. #------------------------------------------------------------ Dh = Dn.copy() ### (9/7/14. Save Dn also.) nD = np.size( Dh ) nR = np.size( self.Ri ) if (nR > 1): #-------------------------- # Case where RI is a grid #-------------------------- ws = np.where( self.Ri > 0 ) ns = np.size( ws[0] ) wu = np.where( np.invert(self.Ri > 0) ) nu = np.size( wu[0] ) if (nD == 1): #****************************************** # Convert Dn to a grid here or somewhere # Should stop with an error message #****************************************** dum = np.int16(0) if (ns != 0): #---------------------------------------------------------- # If (Ri > 0), or (T_surf > T_air), then STABLE. (9/6/14) #---------------------------------------------------------- Dh[ws] = Dh[ws] / (np.float64(1) + (np.float64(10) * self.Ri[ws])) if (nu != 0): Dh[wu] = Dh[wu] * (np.float64(1) - (np.float64(10) * self.Ri[wu])) else: #---------------------------- # Case where Ri is a scalar #-------------------------------- # Works if Dh is grid or scalar #-------------------------------- if (self.Ri > 0): Dh = Dh / (np.float64(1) + (np.float64(10) * self.Ri)) else: Dh = Dh * (np.float64(1) - (np.float64(10) * self.Ri)) #---------------------------------------------------- # NB! We currently assume that these are all equal. #---------------------------------------------------- self.Dn = Dn self.Dh = Dh self.De = Dh ## (assumed equal) # update_bulk_aero_conductance() #------------------------------------------------------------------- def update_sensible_heat_flux(self): #-------------------------------------------------------- # Notes: All the Q's have units of W/m^2 = J/(m^2 s). # Dh is returned by Bulk_Exchange_Coeff function # and is not a pointer. #-------------------------------------------------------- if (self.DEBUG): print 'Callilng update_sensible_heat_flux()...' #--------------------- # Physical constants #--------------------- # rho_air = 1.225d ;[kg m-3, at sea-level] # Cp_air = 1005.7 ;[J kg-1 K-1] #----------------------------- # Compute sensible heat flux #----------------------------- delta_T = (self.T_air - self.T_surf) self.Qh = (self.rho_air * self.Cp_air) * self.Dh * delta_T # update_sensible_heat_flux() #------------------------------------------------------------------- def update_saturation_vapor_pressure(self, MBAR=False, SURFACE=False): if (self.DEBUG): print 'Calling update_saturation_vapor_pressure()...' #---------------------------------------------------------------- #Notes: Saturation vapor pressure is a function of temperature. # T is temperature in Celsius. By default, the method # of Brutsaert (1975) is used. However, the SATTERLUND # keyword is set then the method of Satterlund (1979) is # used. When plotted, they look almost identical. See # the Compare_em_air_Method routine in Qnet_file.pro. # Dingman (2002) uses the Brutsaert method. # Liston (1995, EnBal) uses the Satterlund method. # By default, the result is returned with units of kPa. # Set the MBAR keyword for units of millibars. # 100 kPa = 1 bar = 1000 mbars # => 1 kPa = 10 mbars #---------------------------------------------------------------- #NB! Here, 237.3 is correct, and not a misprint of 273.2. # See footnote on p. 586 in Dingman (Appendix D). #---------------------------------------------------------------- if (SURFACE): ## if (self.T_surf_type in ['Scalar', 'Grid']): ## return T = self.T_surf else: ## if (self.T_air_type in ['Scalar', 'Grid']): ## return T = self.T_air if not(self.SATTERLUND): #------------------------------ # Use Brutsaert (1975) method #------------------------------ term1 = (np.float64(17.3) * T) / (T + np.float64(237.3)) e_sat = np.float64(0.611) * np.exp(term1) # [kPa] else: #------------------------------- # Use Satterlund (1979) method ############ DOUBLE CHECK THIS (7/26/13) #------------------------------- term1 = np.float64(2353) / (T + np.float64(273.15)) e_sat = np.float64(10) ** (np.float64(11.4) - term1) # [Pa] e_sat = (e_sat / np.float64(1000)) # [kPa] #----------------------------------- # Convert units from kPa to mbars? #----------------------------------- if (MBAR): e_sat = (e_sat * np.float64(10)) # [mbar] if (SURFACE): self.e_sat_surf = e_sat else: self.e_sat_air = e_sat # update_saturation_vapor_pressure() #------------------------------------------------------------------- def update_vapor_pressure(self, MBAR=False, SURFACE=False): if (self.DEBUG): print 'Calling update_vapor_pressure()...' #--------------------------------------------------- # Notes: T is temperature in Celsius # RH = relative humidity, in [0,1] # by definition, it equals (e / e_sat) # e has units of kPa. #--------------------------------------------------- if (SURFACE): ## if (self.T_surf_type in ['Scalar', 'Grid']) and \ ## (self.RH_type in ['Scalar', 'Grid']): ## return e_sat = self.e_sat_surf else: ## if (self.T_air_type in ['Scalar', 'Grid']) and \ ## (self.RH_type in ['Scalar', 'Grid']): ## return e_sat = self.e_sat_air e = (self.RH * e_sat) #----------------------------------- # Convert units from kPa to mbars? #----------------------------------- if (MBAR): e = (e * np.float64(10)) # [mbar] if (SURFACE): self.e_surf = e else: self.e_air = e # update_vapor_pressure() #------------------------------------------------------------------- def update_dew_point(self): if (self.DEBUG): print 'Calling update_dew_point()...' #----------------------------------------------------------- # Notes: The dew point is a temperature in degrees C and # is a function of the vapor pressure, e_air. # Vapor pressure is a function of air temperature, # T_air, and relative humidity, RH. # The formula used here needs e_air in kPa units. # See Dingman (2002, Appendix D, p. 587). #----------------------------------------------------------- e_air_kPa = self.e_air / np.float64(10) # [kPa] log_vp = np.log( e_air_kPa ) top = log_vp + np.float64(0.4926) bot = np.float64(0.0708) - (np.float64(0.00421) * log_vp) self.T_dew = (top / bot) # [degrees C] # update_dew_point() #------------------------------------------------------------------- def update_precipitable_water_content(self): if (self.DEBUG): print 'Calling update_precipitable_water_content()...' #------------------------------------------------------------ # Notes: W_p is precipitable water content in centimeters, # which depends on air temp and relative humidity. #------------------------------------------------------------ arg = np.float64( 0.0614 * self.T_dew ) self.W_p = np.float64(1.12) * np.exp( arg ) # [cm] # update_precipitable_water_content() #------------------------------------------------------------------- def update_latent_heat_flux(self): if (self.DEBUG): print 'Calling update_latent_heat_flux()...' #-------------------------------------------------------- # Notes: Pressure units cancel out because e_air and # e_surf (in numer) have same units (mbar) as # p0 (in denom). #-------------------------------------------------------- # According to Dingman (2002, p. 273), constant should # be 0.622 instead of 0.662 (Zhang et al., 2000). #-------------------------------------------------------- const = self.latent_heat_constant factor = (self.rho_air * self.Lv * self.De) delta_e = (self.e_air - self.e_surf) self.Qe = factor * delta_e * (const / self.p0) # update_latent_heat_flux() #------------------------------------------------------------------- def update_conduction_heat_flux(self): if (self.DEBUG): print 'Calling update_conduction_heat_flux()...' #----------------------------------------------------------------- # Notes: The conduction heat flux from snow to soil for computing # snowmelt energy, Qm, is close to zero. # However, the conduction heat flux from surface and sub- # surface for computing Qet is given by Fourier's Law, # namely Qc = Ks(Tx - Ts)/x. # All the Q's have units of W/m^2 = J/(m^2 s). #----------------------------------------------------------------- pass # (initialized at start) # update_conduction_heat_flux() #------------------------------------------------------------------- def update_advection_heat_flux(self): if (self.DEBUG): print 'Calling update_advection_heat_flux()...' #------------------------------------------------------ # Notes: All the Q's have units of W/m^2 = J/(m^2 s). #------------------------------------------------------ pass # (initialized at start) # update_advection_heat_flux() #------------------------------------------------------------------- def update_julian_day(self): if (self.DEBUG): print 'Calling update_julian_day()...' #---------------------------------- # Update the *decimal* Julian day #---------------------------------- self.julian_day += (self.dt / self.secs_per_day) # [days] #------------------------------------------ # Compute the offset from True Solar Noon # clock_hour is in 24-hour military time # but it can have a decimal part. #------------------------------------------ dec_part = self.julian_day - np.int16(self.julian_day) clock_hour = dec_part * self.hours_per_day ## print ' Computing solar_noon...' solar_noon = solar.True_Solar_Noon( self.julian_day, self.lon_deg, self.GMT_offset ) ## print ' Computing TSN_offset...' self.TSN_offset = (clock_hour - solar_noon) # [hours] # update_julian_day() #------------------------------------------------------------------- def update_net_shortwave_radiation(self): #--------------------------------------------------------- # Notes: If time is before local sunrise or after local # sunset then Qn_SW should be zero. #--------------------------------------------------------- if (self.DEBUG): print 'Calling update_net_shortwave_radiation()...' #--------------------------------------- # Compute Qn_SW for this time [W m-2] #--------------------------------------- Qn_SW = solar.Clear_Sky_Radiation( self.lat_deg, self.julian_day, self.W_p, self.TSN_offset, self.alpha, self.beta, self.albedo, self.dust_atten ) self.update_var( 'Qn_SW', Qn_SW ) ## (2/14/17) # if (np.ndim( self.Qn_SW ) == 0): # self.Qn_SW.fill( Qn_SW ) #### (mutable scalar) # else: # self.Qn_SW[:] = Qn_SW # [W m-2] # update_net_shortwave_radiation() #------------------------------------------------------------------- def update_em_air(self): if (self.DEBUG): print 'Calling update_em_air()...' #--------------------------------------------------------- # NB! The Brutsaert and Satterlund formulas for air # emissivity as a function of air temperature are in # close agreement; see compare_em_air_methods(). # However, we must pay close attention to whether # equations require units of kPa, Pa, or mbar. # # 100 kPa = 1 bar = 1000 mbars # => 1 kPa = 10 mbars #--------------------------------------------------------- # NB! Temperatures are assumed to be given with units # of degrees Celsius and are converted to Kelvin # wherever necessary by adding C_to_K = 273.15. # # RH = relative humidity [unitless] #--------------------------------------------------------- # NB! I'm not sure about how F is added at end because # of how the equation is printed in Dingman (2002). # But it reduces to other formulas as it should. #--------------------------------------------------------- T_air_K = self.T_air + self.C_to_K if not(self.SATTERLUND): #----------------------------------------------------- # Brutsaert (1975) method for computing emissivity # of the air, em_air. This formula uses e_air with # units of kPa. (From Dingman (2002, p. 196).) # See notes for update_vapor_pressure(). #----------------------------------------------------- e_air_kPa = self.e_air / np.float64(10) # [kPa] F = self.canopy_factor C = self.cloud_factor term1 = (1.0 - F) * 1.72 * (e_air_kPa / T_air_K) ** self.one_seventh term2 = (1.0 + (0.22 * C ** 2.0)) self.em_air = (term1 * term2) + F else: #-------------------------------------------------------- # Satterlund (1979) method for computing the emissivity # of the air, em_air, that is intended to "correct # apparent deficiencies in this formulation at air # temperatures below 0 degrees C" (see G. Liston) # Liston cites Aase and Idso(1978), Satterlund (1979) #-------------------------------------------------------- e_air_mbar = self.e_air eterm = np.exp(-1 * (e_air_mbar)**(T_air_K / 2016) ) self.em_air = 1.08 * (1.0 - eterm) #-------------------------------------------------------------- # Can't do this yet. em_air is always initialized scalar now # but may change to grid on assignment. (9/23/14) #-------------------------------------------------------------- # if (np.ndim( self.em_air ) == 0): # self.em_air.fill( em_air ) #### (mutable scalar) # else: # self.em_air[:] = em_air # update_em_air() #------------------------------------------------------------------- def update_net_longwave_radiation(self): #---------------------------------------------------------------- # Notes: Net longwave radiation is computed using the # Stefan-Boltzman law. All four data types # should be allowed (scalar, time series, grid or # grid stack). # # Qn_LW = (LW_in - LW_out) # LW_in = em_air * sigma * (T_air + 273.15)^4 # LW_out = em_surf * sigma * (T_surf + 273.15)^4 # # Temperatures in [deg_C] must be converted to # [K]. Recall that absolute zero occurs at # 0 [deg_K] or -273.15 [deg_C]. # #---------------------------------------------------------------- # First, e_air is computed as: # e_air = RH * 0.611 * exp[(17.3 * T_air) / (T_air + 237.3)] # Then, em_air is computed as: # em_air = (1 - F) * 1.72 * [e_air / (T_air + 273.15)]^(1/7) * # (1 + 0.22 * C^2) + F #---------------------------------------------------------------- if (self.DEBUG): print 'Calling update_net_longwave_radiation()...' #-------------------------------- # Compute Qn_LW for this time #-------------------------------- T_air_K = self.T_air + self.C_to_K T_surf_K = self.T_surf + self.C_to_K LW_in = self.em_air * self.sigma * (T_air_K)** 4.0 LW_out = self.em_surf * self.sigma * (T_surf_K)** 4.0 LW_out = LW_out + ((1.0 - self.em_surf) * LW_in) self.Qn_LW = (LW_in - LW_out) # [W m-2] #-------------------------------------------------------------- # Can't do this yet. Qn_LW is always initialized grid now # but will often be created above as a scalar. (9/23/14) #-------------------------------------------------------------- # if (np.ndim( self.Qn_LW ) == 0): # self.Qn_LW.fill( Qn_LW ) #### (mutable scalar) # else: # self.Qn_LW[:] = Qn_LW # [W m-2] # update_net_longwave_radiation() #------------------------------------------------------------------- def update_net_total_radiation(self): #----------------------------------------------- # Notes: Added this on 9/11/14. Not used yet. #------------------------------------------------------------ # Qn_SW = net shortwave radiation flux (solar) # Qn_LW = net longwave radiation flux (air, surface) #------------------------------------------------------------ if (self.DEBUG): print 'Calling update_net_total_radiation()...' Qn_tot = self.Qn_SW + self.Qn_LW # [W m-2] self.update_var( 'Qn_tot', Qn_tot ) ## (2/14/17) # if (np.ndim( self.Qn_tot ) == 0): # self.Qn_tot.fill( Qn_tot ) #### (mutable scalar) # else: # self.Qn_tot[:] = Qn_tot # [W m-2] # update_net_total_radiation() #------------------------------------------------------------------- def update_net_energy_flux(self): if (self.DEBUG): print 'Calling update_net_energy_flux()...' #------------------------------------------------------ # Notes: Q_sum is used by "snow_energy_balance.py". #------------------------------------------------------ # Qm = energy used to melt snowpack (if > 0) # Qn_SW = net shortwave radiation flux (solar) # Qn_LW = net longwave radiation flux (air, surface) # Qh = sensible heat flux from turbulent convection # between snow surface and air # Qe = latent heat flux from evaporation, sublimation, # and condensation # Qa = energy advected by moving water (i.e. rainfall) # (ARHYTHM assumes this to be negligible; Qa=0.) # Qc = energy flux via conduction from snow to soil # (ARHYTHM assumes this to be negligible; Qc=0.) # Ecc = cold content of snowpack = amount of energy # needed before snow can begin to melt [J m-2] # All Q's here have units of [W m-2]. # Are they all treated as positive quantities ? # rho_air = density of air [kg m-3] # rho_snow = density of snow [kg m-3] # Cp_air = specific heat of air [J kg-1 K-1] # Cp_snow = heat capacity of snow [J kg-1 K-1] # = ???????? = specific heat of snow # Kh = eddy diffusivity for heat [m2 s-1] # Ke = eddy diffusivity for water vapor [m2 s-1] # Lv = latent heat of vaporization [J kg-1] # Lf = latent heat of fusion [J kg-1] # ------------------------------------------------------ # Dn = bulk exchange coeff for the conditions of # neutral atmospheric stability [m/s] # Dh = bulk exchange coeff for heat # De = bulk exchange coeff for vapor # ------------------------------------------------------ # T_air = air temperature [deg_C] # T_surf = surface temperature [deg_C] # T_snow = average snow temperature [deg_C] # RH = relative humidity [unitless] (in [0,1]) # e_air = air vapor pressure at height z [mbar] # e_surf = surface vapor pressure [mbar] # ------------------------------------------------------ # h_snow = snow depth [m] # z = height where wind speed is uz [m] # uz = wind speed at height z [m/s] # p0 = atmospheric pressure [mbar] # T0 = snow temperature when isothermal [deg_C] # (This is usually 0.) # z0_air = surface roughness length scale [m] # (includes vegetation not covered by snow) # (Values from page 1033: 0.0013, 0.02 [m]) # kappa = von Karman's constant [unitless] = 0.41 # dt = snowmelt timestep [seconds] #---------------------------------------------------------------- Q_sum = self.Qn_SW + self.Qn_LW + self.Qh + \ self.Qe + self.Qa + self.Qc # [W m-2] self.update_var( 'Q_sum', Q_sum ) ## (2/14/17) # if (np.ndim( self.Q_sum) == 0): # self.Q_sum.fill( Q_sum ) #### (mutable scalar) # else: # self.Q_sum[:] = Q_sum # [W m-2] # update_net_energy_flux() #------------------------------------------------------------------- def open_input_files(self): if (self.DEBUG): print 'Calling open_input_files()...' self.P_file = self.in_directory + self.P_file self.T_air_file = self.in_directory + self.T_air_file self.T_surf_file = self.in_directory + self.T_surf_file self.RH_file = self.in_directory + self.RH_file self.p0_file = self.in_directory + self.p0_file self.uz_file = self.in_directory + self.uz_file self.z_file = self.in_directory + self.z_file self.z0_air_file = self.in_directory + self.z0_air_file self.albedo_file = self.in_directory + self.albedo_file self.em_surf_file = self.in_directory + self.em_surf_file self.dust_atten_file = self.in_directory + self.dust_atten_file self.cloud_factor_file = self.in_directory + self.cloud_factor_file self.canopy_factor_file = self.in_directory + self.canopy_factor_file self.P_unit = model_input.open_file(self.P_type, self.P_file) self.T_air_unit = model_input.open_file(self.T_air_type, self.T_air_file) self.T_surf_unit = model_input.open_file(self.T_surf_type, self.T_surf_file) self.RH_unit = model_input.open_file(self.RH_type, self.RH_file) self.p0_unit = model_input.open_file(self.p0_type, self.p0_file) self.uz_unit = model_input.open_file(self.uz_type, self.uz_file) self.z_unit = model_input.open_file(self.z_type, self.z_file) self.z0_air_unit = model_input.open_file(self.z0_air_type, self.z0_air_file) #----------------------------------------------- # These are needed to compute Qn_SW and Qn_LW. #----------------------------------------------- self.albedo_unit = model_input.open_file(self.albedo_type, self.albedo_file) self.em_surf_unit = model_input.open_file(self.em_surf_type, self.em_surf_file) self.dust_atten_unit = model_input.open_file(self.dust_atten_type, self.dust_atten_file) self.cloud_factor_unit = model_input.open_file(self.cloud_factor_type, self.cloud_factor_file) self.canopy_factor_unit = model_input.open_file(self.canopy_factor_type, self.canopy_factor_file) #---------------------------------------------------------------------------- # Note: GMT_offset plus slope and aspect grids will be read separately. #---------------------------------------------------------------------------- ## self.Qn_SW_unit = model_input.open_file(self.Qn_SW_type, self.Qn_SW_file) ## self.Qn_LW_unit = model_input.open_file(self.Qn_LW_type, self.Qn_LW_file) # open_input_files() #------------------------------------------------------------------- def read_input_files(self): if (self.DEBUG): print 'Calling read_input_files()...' rti = self.rti #-------------------------------------------------------- # All grids are assumed to have a data type of Float32. #-------------------------------------------------------- # NB! read_next() returns None if TYPE arg is "Scalar". #-------------------------------------------------------- P = model_input.read_next(self.P_unit, self.P_type, rti, factor=self.mmph_to_mps) ## print '######### self.P_type = ' + self.P_type ## print '######### np.ndim( P ) = ' + str(np.ndim(P)) if (P is not None): ## print 'MET: (time,P) =', self.time, P self.update_var( 'P', P ) ### 11/15/16 ## if (self.P_type.lower() != 'scalar'): # if (np.ndim( self.P ) == 0): # self.P.fill( P ) #### (2/7/13, mutable scalar) # else: # self.P = P if (self.DEBUG or (self.time_index == 0)): print 'In read_input_files():' print ' min(P) =', P.min() * self.mps_to_mmph, ' [mmph]' print ' max(P) =', P.max() * self.mps_to_mmph, ' [mmph]' print ' ' else: #----------------------------------------------- # Either self.P_type is "Scalar" or we've read # all of the data in the rain_rates file. #----------------------------------------------- if (self.P_type.lower() != 'scalar'): #------------------------------------ # Precip is unique in this respect. #-------------------------------------------------- # 2/7/13. Note that we don't change P from grid # to scalar since that could cause trouble for # other comps that use P, so we just zero it out. #-------------------------------------------------- self.P.fill( 0 ) if (self.DEBUG): print 'Reached end of file:', self.P_file print ' P set to 0 by read_input_files().' elif (self.time_sec >= self.dt): self.P.fill( 0 ) if (self.DEBUG): print 'Reached end of scalar rainfall duration.' print ' P set to 0 by read_input_files().' ## print 'time_sec =', self.time_sec ## print 'met dt =', self.dt ## print '######### In met_base.read_input_files() #######' ## print 'self.P_type =', self.P_type ## print 'self.P =', self.P #------------------------------------------------------------ # Read variables from files into scalars or grids while # making sure to preserve references (in-place). (11/15/16) #------------------------------------------------------------ model_input.read_next2(self, 'T_air', rti) model_input.read_next2(self, 'T_surf', rti) model_input.read_next2(self, 'RH', rti) model_input.read_next2(self, 'p0', rti) model_input.read_next2(self, 'uz', rti) model_input.read_next2(self, 'z', rti) model_input.read_next2(self, 'z0_air', rti) #---------------------------------------------------- model_input.read_next2(self, 'albedo', rti) model_input.read_next2(self, 'em_surf', rti) model_input.read_next2(self, 'dust_atten', rti) model_input.read_next2(self, 'cloud_factor', rti) model_input.read_next2(self, 'canopy_factor', rti) ############################################################### # If any of these are scalars (read from a time series file) # then we'll need to use "fill()" method to prevent breaking # the reference to the "mutable scalar". (2/7/13) ############################################################### T_air = model_input.read_next(self.T_air_unit, self.T_air_type, rti) self.update_var( 'T_air', T_air ) # if (T_air is not None): self.T_air = T_air T_surf = model_input.read_next(self.T_surf_unit, self.T_surf_type, rti) self.update_var( 'T_surf', T_surf ) # if (T_surf is not None): self.T_surf = T_surf RH = model_input.read_next(self.RH_unit, self.RH_type, rti) self.update_var( 'RH', RH ) # if (RH is not None): self.RH = RH p0 = model_input.read_next(self.p0_unit, self.p0_type, rti) self.update_var( 'p0', p0 ) # if (p0 is not None): self.p0 = p0 uz = model_input.read_next(self.uz_unit, self.uz_type, rti) self.update_var( 'uz', uz ) # if (uz is not None): self.uz = uz z = model_input.read_next(self.z_unit, self.z_type, rti) self.update_var( 'z', z ) # if (z is not None): self.z = z z0_air = model_input.read_next(self.z0_air_unit, self.z0_air_type, rti) self.update_var( 'z0_air', z0_air ) # if (z0_air is not None): self.z0_air = z0_air #---------------------------------------------------------------------------- # These are needed to compute Qn_SW and Qn_LW. #---------------------------------------------------------------------------- # Note: We could later write a version of read_next() that takes "self" # and "var_name" as args and that uses "exec()". #---------------------------------------------------------------------------- albedo = model_input.read_next(self.albedo_unit, self.albedo_type, rti) if (albedo is not None): self.albedo = albedo em_surf = model_input.read_next(self.em_surf_unit, self.em_surf_type, rti) if (em_surf is not None): self.em_surf = em_surf dust_atten = model_input.read_next(self.dust_atten_unit, self.dust_atten_type, rti) if (dust_atten is not None): self.dust_atten = dust_atten cloud_factor = model_input.read_next(self.cloud_factor_unit, self.cloud_factor_type, rti) if (cloud_factor is not None): self.cloud_factor = cloud_factor canopy_factor = model_input.read_next(self.canopy_factor_unit, self.canopy_factor_type, rti) if (canopy_factor is not None): self.canopy_factor = canopy_factor #------------------------------------------------------------- # Compute Qsw_prefactor from cloud_factor and canopy factor. #------------------------------------------------------------- ## self.Qsw_prefactor = #------------------------------------------------------------- # These are currently treated as input data, but are usually # generated by functions in Qnet_file.py. Later on, we'll # provide the option to compute them "on the fly" with new # functions called "update_net_shortwave_radiation()" and # "update_net_longwave_radiation()", called from update(). #------------------------------------------------------------- ## Qn_SW = model_input.read_next(self.Qn_SW_unit, self.Qn_SW_type, rti) ## if (Qn_SW is not None): self.Qn_SW = Qn_SW ## ## Qn_LW = model_input.read_next(self.Qn_LW_unit, self.Qn_LW_type, rti) ## if (Qn_LW is not None): self.Qn_LW = Qn_LW # read_input_files() #------------------------------------------------------------------- def close_input_files(self): if (self.DEBUG): print 'Calling close_input_files()...' if (self.P_type != 'Scalar'): self.P_unit.close() if (self.T_air_type != 'Scalar'): self.T_air_unit.close() if (self.T_surf_type != 'Scalar'): self.T_surf_unit.close() if (self.RH_type != 'Scalar'): self.RH_unit.close() if (self.p0_type != 'Scalar'): self.p0_unit.close() if (self.uz_type != 'Scalar'): self.uz_unit.close() if (self.z_type != 'Scalar'): self.z_unit.close() if (self.z0_air_type != 'Scalar'): self.z0_air_unit.close() #--------------------------------------------------- # These are needed to compute Qn_SW and Qn_LW. #--------------------------------------------------- if (self.albedo_type != 'Scalar'): self.albedo_unit.close() if (self.em_surf_type != 'Scalar'): self.em_surf_unit.close() if (self.dust_atten_type != 'Scalar'): self.dust_atten_unit.close() if (self.cloud_factor_type != 'Scalar'): self.cloud_factor_unit.close() if (self.canopy_factor_type != 'Scalar'): self.canopy_factor_unit.close() ## if (self.Qn_SW_type != 'Scalar'): self.Qn_SW_unit.close() ## if (self.Qn_LW_type != 'Scalar'): self.Qn_LW_unit.close() ## if (self.P_file != ''): self.P_unit.close() ## if (self.T_air_file != ''): self.T_air_unit.close() ## if (self.T_surf_file != ''): self.T_surf_unit.close() ## if (self.RH_file != ''): self.RH_unit.close() ## if (self.p0_file != ''): self.p0_unit.close() ## if (self.uz_file != ''): self.uz_unit.close() ## if (self.z_file != ''): self.z_unit.close() ## if (self.z0_air_file != ''): self.z0_air_unit.close() ## #-------------------------------------------------------- ## if (self.Qn_SW_file != ''): self.Qn_SW_unit.close() ## if (self.Qn_LW_file != ''): self.Qn_LW_unit.close() # close_input_files() #------------------------------------------------------------------- def update_outfile_names(self): if (self.DEBUG): print 'Calling update_outfile_names()...' #------------------------------------------------- # Notes: Append out_directory to outfile names. #------------------------------------------------- self.ea_gs_file = (self.out_directory + self.ea_gs_file ) self.es_gs_file = (self.out_directory + self.es_gs_file ) self.Qsw_gs_file = (self.out_directory + self.Qsw_gs_file ) self.Qlw_gs_file = (self.out_directory + self.Qlw_gs_file ) self.ema_gs_file = (self.out_directory + self.ema_gs_file ) #------------------------------------------------------------ self.ea_ts_file = (self.out_directory + self.ea_ts_file ) self.es_ts_file = (self.out_directory + self.es_ts_file ) self.Qsw_ts_file = (self.out_directory + self.Qsw_ts_file ) self.Qlw_ts_file = (self.out_directory + self.Qlw_ts_file ) self.ema_ts_file = (self.out_directory + self.ema_ts_file ) ## self.ea_gs_file = (self.case_prefix + '_2D-ea.rts') ## self.es_gs_file = (self.case_prefix + '_2D-es.rts') ## #----------------------------------------------------- ## self.ea_ts_file = (self.case_prefix + '_0D-ea.txt') ## self.es_ts_file = (self.case_prefix + '_0D-es.txt') # update_outfile_names() #------------------------------------------------------------------- def open_output_files(self): if (self.DEBUG): print 'Calling open_output_files()...' model_output.check_netcdf() self.update_outfile_names() #-------------------------------------- # Open new files to write grid stacks #-------------------------------------- if (self.SAVE_EA_GRIDS): model_output.open_new_gs_file( self, self.ea_gs_file, self.rti, ## var_name='e_air', var_name='ea', long_name='vapor_pressure_in_air', units_name='mbar') if (self.SAVE_ES_GRIDS): model_output.open_new_gs_file( self, self.es_gs_file, self.rti, ## var_name='e_surf', var_name='es', long_name='vapor_pressure_at_surface', units_name='mbar') if (self.SAVE_QSW_GRIDS): model_output.open_new_gs_file( self, self.Qsw_gs_file, self.rti, var_name='Qsw', long_name='net_shortwave_radiation', units_name='W/m^2') if (self.SAVE_QLW_GRIDS): model_output.open_new_gs_file( self, self.Qlw_gs_file, self.rti, var_name='Qlw', long_name='net_longwave_radiation', units_name='W/m^2') if (self.SAVE_EMA_GRIDS): model_output.open_new_gs_file( self, self.ema_gs_file, self.rti, var_name='ema', long_name='air_emissivity', units_name='none') #-------------------------------------- # Open new files to write time series #-------------------------------------- IDs = self.outlet_IDs if (self.SAVE_EA_PIXELS): model_output.open_new_ts_file( self, self.ea_ts_file, IDs, ## var_name='e_air', var_name='ea', long_name='vapor_pressure_in_air', units_name='mbar') if (self.SAVE_ES_PIXELS): model_output.open_new_ts_file( self, self.es_ts_file, IDs, ## var_name='e_surf', var_name='es', long_name='vapor_pressure_at_surface', units_name='mbar') if (self.SAVE_QSW_PIXELS): model_output.open_new_ts_file( self, self.Qsw_ts_file, IDs, var_name='Qsw', long_name='net_shortwave_radiation', units_name='W/m^2') if (self.SAVE_QLW_PIXELS): model_output.open_new_ts_file( self, self.Qlw_ts_file, IDs, var_name='Qlw', long_name='net_longwave_radiation', units_name='W/m^2') if (self.SAVE_EMA_PIXELS): model_output.open_new_ts_file( self, self.ema_ts_file, IDs, var_name='ema', long_name='air_emissivity', units_name='none') # open_output_files() #------------------------------------------------------------------- def write_output_files(self, time_seconds=None): if (self.DEBUG): print 'Calling write_output_files()...' #----------------------------------------- # Allows time to be passed from a caller #----------------------------------------- if (time_seconds is None): time_seconds = self.time_sec model_time = int(time_seconds) #---------------------------------------- # Save computed values at sampled times #---------------------------------------- if (model_time % int(self.save_grid_dt) == 0): self.save_grids() if (model_time % int(self.save_pixels_dt) == 0): self.save_pixel_values() # write_output_files() #------------------------------------------------------------------- def close_output_files(self): if (self.SAVE_EA_GRIDS): model_output.close_gs_file( self, 'ea') if (self.SAVE_ES_GRIDS): model_output.close_gs_file( self, 'es') if (self.SAVE_QSW_GRIDS): model_output.close_gs_file( self, 'Qsw') if (self.SAVE_QLW_GRIDS): model_output.close_gs_file( self, 'Qlw') if (self.SAVE_EMA_GRIDS): model_output.close_gs_file( self, 'ema') #------------------------------------------------------------------- if (self.SAVE_EA_PIXELS): model_output.close_ts_file( self, 'ea') if (self.SAVE_ES_PIXELS): model_output.close_ts_file( self, 'es') if (self.SAVE_QSW_PIXELS): model_output.close_ts_file( self, 'Qsw') if (self.SAVE_QLW_PIXELS): model_output.close_ts_file( self, 'Qlw') if (self.SAVE_EMA_PIXELS): model_output.close_ts_file( self, 'ema') # close_output_files() #------------------------------------------------------------------- def save_grids(self): if (self.SAVE_EA_GRIDS): model_output.add_grid( self, self.e_air, 'ea', self.time_min ) if (self.SAVE_ES_GRIDS): model_output.add_grid( self, self.e_surf, 'es', self.time_min ) if (self.SAVE_QSW_GRIDS): model_output.add_grid( self, self.Qn_SW, 'Qsw', self.time_min ) if (self.SAVE_QLW_GRIDS): model_output.add_grid( self, self.Qn_LW, 'Qlw', self.time_min ) if (self.SAVE_EMA_GRIDS): model_output.add_grid( self, self.em_air, 'ema', self.time_min ) # save_grids() #------------------------------------------------------------------- def save_pixel_values(self): IDs = self.outlet_IDs time = self.time_min ###### if (self.SAVE_EA_PIXELS): model_output.add_values_at_IDs( self, time, self.e_air, 'ea', IDs ) if (self.SAVE_ES_PIXELS): model_output.add_values_at_IDs( self, time, self.e_surf, 'es', IDs ) if (self.SAVE_QSW_PIXELS): model_output.add_values_at_IDs( self, time, self.Qn_SW, 'Qsw', IDs ) if (self.SAVE_QLW_PIXELS): model_output.add_values_at_IDs( self, time, self.Qn_LW, 'Qlw', IDs ) if (self.SAVE_EMA_PIXELS): model_output.add_values_at_IDs( self, time, self.em_air, 'ema', IDs ) # save_pixel_values() #------------------------------------------------------------------- #--------------------------------------------------------------------------------- def compare_em_air_methods(): #-------------------------------------------------------------- # Notes: There are two different methods that are commonly # used to compute the vapor pressure of air, e_air, # and then the emissivity of air, em_air, for use in # longwave radiation calculations. This routine # compares them graphically. # # NB! This hasn't been tested since conversion from IDL. #------------------------------------------------------------- import matplotlib.pyplot T_air = np.arange(80, dtype='Float32') - np.float64(40) #[Celsius] (-40 to 40) RH = np.float64(1.0) C2K = np.float64(273.15) #-------------------------- # Brutsaert (1975) method #-------------------------- term1 = (np.float64(17.3) * T_air) / (T_air + np.float64(237.3)) ######### DOUBLE CHECK THIS (7/26/13) e_air1 = RH * np.float64(0.611) * np.exp( term1 ) # [kPa] em_air1 = np.float64(1.72) * (e_air1 / (T_air + C2K)) ** (np.float64(1) / 7) #--------------------------- # Satterlund (1979) method #---------------------------- # NB! e_air has units of Pa #---------------------------- term2 = np.float64(2353) / (T_air + C2K) e_air2 = RH * np.float64(10) ** (np.float64(11.40) - term2) # [Pa] eterm = np.exp(-np.float64(1) * (e_air2 / np.float64(100)) ** ((T_air + C2K) / np.float64(2016))) em_air2 = np.float64(1.08) * (np.float64(1) - eterm) #---------------------------- # Plot the two e_air curves #-------------------------------- # These two agree quite closely #-------------------------------- matplotlib.pyplot.figure(figsize=(8, 6), dpi=80) matplotlib.pyplot.show() matplotlib.pyplot.plot(T_air, e_air1) matplotlib.pyplot.show() ## oplot(T_air, (e_air2 / np.float64(1000)), psym=-3) # [Pa -> kPa] #----------------------------- # Plot the two em_air curves #-------------------------------------------------- # These two don't agree very well for some reason #-------------------------------------------------- matplotlib.pyplot.figure(figsize=(8, 6), dpi=80) matplotlib.pyplot.show() matplotlib.pyplot.plot(T_air, em_air1) matplotlib.pyplot.show() ## oplot(T_air, em_air2, psym=-3) # compare_em_air_Methods #---------------------------------------------------------------------------------
mit
[ 202, 199, 309, 12078, 298, 9688, 63, 10992, 63, 8387, 363, 750, 343, 63, 16614, 63, 14477, 2, 1852, 12249, 31, 334, 18, 15, 21, 15, 969, 9, 2999, 199, 3, 1898, 334, 67, 9, 12521, 13, 7280, 12, 428, 331, 6215, 577, 14, 11379, 346, 10670, 202, 199, 3, 202, 199, 3, 221, 428, 1545, 6927, 14, 221, 18659, 2070, 1125, 315, 1678, 63, 9377, 63, 322, 1560, 795, 265, 63, 1955, 1252, 202, 199, 3, 3777, 437, 3195, 370, 4526, 7396, 510, 63, 27765, 436, 510, 63, 6322, 14, 202, 199, 3, 221, 25298, 6927, 14, 221, 7053, 445, 3693, 3053, 9739, 23923, 436, 3633, 1536, 14, 202, 199, 3, 221, 3091, 86, 6171, 14, 221, 11801, 471, 14132, 79, 5060, 370, 282, 2018, 2559, 14, 202, 199, 3, 202, 199, 3, 221, 17474, 6171, 14, 799, 17311, 7252, 402, 1324, 15, 1199, 1561, 14, 202, 199, 3, 221, 18365, 6029, 14, 445, 3693, 3053, 9739, 23923, 334, 1023, 378, 14, 23, 14, 25, 9, 436, 699, 10709, 14, 202, 199, 3, 221, 10162, 6029, 14, 510, 365, 3063, 282, 413, 36, 1625, 543, 1373, 1819, 436, 17194, 12, 202, 199, 3, 3322, 880, 1263, 1013, 543, 2984, 370, 652, 883, 1937, 652, 1570, 14, 202, 199, 3, 221, 1603, 324, 7129, 14, 1678, 63, 846, 63, 3612, 10024, 63, 12841, 425, 1062, 5423, 14, 257, 202, 199, 3, 221, 10162, 7129, 14, 18784, 370, 8265, 342, 436, 1586, 63, 4128, 63, 493, 1252, 202, 199, 3, 221, 25298, 8937, 202, 199, 3, 221, 17474, 8937, 14, 11801, 471, 687, 14575, 14, 202, 199, 3, 202, 199, 7656, 12797, 202, 199, 3, 2845, 654, 26, 961, 570, 7890, 282, 298, 1095, 1021, 2, 367, 562, 266, 269, 7085, 202, 199, 3, 263, 7323, 465, 5521, 465, 1263, 3423, 1202, 701, 4750, 503, 202, 199, 3, 263, 1006, 562, 266, 269, 7085, 3102, 14, 221, 710, 3102, 402, 642, 1021, 202, 199, 3, 263, 1077, 506, 1806, 13, 8639, 465, 5784, 367, 3365, 202, 199, 3, 263, 3102, 402, 1402, 316, 562, 266, 269, 7085, 14, 202, 199, 7656, 12797, 202, 199, 3, 8144, 26, 4226, 781, 14433, 1929, 370, 22237, 3382, 282, 13195, 202, 199, 3, 263, 14843, 436, 308, 2131, 14843, 334, 262, 314, 308, 2131, 9, 5805, 202, 199, 3, 263, 799, 1250, 626, 282, 7396, 377, 63, 1152, 382, 63, 88, 1750, 365, 1202, 202, 199, 3, 263, 370, 4526, 1413, 67, 14, 202, 199, 3, 202, 199, 3, 263, 445, 80, 63, 27765, 365, 687, 653, 28395, 445, 4029, 11040, 2521, 1849, 1363, 82, 3330, 2034, 202, 199, 3, 202, 199, 3, 263, 17908, 63, 40, 18, 47, 365, 5544, 440, 11311, 461, 543, 17160, 14, 334, 32310, 2549, 17076, 202, 199, 3, 258, 202, 199, 7656, 12797, 258, 202, 199, 3, 202, 199, 3, 221, 1021, 7647, 63, 3173, 258, 334, 20882, 687, 699, 10709, 63, 1095, 14, 647, 9, 202, 199, 3, 202, 199, 3, 420, 664, 63, 3173, 63, 354, 342, 202, 199, 3, 420, 664, 63, 3215, 342, 3698, 327, 334, 709, 15, 1479, 15, 845, 9, 202, 199, 3, 420, 664, 63, 1210, 63, 1391, 63, 1247, 342, 258, 327, 334, 21, 15, 1046, 15, 713, 9, 202, 199, 3, 420, 664, 63, 1199, 63, 1391, 63, 1247, 342, 259, 327, 334, 21, 15, 1046, 15, 713, 9, 202, 199, 3, 420, 664, 63, 1391, 63, 354, 342, 3322, 327, 334, 21, 15, 1046, 15, 713, 9, 202, 199, 3, 420, 664, 63, 1391, 63, 5260, 342, 3698, 327, 334, 21, 15, 1046, 15, 713, 9, 202, 199, 3, 420, 10652, 9858, 202, 199, 3, 420, 663, 63, 5559, 342, 202, 199, 3, 420, 8265, 342, 202, 199, 3, 420, 1678, 342, 202, 199, 3, 420, 17284, 342, 202, 199, 3, 420, 10652, 4559, 202, 199, 3, 420, 663, 63, 14378, 63, 1210, 63, 2936, 342, 202, 199, 3, 420, 8265, 63, 14378, 63, 2936, 342, 202, 199, 3, 420, 10652, 4559, 202, 199, 3, 420, 1678, 63, 48, 63, 24705, 342, 202, 199, 3, 420, 1678, 63, 48, 63, 988, 342, 202, 199, 3, 420, 1678, 63, 48, 63, 6322, 342, 259, 327, 334, 25, 15, 1079, 15, 1079, 12, 892, 1083, 9, 202, 199, 3, 420, 1678, 63, 48, 63, 27765, 342, 259, 327, 334, 25, 15, 1079, 15, 1079, 12, 892, 1083, 9, 202, 199, 3, 420, 11016, 375, 202, 199, 3, 420, 1678, 63, 9377, 63, 322, 1560, 795, 265, 63, 1955, 342, 202, 199, 3, 420, 1678, 63, 9377, 63, 65, 3478, 63, 388, 1601, 554, 342, 202, 199, 3, 420, 1678, 63, 2464, 1164, 63, 16614, 63, 14477, 342, 202, 199, 3, 420, 1678, 63, 14997, 1542, 63, 86, 439, 269, 63, 21999, 342, 202, 199, 3, 420, 1678, 63, 86, 439, 269, 63, 21999, 342, 202, 199, 3, 420, 1678, 63, 271, 87, 63, 1403, 342, 8540, 327, 334, 23, 15, 22, 15, 709, 9, 202, 199, 3, 420, 1678, 63, 657, 6237, 390, 461, 63, 17217, 63, 1317, 342, 257, 327, 334, 23, 15, 22, 15, 709, 9, 202, 199, 3, 420, 11016, 375, 202, 199, 3, 420, 1678, 63, 750, 343, 63, 16614, 63, 14477, 342, 202, 199, 3, 420, 1678, 63, 388, 5199, 63, 16614, 63, 14477, 342, 202, 199, 3, 420, 1678, 63, 350, 432, 414, 63, 16614, 63, 14477, 342, 202, 199, 3, 420, 11016, 375, 202, 199, 3, 420, 1678, 63, 74, 28325, 63, 2977, 342, 7861, 327, 334, 23, 15, 17, 15, 709, 9, 202, 199, 3, 420, 1678, 63, 846, 63, 3612, 10024, 63, 12841, 425, 342, 420, 327, 334, 23, 15, 17, 15, 709, 9, 202, 199, 3, 420, 1678, 63, 5633, 63, 8387, 342, 9668, 327, 334, 23, 15, 17, 15, 709, 9, 202, 199, 3, 420, 1678, 63, 846, 63, 2809, 10024, 63, 12841, 425, 342, 755, 327, 334, 23, 15, 17, 15, 709, 9, 202, 199, 3, 420, 1678, 63, 846, 63, 8443, 63, 14477, 342, 4519, 327, 1689, 49, 63, 1838, 531, 202, 199, 3, 420, 11016, 375, 202, 199, 3, 420, 1551, 63, 1210, 63, 1725, 342, 202, 199, 3, 420, 1586 ]
[ 199, 309, 12078, 298, 9688, 63, 10992, 63, 8387, 363, 750, 343, 63, 16614, 63, 14477, 2, 1852, 12249, 31, 334, 18, 15, 21, 15, 969, 9, 2999, 199, 3, 1898, 334, 67, 9, 12521, 13, 7280, 12, 428, 331, 6215, 577, 14, 11379, 346, 10670, 202, 199, 3, 202, 199, 3, 221, 428, 1545, 6927, 14, 221, 18659, 2070, 1125, 315, 1678, 63, 9377, 63, 322, 1560, 795, 265, 63, 1955, 1252, 202, 199, 3, 3777, 437, 3195, 370, 4526, 7396, 510, 63, 27765, 436, 510, 63, 6322, 14, 202, 199, 3, 221, 25298, 6927, 14, 221, 7053, 445, 3693, 3053, 9739, 23923, 436, 3633, 1536, 14, 202, 199, 3, 221, 3091, 86, 6171, 14, 221, 11801, 471, 14132, 79, 5060, 370, 282, 2018, 2559, 14, 202, 199, 3, 202, 199, 3, 221, 17474, 6171, 14, 799, 17311, 7252, 402, 1324, 15, 1199, 1561, 14, 202, 199, 3, 221, 18365, 6029, 14, 445, 3693, 3053, 9739, 23923, 334, 1023, 378, 14, 23, 14, 25, 9, 436, 699, 10709, 14, 202, 199, 3, 221, 10162, 6029, 14, 510, 365, 3063, 282, 413, 36, 1625, 543, 1373, 1819, 436, 17194, 12, 202, 199, 3, 3322, 880, 1263, 1013, 543, 2984, 370, 652, 883, 1937, 652, 1570, 14, 202, 199, 3, 221, 1603, 324, 7129, 14, 1678, 63, 846, 63, 3612, 10024, 63, 12841, 425, 1062, 5423, 14, 257, 202, 199, 3, 221, 10162, 7129, 14, 18784, 370, 8265, 342, 436, 1586, 63, 4128, 63, 493, 1252, 202, 199, 3, 221, 25298, 8937, 202, 199, 3, 221, 17474, 8937, 14, 11801, 471, 687, 14575, 14, 202, 199, 3, 202, 199, 7656, 12797, 202, 199, 3, 2845, 654, 26, 961, 570, 7890, 282, 298, 1095, 1021, 2, 367, 562, 266, 269, 7085, 202, 199, 3, 263, 7323, 465, 5521, 465, 1263, 3423, 1202, 701, 4750, 503, 202, 199, 3, 263, 1006, 562, 266, 269, 7085, 3102, 14, 221, 710, 3102, 402, 642, 1021, 202, 199, 3, 263, 1077, 506, 1806, 13, 8639, 465, 5784, 367, 3365, 202, 199, 3, 263, 3102, 402, 1402, 316, 562, 266, 269, 7085, 14, 202, 199, 7656, 12797, 202, 199, 3, 8144, 26, 4226, 781, 14433, 1929, 370, 22237, 3382, 282, 13195, 202, 199, 3, 263, 14843, 436, 308, 2131, 14843, 334, 262, 314, 308, 2131, 9, 5805, 202, 199, 3, 263, 799, 1250, 626, 282, 7396, 377, 63, 1152, 382, 63, 88, 1750, 365, 1202, 202, 199, 3, 263, 370, 4526, 1413, 67, 14, 202, 199, 3, 202, 199, 3, 263, 445, 80, 63, 27765, 365, 687, 653, 28395, 445, 4029, 11040, 2521, 1849, 1363, 82, 3330, 2034, 202, 199, 3, 202, 199, 3, 263, 17908, 63, 40, 18, 47, 365, 5544, 440, 11311, 461, 543, 17160, 14, 334, 32310, 2549, 17076, 202, 199, 3, 258, 202, 199, 7656, 12797, 258, 202, 199, 3, 202, 199, 3, 221, 1021, 7647, 63, 3173, 258, 334, 20882, 687, 699, 10709, 63, 1095, 14, 647, 9, 202, 199, 3, 202, 199, 3, 420, 664, 63, 3173, 63, 354, 342, 202, 199, 3, 420, 664, 63, 3215, 342, 3698, 327, 334, 709, 15, 1479, 15, 845, 9, 202, 199, 3, 420, 664, 63, 1210, 63, 1391, 63, 1247, 342, 258, 327, 334, 21, 15, 1046, 15, 713, 9, 202, 199, 3, 420, 664, 63, 1199, 63, 1391, 63, 1247, 342, 259, 327, 334, 21, 15, 1046, 15, 713, 9, 202, 199, 3, 420, 664, 63, 1391, 63, 354, 342, 3322, 327, 334, 21, 15, 1046, 15, 713, 9, 202, 199, 3, 420, 664, 63, 1391, 63, 5260, 342, 3698, 327, 334, 21, 15, 1046, 15, 713, 9, 202, 199, 3, 420, 10652, 9858, 202, 199, 3, 420, 663, 63, 5559, 342, 202, 199, 3, 420, 8265, 342, 202, 199, 3, 420, 1678, 342, 202, 199, 3, 420, 17284, 342, 202, 199, 3, 420, 10652, 4559, 202, 199, 3, 420, 663, 63, 14378, 63, 1210, 63, 2936, 342, 202, 199, 3, 420, 8265, 63, 14378, 63, 2936, 342, 202, 199, 3, 420, 10652, 4559, 202, 199, 3, 420, 1678, 63, 48, 63, 24705, 342, 202, 199, 3, 420, 1678, 63, 48, 63, 988, 342, 202, 199, 3, 420, 1678, 63, 48, 63, 6322, 342, 259, 327, 334, 25, 15, 1079, 15, 1079, 12, 892, 1083, 9, 202, 199, 3, 420, 1678, 63, 48, 63, 27765, 342, 259, 327, 334, 25, 15, 1079, 15, 1079, 12, 892, 1083, 9, 202, 199, 3, 420, 11016, 375, 202, 199, 3, 420, 1678, 63, 9377, 63, 322, 1560, 795, 265, 63, 1955, 342, 202, 199, 3, 420, 1678, 63, 9377, 63, 65, 3478, 63, 388, 1601, 554, 342, 202, 199, 3, 420, 1678, 63, 2464, 1164, 63, 16614, 63, 14477, 342, 202, 199, 3, 420, 1678, 63, 14997, 1542, 63, 86, 439, 269, 63, 21999, 342, 202, 199, 3, 420, 1678, 63, 86, 439, 269, 63, 21999, 342, 202, 199, 3, 420, 1678, 63, 271, 87, 63, 1403, 342, 8540, 327, 334, 23, 15, 22, 15, 709, 9, 202, 199, 3, 420, 1678, 63, 657, 6237, 390, 461, 63, 17217, 63, 1317, 342, 257, 327, 334, 23, 15, 22, 15, 709, 9, 202, 199, 3, 420, 11016, 375, 202, 199, 3, 420, 1678, 63, 750, 343, 63, 16614, 63, 14477, 342, 202, 199, 3, 420, 1678, 63, 388, 5199, 63, 16614, 63, 14477, 342, 202, 199, 3, 420, 1678, 63, 350, 432, 414, 63, 16614, 63, 14477, 342, 202, 199, 3, 420, 11016, 375, 202, 199, 3, 420, 1678, 63, 74, 28325, 63, 2977, 342, 7861, 327, 334, 23, 15, 17, 15, 709, 9, 202, 199, 3, 420, 1678, 63, 846, 63, 3612, 10024, 63, 12841, 425, 342, 420, 327, 334, 23, 15, 17, 15, 709, 9, 202, 199, 3, 420, 1678, 63, 5633, 63, 8387, 342, 9668, 327, 334, 23, 15, 17, 15, 709, 9, 202, 199, 3, 420, 1678, 63, 846, 63, 2809, 10024, 63, 12841, 425, 342, 755, 327, 334, 23, 15, 17, 15, 709, 9, 202, 199, 3, 420, 1678, 63, 846, 63, 8443, 63, 14477, 342, 4519, 327, 1689, 49, 63, 1838, 531, 202, 199, 3, 420, 11016, 375, 202, 199, 3, 420, 1551, 63, 1210, 63, 1725, 342, 202, 199, 3, 420, 1586, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
savoirfairelinux/django
tests/custom_columns/tests.py
31
3892
from django.core.exceptions import FieldError from django.test import TestCase from .models import Article, Author class CustomColumnsTests(TestCase): def setUp(self): self.a1 = Author.objects.create(first_name="John", last_name="Smith") self.a2 = Author.objects.create(first_name="Peter", last_name="Jones") self.authors = [self.a1, self.a2] self.article = Article.objects.create(headline="Django lets you build Web apps easily", primary_author=self.a1) self.article.authors.set(self.authors) def test_query_all_available_authors(self): self.assertQuerysetEqual( Author.objects.all(), [ "Peter Jones", "John Smith", ], str ) def test_get_first_name(self): self.assertEqual( Author.objects.get(first_name__exact="John"), self.a1, ) def test_filter_first_name(self): self.assertQuerysetEqual( Author.objects.filter(first_name__exact="John"), [ "John Smith", ], str ) def test_field_error(self): with self.assertRaises(FieldError): Author.objects.filter(firstname__exact="John") def test_attribute_error(self): with self.assertRaises(AttributeError): self.a1.firstname with self.assertRaises(AttributeError): self.a1.last def test_get_all_authors_for_an_article(self): self.assertQuerysetEqual( self.article.authors.all(), [ "Peter Jones", "John Smith", ], str ) def test_get_all_articles_for_an_author(self): self.assertQuerysetEqual( self.a1.article_set.all(), [ "Django lets you build Web apps easily", ], lambda a: a.headline ) def test_get_author_m2m_relation(self): self.assertQuerysetEqual( self.article.authors.filter(last_name='Jones'), [ "Peter Jones" ], str ) def test_author_querying(self): self.assertQuerysetEqual( Author.objects.all().order_by('last_name'), ['<Author: Peter Jones>', '<Author: John Smith>'] ) def test_author_filtering(self): self.assertQuerysetEqual( Author.objects.filter(first_name__exact='John'), ['<Author: John Smith>'] ) def test_author_get(self): self.assertEqual(self.a1, Author.objects.get(first_name__exact='John')) def test_filter_on_nonexistent_field(self): msg = ( "Cannot resolve keyword 'firstname' into field. Choices are: " "Author_ID, article, first_name, last_name, primary_set" ) with self.assertRaisesMessage(FieldError, msg): Author.objects.filter(firstname__exact='John') def test_author_get_attributes(self): a = Author.objects.get(last_name__exact='Smith') self.assertEqual('John', a.first_name) self.assertEqual('Smith', a.last_name) with self.assertRaisesMessage(AttributeError, "'Author' object has no attribute 'firstname'"): getattr(a, 'firstname') with self.assertRaisesMessage(AttributeError, "'Author' object has no attribute 'last'"): getattr(a, 'last') def test_m2m_table(self): self.assertQuerysetEqual( self.article.authors.all().order_by('last_name'), ['<Author: Peter Jones>', '<Author: John Smith>'] ) self.assertQuerysetEqual( self.a1.article_set.all(), ['<Article: Django lets you build Web apps easily>'] ) self.assertQuerysetEqual( self.article.authors.filter(last_name='Jones'), ['<Author: Peter Jones>'] )
bsd-3-clause
[ 504, 1639, 14, 1018, 14, 3924, 492, 27691, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1275, 992, 492, 8281, 12, 6529, 421, 199, 533, 8388, 15086, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 65, 17, 275, 6529, 14, 1462, 14, 981, 8, 2246, 63, 354, 628, 12923, 401, 2061, 63, 354, 628, 16782, 448, 531, 267, 291, 14, 65, 18, 275, 6529, 14, 1462, 14, 981, 8, 2246, 63, 354, 628, 8070, 351, 401, 2061, 63, 354, 628, 42, 4548, 531, 267, 291, 14, 8149, 275, 359, 277, 14, 65, 17, 12, 291, 14, 65, 18, 61, 398, 291, 14, 6934, 275, 8281, 14, 1462, 14, 981, 8, 11268, 628, 9323, 19083, 1265, 1900, 6001, 8686, 16174, 401, 5062, 63, 2502, 29, 277, 14, 65, 17, 9, 267, 291, 14, 6934, 14, 8149, 14, 409, 8, 277, 14, 8149, 9, 339, 347, 511, 63, 1131, 63, 452, 63, 4561, 63, 8149, 8, 277, 304, 267, 291, 14, 7108, 8, 288, 6529, 14, 1462, 14, 452, 1062, 359, 355, 298, 8070, 351, 1603, 4548, 401, 298, 12923, 25924, 401, 288, 2156, 288, 620, 267, 776, 339, 347, 511, 63, 362, 63, 2246, 63, 354, 8, 277, 304, 267, 291, 14, 629, 8, 288, 6529, 14, 1462, 14, 362, 8, 2246, 63, 354, 363, 7327, 628, 12923, 1288, 288, 291, 14, 65, 17, 12, 267, 776, 339, 347, 511, 63, 1541, 63, 2246, 63, 354, 8, 277, 304, 267, 291, 14, 7108, 8, 288, 6529, 14, 1462, 14, 1541, 8, 2246, 63, 354, 363, 7327, 628, 12923, 1288, 359, 355, 298, 12923, 25924, 401, 288, 2156, 288, 620, 267, 776, 339, 347, 511, 63, 698, 63, 705, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 792, 547, 304, 288, 6529, 14, 1462, 14, 1541, 8, 25603, 363, 7327, 628, 12923, 531, 339, 347, 511, 63, 3215, 63, 705, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 10227, 304, 288, 291, 14, 65, 17, 14, 25603, 398, 543, 291, 14, 1855, 8, 10227, 304, 288, 291, 14, 65, 17, 14, 2019, 339, 347, 511, 63, 362, 63, 452, 63, 8149, 63, 509, 63, 290, 63, 6934, 8, 277, 304, 267, 291, 14, 7108, 8, 288, 291, 14, 6934, 14, 8149, 14, 452, 1062, 359, 355, 298, 8070, 351, 1603, 4548, 401, 355, 298, 12923, 25924, 401, 288, 2156, 288, 620, 267, 776, 339, 347, 511, 63, 362, 63, 452, 63, 19813, 63, 509, 63, 290, 63, 2502, 8, 277, 304, 267, 291, 14, 7108, 8, 288, 291, 14, 65, 17, 14, 6934, 63, 409, 14, 452, 1062, 359, 355, 298, 9323, 19083, 1265, 1900, 6001, 8686, 16174, 401, 288, 2156, 288, 2400, 282, 26, 282, 14, 11268, 267, 776, 339, 347, 511, 63, 362, 63, 2502, 63, 77, 18, 77, 63, 5690, 8, 277, 304, 267, 291, 14, 7108, 8, 288, 291, 14, 6934, 14, 8149, 14, 1541, 8, 2019, 63, 354, 534, 42, 4548, 659, 359, 355, 298, 8070, 351, 1603, 4548, 2, 288, 2156, 288, 620, 267, 776, 339, 347, 511, 63, 2502, 63, 1131, 316, 8, 277, 304, 267, 291, 14, 7108, 8, 288, 6529, 14, 1462, 14, 452, 1252, 1648, 63, 991, 360, 2019, 63, 354, 659, 288, 12329, 5949, 26, 22912, 1603, 4548, 4206, 2650, 5949, 26, 17815, 25924, 18763, 267, 776, 339, 347, 511, 63, 2502, 63, 24133, 8, 277, 304, 267, 291, 14, 7108, 8, 288, 6529, 14, 1462, 14, 1541, 8, 2246, 63, 354, 363, 7327, 534, 12923, 659, 288, 12329, 5949, 26, 17815, 25924, 18763, 267, 776, 339, 347, 511, 63, 2502, 63, 362, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 65, 17, 12, 6529, 14, 1462, 14, 362, 8, 2246, 63, 354, 363, 7327, 534, 12923, 1333, 339, 347, 511, 63, 1541, 63, 265, 63, 21573, 63, 698, 8, 277, 304, 267, 1499, 275, 334, 288, 298, 6612, 7512, 4252, 283, 25603, 7, 1901, 901, 14, 8802, 2370, 787, 26, 298, 288, 298, 5949, 63, 998, 12, 9772, 12, 1642, 63, 354, 12, 2061, 63, 354, 12, 5062, 63, 409, 2, 267, 776, 267, 543, 291, 14, 14638, 8, 792, 547, 12, 1499, 304, 288, 6529, 14, 1462, 14, 1541, 8, 25603, 363, 7327, 534, 12923, 358, 339, 347, 511, 63, 2502, 63, 362, 63, 2987, 8, 277, 304, 267, 282, 275, 6529, 14, 1462, 14, 362, 8, 2019, 63, 354, 363, 7327, 534, 16782, 448, 358, 267, 291, 14, 629, 360, 12923, 297, 282, 14, 2246, 63, 354, 9, 267, 291, 14, 629, 360, 16782, 448, 297, 282, 14, 2019, 63, 354, 9, 267, 543, 291, 14, 14638, 8, 10227, 12, 3546, 5949, 7, 909, 965, 949, 2225, 283, 25603, 7, 2349, 288, 2519, 8, 65, 12, 283, 25603, 358, 398, 543, 291, 14, 14638, 8, 10227, 12, 3546, 5949, 7, 909, 965, 949, 2225, 283, 2019, 7, 2349, 288, 2519, 8, 65, 12, 283, 2019, 358, 339, 347, 511, 63, 77, 18, 77, 63, 1224, 8, 277, 304, 267, 291, 14, 7108, 8, 288, 291, 14, 6934, 14, 8149, 14, 452, 1252, 1648, 63, 991, 360, 2019, 63, 354, 659, 288, 12329, 5949, 26, 22912, 1603, 4548, 4206, 2650, 5949, 26, 17815, 25924, 18763, 267, 776, 267, 291, 14, 7108, 8, 288, 291, 14, 65, 17, 14, 6934, 63, 409, 14, 452, 1062, 288, 12329, 7221, 26, 5634, 19083, 1265, 1900, 6001, 8686, 16174, 18763, 267, 776, 267, 291, 14, 7108, 8, 288, 291, 14, 6934, 14, 8149, 14, 1541, 8, 2019, 63, 354, 534, 42, 4548, 659, 288, 12329, 5949, 26, 22912, 1603, 4548, 18763, 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 ]
[ 1639, 14, 1018, 14, 3924, 492, 27691, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1275, 992, 492, 8281, 12, 6529, 421, 199, 533, 8388, 15086, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 65, 17, 275, 6529, 14, 1462, 14, 981, 8, 2246, 63, 354, 628, 12923, 401, 2061, 63, 354, 628, 16782, 448, 531, 267, 291, 14, 65, 18, 275, 6529, 14, 1462, 14, 981, 8, 2246, 63, 354, 628, 8070, 351, 401, 2061, 63, 354, 628, 42, 4548, 531, 267, 291, 14, 8149, 275, 359, 277, 14, 65, 17, 12, 291, 14, 65, 18, 61, 398, 291, 14, 6934, 275, 8281, 14, 1462, 14, 981, 8, 11268, 628, 9323, 19083, 1265, 1900, 6001, 8686, 16174, 401, 5062, 63, 2502, 29, 277, 14, 65, 17, 9, 267, 291, 14, 6934, 14, 8149, 14, 409, 8, 277, 14, 8149, 9, 339, 347, 511, 63, 1131, 63, 452, 63, 4561, 63, 8149, 8, 277, 304, 267, 291, 14, 7108, 8, 288, 6529, 14, 1462, 14, 452, 1062, 359, 355, 298, 8070, 351, 1603, 4548, 401, 298, 12923, 25924, 401, 288, 2156, 288, 620, 267, 776, 339, 347, 511, 63, 362, 63, 2246, 63, 354, 8, 277, 304, 267, 291, 14, 629, 8, 288, 6529, 14, 1462, 14, 362, 8, 2246, 63, 354, 363, 7327, 628, 12923, 1288, 288, 291, 14, 65, 17, 12, 267, 776, 339, 347, 511, 63, 1541, 63, 2246, 63, 354, 8, 277, 304, 267, 291, 14, 7108, 8, 288, 6529, 14, 1462, 14, 1541, 8, 2246, 63, 354, 363, 7327, 628, 12923, 1288, 359, 355, 298, 12923, 25924, 401, 288, 2156, 288, 620, 267, 776, 339, 347, 511, 63, 698, 63, 705, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 792, 547, 304, 288, 6529, 14, 1462, 14, 1541, 8, 25603, 363, 7327, 628, 12923, 531, 339, 347, 511, 63, 3215, 63, 705, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 10227, 304, 288, 291, 14, 65, 17, 14, 25603, 398, 543, 291, 14, 1855, 8, 10227, 304, 288, 291, 14, 65, 17, 14, 2019, 339, 347, 511, 63, 362, 63, 452, 63, 8149, 63, 509, 63, 290, 63, 6934, 8, 277, 304, 267, 291, 14, 7108, 8, 288, 291, 14, 6934, 14, 8149, 14, 452, 1062, 359, 355, 298, 8070, 351, 1603, 4548, 401, 355, 298, 12923, 25924, 401, 288, 2156, 288, 620, 267, 776, 339, 347, 511, 63, 362, 63, 452, 63, 19813, 63, 509, 63, 290, 63, 2502, 8, 277, 304, 267, 291, 14, 7108, 8, 288, 291, 14, 65, 17, 14, 6934, 63, 409, 14, 452, 1062, 359, 355, 298, 9323, 19083, 1265, 1900, 6001, 8686, 16174, 401, 288, 2156, 288, 2400, 282, 26, 282, 14, 11268, 267, 776, 339, 347, 511, 63, 362, 63, 2502, 63, 77, 18, 77, 63, 5690, 8, 277, 304, 267, 291, 14, 7108, 8, 288, 291, 14, 6934, 14, 8149, 14, 1541, 8, 2019, 63, 354, 534, 42, 4548, 659, 359, 355, 298, 8070, 351, 1603, 4548, 2, 288, 2156, 288, 620, 267, 776, 339, 347, 511, 63, 2502, 63, 1131, 316, 8, 277, 304, 267, 291, 14, 7108, 8, 288, 6529, 14, 1462, 14, 452, 1252, 1648, 63, 991, 360, 2019, 63, 354, 659, 288, 12329, 5949, 26, 22912, 1603, 4548, 4206, 2650, 5949, 26, 17815, 25924, 18763, 267, 776, 339, 347, 511, 63, 2502, 63, 24133, 8, 277, 304, 267, 291, 14, 7108, 8, 288, 6529, 14, 1462, 14, 1541, 8, 2246, 63, 354, 363, 7327, 534, 12923, 659, 288, 12329, 5949, 26, 17815, 25924, 18763, 267, 776, 339, 347, 511, 63, 2502, 63, 362, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 65, 17, 12, 6529, 14, 1462, 14, 362, 8, 2246, 63, 354, 363, 7327, 534, 12923, 1333, 339, 347, 511, 63, 1541, 63, 265, 63, 21573, 63, 698, 8, 277, 304, 267, 1499, 275, 334, 288, 298, 6612, 7512, 4252, 283, 25603, 7, 1901, 901, 14, 8802, 2370, 787, 26, 298, 288, 298, 5949, 63, 998, 12, 9772, 12, 1642, 63, 354, 12, 2061, 63, 354, 12, 5062, 63, 409, 2, 267, 776, 267, 543, 291, 14, 14638, 8, 792, 547, 12, 1499, 304, 288, 6529, 14, 1462, 14, 1541, 8, 25603, 363, 7327, 534, 12923, 358, 339, 347, 511, 63, 2502, 63, 362, 63, 2987, 8, 277, 304, 267, 282, 275, 6529, 14, 1462, 14, 362, 8, 2019, 63, 354, 363, 7327, 534, 16782, 448, 358, 267, 291, 14, 629, 360, 12923, 297, 282, 14, 2246, 63, 354, 9, 267, 291, 14, 629, 360, 16782, 448, 297, 282, 14, 2019, 63, 354, 9, 267, 543, 291, 14, 14638, 8, 10227, 12, 3546, 5949, 7, 909, 965, 949, 2225, 283, 25603, 7, 2349, 288, 2519, 8, 65, 12, 283, 25603, 358, 398, 543, 291, 14, 14638, 8, 10227, 12, 3546, 5949, 7, 909, 965, 949, 2225, 283, 2019, 7, 2349, 288, 2519, 8, 65, 12, 283, 2019, 358, 339, 347, 511, 63, 77, 18, 77, 63, 1224, 8, 277, 304, 267, 291, 14, 7108, 8, 288, 291, 14, 6934, 14, 8149, 14, 452, 1252, 1648, 63, 991, 360, 2019, 63, 354, 659, 288, 12329, 5949, 26, 22912, 1603, 4548, 4206, 2650, 5949, 26, 17815, 25924, 18763, 267, 776, 267, 291, 14, 7108, 8, 288, 291, 14, 65, 17, 14, 6934, 63, 409, 14, 452, 1062, 288, 12329, 7221, 26, 5634, 19083, 1265, 1900, 6001, 8686, 16174, 18763, 267, 776, 267, 291, 14, 7108, 8, 288, 291, 14, 6934, 14, 8149, 14, 1541, 8, 2019, 63, 354, 534, 42, 4548, 659, 288, 12329, 5949, 26, 22912, 1603, 4548, 18763, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
gibiansky/tensorflow
tensorflow/python/ops/nn.py
2
11979
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================= # pylint: disable=unused-import,g-bad-import-order """## Activation Functions. The activation ops provide different types of nonlinearities for use in neural networks. These include smooth nonlinearities (`sigmoid`, `tanh`, `elu`, `softplus`, and `softsign`), continuous but not everywhere differentiable functions (`relu`, `relu6`, `crelu` and `relu_x`), and random regularization (`dropout`). All activation ops apply componentwise, and produce a tensor of the same shape as the input tensor. @@relu @@relu6 @@crelu @@elu @@softplus @@softsign @@dropout @@bias_add @@sigmoid @@tanh ## Convolution The convolution ops sweep a 2-D filter over a batch of images, applying the filter to each window of each image of the appropriate size. The different ops trade off between generic vs. specific filters: * `conv2d`: Arbitrary filters that can mix channels together. * `depthwise_conv2d`: Filters that operate on each channel independently. * `separable_conv2d`: A depthwise spatial filter followed by a pointwise filter. Note that although these ops are called "convolution", they are strictly speaking "cross-correlation" since the filter is combined with an input window without reversing the filter. For details, see [the properties of cross-correlation](https://en.wikipedia.org/wiki/Cross-correlation#Properties). The filter is applied to image patches of the same size as the filter and strided according to the `strides` argument. `strides = [1, 1, 1, 1]` applies the filter to a patch at every offset, `strides = [1, 2, 2, 1]` applies the filter to every other image patch in each dimension, etc. Ignoring channels for the moment, and assume that the 4-D `input` has shape `[batch, in_height, in_width, ...]` and the 4-D `filter` has shape `[filter_height, filter_width, ...]`, then the spatial semantics of the convolution ops are as follows: first, according to the padding scheme chosen as `'SAME'` or `'VALID'`, the output size and the padding pixels are computed. For the `'SAME'` padding, the output height and width are computed as: out_height = ceil(float(in_height) / float(strides[1])) out_width = ceil(float(in_width) / float(strides[2])) and the padding on the top and left are computed as: pad_along_height = max((out_height - 1) * strides[1] + filter_height - in_height, 0) pad_along_width = max((out_width - 1) * strides[2] + filter_width - in_width, 0) pad_top = pad_along_height // 2 pad_bottom = pad_along_height - pad_top pad_left = pad_along_width // 2 pad_right = pad_along_width - pad_left Note that the division by 2 means that there might be cases when the padding on both sides (top vs bottom, right vs left) are off by one. In this case, the bottom and right sides always get the one additional padded pixel. For example, when `pad_along_height` is 5, we pad 2 pixels at the top and 3 pixels at the bottom. Note that this is different from existing libraries such as cuDNN and Caffe, which explicitly specify the number of padded pixels and always pad the same number of pixels on both sides. For the `'VALID`' padding, the output height and width are computed as: out_height = ceil(float(in_height - filter_height + 1) / float(strides[1])) out_width = ceil(float(in_width - filter_width + 1) / float(strides[2])) and the padding values are always zero. The output is then computed as output[b, i, j, :] = sum_{di, dj} input[b, strides[1] * i + di - pad_top, strides[2] * j + dj - pad_left, ...] * filter[di, dj, ...] where any value outside the original input image region are considered zero ( i.e. we pad zero values around the border of the image). Since `input` is 4-D, each `input[b, i, j, :]` is a vector. For `conv2d`, these vectors are multiplied by the `filter[di, dj, :, :]` matrices to produce new vectors. For `depthwise_conv_2d`, each scalar component `input[b, i, j, k]` is multiplied by a vector `filter[di, dj, k]`, and all the vectors are concatenated. @@convolution @@conv2d @@depthwise_conv2d @@depthwise_conv2d_native @@separable_conv2d @@atrous_conv2d @@atrous_conv2d_transpose @@conv2d_transpose @@conv1d @@conv3d @@conv3d_transpose @@conv2d_backprop_filter @@conv2d_backprop_input @@conv3d_backprop_filter_v2 @@depthwise_conv2d_native_backprop_filter @@depthwise_conv2d_native_backprop_input ## Pooling The pooling ops sweep a rectangular window over the input tensor, computing a reduction operation for each window (average, max, or max with argmax). Each pooling op uses rectangular windows of size `ksize` separated by offset `strides`. For example, if `strides` is all ones every window is used, if `strides` is all twos every other window is used in each dimension, etc. In detail, the output is output[i] = reduce(value[strides * i:strides * i + ksize]) where the indices also take into consideration the padding values. Please refer to the `Convolution` section for details about the padding calculation. @@avg_pool @@max_pool @@max_pool_with_argmax @@avg_pool3d @@max_pool3d @@fractional_avg_pool @@fractional_max_pool @@pool ## Morphological filtering Morphological operators are non-linear filters used in image processing. [Greyscale morphological dilation ](https://en.wikipedia.org/wiki/Dilation_(morphology)) is the max-sum counterpart of standard sum-product convolution: output[b, y, x, c] = max_{dy, dx} input[b, strides[1] * y + rates[1] * dy, strides[2] * x + rates[2] * dx, c] + filter[dy, dx, c] The `filter` is usually called structuring function. Max-pooling is a special case of greyscale morphological dilation when the filter assumes all-zero values (a.k.a. flat structuring function). [Greyscale morphological erosion ](https://en.wikipedia.org/wiki/Erosion_(morphology)) is the min-sum counterpart of standard sum-product convolution: output[b, y, x, c] = min_{dy, dx} input[b, strides[1] * y - rates[1] * dy, strides[2] * x - rates[2] * dx, c] - filter[dy, dx, c] Dilation and erosion are dual to each other. The dilation of the input signal `f` by the structuring signal `g` is equal to the negation of the erosion of `-f` by the reflected `g`, and vice versa. Striding and padding is carried out in exactly the same way as in standard convolution. Please refer to the `Convolution` section for details. @@dilation2d @@erosion2d @@with_space_to_batch ## Normalization Normalization is useful to prevent neurons from saturating when inputs may have varying scale, and to aid generalization. @@l2_normalize @@local_response_normalization @@sufficient_statistics @@normalize_moments @@moments @@weighted_moments @@fused_batch_norm @@batch_normalization @@batch_norm_with_global_normalization ## Losses The loss ops measure error between two tensors, or between a tensor and zero. These can be used for measuring accuracy of a network in a regression task or for regularization purposes (weight decay). @@l2_loss @@log_poisson_loss ## Classification TensorFlow provides several operations that help you perform classification. @@sigmoid_cross_entropy_with_logits @@softmax @@log_softmax @@softmax_cross_entropy_with_logits @@sparse_softmax_cross_entropy_with_logits @@weighted_cross_entropy_with_logits ## Embeddings TensorFlow provides library support for looking up values in embedding tensors. @@embedding_lookup @@embedding_lookup_sparse ## Recurrent Neural Networks TensorFlow provides a number of methods for constructing Recurrent Neural Networks. Most accept an `RNNCell`-subclassed object (see the documentation for `tf.contrib.rnn`). @@dynamic_rnn @@rnn @@state_saving_rnn @@bidirectional_dynamic_rnn @@bidirectional_rnn @@raw_rnn ## Connectionist Temporal Classification (CTC) @@ctc_loss @@ctc_greedy_decoder @@ctc_beam_search_decoder ## Evaluation The evaluation ops are useful for measuring the performance of a network. They are typically used at evaluation time. @@top_k @@in_top_k ## Candidate Sampling Do you want to train a multiclass or multilabel model with thousands or millions of output classes (for example, a language model with a large vocabulary)? Training with a full Softmax is slow in this case, since all of the classes are evaluated for every training example. Candidate Sampling training algorithms can speed up your step times by only considering a small randomly-chosen subset of contrastive classes (called candidates) for each batch of training examples. See our [Candidate Sampling Algorithms Reference](../../extras/candidate_sampling.pdf) ### Sampled Loss Functions TensorFlow provides the following sampled loss functions for faster training. @@nce_loss @@sampled_softmax_loss ### Candidate Samplers TensorFlow provides the following samplers for randomly sampling candidate classes when using one of the sampled loss functions above. @@uniform_candidate_sampler @@log_uniform_candidate_sampler @@learned_unigram_candidate_sampler @@fixed_unigram_candidate_sampler ### Miscellaneous candidate sampling utilities @@compute_accidental_hits ### Quantization ops @@quantized_conv2d @@quantized_relu_x @@quantized_max_pool @@quantized_avg_pool """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import sys as _sys # pylint: disable=unused-import from tensorflow.python.ops import ctc_ops as _ctc_ops from tensorflow.python.ops import embedding_ops as _embedding_ops from tensorflow.python.ops import nn_grad as _nn_grad from tensorflow.python.ops import nn_ops as _nn_ops from tensorflow.python.ops import rnn_cell from tensorflow.python.ops.math_ops import sigmoid from tensorflow.python.ops.math_ops import tanh # pylint: enable=unused-import from tensorflow.python.util.all_util import remove_undocumented # Bring more nn-associated functionality into this package. # go/tf-wildcard-import # pylint: disable=wildcard-import from tensorflow.python.ops.ctc_ops import * from tensorflow.python.ops.nn_impl import * from tensorflow.python.ops.nn_ops import * from tensorflow.python.ops.candidate_sampling_ops import * from tensorflow.python.ops.embedding_ops import * from tensorflow.python.ops.rnn import * # pylint: enable=wildcard-import # TODO(cwhipkey): sigmoid and tanh should not be exposed from tf.nn. _allowed_symbols = [ "zero_fraction", # documented in training.py # Modules whitelisted for reference through tf.nn. # TODO(cwhipkey): migrate callers to use the submodule directly. "rnn_cell", # Symbols whitelisted for export without documentation. # TODO(cwhipkey): review these and move to contrib or expose through # documentation. "all_candidate_sampler", # Excluded in gen_docs_combined. "lrn", # Excluded in gen_docs_combined. "relu_layer", # Excluded in gen_docs_combined. "xw_plus_b", # Excluded in gen_docs_combined. ] remove_undocumented(__name__, _allowed_symbols, [_sys.modules[__name__], _ctc_ops, _nn_ops, _nn_grad, rnn_cell])
apache-2.0
[ 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 26237, 199, 199, 3, 4287, 26, 3507, 29, 8618, 13, 646, 12, 71, 13, 4087, 13, 646, 13, 1648, 199, 624, 309, 29441, 17471, 14, 199, 199, 1918, 10361, 4156, 5647, 3365, 2943, 402, 2222, 604, 27894, 367, 675, 315, 1279, 4889, 199, 7642, 14, 221, 5723, 2387, 19608, 2222, 604, 27894, 13493, 20035, 3559, 658, 21468, 3559, 658, 352, 85, 3559, 199, 64, 1152, 8915, 24879, 3559, 436, 658, 4617, 1037, 29984, 19922, 1325, 440, 4036, 4509, 26796, 461, 199, 5777, 13493, 12833, 3559, 658, 12833, 22, 3559, 658, 1353, 10836, 64, 436, 658, 12833, 63, 88, 29984, 436, 2196, 21095, 199, 8, 64, 17953, 14963, 199, 199, 2422, 10361, 4156, 4838, 3931, 2605, 12, 436, 7389, 282, 2345, 402, 314, 2011, 199, 1392, 465, 314, 1324, 2345, 14, 199, 199, 7492, 12833, 199, 7492, 12833, 22, 199, 7492, 1353, 10836, 199, 7492, 352, 85, 199, 7492, 1152, 8915, 24879, 199, 7492, 4617, 1037, 199, 7492, 17953, 199, 7492, 8160, 63, 525, 199, 7492, 20035, 199, 7492, 21468, 199, 199, 309, 19140, 3347, 199, 199, 1918, 17461, 4156, 5584, 7840, 282, 499, 13, 36, 2457, 1806, 282, 3522, 402, 5935, 12, 18876, 314, 199, 1541, 370, 1924, 4353, 402, 1924, 1834, 402, 314, 5827, 1568, 14, 221, 710, 3365, 199, 1483, 21032, 2331, 3382, 7809, 8118, 14, 2488, 4766, 26, 199, 199, 10, 658, 5598, 18, 68, 8340, 1952, 8734, 4766, 626, 883, 13667, 9245, 10451, 14, 199, 10, 658, 4631, 2605, 63, 5598, 18, 68, 8340, 21240, 626, 19218, 641, 1924, 3623, 30426, 14, 199, 10, 658, 6175, 461, 63, 5598, 18, 68, 8340, 437, 5818, 2605, 11469, 2457, 9437, 701, 282, 2376, 2605, 2457, 14, 199, 199, 7443, 626, 22160, 3520, 4156, 787, 2797, 298, 27625, 401, 2985, 787, 22699, 199, 31258, 316, 298, 7925, 13, 26487, 2, 3967, 314, 2457, 365, 12149, 543, 376, 1324, 4353, 199, 7395, 29465, 1044, 314, 2457, 14, 221, 2104, 2436, 12, 1937, 359, 1589, 4382, 402, 199, 7925, 13, 26487, 8738, 2859, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 14072, 13, 26487, 3, 8516, 680, 199, 199, 1918, 2457, 365, 6781, 370, 1834, 12385, 402, 314, 2011, 1568, 465, 314, 2457, 436, 199, 816, 770, 7182, 370, 314, 658, 16759, 64, 1423, 14, 221, 658, 16759, 275, 359, 17, 12, 413, 12, 413, 12, 413, 16090, 12966, 199, 1589, 2457, 370, 282, 3371, 737, 4036, 3268, 12, 658, 16759, 275, 359, 17, 12, 499, 12, 499, 12, 413, 16090, 12966, 314, 199, 1541, 370, 4036, 1163, 1834, 3371, 315, 1924, 6240, 12, 5423, 14, 199, 199, 32390, 9245, 367, 314, 12427, 12, 436, 5534, 626, 314, 841, 13, 36, 658, 1210, 64, 965, 2215, 199, 64, 59, 2912, 12, 315, 63, 3333, 12, 315, 63, 2063, 12, 2263, 16090, 436, 314, 841, 13, 36, 658, 1541, 64, 965, 2215, 199, 64, 59, 1541, 63, 3333, 12, 2457, 63, 2063, 12, 21214, 3559, 2066, 314, 11469, 19002, 402, 314, 199, 27625, 4156, 787, 465, 11924, 26, 1642, 12, 7182, 370, 314, 6273, 5687, 12414, 199, 305, 658, 7, 19935, 7, 64, 503, 658, 7, 5600, 7, 3559, 314, 1072, 1568, 436, 314, 6273, 11094, 787, 9235, 14, 199, 1858, 314, 658, 7, 19935, 7, 64, 6273, 12, 314, 1072, 4569, 436, 3462, 787, 9235, 465, 26, 339, 734, 63, 3333, 275, 30449, 8, 1609, 8, 262, 63, 3333, 9, 1182, 2069, 8, 16759, 59, 17, 2459, 272, 734, 63, 2063, 221, 275, 30449, 8, 1609, 8, 262, 63, 2063, 9, 1182, 2069, 8, 16759, 59, 18, 2459, 199, 199, 460, 314, 6273, 641, 314, 2746, 436, 3602, 787, 9235, 465, 26, 339, 6567, 63, 21632, 63, 3333, 275, 1390, 1332, 548, 63, 3333, 446, 413, 9, 627, 11883, 59, 17, 61, 435, 717, 2457, 63, 3333, 446, 315, 63, 3333, 12, 378, 9, 272, 6567, 63, 21632, 63, 2063, 275, 1390, 1332, 548, 63, 2063, 446, 413, 9, 627, 11883, 59, 18, 61, 435, 2432, 2457, 63, 2063, 446, 315, 63, 2063, 12, 378, 9, 272, 6567, 63, 2119, 275, 6567, 63, 21632, 63, 3333, 5001, 499, 272, 6567, 63, 8305, 275, 6567, 63, 21632, 63, 3333, 446, 6567, 63, 2119, 272, 6567, 63, 3039, 275, 6567, 63, 21632, 63, 2063, 5001, 499, 272, 6567, 63, 1019, 275, 6567, 63, 21632, 63, 2063, 446, 6567, 63, 3039, 421, 199, 7443, 626, 314, 4629, 701, 499, 4910, 626, 2337, 5594, 506, 5560, 1380, 314, 6273, 641, 199, 10727, 27613, 334, 2119, 8118, 9048, 12, 2451, 8118, 3602, 9, 787, 2331, 701, 1373, 14, 1010, 642, 1930, 12, 314, 199, 8305, 436, 2451, 27613, 3544, 664, 314, 1373, 4722, 21824, 7148, 14, 2104, 2893, 12, 199, 6526, 658, 6226, 63, 21632, 63, 3333, 64, 365, 959, 12, 781, 6567, 499, 11094, 737, 314, 2746, 436, 650, 11094, 737, 314, 199, 8305, 14, 3390, 626, 642, 365, 3365, 687, 3411, 8363, 4066, 465, 286, 18867, 7178, 436, 199, 3630, 2026, 12, 1314, 7662, 4165, 314, 1329, 402, 21824, 11094, 436, 3544, 6567, 314, 199, 7191, 1329, 402, 11094, 641, 3865, 27613, 14, 199, 199, 1858, 314, 658, 7, 5600, 19097, 6273, 12, 314, 1072, 4569, 436, 3462, 787, 9235, 465, 26, 339, 734, 63, 3333, 275, 30449, 8, 1609, 8, 262, 63, 3333, 446, 2457, 63, 3333, 435, 413, 9, 1182, 2069 ]
[ 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 26237, 199, 199, 3, 4287, 26, 3507, 29, 8618, 13, 646, 12, 71, 13, 4087, 13, 646, 13, 1648, 199, 624, 309, 29441, 17471, 14, 199, 199, 1918, 10361, 4156, 5647, 3365, 2943, 402, 2222, 604, 27894, 367, 675, 315, 1279, 4889, 199, 7642, 14, 221, 5723, 2387, 19608, 2222, 604, 27894, 13493, 20035, 3559, 658, 21468, 3559, 658, 352, 85, 3559, 199, 64, 1152, 8915, 24879, 3559, 436, 658, 4617, 1037, 29984, 19922, 1325, 440, 4036, 4509, 26796, 461, 199, 5777, 13493, 12833, 3559, 658, 12833, 22, 3559, 658, 1353, 10836, 64, 436, 658, 12833, 63, 88, 29984, 436, 2196, 21095, 199, 8, 64, 17953, 14963, 199, 199, 2422, 10361, 4156, 4838, 3931, 2605, 12, 436, 7389, 282, 2345, 402, 314, 2011, 199, 1392, 465, 314, 1324, 2345, 14, 199, 199, 7492, 12833, 199, 7492, 12833, 22, 199, 7492, 1353, 10836, 199, 7492, 352, 85, 199, 7492, 1152, 8915, 24879, 199, 7492, 4617, 1037, 199, 7492, 17953, 199, 7492, 8160, 63, 525, 199, 7492, 20035, 199, 7492, 21468, 199, 199, 309, 19140, 3347, 199, 199, 1918, 17461, 4156, 5584, 7840, 282, 499, 13, 36, 2457, 1806, 282, 3522, 402, 5935, 12, 18876, 314, 199, 1541, 370, 1924, 4353, 402, 1924, 1834, 402, 314, 5827, 1568, 14, 221, 710, 3365, 199, 1483, 21032, 2331, 3382, 7809, 8118, 14, 2488, 4766, 26, 199, 199, 10, 658, 5598, 18, 68, 8340, 1952, 8734, 4766, 626, 883, 13667, 9245, 10451, 14, 199, 10, 658, 4631, 2605, 63, 5598, 18, 68, 8340, 21240, 626, 19218, 641, 1924, 3623, 30426, 14, 199, 10, 658, 6175, 461, 63, 5598, 18, 68, 8340, 437, 5818, 2605, 11469, 2457, 9437, 701, 282, 2376, 2605, 2457, 14, 199, 199, 7443, 626, 22160, 3520, 4156, 787, 2797, 298, 27625, 401, 2985, 787, 22699, 199, 31258, 316, 298, 7925, 13, 26487, 2, 3967, 314, 2457, 365, 12149, 543, 376, 1324, 4353, 199, 7395, 29465, 1044, 314, 2457, 14, 221, 2104, 2436, 12, 1937, 359, 1589, 4382, 402, 199, 7925, 13, 26487, 8738, 2859, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 14072, 13, 26487, 3, 8516, 680, 199, 199, 1918, 2457, 365, 6781, 370, 1834, 12385, 402, 314, 2011, 1568, 465, 314, 2457, 436, 199, 816, 770, 7182, 370, 314, 658, 16759, 64, 1423, 14, 221, 658, 16759, 275, 359, 17, 12, 413, 12, 413, 12, 413, 16090, 12966, 199, 1589, 2457, 370, 282, 3371, 737, 4036, 3268, 12, 658, 16759, 275, 359, 17, 12, 499, 12, 499, 12, 413, 16090, 12966, 314, 199, 1541, 370, 4036, 1163, 1834, 3371, 315, 1924, 6240, 12, 5423, 14, 199, 199, 32390, 9245, 367, 314, 12427, 12, 436, 5534, 626, 314, 841, 13, 36, 658, 1210, 64, 965, 2215, 199, 64, 59, 2912, 12, 315, 63, 3333, 12, 315, 63, 2063, 12, 2263, 16090, 436, 314, 841, 13, 36, 658, 1541, 64, 965, 2215, 199, 64, 59, 1541, 63, 3333, 12, 2457, 63, 2063, 12, 21214, 3559, 2066, 314, 11469, 19002, 402, 314, 199, 27625, 4156, 787, 465, 11924, 26, 1642, 12, 7182, 370, 314, 6273, 5687, 12414, 199, 305, 658, 7, 19935, 7, 64, 503, 658, 7, 5600, 7, 3559, 314, 1072, 1568, 436, 314, 6273, 11094, 787, 9235, 14, 199, 1858, 314, 658, 7, 19935, 7, 64, 6273, 12, 314, 1072, 4569, 436, 3462, 787, 9235, 465, 26, 339, 734, 63, 3333, 275, 30449, 8, 1609, 8, 262, 63, 3333, 9, 1182, 2069, 8, 16759, 59, 17, 2459, 272, 734, 63, 2063, 221, 275, 30449, 8, 1609, 8, 262, 63, 2063, 9, 1182, 2069, 8, 16759, 59, 18, 2459, 199, 199, 460, 314, 6273, 641, 314, 2746, 436, 3602, 787, 9235, 465, 26, 339, 6567, 63, 21632, 63, 3333, 275, 1390, 1332, 548, 63, 3333, 446, 413, 9, 627, 11883, 59, 17, 61, 435, 717, 2457, 63, 3333, 446, 315, 63, 3333, 12, 378, 9, 272, 6567, 63, 21632, 63, 2063, 275, 1390, 1332, 548, 63, 2063, 446, 413, 9, 627, 11883, 59, 18, 61, 435, 2432, 2457, 63, 2063, 446, 315, 63, 2063, 12, 378, 9, 272, 6567, 63, 2119, 275, 6567, 63, 21632, 63, 3333, 5001, 499, 272, 6567, 63, 8305, 275, 6567, 63, 21632, 63, 3333, 446, 6567, 63, 2119, 272, 6567, 63, 3039, 275, 6567, 63, 21632, 63, 2063, 5001, 499, 272, 6567, 63, 1019, 275, 6567, 63, 21632, 63, 2063, 446, 6567, 63, 3039, 421, 199, 7443, 626, 314, 4629, 701, 499, 4910, 626, 2337, 5594, 506, 5560, 1380, 314, 6273, 641, 199, 10727, 27613, 334, 2119, 8118, 9048, 12, 2451, 8118, 3602, 9, 787, 2331, 701, 1373, 14, 1010, 642, 1930, 12, 314, 199, 8305, 436, 2451, 27613, 3544, 664, 314, 1373, 4722, 21824, 7148, 14, 2104, 2893, 12, 199, 6526, 658, 6226, 63, 21632, 63, 3333, 64, 365, 959, 12, 781, 6567, 499, 11094, 737, 314, 2746, 436, 650, 11094, 737, 314, 199, 8305, 14, 3390, 626, 642, 365, 3365, 687, 3411, 8363, 4066, 465, 286, 18867, 7178, 436, 199, 3630, 2026, 12, 1314, 7662, 4165, 314, 1329, 402, 21824, 11094, 436, 3544, 6567, 314, 199, 7191, 1329, 402, 11094, 641, 3865, 27613, 14, 199, 199, 1858, 314, 658, 7, 5600, 19097, 6273, 12, 314, 1072, 4569, 436, 3462, 787, 9235, 465, 26, 339, 734, 63, 3333, 275, 30449, 8, 1609, 8, 262, 63, 3333, 446, 2457, 63, 3333, 435, 413, 9, 1182, 2069, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
synety-jdebp/rtpproxy
python/sippy_lite/sippy/Rtp_proxy_client_local.py
6
2202
# Copyright (c) 2003-2005 Maxim Sobolev. All rights reserved. # Copyright (c) 2006-2014 Sippy Software, Inc. All rights reserved. # # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation and/or # other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. from Rtp_proxy_client_stream import Rtp_proxy_client_stream import socket class Rtp_proxy_client_local(Rtp_proxy_client_stream): is_local = True def __init__(self, global_config, address = '/var/run/rtpproxy.sock', \ bind_address = None, nworkers = 1): Rtp_proxy_client_stream.__init__(self, global_config = global_config, \ address = address, bind_address = bind_address, nworkers = nworkers, \ family == socket.AF_UNIX) if __name__ == '__main__': from twisted.internet import reactor def display(*args): print args reactor.crash() r = Rtp_proxy_client_local({'_sip_address':'1.2.3.4'}) r.send_command('VF 123456', display, 'abcd') reactor.run(installSignalHandlers = 1) r.shutdown()
bsd-2-clause
[ 3, 1898, 334, 67, 9, 13004, 13, 9397, 8228, 1017, 2002, 656, 6972, 14, 2900, 4481, 4644, 14, 199, 3, 1898, 334, 67, 9, 8315, 13, 7280, 428, 711, 647, 2290, 12, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 7100, 12, 199, 3, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 199, 3, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 199, 3, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 436, 15, 269, 199, 3, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 6483, 6262, 7024, 2381, 199, 3, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 199, 3, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 199, 3, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 199, 3, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 504, 820, 683, 63, 3280, 63, 1258, 63, 1745, 492, 820, 683, 63, 3280, 63, 1258, 63, 1745, 199, 199, 646, 2838, 199, 199, 533, 820, 683, 63, 3280, 63, 1258, 63, 1832, 8, 50, 683, 63, 3280, 63, 1258, 63, 1745, 304, 272, 365, 63, 1832, 275, 715, 339, 347, 636, 826, 721, 277, 12, 2288, 63, 888, 12, 2287, 275, 1994, 1391, 15, 1065, 15, 82, 683, 3280, 14, 5096, 297, 971, 489, 5398, 63, 1562, 275, 488, 12, 302, 11009, 275, 413, 304, 267, 820, 683, 63, 3280, 63, 1258, 63, 1745, 855, 826, 721, 277, 12, 2288, 63, 888, 275, 2288, 63, 888, 12, 971, 881, 2287, 275, 2287, 12, 5398, 63, 1562, 275, 5398, 63, 1562, 12, 302, 11009, 275, 302, 11009, 12, 971, 881, 9614, 508, 2838, 14, 5699, 63, 19584, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 687, 7390, 14, 4901, 492, 9655, 272, 347, 2929, 2031, 589, 304, 267, 870, 1249, 267, 9655, 14, 14807, 342, 272, 519, 275, 820, 683, 63, 3280, 63, 1258, 63, 1832, 3252, 63, 17839, 63, 1562, 5242, 17, 14, 18, 14, 19, 14, 20, 3071, 272, 519, 14, 2254, 63, 1531, 360, 32364, 14763, 1367, 297, 2929, 12, 283, 13591, 358, 272, 9655, 14, 1065, 8, 3174, 11274, 25096, 275, 413, 9, 272, 519, 14, 8831, 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 ]
[ 1898, 334, 67, 9, 13004, 13, 9397, 8228, 1017, 2002, 656, 6972, 14, 2900, 4481, 4644, 14, 199, 3, 1898, 334, 67, 9, 8315, 13, 7280, 428, 711, 647, 2290, 12, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 7100, 12, 199, 3, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 199, 3, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 199, 3, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 436, 15, 269, 199, 3, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 6483, 6262, 7024, 2381, 199, 3, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 199, 3, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 199, 3, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 199, 3, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 504, 820, 683, 63, 3280, 63, 1258, 63, 1745, 492, 820, 683, 63, 3280, 63, 1258, 63, 1745, 199, 199, 646, 2838, 199, 199, 533, 820, 683, 63, 3280, 63, 1258, 63, 1832, 8, 50, 683, 63, 3280, 63, 1258, 63, 1745, 304, 272, 365, 63, 1832, 275, 715, 339, 347, 636, 826, 721, 277, 12, 2288, 63, 888, 12, 2287, 275, 1994, 1391, 15, 1065, 15, 82, 683, 3280, 14, 5096, 297, 971, 489, 5398, 63, 1562, 275, 488, 12, 302, 11009, 275, 413, 304, 267, 820, 683, 63, 3280, 63, 1258, 63, 1745, 855, 826, 721, 277, 12, 2288, 63, 888, 275, 2288, 63, 888, 12, 971, 881, 2287, 275, 2287, 12, 5398, 63, 1562, 275, 5398, 63, 1562, 12, 302, 11009, 275, 302, 11009, 12, 971, 881, 9614, 508, 2838, 14, 5699, 63, 19584, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 687, 7390, 14, 4901, 492, 9655, 272, 347, 2929, 2031, 589, 304, 267, 870, 1249, 267, 9655, 14, 14807, 342, 272, 519, 275, 820, 683, 63, 3280, 63, 1258, 63, 1832, 3252, 63, 17839, 63, 1562, 5242, 17, 14, 18, 14, 19, 14, 20, 3071, 272, 519, 14, 2254, 63, 1531, 360, 32364, 14763, 1367, 297, 2929, 12, 283, 13591, 358, 272, 9655, 14, 1065, 8, 3174, 11274, 25096, 275, 413, 9, 272, 519, 14, 8831, 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, 0 ]
[ 1, 1, 1, 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/tensorflow
tensorflow/python/kernel_tests/trace_op_test.py
9
2204
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy import tensorflow as tf class TraceTest(tf.test.TestCase): def setUp(self): x = numpy.random.seed(0) def traceOp(self, x, dtype, expected_ans, use_gpu=False): with self.test_session(use_gpu=use_gpu): tf_ans = tf.trace(x.astype(dtype)) out = tf_ans.eval() self.assertAllClose(out, expected_ans) def testEmptyTensor(self): x = numpy.array([]) self.assertRaises(ValueError, self.traceOp, x, numpy.float32, 0) def testRankOneTensor(self): x = numpy.array([1,2,3]) self.assertRaises(ValueError, self.traceOp, x, numpy.float32, 0) def testRankTwoIntTensor(self): x = numpy.array( [[1, 0, 0], [0, 2, 0], [0, 0, 3]]) expected_ans = 6 self.traceOp(x, numpy.int32, expected_ans) self.traceOp(x, numpy.int64, expected_ans) def testRankTwoFloatTensor(self): x = numpy.array( [[1.1, 0, 0], [0, 2.2, 0], [0, 0, 3.3]]) expected_ans = 6.6 self.traceOp(x, numpy.float32, expected_ans) self.traceOp(x, numpy.float64, expected_ans) def testRankThreeFloatTensor(self): x = numpy.random.rand(2, 2, 2) self.assertRaises(ValueError, self.traceOp, x, numpy.float32, 0) def testRankFourFloatTensor(self): x = numpy.random.rand(2, 2, 2, 2) self.assertRaises(ValueError, self.traceOp, x, numpy.float32, 0) if __name__ == "__main__": tf.test.main()
apache-2.0
[ 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 199, 646, 3228, 465, 2833, 421, 199, 533, 11680, 774, 8, 3249, 14, 396, 14, 1746, 304, 819, 347, 3613, 8, 277, 304, 272, 671, 275, 2680, 14, 2355, 14, 5176, 8, 16, 9, 819, 347, 3307, 4619, 8, 277, 12, 671, 12, 2152, 12, 1420, 63, 796, 12, 675, 63, 6477, 29, 797, 304, 272, 543, 291, 14, 396, 63, 1730, 8, 1180, 63, 6477, 29, 1180, 63, 6477, 304, 489, 2833, 63, 796, 275, 2833, 14, 3446, 8, 88, 14, 6041, 8, 2271, 430, 489, 734, 275, 2833, 63, 796, 14, 2579, 342, 272, 291, 14, 7260, 8, 548, 12, 1420, 63, 796, 9, 819, 347, 511, 4699, 3861, 8, 277, 304, 272, 671, 275, 2680, 14, 1144, 4157, 272, 291, 14, 1855, 8, 3393, 12, 291, 14, 3446, 4619, 12, 671, 12, 2680, 14, 1609, 708, 12, 378, 9, 819, 347, 511, 19486, 4395, 3861, 8, 277, 304, 272, 671, 275, 2680, 14, 1144, 779, 17, 12, 18, 12, 19, 566, 272, 291, 14, 1855, 8, 3393, 12, 291, 14, 3446, 4619, 12, 671, 12, 2680, 14, 1609, 708, 12, 378, 9, 819, 347, 511, 19486, 11467, 3241, 3861, 8, 277, 304, 272, 671, 275, 2680, 14, 1144, 8, 267, 3474, 17, 12, 378, 12, 378, 467, 268, 359, 16, 12, 499, 12, 378, 467, 268, 359, 16, 12, 378, 12, 650, 3934, 272, 1420, 63, 796, 275, 1227, 272, 291, 14, 3446, 4619, 8, 88, 12, 2680, 14, 442, 708, 12, 1420, 63, 796, 9, 272, 291, 14, 3446, 4619, 8, 88, 12, 2680, 14, 442, 772, 12, 1420, 63, 796, 9, 819, 347, 511, 19486, 11467, 5136, 3861, 8, 277, 304, 272, 671, 275, 2680, 14, 1144, 8, 267, 3474, 17, 14, 17, 12, 378, 12, 378, 467, 268, 359, 16, 12, 499, 14, 18, 12, 378, 467, 268, 359, 16, 12, 378, 12, 650, 14, 19, 3934, 272, 1420, 63, 796, 275, 1227, 14, 22, 272, 291, 14, 3446, 4619, 8, 88, 12, 2680, 14, 1609, 708, 12, 1420, 63, 796, 9, 272, 291, 14, 3446, 4619, 8, 88, 12, 2680, 14, 1609, 772, 12, 1420, 63, 796, 9, 819, 347, 511, 19486, 21485, 5136, 3861, 8, 277, 304, 272, 671, 275, 2680, 14, 2355, 14, 3759, 8, 18, 12, 499, 12, 499, 9, 272, 291, 14, 1855, 8, 3393, 12, 291, 14, 3446, 4619, 12, 671, 12, 2680, 14, 1609, 708, 12, 378, 9, 819, 347, 511, 19486, 24766, 5136, 3861, 8, 277, 304, 272, 671, 275, 2680, 14, 2355, 14, 3759, 8, 18, 12, 499, 12, 499, 12, 499, 9, 272, 291, 14, 1855, 8, 3393, 12, 291, 14, 3446, 4619, 12, 671, 12, 2680, 14, 1609, 708, 12, 378, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 523, 2833, 14, 396, 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 ]
[ 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 199, 646, 3228, 465, 2833, 421, 199, 533, 11680, 774, 8, 3249, 14, 396, 14, 1746, 304, 819, 347, 3613, 8, 277, 304, 272, 671, 275, 2680, 14, 2355, 14, 5176, 8, 16, 9, 819, 347, 3307, 4619, 8, 277, 12, 671, 12, 2152, 12, 1420, 63, 796, 12, 675, 63, 6477, 29, 797, 304, 272, 543, 291, 14, 396, 63, 1730, 8, 1180, 63, 6477, 29, 1180, 63, 6477, 304, 489, 2833, 63, 796, 275, 2833, 14, 3446, 8, 88, 14, 6041, 8, 2271, 430, 489, 734, 275, 2833, 63, 796, 14, 2579, 342, 272, 291, 14, 7260, 8, 548, 12, 1420, 63, 796, 9, 819, 347, 511, 4699, 3861, 8, 277, 304, 272, 671, 275, 2680, 14, 1144, 4157, 272, 291, 14, 1855, 8, 3393, 12, 291, 14, 3446, 4619, 12, 671, 12, 2680, 14, 1609, 708, 12, 378, 9, 819, 347, 511, 19486, 4395, 3861, 8, 277, 304, 272, 671, 275, 2680, 14, 1144, 779, 17, 12, 18, 12, 19, 566, 272, 291, 14, 1855, 8, 3393, 12, 291, 14, 3446, 4619, 12, 671, 12, 2680, 14, 1609, 708, 12, 378, 9, 819, 347, 511, 19486, 11467, 3241, 3861, 8, 277, 304, 272, 671, 275, 2680, 14, 1144, 8, 267, 3474, 17, 12, 378, 12, 378, 467, 268, 359, 16, 12, 499, 12, 378, 467, 268, 359, 16, 12, 378, 12, 650, 3934, 272, 1420, 63, 796, 275, 1227, 272, 291, 14, 3446, 4619, 8, 88, 12, 2680, 14, 442, 708, 12, 1420, 63, 796, 9, 272, 291, 14, 3446, 4619, 8, 88, 12, 2680, 14, 442, 772, 12, 1420, 63, 796, 9, 819, 347, 511, 19486, 11467, 5136, 3861, 8, 277, 304, 272, 671, 275, 2680, 14, 1144, 8, 267, 3474, 17, 14, 17, 12, 378, 12, 378, 467, 268, 359, 16, 12, 499, 14, 18, 12, 378, 467, 268, 359, 16, 12, 378, 12, 650, 14, 19, 3934, 272, 1420, 63, 796, 275, 1227, 14, 22, 272, 291, 14, 3446, 4619, 8, 88, 12, 2680, 14, 1609, 708, 12, 1420, 63, 796, 9, 272, 291, 14, 3446, 4619, 8, 88, 12, 2680, 14, 1609, 772, 12, 1420, 63, 796, 9, 819, 347, 511, 19486, 21485, 5136, 3861, 8, 277, 304, 272, 671, 275, 2680, 14, 2355, 14, 3759, 8, 18, 12, 499, 12, 499, 9, 272, 291, 14, 1855, 8, 3393, 12, 291, 14, 3446, 4619, 12, 671, 12, 2680, 14, 1609, 708, 12, 378, 9, 819, 347, 511, 19486, 24766, 5136, 3861, 8, 277, 304, 272, 671, 275, 2680, 14, 2355, 14, 3759, 8, 18, 12, 499, 12, 499, 12, 499, 9, 272, 291, 14, 1855, 8, 3393, 12, 291, 14, 3446, 4619, 12, 671, 12, 2680, 14, 1609, 708, 12, 378, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 523, 2833, 14, 396, 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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 0, 0, 0, 0, 0, 0, 0 ]
gokuale/weblate
weblate/trans/specialchars.py
11
9743
# -*- coding: utf-8 -*- # # Copyright © 2012 - 2015 Michal Čihař <michal@cihar.com> # # This file is part of Weblate <http://weblate.org/> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 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/>. # """ Helper code to get user special chars specific for given language. """ from django.utils.translation import ugettext as _, ugettext_lazy # Hard coded list of special chars SPECIAL_CHARS = (u'→', u'↵', u'…') # Names of hardcoded chars CHAR_NAMES = { u'→': ugettext_lazy('Insert tab character'), u'↵': ugettext_lazy('Insert new line'), u'…': ugettext_lazy('Insert horizontal ellipsis'), } # Quotes definition for each language, based on CLDR data SINGLE_OPEN = { 'ja': u'『', 'zh': u'『', 'ar': u'’', 'fi': u'’', 'fo': u'’', 'lag': u'’', 'rn': u'’', 'se': u'’', 'sn': u'’', 'sv': u'’', 'ur': u'’', 'eo': u'‘', 'vo': u'‘', 'ALL': u'‘', 'agq': u'‚', 'bs': u'‚', 'cs': u'‚', 'de': u'‚', 'dsb': u'‚', 'et': u'‚', 'ff': u'‚', 'hr': u'‚', 'hsb': u'‚', 'is': u'‚', 'ksh': u'‚', 'lb': u'‚', 'luy': u'‚', 'mk': u'‚', 'sk': u'‚', 'sl': u'‚', 'ast': u'“', 'bm': u'“', 'ca': u'“', 'cy': u'“', 'dyo': u'“', 'es': u'“', 'ewo': u'“', 'fur': u'“', 'ia': u'“', 'it': u'“', 'kab': u'“', 'mg': u'“', 'mua': u'“', 'nnh': u'“', 'nr': u'“', 'nso': u'“', 'pt': u'“', 'sg': u'“', 'sq': u'“', 'ss': u'“', 'ti': u'“', 'tn': u'“', 'ts': u'“', 've': u'“', 'bas': u'„', 'bg': u'„', 'ky': u'„', 'lt': u'„', 'os': u'„', 'ru': u'„', 'shi': u'„', 'uk': u'„', 'zgh': u'„', 'el': u'"', 'eu': u'"', 'uz': u'\'', 'yi': u'\'', 'hy': u'«', 'ka': u'«', 'nmg': u'«', 'pl': u'«', 'ro': u'«', 'yav': u'«', 'he': u'׳', 'am': u'‹', 'az': u'‹', 'be': u'‹', 'br': u'‹', 'fa': u'‹', 'fr': u'‹', 'gsw': u'‹', 'jgo': u'‹', 'kkj': u'‹', 'rm': u'‹', 'wae': u'‹', 'hu': u'»', 'kl': u'›', 'ug': u'›', } SINGLE_CLOSE = { 'ja': u'』', 'zh': u'』', 'eo': u'’', 'vo': u'’', 'ALL': u'’', 'ar': u'‘', 'bs': u'‘', 'cs': u'‘', 'de': u'‘', 'dsb': u'‘', 'et': u'‘', 'hr': u'‘', 'hsb': u'‘', 'is': u'‘', 'ksh': u'‘', 'lb': u'‘', 'luy': u'‘', 'mk': u'‘', 'sk': u'‘', 'sl': u'‘', 'sr': u'‘', 'ur': u'‘', 'ast': u'”', 'bm': u'”', 'ca': u'”', 'cy': u'”', 'dyo': u'”', 'es': u'”', 'ewo': u'”', 'fur': u'”', 'ia': u'”', 'it': u'”', 'kab': u'”', 'mg': u'”', 'mua': u'”', 'nnh': u'”', 'nr': u'”', 'nso': u'”', 'pt': u'”', 'sg': u'”', 'shi': u'”', 'sq': u'”', 'ss': u'”', 'ti': u'”', 'tn': u'”', 'ts': u'”', 've': u'”', 'zgh': u'”', 'bas': u'“', 'bg': u'“', 'ky': u'“', 'lt': u'“', 'os': u'“', 'ru': u'“', 'uk': u'“', 'el': u'"', 'eu': u'"', 'uz': u'\'', 'yi': u'\'', 'hu': u'«', 'he': u'׳', 'kl': u'‹', 'ug': u'‹', 'hy': u'»', 'ka': u'»', 'nmg': u'»', 'pl': u'»', 'ro': u'»', 'yav': u'»', 'am': u'›', 'az': u'›', 'be': u'›', 'br': u'›', 'fa': u'›', 'fr': u'›', 'gsw': u'›', 'jgo': u'›', 'kkj': u'›', 'rm': u'›', 'wae': u'›', } DOUBLE_OPEN = { 'eu': u'"', 'uz': u'"', 'yi': u'"', 'ja': u'「', 'zh': u'「', 'cy': u'‘', 'fur': u'‘', 'ia': u'‘', 'nr': u'‘', 'nso': u'‘', 'ss': u'‘', 'ti': u'‘', 'tn': u'‘', 'ts': u'‘', 've': u'‘', 'am': u'«', 'ast': u'«', 'az': u'«', 'bas': u'«', 'be': u'«', 'bm': u'«', 'br': u'«', 'ca': u'«', 'dua': u'«', 'dyo': u'«', 'el': u'«', 'es': u'«', 'ewo': u'«', 'fa': u'«', 'fr': u'«', 'gsw': u'«', 'hy': u'«', 'it': u'«', 'jgo': u'«', 'kab': u'«', 'kkj': u'«', 'ksf': u'«', 'ky': u'«', 'mg': u'«', 'mua': u'«', 'nb': u'«', 'nn': u'«', 'nnh': u'«', 'os': u'«', 'pt': u'«', 'rm': u'«', 'ru': u'«', 'rw': u'«', 'sg': u'«', 'shi': u'«', 'sq': u'«', 'uk': u'«', 'wae': u'«', 'yav': u'«', 'zgh': u'«', 'he': u'״', 'ar': u'”', 'fi': u'”', 'fo': u'”', 'lag': u'”', 'rn': u'”', 'se': u'”', 'sn': u'”', 'sv': u'”', 'ur': u'”', 'eo': u'“', 'vo': u'“', 'ALL': u'“', 'kl': u'»', 'ug': u'»', 'agq': u'„', 'bg': u'„', 'bs': u'„', 'cs': u'„', 'de': u'„', 'dsb': u'„', 'et': u'„', 'ff': u'„', 'hr': u'„', 'hsb': u'„', 'hu': u'„', 'is': u'„', 'ka': u'„', 'ksh': u'„', 'lb': u'„', 'lt': u'„', 'luy': u'„', 'mk': u'„', 'nmg': u'„', 'pl': u'„', 'sk': u'„', 'sl': u'„', 'sr': u'„', } DOUBLE_CLOSE = { 'eu': u'"', 'kk': u'"', 'uz': u'"', 'yi': u'"', 'he': u'״', 'cy': u'’', 'fur': u'’', 'ia': u'’', 'nr': u'’', 'nso': u'’', 'ss': u'’', 'ti': u'’', 'tn': u'’', 'ts': u'’', 've': u'’', 'ja': u'」', 'zh': u'」', 'kl': u'«', 'ug': u'«', 'eo': u'”', 'vo': u'”', 'ALL': u'”', 'ar': u'“', 'bg': u'“', 'bs': u'“', 'cs': u'“', 'de': u'“', 'dsb': u'“', 'et': u'“', 'hr': u'“', 'hsb': u'“', 'is': u'“', 'ka': u'“', 'ksh': u'“', 'lb': u'“', 'lt': u'“', 'luy': u'“', 'mk': u'“', 'sk': u'“', 'sl': u'“', 'sr': u'“', 'ur': u'“', 'am': u'»', 'ast': u'»', 'az': u'»', 'bas': u'»', 'be': u'»', 'bm': u'»', 'br': u'»', 'ca': u'»', 'dua': u'»', 'dyo': u'»', 'el': u'»', 'es': u'»', 'ewo': u'»', 'fa': u'»', 'fr': u'»', 'gsw': u'»', 'hy': u'»', 'it': u'»', 'jgo': u'»', 'kab': u'»', 'kkj': u'»', 'ksf': u'»', 'ky': u'»', 'mg': u'»', 'mua': u'»', 'nb': u'»', 'nn': u'»', 'nnh': u'»', 'os': u'»', 'pt': u'»', 'rm': u'»', 'ru': u'»', 'rw': u'»', 'sg': u'»', 'shi': u'»', 'sq': u'»', 'uk': u'»', 'wae': u'»', 'yav': u'»', 'zgh': u'»', } HYPHEN_LANGS = frozenset(( 'af', 'am', 'ar', 'ast', 'az', 'bg', 'bs', 'ca', 'cs', 'cy', 'da', 'de', 'dsb', 'dz', 'ee', 'el', 'en', 'eo', 'es', 'fa', 'fi', 'fr', 'fy', 'gd', 'gl', 'gu', 'he', 'hr', 'hsb', 'id', 'is', 'ja', 'ka', 'kk', 'kn', 'ko', 'ksh', 'ky', 'lb', 'lkt', 'lt', 'lv', 'mk', 'mn', 'mr', 'nl', 'os', 'pa', 'pl', 'pt', 'ro', 'ru', 'sk', 'sr', 'sv', 'ta', 'th', 'to', 'tr', 'uz', 'vi', 'vo', 'yi', 'zh', )) EN_DASH_LANGS = frozenset(( 'af', 'am', 'ar', 'ast', 'az', 'bg', 'bs', 'ca', 'cs', 'cy', 'da', 'de', 'dsb', 'dz', 'ee', 'el', 'en', 'eo', 'es', 'fi', 'fr', 'fy', 'gd', 'gl', 'gu', 'he', 'hr', 'hsb', 'hu', 'id', 'is', 'ka', 'kk', 'kn', 'ksh', 'ky', 'lb', 'lkt', 'lt', 'lv', 'mk', 'mn', 'mr', 'nb', 'nl', 'os', 'pa', 'pl', 'pt', 'ro', 'ru', 'sk', 'sr', 'sv', 'ta', 'th', 'to', 'tr', 'uk', 'uz', 'vi', 'vo', 'yi', 'zh', )) EM_DASH_LANGS = frozenset(( 'af', 'ar', 'ast', 'az', 'bg', 'bs', 'ca', 'cy', 'de', 'dsb', 'dz', 'ee', 'el', 'en', 'eo', 'es', 'fr', 'fy', 'gd', 'gl', 'gu', 'he', 'hr', 'hsb', 'id', 'is', 'it', 'ja', 'ka', 'kk', 'kn', 'ko', 'ksh', 'ky', 'lb', 'lkt', 'lt', 'lv', 'mk', 'mn', 'mr', 'nl', 'os', 'pa', 'pl', 'pt', 'ro', 'ru', 'sv', 'ta', 'th', 'to', 'tr', 'uz', 'vi', 'vo', 'yi', 'zh', )) def get_quote(code, data, name): """ Returns special char for quote. """ if code in data: return name, data[code] return name, data['ALL'] def get_special_chars(language): """ Returns list of special characters. """ for char in SPECIAL_CHARS: if char in CHAR_NAMES: name = CHAR_NAMES[char] else: name = _('Insert character {0}').format(char) yield name, char code = language.code.replace('_', '-').split('-')[0] yield get_quote(code, DOUBLE_OPEN, _('Opening double quote')) yield get_quote(code, DOUBLE_CLOSE, _('Closing double quote')) yield get_quote(code, SINGLE_OPEN, _('Opening single quote')) yield get_quote(code, SINGLE_CLOSE, _('Closing single quote')) if code in HYPHEN_LANGS: yield _('Hyphen'), u'-' if code in EN_DASH_LANGS: yield _('En dash'), u'–' if code in EM_DASH_LANGS: yield _('Em dash'), u'—'
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 22405, 103, 6029, 446, 6900, 603, 1158, 279, 221, 129, 235, 73, 2411, 130, 248, 665, 77, 1158, 279, 32, 559, 8210, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 6001, 750, 665, 1014, 921, 2520, 750, 14, 1308, 3133, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 624, 199, 4433, 1233, 370, 664, 922, 4539, 8365, 2488, 367, 1627, 2637, 14, 199, 624, 199, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 5501, 10366, 63, 6395, 199, 199, 3, 22825, 1233, 68, 769, 402, 4539, 8365, 199, 25748, 63, 16326, 275, 334, 85, 22095, 229, 241, 297, 399, 22095, 229, 114, 297, 399, 7, 8477, 100, 358, 199, 199, 3, 23923, 402, 7508, 15282, 8365, 199, 5901, 63, 14546, 275, 469, 272, 399, 22095, 229, 241, 356, 10366, 63, 6395, 360, 9971, 5174, 4528, 659, 272, 399, 22095, 229, 114, 356, 10366, 63, 6395, 360, 9971, 892, 1004, 659, 272, 399, 7, 8477, 100, 356, 10366, 63, 6395, 360, 9971, 17528, 32696, 659, 199, 93, 199, 199, 3, 5843, 6510, 5492, 367, 1924, 2637, 12, 4079, 641, 13354, 4564, 666, 199, 16425, 63, 9935, 275, 469, 272, 283, 3387, 356, 399, 7, 12805, 237, 297, 272, 283, 3951, 356, 399, 7, 12805, 237, 297, 272, 283, 285, 356, 399, 7, 21045, 297, 272, 283, 329, 356, 399, 7, 21045, 297, 272, 283, 545, 356, 399, 7, 21045, 297, 272, 283, 1823, 356, 399, 7, 21045, 297, 272, 283, 11641, 356, 399, 7, 21045, 297, 272, 283, 261, 356, 399, 7, 21045, 297, 272, 283, 5167, 356, 399, 7, 21045, 297, 272, 283, 2772, 356, 399, 7, 21045, 297, 272, 283, 300, 356, 399, 7, 21045, 297, 272, 283, 20805, 356, 399, 7, 8477, 247, 297, 272, 283, 2392, 356, 399, 7, 8477, 247, 297, 272, 283, 1761, 356, 399, 7, 8477, 247, 297, 272, 283, 643, 81, 356, 399, 7, 8477, 249, 297, 272, 283, 1533, 356, 399, 7, 8477, 249, 297, 272, 283, 1259, 356, 399, 7, 8477, 249, 297, 272, 283, 271, 356, 399, 7, 8477, 249, 297, 272, 283, 795, 66, 356, 399, 7, 8477, 249, 297, 272, 283, 386, 356, 399, 7, 8477, 249, 297, 272, 283, 556, 356, 399, 7, 8477, 249, 297, 272, 283, 6271, 356, 399, 7, 8477, 249, 297, 272, 283, 4213, 66, 356, 399, 7, 8477, 249, 297, 272, 283, 374, 356, 399, 7, 8477, 249, 297, 272, 283, 75, 609, 356, 399, 7, 8477, 249, 297, 272, 283, 6374, 356, 399, 7, 8477, 249, 297, 272, 283, 10836, 89, 356, 399, 7, 8477, 249, 297, 272, 283, 3880, 356, 399, 7, 8477, 249, 297, 272, 283, 1339, 356, 399, 7, 8477, 249, 297, 272, 283, 2482, 356, 399, 7, 8477, 249, 297, 272, 283, 1810, 356, 399, 7, 8477, 251, 297, 272, 283, 12648, 356, 399, 7, 8477, 251, 297, 272, 283, 696, 356, 399, 7, 8477, 251, 297, 272, 283, 1480, 356, 399, 7, 8477, 251, 297, 272, 283, 8161, 79, 356, 399, 7, 8477, 251, 297, 272, 283, 397, 356, 399, 7, 8477, 251, 297, 272, 283, 546, 79, 356, 399, 7, 8477, 251, 297, 272, 283, 70, 300, 356, 399, 7, 8477, 251, 297, 272, 283, 4674, 356, 399, 7, 8477, 251, 297, 272, 283, 390, 356, 399, 7, 8477, 251, 297, 272, 283, 75, 371, 356, 399, 7, 8477, 251, 297, 272, 283, 6649, 356, 399, 7, 8477, 251, 297, 272, 283, 77, 1458, 356, 399, 7, 8477, 251, 297, 272, 283, 4411, 72, 356, 399, 7, 8477, 251, 297, 272, 283, 7865, 356, 399, 7, 8477, 251, 297, 272, 283, 561, 79, 356, 399, 7, 8477, 251, 297, 272, 283, 541, 356, 399, 7, 8477, 251, 297, 272, 283, 1226, 356, 399, 7, 8477, 251, 297, 272, 283, 3526, 356, 399, 7, 8477, 251, 297, 272, 283, 385, 356, 399, 7, 8477, 251, 297, 272, 283, 280, 356, 399, 7, 8477, 251, 297, 272, 283, 5889, 356, 399, 7, 8477, 251, 297, 272, 283, 1086, 356, 399, 7, 8477, 251, 297, 272, 283, 432, 356, 399, 7, 8477, 251, 297, 272, 283, 31917, 356, 399, 7, 8477, 253, 297, 272, 283, 6856, 356, 399, 7, 8477, 253, 297, 272, 283, 10562, 356, 399, 7, 8477, 253, 297, 272, 283, 4116, 356, 399, 7, 8477, 253, 297, 272, 283, 736, 356, 399, 7, 8477, 253, 297, 272, 283, 6558, 356, 399, 7, 8477, 253, 297, 272, 283, 19377, 356, 399, 7, 8477, 253, 297, 272, 283, 3210, 356, 399, 7, 8477, 253, 297, 272, 283, 90, 3561, 356, 399, 7, 8477, 253, 297, 272, 283, 352, 356, 399, 24487, 272, 283, 16913, 356, 399, 24487, 272, 283, 9494, 356, 399, 1154, 6448, 272, 283, 21643, 356, 399, 1154, 6448, 272, 283, 3577, 356, 399, 7, 127, 105, 297, 272, 283, 7351, 356, 399, 7, 127, 105, 297, 272, 283, 78, 6649, 356, 399, 7, 127, 105, 297, 272, 283, 1168, 356, 399, 7, 127, 105, 297, 272, 283, 293, 356, 399, 7, 127, 105, 297, 272, 283, 89, 1214, 356, 399, 7, 127, 105, 297, 272, 283, 426, 356, 399, 7, 148, 112, 297, 272, 283, 455, 356, 399, 7, 8477, 118, 297, 272 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 22405, 103, 6029, 446, 6900, 603, 1158, 279, 221, 129, 235, 73, 2411, 130, 248, 665, 77, 1158, 279, 32, 559, 8210, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 6001, 750, 665, 1014, 921, 2520, 750, 14, 1308, 3133, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 624, 199, 4433, 1233, 370, 664, 922, 4539, 8365, 2488, 367, 1627, 2637, 14, 199, 624, 199, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 5501, 10366, 63, 6395, 199, 199, 3, 22825, 1233, 68, 769, 402, 4539, 8365, 199, 25748, 63, 16326, 275, 334, 85, 22095, 229, 241, 297, 399, 22095, 229, 114, 297, 399, 7, 8477, 100, 358, 199, 199, 3, 23923, 402, 7508, 15282, 8365, 199, 5901, 63, 14546, 275, 469, 272, 399, 22095, 229, 241, 356, 10366, 63, 6395, 360, 9971, 5174, 4528, 659, 272, 399, 22095, 229, 114, 356, 10366, 63, 6395, 360, 9971, 892, 1004, 659, 272, 399, 7, 8477, 100, 356, 10366, 63, 6395, 360, 9971, 17528, 32696, 659, 199, 93, 199, 199, 3, 5843, 6510, 5492, 367, 1924, 2637, 12, 4079, 641, 13354, 4564, 666, 199, 16425, 63, 9935, 275, 469, 272, 283, 3387, 356, 399, 7, 12805, 237, 297, 272, 283, 3951, 356, 399, 7, 12805, 237, 297, 272, 283, 285, 356, 399, 7, 21045, 297, 272, 283, 329, 356, 399, 7, 21045, 297, 272, 283, 545, 356, 399, 7, 21045, 297, 272, 283, 1823, 356, 399, 7, 21045, 297, 272, 283, 11641, 356, 399, 7, 21045, 297, 272, 283, 261, 356, 399, 7, 21045, 297, 272, 283, 5167, 356, 399, 7, 21045, 297, 272, 283, 2772, 356, 399, 7, 21045, 297, 272, 283, 300, 356, 399, 7, 21045, 297, 272, 283, 20805, 356, 399, 7, 8477, 247, 297, 272, 283, 2392, 356, 399, 7, 8477, 247, 297, 272, 283, 1761, 356, 399, 7, 8477, 247, 297, 272, 283, 643, 81, 356, 399, 7, 8477, 249, 297, 272, 283, 1533, 356, 399, 7, 8477, 249, 297, 272, 283, 1259, 356, 399, 7, 8477, 249, 297, 272, 283, 271, 356, 399, 7, 8477, 249, 297, 272, 283, 795, 66, 356, 399, 7, 8477, 249, 297, 272, 283, 386, 356, 399, 7, 8477, 249, 297, 272, 283, 556, 356, 399, 7, 8477, 249, 297, 272, 283, 6271, 356, 399, 7, 8477, 249, 297, 272, 283, 4213, 66, 356, 399, 7, 8477, 249, 297, 272, 283, 374, 356, 399, 7, 8477, 249, 297, 272, 283, 75, 609, 356, 399, 7, 8477, 249, 297, 272, 283, 6374, 356, 399, 7, 8477, 249, 297, 272, 283, 10836, 89, 356, 399, 7, 8477, 249, 297, 272, 283, 3880, 356, 399, 7, 8477, 249, 297, 272, 283, 1339, 356, 399, 7, 8477, 249, 297, 272, 283, 2482, 356, 399, 7, 8477, 249, 297, 272, 283, 1810, 356, 399, 7, 8477, 251, 297, 272, 283, 12648, 356, 399, 7, 8477, 251, 297, 272, 283, 696, 356, 399, 7, 8477, 251, 297, 272, 283, 1480, 356, 399, 7, 8477, 251, 297, 272, 283, 8161, 79, 356, 399, 7, 8477, 251, 297, 272, 283, 397, 356, 399, 7, 8477, 251, 297, 272, 283, 546, 79, 356, 399, 7, 8477, 251, 297, 272, 283, 70, 300, 356, 399, 7, 8477, 251, 297, 272, 283, 4674, 356, 399, 7, 8477, 251, 297, 272, 283, 390, 356, 399, 7, 8477, 251, 297, 272, 283, 75, 371, 356, 399, 7, 8477, 251, 297, 272, 283, 6649, 356, 399, 7, 8477, 251, 297, 272, 283, 77, 1458, 356, 399, 7, 8477, 251, 297, 272, 283, 4411, 72, 356, 399, 7, 8477, 251, 297, 272, 283, 7865, 356, 399, 7, 8477, 251, 297, 272, 283, 561, 79, 356, 399, 7, 8477, 251, 297, 272, 283, 541, 356, 399, 7, 8477, 251, 297, 272, 283, 1226, 356, 399, 7, 8477, 251, 297, 272, 283, 3526, 356, 399, 7, 8477, 251, 297, 272, 283, 385, 356, 399, 7, 8477, 251, 297, 272, 283, 280, 356, 399, 7, 8477, 251, 297, 272, 283, 5889, 356, 399, 7, 8477, 251, 297, 272, 283, 1086, 356, 399, 7, 8477, 251, 297, 272, 283, 432, 356, 399, 7, 8477, 251, 297, 272, 283, 31917, 356, 399, 7, 8477, 253, 297, 272, 283, 6856, 356, 399, 7, 8477, 253, 297, 272, 283, 10562, 356, 399, 7, 8477, 253, 297, 272, 283, 4116, 356, 399, 7, 8477, 253, 297, 272, 283, 736, 356, 399, 7, 8477, 253, 297, 272, 283, 6558, 356, 399, 7, 8477, 253, 297, 272, 283, 19377, 356, 399, 7, 8477, 253, 297, 272, 283, 3210, 356, 399, 7, 8477, 253, 297, 272, 283, 90, 3561, 356, 399, 7, 8477, 253, 297, 272, 283, 352, 356, 399, 24487, 272, 283, 16913, 356, 399, 24487, 272, 283, 9494, 356, 399, 1154, 6448, 272, 283, 21643, 356, 399, 1154, 6448, 272, 283, 3577, 356, 399, 7, 127, 105, 297, 272, 283, 7351, 356, 399, 7, 127, 105, 297, 272, 283, 78, 6649, 356, 399, 7, 127, 105, 297, 272, 283, 1168, 356, 399, 7, 127, 105, 297, 272, 283, 293, 356, 399, 7, 127, 105, 297, 272, 283, 89, 1214, 356, 399, 7, 127, 105, 297, 272, 283, 426, 356, 399, 7, 148, 112, 297, 272, 283, 455, 356, 399, 7, 8477, 118, 297, 272, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
wsmith323/django
tests/flatpages_tests/test_middleware.py
290
8134
from django.conf import settings from django.contrib.auth.models import User from django.contrib.flatpages.models import FlatPage from django.contrib.sites.models import Site from django.test import TestCase, modify_settings, override_settings from .settings import FLATPAGES_TEMPLATES class TestDataMixin(object): @classmethod def setUpTestData(cls): # don't use the manager because we want to ensure the site exists # with pk=1, regardless of whether or not it already exists. cls.site1 = Site(pk=1, domain='example.com', name='example.com') cls.site1.save() cls.fp1 = FlatPage.objects.create( url='/flatpage/', title='A Flatpage', content="Isn't it flat!", enable_comments=False, template_name='', registration_required=False ) cls.fp2 = FlatPage.objects.create( url='/location/flatpage/', title='A Nested Flatpage', content="Isn't it flat and deep!", enable_comments=False, template_name='', registration_required=False ) cls.fp3 = FlatPage.objects.create( url='/sekrit/', title='Sekrit Flatpage', content="Isn't it sekrit!", enable_comments=False, template_name='', registration_required=True ) cls.fp4 = FlatPage.objects.create( url='/location/sekrit/', title='Sekrit Nested Flatpage', content="Isn't it sekrit and deep!", enable_comments=False, template_name='', registration_required=True ) cls.fp1.sites.add(cls.site1) cls.fp2.sites.add(cls.site1) cls.fp3.sites.add(cls.site1) cls.fp4.sites.add(cls.site1) @modify_settings(INSTALLED_APPS={'append': 'django.contrib.flatpages'}) @override_settings( LOGIN_URL='/accounts/login/', MIDDLEWARE_CLASSES=[ 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', ], ROOT_URLCONF='flatpages_tests.urls', TEMPLATES=FLATPAGES_TEMPLATES, SITE_ID=1, ) class FlatpageMiddlewareTests(TestDataMixin, TestCase): def test_view_flatpage(self): "A flatpage can be served through a view, even when the middleware is in use" response = self.client.get('/flatpage_root/flatpage/') self.assertEqual(response.status_code, 200) self.assertContains(response, "<p>Isn't it flat!</p>") def test_view_non_existent_flatpage(self): "A non-existent flatpage raises 404 when served through a view, even when the middleware is in use" response = self.client.get('/flatpage_root/no_such_flatpage/') self.assertEqual(response.status_code, 404) def test_view_authenticated_flatpage(self): "A flatpage served through a view can require authentication" response = self.client.get('/flatpage_root/sekrit/') self.assertRedirects(response, '/accounts/login/?next=/flatpage_root/sekrit/') User.objects.create_user('testuser', 'test@example.com', 's3krit') self.client.login(username='testuser', password='s3krit') response = self.client.get('/flatpage_root/sekrit/') self.assertEqual(response.status_code, 200) self.assertContains(response, "<p>Isn't it sekrit!</p>") def test_fallback_flatpage(self): "A flatpage can be served by the fallback middleware" response = self.client.get('/flatpage/') self.assertEqual(response.status_code, 200) self.assertContains(response, "<p>Isn't it flat!</p>") def test_fallback_non_existent_flatpage(self): "A non-existent flatpage raises a 404 when served by the fallback middleware" response = self.client.get('/no_such_flatpage/') self.assertEqual(response.status_code, 404) def test_fallback_authenticated_flatpage(self): "A flatpage served by the middleware can require authentication" response = self.client.get('/sekrit/') self.assertRedirects(response, '/accounts/login/?next=/sekrit/') User.objects.create_user('testuser', 'test@example.com', 's3krit') self.client.login(username='testuser', password='s3krit') response = self.client.get('/sekrit/') self.assertEqual(response.status_code, 200) self.assertContains(response, "<p>Isn't it sekrit!</p>") def test_fallback_flatpage_special_chars(self): "A flatpage with special chars in the URL can be served by the fallback middleware" fp = FlatPage.objects.create( url="/some.very_special~chars-here/", title="A very special page", content="Isn't it special!", enable_comments=False, registration_required=False, ) fp.sites.add(settings.SITE_ID) response = self.client.get('/some.very_special~chars-here/') self.assertEqual(response.status_code, 200) self.assertContains(response, "<p>Isn't it special!</p>") @modify_settings(INSTALLED_APPS={'append': 'django.contrib.flatpages'}) @override_settings( APPEND_SLASH=True, LOGIN_URL='/accounts/login/', MIDDLEWARE_CLASSES=[ 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', ], ROOT_URLCONF='flatpages_tests.urls', TEMPLATES=FLATPAGES_TEMPLATES, SITE_ID=1, ) class FlatpageMiddlewareAppendSlashTests(TestDataMixin, TestCase): def test_redirect_view_flatpage(self): "A flatpage can be served through a view and should add a slash" response = self.client.get('/flatpage_root/flatpage') self.assertRedirects(response, '/flatpage_root/flatpage/', status_code=301) def test_redirect_view_non_existent_flatpage(self): "A non-existent flatpage raises 404 when served through a view and should not add a slash" response = self.client.get('/flatpage_root/no_such_flatpage') self.assertEqual(response.status_code, 404) def test_redirect_fallback_flatpage(self): "A flatpage can be served by the fallback middleware and should add a slash" response = self.client.get('/flatpage') self.assertRedirects(response, '/flatpage/', status_code=301) def test_redirect_fallback_non_existent_flatpage(self): "A non-existent flatpage raises a 404 when served by the fallback middleware and should not add a slash" response = self.client.get('/no_such_flatpage') self.assertEqual(response.status_code, 404) def test_redirect_fallback_flatpage_special_chars(self): "A flatpage with special chars in the URL can be served by the fallback middleware and should add a slash" fp = FlatPage.objects.create( url="/some.very_special~chars-here/", title="A very special page", content="Isn't it special!", enable_comments=False, registration_required=False, ) fp.sites.add(settings.SITE_ID) response = self.client.get('/some.very_special~chars-here') self.assertRedirects(response, '/some.very_special~chars-here/', status_code=301) def test_redirect_fallback_flatpage_root(self): "A flatpage at / should not cause a redirect loop when APPEND_SLASH is set" fp = FlatPage.objects.create( url="/", title="Root", content="Root", enable_comments=False, registration_required=False, ) fp.sites.add(settings.SITE_ID) response = self.client.get('/') self.assertEqual(response.status_code, 200) self.assertContains(response, "<p>Root</p>")
bsd-3-clause
[ 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 2828, 14, 29974, 14, 992, 492, 19005, 3276, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 504, 1639, 14, 396, 492, 7640, 12, 2811, 63, 1751, 12, 4278, 63, 1751, 199, 199, 504, 1275, 1751, 492, 9821, 619, 48, 5383, 63, 25437, 421, 199, 533, 1379, 1451, 4256, 8, 785, 304, 339, 768, 3744, 272, 347, 3613, 16550, 8, 1886, 304, 267, 327, 2793, 1133, 675, 314, 5256, 2952, 781, 2934, 370, 4868, 314, 4770, 3495, 267, 327, 543, 3803, 29, 17, 12, 15270, 402, 3775, 503, 440, 652, 2575, 3495, 14, 267, 843, 14, 2124, 17, 275, 11666, 8, 2051, 29, 17, 12, 2881, 534, 2694, 14, 957, 297, 536, 534, 2694, 14, 957, 358, 267, 843, 14, 2124, 17, 14, 2117, 342, 267, 843, 14, 3997, 17, 275, 19005, 3276, 14, 1462, 14, 981, 8, 288, 1166, 8805, 26587, 3678, 2538, 534, 33, 19005, 1606, 297, 1564, 628, 1831, 78, 1133, 652, 6829, 17716, 288, 4756, 63, 6223, 29, 797, 12, 1978, 63, 354, 4581, 10991, 63, 2427, 29, 797, 267, 776, 267, 843, 14, 3997, 18, 275, 19005, 3276, 14, 1462, 14, 981, 8, 288, 1166, 8805, 1985, 15, 26587, 3678, 2538, 534, 33, 23137, 19005, 1606, 297, 1564, 628, 1831, 78, 1133, 652, 6829, 436, 13217, 17716, 288, 4756, 63, 6223, 29, 797, 12, 1978, 63, 354, 4581, 10991, 63, 2427, 29, 797, 267, 776, 267, 843, 14, 3997, 19, 275, 19005, 3276, 14, 1462, 14, 981, 8, 288, 1166, 8805, 261, 75, 11133, 3678, 2538, 534, 1513, 75, 11133, 19005, 1606, 297, 1564, 628, 1831, 78, 1133, 652, 542, 75, 11133, 17716, 288, 4756, 63, 6223, 29, 797, 12, 1978, 63, 354, 4581, 10991, 63, 2427, 29, 549, 267, 776, 267, 843, 14, 3997, 20, 275, 19005, 3276, 14, 1462, 14, 981, 8, 288, 1166, 8805, 1985, 15, 261, 75, 11133, 3678, 2538, 534, 1513, 75, 11133, 23137, 19005, 1606, 297, 1564, 628, 1831, 78, 1133, 652, 542, 75, 11133, 436, 13217, 17716, 288, 4756, 63, 6223, 29, 797, 12, 1978, 63, 354, 4581, 10991, 63, 2427, 29, 549, 267, 776, 267, 843, 14, 3997, 17, 14, 8619, 14, 525, 8, 1886, 14, 2124, 17, 9, 267, 843, 14, 3997, 18, 14, 8619, 14, 525, 8, 1886, 14, 2124, 17, 9, 267, 843, 14, 3997, 19, 14, 8619, 14, 525, 8, 1886, 14, 2124, 17, 9, 267, 843, 14, 3997, 20, 14, 8619, 14, 525, 8, 1886, 14, 2124, 17, 9, 421, 199, 32, 8951, 63, 1751, 8, 15942, 63, 14219, 3713, 740, 356, 283, 1176, 14, 2828, 14, 29974, 3071, 199, 32, 4415, 63, 1751, 8, 272, 5051, 568, 63, 2632, 8805, 8370, 15, 2886, 3678, 272, 30718, 63, 13748, 1524, 267, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 267, 283, 1176, 14, 2828, 14, 11676, 14, 5754, 14, 4434, 6608, 297, 267, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 267, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 297, 267, 283, 1176, 14, 2828, 14, 3431, 14, 5754, 14, 2209, 6608, 297, 267, 283, 1176, 14, 2828, 14, 29974, 14, 5754, 14, 17271, 1606, 21860, 6608, 297, 272, 2156, 272, 16547, 63, 18125, 534, 29974, 63, 2219, 14, 3603, 297, 272, 377, 9358, 16601, 29, 3143, 619, 48, 5383, 63, 25437, 12, 272, 428, 4427, 63, 998, 29, 17, 12, 199, 9, 199, 533, 19005, 1606, 6608, 2925, 8, 16550, 4256, 12, 7640, 304, 339, 347, 511, 63, 1345, 63, 26587, 8, 277, 304, 267, 298, 33, 6829, 1606, 883, 506, 19733, 4012, 282, 2455, 12, 2755, 1380, 314, 10816, 365, 315, 675, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 26587, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 9535, 8, 1310, 12, 3886, 80, 30, 1831, 78, 1133, 652, 6829, 28718, 80, 9579, 339, 347, 511, 63, 1345, 63, 2865, 63, 15025, 63, 26587, 8, 277, 304, 267, 298, 33, 2222, 13, 15025, 6829, 1606, 6534, 7901, 1380, 19733, 4012, 282, 2455, 12, 2755, 1380, 314, 10816, 365, 315, 675, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 889, 63, 10180, 63, 26587, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 7901, 9, 339, 347, 511, 63, 1345, 63, 12177, 63, 26587, 8, 277, 304, 267, 298, 33, 6829, 1606, 19733, 4012, 282, 2455, 883, 4409, 6299, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 261, 75, 11133, 6217, 267, 291, 14, 17466, 8, 1310, 12, 1994, 8370, 15, 2886, 10197, 2184, 13043, 26587, 63, 1231, 15, 261, 75, 11133, 6217, 267, 2876, 14, 1462, 14, 981, 63, 751, 360, 21029, 297, 283, 396, 32, 2694, 14, 957, 297, 283, 83, 19, 75, 11133, 358, 267, 291, 14, 1258, 14, 2886, 8, 2473, 534, 21029, 297, 2505, 534, 83, 19, 75, 11133, 358, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 261, 75, 11133, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 9535, 8, 1310, 12, 3886, 80, 30, 1831, 78, 1133, 652, 542, 75, 11133, 28718, 80, 9579, 339, 347, 511, 63, 10538, 63, 26587, 8, 277, 304, 267, 298, 33, 6829, 1606, 883, 506, 19733, 701, 314, 9567, 10816, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 9535, 8, 1310, 12, 3886, 80, 30, 1831, 78, 1133, 652, 6829, 28718, 80, 9579, 339, 347, 511, 63, 10538, 63, 2865, 63, 15025, 63, 26587, 8, 277, 304, 267, 298, 33, 2222, 13, 15025, 6829, 1606, 6534, 282, 7901, 1380, 19733, 701, 314, 9567, 10816, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 889, 63, 10180, 63, 26587, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 7901, 9, 339, 347 ]
[ 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 2828, 14, 29974, 14, 992, 492, 19005, 3276, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 504, 1639, 14, 396, 492, 7640, 12, 2811, 63, 1751, 12, 4278, 63, 1751, 199, 199, 504, 1275, 1751, 492, 9821, 619, 48, 5383, 63, 25437, 421, 199, 533, 1379, 1451, 4256, 8, 785, 304, 339, 768, 3744, 272, 347, 3613, 16550, 8, 1886, 304, 267, 327, 2793, 1133, 675, 314, 5256, 2952, 781, 2934, 370, 4868, 314, 4770, 3495, 267, 327, 543, 3803, 29, 17, 12, 15270, 402, 3775, 503, 440, 652, 2575, 3495, 14, 267, 843, 14, 2124, 17, 275, 11666, 8, 2051, 29, 17, 12, 2881, 534, 2694, 14, 957, 297, 536, 534, 2694, 14, 957, 358, 267, 843, 14, 2124, 17, 14, 2117, 342, 267, 843, 14, 3997, 17, 275, 19005, 3276, 14, 1462, 14, 981, 8, 288, 1166, 8805, 26587, 3678, 2538, 534, 33, 19005, 1606, 297, 1564, 628, 1831, 78, 1133, 652, 6829, 17716, 288, 4756, 63, 6223, 29, 797, 12, 1978, 63, 354, 4581, 10991, 63, 2427, 29, 797, 267, 776, 267, 843, 14, 3997, 18, 275, 19005, 3276, 14, 1462, 14, 981, 8, 288, 1166, 8805, 1985, 15, 26587, 3678, 2538, 534, 33, 23137, 19005, 1606, 297, 1564, 628, 1831, 78, 1133, 652, 6829, 436, 13217, 17716, 288, 4756, 63, 6223, 29, 797, 12, 1978, 63, 354, 4581, 10991, 63, 2427, 29, 797, 267, 776, 267, 843, 14, 3997, 19, 275, 19005, 3276, 14, 1462, 14, 981, 8, 288, 1166, 8805, 261, 75, 11133, 3678, 2538, 534, 1513, 75, 11133, 19005, 1606, 297, 1564, 628, 1831, 78, 1133, 652, 542, 75, 11133, 17716, 288, 4756, 63, 6223, 29, 797, 12, 1978, 63, 354, 4581, 10991, 63, 2427, 29, 549, 267, 776, 267, 843, 14, 3997, 20, 275, 19005, 3276, 14, 1462, 14, 981, 8, 288, 1166, 8805, 1985, 15, 261, 75, 11133, 3678, 2538, 534, 1513, 75, 11133, 23137, 19005, 1606, 297, 1564, 628, 1831, 78, 1133, 652, 542, 75, 11133, 436, 13217, 17716, 288, 4756, 63, 6223, 29, 797, 12, 1978, 63, 354, 4581, 10991, 63, 2427, 29, 549, 267, 776, 267, 843, 14, 3997, 17, 14, 8619, 14, 525, 8, 1886, 14, 2124, 17, 9, 267, 843, 14, 3997, 18, 14, 8619, 14, 525, 8, 1886, 14, 2124, 17, 9, 267, 843, 14, 3997, 19, 14, 8619, 14, 525, 8, 1886, 14, 2124, 17, 9, 267, 843, 14, 3997, 20, 14, 8619, 14, 525, 8, 1886, 14, 2124, 17, 9, 421, 199, 32, 8951, 63, 1751, 8, 15942, 63, 14219, 3713, 740, 356, 283, 1176, 14, 2828, 14, 29974, 3071, 199, 32, 4415, 63, 1751, 8, 272, 5051, 568, 63, 2632, 8805, 8370, 15, 2886, 3678, 272, 30718, 63, 13748, 1524, 267, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 267, 283, 1176, 14, 2828, 14, 11676, 14, 5754, 14, 4434, 6608, 297, 267, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 267, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 297, 267, 283, 1176, 14, 2828, 14, 3431, 14, 5754, 14, 2209, 6608, 297, 267, 283, 1176, 14, 2828, 14, 29974, 14, 5754, 14, 17271, 1606, 21860, 6608, 297, 272, 2156, 272, 16547, 63, 18125, 534, 29974, 63, 2219, 14, 3603, 297, 272, 377, 9358, 16601, 29, 3143, 619, 48, 5383, 63, 25437, 12, 272, 428, 4427, 63, 998, 29, 17, 12, 199, 9, 199, 533, 19005, 1606, 6608, 2925, 8, 16550, 4256, 12, 7640, 304, 339, 347, 511, 63, 1345, 63, 26587, 8, 277, 304, 267, 298, 33, 6829, 1606, 883, 506, 19733, 4012, 282, 2455, 12, 2755, 1380, 314, 10816, 365, 315, 675, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 26587, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 9535, 8, 1310, 12, 3886, 80, 30, 1831, 78, 1133, 652, 6829, 28718, 80, 9579, 339, 347, 511, 63, 1345, 63, 2865, 63, 15025, 63, 26587, 8, 277, 304, 267, 298, 33, 2222, 13, 15025, 6829, 1606, 6534, 7901, 1380, 19733, 4012, 282, 2455, 12, 2755, 1380, 314, 10816, 365, 315, 675, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 889, 63, 10180, 63, 26587, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 7901, 9, 339, 347, 511, 63, 1345, 63, 12177, 63, 26587, 8, 277, 304, 267, 298, 33, 6829, 1606, 19733, 4012, 282, 2455, 883, 4409, 6299, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 261, 75, 11133, 6217, 267, 291, 14, 17466, 8, 1310, 12, 1994, 8370, 15, 2886, 10197, 2184, 13043, 26587, 63, 1231, 15, 261, 75, 11133, 6217, 267, 2876, 14, 1462, 14, 981, 63, 751, 360, 21029, 297, 283, 396, 32, 2694, 14, 957, 297, 283, 83, 19, 75, 11133, 358, 267, 291, 14, 1258, 14, 2886, 8, 2473, 534, 21029, 297, 2505, 534, 83, 19, 75, 11133, 358, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 63, 1231, 15, 261, 75, 11133, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 9535, 8, 1310, 12, 3886, 80, 30, 1831, 78, 1133, 652, 542, 75, 11133, 28718, 80, 9579, 339, 347, 511, 63, 10538, 63, 26587, 8, 277, 304, 267, 298, 33, 6829, 1606, 883, 506, 19733, 701, 314, 9567, 10816, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 26587, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 9535, 8, 1310, 12, 3886, 80, 30, 1831, 78, 1133, 652, 6829, 28718, 80, 9579, 339, 347, 511, 63, 10538, 63, 2865, 63, 15025, 63, 26587, 8, 277, 304, 267, 298, 33, 2222, 13, 15025, 6829, 1606, 6534, 282, 7901, 1380, 19733, 701, 314, 9567, 10816, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 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 ]
liebermeister/flux-enzyme-cost-minimization
scripts/monod_curve.py
1
6430
# -*- coding: utf-8 -*- """ Created on Wed Oct 1 2015 @author: noore """ import os import numpy as np import matplotlib.pyplot as plt from matplotlib import gridspec from scipy.optimize import curve_fit import definitions as D import pandas as pd #LOW_GLUCOSE = D.LOW_CONC['glucoseExt'] LOW_GLUCOSE = 1e-3 # in mM, i.e. 1 uM MAX_GROWTH_RATE_L = 'max growth rate [h$^{-1}$]' GROWTH_RATE_LOW_GLU = 'growth rate at\n%g $\mu$M glucose [h$^{-1}$]' % (1e3*LOW_GLUCOSE) MONOD_COEFF_L = 'Monod coefficient [mM glucose]' INV_MONOD_COEFF_L = 'inverse of Monod coeff.\n[mM$^{-1}$]' MAX_GR_OVER_KM_L = 'max. growth rate / $K_{Monod}$ \n[h$^{-1}$ mM$^{-1}$]' HILL_COEFF_L = 'Hill coefficitent' MONOD_FUNC = lambda x, gr_max, K_M, h : gr_max / (1 + (K_M/x)**h); p0 = (0.07, 1.0, 1.0) def calculate_monod_parameters(figure_data): aerobic_data_df = figure_data['standard'] aerobic_sweep_data_df = figure_data['monod_glucose_aero'] anaerobic_data_df = figure_data['anaerobic'].drop(9999) anaerobic_sweep_data_df = figure_data['monod_glucose_anae'].drop(9999) aerobic_sweep_data_df = aerobic_sweep_data_df.transpose().fillna(0) anaerobic_sweep_data_df = anaerobic_sweep_data_df.transpose().fillna(0) plot_data = [('aerobic conditions', aerobic_sweep_data_df, aerobic_data_df), ('anaerobic conditions', anaerobic_sweep_data_df, anaerobic_data_df)] monod_dfs = [] for title, sweep_df, data_df in plot_data: monod_df = pd.DataFrame(index=sweep_df.columns, columns=[MAX_GROWTH_RATE_L, MONOD_COEFF_L, HILL_COEFF_L], dtype=float) for efm in monod_df.index: try: popt, _ = curve_fit(MONOD_FUNC, sweep_df.index, sweep_df[efm], p0=p0, method='trf') monod_df.loc[efm, :] = popt except RuntimeError: print("cannot resolve Monod curve for EFM %d" % efm) monod_df.loc[efm, :] = np.nan # get fig3 data for plotting the other features monod_df = monod_df.join(data_df) monod_df[INV_MONOD_COEFF_L] = 1.0/monod_df[MONOD_COEFF_L] monod_df[MAX_GR_OVER_KM_L] = monod_df[MAX_GROWTH_RATE_L] * monod_df[INV_MONOD_COEFF_L] # calculate the value of the growth rate using the Monod curve # for LOW_GLUCOSE monod_df[GROWTH_RATE_LOW_GLU] = 0 for j in monod_df.index: monod_df.loc[j, GROWTH_RATE_LOW_GLU] = MONOD_FUNC(LOW_GLUCOSE, monod_df.at[j, MAX_GROWTH_RATE_L], monod_df.at[j, MONOD_COEFF_L], monod_df.at[j, HILL_COEFF_L]) monod_dfs.append((title, monod_df)) return monod_dfs def plot_monod_scatter(monod_dfs, y_var=MAX_GROWTH_RATE_L): fig = plt.figure(figsize=(15, 14)) gs1 = gridspec.GridSpec(2, 4, left=0.05, right=0.95, bottom=0.55, top=0.97) gs2 = gridspec.GridSpec(2, 4, left=0.05, right=0.95, bottom=0.06, top=0.45) axs = [] for i in range(2): for j in range(4): axs.append(plt.subplot(gs1[i, j])) for i in range(2): for j in range(4): axs.append(plt.subplot(gs2[i, j])) for i, ax in enumerate(axs): ax.annotate(chr(ord('a')+i), xy=(0.04, 0.95), xycoords='axes fraction', ha='left', va='top', size=20) for i, (title, monod_df) in enumerate(monod_dfs): xaxis_data = [(INV_MONOD_COEFF_L, (1, 2500), 'log'), (GROWTH_RATE_LOW_GLU, (0.001, 0.2), 'linear')] for j, (x_var, xlim, xscale) in enumerate(xaxis_data): ax_row = axs[4*i + 8*j : 4*i + 8*j + 4] ax = ax_row[0] x = monod_df[x_var] y = monod_df[y_var] CS = ax.scatter(x, y, s=12, marker='o', facecolors=(0.85, 0.85, 0.85), linewidth=0) for efm, (col, lab) in D.efm_dict.items(): if efm in x.index: ax.plot(x[efm], y[efm], markersize=5, marker='o', color=col, label=None) ax.annotate(lab, xy=(x[efm], y[efm]), xytext=(0, 5), textcoords='offset points', ha='center', va='bottom', color=col) ax.set_xlim(xlim[0], xlim[1]) ax.set_xscale(xscale) ax.set_title('%s' % title, fontsize=16) ax.set_xlabel(x_var, fontsize=16) ax.set_ylabel(y_var, fontsize=16) plot_parameters = [ {'c': D.OXYGEN_L, 'title': 'oxygen uptake' , 'ax': ax_row[1], 'vmin': 0, 'vmax': 0.8}, {'c': D.YIELD_L, 'title': 'yield' , 'ax': ax_row[2], 'vmin': 0, 'vmax': 30}, {'c': D.ACE_L, 'title': 'acetate secretion', 'ax': ax_row[3], 'vmin': 0, 'vmax': 0.6} ] for d in plot_parameters: x = monod_df[x_var] y = monod_df[y_var] c = monod_df[d['c']] CS = d['ax'].scatter(x, y, s=12, c=c, marker='o', linewidth=0, cmap='copper_r', vmin=d['vmin'], vmax=d['vmax']) cbar = plt.colorbar(CS, ax=d['ax']) cbar.set_label(d['c'], fontsize=12) d['ax'].set_title(d['title'], fontsize=16) if i % 2 == 1: d['ax'].set_xlabel(x_var, fontsize=16) d['ax'].set_xlim(xlim[0], xlim[1]) d['ax'].set_xscale(xscale) for i in range(16): axs[i].set_yscale('linear') axs[i].set_ylim(0, 0.85) if i % 8 == 0: axs[i].get_xaxis().set_visible(False) if i % 4 > 0: axs[i].get_yaxis().set_visible(False) return fig if __name__ == '__main__': figure_data = D.get_figure_data() monod_dfs = calculate_monod_parameters(figure_data) figS17 = plot_monod_scatter(monod_dfs) D.savefig(figS17, 'S17') #%% from pandas import ExcelWriter writer = ExcelWriter(os.path.join(D.OUTPUT_DIR, 'monod_params.xls')) for title, monod_df in monod_dfs: monod_df.to_excel(writer, title) writer.save()
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 10502, 641, 644, 379, 18365, 413, 6900, 199, 199, 32, 2502, 26, 949, 720, 199, 624, 199, 199, 646, 747, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 8027, 492, 27591, 795, 733, 199, 504, 7026, 14, 13416, 492, 15318, 63, 3269, 199, 646, 10269, 465, 577, 199, 646, 10634, 465, 6454, 421, 199, 3, 5896, 63, 20935, 1439, 899, 275, 577, 14, 5896, 63, 1864, 35, 459, 27191, 331, 261, 4942, 418, 199, 5896, 63, 20935, 1439, 899, 275, 413, 69, 13, 19, 327, 315, 333, 45, 12, 284, 14, 69, 14, 413, 399, 45, 199, 199, 4283, 63, 39, 11415, 2080, 63, 16553, 63, 44, 275, 283, 988, 20772, 273, 6634, 359, 72, 4, 25997, 17, 93, 4, 6616, 199, 39, 11415, 2080, 63, 16553, 63, 5896, 63, 20935, 275, 283, 22890, 273, 6634, 737, 60, 78, 5, 71, 2672, 60, 6553, 4, 45, 6482, 85, 331, 261, 359, 72, 4, 25997, 17, 93, 4, 6616, 450, 334, 17, 69, 19, 10, 5896, 63, 20935, 1439, 899, 9, 199, 11710, 22041, 63, 1439, 29512, 63, 44, 275, 283, 6671, 364, 9421, 359, 77, 45, 6482, 85, 331, 261, 6616, 199, 568, 54, 63, 11710, 22041, 63, 1439, 29512, 63, 44, 275, 283, 11668, 402, 10953, 364, 14678, 3134, 78, 59, 77, 45, 4, 25997, 17, 93, 4, 6616, 199, 4283, 63, 3975, 63, 14336, 63, 43, 45, 63, 44, 275, 283, 988, 14, 20772, 273, 6634, 1182, 2672, 43, 7348, 6671, 364, 93, 4, 971, 78, 59, 72, 4, 25997, 17, 93, 4, 333, 45, 4, 25997, 17, 93, 4, 6616, 199, 40, 14961, 63, 1439, 29512, 63, 44, 275, 283, 40, 778, 7355, 4294, 767, 7, 199, 199, 11710, 22041, 63, 19587, 275, 2400, 671, 12, 7192, 63, 988, 12, 1804, 63, 45, 12, 394, 520, 7192, 63, 988, 1182, 334, 17, 435, 334, 43, 63, 45, 15, 88, 6422, 72, 2736, 299, 16, 275, 334, 16, 14, 1780, 12, 413, 14, 16, 12, 413, 14, 16, 9, 199, 199, 318, 8671, 63, 2106, 364, 63, 3214, 8, 8941, 63, 576, 304, 272, 282, 281, 2873, 530, 63, 576, 63, 1587, 275, 9658, 63, 576, 459, 6807, 418, 272, 282, 281, 2873, 530, 63, 31701, 63, 576, 63, 1587, 275, 9658, 63, 576, 459, 2106, 364, 63, 27191, 331, 261, 63, 65, 3478, 418, 272, 376, 65, 281, 2873, 530, 63, 576, 63, 1587, 275, 9658, 63, 576, 459, 6738, 281, 2873, 530, 2278, 4824, 8, 5008, 9, 272, 376, 65, 281, 2873, 530, 63, 31701, 63, 576, 63, 1587, 275, 9658, 63, 576, 459, 2106, 364, 63, 27191, 331, 261, 63, 290, 3624, 2278, 4824, 8, 5008, 9, 339, 282, 281, 2873, 530, 63, 31701, 63, 576, 63, 1587, 275, 282, 281, 2873, 530, 63, 31701, 63, 576, 63, 1587, 14, 10483, 1252, 4498, 3540, 8, 16, 9, 272, 376, 65, 281, 2873, 530, 63, 31701, 63, 576, 63, 1587, 275, 376, 65, 281, 2873, 530, 63, 31701, 63, 576, 63, 1587, 14, 10483, 1252, 4498, 3540, 8, 16, 9, 339, 5137, 63, 576, 275, 4274, 65, 281, 2873, 530, 3704, 297, 282, 281, 2873, 530, 63, 31701, 63, 576, 63, 1587, 12, 282, 281, 2873, 530, 63, 576, 63, 1587, 395, 326, 661, 6738, 281, 2873, 530, 3704, 297, 376, 65, 281, 2873, 530, 63, 31701, 63, 576, 63, 1587, 12, 376, 65, 281, 2873, 530, 63, 576, 63, 1587, 1874, 2286, 3485, 364, 63, 10434, 275, 942, 272, 367, 2538, 12, 5584, 7840, 63, 1587, 12, 666, 63, 1587, 315, 5137, 63, 576, 26, 267, 3485, 364, 63, 1587, 275, 6454, 14, 9205, 8, 1080, 29, 31701, 63, 1587, 14, 3406, 12, 1816, 4362, 1524, 4283, 63, 39, 11415, 2080, 63, 16553, 63, 44, 12, 603, 615, 22041, 63, 1439, 29512, 63, 44, 12, 869, 14961, 63, 1439, 29512, 63, 44, 467, 1816, 2152, 29, 1609, 9, 267, 367, 9530, 77, 315, 3485, 364, 63, 1587, 14, 1080, 26, 288, 862, 26, 355, 299, 2992, 12, 485, 275, 15318, 63, 3269, 8, 11710, 22041, 63, 19587, 12, 5584, 7840, 63, 1587, 14, 1080, 12, 5584, 7840, 63, 1587, 59, 2829, 77, 467, 2511, 299, 16, 29, 80, 16, 12, 1083, 534, 454, 70, 358, 355, 3485, 364, 63, 1587, 14, 2102, 59, 2829, 77, 12, 12228, 275, 299, 2992, 288, 871, 6064, 26, 355, 870, 480, 11250, 7512, 10953, 364, 15318, 367, 662, 22367, 450, 68, 2, 450, 9530, 77, 9, 355, 3485, 364, 63, 1587, 14, 2102, 59, 2829, 77, 12, 12228, 275, 980, 14, 4304, 398, 327, 664, 6085, 19, 666, 367, 25174, 314, 1163, 4534, 267, 3485, 364, 63, 1587, 275, 3485, 364, 63, 1587, 14, 904, 8, 576, 63, 1587, 9, 267, 3485, 364, 63, 1587, 59, 568, 54, 63, 11710, 22041, 63, 1439, 29512, 63, 44, 61, 275, 413, 14, 16, 15, 2106, 364, 63, 1587, 59, 11710, 22041, 63, 1439, 29512, 63, 44, 61, 267, 3485, 364, 63, 1587, 59, 4283, 63, 3975, 63, 14336, 63, 43, 45, 63, 44, 61, 275, 3485, 364, 63, 1587, 59, 4283, 63, 39, 11415, 2080, 63, 16553, 63, 44, 61, 627, 3485, 364, 63, 1587, 59, 568, 54, 63, 11710, 22041, 63, 1439, 29512, 63, 44, 61, 398, 327, 8671, 314, 574, 402, 314, 20772, 273, 6634, 1808, 314, 10953, 364, 15318, 267, 327, 367, 21359, 63, 20935, 1439, 899, 398, 3485, 364, 63, 1587, 59, 39, 11415, 2080, 63, 16553, 63, 5896, 63, 20935, 61, 275, 378, 267, 367, 1335, 315, 3485, 364, 63, 1587, 14, 1080, 26, 288, 3485, 364, 63, 1587, 14, 2102, 59, 74, 12, 598, 11415, 2080, 63, 16553, 63, 5896, 63, 20935, 61, 275, 603, 615, 22041, 63, 19587, 8, 5896, 63, 20935, 1439, 899, 12, 2432, 3485, 364, 63, 1587, 14, 292, 59, 74, 12, 9141, 63, 39, 11415, 2080, 63, 16553, 63, 44, 467, 2432, 3485, 364, 63, 1587, 14, 292, 59, 74, 12, 603, 615, 22041, 63, 1439, 29512, 63, 44, 467, 2432, 3485, 364, 63, 1587, 14, 292, 59, 74, 12, 869, 14961, 63, 1439, 29512, 63, 44 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 10502, 641, 644, 379, 18365, 413, 6900, 199, 199, 32, 2502, 26, 949, 720, 199, 624, 199, 199, 646, 747, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 8027, 492, 27591, 795, 733, 199, 504, 7026, 14, 13416, 492, 15318, 63, 3269, 199, 646, 10269, 465, 577, 199, 646, 10634, 465, 6454, 421, 199, 3, 5896, 63, 20935, 1439, 899, 275, 577, 14, 5896, 63, 1864, 35, 459, 27191, 331, 261, 4942, 418, 199, 5896, 63, 20935, 1439, 899, 275, 413, 69, 13, 19, 327, 315, 333, 45, 12, 284, 14, 69, 14, 413, 399, 45, 199, 199, 4283, 63, 39, 11415, 2080, 63, 16553, 63, 44, 275, 283, 988, 20772, 273, 6634, 359, 72, 4, 25997, 17, 93, 4, 6616, 199, 39, 11415, 2080, 63, 16553, 63, 5896, 63, 20935, 275, 283, 22890, 273, 6634, 737, 60, 78, 5, 71, 2672, 60, 6553, 4, 45, 6482, 85, 331, 261, 359, 72, 4, 25997, 17, 93, 4, 6616, 450, 334, 17, 69, 19, 10, 5896, 63, 20935, 1439, 899, 9, 199, 11710, 22041, 63, 1439, 29512, 63, 44, 275, 283, 6671, 364, 9421, 359, 77, 45, 6482, 85, 331, 261, 6616, 199, 568, 54, 63, 11710, 22041, 63, 1439, 29512, 63, 44, 275, 283, 11668, 402, 10953, 364, 14678, 3134, 78, 59, 77, 45, 4, 25997, 17, 93, 4, 6616, 199, 4283, 63, 3975, 63, 14336, 63, 43, 45, 63, 44, 275, 283, 988, 14, 20772, 273, 6634, 1182, 2672, 43, 7348, 6671, 364, 93, 4, 971, 78, 59, 72, 4, 25997, 17, 93, 4, 333, 45, 4, 25997, 17, 93, 4, 6616, 199, 40, 14961, 63, 1439, 29512, 63, 44, 275, 283, 40, 778, 7355, 4294, 767, 7, 199, 199, 11710, 22041, 63, 19587, 275, 2400, 671, 12, 7192, 63, 988, 12, 1804, 63, 45, 12, 394, 520, 7192, 63, 988, 1182, 334, 17, 435, 334, 43, 63, 45, 15, 88, 6422, 72, 2736, 299, 16, 275, 334, 16, 14, 1780, 12, 413, 14, 16, 12, 413, 14, 16, 9, 199, 199, 318, 8671, 63, 2106, 364, 63, 3214, 8, 8941, 63, 576, 304, 272, 282, 281, 2873, 530, 63, 576, 63, 1587, 275, 9658, 63, 576, 459, 6807, 418, 272, 282, 281, 2873, 530, 63, 31701, 63, 576, 63, 1587, 275, 9658, 63, 576, 459, 2106, 364, 63, 27191, 331, 261, 63, 65, 3478, 418, 272, 376, 65, 281, 2873, 530, 63, 576, 63, 1587, 275, 9658, 63, 576, 459, 6738, 281, 2873, 530, 2278, 4824, 8, 5008, 9, 272, 376, 65, 281, 2873, 530, 63, 31701, 63, 576, 63, 1587, 275, 9658, 63, 576, 459, 2106, 364, 63, 27191, 331, 261, 63, 290, 3624, 2278, 4824, 8, 5008, 9, 339, 282, 281, 2873, 530, 63, 31701, 63, 576, 63, 1587, 275, 282, 281, 2873, 530, 63, 31701, 63, 576, 63, 1587, 14, 10483, 1252, 4498, 3540, 8, 16, 9, 272, 376, 65, 281, 2873, 530, 63, 31701, 63, 576, 63, 1587, 275, 376, 65, 281, 2873, 530, 63, 31701, 63, 576, 63, 1587, 14, 10483, 1252, 4498, 3540, 8, 16, 9, 339, 5137, 63, 576, 275, 4274, 65, 281, 2873, 530, 3704, 297, 282, 281, 2873, 530, 63, 31701, 63, 576, 63, 1587, 12, 282, 281, 2873, 530, 63, 576, 63, 1587, 395, 326, 661, 6738, 281, 2873, 530, 3704, 297, 376, 65, 281, 2873, 530, 63, 31701, 63, 576, 63, 1587, 12, 376, 65, 281, 2873, 530, 63, 576, 63, 1587, 1874, 2286, 3485, 364, 63, 10434, 275, 942, 272, 367, 2538, 12, 5584, 7840, 63, 1587, 12, 666, 63, 1587, 315, 5137, 63, 576, 26, 267, 3485, 364, 63, 1587, 275, 6454, 14, 9205, 8, 1080, 29, 31701, 63, 1587, 14, 3406, 12, 1816, 4362, 1524, 4283, 63, 39, 11415, 2080, 63, 16553, 63, 44, 12, 603, 615, 22041, 63, 1439, 29512, 63, 44, 12, 869, 14961, 63, 1439, 29512, 63, 44, 467, 1816, 2152, 29, 1609, 9, 267, 367, 9530, 77, 315, 3485, 364, 63, 1587, 14, 1080, 26, 288, 862, 26, 355, 299, 2992, 12, 485, 275, 15318, 63, 3269, 8, 11710, 22041, 63, 19587, 12, 5584, 7840, 63, 1587, 14, 1080, 12, 5584, 7840, 63, 1587, 59, 2829, 77, 467, 2511, 299, 16, 29, 80, 16, 12, 1083, 534, 454, 70, 358, 355, 3485, 364, 63, 1587, 14, 2102, 59, 2829, 77, 12, 12228, 275, 299, 2992, 288, 871, 6064, 26, 355, 870, 480, 11250, 7512, 10953, 364, 15318, 367, 662, 22367, 450, 68, 2, 450, 9530, 77, 9, 355, 3485, 364, 63, 1587, 14, 2102, 59, 2829, 77, 12, 12228, 275, 980, 14, 4304, 398, 327, 664, 6085, 19, 666, 367, 25174, 314, 1163, 4534, 267, 3485, 364, 63, 1587, 275, 3485, 364, 63, 1587, 14, 904, 8, 576, 63, 1587, 9, 267, 3485, 364, 63, 1587, 59, 568, 54, 63, 11710, 22041, 63, 1439, 29512, 63, 44, 61, 275, 413, 14, 16, 15, 2106, 364, 63, 1587, 59, 11710, 22041, 63, 1439, 29512, 63, 44, 61, 267, 3485, 364, 63, 1587, 59, 4283, 63, 3975, 63, 14336, 63, 43, 45, 63, 44, 61, 275, 3485, 364, 63, 1587, 59, 4283, 63, 39, 11415, 2080, 63, 16553, 63, 44, 61, 627, 3485, 364, 63, 1587, 59, 568, 54, 63, 11710, 22041, 63, 1439, 29512, 63, 44, 61, 398, 327, 8671, 314, 574, 402, 314, 20772, 273, 6634, 1808, 314, 10953, 364, 15318, 267, 327, 367, 21359, 63, 20935, 1439, 899, 398, 3485, 364, 63, 1587, 59, 39, 11415, 2080, 63, 16553, 63, 5896, 63, 20935, 61, 275, 378, 267, 367, 1335, 315, 3485, 364, 63, 1587, 14, 1080, 26, 288, 3485, 364, 63, 1587, 14, 2102, 59, 74, 12, 598, 11415, 2080, 63, 16553, 63, 5896, 63, 20935, 61, 275, 603, 615, 22041, 63, 19587, 8, 5896, 63, 20935, 1439, 899, 12, 2432, 3485, 364, 63, 1587, 14, 292, 59, 74, 12, 9141, 63, 39, 11415, 2080, 63, 16553, 63, 44, 467, 2432, 3485, 364, 63, 1587, 14, 292, 59, 74, 12, 603, 615, 22041, 63, 1439, 29512, 63, 44, 467, 2432, 3485, 364, 63, 1587, 14, 292, 59, 74, 12, 869, 14961, 63, 1439, 29512, 63, 44, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
archman/phantasy
phantasy/__init__.py
1
1546
import logging # from phantasy.library.model import flame as flameutils # from phantasy.library import channelfinder from phantasy.library import lattice from phantasy.library import layout from phantasy.library import misc from phantasy.library import model from phantasy.library import operation from phantasy.library import parser from phantasy.library import physics from phantasy.library import pv from phantasy.library import scan from phantasy.library import settings from phantasy.library import data from phantasy.library import * # __authors__ = "Tong Zhang" __copyright__ = "(c) 2016-2017, Facility for Rare Isotope beams," \ " Michigan State University" __contact__ = "Tong Zhang <zhangt@frib.msu.edu>" __version__ = "0.7.0" __doc__ = \ """PHANTASY: [P]hysics [H]igh-level [A]pplications a[N]d [T]oolkits for [A]ccelerator [SY]stem. Main features of ``phantasy``: - Creating virtual accelerators, EPICS controls environment; - Modeling and tuning accelerator on high-level computing stage; - General interface for physics applications; Physics applications built on top of ``phantasy`` are developed as another repo: ``phantasy-apps``, whose names in Debian repo are prefixed with ``python-``, i.e. ``python-phantasy`` and ``python-phantasy-apps``. More details see documentation at https://controls.frib.msu.edu/phantasy/. :version: %s :authors: %s """ % (__version__, __authors__) __all__ = ['flameutils', 'MachinePortal'] logging.basicConfig(format="%(levelname)s: %(asctime)s: %(name)s: %(message)s")
bsd-3-clause
[ 646, 2050, 199, 199, 3, 199, 504, 3945, 867, 5660, 14, 4342, 14, 1238, 492, 2717, 313, 465, 2717, 313, 1208, 199, 199, 3, 199, 504, 3945, 867, 5660, 14, 4342, 492, 15985, 685, 276, 5755, 199, 504, 3945, 867, 5660, 14, 4342, 492, 30952, 199, 504, 3945, 867, 5660, 14, 4342, 492, 7054, 199, 504, 3945, 867, 5660, 14, 4342, 492, 18576, 199, 504, 3945, 867, 5660, 14, 4342, 492, 1402, 199, 504, 3945, 867, 5660, 14, 4342, 492, 3439, 199, 504, 3945, 867, 5660, 14, 4342, 492, 1798, 199, 504, 3945, 867, 5660, 14, 4342, 492, 11831, 17378, 199, 504, 3945, 867, 5660, 14, 4342, 492, 20279, 199, 504, 3945, 867, 5660, 14, 4342, 492, 8000, 199, 504, 3945, 867, 5660, 14, 4342, 492, 2202, 199, 504, 3945, 867, 5660, 14, 4342, 492, 666, 199, 199, 504, 3945, 867, 5660, 14, 4342, 492, 627, 421, 199, 3, 199, 363, 8149, 363, 275, 298, 52, 951, 3107, 27304, 2, 199, 363, 7307, 363, 275, 7340, 67, 9, 7800, 13, 10680, 12, 10859, 12498, 367, 820, 1530, 6596, 3459, 321, 17453, 83, 4589, 971, 355, 298, 603, 1158, 528, 290, 8511, 15904, 2, 199, 363, 7811, 363, 275, 298, 52, 951, 3107, 27304, 665, 3951, 621, 84, 32, 25876, 66, 14, 706, 85, 14, 8654, 4335, 199, 363, 1023, 363, 275, 298, 16, 14, 23, 14, 16, 2, 199, 199, 363, 1301, 363, 275, 971, 199, 624, 9791, 1441, 26222, 26, 359, 48, 61, 3577, 17378, 359, 40, 61, 2056, 13, 1896, 359, 33, 61, 802, 10785, 282, 59, 46, 61, 68, 359, 52, 61, 21943, 75, 1405, 367, 199, 59, 33, 61, 67, 27139, 359, 4669, 61, 18446, 14, 199, 199, 6756, 4534, 402, 1124, 838, 867, 5660, 18983, 199, 199, 13, 20507, 5791, 1066, 11338, 2750, 12, 31922, 21174, 13467, 3734, 27, 199, 13, 4900, 2983, 436, 15486, 316, 1066, 27139, 641, 4721, 13, 1896, 17226, 9546, 27, 199, 13, 1696, 3217, 367, 11831, 17378, 13103, 27, 199, 199, 6678, 17378, 13103, 6137, 641, 2746, 402, 1124, 838, 867, 5660, 1040, 787, 477, 27813, 465, 4573, 199, 3417, 26, 1124, 838, 867, 5660, 13, 5181, 4542, 7447, 1561, 315, 30445, 3831, 787, 18239, 543, 199, 1040, 1548, 13, 4542, 284, 14, 69, 14, 1124, 1548, 13, 838, 867, 5660, 1040, 436, 1124, 1548, 13, 838, 867, 5660, 13, 5181, 4345, 199, 199, 11053, 2436, 1937, 3794, 737, 4178, 921, 13658, 14, 25876, 66, 14, 706, 85, 14, 8654, 15, 838, 867, 5660, 8083, 199, 199, 26, 1023, 26, 450, 83, 199, 26, 8149, 26, 450, 83, 199, 624, 450, 25373, 1023, 3108, 636, 8149, 3368, 199, 199, 363, 452, 363, 275, 788, 2327, 313, 1208, 297, 283, 8412, 26708, 418, 199, 199, 4806, 14, 19602, 8, 908, 17662, 20056, 9, 83, 26, 2818, 18331, 9, 83, 26, 2818, 354, 9, 83, 26, 2818, 1188, 9, 83, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2050, 199, 199, 3, 199, 504, 3945, 867, 5660, 14, 4342, 14, 1238, 492, 2717, 313, 465, 2717, 313, 1208, 199, 199, 3, 199, 504, 3945, 867, 5660, 14, 4342, 492, 15985, 685, 276, 5755, 199, 504, 3945, 867, 5660, 14, 4342, 492, 30952, 199, 504, 3945, 867, 5660, 14, 4342, 492, 7054, 199, 504, 3945, 867, 5660, 14, 4342, 492, 18576, 199, 504, 3945, 867, 5660, 14, 4342, 492, 1402, 199, 504, 3945, 867, 5660, 14, 4342, 492, 3439, 199, 504, 3945, 867, 5660, 14, 4342, 492, 1798, 199, 504, 3945, 867, 5660, 14, 4342, 492, 11831, 17378, 199, 504, 3945, 867, 5660, 14, 4342, 492, 20279, 199, 504, 3945, 867, 5660, 14, 4342, 492, 8000, 199, 504, 3945, 867, 5660, 14, 4342, 492, 2202, 199, 504, 3945, 867, 5660, 14, 4342, 492, 666, 199, 199, 504, 3945, 867, 5660, 14, 4342, 492, 627, 421, 199, 3, 199, 363, 8149, 363, 275, 298, 52, 951, 3107, 27304, 2, 199, 363, 7307, 363, 275, 7340, 67, 9, 7800, 13, 10680, 12, 10859, 12498, 367, 820, 1530, 6596, 3459, 321, 17453, 83, 4589, 971, 355, 298, 603, 1158, 528, 290, 8511, 15904, 2, 199, 363, 7811, 363, 275, 298, 52, 951, 3107, 27304, 665, 3951, 621, 84, 32, 25876, 66, 14, 706, 85, 14, 8654, 4335, 199, 363, 1023, 363, 275, 298, 16, 14, 23, 14, 16, 2, 199, 199, 363, 1301, 363, 275, 971, 199, 624, 9791, 1441, 26222, 26, 359, 48, 61, 3577, 17378, 359, 40, 61, 2056, 13, 1896, 359, 33, 61, 802, 10785, 282, 59, 46, 61, 68, 359, 52, 61, 21943, 75, 1405, 367, 199, 59, 33, 61, 67, 27139, 359, 4669, 61, 18446, 14, 199, 199, 6756, 4534, 402, 1124, 838, 867, 5660, 18983, 199, 199, 13, 20507, 5791, 1066, 11338, 2750, 12, 31922, 21174, 13467, 3734, 27, 199, 13, 4900, 2983, 436, 15486, 316, 1066, 27139, 641, 4721, 13, 1896, 17226, 9546, 27, 199, 13, 1696, 3217, 367, 11831, 17378, 13103, 27, 199, 199, 6678, 17378, 13103, 6137, 641, 2746, 402, 1124, 838, 867, 5660, 1040, 787, 477, 27813, 465, 4573, 199, 3417, 26, 1124, 838, 867, 5660, 13, 5181, 4542, 7447, 1561, 315, 30445, 3831, 787, 18239, 543, 199, 1040, 1548, 13, 4542, 284, 14, 69, 14, 1124, 1548, 13, 838, 867, 5660, 1040, 436, 1124, 1548, 13, 838, 867, 5660, 13, 5181, 4345, 199, 199, 11053, 2436, 1937, 3794, 737, 4178, 921, 13658, 14, 25876, 66, 14, 706, 85, 14, 8654, 15, 838, 867, 5660, 8083, 199, 199, 26, 1023, 26, 450, 83, 199, 26, 8149, 26, 450, 83, 199, 624, 450, 25373, 1023, 3108, 636, 8149, 3368, 199, 199, 363, 452, 363, 275, 788, 2327, 313, 1208, 297, 283, 8412, 26708, 418, 199, 199, 4806, 14, 19602, 8, 908, 17662, 20056, 9, 83, 26, 2818, 18331, 9, 83, 26, 2818, 354, 9, 83, 26, 2818, 1188, 9, 83, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
itmanagerro/tresting
qa/rpc-tests/test_framework/address.py
96
2272
#!/usr/bin/env python3 # Copyright (c) 2016 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. # # address.py # # This file encodes and decodes BASE58 P2PKH and P2SH addresses # from .script import hash256, hash160, sha256, CScript, OP_0 from .util import bytes_to_hex_str, hex_str_to_bytes chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' def byte_to_base58(b, version): result = '' str = bytes_to_hex_str(b) str = bytes_to_hex_str(chr(version).encode('latin-1')) + str checksum = bytes_to_hex_str(hash256(hex_str_to_bytes(str))) str += checksum[:8] value = int('0x'+str,0) while value > 0: result = chars[value % 58] + result value //= 58 while (str[:2] == '00'): result = chars[0] + result str = str[2:] return result # TODO: def base58_decode def keyhash_to_p2pkh(hash, main = False): assert (len(hash) == 20) version = 0 if main else 111 return byte_to_base58(hash, version) def scripthash_to_p2sh(hash, main = False): assert (len(hash) == 20) version = 5 if main else 196 return byte_to_base58(hash, version) def key_to_p2pkh(key, main = False): key = check_key(key) return keyhash_to_p2pkh(hash160(key), main) def script_to_p2sh(script, main = False): script = check_script(script) return scripthash_to_p2sh(hash160(script), main) def key_to_p2sh_p2wpkh(key, main = False): key = check_key(key) p2shscript = CScript([OP_0, hash160(key)]) return script_to_p2sh(p2shscript, main) def script_to_p2sh_p2wsh(script, main = False): script = check_script(script) p2shscript = CScript([OP_0, sha256(script)]) return script_to_p2sh(p2shscript, main) def check_key(key): if (type(key) is str): key = hex_str_to_bytes(key) # Assuming this is hex string if (type(key) is bytes and (len(key) == 33 or len(key) == 65)): return key assert(False) def check_script(script): if (type(script) is str): script = hex_str_to_bytes(script) # Assuming this is hex string if (type(script) is bytes or type(script) is CScript): return script assert(False)
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1898, 334, 67, 9, 7800, 710, 21158, 11672, 19782, 199, 3, 17484, 1334, 314, 10697, 2032, 4190, 12, 1937, 314, 23073, 199, 3, 570, 9685, 503, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 14, 199, 199, 3, 199, 3, 2287, 14, 647, 199, 3, 199, 3, 961, 570, 3752, 83, 436, 4849, 83, 19721, 2010, 510, 18, 8884, 40, 436, 510, 18, 3234, 7149, 199, 3, 199, 199, 504, 1275, 1579, 492, 2631, 3912, 12, 2631, 8488, 12, 7793, 3912, 12, 24682, 12, 9827, 63, 16, 199, 504, 1275, 1974, 492, 2783, 63, 475, 63, 4097, 63, 495, 12, 6318, 63, 495, 63, 475, 63, 2394, 199, 199, 6574, 275, 283, 11272, 22897, 22313, 14307, 45, 14970, 26018, 18677, 75, 19748, 21832, 7, 199, 199, 318, 3696, 63, 475, 63, 1095, 2010, 8, 66, 12, 1015, 304, 272, 754, 275, 2125, 272, 620, 275, 2783, 63, 475, 63, 4097, 63, 495, 8, 66, 9, 272, 620, 275, 2783, 63, 475, 63, 4097, 63, 495, 8, 10194, 8, 1023, 680, 2143, 360, 10378, 13, 17, 1333, 435, 620, 272, 9040, 275, 2783, 63, 475, 63, 4097, 63, 495, 8, 2227, 3912, 8, 4097, 63, 495, 63, 475, 63, 2394, 8, 495, 1724, 272, 620, 847, 9040, 1491, 24, 61, 272, 574, 275, 1109, 360, 16, 88, 6828, 495, 12, 16, 9, 272, 1830, 574, 690, 378, 26, 267, 754, 275, 8365, 59, 585, 450, 13713, 61, 435, 754, 267, 574, 5001, 29, 13713, 272, 1830, 334, 495, 1491, 18, 61, 508, 283, 383, 735, 267, 754, 275, 8365, 59, 16, 61, 435, 754, 267, 620, 275, 620, 59, 18, 2938, 272, 372, 754, 199, 199, 3, 3254, 26, 347, 1300, 2010, 63, 2708, 199, 199, 318, 790, 2227, 63, 475, 63, 80, 18, 2051, 72, 8, 2227, 12, 2446, 275, 756, 304, 272, 702, 334, 552, 8, 2227, 9, 508, 3388, 9, 272, 1015, 275, 378, 340, 2446, 587, 20128, 272, 372, 3696, 63, 475, 63, 1095, 2010, 8, 2227, 12, 1015, 9, 199, 199, 318, 308, 1408, 13316, 1119, 63, 475, 63, 80, 18, 609, 8, 2227, 12, 2446, 275, 756, 304, 272, 702, 334, 552, 8, 2227, 9, 508, 3388, 9, 272, 1015, 275, 959, 340, 2446, 587, 32132, 272, 372, 3696, 63, 475, 63, 1095, 2010, 8, 2227, 12, 1015, 9, 199, 199, 318, 790, 63, 475, 63, 80, 18, 2051, 72, 8, 498, 12, 2446, 275, 756, 304, 272, 790, 275, 1104, 63, 498, 8, 498, 9, 272, 372, 790, 2227, 63, 475, 63, 80, 18, 2051, 72, 8, 2227, 8488, 8, 498, 395, 2446, 9, 199, 199, 318, 2884, 63, 475, 63, 80, 18, 609, 8, 1579, 12, 2446, 275, 756, 304, 272, 2884, 275, 1104, 63, 1579, 8, 1579, 9, 272, 372, 308, 1408, 13316, 1119, 63, 475, 63, 80, 18, 609, 8, 2227, 8488, 8, 1579, 395, 2446, 9, 199, 199, 318, 790, 63, 475, 63, 80, 18, 609, 63, 80, 18, 87, 2051, 72, 8, 498, 12, 2446, 275, 756, 304, 272, 790, 275, 1104, 63, 498, 8, 498, 9, 272, 299, 18, 609, 1579, 275, 24682, 779, 1938, 63, 16, 12, 2631, 8488, 8, 498, 3948, 272, 372, 2884, 63, 475, 63, 80, 18, 609, 8, 80, 18, 609, 1579, 12, 2446, 9, 199, 199, 318, 2884, 63, 475, 63, 80, 18, 609, 63, 80, 18, 87, 609, 8, 1579, 12, 2446, 275, 756, 304, 272, 2884, 275, 1104, 63, 1579, 8, 1579, 9, 272, 299, 18, 609, 1579, 275, 24682, 779, 1938, 63, 16, 12, 7793, 3912, 8, 1579, 3948, 272, 372, 2884, 63, 475, 63, 80, 18, 609, 8, 80, 18, 609, 1579, 12, 2446, 9, 199, 199, 318, 1104, 63, 498, 8, 498, 304, 272, 340, 334, 466, 8, 498, 9, 365, 620, 304, 267, 790, 275, 6318, 63, 495, 63, 475, 63, 2394, 8, 498, 9, 327, 10829, 12848, 642, 365, 6318, 1059, 272, 340, 334, 466, 8, 498, 9, 365, 2783, 436, 334, 552, 8, 498, 9, 508, 9404, 503, 822, 8, 498, 9, 508, 11738, 2298, 267, 372, 790, 272, 702, 8, 797, 9, 199, 199, 318, 1104, 63, 1579, 8, 1579, 304, 272, 340, 334, 466, 8, 1579, 9, 365, 620, 304, 267, 2884, 275, 6318, 63, 495, 63, 475, 63, 2394, 8, 1579, 9, 327, 10829, 12848, 642, 365, 6318, 1059, 272, 340, 334, 466, 8, 1579, 9, 365, 2783, 503, 730, 8, 1579, 9, 365, 24682, 304, 267, 372, 2884, 272, 702, 8, 797, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1898, 334, 67, 9, 7800, 710, 21158, 11672, 19782, 199, 3, 17484, 1334, 314, 10697, 2032, 4190, 12, 1937, 314, 23073, 199, 3, 570, 9685, 503, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 14, 199, 199, 3, 199, 3, 2287, 14, 647, 199, 3, 199, 3, 961, 570, 3752, 83, 436, 4849, 83, 19721, 2010, 510, 18, 8884, 40, 436, 510, 18, 3234, 7149, 199, 3, 199, 199, 504, 1275, 1579, 492, 2631, 3912, 12, 2631, 8488, 12, 7793, 3912, 12, 24682, 12, 9827, 63, 16, 199, 504, 1275, 1974, 492, 2783, 63, 475, 63, 4097, 63, 495, 12, 6318, 63, 495, 63, 475, 63, 2394, 199, 199, 6574, 275, 283, 11272, 22897, 22313, 14307, 45, 14970, 26018, 18677, 75, 19748, 21832, 7, 199, 199, 318, 3696, 63, 475, 63, 1095, 2010, 8, 66, 12, 1015, 304, 272, 754, 275, 2125, 272, 620, 275, 2783, 63, 475, 63, 4097, 63, 495, 8, 66, 9, 272, 620, 275, 2783, 63, 475, 63, 4097, 63, 495, 8, 10194, 8, 1023, 680, 2143, 360, 10378, 13, 17, 1333, 435, 620, 272, 9040, 275, 2783, 63, 475, 63, 4097, 63, 495, 8, 2227, 3912, 8, 4097, 63, 495, 63, 475, 63, 2394, 8, 495, 1724, 272, 620, 847, 9040, 1491, 24, 61, 272, 574, 275, 1109, 360, 16, 88, 6828, 495, 12, 16, 9, 272, 1830, 574, 690, 378, 26, 267, 754, 275, 8365, 59, 585, 450, 13713, 61, 435, 754, 267, 574, 5001, 29, 13713, 272, 1830, 334, 495, 1491, 18, 61, 508, 283, 383, 735, 267, 754, 275, 8365, 59, 16, 61, 435, 754, 267, 620, 275, 620, 59, 18, 2938, 272, 372, 754, 199, 199, 3, 3254, 26, 347, 1300, 2010, 63, 2708, 199, 199, 318, 790, 2227, 63, 475, 63, 80, 18, 2051, 72, 8, 2227, 12, 2446, 275, 756, 304, 272, 702, 334, 552, 8, 2227, 9, 508, 3388, 9, 272, 1015, 275, 378, 340, 2446, 587, 20128, 272, 372, 3696, 63, 475, 63, 1095, 2010, 8, 2227, 12, 1015, 9, 199, 199, 318, 308, 1408, 13316, 1119, 63, 475, 63, 80, 18, 609, 8, 2227, 12, 2446, 275, 756, 304, 272, 702, 334, 552, 8, 2227, 9, 508, 3388, 9, 272, 1015, 275, 959, 340, 2446, 587, 32132, 272, 372, 3696, 63, 475, 63, 1095, 2010, 8, 2227, 12, 1015, 9, 199, 199, 318, 790, 63, 475, 63, 80, 18, 2051, 72, 8, 498, 12, 2446, 275, 756, 304, 272, 790, 275, 1104, 63, 498, 8, 498, 9, 272, 372, 790, 2227, 63, 475, 63, 80, 18, 2051, 72, 8, 2227, 8488, 8, 498, 395, 2446, 9, 199, 199, 318, 2884, 63, 475, 63, 80, 18, 609, 8, 1579, 12, 2446, 275, 756, 304, 272, 2884, 275, 1104, 63, 1579, 8, 1579, 9, 272, 372, 308, 1408, 13316, 1119, 63, 475, 63, 80, 18, 609, 8, 2227, 8488, 8, 1579, 395, 2446, 9, 199, 199, 318, 790, 63, 475, 63, 80, 18, 609, 63, 80, 18, 87, 2051, 72, 8, 498, 12, 2446, 275, 756, 304, 272, 790, 275, 1104, 63, 498, 8, 498, 9, 272, 299, 18, 609, 1579, 275, 24682, 779, 1938, 63, 16, 12, 2631, 8488, 8, 498, 3948, 272, 372, 2884, 63, 475, 63, 80, 18, 609, 8, 80, 18, 609, 1579, 12, 2446, 9, 199, 199, 318, 2884, 63, 475, 63, 80, 18, 609, 63, 80, 18, 87, 609, 8, 1579, 12, 2446, 275, 756, 304, 272, 2884, 275, 1104, 63, 1579, 8, 1579, 9, 272, 299, 18, 609, 1579, 275, 24682, 779, 1938, 63, 16, 12, 7793, 3912, 8, 1579, 3948, 272, 372, 2884, 63, 475, 63, 80, 18, 609, 8, 80, 18, 609, 1579, 12, 2446, 9, 199, 199, 318, 1104, 63, 498, 8, 498, 304, 272, 340, 334, 466, 8, 498, 9, 365, 620, 304, 267, 790, 275, 6318, 63, 495, 63, 475, 63, 2394, 8, 498, 9, 327, 10829, 12848, 642, 365, 6318, 1059, 272, 340, 334, 466, 8, 498, 9, 365, 2783, 436, 334, 552, 8, 498, 9, 508, 9404, 503, 822, 8, 498, 9, 508, 11738, 2298, 267, 372, 790, 272, 702, 8, 797, 9, 199, 199, 318, 1104, 63, 1579, 8, 1579, 304, 272, 340, 334, 466, 8, 1579, 9, 365, 620, 304, 267, 2884, 275, 6318, 63, 495, 63, 475, 63, 2394, 8, 1579, 9, 327, 10829, 12848, 642, 365, 6318, 1059, 272, 340, 334, 466, 8, 1579, 9, 365, 2783, 503, 730, 8, 1579, 9, 365, 24682, 304, 267, 372, 2884, 272, 702, 8, 797, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
LinkHS/incubator-mxnet
example/neural-style/end_to_end/model_vgg19.py
43
6553
# 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 mxnet as mx import os, sys from collections import namedtuple ConvExecutor = namedtuple('ConvExecutor', ['executor', 'data', 'data_grad', 'style', 'content', 'arg_dict']) def get_vgg_symbol(prefix, content_only=False): # declare symbol data = mx.sym.Variable("%s_data" % prefix) conv1_1 = mx.symbol.Convolution(name='%s_conv1_1' % prefix, data=data , num_filter=64, pad=(1,1), kernel=(3,3), stride=(1,1), workspace=1024) relu1_1 = mx.symbol.Activation(data=conv1_1 , act_type='relu') conv1_2 = mx.symbol.Convolution(name='%s_conv1_2' % prefix, data=relu1_1 , num_filter=64, pad=(1,1), kernel=(3,3), stride=(1,1), workspace=1024) relu1_2 = mx.symbol.Activation(data=conv1_2 , act_type='relu') pool1 = mx.symbol.Pooling(data=relu1_2 , pad=(0,0), kernel=(2,2), stride=(2,2), pool_type='avg') conv2_1 = mx.symbol.Convolution(name='%s_conv2_1' % prefix, data=pool1 , num_filter=128, pad=(1,1), kernel=(3,3), stride=(1,1), workspace=1024) relu2_1 = mx.symbol.Activation(data=conv2_1 , act_type='relu') conv2_2 = mx.symbol.Convolution(name='%s_conv2_2' % prefix, data=relu2_1 , num_filter=128, pad=(1,1), kernel=(3,3), stride=(1,1), workspace=1024) relu2_2 = mx.symbol.Activation(data=conv2_2 , act_type='relu') pool2 = mx.symbol.Pooling(data=relu2_2 , pad=(0,0), kernel=(2,2), stride=(2,2), pool_type='avg') conv3_1 = mx.symbol.Convolution(name='%s_conv3_1' % prefix, data=pool2 , num_filter=256, pad=(1,1), kernel=(3,3), stride=(1,1), workspace=1024) relu3_1 = mx.symbol.Activation(data=conv3_1 , act_type='relu') conv3_2 = mx.symbol.Convolution(name='%s_conv3_2' % prefix, data=relu3_1 , num_filter=256, pad=(1,1), kernel=(3,3), stride=(1,1), workspace=1024) relu3_2 = mx.symbol.Activation(data=conv3_2 , act_type='relu') conv3_3 = mx.symbol.Convolution(name='%s_conv3_3' % prefix, data=relu3_2 , num_filter=256, pad=(1,1), kernel=(3,3), stride=(1,1), workspace=1024) relu3_3 = mx.symbol.Activation(data=conv3_3 , act_type='relu') conv3_4 = mx.symbol.Convolution(name='%s_conv3_4' % prefix, data=relu3_3 , num_filter=256, pad=(1,1), kernel=(3,3), stride=(1,1), workspace=1024) relu3_4 = mx.symbol.Activation(data=conv3_4 , act_type='relu') pool3 = mx.symbol.Pooling(data=relu3_4 , pad=(0,0), kernel=(2,2), stride=(2,2), pool_type='avg') conv4_1 = mx.symbol.Convolution(name='%s_conv4_1' % prefix, data=pool3 , num_filter=512, pad=(1,1), kernel=(3,3), stride=(1,1), workspace=1024) relu4_1 = mx.symbol.Activation(data=conv4_1 , act_type='relu') conv4_2 = mx.symbol.Convolution(name='%s_conv4_2' % prefix, data=relu4_1 , num_filter=512, pad=(1,1), kernel=(3,3), stride=(1,1), workspace=1024) relu4_2 = mx.symbol.Activation(data=conv4_2 , act_type='relu') conv4_3 = mx.symbol.Convolution(name='%s_conv4_3' % prefix, data=relu4_2 , num_filter=512, pad=(1,1), kernel=(3,3), stride=(1,1), workspace=1024) relu4_3 = mx.symbol.Activation(data=conv4_3 , act_type='relu') conv4_4 = mx.symbol.Convolution(name='%s_conv4_4' % prefix, data=relu4_3 , num_filter=512, pad=(1,1), kernel=(3,3), stride=(1,1), workspace=1024) relu4_4 = mx.symbol.Activation(data=conv4_4 , act_type='relu') pool4 = mx.symbol.Pooling(data=relu4_4 , pad=(0,0), kernel=(2,2), stride=(2,2), pool_type='avg') conv5_1 = mx.symbol.Convolution(name='%s_conv5_1' % prefix, data=pool4 , num_filter=512, pad=(1,1), kernel=(3,3), stride=(1,1), workspace=1024) relu5_1 = mx.symbol.Activation(data=conv5_1 , act_type='relu') if content_only: return relu4_2 # style and content layers style = mx.sym.Group([relu1_1, relu2_1, relu3_1, relu4_1, relu5_1]) content = mx.sym.Group([relu4_2]) return style, content def get_executor_with_style(style, content, input_size, ctx): out = mx.sym.Group([style, content]) # make executor arg_shapes, output_shapes, aux_shapes = out.infer_shape(data=(1, 3, input_size[0], input_size[1])) arg_names = out.list_arguments() arg_dict = dict(zip(arg_names, [mx.nd.zeros(shape, ctx=ctx) for shape in arg_shapes])) grad_dict = {"data": arg_dict["data"].copyto(ctx)} # init with pretrained weight pretrained = mx.nd.load("./model/vgg19.params") for name in arg_names: if name == "data": continue key = "arg:" + name if key in pretrained: pretrained[key].copyto(arg_dict[name]) else: print("Skip argument %s" % name) executor = out.bind(ctx=ctx, args=arg_dict, args_grad=grad_dict, grad_req="write") return ConvExecutor(executor=executor, data=arg_dict["data"], data_grad=grad_dict["data"], style=executor.outputs[:-1], content=executor.outputs[-1], arg_dict=arg_dict) def get_executor_content(content, input_size, ctx): arg_shapes, output_shapes, aux_shapes = content.infer_shape(data=(1, 3, input_size[0], input_size[1])) arg_names = out.list_arguments() arg_dict = dict(zip(arg_names, [mx.nd.zeros(shape, ctx=ctx) for shape in arg_shapes])) pretrained = mx.nd.load("./model/vgg19.params") for name in arg_names: if name == "data": continue key = "arg:" + name if key in pretrained: pretrained[key].copyto(arg_dict[name]) else: print("Skip argument %s" % name) executor = out.bind(ctx=ctx, args=arg_dict, args_grad=[], grad_req="null") return ConvExecutor(executor=executor, data=arg_dict["data"], data_grad=None, style=None, content=executor.outputs[0], arg_dict=arg_dict)
apache-2.0
[ 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 8728, 846, 465, 8728, 199, 646, 747, 12, 984, 199, 504, 5055, 492, 12863, 199, 199, 11596, 16752, 275, 12863, 360, 11596, 16752, 297, 788, 13471, 297, 283, 576, 297, 283, 576, 63, 6017, 297, 283, 2487, 297, 283, 1317, 297, 283, 1273, 63, 807, 1105, 199, 199, 318, 664, 63, 27948, 63, 5155, 8, 1861, 12, 1564, 63, 2118, 29, 797, 304, 272, 327, 20771, 5272, 272, 666, 275, 8728, 14, 3840, 14, 2773, 3647, 83, 63, 576, 2, 450, 2403, 9, 272, 8260, 17, 63, 17, 275, 8728, 14, 5155, 14, 27394, 8, 354, 9569, 83, 63, 5598, 17, 63, 17, 7, 450, 2403, 12, 666, 29, 576, 2360, 1967, 63, 1541, 29, 772, 12, 6567, 2687, 17, 12, 17, 395, 5114, 2687, 19, 12, 19, 395, 7345, 2687, 17, 12, 17, 395, 14466, 29, 7727, 9, 272, 4668, 85, 17, 63, 17, 275, 8728, 14, 5155, 14, 19535, 8, 576, 29, 5598, 17, 63, 17, 2360, 2454, 63, 466, 534, 12833, 358, 272, 8260, 17, 63, 18, 275, 8728, 14, 5155, 14, 27394, 8, 354, 9569, 83, 63, 5598, 17, 63, 18, 7, 450, 2403, 12, 666, 29, 12833, 17, 63, 17, 2360, 1967, 63, 1541, 29, 772, 12, 6567, 2687, 17, 12, 17, 395, 5114, 2687, 19, 12, 19, 395, 7345, 2687, 17, 12, 17, 395, 14466, 29, 7727, 9, 272, 4668, 85, 17, 63, 18, 275, 8728, 14, 5155, 14, 19535, 8, 576, 29, 5598, 17, 63, 18, 2360, 2454, 63, 466, 534, 12833, 358, 272, 4203, 17, 275, 8728, 14, 5155, 14, 22349, 8, 576, 29, 12833, 17, 63, 18, 2360, 6567, 2687, 16, 12, 16, 395, 5114, 2687, 18, 12, 18, 395, 7345, 2687, 18, 12, 18, 395, 4203, 63, 466, 534, 8595, 358, 272, 8260, 18, 63, 17, 275, 8728, 14, 5155, 14, 27394, 8, 354, 9569, 83, 63, 5598, 18, 63, 17, 7, 450, 2403, 12, 666, 29, 2293, 17, 2360, 1967, 63, 1541, 29, 3933, 12, 6567, 2687, 17, 12, 17, 395, 5114, 2687, 19, 12, 19, 395, 7345, 2687, 17, 12, 17, 395, 14466, 29, 7727, 9, 272, 4668, 85, 18, 63, 17, 275, 8728, 14, 5155, 14, 19535, 8, 576, 29, 5598, 18, 63, 17, 2360, 2454, 63, 466, 534, 12833, 358, 272, 8260, 18, 63, 18, 275, 8728, 14, 5155, 14, 27394, 8, 354, 9569, 83, 63, 5598, 18, 63, 18, 7, 450, 2403, 12, 666, 29, 12833, 18, 63, 17, 2360, 1967, 63, 1541, 29, 3933, 12, 6567, 2687, 17, 12, 17, 395, 5114, 2687, 19, 12, 19, 395, 7345, 2687, 17, 12, 17, 395, 14466, 29, 7727, 9, 272, 4668, 85, 18, 63, 18, 275, 8728, 14, 5155, 14, 19535, 8, 576, 29, 5598, 18, 63, 18, 2360, 2454, 63, 466, 534, 12833, 358, 272, 4203, 18, 275, 8728, 14, 5155, 14, 22349, 8, 576, 29, 12833, 18, 63, 18, 2360, 6567, 2687, 16, 12, 16, 395, 5114, 2687, 18, 12, 18, 395, 7345, 2687, 18, 12, 18, 395, 4203, 63, 466, 534, 8595, 358, 272, 8260, 19, 63, 17, 275, 8728, 14, 5155, 14, 27394, 8, 354, 9569, 83, 63, 5598, 19, 63, 17, 7, 450, 2403, 12, 666, 29, 2293, 18, 2360, 1967, 63, 1541, 29, 3912, 12, 6567, 2687, 17, 12, 17, 395, 5114, 2687, 19, 12, 19, 395, 7345, 2687, 17, 12, 17, 395, 14466, 29, 7727, 9, 272, 4668, 85, 19, 63, 17, 275, 8728, 14, 5155, 14, 19535, 8, 576, 29, 5598, 19, 63, 17, 2360, 2454, 63, 466, 534, 12833, 358, 272, 8260, 19, 63, 18, 275, 8728, 14, 5155, 14, 27394, 8, 354, 9569, 83, 63, 5598, 19, 63, 18, 7, 450, 2403, 12, 666, 29, 12833, 19, 63, 17, 2360, 1967, 63, 1541, 29, 3912, 12, 6567, 2687, 17, 12, 17, 395, 5114, 2687, 19, 12, 19, 395, 7345, 2687, 17, 12, 17, 395, 14466, 29, 7727, 9, 272, 4668, 85, 19, 63, 18, 275, 8728, 14, 5155, 14, 19535, 8, 576, 29, 5598, 19, 63, 18, 2360, 2454, 63, 466, 534, 12833, 358, 272, 8260, 19, 63, 19, 275, 8728, 14, 5155, 14, 27394, 8, 354, 9569, 83, 63, 5598, 19, 63, 19, 7, 450, 2403, 12, 666, 29, 12833, 19, 63, 18, 2360, 1967, 63, 1541, 29, 3912, 12, 6567, 2687, 17, 12, 17, 395, 5114, 2687, 19, 12, 19, 395, 7345, 2687, 17, 12, 17, 395, 14466, 29, 7727, 9, 272, 4668, 85, 19, 63, 19, 275, 8728, 14, 5155, 14, 19535, 8, 576, 29, 5598, 19, 63, 19, 2360, 2454, 63, 466, 534, 12833, 358, 272, 8260, 19, 63, 20, 275, 8728, 14, 5155, 14, 27394, 8, 354, 9569, 83, 63, 5598, 19, 63, 20, 7, 450, 2403, 12, 666, 29, 12833, 19, 63, 19, 2360, 1967, 63, 1541, 29, 3912, 12, 6567, 2687, 17, 12, 17, 395, 5114, 2687, 19, 12, 19, 395, 7345, 2687, 17, 12, 17, 395, 14466, 29, 7727, 9, 272, 4668, 85, 19, 63, 20, 275, 8728, 14, 5155, 14, 19535, 8, 576, 29, 5598, 19, 63, 20, 2360, 2454, 63, 466, 534, 12833, 358, 272, 4203, 19 ]
[ 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 8728, 846, 465, 8728, 199, 646, 747, 12, 984, 199, 504, 5055, 492, 12863, 199, 199, 11596, 16752, 275, 12863, 360, 11596, 16752, 297, 788, 13471, 297, 283, 576, 297, 283, 576, 63, 6017, 297, 283, 2487, 297, 283, 1317, 297, 283, 1273, 63, 807, 1105, 199, 199, 318, 664, 63, 27948, 63, 5155, 8, 1861, 12, 1564, 63, 2118, 29, 797, 304, 272, 327, 20771, 5272, 272, 666, 275, 8728, 14, 3840, 14, 2773, 3647, 83, 63, 576, 2, 450, 2403, 9, 272, 8260, 17, 63, 17, 275, 8728, 14, 5155, 14, 27394, 8, 354, 9569, 83, 63, 5598, 17, 63, 17, 7, 450, 2403, 12, 666, 29, 576, 2360, 1967, 63, 1541, 29, 772, 12, 6567, 2687, 17, 12, 17, 395, 5114, 2687, 19, 12, 19, 395, 7345, 2687, 17, 12, 17, 395, 14466, 29, 7727, 9, 272, 4668, 85, 17, 63, 17, 275, 8728, 14, 5155, 14, 19535, 8, 576, 29, 5598, 17, 63, 17, 2360, 2454, 63, 466, 534, 12833, 358, 272, 8260, 17, 63, 18, 275, 8728, 14, 5155, 14, 27394, 8, 354, 9569, 83, 63, 5598, 17, 63, 18, 7, 450, 2403, 12, 666, 29, 12833, 17, 63, 17, 2360, 1967, 63, 1541, 29, 772, 12, 6567, 2687, 17, 12, 17, 395, 5114, 2687, 19, 12, 19, 395, 7345, 2687, 17, 12, 17, 395, 14466, 29, 7727, 9, 272, 4668, 85, 17, 63, 18, 275, 8728, 14, 5155, 14, 19535, 8, 576, 29, 5598, 17, 63, 18, 2360, 2454, 63, 466, 534, 12833, 358, 272, 4203, 17, 275, 8728, 14, 5155, 14, 22349, 8, 576, 29, 12833, 17, 63, 18, 2360, 6567, 2687, 16, 12, 16, 395, 5114, 2687, 18, 12, 18, 395, 7345, 2687, 18, 12, 18, 395, 4203, 63, 466, 534, 8595, 358, 272, 8260, 18, 63, 17, 275, 8728, 14, 5155, 14, 27394, 8, 354, 9569, 83, 63, 5598, 18, 63, 17, 7, 450, 2403, 12, 666, 29, 2293, 17, 2360, 1967, 63, 1541, 29, 3933, 12, 6567, 2687, 17, 12, 17, 395, 5114, 2687, 19, 12, 19, 395, 7345, 2687, 17, 12, 17, 395, 14466, 29, 7727, 9, 272, 4668, 85, 18, 63, 17, 275, 8728, 14, 5155, 14, 19535, 8, 576, 29, 5598, 18, 63, 17, 2360, 2454, 63, 466, 534, 12833, 358, 272, 8260, 18, 63, 18, 275, 8728, 14, 5155, 14, 27394, 8, 354, 9569, 83, 63, 5598, 18, 63, 18, 7, 450, 2403, 12, 666, 29, 12833, 18, 63, 17, 2360, 1967, 63, 1541, 29, 3933, 12, 6567, 2687, 17, 12, 17, 395, 5114, 2687, 19, 12, 19, 395, 7345, 2687, 17, 12, 17, 395, 14466, 29, 7727, 9, 272, 4668, 85, 18, 63, 18, 275, 8728, 14, 5155, 14, 19535, 8, 576, 29, 5598, 18, 63, 18, 2360, 2454, 63, 466, 534, 12833, 358, 272, 4203, 18, 275, 8728, 14, 5155, 14, 22349, 8, 576, 29, 12833, 18, 63, 18, 2360, 6567, 2687, 16, 12, 16, 395, 5114, 2687, 18, 12, 18, 395, 7345, 2687, 18, 12, 18, 395, 4203, 63, 466, 534, 8595, 358, 272, 8260, 19, 63, 17, 275, 8728, 14, 5155, 14, 27394, 8, 354, 9569, 83, 63, 5598, 19, 63, 17, 7, 450, 2403, 12, 666, 29, 2293, 18, 2360, 1967, 63, 1541, 29, 3912, 12, 6567, 2687, 17, 12, 17, 395, 5114, 2687, 19, 12, 19, 395, 7345, 2687, 17, 12, 17, 395, 14466, 29, 7727, 9, 272, 4668, 85, 19, 63, 17, 275, 8728, 14, 5155, 14, 19535, 8, 576, 29, 5598, 19, 63, 17, 2360, 2454, 63, 466, 534, 12833, 358, 272, 8260, 19, 63, 18, 275, 8728, 14, 5155, 14, 27394, 8, 354, 9569, 83, 63, 5598, 19, 63, 18, 7, 450, 2403, 12, 666, 29, 12833, 19, 63, 17, 2360, 1967, 63, 1541, 29, 3912, 12, 6567, 2687, 17, 12, 17, 395, 5114, 2687, 19, 12, 19, 395, 7345, 2687, 17, 12, 17, 395, 14466, 29, 7727, 9, 272, 4668, 85, 19, 63, 18, 275, 8728, 14, 5155, 14, 19535, 8, 576, 29, 5598, 19, 63, 18, 2360, 2454, 63, 466, 534, 12833, 358, 272, 8260, 19, 63, 19, 275, 8728, 14, 5155, 14, 27394, 8, 354, 9569, 83, 63, 5598, 19, 63, 19, 7, 450, 2403, 12, 666, 29, 12833, 19, 63, 18, 2360, 1967, 63, 1541, 29, 3912, 12, 6567, 2687, 17, 12, 17, 395, 5114, 2687, 19, 12, 19, 395, 7345, 2687, 17, 12, 17, 395, 14466, 29, 7727, 9, 272, 4668, 85, 19, 63, 19, 275, 8728, 14, 5155, 14, 19535, 8, 576, 29, 5598, 19, 63, 19, 2360, 2454, 63, 466, 534, 12833, 358, 272, 8260, 19, 63, 20, 275, 8728, 14, 5155, 14, 27394, 8, 354, 9569, 83, 63, 5598, 19, 63, 20, 7, 450, 2403, 12, 666, 29, 12833, 19, 63, 19, 2360, 1967, 63, 1541, 29, 3912, 12, 6567, 2687, 17, 12, 17, 395, 5114, 2687, 19, 12, 19, 395, 7345, 2687, 17, 12, 17, 395, 14466, 29, 7727, 9, 272, 4668, 85, 19, 63, 20, 275, 8728, 14, 5155, 14, 19535, 8, 576, 29, 5598, 19, 63, 20, 2360, 2454, 63, 466, 534, 12833, 358, 272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, 1, 1, 1, 1, 1 ]
CydarLtd/ansible
test/units/modules/network/junos/junos_module.py
31
3268
# (c) 2017 Red Hat 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/>. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type import os import json import xml.etree.ElementTree as ET from ansible.compat.tests import unittest from ansible.compat.tests.mock import patch from ansible.module_utils import basic from ansible.module_utils._text import to_bytes def set_module_args(args): args = json.dumps({'ANSIBLE_MODULE_ARGS': args}) basic._ANSIBLE_ARGS = to_bytes(args) fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') fixture_data = {} def load_fixture(name, content='xml'): path = os.path.join(fixture_path, name) if path in fixture_data: return fixture_data[path] if content == 'str': with open(path) as f: data = f.read() try: data = json.load(path) except: pass else: try: data = ET.parse(path).getroot() except: pass fixture_data[path] = data return data class AnsibleExitJson(Exception): pass class AnsibleFailJson(Exception): pass class TestJunosModule(unittest.TestCase): def execute_module(self, failed=False, changed=False, commands=None, sort=True, defaults=False, format='text'): self.load_fixtures(commands, format, changed=changed) if failed: result = self.failed() self.assertTrue(result['failed'], result) else: result = self.changed(changed) self.assertEqual(result['changed'], changed, result) return result def failed(self): def fail_json(*args, **kwargs): kwargs['failed'] = True raise AnsibleFailJson(kwargs) with patch.object(basic.AnsibleModule, 'fail_json', fail_json): with self.assertRaises(AnsibleFailJson) as exc: self.module.main() result = exc.exception.args[0] self.assertTrue(result['failed'], result) return result def changed(self, changed=False): def exit_json(*args, **kwargs): if 'changed' not in kwargs: kwargs['changed'] = False raise AnsibleExitJson(kwargs) with patch.object(basic.AnsibleModule, 'exit_json', exit_json): with self.assertRaises(AnsibleExitJson) as exc: self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], changed, result) return result def load_fixtures(self, commands=None, format=None, changed=None): pass
gpl-3.0
[ 3, 334, 67, 9, 9708, 9572, 13002, 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, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 747, 199, 646, 2022, 199, 199, 646, 2748, 14, 9464, 14, 15325, 465, 12265, 199, 199, 504, 3242, 14, 5819, 14, 2219, 492, 2882, 199, 504, 3242, 14, 5819, 14, 2219, 14, 1805, 492, 3371, 199, 504, 3242, 14, 578, 63, 1208, 492, 5678, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 2394, 421, 199, 318, 663, 63, 578, 63, 589, 8, 589, 304, 272, 1249, 275, 2022, 14, 4180, 3252, 8490, 63, 10001, 63, 13990, 356, 1249, 1552, 272, 5678, 423, 8490, 63, 13990, 275, 370, 63, 2394, 8, 589, 9, 199, 199, 5997, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 8769, 358, 199, 5997, 63, 576, 275, 1052, 421, 199, 318, 2248, 63, 5997, 8, 354, 12, 1564, 534, 1652, 735, 272, 931, 275, 747, 14, 515, 14, 904, 8, 5997, 63, 515, 12, 536, 9, 272, 340, 931, 315, 10949, 63, 576, 26, 267, 372, 10949, 63, 576, 59, 515, 61, 339, 340, 1564, 508, 283, 495, 356, 267, 543, 1551, 8, 515, 9, 465, 289, 26, 288, 666, 275, 289, 14, 739, 342, 267, 862, 26, 288, 666, 275, 2022, 14, 912, 8, 515, 9, 267, 871, 26, 288, 986, 272, 587, 26, 267, 862, 26, 288, 666, 275, 12265, 14, 1122, 8, 515, 680, 24544, 342, 267, 871, 26, 288, 986, 339, 10949, 63, 576, 59, 515, 61, 275, 666, 272, 372, 666, 421, 199, 533, 2622, 6699, 9653, 8, 1726, 304, 272, 986, 421, 199, 533, 2622, 4874, 9653, 8, 1726, 304, 272, 986, 421, 199, 533, 1379, 42, 21003, 2377, 8, 2796, 14, 1746, 304, 339, 347, 5341, 63, 578, 8, 277, 12, 3405, 29, 797, 12, 2896, 29, 797, 12, 3718, 29, 403, 12, 4069, 29, 549, 12, 4243, 29, 797, 12, 1475, 534, 505, 735, 398, 291, 14, 912, 63, 8769, 8, 4405, 12, 1475, 12, 2896, 29, 2489, 9, 398, 340, 3405, 26, 288, 754, 275, 291, 14, 4892, 342, 288, 291, 14, 1815, 8, 1099, 459, 4892, 995, 754, 9, 267, 587, 26, 288, 754, 275, 291, 14, 2489, 8, 2489, 9, 288, 291, 14, 629, 8, 1099, 459, 2489, 995, 2896, 12, 754, 9, 398, 372, 754, 339, 347, 3405, 8, 277, 304, 267, 347, 2449, 63, 1001, 2031, 589, 12, 1011, 958, 304, 288, 2074, 459, 4892, 418, 275, 715, 288, 746, 2622, 4874, 9653, 8, 958, 9, 398, 543, 3371, 14, 785, 8, 4316, 14, 10047, 2377, 12, 283, 1633, 63, 1001, 297, 2449, 63, 1001, 304, 288, 543, 291, 14, 1855, 8, 10047, 4874, 9653, 9, 465, 3178, 26, 355, 291, 14, 578, 14, 973, 342, 398, 754, 275, 3178, 14, 1971, 14, 589, 59, 16, 61, 267, 291, 14, 1815, 8, 1099, 459, 4892, 995, 754, 9, 267, 372, 754, 339, 347, 2896, 8, 277, 12, 2896, 29, 797, 304, 267, 347, 4458, 63, 1001, 2031, 589, 12, 1011, 958, 304, 288, 340, 283, 2489, 7, 440, 315, 2074, 26, 355, 2074, 459, 2489, 418, 275, 756, 288, 746, 2622, 6699, 9653, 8, 958, 9, 398, 543, 3371, 14, 785, 8, 4316, 14, 10047, 2377, 12, 283, 2224, 63, 1001, 297, 4458, 63, 1001, 304, 288, 543, 291, 14, 1855, 8, 10047, 6699, 9653, 9, 465, 3178, 26, 355, 291, 14, 578, 14, 973, 342, 398, 754, 275, 3178, 14, 1971, 14, 589, 59, 16, 61, 267, 291, 14, 629, 8, 1099, 459, 2489, 995, 2896, 12, 754, 9, 267, 372, 754, 339, 347, 2248, 63, 8769, 8, 277, 12, 3718, 29, 403, 12, 1475, 29, 403, 12, 2896, 29, 403, 304, 267, 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 ]
[ 334, 67, 9, 9708, 9572, 13002, 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, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 747, 199, 646, 2022, 199, 199, 646, 2748, 14, 9464, 14, 15325, 465, 12265, 199, 199, 504, 3242, 14, 5819, 14, 2219, 492, 2882, 199, 504, 3242, 14, 5819, 14, 2219, 14, 1805, 492, 3371, 199, 504, 3242, 14, 578, 63, 1208, 492, 5678, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 2394, 421, 199, 318, 663, 63, 578, 63, 589, 8, 589, 304, 272, 1249, 275, 2022, 14, 4180, 3252, 8490, 63, 10001, 63, 13990, 356, 1249, 1552, 272, 5678, 423, 8490, 63, 13990, 275, 370, 63, 2394, 8, 589, 9, 199, 199, 5997, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 8769, 358, 199, 5997, 63, 576, 275, 1052, 421, 199, 318, 2248, 63, 5997, 8, 354, 12, 1564, 534, 1652, 735, 272, 931, 275, 747, 14, 515, 14, 904, 8, 5997, 63, 515, 12, 536, 9, 272, 340, 931, 315, 10949, 63, 576, 26, 267, 372, 10949, 63, 576, 59, 515, 61, 339, 340, 1564, 508, 283, 495, 356, 267, 543, 1551, 8, 515, 9, 465, 289, 26, 288, 666, 275, 289, 14, 739, 342, 267, 862, 26, 288, 666, 275, 2022, 14, 912, 8, 515, 9, 267, 871, 26, 288, 986, 272, 587, 26, 267, 862, 26, 288, 666, 275, 12265, 14, 1122, 8, 515, 680, 24544, 342, 267, 871, 26, 288, 986, 339, 10949, 63, 576, 59, 515, 61, 275, 666, 272, 372, 666, 421, 199, 533, 2622, 6699, 9653, 8, 1726, 304, 272, 986, 421, 199, 533, 2622, 4874, 9653, 8, 1726, 304, 272, 986, 421, 199, 533, 1379, 42, 21003, 2377, 8, 2796, 14, 1746, 304, 339, 347, 5341, 63, 578, 8, 277, 12, 3405, 29, 797, 12, 2896, 29, 797, 12, 3718, 29, 403, 12, 4069, 29, 549, 12, 4243, 29, 797, 12, 1475, 534, 505, 735, 398, 291, 14, 912, 63, 8769, 8, 4405, 12, 1475, 12, 2896, 29, 2489, 9, 398, 340, 3405, 26, 288, 754, 275, 291, 14, 4892, 342, 288, 291, 14, 1815, 8, 1099, 459, 4892, 995, 754, 9, 267, 587, 26, 288, 754, 275, 291, 14, 2489, 8, 2489, 9, 288, 291, 14, 629, 8, 1099, 459, 2489, 995, 2896, 12, 754, 9, 398, 372, 754, 339, 347, 3405, 8, 277, 304, 267, 347, 2449, 63, 1001, 2031, 589, 12, 1011, 958, 304, 288, 2074, 459, 4892, 418, 275, 715, 288, 746, 2622, 4874, 9653, 8, 958, 9, 398, 543, 3371, 14, 785, 8, 4316, 14, 10047, 2377, 12, 283, 1633, 63, 1001, 297, 2449, 63, 1001, 304, 288, 543, 291, 14, 1855, 8, 10047, 4874, 9653, 9, 465, 3178, 26, 355, 291, 14, 578, 14, 973, 342, 398, 754, 275, 3178, 14, 1971, 14, 589, 59, 16, 61, 267, 291, 14, 1815, 8, 1099, 459, 4892, 995, 754, 9, 267, 372, 754, 339, 347, 2896, 8, 277, 12, 2896, 29, 797, 304, 267, 347, 4458, 63, 1001, 2031, 589, 12, 1011, 958, 304, 288, 340, 283, 2489, 7, 440, 315, 2074, 26, 355, 2074, 459, 2489, 418, 275, 756, 288, 746, 2622, 6699, 9653, 8, 958, 9, 398, 543, 3371, 14, 785, 8, 4316, 14, 10047, 2377, 12, 283, 2224, 63, 1001, 297, 4458, 63, 1001, 304, 288, 543, 291, 14, 1855, 8, 10047, 6699, 9653, 9, 465, 3178, 26, 355, 291, 14, 578, 14, 973, 342, 398, 754, 275, 3178, 14, 1971, 14, 589, 59, 16, 61, 267, 291, 14, 629, 8, 1099, 459, 2489, 995, 2896, 12, 754, 9, 267, 372, 754, 339, 347, 2248, 63, 8769, 8, 277, 12, 3718, 29, 403, 12, 1475, 29, 403, 12, 2896, 29, 403, 304, 267, 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, 0 ]
[ 1, 1, 1, 1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
test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py
47
15951
# # -*- coding: utf-8 -*- # Copyright 2019 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) """ The vyos_lldp_interfaces class It is in this file where the current configuration (as dict) is compared to the provided configuration (as dict) and the command set necessary to bring the current configuration to it's desired end-state is created """ from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( ConfigBase, ) from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.facts import ( Facts, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( to_list, dict_diff, ) from ansible.module_utils.six import iteritems from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.utils import ( search_obj_in_list, search_dict_tv_in_list, key_value_in_dict, is_dict_element_present, ) class Lldp_interfaces(ConfigBase): """ The vyos_lldp_interfaces class """ gather_subset = [ "!all", "!min", ] gather_network_resources = [ "lldp_interfaces", ] params = ["enable", "location", "name"] def __init__(self, module): super(Lldp_interfaces, self).__init__(module) def get_lldp_interfaces_facts(self): """ Get the 'facts' (the current configuration) :rtype: A dictionary :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( self.gather_subset, self.gather_network_resources ) lldp_interfaces_facts = facts["ansible_network_resources"].get( "lldp_interfaces" ) if not lldp_interfaces_facts: return [] return lldp_interfaces_facts def execute_module(self): """ Execute the module :rtype: A dictionary :returns: The result from module execution """ result = {"changed": False} commands = list() warnings = list() existing_lldp_interfaces_facts = self.get_lldp_interfaces_facts() commands.extend(self.set_config(existing_lldp_interfaces_facts)) if commands: if self._module.check_mode: resp = self._connection.edit_config(commands, commit=False) else: resp = self._connection.edit_config(commands) result["changed"] = True result["commands"] = commands if self._module._diff: result["diff"] = resp["diff"] if result["changed"] else None changed_lldp_interfaces_facts = self.get_lldp_interfaces_facts() result["before"] = existing_lldp_interfaces_facts if result["changed"]: result["after"] = changed_lldp_interfaces_facts result["warnings"] = warnings return result def set_config(self, existing_lldp_interfaces_facts): """ Collect the configuration from the args passed to the module, collect the current configuration (as a dict from facts) :rtype: A list :returns: the commands necessary to migrate the current configuration to the desired configuration """ want = self._module.params["config"] have = existing_lldp_interfaces_facts resp = self.set_state(want, have) return to_list(resp) def set_state(self, want, have): """ Select the appropriate function based on the state provided :param want: the desired configuration as a dictionary :param have: the current configuration as a dictionary :rtype: A list :returns: the commands necessary to migrate the current configuration to the desired configuration """ commands = [] state = self._module.params["state"] if state in ("merged", "replaced", "overridden") and not want: self._module.fail_json( msg="value of config parameter must not be empty for state {0}".format( state ) ) if state == "overridden": commands.extend(self._state_overridden(want=want, have=have)) elif state == "deleted": if want: for item in want: name = item["name"] have_item = search_obj_in_list(name, have) commands.extend( self._state_deleted(want=None, have=have_item) ) else: for have_item in have: commands.extend( self._state_deleted(want=None, have=have_item) ) else: for want_item in want: name = want_item["name"] have_item = search_obj_in_list(name, have) if state == "merged": commands.extend( self._state_merged(want=want_item, have=have_item) ) else: commands.extend( self._state_replaced(want=want_item, have=have_item) ) return commands def _state_replaced(self, want, have): """ The command generator when state is replaced :rtype: A list :returns: the commands necessary to migrate the current configuration to the desired configuration """ commands = [] if have: commands.extend(self._state_deleted(want, have)) commands.extend(self._state_merged(want, have)) return commands def _state_overridden(self, want, have): """ The command generator when state is overridden :rtype: A list :returns: the commands necessary to migrate the current configuration to the desired configuration """ commands = [] for have_item in have: lldp_name = have_item["name"] lldp_in_want = search_obj_in_list(lldp_name, want) if not lldp_in_want: commands.append( self._compute_command(have_item["name"], remove=True) ) for want_item in want: name = want_item["name"] lldp_in_have = search_obj_in_list(name, have) commands.extend(self._state_replaced(want_item, lldp_in_have)) return commands def _state_merged(self, want, have): """ The command generator when state is merged :rtype: A list :returns: the commands necessary to merge the provided into the current configuration """ commands = [] if have: commands.extend(self._render_updates(want, have)) else: commands.extend(self._render_set_commands(want)) return commands def _state_deleted(self, want, have): """ The command generator when state is deleted :rtype: A list :returns: the commands necessary to remove the current configuration of the provided objects """ commands = [] if want: params = Lldp_interfaces.params for attrib in params: if attrib == "location": commands.extend( self._update_location(have["name"], want, have) ) elif have: commands.append(self._compute_command(have["name"], remove=True)) return commands def _render_updates(self, want, have): commands = [] lldp_name = have["name"] commands.extend(self._configure_status(lldp_name, want, have)) commands.extend(self._add_location(lldp_name, want, have)) return commands def _render_set_commands(self, want): commands = [] have = {} lldp_name = want["name"] params = Lldp_interfaces.params commands.extend(self._add_location(lldp_name, want, have)) for attrib in params: value = want[attrib] if value: if attrib == "location": commands.extend(self._add_location(lldp_name, want, have)) elif attrib == "enable": if not value: commands.append( self._compute_command(lldp_name, value="disable") ) else: commands.append(self._compute_command(lldp_name)) return commands def _configure_status(self, name, want_item, have_item): commands = [] if is_dict_element_present(have_item, "enable"): temp_have_item = False else: temp_have_item = True if want_item["enable"] != temp_have_item: if want_item["enable"]: commands.append( self._compute_command(name, value="disable", remove=True) ) else: commands.append(self._compute_command(name, value="disable")) return commands def _add_location(self, name, want_item, have_item): commands = [] have_dict = {} have_ca = {} set_cmd = name + " location " want_location_type = want_item.get("location") or {} have_location_type = have_item.get("location") or {} if want_location_type["coordinate_based"]: want_dict = want_location_type.get("coordinate_based") or {} if is_dict_element_present(have_location_type, "coordinate_based"): have_dict = have_location_type.get("coordinate_based") or {} location_type = "coordinate-based" updates = dict_diff(have_dict, want_dict) for key, value in iteritems(updates): if value: commands.append( self._compute_command( set_cmd + location_type, key, str(value) ) ) elif want_location_type["civic_based"]: location_type = "civic-based" want_dict = want_location_type.get("civic_based") or {} want_ca = want_dict.get("ca_info") or [] if is_dict_element_present(have_location_type, "civic_based"): have_dict = have_location_type.get("civic_based") or {} have_ca = have_dict.get("ca_info") or [] if want_dict["country_code"] != have_dict["country_code"]: commands.append( self._compute_command( set_cmd + location_type, "country-code", str(want_dict["country_code"]), ) ) else: commands.append( self._compute_command( set_cmd + location_type, "country-code", str(want_dict["country_code"]), ) ) commands.extend(self._add_civic_address(name, want_ca, have_ca)) elif want_location_type["elin"]: location_type = "elin" if is_dict_element_present(have_location_type, "elin"): if want_location_type.get("elin") != have_location_type.get( "elin" ): commands.append( self._compute_command( set_cmd + location_type, value=str(want_location_type["elin"]), ) ) else: commands.append( self._compute_command( set_cmd + location_type, value=str(want_location_type["elin"]), ) ) return commands def _update_location(self, name, want_item, have_item): commands = [] del_cmd = name + " location" want_location_type = want_item.get("location") or {} have_location_type = have_item.get("location") or {} if want_location_type["coordinate_based"]: want_dict = want_location_type.get("coordinate_based") or {} if is_dict_element_present(have_location_type, "coordinate_based"): have_dict = have_location_type.get("coordinate_based") or {} location_type = "coordinate-based" for key, value in iteritems(have_dict): only_in_have = key_value_in_dict(key, value, want_dict) if not only_in_have: commands.append( self._compute_command( del_cmd + location_type, key, str(value), True ) ) else: commands.append(self._compute_command(del_cmd, remove=True)) elif want_location_type["civic_based"]: want_dict = want_location_type.get("civic_based") or {} want_ca = want_dict.get("ca_info") or [] if is_dict_element_present(have_location_type, "civic_based"): have_dict = have_location_type.get("civic_based") or {} have_ca = have_dict.get("ca_info") commands.extend( self._update_civic_address(name, want_ca, have_ca) ) else: commands.append(self._compute_command(del_cmd, remove=True)) else: if is_dict_element_present(have_location_type, "elin"): if want_location_type.get("elin") != have_location_type.get( "elin" ): commands.append( self._compute_command(del_cmd, remove=True) ) else: commands.append(self._compute_command(del_cmd, remove=True)) return commands def _add_civic_address(self, name, want, have): commands = [] for item in want: ca_type = item["ca_type"] ca_value = item["ca_value"] obj_in_have = search_dict_tv_in_list( ca_type, ca_value, have, "ca_type", "ca_value" ) if not obj_in_have: commands.append( self._compute_command( key=name + " location civic-based ca-type", attrib=str(ca_type) + " ca-value", value=ca_value, ) ) return commands def _update_civic_address(self, name, want, have): commands = [] for item in have: ca_type = item["ca_type"] ca_value = item["ca_value"] in_want = search_dict_tv_in_list( ca_type, ca_value, want, "ca_type", "ca_value" ) if not in_want: commands.append( self._compute_command( name, "location civic-based ca-type", str(ca_type), remove=True, ) ) return commands def _compute_command(self, key, attrib=None, value=None, remove=False): if remove: cmd = "delete service lldp interface " else: cmd = "set service lldp interface " cmd += key if attrib: cmd += " " + attrib if value: cmd += " '" + value + "'" return cmd
gpl-3.0
[ 3, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 20312, 9572, 13002, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 199, 3, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 624, 199, 1918, 31766, 736, 63, 24319, 63, 7436, 1021, 199, 7940, 365, 315, 642, 570, 2382, 314, 1453, 2897, 334, 305, 1211, 9, 199, 374, 13524, 370, 314, 2741, 2897, 334, 305, 1211, 9, 436, 314, 1414, 663, 199, 17927, 370, 330, 5985, 314, 1453, 2897, 370, 652, 1159, 6387, 1284, 13, 929, 365, 199, 3966, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 199, 363, 6577, 363, 275, 730, 421, 199, 504, 3242, 63, 7882, 14, 4853, 14, 846, 2330, 14, 5265, 14, 578, 63, 1208, 14, 1200, 14, 2330, 14, 4128, 14, 1095, 492, 334, 272, 4094, 1563, 12, 199, 9, 199, 504, 3242, 63, 7882, 14, 16091, 736, 14, 16091, 736, 14, 5265, 14, 578, 63, 1208, 14, 1200, 14, 16091, 736, 14, 5047, 14, 5047, 492, 334, 272, 481, 22282, 12, 199, 9, 199, 504, 3242, 63, 7882, 14, 4853, 14, 846, 2330, 14, 5265, 14, 578, 63, 1208, 14, 1200, 14, 2330, 14, 1208, 492, 334, 272, 370, 63, 513, 12, 272, 1211, 63, 3028, 12, 199, 9, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 10849, 199, 504, 3242, 63, 7882, 14, 16091, 736, 14, 16091, 736, 14, 5265, 14, 578, 63, 1208, 14, 1200, 14, 16091, 736, 14, 1208, 14, 1208, 492, 334, 272, 2754, 63, 1113, 63, 262, 63, 513, 12, 272, 2754, 63, 807, 63, 6993, 63, 262, 63, 513, 12, 272, 790, 63, 585, 63, 262, 63, 807, 12, 272, 365, 63, 807, 63, 2108, 63, 1881, 12, 199, 9, 421, 199, 533, 491, 17288, 63, 7436, 8, 2028, 1563, 304, 272, 408, 272, 710, 31766, 736, 63, 24319, 63, 7436, 1021, 272, 408, 339, 13082, 63, 9401, 275, 359, 267, 19724, 452, 401, 267, 19724, 827, 401, 272, 1622, 339, 13082, 63, 1200, 63, 4435, 275, 359, 267, 298, 24319, 63, 7436, 401, 272, 1622, 339, 1862, 275, 2097, 4296, 401, 298, 1985, 401, 298, 354, 937, 339, 347, 636, 826, 721, 277, 12, 859, 304, 267, 1613, 8, 44, 17288, 63, 7436, 12, 291, 2843, 826, 721, 578, 9, 339, 347, 664, 63, 24319, 63, 7436, 63, 5047, 8, 277, 304, 267, 408, 2372, 314, 283, 5047, 7, 334, 1589, 1453, 2897, 9, 398, 520, 4500, 26, 437, 2600, 267, 520, 5808, 26, 710, 1453, 2897, 465, 282, 2600, 267, 408, 267, 9036, 12, 485, 5451, 275, 481, 22282, 8, 277, 423, 578, 680, 362, 63, 5047, 8, 288, 291, 14, 13737, 63, 9401, 12, 291, 14, 13737, 63, 1200, 63, 4435, 267, 776, 267, 28768, 63, 7436, 63, 5047, 275, 9036, 905, 4853, 63, 1200, 63, 4435, 4140, 362, 8, 288, 298, 24319, 63, 7436, 2, 267, 776, 267, 340, 440, 28768, 63, 7436, 63, 5047, 26, 288, 372, 942, 267, 372, 28768, 63, 7436, 63, 5047, 339, 347, 5341, 63, 578, 8, 277, 304, 267, 408, 17009, 314, 859, 398, 520, 4500, 26, 437, 2600, 267, 520, 5808, 26, 710, 754, 687, 859, 6451, 267, 408, 267, 754, 275, 2420, 2489, 582, 756, 93, 267, 3718, 275, 769, 342, 267, 3598, 275, 769, 342, 267, 3411, 63, 24319, 63, 7436, 63, 5047, 275, 291, 14, 362, 63, 24319, 63, 7436, 63, 5047, 342, 267, 3718, 14, 2880, 8, 277, 14, 409, 63, 888, 8, 5952, 63, 24319, 63, 7436, 63, 5047, 430, 267, 340, 3718, 26, 288, 340, 291, 423, 578, 14, 1074, 63, 632, 26, 355, 3085, 275, 291, 423, 2105, 14, 3773, 63, 888, 8, 4405, 12, 5532, 29, 797, 9, 288, 587, 26, 355, 3085, 275, 291, 423, 2105, 14, 3773, 63, 888, 8, 4405, 9, 288, 754, 905, 2489, 937, 275, 715, 398, 754, 905, 4405, 937, 275, 3718, 398, 340, 291, 423, 578, 423, 3028, 26, 288, 754, 905, 3028, 937, 275, 3085, 905, 3028, 937, 340, 754, 905, 2489, 937, 587, 488, 398, 2896, 63, 24319, 63, 7436, 63, 5047, 275, 291, 14, 362, 63, 24319, 63, 7436, 63, 5047, 342, 267, 754, 905, 5182, 937, 275, 3411, 63, 24319, 63, 7436, 63, 5047, 267, 340, 754, 905, 2489, 6229, 288, 754, 905, 4399, 937, 275, 2896, 63, 24319, 63, 7436, 63, 5047, 398, 754, 905, 5451, 937, 275, 3598, 267, 372, 754, 339, 347, 663, 63, 888, 8, 277, 12, 3411, 63, 24319, 63, 7436, 63, 5047, 304, 267, 408, 19649, 314, 2897, 687, 314, 1249, 3032, 370, 314, 859, 12, 288, 8775, 314, 1453, 2897, 334, 305, 282, 1211, 687, 9036, 9, 398, 520, 4500, 26, 437, 769, 267, 520, 5808, 26, 314, 3718, 5784, 370, 12810, 314, 1453, 2897, 2116, 370, 314, 6387, 2897, 267, 408, 267, 2934, 275, 291, 423, 578, 14, 1162, 905, 888, 937, 267, 1172, 275, 3411, 63, 24319, 63, 7436, 63, 5047, 267, 3085, 275, 291, 14, 409, 63, 929, 8, 7051, 12, 1172, 9, 267, 372, 370, 63, 513, 8, 4518, 9, 339, 347, 663, 63, 929, 8, 277, 12, 2934, 12, 1172, 304, 267, 408, 9496, 314, 5827, 805, 4079, 641, 314, 1174, 2741, 398, 520, 635, 2934, 26, 314, 6387, 2897, 465, 282, 2600, 267, 520, 635, 1172, 26, 314, 1453, 2897, 465, 282, 2600, 267, 520, 4500, 26, 437, 769, 267, 520, 5808, 26, 314, 3718, 5784, 370, 12810, 314, 1453, 2897, 2116, 370, 314, 6387, 2897, 267, 408, 267, 3718, 275, 942, 267, 1174, 275, 291, 423, 578, 14, 1162, 905, 929, 937, 267, 340, 1174, 315, 1689, 15269, 401, 298, 31473, 401, 298, 30769, 531, 436, 440, 2934, 26, 288, 291, 423, 578, 14, 1633, 63, 1001, 8, 355, 1499, 628, 585, 402, 1101, 2725, 1471, 440, 506, 2701, 367, 1174, 469, 16, 5469, 908, 8, 490, 1174, 355, 776, 288, 776, 267, 340, 1174, 508, 298, 30769, 582, 288, 3718, 14, 2880, 8, 277, 423, 929, 63, 30769, 8, 7051, 29, 7051, 12 ]
[ 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 20312, 9572, 13002, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 199, 3, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 624, 199, 1918, 31766, 736, 63, 24319, 63, 7436, 1021, 199, 7940, 365, 315, 642, 570, 2382, 314, 1453, 2897, 334, 305, 1211, 9, 199, 374, 13524, 370, 314, 2741, 2897, 334, 305, 1211, 9, 436, 314, 1414, 663, 199, 17927, 370, 330, 5985, 314, 1453, 2897, 370, 652, 1159, 6387, 1284, 13, 929, 365, 199, 3966, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 199, 363, 6577, 363, 275, 730, 421, 199, 504, 3242, 63, 7882, 14, 4853, 14, 846, 2330, 14, 5265, 14, 578, 63, 1208, 14, 1200, 14, 2330, 14, 4128, 14, 1095, 492, 334, 272, 4094, 1563, 12, 199, 9, 199, 504, 3242, 63, 7882, 14, 16091, 736, 14, 16091, 736, 14, 5265, 14, 578, 63, 1208, 14, 1200, 14, 16091, 736, 14, 5047, 14, 5047, 492, 334, 272, 481, 22282, 12, 199, 9, 199, 504, 3242, 63, 7882, 14, 4853, 14, 846, 2330, 14, 5265, 14, 578, 63, 1208, 14, 1200, 14, 2330, 14, 1208, 492, 334, 272, 370, 63, 513, 12, 272, 1211, 63, 3028, 12, 199, 9, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 10849, 199, 504, 3242, 63, 7882, 14, 16091, 736, 14, 16091, 736, 14, 5265, 14, 578, 63, 1208, 14, 1200, 14, 16091, 736, 14, 1208, 14, 1208, 492, 334, 272, 2754, 63, 1113, 63, 262, 63, 513, 12, 272, 2754, 63, 807, 63, 6993, 63, 262, 63, 513, 12, 272, 790, 63, 585, 63, 262, 63, 807, 12, 272, 365, 63, 807, 63, 2108, 63, 1881, 12, 199, 9, 421, 199, 533, 491, 17288, 63, 7436, 8, 2028, 1563, 304, 272, 408, 272, 710, 31766, 736, 63, 24319, 63, 7436, 1021, 272, 408, 339, 13082, 63, 9401, 275, 359, 267, 19724, 452, 401, 267, 19724, 827, 401, 272, 1622, 339, 13082, 63, 1200, 63, 4435, 275, 359, 267, 298, 24319, 63, 7436, 401, 272, 1622, 339, 1862, 275, 2097, 4296, 401, 298, 1985, 401, 298, 354, 937, 339, 347, 636, 826, 721, 277, 12, 859, 304, 267, 1613, 8, 44, 17288, 63, 7436, 12, 291, 2843, 826, 721, 578, 9, 339, 347, 664, 63, 24319, 63, 7436, 63, 5047, 8, 277, 304, 267, 408, 2372, 314, 283, 5047, 7, 334, 1589, 1453, 2897, 9, 398, 520, 4500, 26, 437, 2600, 267, 520, 5808, 26, 710, 1453, 2897, 465, 282, 2600, 267, 408, 267, 9036, 12, 485, 5451, 275, 481, 22282, 8, 277, 423, 578, 680, 362, 63, 5047, 8, 288, 291, 14, 13737, 63, 9401, 12, 291, 14, 13737, 63, 1200, 63, 4435, 267, 776, 267, 28768, 63, 7436, 63, 5047, 275, 9036, 905, 4853, 63, 1200, 63, 4435, 4140, 362, 8, 288, 298, 24319, 63, 7436, 2, 267, 776, 267, 340, 440, 28768, 63, 7436, 63, 5047, 26, 288, 372, 942, 267, 372, 28768, 63, 7436, 63, 5047, 339, 347, 5341, 63, 578, 8, 277, 304, 267, 408, 17009, 314, 859, 398, 520, 4500, 26, 437, 2600, 267, 520, 5808, 26, 710, 754, 687, 859, 6451, 267, 408, 267, 754, 275, 2420, 2489, 582, 756, 93, 267, 3718, 275, 769, 342, 267, 3598, 275, 769, 342, 267, 3411, 63, 24319, 63, 7436, 63, 5047, 275, 291, 14, 362, 63, 24319, 63, 7436, 63, 5047, 342, 267, 3718, 14, 2880, 8, 277, 14, 409, 63, 888, 8, 5952, 63, 24319, 63, 7436, 63, 5047, 430, 267, 340, 3718, 26, 288, 340, 291, 423, 578, 14, 1074, 63, 632, 26, 355, 3085, 275, 291, 423, 2105, 14, 3773, 63, 888, 8, 4405, 12, 5532, 29, 797, 9, 288, 587, 26, 355, 3085, 275, 291, 423, 2105, 14, 3773, 63, 888, 8, 4405, 9, 288, 754, 905, 2489, 937, 275, 715, 398, 754, 905, 4405, 937, 275, 3718, 398, 340, 291, 423, 578, 423, 3028, 26, 288, 754, 905, 3028, 937, 275, 3085, 905, 3028, 937, 340, 754, 905, 2489, 937, 587, 488, 398, 2896, 63, 24319, 63, 7436, 63, 5047, 275, 291, 14, 362, 63, 24319, 63, 7436, 63, 5047, 342, 267, 754, 905, 5182, 937, 275, 3411, 63, 24319, 63, 7436, 63, 5047, 267, 340, 754, 905, 2489, 6229, 288, 754, 905, 4399, 937, 275, 2896, 63, 24319, 63, 7436, 63, 5047, 398, 754, 905, 5451, 937, 275, 3598, 267, 372, 754, 339, 347, 663, 63, 888, 8, 277, 12, 3411, 63, 24319, 63, 7436, 63, 5047, 304, 267, 408, 19649, 314, 2897, 687, 314, 1249, 3032, 370, 314, 859, 12, 288, 8775, 314, 1453, 2897, 334, 305, 282, 1211, 687, 9036, 9, 398, 520, 4500, 26, 437, 769, 267, 520, 5808, 26, 314, 3718, 5784, 370, 12810, 314, 1453, 2897, 2116, 370, 314, 6387, 2897, 267, 408, 267, 2934, 275, 291, 423, 578, 14, 1162, 905, 888, 937, 267, 1172, 275, 3411, 63, 24319, 63, 7436, 63, 5047, 267, 3085, 275, 291, 14, 409, 63, 929, 8, 7051, 12, 1172, 9, 267, 372, 370, 63, 513, 8, 4518, 9, 339, 347, 663, 63, 929, 8, 277, 12, 2934, 12, 1172, 304, 267, 408, 9496, 314, 5827, 805, 4079, 641, 314, 1174, 2741, 398, 520, 635, 2934, 26, 314, 6387, 2897, 465, 282, 2600, 267, 520, 635, 1172, 26, 314, 1453, 2897, 465, 282, 2600, 267, 520, 4500, 26, 437, 769, 267, 520, 5808, 26, 314, 3718, 5784, 370, 12810, 314, 1453, 2897, 2116, 370, 314, 6387, 2897, 267, 408, 267, 3718, 275, 942, 267, 1174, 275, 291, 423, 578, 14, 1162, 905, 929, 937, 267, 340, 1174, 315, 1689, 15269, 401, 298, 31473, 401, 298, 30769, 531, 436, 440, 2934, 26, 288, 291, 423, 578, 14, 1633, 63, 1001, 8, 355, 1499, 628, 585, 402, 1101, 2725, 1471, 440, 506, 2701, 367, 1174, 469, 16, 5469, 908, 8, 490, 1174, 355, 776, 288, 776, 267, 340, 1174, 508, 298, 30769, 582, 288, 3718, 14, 2880, 8, 277, 423, 929, 63, 30769, 8, 7051, 29, 7051, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
spcui/virt-test
qemu/tests/rv_fullscreen.py
3
3380
""" rv_fullscreen.py - remote-viewer full screen Testing the remote-viewer --full-screen option If successful, the resolution of the guest will take the resolution of the client. Requires: connected binaries remote-viewer, Xorg, gnome session """ import logging from autotest.client.shared import error from virttest.aexpect import ShellCmdError def run_rv_fullscreen(test, params, env): """ Tests the --full-screen option Positive test: full_screen param = yes, verify guest res = client res Negative test: full_screen param= no, verify guest res != client res :param test: QEMU test object. :param params: Dictionary with the test parameters. :param env: Dictionary with test environment. """ # Get the parameters needed for the test full_screen = params.get("full_screen") guest_vm = env.get_vm(params["guest_vm"]) client_vm = env.get_vm(params["client_vm"]) guest_vm.verify_alive() guest_session = guest_vm.wait_for_login( timeout=int(params.get("login_timeout", 360))) client_vm.verify_alive() client_session = client_vm.wait_for_login( timeout=int(params.get("login_timeout", 360))) # Get the resolution of the client & guest logging.info("Getting the Resolution on the client") client_session.cmd("export DISPLAY=:0.0") try: client_session.cmd("xrandr | grep '*' >/tmp/res") client_res_raw = client_session.cmd("cat /tmp/res|awk '{print $1}'") client_res = client_res_raw.split()[0] except ShellCmdError: raise error.TestFail("Could not get guest resolution, xrandr output:" + " %s" % client_res_raw) except IndexError: raise error.TestFail("Could not get guest resolution, xrandr output:" + " %s" % client_res_raw) logging.info("Getting the Resolution on the guest") guest_session.cmd("export DISPLAY=:0.0") try: guest_session.cmd("xrandr | grep '*' >/tmp/res") guest_res_raw = guest_session.cmd("cat /tmp/res|awk '{print $1}'") guest_res = guest_res_raw.split()[0] except ShellCmdError: raise error.TestFail("Could not get guest resolution, xrandr output:" + " %s" % guest_res_raw) except IndexError: raise error.TestFail("Could not get guest resolution, xrandr output:" + " %s" % guest_res_raw) logging.info("Here's the information I have: ") logging.info("\nClient Resolution: " + client_res) logging.info("\nGuest Resolution: " + guest_res) # Positive Test, verify the guest takes the resolution of the client if full_screen == "yes": if(client_res == guest_res): logging.info("PASS: Guest resolution is the same as the client") else: raise error.TestFail("Guest resolution differs from the client") # Negative Test, verify the resolutions are not equal elif full_screen == "no": if(client_res != guest_res): logging.info("PASS: Guest resolution differs from the client") else: raise error.TestFail("Guest resolution is the same as the client") else: raise error.TestFail("The test setup is incorrect.") client_session.close() guest_session.close()
gpl-2.0
[ 624, 199, 6310, 63, 28418, 4463, 14, 647, 446, 3982, 13, 16645, 2615, 6426, 673, 11940, 314, 3982, 13, 16645, 1553, 2861, 13, 5410, 945, 673, 982, 9512, 12, 314, 12401, 402, 314, 13980, 911, 673, 5452, 314, 12401, 402, 314, 1890, 14, 199, 199, 18153, 26, 8539, 21984, 3982, 13, 16645, 12, 1323, 1308, 12, 486, 29897, 2351, 199, 199, 624, 199, 646, 2050, 199, 504, 2599, 396, 14, 1258, 14, 5555, 492, 1125, 199, 504, 12043, 396, 14, 65, 4921, 492, 24599, 7874, 547, 421, 199, 318, 1255, 63, 6310, 63, 28418, 4463, 8, 396, 12, 1862, 12, 2589, 304, 272, 408, 272, 6496, 314, 1553, 2861, 13, 5410, 945, 272, 30245, 511, 26, 2615, 63, 5410, 1215, 275, 9456, 12, 4911, 13980, 522, 275, 1890, 522, 272, 32548, 511, 26, 2615, 63, 5410, 1215, 29, 949, 12, 4911, 13980, 522, 1137, 1890, 522, 339, 520, 635, 511, 26, 1413, 2769, 53, 511, 909, 14, 272, 520, 635, 1862, 26, 11932, 543, 314, 511, 2633, 14, 272, 520, 635, 2589, 26, 11932, 543, 511, 3734, 14, 272, 408, 272, 327, 2372, 314, 2633, 4346, 367, 314, 511, 272, 2615, 63, 5410, 275, 1862, 14, 362, 480, 2861, 63, 5410, 531, 272, 13980, 63, 2611, 275, 2589, 14, 362, 63, 2611, 8, 1162, 905, 10409, 63, 2611, 3135, 272, 1890, 63, 2611, 275, 2589, 14, 362, 63, 2611, 8, 1162, 905, 1258, 63, 2611, 3135, 339, 13980, 63, 2611, 14, 4712, 63, 9631, 342, 272, 13980, 63, 1730, 275, 13980, 63, 2611, 14, 2573, 63, 509, 63, 2886, 8, 267, 2653, 29, 442, 8, 1162, 14, 362, 480, 2886, 63, 2593, 401, 19434, 1724, 339, 1890, 63, 2611, 14, 4712, 63, 9631, 342, 272, 1890, 63, 1730, 275, 1890, 63, 2611, 14, 2573, 63, 509, 63, 2886, 8, 267, 2653, 29, 442, 8, 1162, 14, 362, 480, 2886, 63, 2593, 401, 19434, 1724, 339, 327, 2372, 314, 12401, 402, 314, 1890, 1253, 13980, 272, 2050, 14, 815, 480, 28277, 314, 3591, 3347, 641, 314, 1890, 531, 272, 1890, 63, 1730, 14, 1760, 480, 3790, 7587, 11625, 29, 26, 16, 14, 16, 531, 339, 862, 26, 267, 1890, 63, 1730, 14, 1760, 480, 88, 3759, 82, 1204, 20595, 13626, 690, 15, 2791, 15, 470, 531, 267, 1890, 63, 470, 63, 1773, 275, 1890, 63, 1730, 14, 1760, 480, 3385, 1182, 2791, 15, 470, 92, 10084, 75, 5041, 1361, 2672, 17, 6834, 531, 267, 1890, 63, 470, 275, 1890, 63, 470, 63, 1773, 14, 1294, 3430, 16, 61, 272, 871, 24599, 7874, 547, 26, 267, 746, 1125, 14, 774, 4874, 480, 6531, 440, 664, 13980, 12401, 12, 671, 3759, 82, 1072, 5424, 435, 2490, 298, 450, 83, 2, 450, 1890, 63, 470, 63, 1773, 9, 272, 871, 7888, 26, 267, 746, 1125, 14, 774, 4874, 480, 6531, 440, 664, 13980, 12401, 12, 671, 3759, 82, 1072, 5424, 435, 2490, 298, 450, 83, 2, 450, 1890, 63, 470, 63, 1773, 9, 339, 2050, 14, 815, 480, 28277, 314, 3591, 3347, 641, 314, 13980, 531, 272, 13980, 63, 1730, 14, 1760, 480, 3790, 7587, 11625, 29, 26, 16, 14, 16, 531, 339, 862, 26, 267, 13980, 63, 1730, 14, 1760, 480, 88, 3759, 82, 1204, 20595, 13626, 690, 15, 2791, 15, 470, 531, 267, 13980, 63, 470, 63, 1773, 275, 13980, 63, 1730, 14, 1760, 480, 3385, 1182, 2791, 15, 470, 92, 10084, 75, 5041, 1361, 2672, 17, 6834, 531, 267, 13980, 63, 470, 275, 13980, 63, 470, 63, 1773, 14, 1294, 3430, 16, 61, 272, 871, 24599, 7874, 547, 26, 267, 746, 1125, 14, 774, 4874, 480, 6531, 440, 664, 13980, 12401, 12, 671, 3759, 82, 1072, 5424, 435, 2490, 298, 450, 83, 2, 450, 13980, 63, 470, 63, 1773, 9, 272, 871, 7888, 26, 267, 746, 1125, 14, 774, 4874, 480, 6531, 440, 664, 13980, 12401, 12, 671, 3759, 82, 1072, 5424, 435, 2490, 298, 450, 83, 2, 450, 13980, 63, 470, 63, 1773, 9, 339, 2050, 14, 815, 480, 21741, 1159, 314, 2556, 473, 1172, 26, 6099, 272, 2050, 14, 815, 4582, 78, 3041, 3591, 3347, 26, 298, 435, 1890, 63, 470, 9, 272, 2050, 14, 815, 4582, 78, 16022, 3591, 3347, 26, 298, 435, 13980, 63, 470, 9, 339, 327, 30245, 1379, 12, 4911, 314, 13980, 6181, 314, 12401, 402, 314, 1890, 272, 340, 2615, 63, 5410, 508, 298, 5066, 582, 267, 340, 8, 1258, 63, 470, 508, 13980, 63, 470, 304, 288, 2050, 14, 815, 480, 6909, 26, 598, 5291, 12401, 365, 314, 2011, 465, 314, 1890, 531, 267, 587, 26, 288, 746, 1125, 14, 774, 4874, 480, 16022, 12401, 22754, 687, 314, 1890, 531, 272, 327, 32548, 1379, 12, 4911, 314, 17416, 8653, 787, 440, 4472, 272, 916, 2615, 63, 5410, 508, 298, 889, 582, 267, 340, 8, 1258, 63, 470, 1137, 13980, 63, 470, 304, 288, 2050, 14, 815, 480, 6909, 26, 598, 5291, 12401, 22754, 687, 314, 1890, 531, 267, 587, 26, 288, 746, 1125, 14, 774, 4874, 480, 16022, 12401, 365, 314, 2011, 465, 314, 1890, 531, 272, 587, 26, 267, 746, 1125, 14, 774, 4874, 480, 1918, 511, 3272, 365, 8927, 2685, 339, 1890, 63, 1730, 14, 1600, 342, 272, 13980, 63, 1730, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 6310, 63, 28418, 4463, 14, 647, 446, 3982, 13, 16645, 2615, 6426, 673, 11940, 314, 3982, 13, 16645, 1553, 2861, 13, 5410, 945, 673, 982, 9512, 12, 314, 12401, 402, 314, 13980, 911, 673, 5452, 314, 12401, 402, 314, 1890, 14, 199, 199, 18153, 26, 8539, 21984, 3982, 13, 16645, 12, 1323, 1308, 12, 486, 29897, 2351, 199, 199, 624, 199, 646, 2050, 199, 504, 2599, 396, 14, 1258, 14, 5555, 492, 1125, 199, 504, 12043, 396, 14, 65, 4921, 492, 24599, 7874, 547, 421, 199, 318, 1255, 63, 6310, 63, 28418, 4463, 8, 396, 12, 1862, 12, 2589, 304, 272, 408, 272, 6496, 314, 1553, 2861, 13, 5410, 945, 272, 30245, 511, 26, 2615, 63, 5410, 1215, 275, 9456, 12, 4911, 13980, 522, 275, 1890, 522, 272, 32548, 511, 26, 2615, 63, 5410, 1215, 29, 949, 12, 4911, 13980, 522, 1137, 1890, 522, 339, 520, 635, 511, 26, 1413, 2769, 53, 511, 909, 14, 272, 520, 635, 1862, 26, 11932, 543, 314, 511, 2633, 14, 272, 520, 635, 2589, 26, 11932, 543, 511, 3734, 14, 272, 408, 272, 327, 2372, 314, 2633, 4346, 367, 314, 511, 272, 2615, 63, 5410, 275, 1862, 14, 362, 480, 2861, 63, 5410, 531, 272, 13980, 63, 2611, 275, 2589, 14, 362, 63, 2611, 8, 1162, 905, 10409, 63, 2611, 3135, 272, 1890, 63, 2611, 275, 2589, 14, 362, 63, 2611, 8, 1162, 905, 1258, 63, 2611, 3135, 339, 13980, 63, 2611, 14, 4712, 63, 9631, 342, 272, 13980, 63, 1730, 275, 13980, 63, 2611, 14, 2573, 63, 509, 63, 2886, 8, 267, 2653, 29, 442, 8, 1162, 14, 362, 480, 2886, 63, 2593, 401, 19434, 1724, 339, 1890, 63, 2611, 14, 4712, 63, 9631, 342, 272, 1890, 63, 1730, 275, 1890, 63, 2611, 14, 2573, 63, 509, 63, 2886, 8, 267, 2653, 29, 442, 8, 1162, 14, 362, 480, 2886, 63, 2593, 401, 19434, 1724, 339, 327, 2372, 314, 12401, 402, 314, 1890, 1253, 13980, 272, 2050, 14, 815, 480, 28277, 314, 3591, 3347, 641, 314, 1890, 531, 272, 1890, 63, 1730, 14, 1760, 480, 3790, 7587, 11625, 29, 26, 16, 14, 16, 531, 339, 862, 26, 267, 1890, 63, 1730, 14, 1760, 480, 88, 3759, 82, 1204, 20595, 13626, 690, 15, 2791, 15, 470, 531, 267, 1890, 63, 470, 63, 1773, 275, 1890, 63, 1730, 14, 1760, 480, 3385, 1182, 2791, 15, 470, 92, 10084, 75, 5041, 1361, 2672, 17, 6834, 531, 267, 1890, 63, 470, 275, 1890, 63, 470, 63, 1773, 14, 1294, 3430, 16, 61, 272, 871, 24599, 7874, 547, 26, 267, 746, 1125, 14, 774, 4874, 480, 6531, 440, 664, 13980, 12401, 12, 671, 3759, 82, 1072, 5424, 435, 2490, 298, 450, 83, 2, 450, 1890, 63, 470, 63, 1773, 9, 272, 871, 7888, 26, 267, 746, 1125, 14, 774, 4874, 480, 6531, 440, 664, 13980, 12401, 12, 671, 3759, 82, 1072, 5424, 435, 2490, 298, 450, 83, 2, 450, 1890, 63, 470, 63, 1773, 9, 339, 2050, 14, 815, 480, 28277, 314, 3591, 3347, 641, 314, 13980, 531, 272, 13980, 63, 1730, 14, 1760, 480, 3790, 7587, 11625, 29, 26, 16, 14, 16, 531, 339, 862, 26, 267, 13980, 63, 1730, 14, 1760, 480, 88, 3759, 82, 1204, 20595, 13626, 690, 15, 2791, 15, 470, 531, 267, 13980, 63, 470, 63, 1773, 275, 13980, 63, 1730, 14, 1760, 480, 3385, 1182, 2791, 15, 470, 92, 10084, 75, 5041, 1361, 2672, 17, 6834, 531, 267, 13980, 63, 470, 275, 13980, 63, 470, 63, 1773, 14, 1294, 3430, 16, 61, 272, 871, 24599, 7874, 547, 26, 267, 746, 1125, 14, 774, 4874, 480, 6531, 440, 664, 13980, 12401, 12, 671, 3759, 82, 1072, 5424, 435, 2490, 298, 450, 83, 2, 450, 13980, 63, 470, 63, 1773, 9, 272, 871, 7888, 26, 267, 746, 1125, 14, 774, 4874, 480, 6531, 440, 664, 13980, 12401, 12, 671, 3759, 82, 1072, 5424, 435, 2490, 298, 450, 83, 2, 450, 13980, 63, 470, 63, 1773, 9, 339, 2050, 14, 815, 480, 21741, 1159, 314, 2556, 473, 1172, 26, 6099, 272, 2050, 14, 815, 4582, 78, 3041, 3591, 3347, 26, 298, 435, 1890, 63, 470, 9, 272, 2050, 14, 815, 4582, 78, 16022, 3591, 3347, 26, 298, 435, 13980, 63, 470, 9, 339, 327, 30245, 1379, 12, 4911, 314, 13980, 6181, 314, 12401, 402, 314, 1890, 272, 340, 2615, 63, 5410, 508, 298, 5066, 582, 267, 340, 8, 1258, 63, 470, 508, 13980, 63, 470, 304, 288, 2050, 14, 815, 480, 6909, 26, 598, 5291, 12401, 365, 314, 2011, 465, 314, 1890, 531, 267, 587, 26, 288, 746, 1125, 14, 774, 4874, 480, 16022, 12401, 22754, 687, 314, 1890, 531, 272, 327, 32548, 1379, 12, 4911, 314, 17416, 8653, 787, 440, 4472, 272, 916, 2615, 63, 5410, 508, 298, 889, 582, 267, 340, 8, 1258, 63, 470, 1137, 13980, 63, 470, 304, 288, 2050, 14, 815, 480, 6909, 26, 598, 5291, 12401, 22754, 687, 314, 1890, 531, 267, 587, 26, 288, 746, 1125, 14, 774, 4874, 480, 16022, 12401, 365, 314, 2011, 465, 314, 1890, 531, 272, 587, 26, 267, 746, 1125, 14, 774, 4874, 480, 1918, 511, 3272, 365, 8927, 2685, 339, 1890, 63, 1730, 14, 1600, 342, 272, 13980, 63, 1730, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
alimony/django
tests/gis_tests/geoadmin/tests.py
35
4277
from django.contrib.gis import admin from django.contrib.gis.geos import Point from django.test import TestCase, override_settings from django.test.utils import patch_logger from .admin import UnmodifiableAdmin from .models import City, site @override_settings(ROOT_URLCONF='django.contrib.gis.tests.geoadmin.urls') class GeoAdminTest(TestCase): def test_ensure_geographic_media(self): geoadmin = site._registry[City] admin_js = geoadmin.media.render_js() self.assertTrue(any(geoadmin.openlayers_url in js for js in admin_js)) def test_olmap_OSM_rendering(self): delete_all_btn = """<a href="javascript:geodjango_point.clearFeatures()">Delete all Features</a>""" original_geoadmin = site._registry[City] params = original_geoadmin.get_map_widget(City._meta.get_field('point')).params result = original_geoadmin.get_map_widget(City._meta.get_field('point'))( ).render('point', Point(-79.460734, 40.18476), params) self.assertIn( """geodjango_point.layers.base = new OpenLayers.Layer.OSM("OpenStreetMap (Mapnik)");""", result) self.assertIn(delete_all_btn, result) site.unregister(City) site.register(City, UnmodifiableAdmin) try: geoadmin = site._registry[City] params = geoadmin.get_map_widget(City._meta.get_field('point')).params result = geoadmin.get_map_widget(City._meta.get_field('point'))( ).render('point', Point(-79.460734, 40.18476), params) self.assertNotIn(delete_all_btn, result) finally: site.unregister(City) site.register(City, original_geoadmin.__class__) def test_olmap_WMS_rendering(self): geoadmin = admin.GeoModelAdmin(City, site) result = geoadmin.get_map_widget(City._meta.get_field('point'))( ).render('point', Point(-79.460734, 40.18476)) self.assertIn( """geodjango_point.layers.base = new OpenLayers.Layer.WMS("OpenLayers WMS", """ """"http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic', format: 'image/jpeg'});""", result) def test_olwidget_has_changed(self): """ Changes are accurately noticed by OpenLayersWidget. """ geoadmin = site._registry[City] form = geoadmin.get_changelist_form(None)() has_changed = form.fields['point'].has_changed initial = Point(13.4197458572965953, 52.5194108501149799, srid=4326) data_same = "SRID=3857;POINT(1493879.2754093995 6894592.019687599)" data_almost_same = "SRID=3857;POINT(1493879.2754093990 6894592.019687590)" data_changed = "SRID=3857;POINT(1493884.0527237 6894593.8111804)" self.assertTrue(has_changed(None, data_changed)) self.assertTrue(has_changed(initial, "")) self.assertFalse(has_changed(None, "")) self.assertFalse(has_changed(initial, data_same)) self.assertFalse(has_changed(initial, data_almost_same)) self.assertTrue(has_changed(initial, data_changed)) def test_olwidget_empty_string(self): geoadmin = site._registry[City] form = geoadmin.get_changelist_form(None)({'point': ''}) with patch_logger('django.contrib.gis', 'error') as logger_calls: output = str(form['point']) self.assertInHTML( '<textarea id="id_point" class="vWKTField required" cols="150"' ' rows="10" name="point"></textarea>', output ) self.assertEqual(logger_calls, []) def test_olwidget_invalid_string(self): geoadmin = site._registry[City] form = geoadmin.get_changelist_form(None)({'point': 'INVALID()'}) with patch_logger('django.contrib.gis', 'error') as logger_calls: output = str(form['point']) self.assertInHTML( '<textarea id="id_point" class="vWKTField required" cols="150"' ' rows="10" name="point"></textarea>', output ) self.assertEqual(len(logger_calls), 1) self.assertEqual( logger_calls[0], "Error creating geometry from value 'INVALID()' (String input " "unrecognized as WKT EWKT, and HEXEWKB.)" )
bsd-3-clause
[ 504, 1639, 14, 2828, 14, 5668, 492, 4628, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 492, 7584, 199, 504, 1639, 14, 396, 492, 7640, 12, 4278, 63, 1751, 199, 504, 1639, 14, 396, 14, 1208, 492, 3371, 63, 2921, 199, 199, 504, 1275, 2113, 492, 1910, 3729, 24183, 4880, 199, 504, 1275, 992, 492, 14753, 12, 4770, 421, 199, 32, 4415, 63, 1751, 8, 5441, 63, 18125, 534, 1176, 14, 2828, 14, 5668, 14, 2219, 14, 6721, 2113, 14, 3603, 358, 199, 533, 8875, 4880, 774, 8, 1746, 304, 339, 347, 511, 63, 7505, 63, 6721, 9770, 63, 4603, 8, 277, 304, 267, 8509, 2113, 275, 4770, 423, 5189, 59, 17024, 61, 267, 4628, 63, 3596, 275, 8509, 2113, 14, 4603, 14, 3352, 63, 3596, 342, 267, 291, 14, 1815, 8, 1629, 8, 6721, 2113, 14, 1490, 4359, 63, 633, 315, 8586, 367, 8586, 315, 4628, 63, 3596, 430, 339, 347, 511, 63, 393, 1130, 63, 3100, 45, 63, 28228, 8, 277, 304, 267, 3145, 63, 452, 63, 9633, 275, 8894, 65, 4369, 628, 9554, 26, 303, 364, 858, 63, 1403, 14, 3584, 10807, 342, 1743, 5392, 1006, 7949, 2093, 1108, 65, 11193, 398, 3379, 63, 6721, 2113, 275, 4770, 423, 5189, 59, 17024, 61, 267, 1862, 275, 3379, 63, 6721, 2113, 14, 362, 63, 1130, 63, 3440, 8, 17024, 423, 2024, 14, 362, 63, 698, 360, 1403, 11103, 1162, 267, 754, 275, 3379, 63, 6721, 2113, 14, 362, 63, 1130, 63, 3440, 8, 17024, 423, 2024, 14, 362, 63, 698, 360, 1403, 1333, 8, 267, 7092, 3352, 360, 1403, 297, 7584, 2801, 1965, 14, 2466, 1780, 1082, 12, 6335, 14, 10078, 2114, 395, 1862, 9, 267, 291, 14, 4080, 8, 288, 408, 303, 364, 858, 63, 1403, 14, 4359, 14, 1095, 275, 892, 3232, 16862, 14, 5003, 14, 3100, 45, 480, 4299, 933, 7936, 2956, 334, 2956, 22998, 9, 3547, 7208, 288, 754, 9, 398, 291, 14, 4080, 8, 1807, 63, 452, 63, 9633, 12, 754, 9, 398, 4770, 14, 18408, 8, 17024, 9, 267, 4770, 14, 2683, 8, 17024, 12, 1910, 3729, 24183, 4880, 9, 267, 862, 26, 288, 8509, 2113, 275, 4770, 423, 5189, 59, 17024, 61, 288, 1862, 275, 8509, 2113, 14, 362, 63, 1130, 63, 3440, 8, 17024, 423, 2024, 14, 362, 63, 698, 360, 1403, 11103, 1162, 288, 754, 275, 8509, 2113, 14, 362, 63, 1130, 63, 3440, 8, 17024, 423, 2024, 14, 362, 63, 698, 360, 1403, 1333, 8, 288, 7092, 3352, 360, 1403, 297, 7584, 2801, 1965, 14, 2466, 1780, 1082, 12, 6335, 14, 10078, 2114, 395, 1862, 9, 953, 291, 14, 8795, 8, 1807, 63, 452, 63, 9633, 12, 754, 9, 267, 3753, 26, 288, 4770, 14, 18408, 8, 17024, 9, 288, 4770, 14, 2683, 8, 17024, 12, 3379, 63, 6721, 2113, 855, 533, 3368, 339, 347, 511, 63, 393, 1130, 63, 55, 3053, 63, 28228, 8, 277, 304, 267, 8509, 2113, 275, 4628, 14, 10748, 12976, 8, 17024, 12, 4770, 9, 267, 754, 275, 8509, 2113, 14, 362, 63, 1130, 63, 3440, 8, 17024, 423, 2024, 14, 362, 63, 698, 360, 1403, 1333, 8, 267, 7092, 3352, 360, 1403, 297, 7584, 2801, 1965, 14, 2466, 1780, 1082, 12, 6335, 14, 10078, 2114, 430, 267, 291, 14, 4080, 8, 288, 408, 303, 364, 858, 63, 1403, 14, 4359, 14, 1095, 275, 892, 3232, 16862, 14, 5003, 14, 55, 3053, 480, 4299, 16862, 644, 3053, 401, 408, 288, 408, 2, 1014, 921, 86, 1130, 16, 14, 18819, 14, 736, 6721, 14, 1308, 15, 30297, 15, 86, 1130, 16, 401, 469, 4359, 26, 283, 4316, 297, 1475, 26, 283, 1569, 15, 14230, 936, 2736, 7208, 288, 754, 9, 339, 347, 511, 63, 393, 3440, 63, 1989, 63, 2489, 8, 277, 304, 267, 408, 267, 18784, 787, 1066, 895, 13824, 4245, 68, 701, 3232, 16862, 3339, 14, 267, 408, 267, 8509, 2113, 275, 4770, 423, 5189, 59, 17024, 61, 267, 1824, 275, 8509, 2113, 14, 362, 63, 19043, 63, 964, 8, 403, 16315, 267, 965, 63, 2489, 275, 1824, 14, 955, 459, 1403, 2278, 1989, 63, 2489, 398, 2536, 275, 7584, 8, 969, 14, 25230, 1342, 2010, 1641, 11700, 1427, 2481, 12, 14589, 14, 21, 10860, 709, 2426, 614, 1079, 2576, 1020, 12, 15627, 29, 17948, 9, 267, 666, 63, 7191, 275, 298, 5943, 998, 29, 1703, 1641, 27, 7217, 8, 1079, 3129, 13657, 14, 1465, 26385, 10936, 21, 1227, 12128, 14098, 14, 26978, 13357, 1020, 2924, 267, 666, 63, 4398, 63, 7191, 275, 298, 5943, 998, 29, 1703, 1641, 27, 7217, 8, 1079, 3129, 13657, 14, 1465, 26385, 10936, 16, 1227, 12128, 14098, 14, 26978, 1555, 15458, 2924, 267, 666, 63, 2489, 275, 298, 5943, 998, 29, 1703, 1641, 27, 7217, 8, 1079, 3129, 16303, 14, 1717, 1465, 10638, 1227, 12128, 17380, 14, 26623, 1085, 966, 2924, 398, 291, 14, 1815, 8, 1989, 63, 2489, 8, 403, 12, 666, 63, 2489, 430, 267, 291, 14, 1815, 8, 1989, 63, 2489, 8, 2747, 12, 25491, 267, 291, 14, 3334, 8, 1989, 63, 2489, 8, 403, 12, 25491, 267, 291, 14, 3334, 8, 1989, 63, 2489, 8, 2747, 12, 666, 63, 7191, 430, 267, 291, 14, 3334, 8, 1989, 63, 2489, 8, 2747, 12, 666, 63, 4398, 63, 7191, 430, 267, 291, 14, 1815, 8, 1989, 63, 2489, 8, 2747, 12, 666, 63, 2489, 430, 339, 347, 511, 63, 393, 3440, 63, 1667, 63, 875, 8, 277, 304, 267, 8509, 2113, 275, 4770, 423, 5189, 59, 17024, 61, 267, 1824, 275, 8509, 2113, 14, 362, 63, 19043, 63, 964, 8, 403, 9, 3252, 1403, 356, 283, 3071, 267, 543, 3371, 63, 2921, 360, 1176, 14, 2828, 14, 5668, 297, 283, 705, 358, 465, 2512, 63, 5352, 26, 288, 1072, 275, 620, 8, 964, 459, 1403, 1105, 267, 291, 14, 4080, 4943, 8, 288, 2650, 20895, 1305, 628, 344, 63, 1403, 2, 1021, 628, 86, 55, 12362, 792, 1415, 2, 8850, 628, 8251, 4507, 288, 283, 4730, 628, 709, 2, 536, 628, 1403, 10070, 20895, 4206, 288, 1072, 267, 776, 267, 291, 14, 629, 8, 2921, 63, 5352, 12, 3073, 339, 347, 511, 63, 393, 3440, 63, 3197, 63, 875, 8, 277, 304, 267, 8509, 2113, 275, 4770 ]
[ 1639, 14, 2828, 14, 5668, 492, 4628, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 492, 7584, 199, 504, 1639, 14, 396, 492, 7640, 12, 4278, 63, 1751, 199, 504, 1639, 14, 396, 14, 1208, 492, 3371, 63, 2921, 199, 199, 504, 1275, 2113, 492, 1910, 3729, 24183, 4880, 199, 504, 1275, 992, 492, 14753, 12, 4770, 421, 199, 32, 4415, 63, 1751, 8, 5441, 63, 18125, 534, 1176, 14, 2828, 14, 5668, 14, 2219, 14, 6721, 2113, 14, 3603, 358, 199, 533, 8875, 4880, 774, 8, 1746, 304, 339, 347, 511, 63, 7505, 63, 6721, 9770, 63, 4603, 8, 277, 304, 267, 8509, 2113, 275, 4770, 423, 5189, 59, 17024, 61, 267, 4628, 63, 3596, 275, 8509, 2113, 14, 4603, 14, 3352, 63, 3596, 342, 267, 291, 14, 1815, 8, 1629, 8, 6721, 2113, 14, 1490, 4359, 63, 633, 315, 8586, 367, 8586, 315, 4628, 63, 3596, 430, 339, 347, 511, 63, 393, 1130, 63, 3100, 45, 63, 28228, 8, 277, 304, 267, 3145, 63, 452, 63, 9633, 275, 8894, 65, 4369, 628, 9554, 26, 303, 364, 858, 63, 1403, 14, 3584, 10807, 342, 1743, 5392, 1006, 7949, 2093, 1108, 65, 11193, 398, 3379, 63, 6721, 2113, 275, 4770, 423, 5189, 59, 17024, 61, 267, 1862, 275, 3379, 63, 6721, 2113, 14, 362, 63, 1130, 63, 3440, 8, 17024, 423, 2024, 14, 362, 63, 698, 360, 1403, 11103, 1162, 267, 754, 275, 3379, 63, 6721, 2113, 14, 362, 63, 1130, 63, 3440, 8, 17024, 423, 2024, 14, 362, 63, 698, 360, 1403, 1333, 8, 267, 7092, 3352, 360, 1403, 297, 7584, 2801, 1965, 14, 2466, 1780, 1082, 12, 6335, 14, 10078, 2114, 395, 1862, 9, 267, 291, 14, 4080, 8, 288, 408, 303, 364, 858, 63, 1403, 14, 4359, 14, 1095, 275, 892, 3232, 16862, 14, 5003, 14, 3100, 45, 480, 4299, 933, 7936, 2956, 334, 2956, 22998, 9, 3547, 7208, 288, 754, 9, 398, 291, 14, 4080, 8, 1807, 63, 452, 63, 9633, 12, 754, 9, 398, 4770, 14, 18408, 8, 17024, 9, 267, 4770, 14, 2683, 8, 17024, 12, 1910, 3729, 24183, 4880, 9, 267, 862, 26, 288, 8509, 2113, 275, 4770, 423, 5189, 59, 17024, 61, 288, 1862, 275, 8509, 2113, 14, 362, 63, 1130, 63, 3440, 8, 17024, 423, 2024, 14, 362, 63, 698, 360, 1403, 11103, 1162, 288, 754, 275, 8509, 2113, 14, 362, 63, 1130, 63, 3440, 8, 17024, 423, 2024, 14, 362, 63, 698, 360, 1403, 1333, 8, 288, 7092, 3352, 360, 1403, 297, 7584, 2801, 1965, 14, 2466, 1780, 1082, 12, 6335, 14, 10078, 2114, 395, 1862, 9, 953, 291, 14, 8795, 8, 1807, 63, 452, 63, 9633, 12, 754, 9, 267, 3753, 26, 288, 4770, 14, 18408, 8, 17024, 9, 288, 4770, 14, 2683, 8, 17024, 12, 3379, 63, 6721, 2113, 855, 533, 3368, 339, 347, 511, 63, 393, 1130, 63, 55, 3053, 63, 28228, 8, 277, 304, 267, 8509, 2113, 275, 4628, 14, 10748, 12976, 8, 17024, 12, 4770, 9, 267, 754, 275, 8509, 2113, 14, 362, 63, 1130, 63, 3440, 8, 17024, 423, 2024, 14, 362, 63, 698, 360, 1403, 1333, 8, 267, 7092, 3352, 360, 1403, 297, 7584, 2801, 1965, 14, 2466, 1780, 1082, 12, 6335, 14, 10078, 2114, 430, 267, 291, 14, 4080, 8, 288, 408, 303, 364, 858, 63, 1403, 14, 4359, 14, 1095, 275, 892, 3232, 16862, 14, 5003, 14, 55, 3053, 480, 4299, 16862, 644, 3053, 401, 408, 288, 408, 2, 1014, 921, 86, 1130, 16, 14, 18819, 14, 736, 6721, 14, 1308, 15, 30297, 15, 86, 1130, 16, 401, 469, 4359, 26, 283, 4316, 297, 1475, 26, 283, 1569, 15, 14230, 936, 2736, 7208, 288, 754, 9, 339, 347, 511, 63, 393, 3440, 63, 1989, 63, 2489, 8, 277, 304, 267, 408, 267, 18784, 787, 1066, 895, 13824, 4245, 68, 701, 3232, 16862, 3339, 14, 267, 408, 267, 8509, 2113, 275, 4770, 423, 5189, 59, 17024, 61, 267, 1824, 275, 8509, 2113, 14, 362, 63, 19043, 63, 964, 8, 403, 16315, 267, 965, 63, 2489, 275, 1824, 14, 955, 459, 1403, 2278, 1989, 63, 2489, 398, 2536, 275, 7584, 8, 969, 14, 25230, 1342, 2010, 1641, 11700, 1427, 2481, 12, 14589, 14, 21, 10860, 709, 2426, 614, 1079, 2576, 1020, 12, 15627, 29, 17948, 9, 267, 666, 63, 7191, 275, 298, 5943, 998, 29, 1703, 1641, 27, 7217, 8, 1079, 3129, 13657, 14, 1465, 26385, 10936, 21, 1227, 12128, 14098, 14, 26978, 13357, 1020, 2924, 267, 666, 63, 4398, 63, 7191, 275, 298, 5943, 998, 29, 1703, 1641, 27, 7217, 8, 1079, 3129, 13657, 14, 1465, 26385, 10936, 16, 1227, 12128, 14098, 14, 26978, 1555, 15458, 2924, 267, 666, 63, 2489, 275, 298, 5943, 998, 29, 1703, 1641, 27, 7217, 8, 1079, 3129, 16303, 14, 1717, 1465, 10638, 1227, 12128, 17380, 14, 26623, 1085, 966, 2924, 398, 291, 14, 1815, 8, 1989, 63, 2489, 8, 403, 12, 666, 63, 2489, 430, 267, 291, 14, 1815, 8, 1989, 63, 2489, 8, 2747, 12, 25491, 267, 291, 14, 3334, 8, 1989, 63, 2489, 8, 403, 12, 25491, 267, 291, 14, 3334, 8, 1989, 63, 2489, 8, 2747, 12, 666, 63, 7191, 430, 267, 291, 14, 3334, 8, 1989, 63, 2489, 8, 2747, 12, 666, 63, 4398, 63, 7191, 430, 267, 291, 14, 1815, 8, 1989, 63, 2489, 8, 2747, 12, 666, 63, 2489, 430, 339, 347, 511, 63, 393, 3440, 63, 1667, 63, 875, 8, 277, 304, 267, 8509, 2113, 275, 4770, 423, 5189, 59, 17024, 61, 267, 1824, 275, 8509, 2113, 14, 362, 63, 19043, 63, 964, 8, 403, 9, 3252, 1403, 356, 283, 3071, 267, 543, 3371, 63, 2921, 360, 1176, 14, 2828, 14, 5668, 297, 283, 705, 358, 465, 2512, 63, 5352, 26, 288, 1072, 275, 620, 8, 964, 459, 1403, 1105, 267, 291, 14, 4080, 4943, 8, 288, 2650, 20895, 1305, 628, 344, 63, 1403, 2, 1021, 628, 86, 55, 12362, 792, 1415, 2, 8850, 628, 8251, 4507, 288, 283, 4730, 628, 709, 2, 536, 628, 1403, 10070, 20895, 4206, 288, 1072, 267, 776, 267, 291, 14, 629, 8, 2921, 63, 5352, 12, 3073, 339, 347, 511, 63, 393, 3440, 63, 3197, 63, 875, 8, 277, 304, 267, 8509, 2113, 275, 4770, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
undoware/neutron-drive
google_appengine/google/appengine/_internal/antlr3/recognizers.py
28
51703
"""ANTLR3 runtime package""" # begin[licence] # # [The "BSD licence"] # Copyright (c) 2005-2008 Terence Parr # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR 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. # # end[licence] import sys import inspect from google.appengine._internal.antlr3 import runtime_version, runtime_version_str from google.appengine._internal.antlr3.constants import DEFAULT_CHANNEL, HIDDEN_CHANNEL, EOF, EOR_TOKEN_TYPE, INVALID_TOKEN_TYPE from google.appengine._internal.antlr3.exceptions import RecognitionException, MismatchedTokenException, MismatchedRangeException, MismatchedTreeNodeException, NoViableAltException, EarlyExitException, MismatchedSetException, MismatchedNotSetException, FailedPredicateException, BacktrackingFailed, UnwantedTokenException, MissingTokenException from google.appengine._internal.antlr3.tokens import CommonToken, EOF_TOKEN, SKIP_TOKEN from google.appengine._internal.antlr3.compat import set, frozenset, reversed class RecognizerSharedState(object): """ The set of fields needed by an abstract recognizer to recognize input and recover from errors etc... As a separate state object, it can be shared among multiple grammars; e.g., when one grammar imports another. These fields are publically visible but the actual state pointer per parser is protected. """ def __init__(self): # Track the set of token types that can follow any rule invocation. # Stack grows upwards. self.following = [] # This is true when we see an error and before having successfully # matched a token. Prevents generation of more than one error message # per error. self.errorRecovery = False # The index into the input stream where the last error occurred. # This is used to prevent infinite loops where an error is found # but no token is consumed during recovery...another error is found, # ad naseum. This is a failsafe mechanism to guarantee that at least # one token/tree node is consumed for two errors. self.lastErrorIndex = -1 # If 0, no backtracking is going on. Safe to exec actions etc... # If >0 then it's the level of backtracking. self.backtracking = 0 # An array[size num rules] of Map<Integer,Integer> that tracks # the stop token index for each rule. ruleMemo[ruleIndex] is # the memoization table for ruleIndex. For key ruleStartIndex, you # get back the stop token for associated rule or MEMO_RULE_FAILED. # # This is only used if rule memoization is on (which it is by default). self.ruleMemo = None ## Did the recognizer encounter a syntax error? Track how many. self.syntaxErrors = 0 # LEXER FIELDS (must be in same state object to avoid casting # constantly in generated code and Lexer object) :( ## The goal of all lexer rules/methods is to create a token object. # This is an instance variable as multiple rules may collaborate to # create a single token. nextToken will return this object after # matching lexer rule(s). If you subclass to allow multiple token # emissions, then set this to the last token to be matched or # something nonnull so that the auto token emit mechanism will not # emit another token. self.token = None ## What character index in the stream did the current token start at? # Needed, for example, to get the text for current token. Set at # the start of nextToken. self.tokenStartCharIndex = -1 ## The line on which the first character of the token resides self.tokenStartLine = None ## The character position of first character within the line self.tokenStartCharPositionInLine = None ## The channel number for the current token self.channel = None ## The token type for the current token self.type = None ## You can set the text for the current token to override what is in # the input char buffer. Use setText() or can set this instance var. self.text = None class BaseRecognizer(object): """ @brief Common recognizer functionality. A generic recognizer that can handle recognizers generated from lexer, parser, and tree grammars. This is all the parsing support code essentially; most of it is error recovery stuff and backtracking. """ MEMO_RULE_FAILED = -2 MEMO_RULE_UNKNOWN = -1 # copies from Token object for convenience in actions DEFAULT_TOKEN_CHANNEL = DEFAULT_CHANNEL # for convenience in actions HIDDEN = HIDDEN_CHANNEL # overridden by generated subclasses tokenNames = None # The antlr_version attribute has been introduced in 3.1. If it is not # overwritten in the generated recognizer, we assume a default of 3.0.1. antlr_version = (3, 0, 1, 0) antlr_version_str = "3.0.1" def __init__(self, state=None): # Input stream of the recognizer. Must be initialized by a subclass. self.input = None ## State of a lexer, parser, or tree parser are collected into a state # object so the state can be shared. This sharing is needed to # have one grammar import others and share same error variables # and other state variables. It's a kind of explicit multiple # inheritance via delegation of methods and shared state. if state is None: state = RecognizerSharedState() self._state = state if self.antlr_version > runtime_version: raise RuntimeError( "ANTLR version mismatch: " "The recognizer has been generated by V%s, but this runtime " "is V%s. Please use the V%s runtime or higher." % (self.antlr_version_str, runtime_version_str, self.antlr_version_str)) elif (self.antlr_version < (3, 1, 0, 0) and self.antlr_version != runtime_version): # FIXME: make the runtime compatible with 3.0.1 codegen # and remove this block. raise RuntimeError( "ANTLR version mismatch: " "The recognizer has been generated by V%s, but this runtime " "is V%s. Please use the V%s runtime." % (self.antlr_version_str, runtime_version_str, self.antlr_version_str)) # this one only exists to shut up pylint :( def setInput(self, input): self.input = input def reset(self): """ reset the parser's state; subclasses must rewinds the input stream """ # wack everything related to error recovery if self._state is None: # no shared state work to do return self._state.following = [] self._state.errorRecovery = False self._state.lastErrorIndex = -1 self._state.syntaxErrors = 0 # wack everything related to backtracking and memoization self._state.backtracking = 0 if self._state.ruleMemo is not None: self._state.ruleMemo = {} def match(self, input, ttype, follow): """ Match current input symbol against ttype. Attempt single token insertion or deletion error recovery. If that fails, throw MismatchedTokenException. To turn off single token insertion or deletion error recovery, override mismatchRecover() and have it call plain mismatch(), which does not recover. Then any error in a rule will cause an exception and immediate exit from rule. Rule would recover by resynchronizing to the set of symbols that can follow rule ref. """ matchedSymbol = self.getCurrentInputSymbol(input) if self.input.LA(1) == ttype: self.input.consume() self._state.errorRecovery = False return matchedSymbol if self._state.backtracking > 0: # FIXME: need to return matchedSymbol here as well. damn!! raise BacktrackingFailed matchedSymbol = self.recoverFromMismatchedToken(input, ttype, follow) return matchedSymbol def matchAny(self, input): """Match the wildcard: in a symbol""" self._state.errorRecovery = False self.input.consume() def mismatchIsUnwantedToken(self, input, ttype): return input.LA(2) == ttype def mismatchIsMissingToken(self, input, follow): if follow is None: # we have no information about the follow; we can only consume # a single token and hope for the best return False # compute what can follow this grammar element reference if EOR_TOKEN_TYPE in follow: if len(self._state.following) > 0: # remove EOR if we're not the start symbol follow = follow - set([EOR_TOKEN_TYPE]) viableTokensFollowingThisRule = self.computeContextSensitiveRuleFOLLOW() follow = follow | viableTokensFollowingThisRule # if current token is consistent with what could come after set # then we know we're missing a token; error recovery is free to # "insert" the missing token if input.LA(1) in follow or EOR_TOKEN_TYPE in follow: return True return False def mismatch(self, input, ttype, follow): """ Factor out what to do upon token mismatch so tree parsers can behave differently. Override and call mismatchRecover(input, ttype, follow) to get single token insertion and deletion. Use this to turn of single token insertion and deletion. Override mismatchRecover to call this instead. """ if self.mismatchIsUnwantedToken(input, ttype): raise UnwantedTokenException(ttype, input) elif self.mismatchIsMissingToken(input, follow): raise MissingTokenException(ttype, input, None) raise MismatchedTokenException(ttype, input) ## def mismatchRecover(self, input, ttype, follow): ## if self.mismatchIsUnwantedToken(input, ttype): ## mte = UnwantedTokenException(ttype, input) ## elif self.mismatchIsMissingToken(input, follow): ## mte = MissingTokenException(ttype, input) ## else: ## mte = MismatchedTokenException(ttype, input) ## self.recoverFromMismatchedToken(input, mte, ttype, follow) def reportError(self, e): """Report a recognition problem. This method sets errorRecovery to indicate the parser is recovering not parsing. Once in recovery mode, no errors are generated. To get out of recovery mode, the parser must successfully match a token (after a resync). So it will go: 1. error occurs 2. enter recovery mode, report error 3. consume until token found in resynch set 4. try to resume parsing 5. next match() will reset errorRecovery mode If you override, make sure to update syntaxErrors if you care about that. """ # if we've already reported an error and have not matched a token # yet successfully, don't report any errors. if self._state.errorRecovery: return self._state.syntaxErrors += 1 # don't count spurious self._state.errorRecovery = True self.displayRecognitionError(self.tokenNames, e) def displayRecognitionError(self, tokenNames, e): hdr = self.getErrorHeader(e) msg = self.getErrorMessage(e, tokenNames) self.emitErrorMessage(hdr+" "+msg) def getErrorMessage(self, e, tokenNames): """ What error message should be generated for the various exception types? Not very object-oriented code, but I like having all error message generation within one method rather than spread among all of the exception classes. This also makes it much easier for the exception handling because the exception classes do not have to have pointers back to this object to access utility routines and so on. Also, changing the message for an exception type would be difficult because you would have to subclassing exception, but then somehow get ANTLR to make those kinds of exception objects instead of the default. This looks weird, but trust me--it makes the most sense in terms of flexibility. For grammar debugging, you will want to override this to add more information such as the stack frame with getRuleInvocationStack(e, this.getClass().getName()) and, for no viable alts, the decision description and state etc... Override this to change the message generated for one or more exception types. """ if isinstance(e, UnwantedTokenException): tokenName = "<unknown>" if e.expecting == EOF: tokenName = "EOF" else: tokenName = self.tokenNames[e.expecting] msg = "extraneous input %s expecting %s" % ( self.getTokenErrorDisplay(e.getUnexpectedToken()), tokenName ) elif isinstance(e, MissingTokenException): tokenName = "<unknown>" if e.expecting == EOF: tokenName = "EOF" else: tokenName = self.tokenNames[e.expecting] msg = "missing %s at %s" % ( tokenName, self.getTokenErrorDisplay(e.token) ) elif isinstance(e, MismatchedTokenException): tokenName = "<unknown>" if e.expecting == EOF: tokenName = "EOF" else: tokenName = self.tokenNames[e.expecting] msg = "mismatched input " + self.getTokenErrorDisplay(e.token) + " expecting " + tokenName elif isinstance(e, MismatchedTreeNodeException): tokenName = "<unknown>" if e.expecting == EOF: tokenName = "EOF" else: tokenName = self.tokenNames[e.expecting] msg = "mismatched tree node: %s expecting %s" % (e.node, tokenName) elif isinstance(e, NoViableAltException): msg = "no viable alternative at input " + self.getTokenErrorDisplay(e.token) elif isinstance(e, EarlyExitException): msg = "required (...)+ loop did not match anything at input " + self.getTokenErrorDisplay(e.token) elif isinstance(e, MismatchedSetException): msg = "mismatched input " + self.getTokenErrorDisplay(e.token) + " expecting set " + repr(e.expecting) elif isinstance(e, MismatchedNotSetException): msg = "mismatched input " + self.getTokenErrorDisplay(e.token) + " expecting set " + repr(e.expecting) elif isinstance(e, FailedPredicateException): msg = "rule " + e.ruleName + " failed predicate: {" + e.predicateText + "}?" else: msg = str(e) return msg def getNumberOfSyntaxErrors(self): """ Get number of recognition errors (lexer, parser, tree parser). Each recognizer tracks its own number. So parser and lexer each have separate count. Does not count the spurious errors found between an error and next valid token match See also reportError() """ return self._state.syntaxErrors def getErrorHeader(self, e): """ What is the error header, normally line/character position information? """ return "line %d:%d" % (e.line, e.charPositionInLine) def getTokenErrorDisplay(self, t): """ How should a token be displayed in an error message? The default is to display just the text, but during development you might want to have a lot of information spit out. Override in that case to use t.toString() (which, for CommonToken, dumps everything about the token). This is better than forcing you to override a method in your token objects because you don't have to go modify your lexer so that it creates a new Java type. """ s = t.text if s is None: if t.type == EOF: s = "<EOF>" else: s = "<"+t.type+">" return repr(s) def emitErrorMessage(self, msg): """Override this method to change where error messages go""" sys.stderr.write(msg + '\n') def recover(self, input, re): """ Recover from an error found on the input stream. This is for NoViableAlt and mismatched symbol exceptions. If you enable single token insertion and deletion, this will usually not handle mismatched symbol exceptions but there could be a mismatched token that the match() routine could not recover from. """ # PROBLEM? what if input stream is not the same as last time # perhaps make lastErrorIndex a member of input if self._state.lastErrorIndex == input.index(): # uh oh, another error at same token index; must be a case # where LT(1) is in the recovery token set so nothing is # consumed; consume a single token so at least to prevent # an infinite loop; this is a failsafe. input.consume() self._state.lastErrorIndex = input.index() followSet = self.computeErrorRecoverySet() self.beginResync() self.consumeUntil(input, followSet) self.endResync() def beginResync(self): """ A hook to listen in on the token consumption during error recovery. The DebugParser subclasses this to fire events to the listenter. """ pass def endResync(self): """ A hook to listen in on the token consumption during error recovery. The DebugParser subclasses this to fire events to the listenter. """ pass def computeErrorRecoverySet(self): """ Compute the error recovery set for the current rule. During rule invocation, the parser pushes the set of tokens that can follow that rule reference on the stack; this amounts to computing FIRST of what follows the rule reference in the enclosing rule. This local follow set only includes tokens from within the rule; i.e., the FIRST computation done by ANTLR stops at the end of a rule. EXAMPLE When you find a "no viable alt exception", the input is not consistent with any of the alternatives for rule r. The best thing to do is to consume tokens until you see something that can legally follow a call to r *or* any rule that called r. You don't want the exact set of viable next tokens because the input might just be missing a token--you might consume the rest of the input looking for one of the missing tokens. Consider grammar: a : '[' b ']' | '(' b ')' ; b : c '^' INT ; c : ID | INT ; At each rule invocation, the set of tokens that could follow that rule is pushed on a stack. Here are the various "local" follow sets: FOLLOW(b1_in_a) = FIRST(']') = ']' FOLLOW(b2_in_a) = FIRST(')') = ')' FOLLOW(c_in_b) = FIRST('^') = '^' Upon erroneous input "[]", the call chain is a -> b -> c and, hence, the follow context stack is: depth local follow set after call to rule 0 \<EOF> a (from main()) 1 ']' b 3 '^' c Notice that ')' is not included, because b would have to have been called from a different context in rule a for ')' to be included. For error recovery, we cannot consider FOLLOW(c) (context-sensitive or otherwise). We need the combined set of all context-sensitive FOLLOW sets--the set of all tokens that could follow any reference in the call chain. We need to resync to one of those tokens. Note that FOLLOW(c)='^' and if we resync'd to that token, we'd consume until EOF. We need to sync to context-sensitive FOLLOWs for a, b, and c: {']','^'}. In this case, for input "[]", LA(1) is in this set so we would not consume anything and after printing an error rule c would return normally. It would not find the required '^' though. At this point, it gets a mismatched token error and throws an exception (since LA(1) is not in the viable following token set). The rule exception handler tries to recover, but finds the same recovery set and doesn't consume anything. Rule b exits normally returning to rule a. Now it finds the ']' (and with the successful match exits errorRecovery mode). So, you cna see that the parser walks up call chain looking for the token that was a member of the recovery set. Errors are not generated in errorRecovery mode. ANTLR's error recovery mechanism is based upon original ideas: "Algorithms + Data Structures = Programs" by Niklaus Wirth and "A note on error recovery in recursive descent parsers": http://portal.acm.org/citation.cfm?id=947902.947905 Later, Josef Grosch had some good ideas: "Efficient and Comfortable Error Recovery in Recursive Descent Parsers": ftp://www.cocolab.com/products/cocktail/doca4.ps/ell.ps.zip Like Grosch I implemented local FOLLOW sets that are combined at run-time upon error to avoid overhead during parsing. """ return self.combineFollows(False) def computeContextSensitiveRuleFOLLOW(self): """ Compute the context-sensitive FOLLOW set for current rule. This is set of token types that can follow a specific rule reference given a specific call chain. You get the set of viable tokens that can possibly come next (lookahead depth 1) given the current call chain. Contrast this with the definition of plain FOLLOW for rule r: FOLLOW(r)={x | S=>*alpha r beta in G and x in FIRST(beta)} where x in T* and alpha, beta in V*; T is set of terminals and V is the set of terminals and nonterminals. In other words, FOLLOW(r) is the set of all tokens that can possibly follow references to r in *any* sentential form (context). At runtime, however, we know precisely which context applies as we have the call chain. We may compute the exact (rather than covering superset) set of following tokens. For example, consider grammar: stat : ID '=' expr ';' // FOLLOW(stat)=={EOF} | "return" expr '.' ; expr : atom ('+' atom)* ; // FOLLOW(expr)=={';','.',')'} atom : INT // FOLLOW(atom)=={'+',')',';','.'} | '(' expr ')' ; The FOLLOW sets are all inclusive whereas context-sensitive FOLLOW sets are precisely what could follow a rule reference. For input input "i=(3);", here is the derivation: stat => ID '=' expr ';' => ID '=' atom ('+' atom)* ';' => ID '=' '(' expr ')' ('+' atom)* ';' => ID '=' '(' atom ')' ('+' atom)* ';' => ID '=' '(' INT ')' ('+' atom)* ';' => ID '=' '(' INT ')' ';' At the "3" token, you'd have a call chain of stat -> expr -> atom -> expr -> atom What can follow that specific nested ref to atom? Exactly ')' as you can see by looking at the derivation of this specific input. Contrast this with the FOLLOW(atom)={'+',')',';','.'}. You want the exact viable token set when recovering from a token mismatch. Upon token mismatch, if LA(1) is member of the viable next token set, then you know there is most likely a missing token in the input stream. "Insert" one by just not throwing an exception. """ return self.combineFollows(True) def combineFollows(self, exact): followSet = set() for idx, localFollowSet in reversed(list(enumerate(self._state.following))): followSet |= localFollowSet if exact: # can we see end of rule? if EOR_TOKEN_TYPE in localFollowSet: # Only leave EOR in set if at top (start rule); this lets # us know if have to include follow(start rule); i.e., EOF if idx > 0: followSet.remove(EOR_TOKEN_TYPE) else: # can't see end of rule, quit break return followSet def recoverFromMismatchedToken(self, input, ttype, follow): """Attempt to recover from a single missing or extra token. EXTRA TOKEN LA(1) is not what we are looking for. If LA(2) has the right token, however, then assume LA(1) is some extra spurious token. Delete it and LA(2) as if we were doing a normal match(), which advances the input. MISSING TOKEN If current token is consistent with what could come after ttype then it is ok to 'insert' the missing token, else throw exception For example, Input 'i=(3;' is clearly missing the ')'. When the parser returns from the nested call to expr, it will have call chain: stat -> expr -> atom and it will be trying to match the ')' at this point in the derivation: => ID '=' '(' INT ')' ('+' atom)* ';' ^ match() will see that ';' doesn't match ')' and report a mismatched token error. To recover, it sees that LA(1)==';' is in the set of tokens that can follow the ')' token reference in rule atom. It can assume that you forgot the ')'. """ e = None # if next token is what we are looking for then "delete" this token if self. mismatchIsUnwantedToken(input, ttype): e = UnwantedTokenException(ttype, input) self.beginResync() input.consume() # simply delete extra token self.endResync() # report after consuming so AW sees the token in the exception self.reportError(e) # we want to return the token we're actually matching matchedSymbol = self.getCurrentInputSymbol(input) # move past ttype token as if all were ok input.consume() return matchedSymbol # can't recover with single token deletion, try insertion if self.mismatchIsMissingToken(input, follow): inserted = self.getMissingSymbol(input, e, ttype, follow) e = MissingTokenException(ttype, input, inserted) # report after inserting so AW sees the token in the exception self.reportError(e) return inserted # even that didn't work; must throw the exception e = MismatchedTokenException(ttype, input) raise e def recoverFromMismatchedSet(self, input, e, follow): """Not currently used""" if self.mismatchIsMissingToken(input, follow): self.reportError(e) # we don't know how to conjure up a token for sets yet return self.getMissingSymbol(input, e, INVALID_TOKEN_TYPE, follow) # TODO do single token deletion like above for Token mismatch raise e def getCurrentInputSymbol(self, input): """ Match needs to return the current input symbol, which gets put into the label for the associated token ref; e.g., x=ID. Token and tree parsers need to return different objects. Rather than test for input stream type or change the IntStream interface, I use a simple method to ask the recognizer to tell me what the current input symbol is. This is ignored for lexers. """ return None def getMissingSymbol(self, input, e, expectedTokenType, follow): """Conjure up a missing token during error recovery. The recognizer attempts to recover from single missing symbols. But, actions might refer to that missing symbol. For example, x=ID {f($x);}. The action clearly assumes that there has been an identifier matched previously and that $x points at that token. If that token is missing, but the next token in the stream is what we want we assume that this token is missing and we keep going. Because we have to return some token to replace the missing token, we have to conjure one up. This method gives the user control over the tokens returned for missing tokens. Mostly, you will want to create something special for identifier tokens. For literals such as '{' and ',', the default action in the parser or tree parser works. It simply creates a CommonToken of the appropriate type. The text will be the token. If you change what tokens must be created by the lexer, override this method to create the appropriate tokens. """ return None ## def recoverFromMissingElement(self, input, e, follow): ## """ ## This code is factored out from mismatched token and mismatched set ## recovery. It handles "single token insertion" error recovery for ## both. No tokens are consumed to recover from insertions. Return ## true if recovery was possible else return false. ## """ ## if self.mismatchIsMissingToken(input, follow): ## self.reportError(e) ## return True ## # nothing to do; throw exception ## return False def consumeUntil(self, input, tokenTypes): """ Consume tokens until one matches the given token or token set tokenTypes can be a single token type or a set of token types """ if not isinstance(tokenTypes, (set, frozenset)): tokenTypes = frozenset([tokenTypes]) ttype = input.LA(1) while ttype != EOF and ttype not in tokenTypes: input.consume() ttype = input.LA(1) def getRuleInvocationStack(self): """ Return List<String> of the rules in your parser instance leading up to a call to this method. You could override if you want more details such as the file/line info of where in the parser java code a rule is invoked. This is very useful for error messages and for context-sensitive error recovery. You must be careful, if you subclass a generated recognizers. The default implementation will only search the module of self for rules, but the subclass will not contain any rules. You probably want to override this method to look like def getRuleInvocationStack(self): return self._getRuleInvocationStack(<class>.__module__) where <class> is the class of the generated recognizer, e.g. the superclass of self. """ return self._getRuleInvocationStack(self.__module__) def _getRuleInvocationStack(cls, module): """ A more general version of getRuleInvocationStack where you can pass in, for example, a RecognitionException to get it's rule stack trace. This routine is shared with all recognizers, hence, static. TODO: move to a utility class or something; weird having lexer call this """ # mmmhhh,... perhaps look at the first argument # (f_locals[co_varnames[0]]?) and test if it's a (sub)class of # requested recognizer... rules = [] for frame in reversed(inspect.stack()): code = frame[0].f_code codeMod = inspect.getmodule(code) if codeMod is None: continue # skip frames not in requested module if codeMod.__name__ != module: continue # skip some unwanted names if code.co_name in ('nextToken', '<module>'): continue rules.append(code.co_name) return rules _getRuleInvocationStack = classmethod(_getRuleInvocationStack) def getBacktrackingLevel(self): return self._state.backtracking def getGrammarFileName(self): """For debugging and other purposes, might want the grammar name. Have ANTLR generate an implementation for this method. """ return self.grammarFileName def getSourceName(self): raise NotImplementedError def toStrings(self, tokens): """A convenience method for use most often with template rewrites. Convert a List<Token> to List<String> """ if tokens is None: return None return [token.text for token in tokens] def getRuleMemoization(self, ruleIndex, ruleStartIndex): """ Given a rule number and a start token index number, return MEMO_RULE_UNKNOWN if the rule has not parsed input starting from start index. If this rule has parsed input starting from the start index before, then return where the rule stopped parsing. It returns the index of the last token matched by the rule. """ if ruleIndex not in self._state.ruleMemo: self._state.ruleMemo[ruleIndex] = {} return self._state.ruleMemo[ruleIndex].get( ruleStartIndex, self.MEMO_RULE_UNKNOWN ) def alreadyParsedRule(self, input, ruleIndex): """ Has this rule already parsed input at the current index in the input stream? Return the stop token index or MEMO_RULE_UNKNOWN. If we attempted but failed to parse properly before, return MEMO_RULE_FAILED. This method has a side-effect: if we have seen this input for this rule and successfully parsed before, then seek ahead to 1 past the stop token matched for this rule last time. """ stopIndex = self.getRuleMemoization(ruleIndex, input.index()) if stopIndex == self.MEMO_RULE_UNKNOWN: return False if stopIndex == self.MEMO_RULE_FAILED: raise BacktrackingFailed else: input.seek(stopIndex + 1) return True def memoize(self, input, ruleIndex, ruleStartIndex, success): """ Record whether or not this rule parsed the input at this position successfully. """ if success: stopTokenIndex = input.index() - 1 else: stopTokenIndex = self.MEMO_RULE_FAILED if ruleIndex in self._state.ruleMemo: self._state.ruleMemo[ruleIndex][ruleStartIndex] = stopTokenIndex def traceIn(self, ruleName, ruleIndex, inputSymbol): sys.stdout.write("enter %s %s" % (ruleName, inputSymbol)) ## if self._state.failed: ## sys.stdout.write(" failed=%s" % self._state.failed) if self._state.backtracking > 0: sys.stdout.write(" backtracking=%s" % self._state.backtracking) sys.stdout.write('\n') def traceOut(self, ruleName, ruleIndex, inputSymbol): sys.stdout.write("exit %s %s" % (ruleName, inputSymbol)) ## if self._state.failed: ## sys.stdout.write(" failed=%s" % self._state.failed) if self._state.backtracking > 0: sys.stdout.write(" backtracking=%s" % self._state.backtracking) sys.stdout.write('\n') class TokenSource(object): """ @brief Abstract baseclass for token producers. A source of tokens must provide a sequence of tokens via nextToken() and also must reveal it's source of characters; CommonToken's text is computed from a CharStream; it only store indices into the char stream. Errors from the lexer are never passed to the parser. Either you want to keep going or you do not upon token recognition error. If you do not want to continue lexing then you do not want to continue parsing. Just throw an exception not under RecognitionException and Java will naturally toss you all the way out of the recognizers. If you want to continue lexing then you should not throw an exception to the parser--it has already requested a token. Keep lexing until you get a valid one. Just report errors and keep going, looking for a valid token. """ def nextToken(self): """Return a Token object from your input stream (usually a CharStream). Do not fail/return upon lexing error; keep chewing on the characters until you get a good one; errors are not passed through to the parser. """ raise NotImplementedError def __iter__(self): """The TokenSource is an interator. The iteration will not include the final EOF token, see also the note for the next() method. """ return self def next(self): """Return next token or raise StopIteration. Note that this will raise StopIteration when hitting the EOF token, so EOF will not be part of the iteration. """ token = self.nextToken() if token is None or token.type == EOF: raise StopIteration return token class Lexer(BaseRecognizer, TokenSource): """ @brief Baseclass for generated lexer classes. A lexer is recognizer that draws input symbols from a character stream. lexer grammars result in a subclass of this object. A Lexer object uses simplified match() and error recovery mechanisms in the interest of speed. """ def __init__(self, input, state=None): BaseRecognizer.__init__(self, state) TokenSource.__init__(self) # Where is the lexer drawing characters from? self.input = input def reset(self): BaseRecognizer.reset(self) # reset all recognizer state variables if self.input is not None: # rewind the input self.input.seek(0) if self._state is None: # no shared state work to do return # wack Lexer state variables self._state.token = None self._state.type = INVALID_TOKEN_TYPE self._state.channel = DEFAULT_CHANNEL self._state.tokenStartCharIndex = -1 self._state.tokenStartLine = -1 self._state.tokenStartCharPositionInLine = -1 self._state.text = None def nextToken(self): """ Return a token from this source; i.e., match a token on the char stream. """ while 1: self._state.token = None self._state.channel = DEFAULT_CHANNEL self._state.tokenStartCharIndex = self.input.index() self._state.tokenStartCharPositionInLine = self.input.charPositionInLine self._state.tokenStartLine = self.input.line self._state.text = None if self.input.LA(1) == EOF: return EOF_TOKEN try: self.mTokens() if self._state.token is None: self.emit() elif self._state.token == SKIP_TOKEN: continue return self._state.token except NoViableAltException, re: self.reportError(re) self.recover(re) # throw out current char and try again except RecognitionException, re: self.reportError(re) # match() routine has already called recover() def skip(self): """ Instruct the lexer to skip creating a token for current lexer rule and look for another token. nextToken() knows to keep looking when a lexer rule finishes with token set to SKIP_TOKEN. Recall that if token==null at end of any token rule, it creates one for you and emits it. """ self._state.token = SKIP_TOKEN def mTokens(self): """This is the lexer entry point that sets instance var 'token'""" # abstract method raise NotImplementedError def setCharStream(self, input): """Set the char stream and reset the lexer""" self.input = None self.reset() self.input = input def getSourceName(self): return self.input.getSourceName() def emit(self, token=None): """ The standard method called to automatically emit a token at the outermost lexical rule. The token object should point into the char buffer start..stop. If there is a text override in 'text', use that to set the token's text. Override this method to emit custom Token objects. If you are building trees, then you should also override Parser or TreeParser.getMissingSymbol(). """ if token is None: token = CommonToken( input=self.input, type=self._state.type, channel=self._state.channel, start=self._state.tokenStartCharIndex, stop=self.getCharIndex()-1 ) token.line = self._state.tokenStartLine token.text = self._state.text token.charPositionInLine = self._state.tokenStartCharPositionInLine self._state.token = token return token def match(self, s): if isinstance(s, basestring): for c in s: if self.input.LA(1) != ord(c): if self._state.backtracking > 0: raise BacktrackingFailed mte = MismatchedTokenException(c, self.input) self.recover(mte) raise mte self.input.consume() else: if self.input.LA(1) != s: if self._state.backtracking > 0: raise BacktrackingFailed mte = MismatchedTokenException(unichr(s), self.input) self.recover(mte) # don't really recover; just consume in lexer raise mte self.input.consume() def matchAny(self): self.input.consume() def matchRange(self, a, b): if self.input.LA(1) < a or self.input.LA(1) > b: if self._state.backtracking > 0: raise BacktrackingFailed mre = MismatchedRangeException(unichr(a), unichr(b), self.input) self.recover(mre) raise mre self.input.consume() def getLine(self): return self.input.line def getCharPositionInLine(self): return self.input.charPositionInLine def getCharIndex(self): """What is the index of the current character of lookahead?""" return self.input.index() def getText(self): """ Return the text matched so far for the current token or any text override. """ if self._state.text is not None: return self._state.text return self.input.substring( self._state.tokenStartCharIndex, self.getCharIndex()-1 ) def setText(self, text): """ Set the complete text of this token; it wipes any previous changes to the text. """ self._state.text = text text = property(getText, setText) def reportError(self, e): ## TODO: not thought about recovery in lexer yet. ## # if we've already reported an error and have not matched a token ## # yet successfully, don't report any errors. ## if self.errorRecovery: ## #System.err.print("[SPURIOUS] "); ## return; ## ## self.errorRecovery = True self.displayRecognitionError(self.tokenNames, e) def getErrorMessage(self, e, tokenNames): msg = None if isinstance(e, MismatchedTokenException): msg = "mismatched character " + self.getCharErrorDisplay(e.c) + " expecting " + self.getCharErrorDisplay(e.expecting) elif isinstance(e, NoViableAltException): msg = "no viable alternative at character " + self.getCharErrorDisplay(e.c) elif isinstance(e, EarlyExitException): msg = "required (...)+ loop did not match anything at character " + self.getCharErrorDisplay(e.c) elif isinstance(e, MismatchedNotSetException): msg = "mismatched character " + self.getCharErrorDisplay(e.c) + " expecting set " + repr(e.expecting) elif isinstance(e, MismatchedSetException): msg = "mismatched character " + self.getCharErrorDisplay(e.c) + " expecting set " + repr(e.expecting) elif isinstance(e, MismatchedRangeException): msg = "mismatched character " + self.getCharErrorDisplay(e.c) + " expecting set " + self.getCharErrorDisplay(e.a) + ".." + self.getCharErrorDisplay(e.b) else: msg = BaseRecognizer.getErrorMessage(self, e, tokenNames) return msg def getCharErrorDisplay(self, c): if c == EOF: c = '<EOF>' return repr(c) def recover(self, re): """ Lexers can normally match any char in it's vocabulary after matching a token, so do the easy thing and just kill a character and hope it all works out. You can instead use the rule invocation stack to do sophisticated error recovery if you are in a fragment rule. """ self.input.consume() def traceIn(self, ruleName, ruleIndex): inputSymbol = "%s line=%d:%s" % (self.input.LT(1), self.getLine(), self.getCharPositionInLine() ) BaseRecognizer.traceIn(self, ruleName, ruleIndex, inputSymbol) def traceOut(self, ruleName, ruleIndex): inputSymbol = "%s line=%d:%s" % (self.input.LT(1), self.getLine(), self.getCharPositionInLine() ) BaseRecognizer.traceOut(self, ruleName, ruleIndex, inputSymbol) class Parser(BaseRecognizer): """ @brief Baseclass for generated parser classes. """ def __init__(self, lexer, state=None): BaseRecognizer.__init__(self, state) self.setTokenStream(lexer) def reset(self): BaseRecognizer.reset(self) # reset all recognizer state variables if self.input is not None: self.input.seek(0) # rewind the input def getCurrentInputSymbol(self, input): return input.LT(1) def getMissingSymbol(self, input, e, expectedTokenType, follow): if expectedTokenType == EOF: tokenText = "<missing EOF>" else: tokenText = "<missing " + self.tokenNames[expectedTokenType] + ">" t = CommonToken(type=expectedTokenType, text=tokenText) current = input.LT(1) if current.type == EOF: current = input.LT(-1) if current is not None: t.line = current.line t.charPositionInLine = current.charPositionInLine t.channel = DEFAULT_CHANNEL return t def setTokenStream(self, input): """Set the token stream and reset the parser""" self.input = None self.reset() self.input = input def getTokenStream(self): return self.input def getSourceName(self): return self.input.getSourceName() def traceIn(self, ruleName, ruleIndex): BaseRecognizer.traceIn(self, ruleName, ruleIndex, self.input.LT(1)) def traceOut(self, ruleName, ruleIndex): BaseRecognizer.traceOut(self, ruleName, ruleIndex, self.input.LT(1)) class RuleReturnScope(object): """ Rules can return start/stop info as well as possible trees and templates. """ def getStart(self): """Return the start token or tree.""" return None def getStop(self): """Return the stop token or tree.""" return None def getTree(self): """Has a value potentially if output=AST.""" return None def getTemplate(self): """Has a value potentially if output=template.""" return None class ParserRuleReturnScope(RuleReturnScope): """ Rules that return more than a single value must return an object containing all the values. Besides the properties defined in RuleLabelScope.predefinedRulePropertiesScope there may be user-defined return values. This class simply defines the minimum properties that are always defined and methods to access the others that might be available depending on output option such as template and tree. Note text is not an actual property of the return value, it is computed from start and stop using the input stream's toString() method. I could add a ctor to this so that we can pass in and store the input stream, but I'm not sure we want to do that. It would seem to be undefined to get the .text property anyway if the rule matches tokens from multiple input streams. I do not use getters for fields of objects that are used simply to group values such as this aggregate. The getters/setters are there to satisfy the superclass interface. """ def __init__(self): self.start = None self.stop = None def getStart(self): return self.start def getStop(self): return self.stop
bsd-3-clause
[ 624, 1441, 17665, 19, 8836, 2559, 624, 199, 199, 3, 5386, 59, 606, 4894, 61, 199, 3, 199, 3, 359, 1918, 298, 15400, 23854, 4894, 937, 199, 3, 1898, 334, 67, 9, 11811, 13, 9300, 5773, 4646, 2235, 82, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 787, 7647, 26, 199, 3, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 259, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 650, 14, 710, 536, 402, 314, 4132, 1443, 440, 506, 1202, 370, 10692, 503, 10016, 7585, 199, 3, 259, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 17632, 1124, 1179, 2281, 891, 2401, 1821, 7168, 1549, 199, 3, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 2990, 199, 3, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 9706, 14, 199, 3, 1621, 4825, 6461, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 199, 3, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 199, 3, 2845, 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, 1634, 199, 3, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 3, 1284, 59, 606, 4894, 61, 199, 199, 646, 984, 199, 646, 6485, 199, 199, 504, 6233, 14, 15358, 423, 4672, 14, 867, 7493, 19, 492, 8836, 63, 1023, 12, 8836, 63, 1023, 63, 495, 199, 504, 6233, 14, 15358, 423, 4672, 14, 867, 7493, 19, 14, 5559, 492, 6186, 63, 14833, 12, 869, 22436, 63, 14833, 12, 9027, 12, 662, 726, 63, 8803, 63, 2711, 12, 29901, 63, 8803, 63, 2711, 199, 504, 6233, 14, 15358, 423, 4672, 14, 867, 7493, 19, 14, 3924, 492, 799, 6862, 15415, 1726, 12, 12481, 10151, 3264, 1726, 12, 12481, 10151, 4709, 1726, 12, 12481, 10151, 26749, 1726, 12, 3091, 2201, 461, 16985, 1726, 12, 662, 285, 590, 6699, 1726, 12, 12481, 10151, 1084, 1726, 12, 12481, 10151, 15953, 1726, 12, 16277, 22236, 1726, 12, 10257, 14428, 4276, 12, 1910, 19361, 3264, 1726, 12, 15626, 3264, 1726, 199, 504, 6233, 14, 15358, 423, 4672, 14, 867, 7493, 19, 14, 4504, 492, 13964, 3264, 12, 9027, 63, 8803, 12, 27885, 63, 8803, 199, 504, 6233, 14, 15358, 423, 4672, 14, 867, 7493, 19, 14, 5819, 492, 663, 12, 9522, 12, 10822, 421, 199, 533, 799, 6862, 1793, 12197, 2223, 8, 785, 304, 272, 408, 272, 710, 663, 402, 1504, 4346, 701, 376, 9006, 17319, 1793, 370, 27159, 1324, 272, 436, 22803, 687, 2552, 5423, 1396, 221, 3709, 282, 7396, 1174, 909, 12, 652, 883, 506, 272, 5709, 16885, 3663, 1999, 596, 4291, 27, 325, 14, 71, 2020, 1380, 1373, 12528, 8925, 4573, 14, 339, 5723, 1504, 787, 4575, 1183, 8917, 1325, 314, 3503, 1174, 7849, 1126, 272, 1798, 365, 17819, 14, 272, 408, 339, 347, 636, 826, 721, 277, 304, 267, 327, 17507, 314, 663, 402, 1526, 2943, 626, 883, 2035, 1263, 2332, 19569, 14, 267, 327, 13894, 486, 3838, 1536, 4751, 14, 267, 291, 14, 21589, 275, 942, 398, 327, 961, 365, 2549, 1380, 781, 1937, 376, 1125, 436, 2544, 9445, 8792, 267, 327, 7838, 282, 1526, 14, 221, 29861, 83, 10152, 402, 1655, 2419, 1373, 1125, 1245, 267, 327, 1126, 1125, 14, 267, 291, 14, 705, 497, 6913, 275, 756, 398, 327, 710, 1478, 1901, 314, 1324, 2547, 2382, 314, 2061, 1125, 8920, 14, 267, 327, 961, 365, 1202, 370, 7981, 15258, 17222, 2382, 376, 1125, 365, 1911, 267, 327, 1325, 949, 1526, 365, 16949, 5309, 24201, 1396, 13565, 1125, 365, 1911, 12, 267, 327, 1503, 302, 482, 453, 14, 221, 961, 365, 282, 2449, 3489, 14729, 370, 24197, 626, 737, 5210, 267, 327, 1373, 1526, 15, 2350, 1031, 365, 16949, 367, 2877, 2552, 14, 267, 291, 14, 2019, 547, 2681, 275, 446, 17, 398, 327, 982, 378, 12, 949, 1771, 14428, 365, 9995, 641, 14, 221, 14969, 370, 2146, 5445, 5423, 1396, 267, 327, 982, 690, 16, 2066, 652, 1159, 314, 2166, 402, 1771, 14428, 14, 267, 291, 14, 894, 14428, 275, 378, 398, 327, 1626, 1625, 59, 890, 1967, 4713, 61, 402, 9672, 28, 2674, 12, 2674, 30, 626, 18917, 267, 327, 314, 3631, 1526, 1478, 367, 1924, 2332, 14, 221, 2332, 1352, 573, 59, 2200, 2681, 61, 365, 267, 327, 314, 11955, 2072, 1817, 367, 2332, 2681, 14, 221, 2104, 790, 2332, 3162, 2681, 12, 1265, 267, 327, 664, 1771, 314, 3631, 1526, 367, 4568, 2332, 503, 603, 37, 2679, 63, 13578, 63, 12299, 14, 267, 327, 267, 327, 961, 365, 1454, 1202, 340, 2332, 11955, 2072, 365, 641, 334, 6777, 652, 365, 701, 849, 680, 267, 291, 14, 2200, 1352, 573, 275, 488, 398, 925, 29503, 314, 17319, 1793, 655, 5337, 282, 6302, 1125, 31, 221, 17507, 4212, 5002, 14, 267, 291, 14, 1786, 6825, 83, 275, 378, 7318, 327, 491, 1438, 540, 15435, 2901, 3177, 334, 7790, 506, 315, 2011, 1174, 909, 370, 5126, 22883, 267, 327, 4413, 590, 315, 4046, 1233, 436, 21125, 909, 9, 520, 8, 4388, 198, 309, 710, 14850, 402, 1006, 10426, 4713, 15, 2474, 365, 370, 1218, 282, 1526, 909, 14, 267, 327, 961, 365, 376, 1256, 1750, 465, 3663, 4713, 1443, 1048, 5561, 269, 323, 370, 267, 327, 1218, 282, 2849, 1526, 14, 221, 2163, 3264, 911, 372, 642, 909, 2410, 267, 327, 4877, 10426, 2332, 8 ]
[ 1441, 17665, 19, 8836, 2559, 624, 199, 199, 3, 5386, 59, 606, 4894, 61, 199, 3, 199, 3, 359, 1918, 298, 15400, 23854, 4894, 937, 199, 3, 1898, 334, 67, 9, 11811, 13, 9300, 5773, 4646, 2235, 82, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 787, 7647, 26, 199, 3, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 259, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 650, 14, 710, 536, 402, 314, 4132, 1443, 440, 506, 1202, 370, 10692, 503, 10016, 7585, 199, 3, 259, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 17632, 1124, 1179, 2281, 891, 2401, 1821, 7168, 1549, 199, 3, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 2990, 199, 3, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 9706, 14, 199, 3, 1621, 4825, 6461, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 199, 3, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 199, 3, 2845, 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, 1634, 199, 3, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 3, 1284, 59, 606, 4894, 61, 199, 199, 646, 984, 199, 646, 6485, 199, 199, 504, 6233, 14, 15358, 423, 4672, 14, 867, 7493, 19, 492, 8836, 63, 1023, 12, 8836, 63, 1023, 63, 495, 199, 504, 6233, 14, 15358, 423, 4672, 14, 867, 7493, 19, 14, 5559, 492, 6186, 63, 14833, 12, 869, 22436, 63, 14833, 12, 9027, 12, 662, 726, 63, 8803, 63, 2711, 12, 29901, 63, 8803, 63, 2711, 199, 504, 6233, 14, 15358, 423, 4672, 14, 867, 7493, 19, 14, 3924, 492, 799, 6862, 15415, 1726, 12, 12481, 10151, 3264, 1726, 12, 12481, 10151, 4709, 1726, 12, 12481, 10151, 26749, 1726, 12, 3091, 2201, 461, 16985, 1726, 12, 662, 285, 590, 6699, 1726, 12, 12481, 10151, 1084, 1726, 12, 12481, 10151, 15953, 1726, 12, 16277, 22236, 1726, 12, 10257, 14428, 4276, 12, 1910, 19361, 3264, 1726, 12, 15626, 3264, 1726, 199, 504, 6233, 14, 15358, 423, 4672, 14, 867, 7493, 19, 14, 4504, 492, 13964, 3264, 12, 9027, 63, 8803, 12, 27885, 63, 8803, 199, 504, 6233, 14, 15358, 423, 4672, 14, 867, 7493, 19, 14, 5819, 492, 663, 12, 9522, 12, 10822, 421, 199, 533, 799, 6862, 1793, 12197, 2223, 8, 785, 304, 272, 408, 272, 710, 663, 402, 1504, 4346, 701, 376, 9006, 17319, 1793, 370, 27159, 1324, 272, 436, 22803, 687, 2552, 5423, 1396, 221, 3709, 282, 7396, 1174, 909, 12, 652, 883, 506, 272, 5709, 16885, 3663, 1999, 596, 4291, 27, 325, 14, 71, 2020, 1380, 1373, 12528, 8925, 4573, 14, 339, 5723, 1504, 787, 4575, 1183, 8917, 1325, 314, 3503, 1174, 7849, 1126, 272, 1798, 365, 17819, 14, 272, 408, 339, 347, 636, 826, 721, 277, 304, 267, 327, 17507, 314, 663, 402, 1526, 2943, 626, 883, 2035, 1263, 2332, 19569, 14, 267, 327, 13894, 486, 3838, 1536, 4751, 14, 267, 291, 14, 21589, 275, 942, 398, 327, 961, 365, 2549, 1380, 781, 1937, 376, 1125, 436, 2544, 9445, 8792, 267, 327, 7838, 282, 1526, 14, 221, 29861, 83, 10152, 402, 1655, 2419, 1373, 1125, 1245, 267, 327, 1126, 1125, 14, 267, 291, 14, 705, 497, 6913, 275, 756, 398, 327, 710, 1478, 1901, 314, 1324, 2547, 2382, 314, 2061, 1125, 8920, 14, 267, 327, 961, 365, 1202, 370, 7981, 15258, 17222, 2382, 376, 1125, 365, 1911, 267, 327, 1325, 949, 1526, 365, 16949, 5309, 24201, 1396, 13565, 1125, 365, 1911, 12, 267, 327, 1503, 302, 482, 453, 14, 221, 961, 365, 282, 2449, 3489, 14729, 370, 24197, 626, 737, 5210, 267, 327, 1373, 1526, 15, 2350, 1031, 365, 16949, 367, 2877, 2552, 14, 267, 291, 14, 2019, 547, 2681, 275, 446, 17, 398, 327, 982, 378, 12, 949, 1771, 14428, 365, 9995, 641, 14, 221, 14969, 370, 2146, 5445, 5423, 1396, 267, 327, 982, 690, 16, 2066, 652, 1159, 314, 2166, 402, 1771, 14428, 14, 267, 291, 14, 894, 14428, 275, 378, 398, 327, 1626, 1625, 59, 890, 1967, 4713, 61, 402, 9672, 28, 2674, 12, 2674, 30, 626, 18917, 267, 327, 314, 3631, 1526, 1478, 367, 1924, 2332, 14, 221, 2332, 1352, 573, 59, 2200, 2681, 61, 365, 267, 327, 314, 11955, 2072, 1817, 367, 2332, 2681, 14, 221, 2104, 790, 2332, 3162, 2681, 12, 1265, 267, 327, 664, 1771, 314, 3631, 1526, 367, 4568, 2332, 503, 603, 37, 2679, 63, 13578, 63, 12299, 14, 267, 327, 267, 327, 961, 365, 1454, 1202, 340, 2332, 11955, 2072, 365, 641, 334, 6777, 652, 365, 701, 849, 680, 267, 291, 14, 2200, 1352, 573, 275, 488, 398, 925, 29503, 314, 17319, 1793, 655, 5337, 282, 6302, 1125, 31, 221, 17507, 4212, 5002, 14, 267, 291, 14, 1786, 6825, 83, 275, 378, 7318, 327, 491, 1438, 540, 15435, 2901, 3177, 334, 7790, 506, 315, 2011, 1174, 909, 370, 5126, 22883, 267, 327, 4413, 590, 315, 4046, 1233, 436, 21125, 909, 9, 520, 8, 4388, 198, 309, 710, 14850, 402, 1006, 10426, 4713, 15, 2474, 365, 370, 1218, 282, 1526, 909, 14, 267, 327, 961, 365, 376, 1256, 1750, 465, 3663, 4713, 1443, 1048, 5561, 269, 323, 370, 267, 327, 1218, 282, 2849, 1526, 14, 221, 2163, 3264, 911, 372, 642, 909, 2410, 267, 327, 4877, 10426, 2332, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
frankyrumple/ope
libs/gluon/contenttype.py
33
30533
#!/usr/bin/env python # -*- coding: utf-8 -*- """ | This file is part of the web2py Web Framework | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html) CONTENT_TYPE dictionary created against freedesktop.org's shared mime info database version 1.1. Deviations from official standards: - .md: application/x-genesis-rom --> text/x-markdown - .png: image/x-apple-ios-png --> image/png Additions: - .load: text/html - .json: application/json - .jsonp: application/jsonp - .pickle: application/python-pickle - .w2p': application/w2p """ __all__ = ['contenttype'] CONTENT_TYPE = { '.123': 'application/vnd.lotus-1-2-3', '.3ds': 'image/x-3ds', '.3g2': 'video/3gpp2', '.3ga': 'video/3gpp', '.3gp': 'video/3gpp', '.3gp2': 'video/3gpp2', '.3gpp': 'video/3gpp', '.3gpp2': 'video/3gpp2', '.602': 'application/x-t602', '.669': 'audio/x-mod', '.7z': 'application/x-7z-compressed', '.a': 'application/x-archive', '.aac': 'audio/aac', '.abw': 'application/x-abiword', '.abw.crashed': 'application/x-abiword', '.abw.gz': 'application/x-abiword', '.ac3': 'audio/ac3', '.ace': 'application/x-ace', '.adb': 'text/x-adasrc', '.ads': 'text/x-adasrc', '.afm': 'application/x-font-afm', '.ag': 'image/x-applix-graphics', '.ai': 'application/illustrator', '.aif': 'audio/x-aiff', '.aifc': 'audio/x-aifc', '.aiff': 'audio/x-aiff', '.aiffc': 'audio/x-aifc', '.al': 'application/x-perl', '.alz': 'application/x-alz', '.amr': 'audio/amr', '.amz': 'audio/x-amzxml', '.ani': 'application/x-navi-animation', '.anim[1-9j]': 'video/x-anim', '.anx': 'application/annodex', '.ape': 'audio/x-ape', '.apk': 'application/vnd.android.package-archive', '.ar': 'application/x-archive', '.arj': 'application/x-arj', '.arw': 'image/x-sony-arw', '.as': 'application/x-applix-spreadsheet', '.asc': 'text/plain', '.asf': 'video/x-ms-asf', '.asp': 'application/x-asp', '.ass': 'text/x-ssa', '.asx': 'audio/x-ms-asx', '.atom': 'application/atom+xml', '.au': 'audio/basic', '.avf': 'video/x-msvideo', '.avi': 'video/x-msvideo', '.aw': 'application/x-applix-word', '.awb': 'audio/amr-wb', '.awk': 'application/x-awk', '.axa': 'audio/annodex', '.axv': 'video/annodex', '.bak': 'application/x-trash', '.bcpio': 'application/x-bcpio', '.bdf': 'application/x-font-bdf', '.bdm': 'video/mp2t', '.bdmv': 'video/mp2t', '.bib': 'text/x-bibtex', '.bin': 'application/octet-stream', '.blend': 'application/x-blender', '.blender': 'application/x-blender', '.bmp': 'image/bmp', '.bz': 'application/x-bzip', '.bz2': 'application/x-bzip', '.c': 'text/x-csrc', '.c++': 'text/x-c++src', '.cab': 'application/vnd.ms-cab-compressed', '.cap': 'application/vnd.tcpdump.pcap', '.cb7': 'application/x-cb7', '.cbl': 'text/x-cobol', '.cbr': 'application/x-cbr', '.cbt': 'application/x-cbt', '.cbz': 'application/x-cbz', '.cc': 'text/x-c++src', '.ccmx': 'application/x-ccmx', '.cdf': 'application/x-netcdf', '.cdr': 'application/vnd.corel-draw', '.cer': 'application/pkix-cert', '.cert': 'application/x-x509-ca-cert', '.cgm': 'image/cgm', '.chm': 'application/vnd.ms-htmlhelp', '.chrt': 'application/x-kchart', '.class': 'application/x-java', '.clpi': 'video/mp2t', '.cls': 'text/x-tex', '.cmake': 'text/x-cmake', '.cob': 'text/x-cobol', '.cpi': 'video/mp2t', '.cpio': 'application/x-cpio', '.cpio.gz': 'application/x-cpio-compressed', '.cpp': 'text/x-c++src', '.cr2': 'image/x-canon-cr2', '.crl': 'application/pkix-crl', '.crt': 'application/x-x509-ca-cert', '.crw': 'image/x-canon-crw', '.cs': 'text/x-csharp', '.csh': 'application/x-csh', '.css': 'text/css', '.cssl': 'text/css', '.csv': 'text/csv', '.cue': 'application/x-cue', '.cur': 'image/x-win-bitmap', '.cxx': 'text/x-c++src', '.d': 'text/x-dsrc', '.dar': 'application/x-dar', '.dbf': 'application/x-dbf', '.dc': 'application/x-dc-rom', '.dcl': 'text/x-dcl', '.dcm': 'application/dicom', '.dcr': 'image/x-kodak-dcr', '.dds': 'image/x-dds', '.deb': 'application/x-deb', '.der': 'application/x-x509-ca-cert', '.desktop': 'application/x-desktop', '.di': 'text/x-dsrc', '.dia': 'application/x-dia-diagram', '.diff': 'text/x-patch', '.divx': 'video/x-msvideo', '.djv': 'image/vnd.djvu', '.djvu': 'image/vnd.djvu', '.dmg': 'application/x-apple-diskimage', '.dmp': 'application/vnd.tcpdump.pcap', '.dng': 'image/x-adobe-dng', '.doc': 'application/msword', '.docbook': 'application/x-docbook+xml', '.docm': 'application/vnd.ms-word.document.macroenabled.12', '.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', '.dot': 'text/vnd.graphviz', '.dotm': 'application/vnd.ms-word.template.macroenabled.12', '.dotx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', '.dsl': 'text/x-dsl', '.dtd': 'application/xml-dtd', '.dts': 'audio/vnd.dts', '.dtshd': 'audio/vnd.dts.hd', '.dtx': 'text/x-tex', '.dv': 'video/dv', '.dvi': 'application/x-dvi', '.dvi.bz2': 'application/x-bzdvi', '.dvi.gz': 'application/x-gzdvi', '.dwg': 'image/vnd.dwg', '.dxf': 'image/vnd.dxf', '.e': 'text/x-eiffel', '.egon': 'application/x-egon', '.eif': 'text/x-eiffel', '.el': 'text/x-emacs-lisp', '.emf': 'image/x-emf', '.eml': 'message/rfc822', '.emp': 'application/vnd.emusic-emusic_package', '.ent': 'application/xml-external-parsed-entity', '.eps': 'image/x-eps', '.eps.bz2': 'image/x-bzeps', '.eps.gz': 'image/x-gzeps', '.epsf': 'image/x-eps', '.epsf.bz2': 'image/x-bzeps', '.epsf.gz': 'image/x-gzeps', '.epsi': 'image/x-eps', '.epsi.bz2': 'image/x-bzeps', '.epsi.gz': 'image/x-gzeps', '.epub': 'application/epub+zip', '.erl': 'text/x-erlang', '.es': 'application/ecmascript', '.etheme': 'application/x-e-theme', '.etx': 'text/x-setext', '.exe': 'application/x-ms-dos-executable', '.exr': 'image/x-exr', '.ez': 'application/andrew-inset', '.f': 'text/x-fortran', '.f4a': 'audio/mp4', '.f4b': 'audio/x-m4b', '.f4v': 'video/mp4', '.f90': 'text/x-fortran', '.f95': 'text/x-fortran', '.fb2': 'application/x-fictionbook+xml', '.fig': 'image/x-xfig', '.fits': 'image/fits', '.fl': 'application/x-fluid', '.flac': 'audio/flac', '.flc': 'video/x-flic', '.fli': 'video/x-flic', '.flv': 'video/x-flv', '.flw': 'application/x-kivio', '.fo': 'text/x-xslfo', '.fodg': 'application/vnd.oasis.opendocument.graphics-flat-xml', '.fodp': 'application/vnd.oasis.opendocument.presentation-flat-xml', '.fods': 'application/vnd.oasis.opendocument.spreadsheet-flat-xml', '.fodt': 'application/vnd.oasis.opendocument.text-flat-xml', '.for': 'text/x-fortran', '.fxm': 'video/x-javafx', '.g3': 'image/fax-g3', '.gb': 'application/x-gameboy-rom', '.gba': 'application/x-gba-rom', '.gcrd': 'text/vcard', '.ged': 'application/x-gedcom', '.gedcom': 'application/x-gedcom', '.gem': 'application/x-tar', '.gen': 'application/x-genesis-rom', '.gf': 'application/x-tex-gf', '.gg': 'application/x-sms-rom', '.gif': 'image/gif', '.glade': 'application/x-glade', '.gml': 'application/gml+xml', '.gmo': 'application/x-gettext-translation', '.gnc': 'application/x-gnucash', '.gnd': 'application/gnunet-directory', '.gnucash': 'application/x-gnucash', '.gnumeric': 'application/x-gnumeric', '.gnuplot': 'application/x-gnuplot', '.go': 'text/x-go', '.gp': 'application/x-gnuplot', '.gpg': 'application/pgp-encrypted', '.gplt': 'application/x-gnuplot', '.gra': 'application/x-graphite', '.gsf': 'application/x-font-type1', '.gsm': 'audio/x-gsm', '.gtar': 'application/x-tar', '.gv': 'text/vnd.graphviz', '.gvp': 'text/x-google-video-pointer', '.gz': 'application/gzip', '.h': 'text/x-chdr', '.h++': 'text/x-c++hdr', '.h4': 'application/x-hdf', '.h5': 'application/x-hdf', '.hdf': 'application/x-hdf', '.hdf4': 'application/x-hdf', '.hdf5': 'application/x-hdf', '.hh': 'text/x-c++hdr', '.hlp': 'application/winhlp', '.hp': 'text/x-c++hdr', '.hpgl': 'application/vnd.hp-hpgl', '.hpp': 'text/x-c++hdr', '.hs': 'text/x-haskell', '.htm': 'text/html', '.html': 'text/html', '.hwp': 'application/x-hwp', '.hwt': 'application/x-hwt', '.hxx': 'text/x-c++hdr', '.ica': 'application/x-ica', '.icb': 'image/x-tga', '.icc': 'application/vnd.iccprofile', '.icm': 'application/vnd.iccprofile', '.icns': 'image/x-icns', '.ico': 'image/vnd.microsoft.icon', '.ics': 'text/calendar', '.idl': 'text/x-idl', '.ief': 'image/ief', '.iff': 'image/x-ilbm', '.ilbm': 'image/x-ilbm', '.ime': 'text/x-imelody', '.imy': 'text/x-imelody', '.ins': 'text/x-tex', '.iptables': 'text/x-iptables', '.iso': 'application/x-cd-image', '.iso9660': 'application/x-cd-image', '.it': 'audio/x-it', '.it87': 'application/x-it87', '.j2k': 'image/jp2', '.jad': 'text/vnd.sun.j2me.app-descriptor', '.jar': 'application/x-java-archive', '.java': 'text/x-java', '.jceks': 'application/x-java-jce-keystore', '.jks': 'application/x-java-keystore', '.jng': 'image/x-jng', '.jnlp': 'application/x-java-jnlp-file', '.jp2': 'image/jp2', '.jpc': 'image/jp2', '.jpe': 'image/jpeg', '.jpeg': 'image/jpeg', '.jpf': 'image/jp2', '.jpg': 'image/jpeg', '.jpr': 'application/x-jbuilder-project', '.jpx': 'image/jp2', '.js': 'application/javascript', '.json': 'application/json', '.jsonp': 'application/jsonp', '.k25': 'image/x-kodak-k25', '.kar': 'audio/midi', '.karbon': 'application/x-karbon', '.kdc': 'image/x-kodak-kdc', '.kdelnk': 'application/x-desktop', '.kexi': 'application/x-kexiproject-sqlite3', '.kexic': 'application/x-kexi-connectiondata', '.kexis': 'application/x-kexiproject-shortcut', '.kfo': 'application/x-kformula', '.kil': 'application/x-killustrator', '.kino': 'application/smil', '.kml': 'application/vnd.google-earth.kml+xml', '.kmz': 'application/vnd.google-earth.kmz', '.kon': 'application/x-kontour', '.kpm': 'application/x-kpovmodeler', '.kpr': 'application/x-kpresenter', '.kpt': 'application/x-kpresenter', '.kra': 'application/x-krita', '.ks': 'application/x-java-keystore', '.ksp': 'application/x-kspread', '.kud': 'application/x-kugar', '.kwd': 'application/x-kword', '.kwt': 'application/x-kword', '.la': 'application/x-shared-library-la', '.latex': 'text/x-tex', '.lbm': 'image/x-ilbm', '.ldif': 'text/x-ldif', '.lha': 'application/x-lha', '.lhs': 'text/x-literate-haskell', '.lhz': 'application/x-lhz', '.load' : 'text/html', '.log': 'text/x-log', '.lrz': 'application/x-lrzip', '.ltx': 'text/x-tex', '.lua': 'text/x-lua', '.lwo': 'image/x-lwo', '.lwob': 'image/x-lwo', '.lwp': 'application/vnd.lotus-wordpro', '.lws': 'image/x-lws', '.ly': 'text/x-lilypond', '.lyx': 'application/x-lyx', '.lz': 'application/x-lzip', '.lzh': 'application/x-lha', '.lzma': 'application/x-lzma', '.lzo': 'application/x-lzop', '.m': 'text/x-matlab', '.m15': 'audio/x-mod', '.m1u': 'video/vnd.mpegurl', '.m2t': 'video/mp2t', '.m2ts': 'video/mp2t', '.m3u': 'application/vnd.apple.mpegurl', '.m3u8': 'application/vnd.apple.mpegurl', '.m4': 'application/x-m4', '.m4a': 'audio/mp4', '.m4b': 'audio/x-m4b', '.m4u': 'video/vnd.mpegurl', '.m4v': 'video/mp4', '.mab': 'application/x-markaby', '.mak': 'text/x-makefile', '.man': 'application/x-troff-man', '.manifest': 'text/cache-manifest', '.markdown': 'text/x-markdown', '.mbox': 'application/mbox', '.md': 'text/x-markdown', '.mdb': 'application/vnd.ms-access', '.mdi': 'image/vnd.ms-modi', '.me': 'text/x-troff-me', '.med': 'audio/x-mod', '.meta4': 'application/metalink4+xml', '.metalink': 'application/metalink+xml', '.mgp': 'application/x-magicpoint', '.mht': 'application/x-mimearchive', '.mhtml': 'application/x-mimearchive', '.mid': 'audio/midi', '.midi': 'audio/midi', '.mif': 'application/x-mif', '.minipsf': 'audio/x-minipsf', '.mk': 'text/x-makefile', '.mka': 'audio/x-matroska', '.mkd': 'text/x-markdown', '.mkv': 'video/x-matroska', '.ml': 'text/x-ocaml', '.mli': 'text/x-ocaml', '.mm': 'text/x-troff-mm', '.mmf': 'application/x-smaf', '.mml': 'application/mathml+xml', '.mng': 'video/x-mng', '.mo': 'text/x-modelica', '.mo3': 'audio/x-mo3', '.mobi': 'application/x-mobipocket-ebook', '.moc': 'text/x-moc', '.mod': 'audio/x-mod', '.mof': 'text/x-mof', '.moov': 'video/quicktime', '.mov': 'video/quicktime', '.movie': 'video/x-sgi-movie', '.mp+': 'audio/x-musepack', '.mp2': 'video/mpeg', '.mp3': 'audio/mpeg', '.mp4': 'video/mp4', '.mpc': 'audio/x-musepack', '.mpe': 'video/mpeg', '.mpeg': 'video/mpeg', '.mpg': 'video/mpeg', '.mpga': 'audio/mpeg', '.mpl': 'video/mp2t', '.mpls': 'video/mp2t', '.mpp': 'audio/x-musepack', '.mrl': 'text/x-mrml', '.mrml': 'text/x-mrml', '.mrw': 'image/x-minolta-mrw', '.ms': 'text/x-troff-ms', '.msi': 'application/x-msi', '.msod': 'image/x-msod', '.msx': 'application/x-msx-rom', '.mtm': 'audio/x-mod', '.mts': 'video/mp2t', '.mup': 'text/x-mup', '.mxf': 'application/mxf', '.mxu': 'video/vnd.mpegurl', '.n64': 'application/x-n64-rom', '.nb': 'application/mathematica', '.nc': 'application/x-netcdf', '.nds': 'application/x-nintendo-ds-rom', '.nef': 'image/x-nikon-nef', '.nes': 'application/x-nes-rom', '.nfo': 'text/x-nfo', '.not': 'text/x-mup', '.nsc': 'application/x-netshow-channel', '.nsv': 'video/x-nsv', '.nzb': 'application/x-nzb', '.o': 'application/x-object', '.obj': 'application/x-tgif', '.ocl': 'text/x-ocl', '.oda': 'application/oda', '.odb': 'application/vnd.oasis.opendocument.database', '.odc': 'application/vnd.oasis.opendocument.chart', '.odf': 'application/vnd.oasis.opendocument.formula', '.odg': 'application/vnd.oasis.opendocument.graphics', '.odi': 'application/vnd.oasis.opendocument.image', '.odm': 'application/vnd.oasis.opendocument.text-master', '.odp': 'application/vnd.oasis.opendocument.presentation', '.ods': 'application/vnd.oasis.opendocument.spreadsheet', '.odt': 'application/vnd.oasis.opendocument.text', '.oga': 'audio/ogg', '.ogg': 'application/ogg', '.ogm': 'video/x-ogm+ogg', '.ogv': 'video/ogg', '.ogx': 'application/ogg', '.old': 'application/x-trash', '.oleo': 'application/x-oleo', '.ooc': 'text/x-ooc', '.opml': 'text/x-opml+xml', '.oprc': 'application/vnd.palm', '.ora': 'image/openraster', '.orf': 'image/x-olympus-orf', '.otc': 'application/vnd.oasis.opendocument.chart-template', '.otf': 'application/x-font-otf', '.otg': 'application/vnd.oasis.opendocument.graphics-template', '.oth': 'application/vnd.oasis.opendocument.text-web', '.otp': 'application/vnd.oasis.opendocument.presentation-template', '.ots': 'application/vnd.oasis.opendocument.spreadsheet-template', '.ott': 'application/vnd.oasis.opendocument.text-template', '.owl': 'application/rdf+xml', '.oxps': 'application/oxps', '.oxt': 'application/vnd.openofficeorg.extension', '.p': 'text/x-pascal', '.p10': 'application/pkcs10', '.p12': 'application/x-pkcs12', '.p7b': 'application/x-pkcs7-certificates', '.p7c': 'application/pkcs7-mime', '.p7m': 'application/pkcs7-mime', '.p7s': 'application/pkcs7-signature', '.p8': 'application/pkcs8', '.pack': 'application/x-java-pack200', '.pak': 'application/x-pak', '.par2': 'application/x-par2', '.pas': 'text/x-pascal', '.patch': 'text/x-patch', '.pbm': 'image/x-portable-bitmap', '.pcap': 'application/vnd.tcpdump.pcap', '.pcd': 'image/x-photo-cd', '.pcf': 'application/x-cisco-vpn-settings', '.pcf.gz': 'application/x-font-pcf', '.pcf.z': 'application/x-font-pcf', '.pcl': 'application/vnd.hp-pcl', '.pct': 'image/x-pict', '.pcx': 'image/x-pcx', '.pdb': 'chemical/x-pdb', '.pdc': 'application/x-aportisdoc', '.pdf': 'application/pdf', '.pdf.bz2': 'application/x-bzpdf', '.pdf.gz': 'application/x-gzpdf', '.pdf.xz': 'application/x-xzpdf', '.pef': 'image/x-pentax-pef', '.pem': 'application/x-x509-ca-cert', '.perl': 'application/x-perl', '.pfa': 'application/x-font-type1', '.pfb': 'application/x-font-type1', '.pfx': 'application/x-pkcs12', '.pgm': 'image/x-portable-graymap', '.pgn': 'application/x-chess-pgn', '.pgp': 'application/pgp-encrypted', '.php': 'application/x-php', '.php3': 'application/x-php', '.php4': 'application/x-php', '.php5': 'application/x-php', '.phps': 'application/x-php', '.pict': 'image/x-pict', '.pict1': 'image/x-pict', '.pict2': 'image/x-pict', '.pk': 'application/x-tex-pk', '.pkipath': 'application/pkix-pkipath', '.pkr': 'application/pgp-keys', '.pl': 'application/x-perl', '.pla': 'audio/x-iriver-pla', '.pln': 'application/x-planperfect', '.pls': 'audio/x-scpls', '.pm': 'application/x-perl', '.png': 'image/png', '.pnm': 'image/x-portable-anymap', '.pntg': 'image/x-macpaint', '.po': 'text/x-gettext-translation', '.por': 'application/x-spss-por', '.pot': 'text/x-gettext-translation-template', '.potm': 'application/vnd.ms-powerpoint.template.macroenabled.12', '.potx': 'application/vnd.openxmlformats-officedocument.presentationml.template', '.ppam': 'application/vnd.ms-powerpoint.addin.macroenabled.12', '.ppm': 'image/x-portable-pixmap', '.pps': 'application/vnd.ms-powerpoint', '.ppsm': 'application/vnd.ms-powerpoint.slideshow.macroenabled.12', '.ppsx': 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', '.ppt': 'application/vnd.ms-powerpoint', '.pptm': 'application/vnd.ms-powerpoint.presentation.macroenabled.12', '.pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation', '.ppz': 'application/vnd.ms-powerpoint', '.pqa': 'application/vnd.palm', '.prc': 'application/vnd.palm', '.ps': 'application/postscript', '.ps.bz2': 'application/x-bzpostscript', '.ps.gz': 'application/x-gzpostscript', '.psd': 'image/vnd.adobe.photoshop', '.psf': 'audio/x-psf', '.psf.gz': 'application/x-gz-font-linux-psf', '.psflib': 'audio/x-psflib', '.psid': 'audio/prs.sid', '.psw': 'application/x-pocket-word', '.pw': 'application/x-pw', '.py': 'text/x-python', '.pyc': 'application/x-python-bytecode', '.pickle': 'application/python-pickle', '.pyo': 'application/x-python-bytecode', '.qif': 'image/x-quicktime', '.qml': 'text/x-qml', '.qt': 'video/quicktime', '.qti': 'application/x-qtiplot', '.qti.gz': 'application/x-qtiplot', '.qtif': 'image/x-quicktime', '.qtl': 'application/x-quicktime-media-link', '.qtvr': 'video/quicktime', '.ra': 'audio/vnd.rn-realaudio', '.raf': 'image/x-fuji-raf', '.ram': 'application/ram', '.rar': 'application/x-rar', '.ras': 'image/x-cmu-raster', '.raw': 'image/x-panasonic-raw', '.rax': 'audio/vnd.rn-realaudio', '.rb': 'application/x-ruby', '.rdf': 'application/rdf+xml', '.rdfs': 'application/rdf+xml', '.reg': 'text/x-ms-regedit', '.rej': 'text/x-reject', '.rgb': 'image/x-rgb', '.rle': 'image/rle', '.rm': 'application/vnd.rn-realmedia', '.rmj': 'application/vnd.rn-realmedia', '.rmm': 'application/vnd.rn-realmedia', '.rms': 'application/vnd.rn-realmedia', '.rmvb': 'application/vnd.rn-realmedia', '.rmx': 'application/vnd.rn-realmedia', '.rnc': 'application/relax-ng-compact-syntax', '.rng': 'application/xml', '.roff': 'text/troff', '.rp': 'image/vnd.rn-realpix', '.rpm': 'application/x-rpm', '.rss': 'application/rss+xml', '.rt': 'text/vnd.rn-realtext', '.rtf': 'application/rtf', '.rtx': 'text/richtext', '.rv': 'video/vnd.rn-realvideo', '.rvx': 'video/vnd.rn-realvideo', '.rw2': 'image/x-panasonic-raw2', '.s3m': 'audio/x-s3m', '.sam': 'application/x-amipro', '.sami': 'application/x-sami', '.sav': 'application/x-spss-sav', '.scala': 'text/x-scala', '.scm': 'text/x-scheme', '.sda': 'application/vnd.stardivision.draw', '.sdc': 'application/vnd.stardivision.calc', '.sdd': 'application/vnd.stardivision.impress', '.sdp': 'application/sdp', '.sds': 'application/vnd.stardivision.chart', '.sdw': 'application/vnd.stardivision.writer', '.sgf': 'application/x-go-sgf', '.sgi': 'image/x-sgi', '.sgl': 'application/vnd.stardivision.writer', '.sgm': 'text/sgml', '.sgml': 'text/sgml', '.sh': 'application/x-shellscript', '.shape': 'application/x-dia-shape', '.shar': 'application/x-shar', '.shn': 'application/x-shorten', '.siag': 'application/x-siag', '.sid': 'audio/prs.sid', '.sik': 'application/x-trash', '.sis': 'application/vnd.symbian.install', '.sisx': 'x-epoc/x-sisx-app', '.sit': 'application/x-stuffit', '.siv': 'application/sieve', '.sk': 'image/x-skencil', '.sk1': 'image/x-skencil', '.skr': 'application/pgp-keys', '.sldm': 'application/vnd.ms-powerpoint.slide.macroenabled.12', '.sldx': 'application/vnd.openxmlformats-officedocument.presentationml.slide', '.slk': 'text/spreadsheet', '.smaf': 'application/x-smaf', '.smc': 'application/x-snes-rom', '.smd': 'application/vnd.stardivision.mail', '.smf': 'application/vnd.stardivision.math', '.smi': 'application/x-sami', '.smil': 'application/smil', '.sml': 'application/smil', '.sms': 'application/x-sms-rom', '.snd': 'audio/basic', '.so': 'application/x-sharedlib', '.spc': 'application/x-pkcs7-certificates', '.spd': 'application/x-font-speedo', '.spec': 'text/x-rpm-spec', '.spl': 'application/x-shockwave-flash', '.spm': 'application/x-source-rpm', '.spx': 'audio/x-speex', '.sql': 'text/x-sql', '.sr2': 'image/x-sony-sr2', '.src': 'application/x-wais-source', '.src.rpm': 'application/x-source-rpm', '.srf': 'image/x-sony-srf', '.srt': 'application/x-subrip', '.ss': 'text/x-scheme', '.ssa': 'text/x-ssa', '.stc': 'application/vnd.sun.xml.calc.template', '.std': 'application/vnd.sun.xml.draw.template', '.sti': 'application/vnd.sun.xml.impress.template', '.stm': 'audio/x-stm', '.stw': 'application/vnd.sun.xml.writer.template', '.sty': 'text/x-tex', '.sub': 'text/x-subviewer', '.sun': 'image/x-sun-raster', '.sv': 'text/x-svsrc', '.sv4cpio': 'application/x-sv4cpio', '.sv4crc': 'application/x-sv4crc', '.svg': 'image/svg+xml', '.svgz': 'image/svg+xml-compressed', '.svh': 'text/x-svhdr', '.swf': 'application/x-shockwave-flash', '.swm': 'application/x-ms-wim', '.sxc': 'application/vnd.sun.xml.calc', '.sxd': 'application/vnd.sun.xml.draw', '.sxg': 'application/vnd.sun.xml.writer.global', '.sxi': 'application/vnd.sun.xml.impress', '.sxm': 'application/vnd.sun.xml.math', '.sxw': 'application/vnd.sun.xml.writer', '.sylk': 'text/spreadsheet', '.t': 'text/troff', '.t2t': 'text/x-txt2tags', '.tar': 'application/x-tar', '.tar.bz': 'application/x-bzip-compressed-tar', '.tar.bz2': 'application/x-bzip-compressed-tar', '.tar.gz': 'application/x-compressed-tar', '.tar.lrz': 'application/x-lrzip-compressed-tar', '.tar.lzma': 'application/x-lzma-compressed-tar', '.tar.lzo': 'application/x-tzo', '.tar.xz': 'application/x-xz-compressed-tar', '.tar.z': 'application/x-tarz', '.taz': 'application/x-tarz', '.tb2': 'application/x-bzip-compressed-tar', '.tbz': 'application/x-bzip-compressed-tar', '.tbz2': 'application/x-bzip-compressed-tar', '.tcl': 'text/x-tcl', '.tex': 'text/x-tex', '.texi': 'text/x-texinfo', '.texinfo': 'text/x-texinfo', '.tga': 'image/x-tga', '.tgz': 'application/x-compressed-tar', '.theme': 'application/x-theme', '.themepack': 'application/x-windows-themepack', '.tif': 'image/tiff', '.tiff': 'image/tiff', '.tk': 'text/x-tcl', '.tlrz': 'application/x-lrzip-compressed-tar', '.tlz': 'application/x-lzma-compressed-tar', '.tnef': 'application/vnd.ms-tnef', '.tnf': 'application/vnd.ms-tnef', '.toc': 'application/x-cdrdao-toc', '.torrent': 'application/x-bittorrent', '.tpic': 'image/x-tga', '.tr': 'text/troff', '.ts': 'video/mp2t', '.tsv': 'text/tab-separated-values', '.tta': 'audio/x-tta', '.ttc': 'application/x-font-ttf', '.ttf': 'application/x-font-ttf', '.ttx': 'application/x-font-ttx', '.txt': 'text/plain', '.txz': 'application/x-xz-compressed-tar', '.tzo': 'application/x-tzo', '.ufraw': 'application/x-ufraw', '.ui': 'application/x-gtk-builder', '.uil': 'text/x-uil', '.ult': 'audio/x-mod', '.uni': 'audio/x-mod', '.url': 'application/x-mswinurl', '.ustar': 'application/x-ustar', '.uue': 'text/x-uuencode', '.v': 'text/x-verilog', '.vala': 'text/x-vala', '.vapi': 'text/x-vala', '.vcard': 'text/vcard', '.vcf': 'text/vcard', '.vcs': 'text/calendar', '.vct': 'text/vcard', '.vda': 'image/x-tga', '.vhd': 'text/x-vhdl', '.vhdl': 'text/x-vhdl', '.viv': 'video/vivo', '.vivo': 'video/vivo', '.vlc': 'audio/x-mpegurl', '.vob': 'video/mpeg', '.voc': 'audio/x-voc', '.vor': 'application/vnd.stardivision.writer', '.vrm': 'model/vrml', '.vrml': 'model/vrml', '.vsd': 'application/vnd.visio', '.vss': 'application/vnd.visio', '.vst': 'image/x-tga', '.vsw': 'application/vnd.visio', '.vtt': 'text/vtt', '.w2p': 'application/w2p', '.wav': 'audio/x-wav', '.wax': 'audio/x-ms-asx', '.wb1': 'application/x-quattropro', '.wb2': 'application/x-quattropro', '.wb3': 'application/x-quattropro', '.wbmp': 'image/vnd.wap.wbmp', '.wcm': 'application/vnd.ms-works', '.wdb': 'application/vnd.ms-works', '.webm': 'video/webm', '.wim': 'application/x-ms-wim', '.wk1': 'application/vnd.lotus-1-2-3', '.wk3': 'application/vnd.lotus-1-2-3', '.wk4': 'application/vnd.lotus-1-2-3', '.wks': 'application/vnd.ms-works', '.wma': 'audio/x-ms-wma', '.wmf': 'image/x-wmf', '.wml': 'text/vnd.wap.wml', '.wmls': 'text/vnd.wap.wmlscript', '.wmv': 'video/x-ms-wmv', '.wmx': 'audio/x-ms-asx', '.woff': 'application/font-woff', '.wp': 'application/vnd.wordperfect', '.wp4': 'application/vnd.wordperfect', '.wp5': 'application/vnd.wordperfect', '.wp6': 'application/vnd.wordperfect', '.wpd': 'application/vnd.wordperfect', '.wpg': 'application/x-wpg', '.wpl': 'application/vnd.ms-wpl', '.wpp': 'application/vnd.wordperfect', '.wps': 'application/vnd.ms-works', '.wri': 'application/x-mswrite', '.wrl': 'model/vrml', '.wsgi': 'text/x-python', '.wv': 'audio/x-wavpack', '.wvc': 'audio/x-wavpack-correction', '.wvp': 'audio/x-wavpack', '.wvx': 'audio/x-ms-asx', '.wwf': 'application/x-wwf', '.x3f': 'image/x-sigma-x3f', '.xac': 'application/x-gnucash', '.xbel': 'application/x-xbel', '.xbl': 'application/xml', '.xbm': 'image/x-xbitmap', '.xcf': 'image/x-xcf', '.xcf.bz2': 'image/x-compressed-xcf', '.xcf.gz': 'image/x-compressed-xcf', '.xhtml': 'application/xhtml+xml', '.xi': 'audio/x-xi', '.xla': 'application/vnd.ms-excel', '.xlam': 'application/vnd.ms-excel.addin.macroenabled.12', '.xlc': 'application/vnd.ms-excel', '.xld': 'application/vnd.ms-excel', '.xlf': 'application/x-xliff', '.xliff': 'application/x-xliff', '.xll': 'application/vnd.ms-excel', '.xlm': 'application/vnd.ms-excel', '.xlr': 'application/vnd.ms-works', '.xls': 'application/vnd.ms-excel', '.xlsb': 'application/vnd.ms-excel.sheet.binary.macroenabled.12', '.xlsm': 'application/vnd.ms-excel.sheet.macroenabled.12', '.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', '.xlt': 'application/vnd.ms-excel', '.xltm': 'application/vnd.ms-excel.template.macroenabled.12', '.xltx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', '.xlw': 'application/vnd.ms-excel', '.xm': 'audio/x-xm', '.xmf': 'audio/x-xmf', '.xmi': 'text/x-xmi', '.xml': 'application/xml', '.xpi': 'application/x-xpinstall', '.xpm': 'image/x-xpixmap', '.xps': 'application/oxps', '.xsd': 'application/xml', '.xsl': 'application/xslt+xml', '.xslfo': 'text/x-xslfo', '.xslm' : 'application/vnd.ms-excel.sheet.macroEnabled.12', '.xslt': 'application/xslt+xml', '.xspf': 'application/xspf+xml', '.xul': 'application/vnd.mozilla.xul+xml', '.xwd': 'image/x-xwindowdump', '.xyz': 'chemical/x-pdb', '.xz': 'application/x-xz', '.yaml': 'application/x-yaml', '.yml': 'application/x-yaml', '.z': 'application/x-compress', '.zabw': 'application/x-abiword', '.zip': 'application/zip', '.zoo': 'application/x-zoo', } def contenttype(filename, default='text/plain'): """ Returns the Content-Type string matching extension of the given filename. """ i = filename.rfind('.') if i >= 0: default = CONTENT_TYPE.get(filename[i:].lower(), default) j = filename.rfind('.', 0, i) if j >= 0: default = CONTENT_TYPE.get(filename[j:].lower(), default) if default.startswith('text/'): default += '; charset=utf-8' return default
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 92, 961, 570, 365, 1777, 402, 314, 3330, 18, 647, 6001, 22545, 199, 92, 11247, 31816, 471, 701, 603, 2608, 573, 3757, 510, 4446, 293, 665, 20208, 1038, 281, 293, 32, 1259, 14, 271, 387, 348, 14, 8654, 30, 199, 92, 844, 26, 491, 28863, 19, 334, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 14, 1360, 9, 199, 199, 9663, 63, 2711, 2600, 2737, 6169, 2867, 14487, 14, 1308, 1159, 5709, 6660, 2256, 199, 4659, 1015, 413, 14, 17, 14, 199, 199, 872, 433, 1298, 687, 25410, 10584, 5596, 26, 199, 446, 1275, 1064, 26, 4223, 15, 88, 13, 10654, 2316, 13, 417, 10541, 1318, 15, 88, 13, 15653, 199, 446, 1275, 4524, 26, 1834, 15, 88, 13, 12820, 13, 9207, 13, 4524, 10541, 1834, 15, 4524, 199, 2767, 3138, 26, 199, 446, 1275, 912, 26, 1318, 15, 1360, 199, 446, 1275, 1001, 26, 4223, 15, 1001, 199, 446, 1275, 1001, 80, 26, 4223, 15, 1001, 80, 199, 446, 1275, 8092, 26, 4223, 15, 1548, 13, 8092, 199, 446, 1275, 87, 18, 80, 356, 4223, 15, 87, 18, 80, 199, 624, 199, 199, 363, 452, 363, 275, 788, 20735, 418, 199, 199, 9663, 63, 2711, 275, 469, 272, 1987, 4288, 356, 283, 3578, 15, 26379, 14, 1653, 527, 13, 17, 13, 18, 13, 19, 297, 272, 1987, 19, 795, 356, 283, 1569, 15, 88, 13, 19, 795, 297, 272, 1987, 19, 71, 18, 356, 283, 3722, 15, 19, 71, 802, 18, 297, 272, 1987, 19, 5294, 356, 283, 3722, 15, 19, 71, 802, 297, 272, 1987, 19, 4927, 356, 283, 3722, 15, 19, 71, 802, 297, 272, 1987, 19, 4927, 18, 356, 283, 3722, 15, 19, 71, 802, 18, 297, 272, 1987, 19, 71, 802, 356, 283, 3722, 15, 19, 71, 802, 297, 272, 1987, 19, 71, 802, 18, 356, 283, 3722, 15, 19, 71, 802, 18, 297, 272, 1987, 28384, 356, 283, 3578, 15, 88, 13, 84, 28384, 297, 272, 1987, 15014, 356, 283, 8130, 15, 88, 13, 1494, 297, 272, 1987, 23, 90, 356, 283, 3578, 15, 88, 13, 23, 90, 13, 10895, 297, 272, 1987, 65, 356, 283, 3578, 15, 88, 13, 6404, 297, 272, 1987, 27538, 356, 283, 8130, 15, 27538, 297, 272, 1987, 371, 87, 356, 283, 3578, 15, 88, 13, 14677, 1027, 297, 272, 1987, 371, 87, 14, 14807, 379, 356, 283, 3578, 15, 88, 13, 14677, 1027, 297, 272, 1987, 371, 87, 14, 6838, 356, 283, 3578, 15, 88, 13, 14677, 1027, 297, 272, 1987, 645, 19, 356, 283, 8130, 15, 645, 19, 297, 272, 1987, 7984, 356, 283, 3578, 15, 88, 13, 7984, 297, 272, 1987, 13741, 356, 283, 505, 15, 88, 13, 350, 305, 1195, 297, 272, 1987, 9402, 356, 283, 505, 15, 88, 13, 350, 305, 1195, 297, 272, 1987, 2756, 77, 356, 283, 3578, 15, 88, 13, 4246, 13, 2756, 77, 297, 272, 1987, 643, 356, 283, 1569, 15, 88, 13, 571, 20528, 13, 15707, 297, 272, 1987, 5789, 356, 283, 3578, 15, 778, 11409, 707, 297, 272, 1987, 65, 692, 356, 283, 8130, 15, 88, 13, 5789, 556, 297, 272, 1987, 65, 25040, 356, 283, 8130, 15, 88, 13, 65, 25040, 297, 272, 1987, 5789, 556, 356, 283, 8130, 15, 88, 13, 5789, 556, 297, 272, 1987, 5789, 26299, 356, 283, 8130, 15, 88, 13, 65, 25040, 297, 272, 1987, 279, 356, 283, 3578, 15, 88, 13, 22805, 297, 272, 1987, 279, 90, 356, 283, 3578, 15, 88, 13, 279, 90, 297, 272, 1987, 455, 82, 356, 283, 8130, 15, 455, 82, 297, 272, 1987, 455, 90, 356, 283, 8130, 15, 88, 13, 455, 90, 1652, 297, 272, 1987, 26455, 356, 283, 3578, 15, 88, 13, 15595, 13, 22228, 297, 272, 1987, 22019, 59, 17, 13, 25, 74, 61, 356, 283, 3722, 15, 88, 13, 22019, 297, 272, 1987, 290, 88, 356, 283, 3578, 15, 290, 932, 88, 297, 272, 1987, 924, 356, 283, 8130, 15, 88, 13, 924, 297, 272, 1987, 23582, 356, 283, 3578, 15, 26379, 14, 6238, 14, 2491, 13, 6404, 297, 272, 1987, 285, 356, 283, 3578, 15, 88, 13, 6404, 297, 272, 1987, 285, 74, 356, 283, 3578, 15, 88, 13, 285, 74, 297, 272, 1987, 285, 87, 356, 283, 1569, 15, 88, 13, 834, 89, 13, 285, 87, 297, 272, 1987, 305, 356, 283, 3578, 15, 88, 13, 571, 20528, 13, 19930, 297, 272, 1987, 10125, 356, 283, 505, 15, 6104, 297, 272, 1987, 29551, 356, 283, 3722, 15, 88, 13, 706, 13, 29551, 297, 272, 1987, 20222, 356, 283, 3578, 15, 88, 13, 20222, 297, 272, 1987, 405, 356, 283, 505, 15, 88, 13, 28023, 297, 272, 1987, 305, 88, 356, 283, 8130, 15, 88, 13, 706, 13, 305, 88, 297, 272, 1987, 4188, 356, 283, 3578, 15, 4188, 11, 1652, 297, 272, 1987, 3844, 356, 283, 8130, 15, 4316, 297, 272, 1987, 1214, 70, 356, 283, 3722, 15, 88, 13, 706, 3722, 297, 272, 1987, 7194, 356, 283, 3722, 15, 88, 13, 706, 3722, 297, 272, 1987, 10084, 356, 283, 3578, 15, 88, 13, 571, 20528, 13, 1027, 297, 272, 1987, 65, 6603, 356, 283, 8130, 15, 455, 82, 13, 6603, 297, 272, 1987, 10084, 75, 356, 283, 3578, 15, 88, 13, 10084, 75, 297, 272, 1987, 1219, 65, 356, 283, 8130, 15, 290, 932, 88, 297, 272, 1987, 1219, 86, 356, 283, 3722, 15, 290, 932, 88, 297, 272, 1987, 27162, 356, 283, 3578, 15, 88, 13, 28272, 297, 272, 1987, 3776, 13937, 356, 283, 3578, 15, 88, 13, 3776, 13937, 297, 272, 1987, 66, 1587, 356, 283, 3578, 15, 88, 13, 4246, 13, 66, 1587, 297, 272, 1987, 21520, 356, 283, 3722, 15, 311, 18, 84, 297, 272, 1987, 3691, 12393, 356, 283, 3722, 15, 311, 18, 84, 297, 272, 1987, 8804, 356, 283, 505, 15, 88, 13, 8804, 3858, 297, 272, 1987, 1393, 356, 283, 3578, 15, 18162, 13, 1745, 297, 272, 1987, 27163, 356, 283, 3578, 15, 88, 13, 66, 24912, 297, 272, 1987, 66, 24912, 356, 283, 3578, 15, 88, 13, 66, 24912, 297 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 92, 961, 570, 365, 1777, 402, 314, 3330, 18, 647, 6001, 22545, 199, 92, 11247, 31816, 471, 701, 603, 2608, 573, 3757, 510, 4446, 293, 665, 20208, 1038, 281, 293, 32, 1259, 14, 271, 387, 348, 14, 8654, 30, 199, 92, 844, 26, 491, 28863, 19, 334, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 14, 1360, 9, 199, 199, 9663, 63, 2711, 2600, 2737, 6169, 2867, 14487, 14, 1308, 1159, 5709, 6660, 2256, 199, 4659, 1015, 413, 14, 17, 14, 199, 199, 872, 433, 1298, 687, 25410, 10584, 5596, 26, 199, 446, 1275, 1064, 26, 4223, 15, 88, 13, 10654, 2316, 13, 417, 10541, 1318, 15, 88, 13, 15653, 199, 446, 1275, 4524, 26, 1834, 15, 88, 13, 12820, 13, 9207, 13, 4524, 10541, 1834, 15, 4524, 199, 2767, 3138, 26, 199, 446, 1275, 912, 26, 1318, 15, 1360, 199, 446, 1275, 1001, 26, 4223, 15, 1001, 199, 446, 1275, 1001, 80, 26, 4223, 15, 1001, 80, 199, 446, 1275, 8092, 26, 4223, 15, 1548, 13, 8092, 199, 446, 1275, 87, 18, 80, 356, 4223, 15, 87, 18, 80, 199, 624, 199, 199, 363, 452, 363, 275, 788, 20735, 418, 199, 199, 9663, 63, 2711, 275, 469, 272, 1987, 4288, 356, 283, 3578, 15, 26379, 14, 1653, 527, 13, 17, 13, 18, 13, 19, 297, 272, 1987, 19, 795, 356, 283, 1569, 15, 88, 13, 19, 795, 297, 272, 1987, 19, 71, 18, 356, 283, 3722, 15, 19, 71, 802, 18, 297, 272, 1987, 19, 5294, 356, 283, 3722, 15, 19, 71, 802, 297, 272, 1987, 19, 4927, 356, 283, 3722, 15, 19, 71, 802, 297, 272, 1987, 19, 4927, 18, 356, 283, 3722, 15, 19, 71, 802, 18, 297, 272, 1987, 19, 71, 802, 356, 283, 3722, 15, 19, 71, 802, 297, 272, 1987, 19, 71, 802, 18, 356, 283, 3722, 15, 19, 71, 802, 18, 297, 272, 1987, 28384, 356, 283, 3578, 15, 88, 13, 84, 28384, 297, 272, 1987, 15014, 356, 283, 8130, 15, 88, 13, 1494, 297, 272, 1987, 23, 90, 356, 283, 3578, 15, 88, 13, 23, 90, 13, 10895, 297, 272, 1987, 65, 356, 283, 3578, 15, 88, 13, 6404, 297, 272, 1987, 27538, 356, 283, 8130, 15, 27538, 297, 272, 1987, 371, 87, 356, 283, 3578, 15, 88, 13, 14677, 1027, 297, 272, 1987, 371, 87, 14, 14807, 379, 356, 283, 3578, 15, 88, 13, 14677, 1027, 297, 272, 1987, 371, 87, 14, 6838, 356, 283, 3578, 15, 88, 13, 14677, 1027, 297, 272, 1987, 645, 19, 356, 283, 8130, 15, 645, 19, 297, 272, 1987, 7984, 356, 283, 3578, 15, 88, 13, 7984, 297, 272, 1987, 13741, 356, 283, 505, 15, 88, 13, 350, 305, 1195, 297, 272, 1987, 9402, 356, 283, 505, 15, 88, 13, 350, 305, 1195, 297, 272, 1987, 2756, 77, 356, 283, 3578, 15, 88, 13, 4246, 13, 2756, 77, 297, 272, 1987, 643, 356, 283, 1569, 15, 88, 13, 571, 20528, 13, 15707, 297, 272, 1987, 5789, 356, 283, 3578, 15, 778, 11409, 707, 297, 272, 1987, 65, 692, 356, 283, 8130, 15, 88, 13, 5789, 556, 297, 272, 1987, 65, 25040, 356, 283, 8130, 15, 88, 13, 65, 25040, 297, 272, 1987, 5789, 556, 356, 283, 8130, 15, 88, 13, 5789, 556, 297, 272, 1987, 5789, 26299, 356, 283, 8130, 15, 88, 13, 65, 25040, 297, 272, 1987, 279, 356, 283, 3578, 15, 88, 13, 22805, 297, 272, 1987, 279, 90, 356, 283, 3578, 15, 88, 13, 279, 90, 297, 272, 1987, 455, 82, 356, 283, 8130, 15, 455, 82, 297, 272, 1987, 455, 90, 356, 283, 8130, 15, 88, 13, 455, 90, 1652, 297, 272, 1987, 26455, 356, 283, 3578, 15, 88, 13, 15595, 13, 22228, 297, 272, 1987, 22019, 59, 17, 13, 25, 74, 61, 356, 283, 3722, 15, 88, 13, 22019, 297, 272, 1987, 290, 88, 356, 283, 3578, 15, 290, 932, 88, 297, 272, 1987, 924, 356, 283, 8130, 15, 88, 13, 924, 297, 272, 1987, 23582, 356, 283, 3578, 15, 26379, 14, 6238, 14, 2491, 13, 6404, 297, 272, 1987, 285, 356, 283, 3578, 15, 88, 13, 6404, 297, 272, 1987, 285, 74, 356, 283, 3578, 15, 88, 13, 285, 74, 297, 272, 1987, 285, 87, 356, 283, 1569, 15, 88, 13, 834, 89, 13, 285, 87, 297, 272, 1987, 305, 356, 283, 3578, 15, 88, 13, 571, 20528, 13, 19930, 297, 272, 1987, 10125, 356, 283, 505, 15, 6104, 297, 272, 1987, 29551, 356, 283, 3722, 15, 88, 13, 706, 13, 29551, 297, 272, 1987, 20222, 356, 283, 3578, 15, 88, 13, 20222, 297, 272, 1987, 405, 356, 283, 505, 15, 88, 13, 28023, 297, 272, 1987, 305, 88, 356, 283, 8130, 15, 88, 13, 706, 13, 305, 88, 297, 272, 1987, 4188, 356, 283, 3578, 15, 4188, 11, 1652, 297, 272, 1987, 3844, 356, 283, 8130, 15, 4316, 297, 272, 1987, 1214, 70, 356, 283, 3722, 15, 88, 13, 706, 3722, 297, 272, 1987, 7194, 356, 283, 3722, 15, 88, 13, 706, 3722, 297, 272, 1987, 10084, 356, 283, 3578, 15, 88, 13, 571, 20528, 13, 1027, 297, 272, 1987, 65, 6603, 356, 283, 8130, 15, 455, 82, 13, 6603, 297, 272, 1987, 10084, 75, 356, 283, 3578, 15, 88, 13, 10084, 75, 297, 272, 1987, 1219, 65, 356, 283, 8130, 15, 290, 932, 88, 297, 272, 1987, 1219, 86, 356, 283, 3722, 15, 290, 932, 88, 297, 272, 1987, 27162, 356, 283, 3578, 15, 88, 13, 28272, 297, 272, 1987, 3776, 13937, 356, 283, 3578, 15, 88, 13, 3776, 13937, 297, 272, 1987, 66, 1587, 356, 283, 3578, 15, 88, 13, 4246, 13, 66, 1587, 297, 272, 1987, 21520, 356, 283, 3722, 15, 311, 18, 84, 297, 272, 1987, 3691, 12393, 356, 283, 3722, 15, 311, 18, 84, 297, 272, 1987, 8804, 356, 283, 505, 15, 88, 13, 8804, 3858, 297, 272, 1987, 1393, 356, 283, 3578, 15, 18162, 13, 1745, 297, 272, 1987, 27163, 356, 283, 3578, 15, 88, 13, 66, 24912, 297, 272, 1987, 66, 24912, 356, 283, 3578, 15, 88, 13, 66, 24912, 297, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ccellis/WHACK2016
flask/lib/python2.7/site-packages/whoosh/lang/snowball/russian.py
95
20904
from whoosh.compat import u class RussianStemmer(object): """ The Russian Snowball stemmer. :cvar __perfective_gerund_suffixes: Suffixes to be deleted. :type __perfective_gerund_suffixes: tuple :cvar __adjectival_suffixes: Suffixes to be deleted. :type __adjectival_suffixes: tuple :cvar __reflexive_suffixes: Suffixes to be deleted. :type __reflexive_suffixes: tuple :cvar __verb_suffixes: Suffixes to be deleted. :type __verb_suffixes: tuple :cvar __noun_suffixes: Suffixes to be deleted. :type __noun_suffixes: tuple :cvar __superlative_suffixes: Suffixes to be deleted. :type __superlative_suffixes: tuple :cvar __derivational_suffixes: Suffixes to be deleted. :type __derivational_suffixes: tuple :note: A detailed description of the Russian stemming algorithm can be found under http://snowball.tartarus.org/algorithms/russian/stemmer.html """ __perfective_gerund_suffixes = ("ivshis'", "yvshis'", "vshis'", "ivshi", "yvshi", "vshi", "iv", "yv", "v") __adjectival_suffixes = ('ui^ushchi^ui^u', 'ui^ushchi^ai^a', 'ui^ushchimi', 'ui^ushchymi', 'ui^ushchego', 'ui^ushchogo', 'ui^ushchemu', 'ui^ushchomu', 'ui^ushchikh', 'ui^ushchykh', 'ui^ushchui^u', 'ui^ushchaia', 'ui^ushchoi^u', 'ui^ushchei^u', 'i^ushchi^ui^u', 'i^ushchi^ai^a', 'ui^ushchee', 'ui^ushchie', 'ui^ushchye', 'ui^ushchoe', 'ui^ushchei`', 'ui^ushchii`', 'ui^ushchyi`', 'ui^ushchoi`', 'ui^ushchem', 'ui^ushchim', 'ui^ushchym', 'ui^ushchom', 'i^ushchimi', 'i^ushchymi', 'i^ushchego', 'i^ushchogo', 'i^ushchemu', 'i^ushchomu', 'i^ushchikh', 'i^ushchykh', 'i^ushchui^u', 'i^ushchai^a', 'i^ushchoi^u', 'i^ushchei^u', 'i^ushchee', 'i^ushchie', 'i^ushchye', 'i^ushchoe', 'i^ushchei`', 'i^ushchii`', 'i^ushchyi`', 'i^ushchoi`', 'i^ushchem', 'i^ushchim', 'i^ushchym', 'i^ushchom', 'shchi^ui^u', 'shchi^ai^a', 'ivshi^ui^u', 'ivshi^ai^a', 'yvshi^ui^u', 'yvshi^ai^a', 'shchimi', 'shchymi', 'shchego', 'shchogo', 'shchemu', 'shchomu', 'shchikh', 'shchykh', 'shchui^u', 'shchai^a', 'shchoi^u', 'shchei^u', 'ivshimi', 'ivshymi', 'ivshego', 'ivshogo', 'ivshemu', 'ivshomu', 'ivshikh', 'ivshykh', 'ivshui^u', 'ivshai^a', 'ivshoi^u', 'ivshei^u', 'yvshimi', 'yvshymi', 'yvshego', 'yvshogo', 'yvshemu', 'yvshomu', 'yvshikh', 'yvshykh', 'yvshui^u', 'yvshai^a', 'yvshoi^u', 'yvshei^u', 'vshi^ui^u', 'vshi^ai^a', 'shchee', 'shchie', 'shchye', 'shchoe', 'shchei`', 'shchii`', 'shchyi`', 'shchoi`', 'shchem', 'shchim', 'shchym', 'shchom', 'ivshee', 'ivshie', 'ivshye', 'ivshoe', 'ivshei`', 'ivshii`', 'ivshyi`', 'ivshoi`', 'ivshem', 'ivshim', 'ivshym', 'ivshom', 'yvshee', 'yvshie', 'yvshye', 'yvshoe', 'yvshei`', 'yvshii`', 'yvshyi`', 'yvshoi`', 'yvshem', 'yvshim', 'yvshym', 'yvshom', 'vshimi', 'vshymi', 'vshego', 'vshogo', 'vshemu', 'vshomu', 'vshikh', 'vshykh', 'vshui^u', 'vshai^a', 'vshoi^u', 'vshei^u', 'emi^ui^u', 'emi^ai^a', 'nni^ui^u', 'nni^ai^a', 'vshee', 'vshie', 'vshye', 'vshoe', 'vshei`', 'vshii`', 'vshyi`', 'vshoi`', 'vshem', 'vshim', 'vshym', 'vshom', 'emimi', 'emymi', 'emego', 'emogo', 'ememu', 'emomu', 'emikh', 'emykh', 'emui^u', 'emai^a', 'emoi^u', 'emei^u', 'nnimi', 'nnymi', 'nnego', 'nnogo', 'nnemu', 'nnomu', 'nnikh', 'nnykh', 'nnui^u', 'nnai^a', 'nnoi^u', 'nnei^u', 'emee', 'emie', 'emye', 'emoe', 'emei`', 'emii`', 'emyi`', 'emoi`', 'emem', 'emim', 'emym', 'emom', 'nnee', 'nnie', 'nnye', 'nnoe', 'nnei`', 'nnii`', 'nnyi`', 'nnoi`', 'nnem', 'nnim', 'nnym', 'nnom', 'i^ui^u', 'i^ai^a', 'imi', 'ymi', 'ego', 'ogo', 'emu', 'omu', 'ikh', 'ykh', 'ui^u', 'ai^a', 'oi^u', 'ei^u', 'ee', 'ie', 'ye', 'oe', 'ei`', 'ii`', 'yi`', 'oi`', 'em', 'im', 'ym', 'om') __reflexive_suffixes = ("si^a", "s'") __verb_suffixes = ("esh'", 'ei`te', 'ui`te', 'ui^ut', "ish'", 'ete', 'i`te', 'i^ut', 'nno', 'ila', 'yla', 'ena', 'ite', 'ili', 'yli', 'ilo', 'ylo', 'eno', 'i^at', 'uet', 'eny', "it'", "yt'", 'ui^u', 'la', 'na', 'li', 'em', 'lo', 'no', 'et', 'ny', "t'", 'ei`', 'ui`', 'il', 'yl', 'im', 'ym', 'en', 'it', 'yt', 'i^u', 'i`', 'l', 'n') __noun_suffixes = ('ii^ami', 'ii^akh', 'i^ami', 'ii^am', 'i^akh', 'ami', 'iei`', 'i^am', 'iem', 'akh', 'ii^u', "'i^u", 'ii^a', "'i^a", 'ev', 'ov', 'ie', "'e", 'ei', 'ii', 'ei`', 'oi`', 'ii`', 'em', 'am', 'om', 'i^u', 'i^a', 'a', 'e', 'i', 'i`', 'o', 'u', 'y', "'") __superlative_suffixes = ("ei`she", "ei`sh") __derivational_suffixes = ("ost'", "ost") def stem(self, word): """ Stem a Russian word and return the stemmed form. :param word: The word that is stemmed. :type word: str or unicode :return: The stemmed form. :rtype: unicode """ chr_exceeded = False for i in range(len(word)): if ord(word[i]) > 255: chr_exceeded = True break if chr_exceeded: word = self.__cyrillic_to_roman(word) step1_success = False adjectival_removed = False verb_removed = False undouble_success = False superlative_removed = False rv, r2 = self.__regions_russian(word) # Step 1 for suffix in self.__perfective_gerund_suffixes: if rv.endswith(suffix): if suffix in ("v", "vshi", "vshis'"): if (rv[-len(suffix) - 3:-len(suffix)] == "i^a" or rv[-len(suffix) - 1:-len(suffix)] == "a"): word = word[:-len(suffix)] r2 = r2[:-len(suffix)] rv = rv[:-len(suffix)] step1_success = True break else: word = word[:-len(suffix)] r2 = r2[:-len(suffix)] rv = rv[:-len(suffix)] step1_success = True break if not step1_success: for suffix in self.__reflexive_suffixes: if rv.endswith(suffix): word = word[:-len(suffix)] r2 = r2[:-len(suffix)] rv = rv[:-len(suffix)] break for suffix in self.__adjectival_suffixes: if rv.endswith(suffix): if suffix in ('i^ushchi^ui^u', 'i^ushchi^ai^a', 'i^ushchui^u', 'i^ushchai^a', 'i^ushchoi^u', 'i^ushchei^u', 'i^ushchimi', 'i^ushchymi', 'i^ushchego', 'i^ushchogo', 'i^ushchemu', 'i^ushchomu', 'i^ushchikh', 'i^ushchykh', 'shchi^ui^u', 'shchi^ai^a', 'i^ushchee', 'i^ushchie', 'i^ushchye', 'i^ushchoe', 'i^ushchei`', 'i^ushchii`', 'i^ushchyi`', 'i^ushchoi`', 'i^ushchem', 'i^ushchim', 'i^ushchym', 'i^ushchom', 'vshi^ui^u', 'vshi^ai^a', 'shchui^u', 'shchai^a', 'shchoi^u', 'shchei^u', 'emi^ui^u', 'emi^ai^a', 'nni^ui^u', 'nni^ai^a', 'shchimi', 'shchymi', 'shchego', 'shchogo', 'shchemu', 'shchomu', 'shchikh', 'shchykh', 'vshui^u', 'vshai^a', 'vshoi^u', 'vshei^u', 'shchee', 'shchie', 'shchye', 'shchoe', 'shchei`', 'shchii`', 'shchyi`', 'shchoi`', 'shchem', 'shchim', 'shchym', 'shchom', 'vshimi', 'vshymi', 'vshego', 'vshogo', 'vshemu', 'vshomu', 'vshikh', 'vshykh', 'emui^u', 'emai^a', 'emoi^u', 'emei^u', 'nnui^u', 'nnai^a', 'nnoi^u', 'nnei^u', 'vshee', 'vshie', 'vshye', 'vshoe', 'vshei`', 'vshii`', 'vshyi`', 'vshoi`', 'vshem', 'vshim', 'vshym', 'vshom', 'emimi', 'emymi', 'emego', 'emogo', 'ememu', 'emomu', 'emikh', 'emykh', 'nnimi', 'nnymi', 'nnego', 'nnogo', 'nnemu', 'nnomu', 'nnikh', 'nnykh', 'emee', 'emie', 'emye', 'emoe', 'emei`', 'emii`', 'emyi`', 'emoi`', 'emem', 'emim', 'emym', 'emom', 'nnee', 'nnie', 'nnye', 'nnoe', 'nnei`', 'nnii`', 'nnyi`', 'nnoi`', 'nnem', 'nnim', 'nnym', 'nnom'): if (rv[-len(suffix) - 3:-len(suffix)] == "i^a" or rv[-len(suffix) - 1:-len(suffix)] == "a"): word = word[:-len(suffix)] r2 = r2[:-len(suffix)] rv = rv[:-len(suffix)] adjectival_removed = True break else: word = word[:-len(suffix)] r2 = r2[:-len(suffix)] rv = rv[:-len(suffix)] adjectival_removed = True break if not adjectival_removed: for suffix in self.__verb_suffixes: if rv.endswith(suffix): if suffix in ("la", "na", "ete", "i`te", "li", "i`", "l", "em", "n", "lo", "no", "et", "i^ut", "ny", "t'", "esh'", "nno"): if (rv[-len(suffix) - 3:-len(suffix)] == "i^a" or rv[-len(suffix) - 1:-len(suffix)] == "a"): word = word[:-len(suffix)] r2 = r2[:-len(suffix)] rv = rv[:-len(suffix)] verb_removed = True break else: word = word[:-len(suffix)] r2 = r2[:-len(suffix)] rv = rv[:-len(suffix)] verb_removed = True break if not adjectival_removed and not verb_removed: for suffix in self.__noun_suffixes: if rv.endswith(suffix): word = word[:-len(suffix)] r2 = r2[:-len(suffix)] rv = rv[:-len(suffix)] break # Step 2 if rv.endswith("i"): word = word[:-1] r2 = r2[:-1] # Step 3 for suffix in self.__derivational_suffixes: if r2.endswith(suffix): word = word[:-len(suffix)] break # Step 4 if word.endswith("nn"): word = word[:-1] undouble_success = True if not undouble_success: for suffix in self.__superlative_suffixes: if word.endswith(suffix): word = word[:-len(suffix)] superlative_removed = True break if word.endswith("nn"): word = word[:-1] if not undouble_success and not superlative_removed: if word.endswith("'"): word = word[:-1] if chr_exceeded: word = self.__roman_to_cyrillic(word) return word def __regions_russian(self, word): """ Return the regions RV and R2 which are used by the Russian stemmer. In any word, RV is the region after the first vowel, or the end of the word if it contains no vowel. R2 is the region after the first non-vowel following a vowel in R1, or the end of the word if there is no such non-vowel. R1 is the region after the first non-vowel following a vowel, or the end of the word if there is no such non-vowel. :param word: The Russian word whose regions RV and R2 are determined. :type word: str or unicode :return: the regions RV and R2 for the respective Russian word. :rtype: tuple :note: This helper method is invoked by the stem method of the subclass RussianStemmer. It is not to be invoked directly! """ r1 = "" r2 = "" rv = "" vowels = ("A", "U", "E", "a", "e", "i", "o", "u", "y") word = (word.replace("i^a", "A") .replace("i^u", "U") .replace("e`", "E")) for i in range(1, len(word)): if word[i] not in vowels and word[i - 1] in vowels: r1 = word[i + 1:] break for i in range(1, len(r1)): if r1[i] not in vowels and r1[i - 1] in vowels: r2 = r1[i + 1:] break for i in range(len(word)): if word[i] in vowels: rv = word[i + 1:] break r2 = (r2.replace("A", "i^a") .replace("U", "i^u") .replace("E", "e`")) rv = (rv.replace("A", "i^a") .replace("U", "i^u") .replace("E", "e`")) return (rv, r2) def __cyrillic_to_roman(self, word): """ Transliterate a Russian word into the Roman alphabet. A Russian word whose letters consist of the Cyrillic alphabet are transliterated into the Roman alphabet in order to ease the forthcoming stemming process. :param word: The word that is transliterated. :type word: unicode :return: the transliterated word. :rtype: unicode :note: This helper method is invoked by the stem method of the subclass RussianStemmer. It is not to be invoked directly! """ word = (word.replace(u("\u0410"), "a").replace(u("\u0430"), "a") .replace(u("\u0411"), "b").replace(u("\u0431"), "b") .replace(u("\u0412"), "v").replace(u("\u0432"), "v") .replace(u("\u0413"), "g").replace(u("\u0433"), "g") .replace(u("\u0414"), "d").replace(u("\u0434"), "d") .replace(u("\u0415"), "e").replace(u("\u0435"), "e") .replace(u("\u0401"), "e").replace(u("\u0451"), "e") .replace(u("\u0416"), "zh").replace(u("\u0436"), "zh") .replace(u("\u0417"), "z").replace(u("\u0437"), "z") .replace(u("\u0418"), "i").replace(u("\u0438"), "i") .replace(u("\u0419"), "i`").replace(u("\u0439"), "i`") .replace(u("\u041A"), "k").replace(u("\u043A"), "k") .replace(u("\u041B"), "l").replace(u("\u043B"), "l") .replace(u("\u041C"), "m").replace(u("\u043C"), "m") .replace(u("\u041D"), "n").replace(u("\u043D"), "n") .replace(u("\u041E"), "o").replace(u("\u043E"), "o") .replace(u("\u041F"), "p").replace(u("\u043F"), "p") .replace(u("\u0420"), "r").replace(u("\u0440"), "r") .replace(u("\u0421"), "s").replace(u("\u0441"), "s") .replace(u("\u0422"), "t").replace(u("\u0442"), "t") .replace(u("\u0423"), "u").replace(u("\u0443"), "u") .replace(u("\u0424"), "f").replace(u("\u0444"), "f") .replace(u("\u0425"), "kh").replace(u("\u0445"), "kh") .replace(u("\u0426"), "t^s").replace(u("\u0446"), "t^s") .replace(u("\u0427"), "ch").replace(u("\u0447"), "ch") .replace(u("\u0428"), "sh").replace(u("\u0448"), "sh") .replace(u("\u0429"), "shch").replace(u("\u0449"), "shch") .replace(u("\u042A"), "''").replace(u("\u044A"), "''") .replace(u("\u042B"), "y").replace(u("\u044B"), "y") .replace(u("\u042C"), "'").replace(u("\u044C"), "'") .replace(u("\u042D"), "e`").replace(u("\u044D"), "e`") .replace(u("\u042E"), "i^u").replace(u("\u044E"), "i^u") .replace(u("\u042F"), "i^a").replace(u("\u044F"), "i^a")) return word def __roman_to_cyrillic(self, word): """ Transliterate a Russian word back into the Cyrillic alphabet. A Russian word formerly transliterated into the Roman alphabet in order to ease the stemming process, is transliterated back into the Cyrillic alphabet, its original form. :param word: The word that is transliterated. :type word: str or unicode :return: word, the transliterated word. :rtype: unicode :note: This helper method is invoked by the stem method of the subclass RussianStemmer. It is not to be invoked directly! """ word = (word.replace("i^u", u("\u044E")).replace("i^a", u("\u044F")) .replace("shch", u("\u0449")).replace("kh", u("\u0445")) .replace("t^s", u("\u0446")).replace("ch", u("\u0447")) .replace("e`", u("\u044D")).replace("i`", u("\u0439")) .replace("sh", u("\u0448")).replace("k", u("\u043A")) .replace("e", u("\u0435")).replace("zh", u("\u0436")) .replace("a", u("\u0430")).replace("b", u("\u0431")) .replace("v", u("\u0432")).replace("g", u("\u0433")) .replace("d", u("\u0434")).replace("e", u("\u0435")) .replace("z", u("\u0437")).replace("i", u("\u0438")) .replace("l", u("\u043B")).replace("m", u("\u043C")) .replace("n", u("\u043D")).replace("o", u("\u043E")) .replace("p", u("\u043F")).replace("r", u("\u0440")) .replace("s", u("\u0441")).replace("t", u("\u0442")) .replace("u", u("\u0443")).replace("f", u("\u0444")) .replace("''", u("\u044A")).replace("y", u("\u044B")) .replace("'", u("\u044C"))) return word
bsd-3-clause
[ 504, 3963, 22267, 14, 5819, 492, 399, 199, 199, 533, 820, 8630, 51, 563, 2626, 8, 785, 304, 272, 408, 272, 710, 820, 8630, 428, 2131, 8571, 17408, 2626, 14, 339, 520, 26781, 636, 529, 771, 6648, 63, 836, 725, 63, 16097, 26, 428, 2875, 397, 370, 506, 5463, 14, 272, 520, 466, 636, 529, 771, 6648, 63, 836, 725, 63, 16097, 26, 2008, 272, 520, 26781, 636, 12551, 825, 280, 637, 63, 16097, 26, 428, 2875, 397, 370, 506, 5463, 14, 272, 520, 466, 636, 12551, 825, 280, 637, 63, 16097, 26, 2008, 272, 520, 26781, 636, 1121, 3113, 1912, 63, 16097, 26, 428, 2875, 397, 370, 506, 5463, 14, 272, 520, 466, 636, 1121, 3113, 1912, 63, 16097, 26, 2008, 272, 520, 26781, 636, 17050, 63, 16097, 26, 428, 2875, 397, 370, 506, 5463, 14, 272, 520, 466, 636, 17050, 63, 16097, 26, 2008, 272, 520, 26781, 636, 889, 324, 63, 16097, 26, 428, 2875, 397, 370, 506, 5463, 14, 272, 520, 466, 636, 889, 324, 63, 16097, 26, 2008, 272, 520, 26781, 636, 4792, 3026, 63, 16097, 26, 428, 2875, 397, 370, 506, 5463, 14, 272, 520, 466, 636, 4792, 3026, 63, 16097, 26, 2008, 272, 520, 26781, 636, 9910, 4255, 279, 63, 16097, 26, 428, 2875, 397, 370, 506, 5463, 14, 272, 520, 466, 636, 9910, 4255, 279, 63, 16097, 26, 2008, 272, 520, 4610, 26, 437, 16212, 1369, 402, 314, 820, 8630, 1779, 17408, 14566, 5563, 883, 506, 1911, 1334, 1779, 1455, 921, 27765, 8571, 14, 84, 580, 285, 527, 14, 1308, 15, 24365, 15, 82, 8630, 15, 18446, 2626, 14, 1360, 339, 408, 339, 636, 529, 771, 6648, 63, 836, 725, 63, 16097, 275, 1689, 1003, 609, 374, 4662, 298, 89, 86, 609, 374, 4662, 298, 86, 609, 374, 4662, 4228, 298, 1003, 19377, 401, 298, 89, 86, 19377, 401, 298, 86, 19377, 401, 298, 1003, 401, 4228, 298, 89, 86, 401, 298, 86, 531, 272, 636, 12551, 825, 280, 637, 63, 16097, 275, 661, 1907, 62, 2084, 13175, 62, 1907, 62, 85, 297, 283, 1907, 62, 2084, 13175, 62, 5789, 62, 65, 297, 3044, 283, 1907, 62, 2084, 335, 1017, 73, 297, 283, 1907, 62, 2084, 335, 89, 2664, 297, 283, 1907, 62, 2084, 595, 1939, 297, 3044, 283, 1907, 62, 2084, 335, 974, 79, 297, 283, 1907, 62, 2084, 595, 6553, 297, 283, 1907, 62, 2084, 335, 676, 85, 297, 3044, 283, 1907, 62, 2084, 335, 3258, 72, 297, 283, 1907, 62, 2084, 335, 89, 21889, 297, 3044, 283, 1907, 62, 2084, 335, 1907, 62, 85, 297, 283, 1907, 62, 2084, 9518, 4674, 297, 3044, 283, 1907, 62, 2084, 2239, 73, 62, 85, 297, 283, 1907, 62, 2084, 595, 73, 62, 85, 297, 3044, 283, 73, 62, 2084, 13175, 62, 1907, 62, 85, 297, 283, 73, 62, 2084, 13175, 62, 5789, 62, 65, 297, 3044, 283, 1907, 62, 2084, 595, 69, 297, 283, 1907, 62, 2084, 14025, 297, 3044, 283, 1907, 62, 2084, 335, 8048, 297, 283, 1907, 62, 2084, 2239, 69, 297, 283, 1907, 62, 2084, 595, 73, 30880, 3044, 283, 1907, 62, 2084, 335, 5908, 30880, 283, 1907, 62, 2084, 335, 21643, 30880, 3044, 283, 1907, 62, 2084, 2239, 73, 30880, 283, 1907, 62, 2084, 24448, 297, 283, 1907, 62, 2084, 335, 1017, 297, 3044, 283, 1907, 62, 2084, 335, 12828, 297, 283, 1907, 62, 2084, 335, 676, 297, 283, 73, 62, 2084, 335, 1017, 73, 297, 3044, 283, 73, 62, 2084, 335, 89, 2664, 297, 283, 73, 62, 2084, 595, 1939, 297, 283, 73, 62, 2084, 335, 974, 79, 297, 3044, 283, 73, 62, 2084, 595, 6553, 297, 283, 73, 62, 2084, 335, 676, 85, 297, 283, 73, 62, 2084, 335, 3258, 72, 297, 3044, 283, 73, 62, 2084, 335, 89, 21889, 297, 283, 73, 62, 2084, 335, 1907, 62, 85, 297, 283, 73, 62, 2084, 335, 5789, 62, 65, 297, 3044, 283, 73, 62, 2084, 2239, 73, 62, 85, 297, 283, 73, 62, 2084, 595, 73, 62, 85, 297, 283, 73, 62, 2084, 595, 69, 297, 3044, 283, 73, 62, 2084, 14025, 297, 283, 73, 62, 2084, 335, 8048, 297, 283, 73, 62, 2084, 2239, 69, 297, 3044, 283, 73, 62, 2084, 595, 73, 30880, 283, 73, 62, 2084, 335, 5908, 30880, 3044, 283, 73, 62, 2084, 335, 21643, 30880, 283, 73, 62, 2084, 2239, 73, 30880, 283, 73, 62, 2084, 24448, 297, 3044, 283, 73, 62, 2084, 335, 1017, 297, 283, 73, 62, 2084, 335, 12828, 297, 283, 73, 62, 2084, 335, 676, 297, 3044, 283, 609, 13175, 62, 1907, 62, 85, 297, 283, 609, 13175, 62, 5789, 62, 65, 297, 283, 1003, 19377, 62, 1907, 62, 85, 297, 3044, 283, 1003, 19377, 62, 5789, 62, 65, 297, 283, 89, 86, 19377, 62, 1907, 62, 85, 297, 283, 89, 86, 19377, 62, 5789, 62, 65, 297, 3044, 283, 609, 335, 1017, 73, 297, 283, 609, 335, 89, 2664, 297, 283, 609, 595, 1939, 297, 283, 609, 335, 974, 79, 297, 3044, 283, 609, 595, 6553, 297, 283, 609, 335, 676, 85, 297, 283, 609, 335, 3258, 72, 297, 283, 609, 335, 89, 21889, 297, 3044, 283, 609, 335, 1907, 62, 85, 297, 283, 609, 335, 5789, 62, 65, 297, 283, 609, 2239, 73, 62, 85, 297, 3044, 283, 609, 595, 73, 62, 85, 297, 283, 1003, 28238, 73, 297, 283, 1003, 609, 89, 2664, 297, 3044, 283, 1003, 19195, 1939, 297, 283, 1003, 13927, 1939, 297, 283, 1003, 19195, 6553, 297, 283, 1003, 13927, 6553, 297, 3044, 283, 1003, 609, 3258, 72, 297, 283, 1003, 609, 89, 21889, 297, 283, 1003, 609, 1907, 62, 85, 297, 3044, 283, 1003, 4835, 73, 62, 65, 297, 283, 1003, 13927, 73, 62, 85, 297, 283, 1003, 19195, 73, 62, 85, 297, 3044, 283, 89, 86, 28238, 73, 297, 283, 89, 86, 609, 89, 2664, 297, 283, 89, 3122, 426, 1939, 297, 283, 89, 3122, 526, 1939, 297, 3044, 283, 89, 3122, 426, 6553, 297, 283, 89, 3122, 526, 6553, 297, 283, 89, 86, 609, 3258, 72, 297, 283, 89, 86, 609, 89, 21889, 297, 3044, 283, 89, 86, 609, 1907, 62, 85, 297, 283, 89, 86, 4835, 73, 62, 65, 297, 283, 89, 3122 ]
[ 3963, 22267, 14, 5819, 492, 399, 199, 199, 533, 820, 8630, 51, 563, 2626, 8, 785, 304, 272, 408, 272, 710, 820, 8630, 428, 2131, 8571, 17408, 2626, 14, 339, 520, 26781, 636, 529, 771, 6648, 63, 836, 725, 63, 16097, 26, 428, 2875, 397, 370, 506, 5463, 14, 272, 520, 466, 636, 529, 771, 6648, 63, 836, 725, 63, 16097, 26, 2008, 272, 520, 26781, 636, 12551, 825, 280, 637, 63, 16097, 26, 428, 2875, 397, 370, 506, 5463, 14, 272, 520, 466, 636, 12551, 825, 280, 637, 63, 16097, 26, 2008, 272, 520, 26781, 636, 1121, 3113, 1912, 63, 16097, 26, 428, 2875, 397, 370, 506, 5463, 14, 272, 520, 466, 636, 1121, 3113, 1912, 63, 16097, 26, 2008, 272, 520, 26781, 636, 17050, 63, 16097, 26, 428, 2875, 397, 370, 506, 5463, 14, 272, 520, 466, 636, 17050, 63, 16097, 26, 2008, 272, 520, 26781, 636, 889, 324, 63, 16097, 26, 428, 2875, 397, 370, 506, 5463, 14, 272, 520, 466, 636, 889, 324, 63, 16097, 26, 2008, 272, 520, 26781, 636, 4792, 3026, 63, 16097, 26, 428, 2875, 397, 370, 506, 5463, 14, 272, 520, 466, 636, 4792, 3026, 63, 16097, 26, 2008, 272, 520, 26781, 636, 9910, 4255, 279, 63, 16097, 26, 428, 2875, 397, 370, 506, 5463, 14, 272, 520, 466, 636, 9910, 4255, 279, 63, 16097, 26, 2008, 272, 520, 4610, 26, 437, 16212, 1369, 402, 314, 820, 8630, 1779, 17408, 14566, 5563, 883, 506, 1911, 1334, 1779, 1455, 921, 27765, 8571, 14, 84, 580, 285, 527, 14, 1308, 15, 24365, 15, 82, 8630, 15, 18446, 2626, 14, 1360, 339, 408, 339, 636, 529, 771, 6648, 63, 836, 725, 63, 16097, 275, 1689, 1003, 609, 374, 4662, 298, 89, 86, 609, 374, 4662, 298, 86, 609, 374, 4662, 4228, 298, 1003, 19377, 401, 298, 89, 86, 19377, 401, 298, 86, 19377, 401, 298, 1003, 401, 4228, 298, 89, 86, 401, 298, 86, 531, 272, 636, 12551, 825, 280, 637, 63, 16097, 275, 661, 1907, 62, 2084, 13175, 62, 1907, 62, 85, 297, 283, 1907, 62, 2084, 13175, 62, 5789, 62, 65, 297, 3044, 283, 1907, 62, 2084, 335, 1017, 73, 297, 283, 1907, 62, 2084, 335, 89, 2664, 297, 283, 1907, 62, 2084, 595, 1939, 297, 3044, 283, 1907, 62, 2084, 335, 974, 79, 297, 283, 1907, 62, 2084, 595, 6553, 297, 283, 1907, 62, 2084, 335, 676, 85, 297, 3044, 283, 1907, 62, 2084, 335, 3258, 72, 297, 283, 1907, 62, 2084, 335, 89, 21889, 297, 3044, 283, 1907, 62, 2084, 335, 1907, 62, 85, 297, 283, 1907, 62, 2084, 9518, 4674, 297, 3044, 283, 1907, 62, 2084, 2239, 73, 62, 85, 297, 283, 1907, 62, 2084, 595, 73, 62, 85, 297, 3044, 283, 73, 62, 2084, 13175, 62, 1907, 62, 85, 297, 283, 73, 62, 2084, 13175, 62, 5789, 62, 65, 297, 3044, 283, 1907, 62, 2084, 595, 69, 297, 283, 1907, 62, 2084, 14025, 297, 3044, 283, 1907, 62, 2084, 335, 8048, 297, 283, 1907, 62, 2084, 2239, 69, 297, 283, 1907, 62, 2084, 595, 73, 30880, 3044, 283, 1907, 62, 2084, 335, 5908, 30880, 283, 1907, 62, 2084, 335, 21643, 30880, 3044, 283, 1907, 62, 2084, 2239, 73, 30880, 283, 1907, 62, 2084, 24448, 297, 283, 1907, 62, 2084, 335, 1017, 297, 3044, 283, 1907, 62, 2084, 335, 12828, 297, 283, 1907, 62, 2084, 335, 676, 297, 283, 73, 62, 2084, 335, 1017, 73, 297, 3044, 283, 73, 62, 2084, 335, 89, 2664, 297, 283, 73, 62, 2084, 595, 1939, 297, 283, 73, 62, 2084, 335, 974, 79, 297, 3044, 283, 73, 62, 2084, 595, 6553, 297, 283, 73, 62, 2084, 335, 676, 85, 297, 283, 73, 62, 2084, 335, 3258, 72, 297, 3044, 283, 73, 62, 2084, 335, 89, 21889, 297, 283, 73, 62, 2084, 335, 1907, 62, 85, 297, 283, 73, 62, 2084, 335, 5789, 62, 65, 297, 3044, 283, 73, 62, 2084, 2239, 73, 62, 85, 297, 283, 73, 62, 2084, 595, 73, 62, 85, 297, 283, 73, 62, 2084, 595, 69, 297, 3044, 283, 73, 62, 2084, 14025, 297, 283, 73, 62, 2084, 335, 8048, 297, 283, 73, 62, 2084, 2239, 69, 297, 3044, 283, 73, 62, 2084, 595, 73, 30880, 283, 73, 62, 2084, 335, 5908, 30880, 3044, 283, 73, 62, 2084, 335, 21643, 30880, 283, 73, 62, 2084, 2239, 73, 30880, 283, 73, 62, 2084, 24448, 297, 3044, 283, 73, 62, 2084, 335, 1017, 297, 283, 73, 62, 2084, 335, 12828, 297, 283, 73, 62, 2084, 335, 676, 297, 3044, 283, 609, 13175, 62, 1907, 62, 85, 297, 283, 609, 13175, 62, 5789, 62, 65, 297, 283, 1003, 19377, 62, 1907, 62, 85, 297, 3044, 283, 1003, 19377, 62, 5789, 62, 65, 297, 283, 89, 86, 19377, 62, 1907, 62, 85, 297, 283, 89, 86, 19377, 62, 5789, 62, 65, 297, 3044, 283, 609, 335, 1017, 73, 297, 283, 609, 335, 89, 2664, 297, 283, 609, 595, 1939, 297, 283, 609, 335, 974, 79, 297, 3044, 283, 609, 595, 6553, 297, 283, 609, 335, 676, 85, 297, 283, 609, 335, 3258, 72, 297, 283, 609, 335, 89, 21889, 297, 3044, 283, 609, 335, 1907, 62, 85, 297, 283, 609, 335, 5789, 62, 65, 297, 283, 609, 2239, 73, 62, 85, 297, 3044, 283, 609, 595, 73, 62, 85, 297, 283, 1003, 28238, 73, 297, 283, 1003, 609, 89, 2664, 297, 3044, 283, 1003, 19195, 1939, 297, 283, 1003, 13927, 1939, 297, 283, 1003, 19195, 6553, 297, 283, 1003, 13927, 6553, 297, 3044, 283, 1003, 609, 3258, 72, 297, 283, 1003, 609, 89, 21889, 297, 283, 1003, 609, 1907, 62, 85, 297, 3044, 283, 1003, 4835, 73, 62, 65, 297, 283, 1003, 13927, 73, 62, 85, 297, 283, 1003, 19195, 73, 62, 85, 297, 3044, 283, 89, 86, 28238, 73, 297, 283, 89, 86, 609, 89, 2664, 297, 283, 89, 3122, 426, 1939, 297, 283, 89, 3122, 526, 1939, 297, 3044, 283, 89, 3122, 426, 6553, 297, 283, 89, 3122, 526, 6553, 297, 283, 89, 86, 609, 3258, 72, 297, 283, 89, 86, 609, 89, 21889, 297, 3044, 283, 89, 86, 609, 1907, 62, 85, 297, 283, 89, 86, 4835, 73, 62, 65, 297, 283, 89, 3122, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
djbaldey/django
tests/signals/tests.py
311
10273
from __future__ import unicode_literals from django.db import models from django.db.models import signals from django.dispatch import receiver from django.test import TestCase from django.utils import six from .models import Author, Book, Car, Person class BaseSignalTest(TestCase): def setUp(self): # Save up the number of connected signals so that we can check at the # end that all the signals we register get properly unregistered (#9989) self.pre_signals = ( len(signals.pre_save.receivers), len(signals.post_save.receivers), len(signals.pre_delete.receivers), len(signals.post_delete.receivers), ) def tearDown(self): # Check that all our signals got disconnected properly. post_signals = ( len(signals.pre_save.receivers), len(signals.post_save.receivers), len(signals.pre_delete.receivers), len(signals.post_delete.receivers), ) self.assertEqual(self.pre_signals, post_signals) class SignalTests(BaseSignalTest): def test_model_pre_init_and_post_init(self): data = [] def pre_init_callback(sender, args, **kwargs): data.append(kwargs['kwargs']) signals.pre_init.connect(pre_init_callback) def post_init_callback(sender, instance, **kwargs): data.append(instance) signals.post_init.connect(post_init_callback) p1 = Person(first_name="John", last_name="Doe") self.assertEqual(data, [{}, p1]) def test_save_signals(self): data = [] def pre_save_handler(signal, sender, instance, **kwargs): data.append( (instance, kwargs.get("raw", False)) ) def post_save_handler(signal, sender, instance, **kwargs): data.append( (instance, kwargs.get("created"), kwargs.get("raw", False)) ) signals.pre_save.connect(pre_save_handler, weak=False) signals.post_save.connect(post_save_handler, weak=False) try: p1 = Person.objects.create(first_name="John", last_name="Smith") self.assertEqual(data, [ (p1, False), (p1, True, False), ]) data[:] = [] p1.first_name = "Tom" p1.save() self.assertEqual(data, [ (p1, False), (p1, False, False), ]) data[:] = [] # Calling an internal method purely so that we can trigger a "raw" save. p1.save_base(raw=True) self.assertEqual(data, [ (p1, True), (p1, False, True), ]) data[:] = [] p2 = Person(first_name="James", last_name="Jones") p2.id = 99999 p2.save() self.assertEqual(data, [ (p2, False), (p2, True, False), ]) data[:] = [] p2.id = 99998 p2.save() self.assertEqual(data, [ (p2, False), (p2, True, False), ]) finally: signals.pre_save.disconnect(pre_save_handler) signals.post_save.disconnect(post_save_handler) def test_delete_signals(self): data = [] def pre_delete_handler(signal, sender, instance, **kwargs): data.append( (instance, instance.id is None) ) # #8285: signals can be any callable class PostDeleteHandler(object): def __init__(self, data): self.data = data def __call__(self, signal, sender, instance, **kwargs): self.data.append( (instance, instance.id is None) ) post_delete_handler = PostDeleteHandler(data) signals.pre_delete.connect(pre_delete_handler, weak=False) signals.post_delete.connect(post_delete_handler, weak=False) try: p1 = Person.objects.create(first_name="John", last_name="Smith") p1.delete() self.assertEqual(data, [ (p1, False), (p1, False), ]) data[:] = [] p2 = Person(first_name="James", last_name="Jones") p2.id = 99999 p2.save() p2.id = 99998 p2.save() p2.delete() self.assertEqual(data, [ (p2, False), (p2, False) ]) data[:] = [] self.assertQuerysetEqual( Person.objects.all(), [ "James Jones", ], six.text_type ) finally: signals.pre_delete.disconnect(pre_delete_handler) signals.post_delete.disconnect(post_delete_handler) def test_decorators(self): data = [] @receiver(signals.pre_save, weak=False) def decorated_handler(signal, sender, instance, **kwargs): data.append(instance) @receiver(signals.pre_save, sender=Car, weak=False) def decorated_handler_with_sender_arg(signal, sender, instance, **kwargs): data.append(instance) try: c1 = Car.objects.create(make="Volkswagon", model="Passat") self.assertEqual(data, [c1, c1]) finally: signals.pre_save.disconnect(decorated_handler) signals.pre_save.disconnect(decorated_handler_with_sender_arg, sender=Car) def test_save_and_delete_signals_with_m2m(self): data = [] def pre_save_handler(signal, sender, instance, **kwargs): data.append('pre_save signal, %s' % instance) if kwargs.get('raw'): data.append('Is raw') def post_save_handler(signal, sender, instance, **kwargs): data.append('post_save signal, %s' % instance) if 'created' in kwargs: if kwargs['created']: data.append('Is created') else: data.append('Is updated') if kwargs.get('raw'): data.append('Is raw') def pre_delete_handler(signal, sender, instance, **kwargs): data.append('pre_delete signal, %s' % instance) data.append('instance.id is not None: %s' % (instance.id is not None)) def post_delete_handler(signal, sender, instance, **kwargs): data.append('post_delete signal, %s' % instance) data.append('instance.id is not None: %s' % (instance.id is not None)) signals.pre_save.connect(pre_save_handler, weak=False) signals.post_save.connect(post_save_handler, weak=False) signals.pre_delete.connect(pre_delete_handler, weak=False) signals.post_delete.connect(post_delete_handler, weak=False) try: a1 = Author.objects.create(name='Neal Stephenson') self.assertEqual(data, [ "pre_save signal, Neal Stephenson", "post_save signal, Neal Stephenson", "Is created" ]) data[:] = [] b1 = Book.objects.create(name='Snow Crash') self.assertEqual(data, [ "pre_save signal, Snow Crash", "post_save signal, Snow Crash", "Is created" ]) data[:] = [] # Assigning and removing to/from m2m shouldn't generate an m2m signal. b1.authors = [a1] self.assertEqual(data, []) b1.authors = [] self.assertEqual(data, []) finally: signals.pre_save.disconnect(pre_save_handler) signals.post_save.disconnect(post_save_handler) signals.pre_delete.disconnect(pre_delete_handler) signals.post_delete.disconnect(post_delete_handler) def test_disconnect_in_dispatch(self): """ Test that signals that disconnect when being called don't mess future dispatching. """ class Handler(object): def __init__(self, param): self.param = param self._run = False def __call__(self, signal, sender, **kwargs): self._run = True signal.disconnect(receiver=self, sender=sender) a, b = Handler(1), Handler(2) signals.post_save.connect(a, sender=Person, weak=False) signals.post_save.connect(b, sender=Person, weak=False) Person.objects.create(first_name='John', last_name='Smith') self.assertTrue(a._run) self.assertTrue(b._run) self.assertEqual(signals.post_save.receivers, []) class LazyModelRefTest(BaseSignalTest): def setUp(self): super(LazyModelRefTest, self).setUp() self.received = [] def receiver(self, **kwargs): self.received.append(kwargs) def test_invalid_sender_model_name(self): with self.assertRaisesMessage(ValueError, "Specified sender must either be a model or a " "model name of the 'app_label.ModelName' form."): signals.post_init.connect(self.receiver, sender='invalid') def test_already_loaded_model(self): signals.post_init.connect( self.receiver, sender='signals.Book', weak=False ) try: instance = Book() self.assertEqual(self.received, [{ 'signal': signals.post_init, 'sender': Book, 'instance': instance }]) finally: signals.post_init.disconnect(self.receiver, sender=Book) def test_not_loaded_model(self): signals.post_init.connect( self.receiver, sender='signals.Created', weak=False ) try: class Created(models.Model): pass instance = Created() self.assertEqual(self.received, [{ 'signal': signals.post_init, 'sender': Created, 'instance': instance }]) finally: signals.post_init.disconnect(self.receiver, sender=Created)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 492, 10166, 199, 504, 1639, 14, 6052, 492, 13035, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 504, 1275, 992, 492, 6529, 12, 8944, 12, 14243, 12, 8028, 421, 199, 533, 3523, 11274, 774, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 327, 11063, 1536, 314, 1329, 402, 8539, 10166, 880, 626, 781, 883, 1104, 737, 314, 267, 327, 1284, 626, 1006, 314, 10166, 781, 2274, 664, 7684, 625, 11616, 15196, 1020, 1407, 9, 267, 291, 14, 657, 63, 10458, 275, 334, 288, 822, 8, 10458, 14, 657, 63, 2117, 14, 29494, 395, 288, 822, 8, 10458, 14, 1932, 63, 2117, 14, 29494, 395, 288, 822, 8, 10458, 14, 657, 63, 1807, 14, 29494, 395, 288, 822, 8, 10458, 14, 1932, 63, 1807, 14, 29494, 395, 267, 776, 339, 347, 6766, 8, 277, 304, 267, 327, 2670, 626, 1006, 4154, 10166, 4788, 25602, 7684, 14, 267, 2963, 63, 10458, 275, 334, 288, 822, 8, 10458, 14, 657, 63, 2117, 14, 29494, 395, 288, 822, 8, 10458, 14, 1932, 63, 2117, 14, 29494, 395, 288, 822, 8, 10458, 14, 657, 63, 1807, 14, 29494, 395, 288, 822, 8, 10458, 14, 1932, 63, 1807, 14, 29494, 395, 267, 776, 267, 291, 14, 629, 8, 277, 14, 657, 63, 10458, 12, 2963, 63, 10458, 9, 421, 199, 533, 18288, 2925, 8, 1563, 11274, 774, 304, 272, 347, 511, 63, 1238, 63, 657, 63, 826, 63, 460, 63, 1932, 63, 826, 8, 277, 304, 267, 666, 275, 942, 398, 347, 876, 63, 826, 63, 3058, 8, 8114, 12, 1249, 12, 1011, 958, 304, 288, 666, 14, 740, 8, 958, 459, 958, 1105, 267, 10166, 14, 657, 63, 826, 14, 2242, 8, 657, 63, 826, 63, 3058, 9, 398, 347, 2963, 63, 826, 63, 3058, 8, 8114, 12, 1256, 12, 1011, 958, 304, 288, 666, 14, 740, 8, 842, 9, 267, 10166, 14, 1932, 63, 826, 14, 2242, 8, 1932, 63, 826, 63, 3058, 9, 398, 299, 17, 275, 8028, 8, 2246, 63, 354, 628, 12923, 401, 2061, 63, 354, 628, 2585, 69, 531, 267, 291, 14, 629, 8, 576, 12, 8910, 1386, 299, 17, 566, 339, 347, 511, 63, 2117, 63, 10458, 8, 277, 304, 267, 666, 275, 942, 398, 347, 876, 63, 2117, 63, 2232, 8, 4653, 12, 8904, 12, 1256, 12, 1011, 958, 304, 288, 666, 14, 740, 8, 355, 334, 842, 12, 2074, 14, 362, 480, 1773, 401, 756, 430, 288, 776, 398, 347, 2963, 63, 2117, 63, 2232, 8, 4653, 12, 8904, 12, 1256, 12, 1011, 958, 304, 288, 666, 14, 740, 8, 355, 334, 842, 12, 2074, 14, 362, 480, 3966, 1288, 2074, 14, 362, 480, 1773, 401, 756, 430, 288, 776, 398, 10166, 14, 657, 63, 2117, 14, 2242, 8, 657, 63, 2117, 63, 2232, 12, 9282, 29, 797, 9, 267, 10166, 14, 1932, 63, 2117, 14, 2242, 8, 1932, 63, 2117, 63, 2232, 12, 9282, 29, 797, 9, 267, 862, 26, 288, 299, 17, 275, 8028, 14, 1462, 14, 981, 8, 2246, 63, 354, 628, 12923, 401, 2061, 63, 354, 628, 16782, 448, 531, 953, 291, 14, 629, 8, 576, 12, 359, 355, 334, 80, 17, 12, 756, 395, 355, 334, 80, 17, 12, 715, 12, 756, 395, 288, 4794, 288, 666, 5873, 275, 942, 953, 299, 17, 14, 2246, 63, 354, 275, 298, 52, 676, 2, 288, 299, 17, 14, 2117, 342, 288, 291, 14, 629, 8, 576, 12, 359, 355, 334, 80, 17, 12, 756, 395, 355, 334, 80, 17, 12, 756, 12, 756, 395, 288, 4794, 288, 666, 5873, 275, 942, 953, 327, 23892, 376, 5007, 1083, 15111, 590, 880, 626, 781, 883, 6804, 282, 298, 1773, 2, 3354, 14, 288, 299, 17, 14, 2117, 63, 1095, 8, 1773, 29, 549, 9, 288, 291, 14, 629, 8, 576, 12, 359, 355, 334, 80, 17, 12, 715, 395, 355, 334, 80, 17, 12, 756, 12, 715, 395, 288, 4794, 288, 666, 5873, 275, 942, 953, 299, 18, 275, 8028, 8, 2246, 63, 354, 628, 42, 14015, 401, 2061, 63, 354, 628, 42, 4548, 531, 288, 299, 18, 14, 344, 275, 221, 27055, 288, 299, 18, 14, 2117, 342, 288, 291, 14, 629, 8, 576, 12, 359, 355, 334, 80, 18, 12, 756, 395, 355, 334, 80, 18, 12, 715, 12, 756, 395, 288, 4794, 288, 666, 5873, 275, 942, 288, 299, 18, 14, 344, 275, 221, 5008, 24, 288, 299, 18, 14, 2117, 342, 288, 291, 14, 629, 8, 576, 12, 359, 355, 334, 80, 18, 12, 756, 395, 355, 334, 80, 18, 12, 715, 12, 756, 395, 288, 4794, 267, 3753, 26, 288, 10166, 14, 657, 63, 2117, 14, 10673, 8, 657, 63, 2117, 63, 2232, 9, 288, 10166, 14, 1932, 63, 2117, 14, 10673, 8, 1932, 63, 2117, 63, 2232, 9, 339, 347, 511, 63, 1807, 63, 10458, 8, 277, 304, 267, 666, 275, 942, 398, 347, 876, 63, 1807, 63, 2232, 8, 4653, 12, 8904, 12, 1256, 12, 1011, 958, 304, 288, 666, 14, 740, 8, 355, 334, 842, 12, 1256, 14, 344, 365, 488, 9, 288, 776, 398, 327, 327, 24, 14523, 26, 10166, 883, 506, 1263, 4550, 267, 1021, 7711, 5392, 2461, 8, 785, 304, 288, 347, 636, 826, 721, 277, 12, 666, 304, 355, 291, 14, 576, 275, 666, 953, 347, 636, 1250, 721, 277, 12, 4673, 12, 8904, 12, 1256, 12, 1011, 958, 304, 355, 291, 14, 576, 14, 740, 8, 490, 334, 842, 12, 1256, 14, 344, 365, 488, 9, 355, 776, 267, 2963, 63, 1807, 63, 2232, 275, 7711, 5392, 2461, 8, 576, 9, 398, 10166, 14, 657, 63, 1807, 14, 2242, 8, 657, 63, 1807, 63, 2232, 12, 9282, 29, 797, 9, 267, 10166, 14, 1932, 63, 1807, 14, 2242, 8, 1932, 63, 1807, 63, 2232, 12, 9282, 29, 797, 9, 267, 862, 26, 288, 299, 17, 275, 8028, 14, 1462, 14, 981, 8, 2246, 63, 354, 628, 12923, 401, 2061, 63, 354, 628, 16782, 448, 531, 288, 299, 17, 14, 1807, 342, 288, 291, 14 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 492, 10166, 199, 504, 1639, 14, 6052, 492, 13035, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 504, 1275, 992, 492, 6529, 12, 8944, 12, 14243, 12, 8028, 421, 199, 533, 3523, 11274, 774, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 327, 11063, 1536, 314, 1329, 402, 8539, 10166, 880, 626, 781, 883, 1104, 737, 314, 267, 327, 1284, 626, 1006, 314, 10166, 781, 2274, 664, 7684, 625, 11616, 15196, 1020, 1407, 9, 267, 291, 14, 657, 63, 10458, 275, 334, 288, 822, 8, 10458, 14, 657, 63, 2117, 14, 29494, 395, 288, 822, 8, 10458, 14, 1932, 63, 2117, 14, 29494, 395, 288, 822, 8, 10458, 14, 657, 63, 1807, 14, 29494, 395, 288, 822, 8, 10458, 14, 1932, 63, 1807, 14, 29494, 395, 267, 776, 339, 347, 6766, 8, 277, 304, 267, 327, 2670, 626, 1006, 4154, 10166, 4788, 25602, 7684, 14, 267, 2963, 63, 10458, 275, 334, 288, 822, 8, 10458, 14, 657, 63, 2117, 14, 29494, 395, 288, 822, 8, 10458, 14, 1932, 63, 2117, 14, 29494, 395, 288, 822, 8, 10458, 14, 657, 63, 1807, 14, 29494, 395, 288, 822, 8, 10458, 14, 1932, 63, 1807, 14, 29494, 395, 267, 776, 267, 291, 14, 629, 8, 277, 14, 657, 63, 10458, 12, 2963, 63, 10458, 9, 421, 199, 533, 18288, 2925, 8, 1563, 11274, 774, 304, 272, 347, 511, 63, 1238, 63, 657, 63, 826, 63, 460, 63, 1932, 63, 826, 8, 277, 304, 267, 666, 275, 942, 398, 347, 876, 63, 826, 63, 3058, 8, 8114, 12, 1249, 12, 1011, 958, 304, 288, 666, 14, 740, 8, 958, 459, 958, 1105, 267, 10166, 14, 657, 63, 826, 14, 2242, 8, 657, 63, 826, 63, 3058, 9, 398, 347, 2963, 63, 826, 63, 3058, 8, 8114, 12, 1256, 12, 1011, 958, 304, 288, 666, 14, 740, 8, 842, 9, 267, 10166, 14, 1932, 63, 826, 14, 2242, 8, 1932, 63, 826, 63, 3058, 9, 398, 299, 17, 275, 8028, 8, 2246, 63, 354, 628, 12923, 401, 2061, 63, 354, 628, 2585, 69, 531, 267, 291, 14, 629, 8, 576, 12, 8910, 1386, 299, 17, 566, 339, 347, 511, 63, 2117, 63, 10458, 8, 277, 304, 267, 666, 275, 942, 398, 347, 876, 63, 2117, 63, 2232, 8, 4653, 12, 8904, 12, 1256, 12, 1011, 958, 304, 288, 666, 14, 740, 8, 355, 334, 842, 12, 2074, 14, 362, 480, 1773, 401, 756, 430, 288, 776, 398, 347, 2963, 63, 2117, 63, 2232, 8, 4653, 12, 8904, 12, 1256, 12, 1011, 958, 304, 288, 666, 14, 740, 8, 355, 334, 842, 12, 2074, 14, 362, 480, 3966, 1288, 2074, 14, 362, 480, 1773, 401, 756, 430, 288, 776, 398, 10166, 14, 657, 63, 2117, 14, 2242, 8, 657, 63, 2117, 63, 2232, 12, 9282, 29, 797, 9, 267, 10166, 14, 1932, 63, 2117, 14, 2242, 8, 1932, 63, 2117, 63, 2232, 12, 9282, 29, 797, 9, 267, 862, 26, 288, 299, 17, 275, 8028, 14, 1462, 14, 981, 8, 2246, 63, 354, 628, 12923, 401, 2061, 63, 354, 628, 16782, 448, 531, 953, 291, 14, 629, 8, 576, 12, 359, 355, 334, 80, 17, 12, 756, 395, 355, 334, 80, 17, 12, 715, 12, 756, 395, 288, 4794, 288, 666, 5873, 275, 942, 953, 299, 17, 14, 2246, 63, 354, 275, 298, 52, 676, 2, 288, 299, 17, 14, 2117, 342, 288, 291, 14, 629, 8, 576, 12, 359, 355, 334, 80, 17, 12, 756, 395, 355, 334, 80, 17, 12, 756, 12, 756, 395, 288, 4794, 288, 666, 5873, 275, 942, 953, 327, 23892, 376, 5007, 1083, 15111, 590, 880, 626, 781, 883, 6804, 282, 298, 1773, 2, 3354, 14, 288, 299, 17, 14, 2117, 63, 1095, 8, 1773, 29, 549, 9, 288, 291, 14, 629, 8, 576, 12, 359, 355, 334, 80, 17, 12, 715, 395, 355, 334, 80, 17, 12, 756, 12, 715, 395, 288, 4794, 288, 666, 5873, 275, 942, 953, 299, 18, 275, 8028, 8, 2246, 63, 354, 628, 42, 14015, 401, 2061, 63, 354, 628, 42, 4548, 531, 288, 299, 18, 14, 344, 275, 221, 27055, 288, 299, 18, 14, 2117, 342, 288, 291, 14, 629, 8, 576, 12, 359, 355, 334, 80, 18, 12, 756, 395, 355, 334, 80, 18, 12, 715, 12, 756, 395, 288, 4794, 288, 666, 5873, 275, 942, 288, 299, 18, 14, 344, 275, 221, 5008, 24, 288, 299, 18, 14, 2117, 342, 288, 291, 14, 629, 8, 576, 12, 359, 355, 334, 80, 18, 12, 756, 395, 355, 334, 80, 18, 12, 715, 12, 756, 395, 288, 4794, 267, 3753, 26, 288, 10166, 14, 657, 63, 2117, 14, 10673, 8, 657, 63, 2117, 63, 2232, 9, 288, 10166, 14, 1932, 63, 2117, 14, 10673, 8, 1932, 63, 2117, 63, 2232, 9, 339, 347, 511, 63, 1807, 63, 10458, 8, 277, 304, 267, 666, 275, 942, 398, 347, 876, 63, 1807, 63, 2232, 8, 4653, 12, 8904, 12, 1256, 12, 1011, 958, 304, 288, 666, 14, 740, 8, 355, 334, 842, 12, 1256, 14, 344, 365, 488, 9, 288, 776, 398, 327, 327, 24, 14523, 26, 10166, 883, 506, 1263, 4550, 267, 1021, 7711, 5392, 2461, 8, 785, 304, 288, 347, 636, 826, 721, 277, 12, 666, 304, 355, 291, 14, 576, 275, 666, 953, 347, 636, 1250, 721, 277, 12, 4673, 12, 8904, 12, 1256, 12, 1011, 958, 304, 355, 291, 14, 576, 14, 740, 8, 490, 334, 842, 12, 1256, 14, 344, 365, 488, 9, 355, 776, 267, 2963, 63, 1807, 63, 2232, 275, 7711, 5392, 2461, 8, 576, 9, 398, 10166, 14, 657, 63, 1807, 14, 2242, 8, 657, 63, 1807, 63, 2232, 12, 9282, 29, 797, 9, 267, 10166, 14, 1932, 63, 1807, 14, 2242, 8, 1932, 63, 1807, 63, 2232, 12, 9282, 29, 797, 9, 267, 862, 26, 288, 299, 17, 275, 8028, 14, 1462, 14, 981, 8, 2246, 63, 354, 628, 12923, 401, 2061, 63, 354, 628, 16782, 448, 531, 288, 299, 17, 14, 1807, 342, 288, 291, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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 -*- """ Generates turn definitions XML file based on connections XML file. """ import connections import turndefinitions import logging import optparse LOGGER = logging.getLogger(__name__) if __name__ == "__main__": # pylint: disable-msg=C0103 logging.basicConfig(level="INFO") option_parser = optparse.OptionParser() option_parser.add_option("-c", "--connections-file", dest="connections_file", help="Read connections defined in CONNECTIONS_FILE. Mandatory.", metavar="CONNECTIONS_FILE") option_parser.add_option("-t", "--turn-definitions-file", dest="turn_definitions_file", help="Write the resulting turn definitions to TURN_DEFINITIONS_FILE. " "Mandatory.", metavar="TURN_DEFINITIONS_FILE") (options, args) = option_parser.parse_args() if options.connections_file is None: LOGGER.fatal("Missing CONNECTIONS_FILE.\n" + option_parser.format_help()) exit() if options.turn_definitions_file is None: LOGGER.fatal("Missing TURN_DEFINITIONS_FILE.\n" + option_parser.format_help()) exit() connections_file = open(options.connections_file, "r") turn_definitions_file = open(options.turn_definitions_file, "w") connections = connections.from_stream(connections_file) turn_definitions = turndefinitions.from_connections(connections) turn_definitions_xml = turndefinitions.to_xml(turn_definitions) turn_definitions_file.write(turn_definitions_xml) connections_file.close() turn_definitions_file.close()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2644, 26, 2774, 24, 1882, 199, 199, 624, 21687, 7485, 10269, 4692, 570, 4079, 641, 272, 6947, 4692, 570, 14, 408, 199, 199, 646, 6947, 199, 646, 7485, 15388, 199, 646, 2050, 199, 646, 8691, 199, 199, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 339, 327, 4287, 26, 3507, 13, 1328, 29, 35, 28399, 339, 2050, 14, 19602, 8, 1896, 628, 4531, 531, 339, 945, 63, 2087, 275, 8691, 14, 14553, 342, 272, 945, 63, 2087, 14, 525, 63, 1422, 6096, 67, 401, 4320, 7995, 13, 493, 401, 267, 2053, 628, 7995, 63, 493, 401, 267, 1720, 628, 3284, 6947, 3247, 315, 1868, 6930, 2823, 63, 3817, 14, 603, 13530, 4765, 267, 8214, 628, 14657, 2823, 63, 3817, 531, 272, 945, 63, 2087, 14, 525, 63, 1422, 6096, 84, 401, 4320, 353, 13, 15388, 13, 493, 401, 267, 2053, 628, 353, 63, 15388, 63, 493, 401, 267, 1720, 628, 3534, 314, 9183, 7485, 10269, 370, 377, 7648, 63, 5638, 8727, 2823, 63, 3817, 14, 298, 1467, 298, 45, 13530, 4765, 267, 8214, 628, 52, 7648, 63, 5638, 8727, 2823, 63, 3817, 531, 339, 334, 1419, 12, 1249, 9, 275, 945, 63, 2087, 14, 1122, 63, 589, 342, 339, 340, 1511, 14, 7995, 63, 493, 365, 488, 26, 267, 20184, 14, 16208, 480, 7718, 1868, 6930, 2823, 63, 3817, 3134, 78, 2, 435, 288, 945, 63, 2087, 14, 908, 63, 3437, 1012, 267, 4458, 342, 339, 340, 1511, 14, 353, 63, 15388, 63, 493, 365, 488, 26, 267, 20184, 14, 16208, 480, 7718, 377, 7648, 63, 5638, 8727, 2823, 63, 3817, 3134, 78, 2, 435, 288, 945, 63, 2087, 14, 908, 63, 3437, 1012, 267, 4458, 342, 339, 6947, 63, 493, 275, 1551, 8, 1419, 14, 7995, 63, 493, 12, 298, 82, 531, 272, 7485, 63, 15388, 63, 493, 275, 1551, 8, 1419, 14, 353, 63, 15388, 63, 493, 12, 298, 87, 531, 339, 6947, 275, 6947, 14, 504, 63, 1745, 8, 7995, 63, 493, 9, 272, 7485, 63, 15388, 275, 7485, 15388, 14, 504, 63, 7995, 8, 7995, 9, 272, 7485, 63, 15388, 63, 1652, 275, 7485, 15388, 14, 475, 63, 1652, 8, 353, 63, 15388, 9, 272, 7485, 63, 15388, 63, 493, 14, 952, 8, 353, 63, 15388, 63, 1652, 9, 339, 6947, 63, 493, 14, 1600, 342, 272, 7485, 63, 15388, 63, 493, 14, 1600, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2644, 26, 2774, 24, 1882, 199, 199, 624, 21687, 7485, 10269, 4692, 570, 4079, 641, 272, 6947, 4692, 570, 14, 408, 199, 199, 646, 6947, 199, 646, 7485, 15388, 199, 646, 2050, 199, 646, 8691, 199, 199, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 339, 327, 4287, 26, 3507, 13, 1328, 29, 35, 28399, 339, 2050, 14, 19602, 8, 1896, 628, 4531, 531, 339, 945, 63, 2087, 275, 8691, 14, 14553, 342, 272, 945, 63, 2087, 14, 525, 63, 1422, 6096, 67, 401, 4320, 7995, 13, 493, 401, 267, 2053, 628, 7995, 63, 493, 401, 267, 1720, 628, 3284, 6947, 3247, 315, 1868, 6930, 2823, 63, 3817, 14, 603, 13530, 4765, 267, 8214, 628, 14657, 2823, 63, 3817, 531, 272, 945, 63, 2087, 14, 525, 63, 1422, 6096, 84, 401, 4320, 353, 13, 15388, 13, 493, 401, 267, 2053, 628, 353, 63, 15388, 63, 493, 401, 267, 1720, 628, 3534, 314, 9183, 7485, 10269, 370, 377, 7648, 63, 5638, 8727, 2823, 63, 3817, 14, 298, 1467, 298, 45, 13530, 4765, 267, 8214, 628, 52, 7648, 63, 5638, 8727, 2823, 63, 3817, 531, 339, 334, 1419, 12, 1249, 9, 275, 945, 63, 2087, 14, 1122, 63, 589, 342, 339, 340, 1511, 14, 7995, 63, 493, 365, 488, 26, 267, 20184, 14, 16208, 480, 7718, 1868, 6930, 2823, 63, 3817, 3134, 78, 2, 435, 288, 945, 63, 2087, 14, 908, 63, 3437, 1012, 267, 4458, 342, 339, 340, 1511, 14, 353, 63, 15388, 63, 493, 365, 488, 26, 267, 20184, 14, 16208, 480, 7718, 377, 7648, 63, 5638, 8727, 2823, 63, 3817, 3134, 78, 2, 435, 288, 945, 63, 2087, 14, 908, 63, 3437, 1012, 267, 4458, 342, 339, 6947, 63, 493, 275, 1551, 8, 1419, 14, 7995, 63, 493, 12, 298, 82, 531, 272, 7485, 63, 15388, 63, 493, 275, 1551, 8, 1419, 14, 353, 63, 15388, 63, 493, 12, 298, 87, 531, 339, 6947, 275, 6947, 14, 504, 63, 1745, 8, 7995, 63, 493, 9, 272, 7485, 63, 15388, 275, 7485, 15388, 14, 504, 63, 7995, 8, 7995, 9, 272, 7485, 63, 15388, 63, 1652, 275, 7485, 15388, 14, 475, 63, 1652, 8, 353, 63, 15388, 9, 272, 7485, 63, 15388, 63, 493, 14, 952, 8, 353, 63, 15388, 63, 1652, 9, 339, 6947, 63, 493, 14, 1600, 342, 272, 7485, 63, 15388, 63, 493, 14, 1600, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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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 ]
CodeMonkeyJan/hyperspy
hyperspy/tests/io/test_dm3.py
2
11636
# -*- coding: utf-8 -*- # Copyright 2007-2016 The HyperSpy developers # # This file is part of HyperSpy. # # HyperSpy is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # HyperSpy is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with HyperSpy. If not, see <http://www.gnu.org/licenses/>. import os import numpy as np from numpy.testing import assert_allclose import pytest from hyperspy.tests.io.generate_dm_testing_files import (dm3_data_types, dm4_data_types) from hyperspy.io import load from hyperspy.io_plugins.digital_micrograph import DigitalMicrographReader, ImageObject MY_PATH = os.path.dirname(__file__) class TestImageObject(): def setup_method(self, method): self.imageobject = ImageObject({}, "") def _load_file(self, fname): with open(fname, "rb") as f: dm = DigitalMicrographReader(f) dm.parse_file() self.imdict = dm.get_image_dictionaries() return [ImageObject(imdict, fname) for imdict in self.imdict] def test_get_microscope_name(self): fname = os.path.join(MY_PATH, "dm3_2D_data", "test_diffraction_pattern_tags_removed.dm3") images = self._load_file(fname) image = images[0] # Should return None because the tags are missing assert image._get_microscope_name(image.imdict.ImageTags) is None fname = os.path.join(MY_PATH, "dm3_2D_data", "test_diffraction_pattern.dm3") images = self._load_file(fname) image = images[0] assert image._get_microscope_name( image.imdict.ImageTags) == "FEI Tecnai" def test_get_date(self): assert self.imageobject._get_date("11/13/2016") == "2016-11-13" def test_get_time(self): assert self.imageobject._get_time("6:56:37 pm") == "18:56:37" def test_parse_string(self): assert self.imageobject._parse_string("") is None assert self.imageobject._parse_string("string") is "string" def test_missing_tag(): fname = os.path.join(MY_PATH, "dm3_2D_data", "test_diffraction_pattern_tags_removed.dm3") s = load(fname) md = s.metadata assert_allclose(md.Acquisition_instrument.TEM.beam_energy, 200.0) assert_allclose(md.Acquisition_instrument.TEM.Camera.exposure, 0.2) assert md.General.date == "2014-07-09" assert md.General.time == "18:56:37" assert md.General.title == "test_diffraction_pattern_tags_removed" def test_read_TEM_metadata(): fname = os.path.join(MY_PATH, "tiff_files", "test_dm_image_um_unit.dm3") s = load(fname) md = s.metadata assert md.Acquisition_instrument.TEM.acquisition_mode == "TEM" assert_allclose(md.Acquisition_instrument.TEM.beam_energy, 200.0) assert_allclose(md.Acquisition_instrument.TEM.Camera.exposure, 0.5) assert_allclose(md.Acquisition_instrument.TEM.magnification, 51.0) assert md.Acquisition_instrument.TEM.microscope == "FEI Tecnai" assert md.General.date == "2015-07-20" assert md.General.original_filename == "test_dm_image_um_unit.dm3" assert md.General.title == "test_dm_image_um_unit" assert md.General.time == "18:48:25" assert md.Signal.quantity == "Intensity" assert md.Signal.signal_type == "" def test_read_Diffraction_metadata(): fname = os.path.join( MY_PATH, "dm3_2D_data", "test_diffraction_pattern.dm3") s = load(fname) md = s.metadata assert md.Acquisition_instrument.TEM.acquisition_mode == "TEM" assert_allclose(md.Acquisition_instrument.TEM.beam_energy, 200.0) assert_allclose(md.Acquisition_instrument.TEM.Camera.exposure, 0.2) assert_allclose(md.Acquisition_instrument.TEM.camera_length, 320.0) assert md.Acquisition_instrument.TEM.microscope == "FEI Tecnai" assert md.General.date == "2014-07-09" assert ( md.General.original_filename == "test_diffraction_pattern.dm3") assert md.General.title == "test_diffraction_pattern" assert md.General.time == "18:56:37" assert md.Signal.quantity == "Intensity" assert md.Signal.signal_type == "" def test_read_STEM_metadata(): fname = os.path.join(MY_PATH, "dm3_2D_data", "test_STEM_image.dm3") s = load(fname) md = s.metadata assert md.Acquisition_instrument.TEM.acquisition_mode == "STEM" assert_allclose(md.Acquisition_instrument.TEM.beam_energy, 200.0) assert_allclose(md.Acquisition_instrument.TEM.dwell_time, 3.5E-6) assert_allclose(md.Acquisition_instrument.TEM.camera_length, 135.0) assert_allclose( md.Acquisition_instrument.TEM.magnification, 225000.0) assert md.Acquisition_instrument.TEM.microscope == "FEI Titan" assert md.General.date == "2016-08-08" assert md.General.original_filename == "test_STEM_image.dm3" assert md.General.title == "test_STEM_image" assert md.General.time == "16:26:37" assert md.Signal.quantity == "Intensity" assert md.Signal.signal_type == "" def test_read_EELS_metadata(): fname = os.path.join(MY_PATH, "dm3_1D_data", "test-EELS_spectrum.dm3") s = load(fname) md = s.metadata assert md.Acquisition_instrument.TEM.acquisition_mode == "STEM" assert_allclose(md.Acquisition_instrument.TEM.beam_energy, 200.0) assert md.Acquisition_instrument.TEM.microscope == "FEI Titan" assert_allclose(md.Acquisition_instrument.TEM.camera_length, 135.0) assert_allclose( md.Acquisition_instrument.TEM.magnification, 640000.0) assert_allclose(md.Acquisition_instrument.TEM.Stage.tilt_alpha, 24.95, atol=1E-2) assert_allclose(md.Acquisition_instrument.TEM.Stage.x, -0.478619, atol=1E-2) assert_allclose(md.Acquisition_instrument.TEM.Stage.y, 0.0554612, atol=1E-2) assert_allclose(md.Acquisition_instrument.TEM.Stage.z, 0.036348, atol=1E-2) assert_allclose( md.Acquisition_instrument.TEM.convergence_angle, 21.0) assert_allclose( md.Acquisition_instrument.TEM.Detector.EELS.collection_angle, 0.0) assert_allclose( md.Acquisition_instrument.TEM.Detector.EELS.exposure, 0.0035) assert_allclose( md.Acquisition_instrument.TEM.Detector.EELS.frame_number, 50) assert ( md.Acquisition_instrument.TEM.Detector.EELS.spectrometer == 'GIF Quantum ER') assert ( md.Acquisition_instrument.TEM.Detector.EELS.aperture_size == 5.0) assert md.General.date == "2016-08-08" assert md.General.original_filename == "test-EELS_spectrum.dm3" assert md.General.title == "EELS Acquire" assert md.General.time == "19:35:17" assert md.Signal.quantity == "Electrons (Counts)" assert md.Signal.signal_type == "EELS" assert_allclose( md.Signal.Noise_properties.Variance_linear_model.gain_factor, 0.1285347) assert_allclose( md.Signal.Noise_properties.Variance_linear_model.gain_offset, 0.0) def test_read_EDS_metadata(): fname = os.path.join(MY_PATH, "dm3_1D_data", "test-EDS_spectrum.dm3") s = load(fname) md = s.metadata assert md.Acquisition_instrument.TEM.acquisition_mode == "STEM" assert_allclose( md.Acquisition_instrument.TEM.Detector.EDS.azimuth_angle, 45.0) assert_allclose( md.Acquisition_instrument.TEM.Detector.EDS.elevation_angle, 18.0) assert_allclose( md.Acquisition_instrument.TEM.Detector.EDS.energy_resolution_MnKa, 130.0) assert_allclose( md.Acquisition_instrument.TEM.Detector.EDS.live_time, 3.806) assert_allclose( md.Acquisition_instrument.TEM.Detector.EDS.real_time, 4.233) assert_allclose(md.Acquisition_instrument.TEM.Stage.tilt_alpha, 24.95, atol=1E-2) assert_allclose(md.Acquisition_instrument.TEM.beam_energy, 200.0) assert md.Acquisition_instrument.TEM.microscope == "FEI Titan" assert_allclose(md.Acquisition_instrument.TEM.camera_length, 135.0) assert_allclose( md.Acquisition_instrument.TEM.magnification, 320000.0) assert md.General.date == "2016-08-08" assert md.General.original_filename == "test-EDS_spectrum.dm3" assert md.General.title == "EDS Spectrum" assert md.General.time == "21:46:19" assert md.Signal.quantity == "X-rays (Counts)" assert md.Signal.signal_type == "EDS_TEM" assert_allclose( md.Signal.Noise_properties.Variance_linear_model.gain_factor, 1.0) assert_allclose( md.Signal.Noise_properties.Variance_linear_model.gain_offset, 0.0) def test_location(): fname_list = ['Fei HAADF-DE_location.dm3', 'Fei HAADF-FR_location.dm3', 'Fei HAADF-MX_location.dm3', 'Fei HAADF-UK_location.dm3'] s = load(os.path.join(MY_PATH, "dm3_locale", fname_list[0])) assert s.metadata.General.date == "2016-08-27" assert s.metadata.General.time == "20:54:33" s = load(os.path.join(MY_PATH, "dm3_locale", fname_list[1])) assert s.metadata.General.date == "2016-08-27" assert s.metadata.General.time == "20:55:20" s = load(os.path.join(MY_PATH, "dm3_locale", fname_list[2])) assert s.metadata.General.date == "2016-08-27" # assert_equal(s.metadata.General.time, "20:55:20") # MX not working s = load(os.path.join(MY_PATH, "dm3_locale", fname_list[3])) assert s.metadata.General.date == "2016-08-27" assert s.metadata.General.time == "20:52:30" def generate_parameters(): parameters = [] for dim in range(1, 4): for key in dm3_data_types.keys(): subfolder = 'dm3_%iD_data' % dim fname = "test-%s.dm3" % key filename = os.path.join(MY_PATH, subfolder, fname) parameters.append({ "filename": filename, "subfolder": subfolder, "key": key, }) for key in dm4_data_types.keys(): subfolder = 'dm4_%iD_data' % dim fname = "test-%s.dm4" % key filename = os.path.join(MY_PATH, subfolder, fname) parameters.append({ "filename": filename, "subfolder": subfolder, "key": key, }) return parameters @pytest.mark.parametrize("pdict", generate_parameters()) def test_data(pdict): s = load(pdict["filename"]) key = pdict["key"] assert s.data.dtype == np.dtype(dm4_data_types[key]) subfolder = pdict["subfolder"] print(pdict["subfolder"]) if subfolder in ('dm3_1D_data', 'dm4_1D_data'): dat = np.arange(1, 3) elif subfolder in ('dm3_2D_data', 'dm4_2D_data'): dat = np.arange(1, 5).reshape(2, 2) elif subfolder in ('dm3_3D_data', 'dm4_3D_data'): dat = np.arange(1, 9).reshape(2, 2, 2) else: raise ValueError dat = dat.astype(dm4_data_types[key]) if key in (8, 23): # RGBA dat["A"][:] = 0 np.testing.assert_array_equal(s.data, dat, err_msg='content %s type % i: ' '\n%s not equal to \n%s' % (subfolder, key, str(s.data), str(dat)))
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 10219, 13, 9261, 710, 21344, 51, 647, 19782, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 221, 21344, 51, 647, 14, 199, 3, 199, 3, 221, 21344, 51, 647, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 21344, 51, 647, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 221, 21344, 51, 647, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 646, 747, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 702, 63, 7520, 199, 646, 4613, 199, 199, 504, 10342, 15252, 14, 2219, 14, 2308, 14, 4208, 63, 6428, 63, 4776, 63, 1725, 492, 334, 6428, 19, 63, 576, 63, 1313, 12, 12740, 17547, 20, 63, 576, 63, 1313, 9, 199, 504, 10342, 15252, 14, 2308, 492, 2248, 199, 504, 10342, 15252, 14, 2308, 63, 5265, 14, 25888, 63, 6453, 2180, 492, 29979, 23990, 2180, 5929, 12, 6047, 1692, 199, 199, 12339, 63, 3243, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 421, 199, 533, 1379, 3491, 1692, 837, 339, 347, 3272, 63, 765, 8, 277, 12, 1083, 304, 267, 291, 14, 1569, 785, 275, 6047, 1692, 16037, 6899, 339, 347, 485, 912, 63, 493, 8, 277, 12, 6748, 304, 267, 543, 1551, 8, 5252, 12, 298, 4848, 531, 465, 289, 26, 288, 17547, 275, 29979, 23990, 2180, 5929, 8, 70, 9, 288, 17547, 14, 1122, 63, 493, 342, 288, 291, 14, 1017, 807, 275, 17547, 14, 362, 63, 1569, 63, 328, 10150, 342, 267, 372, 359, 3491, 1692, 8, 1017, 807, 12, 6748, 9, 367, 3416, 807, 315, 291, 14, 1017, 807, 61, 339, 347, 511, 63, 362, 63, 6453, 2645, 63, 354, 8, 277, 304, 267, 6748, 275, 747, 14, 515, 14, 904, 8, 12339, 63, 3243, 12, 298, 6428, 19, 63, 18, 36, 63, 576, 401, 2490, 298, 396, 63, 3028, 6156, 63, 3401, 63, 2969, 63, 10649, 14, 6428, 19, 531, 267, 5935, 275, 291, 423, 912, 63, 493, 8, 5252, 9, 267, 1834, 275, 5935, 59, 16, 61, 267, 327, 7719, 372, 488, 2952, 314, 3762, 787, 4124, 267, 702, 1834, 423, 362, 63, 6453, 2645, 63, 354, 8, 1569, 14, 1017, 807, 14, 3491, 9440, 9, 365, 488, 398, 6748, 275, 747, 14, 515, 14, 904, 8, 12339, 63, 3243, 12, 298, 6428, 19, 63, 18, 36, 63, 576, 401, 2490, 298, 396, 63, 3028, 6156, 63, 3401, 14, 6428, 19, 531, 267, 5935, 275, 291, 423, 912, 63, 493, 8, 5252, 9, 267, 1834, 275, 5935, 59, 16, 61, 267, 702, 1834, 423, 362, 63, 6453, 2645, 63, 354, 8, 288, 1834, 14, 1017, 807, 14, 3491, 9440, 9, 508, 298, 5100, 41, 377, 825, 3540, 73, 2, 339, 347, 511, 63, 362, 63, 602, 8, 277, 304, 267, 702, 291, 14, 1569, 785, 423, 362, 63, 602, 480, 845, 15, 969, 15, 9261, 531, 508, 298, 9261, 13, 845, 13, 969, 2, 339, 347, 511, 63, 362, 63, 521, 8, 277, 304, 267, 702, 291, 14, 1569, 785, 423, 362, 63, 521, 480, 22, 26, 1367, 26, 1401, 14207, 531, 508, 298, 1085, 26, 1367, 26, 1401, 2, 339, 347, 511, 63, 1122, 63, 875, 8, 277, 304, 267, 702, 291, 14, 1569, 785, 423, 1122, 63, 875, 10804, 365, 488, 267, 702, 291, 14, 1569, 785, 423, 1122, 63, 875, 480, 875, 531, 365, 298, 875, 2, 421, 199, 318, 511, 63, 4752, 63, 1450, 837, 272, 6748, 275, 747, 14, 515, 14, 904, 8, 12339, 63, 3243, 12, 298, 6428, 19, 63, 18, 36, 63, 576, 401, 586, 298, 396, 63, 3028, 6156, 63, 3401, 63, 2969, 63, 10649, 14, 6428, 19, 531, 272, 308, 275, 2248, 8, 5252, 9, 272, 6128, 275, 308, 14, 2343, 272, 702, 63, 7520, 8, 1064, 14, 1945, 21523, 63, 13321, 14, 22057, 14, 14529, 63, 8443, 12, 1926, 14, 16, 9, 272, 702, 63, 7520, 8, 1064, 14, 1945, 21523, 63, 13321, 14, 22057, 14, 18425, 14, 28480, 12, 378, 14, 18, 9, 272, 702, 6128, 14, 14109, 14, 602, 508, 298, 7280, 13, 1780, 13, 1643, 2, 272, 702, 6128, 14, 14109, 14, 521, 508, 298, 1085, 26, 1367, 26, 1401, 2, 272, 702, 6128, 14, 14109, 14, 1213, 508, 298, 396, 63, 3028, 6156, 63, 3401, 63, 2969, 63, 10649, 2, 421, 199, 318, 511, 63, 739, 63, 22057, 63, 2343, 837, 272, 6748, 275, 747, 14, 515, 14, 904, 8, 12339, 63, 3243, 12, 298, 29119, 63, 1725, 401, 298, 396, 63, 6428, 63, 1569, 63, 453, 63, 3248, 14, 6428, 19, 531, 272, 308, 275, 2248, 8, 5252, 9, 272, 6128, 275, 308, 14, 2343, 272, 702, 6128, 14, 1945, 21523, 63, 13321, 14, 22057, 14, 645, 21523, 63, 632, 508, 298, 22057, 2, 272, 702, 63, 7520, 8, 1064, 14, 1945, 21523, 63, 13321, 14, 22057, 14, 14529, 63, 8443, 12, 1926, 14, 16, 9, 272, 702, 63, 7520, 8, 1064, 14, 1945, 21523, 63, 13321, 14, 22057, 14, 18425, 14, 28480, 12, 378, 14, 21, 9, 272, 702, 63, 7520, 8, 1064, 14, 1945, 21523, 63, 13321, 14, 22057, 14, 19902, 7313, 12, 8026, 14, 16, 9, 272, 702, 6128, 14, 1945, 21523, 63, 13321, 14, 22057, 14, 6453, 2645, 508, 298, 5100, 41, 377, 825, 3540, 73, 2, 272, 702, 6128, 14, 14109, 14, 602, 508, 298, 7806, 13, 1780, 13, 1165, 2, 272, 702, 6128, 14, 14109, 14, 5043, 63, 1501, 508 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 10219, 13, 9261, 710, 21344, 51, 647, 19782, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 221, 21344, 51, 647, 14, 199, 3, 199, 3, 221, 21344, 51, 647, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 21344, 51, 647, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 221, 21344, 51, 647, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 646, 747, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 702, 63, 7520, 199, 646, 4613, 199, 199, 504, 10342, 15252, 14, 2219, 14, 2308, 14, 4208, 63, 6428, 63, 4776, 63, 1725, 492, 334, 6428, 19, 63, 576, 63, 1313, 12, 12740, 17547, 20, 63, 576, 63, 1313, 9, 199, 504, 10342, 15252, 14, 2308, 492, 2248, 199, 504, 10342, 15252, 14, 2308, 63, 5265, 14, 25888, 63, 6453, 2180, 492, 29979, 23990, 2180, 5929, 12, 6047, 1692, 199, 199, 12339, 63, 3243, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 421, 199, 533, 1379, 3491, 1692, 837, 339, 347, 3272, 63, 765, 8, 277, 12, 1083, 304, 267, 291, 14, 1569, 785, 275, 6047, 1692, 16037, 6899, 339, 347, 485, 912, 63, 493, 8, 277, 12, 6748, 304, 267, 543, 1551, 8, 5252, 12, 298, 4848, 531, 465, 289, 26, 288, 17547, 275, 29979, 23990, 2180, 5929, 8, 70, 9, 288, 17547, 14, 1122, 63, 493, 342, 288, 291, 14, 1017, 807, 275, 17547, 14, 362, 63, 1569, 63, 328, 10150, 342, 267, 372, 359, 3491, 1692, 8, 1017, 807, 12, 6748, 9, 367, 3416, 807, 315, 291, 14, 1017, 807, 61, 339, 347, 511, 63, 362, 63, 6453, 2645, 63, 354, 8, 277, 304, 267, 6748, 275, 747, 14, 515, 14, 904, 8, 12339, 63, 3243, 12, 298, 6428, 19, 63, 18, 36, 63, 576, 401, 2490, 298, 396, 63, 3028, 6156, 63, 3401, 63, 2969, 63, 10649, 14, 6428, 19, 531, 267, 5935, 275, 291, 423, 912, 63, 493, 8, 5252, 9, 267, 1834, 275, 5935, 59, 16, 61, 267, 327, 7719, 372, 488, 2952, 314, 3762, 787, 4124, 267, 702, 1834, 423, 362, 63, 6453, 2645, 63, 354, 8, 1569, 14, 1017, 807, 14, 3491, 9440, 9, 365, 488, 398, 6748, 275, 747, 14, 515, 14, 904, 8, 12339, 63, 3243, 12, 298, 6428, 19, 63, 18, 36, 63, 576, 401, 2490, 298, 396, 63, 3028, 6156, 63, 3401, 14, 6428, 19, 531, 267, 5935, 275, 291, 423, 912, 63, 493, 8, 5252, 9, 267, 1834, 275, 5935, 59, 16, 61, 267, 702, 1834, 423, 362, 63, 6453, 2645, 63, 354, 8, 288, 1834, 14, 1017, 807, 14, 3491, 9440, 9, 508, 298, 5100, 41, 377, 825, 3540, 73, 2, 339, 347, 511, 63, 362, 63, 602, 8, 277, 304, 267, 702, 291, 14, 1569, 785, 423, 362, 63, 602, 480, 845, 15, 969, 15, 9261, 531, 508, 298, 9261, 13, 845, 13, 969, 2, 339, 347, 511, 63, 362, 63, 521, 8, 277, 304, 267, 702, 291, 14, 1569, 785, 423, 362, 63, 521, 480, 22, 26, 1367, 26, 1401, 14207, 531, 508, 298, 1085, 26, 1367, 26, 1401, 2, 339, 347, 511, 63, 1122, 63, 875, 8, 277, 304, 267, 702, 291, 14, 1569, 785, 423, 1122, 63, 875, 10804, 365, 488, 267, 702, 291, 14, 1569, 785, 423, 1122, 63, 875, 480, 875, 531, 365, 298, 875, 2, 421, 199, 318, 511, 63, 4752, 63, 1450, 837, 272, 6748, 275, 747, 14, 515, 14, 904, 8, 12339, 63, 3243, 12, 298, 6428, 19, 63, 18, 36, 63, 576, 401, 586, 298, 396, 63, 3028, 6156, 63, 3401, 63, 2969, 63, 10649, 14, 6428, 19, 531, 272, 308, 275, 2248, 8, 5252, 9, 272, 6128, 275, 308, 14, 2343, 272, 702, 63, 7520, 8, 1064, 14, 1945, 21523, 63, 13321, 14, 22057, 14, 14529, 63, 8443, 12, 1926, 14, 16, 9, 272, 702, 63, 7520, 8, 1064, 14, 1945, 21523, 63, 13321, 14, 22057, 14, 18425, 14, 28480, 12, 378, 14, 18, 9, 272, 702, 6128, 14, 14109, 14, 602, 508, 298, 7280, 13, 1780, 13, 1643, 2, 272, 702, 6128, 14, 14109, 14, 521, 508, 298, 1085, 26, 1367, 26, 1401, 2, 272, 702, 6128, 14, 14109, 14, 1213, 508, 298, 396, 63, 3028, 6156, 63, 3401, 63, 2969, 63, 10649, 2, 421, 199, 318, 511, 63, 739, 63, 22057, 63, 2343, 837, 272, 6748, 275, 747, 14, 515, 14, 904, 8, 12339, 63, 3243, 12, 298, 29119, 63, 1725, 401, 298, 396, 63, 6428, 63, 1569, 63, 453, 63, 3248, 14, 6428, 19, 531, 272, 308, 275, 2248, 8, 5252, 9, 272, 6128, 275, 308, 14, 2343, 272, 702, 6128, 14, 1945, 21523, 63, 13321, 14, 22057, 14, 645, 21523, 63, 632, 508, 298, 22057, 2, 272, 702, 63, 7520, 8, 1064, 14, 1945, 21523, 63, 13321, 14, 22057, 14, 14529, 63, 8443, 12, 1926, 14, 16, 9, 272, 702, 63, 7520, 8, 1064, 14, 1945, 21523, 63, 13321, 14, 22057, 14, 18425, 14, 28480, 12, 378, 14, 21, 9, 272, 702, 63, 7520, 8, 1064, 14, 1945, 21523, 63, 13321, 14, 22057, 14, 19902, 7313, 12, 8026, 14, 16, 9, 272, 702, 6128, 14, 1945, 21523, 63, 13321, 14, 22057, 14, 6453, 2645, 508, 298, 5100, 41, 377, 825, 3540, 73, 2, 272, 702, 6128, 14, 14109, 14, 602, 508, 298, 7806, 13, 1780, 13, 1165, 2, 272, 702, 6128, 14, 14109, 14, 5043, 63, 1501, 508, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ioanpocol/superdesk-core
apps/ldap/commands.py
1
3036
# -*- coding: utf-8; -*- # # This file is part of Superdesk. # # Copyright 2013, 2014 Sourcefabric z.u. and contributors. # # For the full copyright and license information, please see the # AUTHORS and LICENSE files distributed with this source code, or # at https://www.sourcefabric.org/superdesk/license import logging from flask import current_app as app from superdesk.errors import SuperdeskApiError import superdesk from .ldap import ADAuth, add_default_values, get_user_query logger = logging.getLogger(__name__) class ImportUserProfileFromADCommand(superdesk.Command): """Responsible for importing a user profile from Active Directory (AD) to Mongo. This command runs on assumption that the user executing this command and the user whose profile need to be imported need not to be the same. Uses ad_username and ad_password to bind to AD and then searches for a user identified by username_to_import and if found imports into Mongo. Example: :: $ python manage.py users:copyfromad --ad_username=ad_uname --ad_password=123 --username_to_import=admin """ option_list = ( superdesk.Option('--ad_username', '-adu', dest='ad_username', required=True), superdesk.Option('--ad_password', '-adp', dest='ad_password', required=True), superdesk.Option('--username_to_import', '-u', dest='username', required=True), superdesk.Option('--admin', '-a', dest='admin', required=False), ) def run(self, ad_username, ad_password, username, admin='false'): """Imports or Updates a User Profile from AD to Mongo. :param ad_username: Active Directory Username :param ad_password: Password of Active Directory Username :param username: Username as in Active Directory whose profile needs to be imported to Superdesk. :return: User Profile. """ # force type conversion to boolean user_type = 'administrator' if admin is not None and admin.lower() == 'true' else 'user' # Authenticate and fetch profile from AD settings = app.settings ad_auth = ADAuth(settings['LDAP_SERVER'], settings['LDAP_SERVER_PORT'], settings['LDAP_BASE_FILTER'], settings['LDAP_USER_FILTER'], settings['LDAP_USER_ATTRIBUTES'], settings['LDAP_FQDN']) user_data = ad_auth.authenticate_and_fetch_profile(ad_username, ad_password, username) if len(user_data) == 0: raise SuperdeskApiError.notFoundError('Username not found') # Check if User Profile already exists in Mongo user = superdesk.get_resource_service('users').find_one(req=None, **get_user_query(username)) if user: superdesk.get_resource_service('users').patch(user.get('_id'), user_data) else: add_default_values(user_data, username, user_type=user_type) superdesk.get_resource_service('users').post([user_data]) return user_data superdesk.command('users:copyfromad', ImportUserProfileFromADCommand())
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 27, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 17897, 10368, 14, 199, 3, 199, 3, 1898, 6171, 12, 6927, 5800, 4991, 1315, 14, 85, 14, 436, 8417, 14, 199, 3, 199, 3, 2104, 314, 2615, 4248, 436, 4190, 2556, 12, 8749, 1937, 314, 199, 3, 10610, 436, 5113, 1584, 1854, 543, 642, 1350, 1233, 12, 503, 199, 3, 737, 4178, 921, 1544, 14, 1365, 4991, 14, 1308, 15, 4792, 10368, 15, 1682, 199, 199, 646, 2050, 199, 504, 7209, 492, 1453, 63, 571, 465, 1145, 199, 504, 1613, 10368, 14, 2550, 492, 17897, 10368, 7394, 547, 199, 646, 1613, 10368, 199, 504, 1275, 9642, 492, 16271, 2817, 12, 1050, 63, 885, 63, 1459, 12, 664, 63, 751, 63, 1131, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 3161, 23544, 2532, 1554, 3110, 8, 4792, 10368, 14, 3110, 304, 272, 408, 1322, 678, 1164, 367, 16306, 282, 922, 4690, 687, 23241, 15191, 334, 1554, 9, 370, 13503, 14, 339, 961, 1414, 7858, 641, 30075, 626, 314, 922, 14043, 642, 1414, 436, 272, 314, 922, 7447, 4690, 1929, 370, 506, 8439, 1929, 440, 370, 506, 314, 2011, 14, 14911, 1503, 63, 2473, 436, 1503, 63, 2060, 370, 5398, 370, 16271, 272, 436, 2066, 21858, 367, 282, 922, 15836, 701, 3434, 63, 475, 63, 646, 436, 340, 1911, 8925, 1901, 13503, 14, 339, 5679, 26, 272, 3800, 398, 2672, 2366, 9635, 14, 647, 4390, 26, 1574, 504, 350, 1553, 350, 63, 2473, 29, 350, 63, 16040, 1553, 350, 63, 2060, 29, 4288, 1553, 2473, 63, 475, 63, 646, 29, 2113, 272, 408, 339, 945, 63, 513, 275, 334, 267, 1613, 10368, 14, 2602, 4517, 350, 63, 2473, 297, 2475, 350, 85, 297, 2053, 534, 350, 63, 2473, 297, 1415, 29, 549, 395, 267, 1613, 10368, 14, 2602, 4517, 350, 63, 2060, 297, 2475, 350, 80, 297, 2053, 534, 350, 63, 2060, 297, 1415, 29, 549, 395, 267, 1613, 10368, 14, 2602, 4517, 2473, 63, 475, 63, 646, 297, 2475, 85, 297, 2053, 534, 2473, 297, 1415, 29, 549, 395, 267, 1613, 10368, 14, 2602, 4517, 2113, 297, 2475, 65, 297, 2053, 534, 2113, 297, 1415, 29, 797, 395, 272, 776, 339, 347, 1255, 8, 277, 12, 1503, 63, 2473, 12, 1503, 63, 2060, 12, 3434, 12, 4628, 534, 3910, 735, 267, 408, 32447, 503, 24663, 282, 2876, 14386, 687, 16271, 370, 13503, 14, 398, 520, 635, 1503, 63, 2473, 26, 23241, 15191, 29739, 267, 520, 635, 1503, 63, 2060, 26, 13635, 402, 23241, 15191, 29739, 267, 520, 635, 3434, 26, 29739, 465, 315, 23241, 15191, 7447, 4690, 4839, 370, 506, 8439, 370, 17897, 10368, 14, 267, 520, 1107, 26, 2876, 14386, 14, 267, 408, 398, 327, 3542, 730, 8603, 370, 5046, 267, 922, 63, 466, 275, 283, 2113, 14710, 7, 340, 4628, 365, 440, 488, 436, 4628, 14, 2325, 342, 508, 283, 2052, 7, 587, 283, 751, 7, 398, 327, 3590, 7672, 436, 5267, 4690, 687, 16271, 267, 2202, 275, 1145, 14, 1751, 267, 1503, 63, 1178, 275, 16271, 2817, 8, 1751, 459, 19534, 63, 6613, 995, 2202, 459, 19534, 63, 6613, 63, 3657, 995, 2202, 459, 19534, 63, 5825, 63, 9905, 995, 586, 2202, 459, 19534, 63, 3791, 63, 9905, 995, 2202, 459, 19534, 63, 3791, 63, 18166, 995, 2202, 459, 19534, 63, 27629, 10872, 1105, 398, 922, 63, 576, 275, 1503, 63, 1178, 14, 13975, 63, 460, 63, 3535, 63, 2913, 8, 350, 63, 2473, 12, 1503, 63, 2060, 12, 3434, 9, 398, 340, 822, 8, 751, 63, 576, 9, 508, 378, 26, 288, 746, 17897, 10368, 7394, 547, 14, 1397, 3601, 547, 360, 13355, 440, 1911, 358, 398, 327, 2670, 340, 2876, 14386, 2575, 3495, 315, 13503, 267, 922, 275, 1613, 10368, 14, 362, 63, 1927, 63, 1364, 360, 3707, 1959, 1623, 63, 368, 8, 2103, 29, 403, 12, 1011, 362, 63, 751, 63, 1131, 8, 2473, 430, 398, 340, 922, 26, 288, 1613, 10368, 14, 362, 63, 1927, 63, 1364, 360, 3707, 1959, 2068, 8, 751, 14, 362, 6412, 344, 659, 922, 63, 576, 9, 267, 587, 26, 288, 1050, 63, 885, 63, 1459, 8, 751, 63, 576, 12, 3434, 12, 922, 63, 466, 29, 751, 63, 466, 9, 288, 1613, 10368, 14, 362, 63, 1927, 63, 1364, 360, 3707, 1959, 1932, 779, 751, 63, 576, 566, 398, 372, 922, 63, 576, 421, 199, 4792, 10368, 14, 1531, 360, 3707, 26, 1574, 504, 350, 297, 3161, 23544, 2532, 1554, 3110, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 27, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 17897, 10368, 14, 199, 3, 199, 3, 1898, 6171, 12, 6927, 5800, 4991, 1315, 14, 85, 14, 436, 8417, 14, 199, 3, 199, 3, 2104, 314, 2615, 4248, 436, 4190, 2556, 12, 8749, 1937, 314, 199, 3, 10610, 436, 5113, 1584, 1854, 543, 642, 1350, 1233, 12, 503, 199, 3, 737, 4178, 921, 1544, 14, 1365, 4991, 14, 1308, 15, 4792, 10368, 15, 1682, 199, 199, 646, 2050, 199, 504, 7209, 492, 1453, 63, 571, 465, 1145, 199, 504, 1613, 10368, 14, 2550, 492, 17897, 10368, 7394, 547, 199, 646, 1613, 10368, 199, 504, 1275, 9642, 492, 16271, 2817, 12, 1050, 63, 885, 63, 1459, 12, 664, 63, 751, 63, 1131, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 3161, 23544, 2532, 1554, 3110, 8, 4792, 10368, 14, 3110, 304, 272, 408, 1322, 678, 1164, 367, 16306, 282, 922, 4690, 687, 23241, 15191, 334, 1554, 9, 370, 13503, 14, 339, 961, 1414, 7858, 641, 30075, 626, 314, 922, 14043, 642, 1414, 436, 272, 314, 922, 7447, 4690, 1929, 370, 506, 8439, 1929, 440, 370, 506, 314, 2011, 14, 14911, 1503, 63, 2473, 436, 1503, 63, 2060, 370, 5398, 370, 16271, 272, 436, 2066, 21858, 367, 282, 922, 15836, 701, 3434, 63, 475, 63, 646, 436, 340, 1911, 8925, 1901, 13503, 14, 339, 5679, 26, 272, 3800, 398, 2672, 2366, 9635, 14, 647, 4390, 26, 1574, 504, 350, 1553, 350, 63, 2473, 29, 350, 63, 16040, 1553, 350, 63, 2060, 29, 4288, 1553, 2473, 63, 475, 63, 646, 29, 2113, 272, 408, 339, 945, 63, 513, 275, 334, 267, 1613, 10368, 14, 2602, 4517, 350, 63, 2473, 297, 2475, 350, 85, 297, 2053, 534, 350, 63, 2473, 297, 1415, 29, 549, 395, 267, 1613, 10368, 14, 2602, 4517, 350, 63, 2060, 297, 2475, 350, 80, 297, 2053, 534, 350, 63, 2060, 297, 1415, 29, 549, 395, 267, 1613, 10368, 14, 2602, 4517, 2473, 63, 475, 63, 646, 297, 2475, 85, 297, 2053, 534, 2473, 297, 1415, 29, 549, 395, 267, 1613, 10368, 14, 2602, 4517, 2113, 297, 2475, 65, 297, 2053, 534, 2113, 297, 1415, 29, 797, 395, 272, 776, 339, 347, 1255, 8, 277, 12, 1503, 63, 2473, 12, 1503, 63, 2060, 12, 3434, 12, 4628, 534, 3910, 735, 267, 408, 32447, 503, 24663, 282, 2876, 14386, 687, 16271, 370, 13503, 14, 398, 520, 635, 1503, 63, 2473, 26, 23241, 15191, 29739, 267, 520, 635, 1503, 63, 2060, 26, 13635, 402, 23241, 15191, 29739, 267, 520, 635, 3434, 26, 29739, 465, 315, 23241, 15191, 7447, 4690, 4839, 370, 506, 8439, 370, 17897, 10368, 14, 267, 520, 1107, 26, 2876, 14386, 14, 267, 408, 398, 327, 3542, 730, 8603, 370, 5046, 267, 922, 63, 466, 275, 283, 2113, 14710, 7, 340, 4628, 365, 440, 488, 436, 4628, 14, 2325, 342, 508, 283, 2052, 7, 587, 283, 751, 7, 398, 327, 3590, 7672, 436, 5267, 4690, 687, 16271, 267, 2202, 275, 1145, 14, 1751, 267, 1503, 63, 1178, 275, 16271, 2817, 8, 1751, 459, 19534, 63, 6613, 995, 2202, 459, 19534, 63, 6613, 63, 3657, 995, 2202, 459, 19534, 63, 5825, 63, 9905, 995, 586, 2202, 459, 19534, 63, 3791, 63, 9905, 995, 2202, 459, 19534, 63, 3791, 63, 18166, 995, 2202, 459, 19534, 63, 27629, 10872, 1105, 398, 922, 63, 576, 275, 1503, 63, 1178, 14, 13975, 63, 460, 63, 3535, 63, 2913, 8, 350, 63, 2473, 12, 1503, 63, 2060, 12, 3434, 9, 398, 340, 822, 8, 751, 63, 576, 9, 508, 378, 26, 288, 746, 17897, 10368, 7394, 547, 14, 1397, 3601, 547, 360, 13355, 440, 1911, 358, 398, 327, 2670, 340, 2876, 14386, 2575, 3495, 315, 13503, 267, 922, 275, 1613, 10368, 14, 362, 63, 1927, 63, 1364, 360, 3707, 1959, 1623, 63, 368, 8, 2103, 29, 403, 12, 1011, 362, 63, 751, 63, 1131, 8, 2473, 430, 398, 340, 922, 26, 288, 1613, 10368, 14, 362, 63, 1927, 63, 1364, 360, 3707, 1959, 2068, 8, 751, 14, 362, 6412, 344, 659, 922, 63, 576, 9, 267, 587, 26, 288, 1050, 63, 885, 63, 1459, 8, 751, 63, 576, 12, 3434, 12, 922, 63, 466, 29, 751, 63, 466, 9, 288, 1613, 10368, 14, 362, 63, 1927, 63, 1364, 360, 3707, 1959, 1932, 779, 751, 63, 576, 566, 398, 372, 922, 63, 576, 421, 199, 4792, 10368, 14, 1531, 360, 3707, 26, 1574, 504, 350, 297, 3161, 23544, 2532, 1554, 3110, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bonitadecker77/python-for-android
python-modules/twisted/twisted/words/im/ircsupport.py
49
9263
# Copyright (c) 2001-2010 Twisted Matrix Laboratories. # See LICENSE for details. """ IRC support for Instance Messenger. """ import string from twisted.words.protocols import irc from twisted.words.im.locals import ONLINE from twisted.internet import defer, reactor, protocol from twisted.internet.defer import succeed from twisted.words.im import basesupport, interfaces, locals from zope.interface import implements class IRCPerson(basesupport.AbstractPerson): def imperson_whois(self): if self.account.client is None: raise locals.OfflineError self.account.client.sendLine("WHOIS %s" % self.name) ### interface impl def isOnline(self): return ONLINE def getStatus(self): return ONLINE def setStatus(self,status): self.status=status self.chat.getContactsList().setContactStatus(self) def sendMessage(self, text, meta=None): if self.account.client is None: raise locals.OfflineError for line in string.split(text, '\n'): if meta and meta.get("style", None) == "emote": self.account.client.ctcpMakeQuery(self.name,[('ACTION', line)]) else: self.account.client.msg(self.name, line) return succeed(text) class IRCGroup(basesupport.AbstractGroup): implements(interfaces.IGroup) def imgroup_testAction(self): pass def imtarget_kick(self, target): if self.account.client is None: raise locals.OfflineError reason = "for great justice!" self.account.client.sendLine("KICK #%s %s :%s" % ( self.name, target.name, reason)) ### Interface Implementation def setTopic(self, topic): if self.account.client is None: raise locals.OfflineError self.account.client.topic(self.name, topic) def sendGroupMessage(self, text, meta={}): if self.account.client is None: raise locals.OfflineError if meta and meta.get("style", None) == "emote": self.account.client.me(self.name,text) return succeed(text) #standard shmandard, clients don't support plain escaped newlines! for line in string.split(text, '\n'): self.account.client.say(self.name, line) return succeed(text) def leave(self): if self.account.client is None: raise locals.OfflineError self.account.client.leave(self.name) self.account.client.getGroupConversation(self.name,1) class IRCProto(basesupport.AbstractClientMixin, irc.IRCClient): def __init__(self, account, chatui, logonDeferred=None): basesupport.AbstractClientMixin.__init__(self, account, chatui, logonDeferred) self._namreplies={} self._ingroups={} self._groups={} self._topics={} def getGroupConversation(self, name, hide=0): name=string.lower(name) return self.chat.getGroupConversation(self.chat.getGroup(name, self), stayHidden=hide) def getPerson(self,name): return self.chat.getPerson(name, self) def connectionMade(self): # XXX: Why do I duplicate code in IRCClient.register? try: if self.account.password: self.sendLine("PASS :%s" % self.account.password) self.setNick(self.account.username) self.sendLine("USER %s foo bar :Twisted-IM user" % ( self.account.username,)) for channel in self.account.channels: self.joinGroup(channel) self.account._isOnline=1 if self._logonDeferred is not None: self._logonDeferred.callback(self) self.chat.getContactsList() except: import traceback traceback.print_exc() def setNick(self,nick): self.name=nick self.accountName="%s (IRC)"%nick irc.IRCClient.setNick(self,nick) def kickedFrom(self, channel, kicker, message): """ Called when I am kicked from a channel. """ return self.chat.getGroupConversation( self.chat.getGroup(channel[1:], self), 1) def userKicked(self, kickee, channel, kicker, message): pass def noticed(self, username, channel, message): self.privmsg(username, channel, message, {"dontAutoRespond": 1}) def privmsg(self, username, channel, message, metadata=None): if metadata is None: metadata = {} username=string.split(username,'!',1)[0] if username==self.name: return if channel[0]=='#': group=channel[1:] self.getGroupConversation(group).showGroupMessage(username, message, metadata) return self.chat.getConversation(self.getPerson(username)).showMessage(message, metadata) def action(self,username,channel,emote): username=string.split(username,'!',1)[0] if username==self.name: return meta={'style':'emote'} if channel[0]=='#': group=channel[1:] self.getGroupConversation(group).showGroupMessage(username, emote, meta) return self.chat.getConversation(self.getPerson(username)).showMessage(emote,meta) def irc_RPL_NAMREPLY(self,prefix,params): """ RPL_NAMREPLY >> NAMES #bnl << :Arlington.VA.US.Undernet.Org 353 z3p = #bnl :pSwede Dan-- SkOyg AG """ group=string.lower(params[2][1:]) users=string.split(params[3]) for ui in range(len(users)): while users[ui][0] in ["@","+"]: # channel modes users[ui]=users[ui][1:] if not self._namreplies.has_key(group): self._namreplies[group]=[] self._namreplies[group].extend(users) for nickname in users: try: self._ingroups[nickname].append(group) except: self._ingroups[nickname]=[group] def irc_RPL_ENDOFNAMES(self,prefix,params): group=params[1][1:] self.getGroupConversation(group).setGroupMembers(self._namreplies[string.lower(group)]) del self._namreplies[string.lower(group)] def irc_RPL_TOPIC(self,prefix,params): self._topics[params[1][1:]]=params[2] def irc_333(self,prefix,params): group=params[1][1:] self.getGroupConversation(group).setTopic(self._topics[group],params[2]) del self._topics[group] def irc_TOPIC(self,prefix,params): nickname = string.split(prefix,"!")[0] group = params[0][1:] topic = params[1] self.getGroupConversation(group).setTopic(topic,nickname) def irc_JOIN(self,prefix,params): nickname=string.split(prefix,"!")[0] group=string.lower(params[0][1:]) if nickname!=self.nickname: try: self._ingroups[nickname].append(group) except: self._ingroups[nickname]=[group] self.getGroupConversation(group).memberJoined(nickname) def irc_PART(self,prefix,params): nickname=string.split(prefix,"!")[0] group=string.lower(params[0][1:]) if nickname!=self.nickname: if group in self._ingroups[nickname]: self._ingroups[nickname].remove(group) self.getGroupConversation(group).memberLeft(nickname) def irc_QUIT(self,prefix,params): nickname=string.split(prefix,"!")[0] if self._ingroups.has_key(nickname): for group in self._ingroups[nickname]: self.getGroupConversation(group).memberLeft(nickname) self._ingroups[nickname]=[] def irc_NICK(self, prefix, params): fromNick = string.split(prefix, "!")[0] toNick = params[0] if not self._ingroups.has_key(fromNick): return for group in self._ingroups[fromNick]: self.getGroupConversation(group).memberChangedNick(fromNick, toNick) self._ingroups[toNick] = self._ingroups[fromNick] del self._ingroups[fromNick] def irc_unknown(self, prefix, command, params): pass # GTKIM calls def joinGroup(self,name): self.join(name) self.getGroupConversation(name) class IRCAccount(basesupport.AbstractAccount): implements(interfaces.IAccount) gatewayType = "IRC" _groupFactory = IRCGroup _personFactory = IRCPerson def __init__(self, accountName, autoLogin, username, password, host, port, channels=''): basesupport.AbstractAccount.__init__(self, accountName, autoLogin, username, password, host, port) self.channels = map(string.strip,string.split(channels,',')) if self.channels == ['']: self.channels = [] def _startLogOn(self, chatui): logonDeferred = defer.Deferred() cc = protocol.ClientCreator(reactor, IRCProto, self, chatui, logonDeferred) d = cc.connectTCP(self.host, self.port) d.addErrback(logonDeferred.errback) return logonDeferred
apache-2.0
[ 3, 1898, 334, 67, 9, 12521, 13, 6542, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 3927, 35, 2291, 367, 10066, 603, 397, 23444, 14, 199, 624, 199, 199, 646, 1059, 199, 199, 504, 7390, 14, 3148, 14, 16541, 492, 22157, 199, 504, 7390, 14, 3148, 14, 1017, 14, 9350, 492, 5258, 6174, 199, 504, 7390, 14, 4901, 492, 10133, 12, 9655, 12, 4113, 199, 504, 7390, 14, 4901, 14, 11610, 492, 17961, 199, 504, 7390, 14, 3148, 14, 1017, 492, 1300, 4058, 12, 8386, 12, 9480, 199, 504, 20110, 14, 3266, 492, 9031, 421, 199, 533, 473, 8205, 7344, 8, 1095, 4058, 14, 8458, 7344, 304, 339, 347, 1742, 21649, 63, 11345, 374, 8, 277, 304, 267, 340, 291, 14, 2048, 14, 1258, 365, 488, 26, 288, 746, 9480, 14, 5195, 604, 547, 267, 291, 14, 2048, 14, 1258, 14, 2254, 3049, 480, 55, 2979, 1311, 450, 83, 2, 450, 291, 14, 354, 9, 339, 6754, 3217, 11512, 339, 347, 365, 28587, 8, 277, 304, 267, 372, 5258, 6174, 339, 347, 664, 3694, 8, 277, 304, 267, 372, 5258, 6174, 339, 347, 663, 3694, 8, 277, 12, 1205, 304, 267, 291, 14, 1205, 29, 1205, 267, 291, 14, 10289, 14, 362, 714, 11961, 1296, 1252, 409, 14499, 3694, 8, 277, 9, 339, 347, 3222, 2209, 8, 277, 12, 1318, 12, 3404, 29, 403, 304, 267, 340, 291, 14, 2048, 14, 1258, 365, 488, 26, 288, 746, 9480, 14, 5195, 604, 547, 267, 367, 1004, 315, 1059, 14, 1294, 8, 505, 12, 1557, 78, 735, 288, 340, 3404, 436, 3404, 14, 362, 480, 2487, 401, 488, 9, 508, 298, 69, 2137, 582, 355, 291, 14, 2048, 14, 1258, 14, 319, 1850, 5483, 3227, 8, 277, 14, 354, 14343, 360, 10052, 297, 1004, 3948, 288, 587, 26, 355, 291, 14, 2048, 14, 1258, 14, 1328, 8, 277, 14, 354, 12, 1004, 9, 267, 372, 17961, 8, 505, 9, 199, 199, 533, 473, 8205, 2448, 8, 1095, 4058, 14, 8458, 2448, 304, 339, 9031, 8, 7436, 14, 1277, 684, 9, 339, 347, 3416, 923, 63, 396, 3310, 8, 277, 304, 267, 986, 339, 347, 3416, 1375, 63, 31257, 8, 277, 12, 1347, 304, 267, 340, 291, 14, 2048, 14, 1258, 365, 488, 26, 288, 746, 9480, 14, 5195, 604, 547, 267, 4499, 275, 298, 509, 27254, 2951, 1885, 9539, 267, 291, 14, 2048, 14, 1258, 14, 2254, 3049, 480, 43, 13884, 24307, 83, 450, 83, 520, 5, 83, 2, 450, 334, 288, 291, 14, 354, 12, 1347, 14, 354, 12, 4499, 430, 339, 6754, 14816, 24425, 339, 347, 663, 12157, 8, 277, 12, 7482, 304, 267, 340, 291, 14, 2048, 14, 1258, 365, 488, 26, 288, 746, 9480, 14, 5195, 604, 547, 267, 291, 14, 2048, 14, 1258, 14, 5746, 8, 277, 14, 354, 12, 7482, 9, 339, 347, 3222, 2448, 2209, 8, 277, 12, 1318, 12, 3404, 16420, 267, 340, 291, 14, 2048, 14, 1258, 365, 488, 26, 288, 746, 9480, 14, 5195, 604, 547, 267, 340, 3404, 436, 3404, 14, 362, 480, 2487, 401, 488, 9, 508, 298, 69, 2137, 582, 288, 291, 14, 2048, 14, 1258, 14, 278, 8, 277, 14, 354, 12, 505, 9, 288, 372, 17961, 8, 505, 9, 267, 327, 6807, 1033, 77, 2814, 12, 13431, 2793, 1133, 2291, 8971, 11077, 14930, 1, 267, 367, 1004, 315, 1059, 14, 1294, 8, 505, 12, 1557, 78, 735, 288, 291, 14, 2048, 14, 1258, 14, 19787, 8, 277, 14, 354, 12, 1004, 9, 267, 372, 17961, 8, 505, 9, 339, 347, 10137, 8, 277, 304, 267, 340, 291, 14, 2048, 14, 1258, 365, 488, 26, 288, 746, 9480, 14, 5195, 604, 547, 267, 291, 14, 2048, 14, 1258, 14, 12422, 8, 277, 14, 354, 9, 267, 291, 14, 2048, 14, 1258, 14, 362, 2448, 7619, 20592, 8, 277, 14, 354, 12, 17, 9, 421, 199, 533, 473, 8205, 8548, 8, 1095, 4058, 14, 8458, 3041, 4256, 12, 22157, 14, 3927, 2571, 864, 304, 272, 347, 636, 826, 721, 277, 12, 2933, 12, 21472, 1907, 12, 943, 265, 9937, 29, 403, 304, 267, 1300, 4058, 14, 8458, 3041, 4256, 855, 826, 721, 277, 12, 2933, 12, 21472, 1907, 12, 1740, 943, 265, 9937, 9, 267, 291, 423, 17811, 1155, 6528, 7622, 267, 291, 423, 316, 684, 83, 7622, 267, 291, 423, 2634, 7622, 267, 291, 423, 11299, 7622, 339, 347, 664, 2448, 7619, 20592, 8, 277, 12, 536, 12, 13714, 29, 16, 304, 267, 536, 29, 875, 14, 2325, 8, 354, 9, 267, 372, 291, 14, 10289, 14, 362, 2448, 7619, 20592, 8, 277, 14, 10289, 14, 362, 2448, 8, 354, 12, 291, 395, 6343, 25578, 14983, 29, 8191, 9, 339, 347, 664, 7344, 8, 277, 12, 354, 304, 267, 372, 291, 14, 10289, 14, 362, 7344, 8, 354, 12, 291, 9, 339, 347, 1950, 26973, 8, 277, 304, 267, 327, 5787, 26, 6827, 886, 473, 9250, 1233, 315, 473, 50, 2571, 864, 14, 2683, 31, 267, 862, 26, 288, 340, 291, 14, 2048, 14, 2060, 26, 355, 291, 14, 2254, 3049, 480, 6909, 520, 5, 83, 2, 450, 291, 14, 2048, 14, 2060, 9, 288, 291, 14, 409, 32172, 8, 277, 14, 2048, 14, 2473, 9, 288, 291, 14, 2254, 3049, 480, 3791, 450, 83, 3925, 4681, 520, 52, 5221, 13, 1469, 922, 2, 450, 334, 355, 291, 14, 2048, 14, 2473, 4641, 288, 367, 3623, 315, 291, 14, 2048, 14, 6324, 26, 355, 291, 14, 904, 2448, 8, 2775, 9, 288, 291, 14, 2048, 423, 374, 28587, 29, 17, 288, 340, 291, 423, 793, 265, 9937, 365, 440, 488, 26, 355, 291, 423, 793, 265, 9937, 14, 3058, 8, 277, 9, 288, 291, 14, 10289, 14, 362, 714, 11961, 1296, 342, 267, 871, 26, 288, 492, 5190, 288, 5190, 14, 1361, 63, 2804, 342, 339, 347, 663, 32172, 8, 277, 12, 11082, 304, 267, 291, 14, 354, 29, 11082, 267, 291, 14, 2048, 985, 5961, 83, 334, 3927, 35, 2924, 5, 11082, 267, 22157, 14, 3927, 2571, 864, 14, 409, 32172, 8, 277, 12, 11082, 9, 339, 347, 29898, 379, 2532, 8, 277, 12, 3623, 12, 29898, 281, 12, 1245, 304, 267, 408, 267 ]
[ 1898, 334, 67, 9, 12521, 13, 6542, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 3927, 35, 2291, 367, 10066, 603, 397, 23444, 14, 199, 624, 199, 199, 646, 1059, 199, 199, 504, 7390, 14, 3148, 14, 16541, 492, 22157, 199, 504, 7390, 14, 3148, 14, 1017, 14, 9350, 492, 5258, 6174, 199, 504, 7390, 14, 4901, 492, 10133, 12, 9655, 12, 4113, 199, 504, 7390, 14, 4901, 14, 11610, 492, 17961, 199, 504, 7390, 14, 3148, 14, 1017, 492, 1300, 4058, 12, 8386, 12, 9480, 199, 504, 20110, 14, 3266, 492, 9031, 421, 199, 533, 473, 8205, 7344, 8, 1095, 4058, 14, 8458, 7344, 304, 339, 347, 1742, 21649, 63, 11345, 374, 8, 277, 304, 267, 340, 291, 14, 2048, 14, 1258, 365, 488, 26, 288, 746, 9480, 14, 5195, 604, 547, 267, 291, 14, 2048, 14, 1258, 14, 2254, 3049, 480, 55, 2979, 1311, 450, 83, 2, 450, 291, 14, 354, 9, 339, 6754, 3217, 11512, 339, 347, 365, 28587, 8, 277, 304, 267, 372, 5258, 6174, 339, 347, 664, 3694, 8, 277, 304, 267, 372, 5258, 6174, 339, 347, 663, 3694, 8, 277, 12, 1205, 304, 267, 291, 14, 1205, 29, 1205, 267, 291, 14, 10289, 14, 362, 714, 11961, 1296, 1252, 409, 14499, 3694, 8, 277, 9, 339, 347, 3222, 2209, 8, 277, 12, 1318, 12, 3404, 29, 403, 304, 267, 340, 291, 14, 2048, 14, 1258, 365, 488, 26, 288, 746, 9480, 14, 5195, 604, 547, 267, 367, 1004, 315, 1059, 14, 1294, 8, 505, 12, 1557, 78, 735, 288, 340, 3404, 436, 3404, 14, 362, 480, 2487, 401, 488, 9, 508, 298, 69, 2137, 582, 355, 291, 14, 2048, 14, 1258, 14, 319, 1850, 5483, 3227, 8, 277, 14, 354, 14343, 360, 10052, 297, 1004, 3948, 288, 587, 26, 355, 291, 14, 2048, 14, 1258, 14, 1328, 8, 277, 14, 354, 12, 1004, 9, 267, 372, 17961, 8, 505, 9, 199, 199, 533, 473, 8205, 2448, 8, 1095, 4058, 14, 8458, 2448, 304, 339, 9031, 8, 7436, 14, 1277, 684, 9, 339, 347, 3416, 923, 63, 396, 3310, 8, 277, 304, 267, 986, 339, 347, 3416, 1375, 63, 31257, 8, 277, 12, 1347, 304, 267, 340, 291, 14, 2048, 14, 1258, 365, 488, 26, 288, 746, 9480, 14, 5195, 604, 547, 267, 4499, 275, 298, 509, 27254, 2951, 1885, 9539, 267, 291, 14, 2048, 14, 1258, 14, 2254, 3049, 480, 43, 13884, 24307, 83, 450, 83, 520, 5, 83, 2, 450, 334, 288, 291, 14, 354, 12, 1347, 14, 354, 12, 4499, 430, 339, 6754, 14816, 24425, 339, 347, 663, 12157, 8, 277, 12, 7482, 304, 267, 340, 291, 14, 2048, 14, 1258, 365, 488, 26, 288, 746, 9480, 14, 5195, 604, 547, 267, 291, 14, 2048, 14, 1258, 14, 5746, 8, 277, 14, 354, 12, 7482, 9, 339, 347, 3222, 2448, 2209, 8, 277, 12, 1318, 12, 3404, 16420, 267, 340, 291, 14, 2048, 14, 1258, 365, 488, 26, 288, 746, 9480, 14, 5195, 604, 547, 267, 340, 3404, 436, 3404, 14, 362, 480, 2487, 401, 488, 9, 508, 298, 69, 2137, 582, 288, 291, 14, 2048, 14, 1258, 14, 278, 8, 277, 14, 354, 12, 505, 9, 288, 372, 17961, 8, 505, 9, 267, 327, 6807, 1033, 77, 2814, 12, 13431, 2793, 1133, 2291, 8971, 11077, 14930, 1, 267, 367, 1004, 315, 1059, 14, 1294, 8, 505, 12, 1557, 78, 735, 288, 291, 14, 2048, 14, 1258, 14, 19787, 8, 277, 14, 354, 12, 1004, 9, 267, 372, 17961, 8, 505, 9, 339, 347, 10137, 8, 277, 304, 267, 340, 291, 14, 2048, 14, 1258, 365, 488, 26, 288, 746, 9480, 14, 5195, 604, 547, 267, 291, 14, 2048, 14, 1258, 14, 12422, 8, 277, 14, 354, 9, 267, 291, 14, 2048, 14, 1258, 14, 362, 2448, 7619, 20592, 8, 277, 14, 354, 12, 17, 9, 421, 199, 533, 473, 8205, 8548, 8, 1095, 4058, 14, 8458, 3041, 4256, 12, 22157, 14, 3927, 2571, 864, 304, 272, 347, 636, 826, 721, 277, 12, 2933, 12, 21472, 1907, 12, 943, 265, 9937, 29, 403, 304, 267, 1300, 4058, 14, 8458, 3041, 4256, 855, 826, 721, 277, 12, 2933, 12, 21472, 1907, 12, 1740, 943, 265, 9937, 9, 267, 291, 423, 17811, 1155, 6528, 7622, 267, 291, 423, 316, 684, 83, 7622, 267, 291, 423, 2634, 7622, 267, 291, 423, 11299, 7622, 339, 347, 664, 2448, 7619, 20592, 8, 277, 12, 536, 12, 13714, 29, 16, 304, 267, 536, 29, 875, 14, 2325, 8, 354, 9, 267, 372, 291, 14, 10289, 14, 362, 2448, 7619, 20592, 8, 277, 14, 10289, 14, 362, 2448, 8, 354, 12, 291, 395, 6343, 25578, 14983, 29, 8191, 9, 339, 347, 664, 7344, 8, 277, 12, 354, 304, 267, 372, 291, 14, 10289, 14, 362, 7344, 8, 354, 12, 291, 9, 339, 347, 1950, 26973, 8, 277, 304, 267, 327, 5787, 26, 6827, 886, 473, 9250, 1233, 315, 473, 50, 2571, 864, 14, 2683, 31, 267, 862, 26, 288, 340, 291, 14, 2048, 14, 2060, 26, 355, 291, 14, 2254, 3049, 480, 6909, 520, 5, 83, 2, 450, 291, 14, 2048, 14, 2060, 9, 288, 291, 14, 409, 32172, 8, 277, 14, 2048, 14, 2473, 9, 288, 291, 14, 2254, 3049, 480, 3791, 450, 83, 3925, 4681, 520, 52, 5221, 13, 1469, 922, 2, 450, 334, 355, 291, 14, 2048, 14, 2473, 4641, 288, 367, 3623, 315, 291, 14, 2048, 14, 6324, 26, 355, 291, 14, 904, 2448, 8, 2775, 9, 288, 291, 14, 2048, 423, 374, 28587, 29, 17, 288, 340, 291, 423, 793, 265, 9937, 365, 440, 488, 26, 355, 291, 423, 793, 265, 9937, 14, 3058, 8, 277, 9, 288, 291, 14, 10289, 14, 362, 714, 11961, 1296, 342, 267, 871, 26, 288, 492, 5190, 288, 5190, 14, 1361, 63, 2804, 342, 339, 347, 663, 32172, 8, 277, 12, 11082, 304, 267, 291, 14, 354, 29, 11082, 267, 291, 14, 2048, 985, 5961, 83, 334, 3927, 35, 2924, 5, 11082, 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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 ]
joeythesaint/yocto-autobuilder
lib/python2.7/site-packages/buildbot-0.8.8-py2.7.egg/buildbot/buildslave/base.py
4
42257
# This file is part of Buildbot. Buildbot is free software: you can # redistribute it and/or modify it under the terms of the GNU General Public # License as published by the Free Software Foundation, version 2. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # Portions Copyright Buildbot Team Members # Portions Copyright Canonical Ltd. 2009 import time from email.Message import Message from email.Utils import formatdate from zope.interface import implements from twisted.python import log from twisted.internet import defer, reactor from twisted.application import service from twisted.spread import pb from twisted.python.reflect import namedModule from buildbot.status.slave import SlaveStatus from buildbot.status.mail import MailNotifier from buildbot.process import metrics, botmaster from buildbot.interfaces import IBuildSlave, ILatentBuildSlave from buildbot.process.properties import Properties from buildbot.util import subscription from buildbot.util.eventual import eventually from buildbot import config class AbstractBuildSlave(config.ReconfigurableServiceMixin, pb.Avatar, service.MultiService): """This is the master-side representative for a remote buildbot slave. There is exactly one for each slave described in the config file (the c['slaves'] list). When buildbots connect in (.attach), they get a reference to this instance. The BotMaster object is stashed as the .botmaster attribute. The BotMaster is also our '.parent' Service. I represent a build slave -- a remote machine capable of running builds. I am instantiated by the configuration file, and can be subclassed to add extra functionality.""" implements(IBuildSlave) keepalive_timer = None keepalive_interval = None # reconfig slaves after builders reconfig_priority = 64 def __init__(self, name, password, max_builds=None, notify_on_missing=[], missing_timeout=3600, properties={}, locks=None, keepalive_interval=3600): """ @param name: botname this machine will supply when it connects @param password: password this machine will supply when it connects @param max_builds: maximum number of simultaneous builds that will be run concurrently on this buildslave (the default is None for no limit) @param properties: properties that will be applied to builds run on this slave @type properties: dictionary @param locks: A list of locks that must be acquired before this slave can be used @type locks: dictionary """ service.MultiService.__init__(self) self.slavename = name self.password = password # PB registration self.registration = None self.registered_port = None # these are set when the service is started, and unset when it is # stopped self.botmaster = None self.master = None self.slave_status = SlaveStatus(name) self.slave = None # a RemoteReference to the Bot, when connected self.slave_commands = None self.slavebuilders = {} self.max_builds = max_builds self.access = [] if locks: self.access = locks self.lock_subscriptions = [] self.properties = Properties() self.properties.update(properties, "BuildSlave") self.properties.setProperty("slavename", name, "BuildSlave") self.lastMessageReceived = 0 if isinstance(notify_on_missing, str): notify_on_missing = [notify_on_missing] self.notify_on_missing = notify_on_missing for i in notify_on_missing: if not isinstance(i, str): config.error( 'notify_on_missing arg %r is not a string' % (i,)) self.missing_timeout = missing_timeout self.missing_timer = None self.keepalive_interval = keepalive_interval self.detached_subs = None self._old_builder_list = None def __repr__(self): return "<%s %r>" % (self.__class__.__name__, self.slavename) def updateLocks(self): """Convert the L{LockAccess} objects in C{self.locks} into real lock objects, while also maintaining the subscriptions to lock releases.""" # unsubscribe from any old locks for s in self.lock_subscriptions: s.unsubscribe() # convert locks into their real form locks = [ (self.botmaster.getLockFromLockAccess(a), a) for a in self.access ] self.locks = [(l.getLock(self), la) for l, la in locks] self.lock_subscriptions = [ l.subscribeToReleases(self._lockReleased) for l, la in self.locks ] def locksAvailable(self): """ I am called to see if all the locks I depend on are available, in which I return True, otherwise I return False """ if not self.locks: return True for lock, access in self.locks: if not lock.isAvailable(self, access): return False return True def acquireLocks(self): """ I am called when a build is preparing to run. I try to claim all the locks that are needed for a build to happen. If I can't, then my caller should give up the build and try to get another slave to look at it. """ log.msg("acquireLocks(slave %s, locks %s)" % (self, self.locks)) if not self.locksAvailable(): log.msg("slave %s can't lock, giving up" % (self, )) return False # all locks are available, claim them all for lock, access in self.locks: lock.claim(self, access) return True def releaseLocks(self): """ I am called to release any locks after a build has finished """ log.msg("releaseLocks(%s): %s" % (self, self.locks)) for lock, access in self.locks: lock.release(self, access) def _lockReleased(self): """One of the locks for this slave was released; try scheduling builds.""" if not self.botmaster: return # oh well.. self.botmaster.maybeStartBuildsForSlave(self.slavename) def setServiceParent(self, parent): # botmaster needs to set before setServiceParent which calls startService self.botmaster = parent self.master = parent.master service.MultiService.setServiceParent(self, parent) def startService(self): self.updateLocks() self.startMissingTimer() return service.MultiService.startService(self) @defer.inlineCallbacks def reconfigService(self, new_config): # Given a new BuildSlave, configure this one identically. Because # BuildSlave objects are remotely referenced, we can't replace them # without disconnecting the slave, yet there's no reason to do that. new = self.findNewSlaveInstance(new_config) assert self.slavename == new.slavename # do we need to re-register? if (not self.registration or self.password != new.password or new_config.slavePortnum != self.registered_port): if self.registration: yield self.registration.unregister() self.registration = None self.password = new.password self.registered_port = new_config.slavePortnum self.registration = self.master.pbmanager.register( self.registered_port, self.slavename, self.password, self.getPerspective) # adopt new instance's configuration parameters self.max_builds = new.max_builds self.access = new.access self.notify_on_missing = new.notify_on_missing self.keepalive_interval = new.keepalive_interval if self.missing_timeout != new.missing_timeout: running_missing_timer = self.missing_timer self.stopMissingTimer() self.missing_timeout = new.missing_timeout if running_missing_timer: self.startMissingTimer() properties = Properties() properties.updateFromProperties(new.properties) self.properties = properties self.updateLocks() # update the attached slave's notion of which builders are attached. # This assumes that the relevant builders have already been configured, # which is why the reconfig_priority is set low in this class. yield self.updateSlave() yield config.ReconfigurableServiceMixin.reconfigService(self, new_config) def stopService(self): if self.registration: self.registration.unregister() self.registration = None self.stopMissingTimer() return service.MultiService.stopService(self) def findNewSlaveInstance(self, new_config): # TODO: called multiple times per reconfig; use 1-element cache? for sl in new_config.slaves: if sl.slavename == self.slavename: return sl assert 0, "no new slave named '%s'" % self.slavename def startMissingTimer(self): if self.notify_on_missing and self.missing_timeout and self.parent: self.stopMissingTimer() # in case it's already running self.missing_timer = reactor.callLater(self.missing_timeout, self._missing_timer_fired) def stopMissingTimer(self): if self.missing_timer: self.missing_timer.cancel() self.missing_timer = None def getPerspective(self, mind, slavename): assert slavename == self.slavename metrics.MetricCountEvent.log("attached_slaves", 1) # record when this connection attempt occurred if self.slave_status: self.slave_status.recordConnectTime() # try to use TCP keepalives try: mind.broker.transport.setTcpKeepAlive(1) except: pass if self.isConnected(): # duplicate slave - send it to arbitration arb = botmaster.DuplicateSlaveArbitrator(self) return arb.getPerspective(mind, slavename) else: log.msg("slave '%s' attaching from %s" % (slavename, mind.broker.transport.getPeer())) return self def doKeepalive(self): self.keepalive_timer = reactor.callLater(self.keepalive_interval, self.doKeepalive) if not self.slave: return d = self.slave.callRemote("print", "Received keepalive from master") d.addErrback(log.msg, "Keepalive failed for '%s'" % (self.slavename, )) def stopKeepaliveTimer(self): if self.keepalive_timer: self.keepalive_timer.cancel() def startKeepaliveTimer(self): assert self.keepalive_interval log.msg("Starting buildslave keepalive timer for '%s'" % \ (self.slavename, )) self.doKeepalive() def isConnected(self): return self.slave def _missing_timer_fired(self): self.missing_timer = None # notify people, but only if we're still in the config if not self.parent: return buildmaster = self.botmaster.master status = buildmaster.getStatus() text = "The Buildbot working for '%s'\n" % status.getTitle() text += ("has noticed that the buildslave named %s went away\n" % self.slavename) text += "\n" text += ("It last disconnected at %s (buildmaster-local time)\n" % time.ctime(time.time() - self.missing_timeout)) # approx text += "\n" text += "The admin on record (as reported by BUILDSLAVE:info/admin)\n" text += "was '%s'.\n" % self.slave_status.getAdmin() text += "\n" text += "Sincerely,\n" text += " The Buildbot\n" text += " %s\n" % status.getTitleURL() text += "\n" text += "%s\n" % status.getURLForThing(self.slave_status) subject = "Buildbot: buildslave %s was lost" % self.slavename return self._mail_missing_message(subject, text) def updateSlave(self): """Called to add or remove builders after the slave has connected. @return: a Deferred that indicates when an attached slave has accepted the new builders and/or released the old ones.""" if self.slave: return self.sendBuilderList() else: return defer.succeed(None) def updateSlaveStatus(self, buildStarted=None, buildFinished=None): if buildStarted: self.slave_status.buildStarted(buildStarted) if buildFinished: self.slave_status.buildFinished(buildFinished) @metrics.countMethod('AbstractBuildSlave.attached()') def attached(self, bot): """This is called when the slave connects. @return: a Deferred that fires when the attachment is complete """ # the botmaster should ensure this. assert not self.isConnected() metrics.MetricCountEvent.log("AbstractBuildSlave.attached_slaves", 1) # set up the subscription point for eventual detachment self.detached_subs = subscription.SubscriptionPoint("detached") # now we go through a sequence of calls, gathering information, then # tell the Botmaster that it can finally give this slave to all the # Builders that care about it. # we accumulate slave information in this 'state' dictionary, then # set it atomically if we make it far enough through the process state = {} # Reset graceful shutdown status self.slave_status.setGraceful(False) # We want to know when the graceful shutdown flag changes self.slave_status.addGracefulWatcher(self._gracefulChanged) d = defer.succeed(None) def _log_attachment_on_slave(res): d1 = bot.callRemote("print", "attached") d1.addErrback(lambda why: None) return d1 d.addCallback(_log_attachment_on_slave) def _get_info(res): d1 = bot.callRemote("getSlaveInfo") def _got_info(info): log.msg("Got slaveinfo from '%s'" % self.slavename) # TODO: info{} might have other keys state["admin"] = info.get("admin") state["host"] = info.get("host") state["access_uri"] = info.get("access_uri", None) state["slave_environ"] = info.get("environ", {}) state["slave_basedir"] = info.get("basedir", None) state["slave_system"] = info.get("system", None) def _info_unavailable(why): why.trap(pb.NoSuchMethod) # maybe an old slave, doesn't implement remote_getSlaveInfo log.msg("BuildSlave.info_unavailable") log.err(why) d1.addCallbacks(_got_info, _info_unavailable) return d1 d.addCallback(_get_info) self.startKeepaliveTimer() def _get_version(res): d = bot.callRemote("getVersion") def _got_version(version): state["version"] = version def _version_unavailable(why): why.trap(pb.NoSuchMethod) # probably an old slave state["version"] = '(unknown)' d.addCallbacks(_got_version, _version_unavailable) return d d.addCallback(_get_version) def _get_commands(res): d1 = bot.callRemote("getCommands") def _got_commands(commands): state["slave_commands"] = commands def _commands_unavailable(why): # probably an old slave if why.check(AttributeError): return log.msg("BuildSlave.getCommands is unavailable - ignoring") log.err(why) d1.addCallbacks(_got_commands, _commands_unavailable) return d1 d.addCallback(_get_commands) def _accept_slave(res): self.slave_status.setAdmin(state.get("admin")) self.slave_status.setHost(state.get("host")) self.slave_status.setAccessURI(state.get("access_uri")) self.slave_status.setVersion(state.get("version")) self.slave_status.setConnected(True) self.slave_commands = state.get("slave_commands") self.slave_environ = state.get("slave_environ") self.slave_basedir = state.get("slave_basedir") self.slave_system = state.get("slave_system") self.slave = bot if self.slave_system == "nt": self.path_module = namedModule("ntpath") else: # most eveything accepts / as separator, so posix should be a # reasonable fallback self.path_module = namedModule("posixpath") log.msg("bot attached") self.messageReceivedFromSlave() self.stopMissingTimer() self.botmaster.master.status.slaveConnected(self.slavename) return self.updateSlave() d.addCallback(_accept_slave) d.addCallback(lambda _: self.botmaster.maybeStartBuildsForSlave(self.slavename)) # Finally, the slave gets a reference to this BuildSlave. They # receive this later, after we've started using them. d.addCallback(lambda _: self) return d def messageReceivedFromSlave(self): now = time.time() self.lastMessageReceived = now self.slave_status.setLastMessageReceived(now) def detached(self, mind): metrics.MetricCountEvent.log("AbstractBuildSlave.attached_slaves", -1) self.slave = None self._old_builder_list = [] self.slave_status.removeGracefulWatcher(self._gracefulChanged) self.slave_status.setConnected(False) log.msg("BuildSlave.detached(%s)" % self.slavename) self.botmaster.master.status.slaveDisconnected(self.slavename) self.stopKeepaliveTimer() self.releaseLocks() # notify watchers, but do so in the next reactor iteration so that # any further detached() action by subclasses happens first def notif(): subs = self.detached_subs self.detached_subs = None subs.deliver() eventually(notif) def subscribeToDetach(self, callback): """ Request that C{callable} be invoked with no arguments when the L{detached} method is invoked. @returns: L{Subscription} """ assert self.detached_subs, "detached_subs is only set if attached" return self.detached_subs.subscribe(callback) def disconnect(self): """Forcibly disconnect the slave. This severs the TCP connection and returns a Deferred that will fire (with None) when the connection is probably gone. If the slave is still alive, they will probably try to reconnect again in a moment. This is called in two circumstances. The first is when a slave is removed from the config file. In this case, when they try to reconnect, they will be rejected as an unknown slave. The second is when we wind up with two connections for the same slave, in which case we disconnect the older connection. """ if not self.slave: return defer.succeed(None) log.msg("disconnecting old slave %s now" % self.slavename) # When this Deferred fires, we'll be ready to accept the new slave return self._disconnect(self.slave) def _disconnect(self, slave): # all kinds of teardown will happen as a result of # loseConnection(), but it happens after a reactor iteration or # two. Hook the actual disconnect so we can know when it is safe # to connect the new slave. We have to wait one additional # iteration (with callLater(0)) to make sure the *other* # notifyOnDisconnect handlers have had a chance to run. d = defer.Deferred() # notifyOnDisconnect runs the callback with one argument, the # RemoteReference being disconnected. def _disconnected(rref): eventually(d.callback, None) slave.notifyOnDisconnect(_disconnected) tport = slave.broker.transport # this is the polite way to request that a socket be closed tport.loseConnection() try: # but really we don't want to wait for the transmit queue to # drain. The remote end is unlikely to ACK the data, so we'd # probably have to wait for a (20-minute) TCP timeout. #tport._closeSocket() # however, doing _closeSocket (whether before or after # loseConnection) somehow prevents the notifyOnDisconnect # handlers from being run. Bummer. tport.offset = 0 tport.dataBuffer = "" except: # however, these hacks are pretty internal, so don't blow up if # they fail or are unavailable log.msg("failed to accelerate the shutdown process") log.msg("waiting for slave to finish disconnecting") return d def sendBuilderList(self): our_builders = self.botmaster.getBuildersForSlave(self.slavename) blist = [(b.name, b.config.slavebuilddir) for b in our_builders] if blist == self._old_builder_list: return defer.succeed(None) d = self.slave.callRemote("setBuilderList", blist) def sentBuilderList(ign): self._old_builder_list = blist return ign d.addCallback(sentBuilderList) return d def perspective_keepalive(self): self.messageReceivedFromSlave() def perspective_shutdown(self): log.msg("slave %s wants to shut down" % self.slavename) self.slave_status.setGraceful(True) def addSlaveBuilder(self, sb): self.slavebuilders[sb.builder_name] = sb def removeSlaveBuilder(self, sb): try: del self.slavebuilders[sb.builder_name] except KeyError: pass def buildFinished(self, sb): """This is called when a build on this slave is finished.""" self.botmaster.maybeStartBuildsForSlave(self.slavename) def canStartBuild(self): """ I am called when a build is requested to see if this buildslave can start a build. This function can be used to limit overall concurrency on the buildslave. Note for subclassers: if a slave can become willing to start a build without any action on that slave (for example, by a resource in use on another slave becoming available), then you must arrange for L{maybeStartBuildsForSlave} to be called at that time, or builds on this slave will not start. """ if self.slave_status.isPaused(): return False # If we're waiting to shutdown gracefully, then we shouldn't # accept any new jobs. if self.slave_status.getGraceful(): return False if self.max_builds: active_builders = [sb for sb in self.slavebuilders.values() if sb.isBusy()] if len(active_builders) >= self.max_builds: return False if not self.locksAvailable(): return False return True def _mail_missing_message(self, subject, text): # first, see if we have a MailNotifier we can use. This gives us a # fromaddr and a relayhost. buildmaster = self.botmaster.master for st in buildmaster.status: if isinstance(st, MailNotifier): break else: # if not, they get a default MailNotifier, which always uses SMTP # to localhost and uses a dummy fromaddr of "buildbot". log.msg("buildslave-missing msg using default MailNotifier") st = MailNotifier("buildbot") # now construct the mail m = Message() m.set_payload(text) m['Date'] = formatdate(localtime=True) m['Subject'] = subject m['From'] = st.fromaddr recipients = self.notify_on_missing m['To'] = ", ".join(recipients) d = st.sendMessage(m, recipients) # return the Deferred for testing purposes return d def _gracefulChanged(self, graceful): """This is called when our graceful shutdown setting changes""" self.maybeShutdown() @defer.inlineCallbacks def shutdown(self): """Shutdown the slave""" if not self.slave: log.msg("no remote; slave is already shut down") return # First, try the "new" way - calling our own remote's shutdown # method. The method was only added in 0.8.3, so ignore NoSuchMethod # failures. def new_way(): d = self.slave.callRemote('shutdown') d.addCallback(lambda _ : True) # successful shutdown request def check_nsm(f): f.trap(pb.NoSuchMethod) return False # fall through to the old way d.addErrback(check_nsm) def check_connlost(f): f.trap(pb.PBConnectionLost) return True # the slave is gone, so call it finished d.addErrback(check_connlost) return d if (yield new_way()): return # done! # Now, the old way. Look for a builder with a remote reference to the # client side slave. If we can find one, then call "shutdown" on the # remote builder, which will cause the slave buildbot process to exit. def old_way(): d = None for b in self.slavebuilders.values(): if b.remote: d = b.remote.callRemote("shutdown") break if d: log.msg("Shutting down (old) slave: %s" % self.slavename) # The remote shutdown call will not complete successfully since the # buildbot process exits almost immediately after getting the # shutdown request. # Here we look at the reason why the remote call failed, and if # it's because the connection was lost, that means the slave # shutdown as expected. def _errback(why): if why.check(pb.PBConnectionLost): log.msg("Lost connection to %s" % self.slavename) else: log.err("Unexpected error when trying to shutdown %s" % self.slavename) d.addErrback(_errback) return d log.err("Couldn't find remote builder to shut down slave") return defer.succeed(None) yield old_way() def maybeShutdown(self): """Shut down this slave if it has been asked to shut down gracefully, and has no active builders.""" if not self.slave_status.getGraceful(): return active_builders = [sb for sb in self.slavebuilders.values() if sb.isBusy()] if active_builders: return d = self.shutdown() d.addErrback(log.err, 'error while shutting down slave') def pause(self): """Stop running new builds on the slave.""" self.slave_status.setPaused(True) def unpause(self): """Restart running new builds on the slave.""" self.slave_status.setPaused(False) self.botmaster.maybeStartBuildsForSlave(self.slavename) def isPaused(self): return self.paused class BuildSlave(AbstractBuildSlave): def sendBuilderList(self): d = AbstractBuildSlave.sendBuilderList(self) def _sent(slist): # Nothing has changed, so don't need to re-attach to everything if not slist: return dl = [] for name, remote in slist.items(): # use get() since we might have changed our mind since then b = self.botmaster.builders.get(name) if b: d1 = b.attached(self, remote, self.slave_commands) dl.append(d1) return defer.DeferredList(dl) def _set_failed(why): log.msg("BuildSlave.sendBuilderList (%s) failed" % self) log.err(why) # TODO: hang up on them?, without setBuilderList we can't use # them d.addCallbacks(_sent, _set_failed) return d def detached(self, mind): AbstractBuildSlave.detached(self, mind) self.botmaster.slaveLost(self) self.startMissingTimer() def buildFinished(self, sb): """This is called when a build on this slave is finished.""" AbstractBuildSlave.buildFinished(self, sb) # If we're gracefully shutting down, and we have no more active # builders, then it's safe to disconnect self.maybeShutdown() class AbstractLatentBuildSlave(AbstractBuildSlave): """A build slave that will start up a slave instance when needed. To use, subclass and implement start_instance and stop_instance. See ec2buildslave.py for a concrete example. Also see the stub example in test/test_slaves.py. """ implements(ILatentBuildSlave) substantiated = False substantiation_deferred = None substantiation_build = None insubstantiating = False build_wait_timer = None _shutdown_callback_handle = None def __init__(self, name, password, max_builds=None, notify_on_missing=[], missing_timeout=60*20, build_wait_timeout=60*10, properties={}, locks=None): AbstractBuildSlave.__init__( self, name, password, max_builds, notify_on_missing, missing_timeout, properties, locks) self.building = set() self.build_wait_timeout = build_wait_timeout def start_instance(self, build): # responsible for starting instance that will try to connect with this # master. Should return deferred with either True (instance started) # or False (instance not started, so don't run a build here). Problems # should use an errback. raise NotImplementedError def stop_instance(self, fast=False): # responsible for shutting down instance. raise NotImplementedError def substantiate(self, sb, build): if self.substantiated: self._clearBuildWaitTimer() self._setBuildWaitTimer() return defer.succeed(True) if self.substantiation_deferred is None: if self.parent and not self.missing_timer: # start timer. if timer times out, fail deferred self.missing_timer = reactor.callLater( self.missing_timeout, self._substantiation_failed, defer.TimeoutError()) self.substantiation_deferred = defer.Deferred() self.substantiation_build = build if self.slave is None: d = self._substantiate(build) # start up instance d.addErrback(log.err, "while substantiating") # else: we're waiting for an old one to detach. the _substantiate # will be done in ``detached`` below. return self.substantiation_deferred def _substantiate(self, build): # register event trigger d = self.start_instance(build) self._shutdown_callback_handle = reactor.addSystemEventTrigger( 'before', 'shutdown', self._soft_disconnect, fast=True) def start_instance_result(result): # If we don't report success, then preparation failed. if not result: log.msg("Slave '%s' doesn not want to substantiate at this time" % (self.slavename,)) d = self.substantiation_deferred self.substantiation_deferred = None d.callback(False) return result def clean_up(failure): if self.missing_timer is not None: self.missing_timer.cancel() self._substantiation_failed(failure) if self._shutdown_callback_handle is not None: handle = self._shutdown_callback_handle del self._shutdown_callback_handle reactor.removeSystemEventTrigger(handle) return failure d.addCallbacks(start_instance_result, clean_up) return d def attached(self, bot): if self.substantiation_deferred is None and self.build_wait_timeout >= 0: msg = 'Slave %s received connection while not trying to ' \ 'substantiate. Disconnecting.' % (self.slavename,) log.msg(msg) self._disconnect(bot) return defer.fail(RuntimeError(msg)) return AbstractBuildSlave.attached(self, bot) def detached(self, mind): AbstractBuildSlave.detached(self, mind) if self.substantiation_deferred is not None: d = self._substantiate(self.substantiation_build) d.addErrback(log.err, 'while re-substantiating') def _substantiation_failed(self, failure): self.missing_timer = None if self.substantiation_deferred: d = self.substantiation_deferred self.substantiation_deferred = None self.substantiation_build = None d.errback(failure) self.insubstantiate() # notify people, but only if we're still in the config if not self.parent or not self.notify_on_missing: return buildmaster = self.botmaster.master status = buildmaster.getStatus() text = "The Buildbot working for '%s'\n" % status.getTitle() text += ("has noticed that the latent buildslave named %s \n" % self.slavename) text += "never substantiated after a request\n" text += "\n" text += ("The request was made at %s (buildmaster-local time)\n" % time.ctime(time.time() - self.missing_timeout)) # approx text += "\n" text += "Sincerely,\n" text += " The Buildbot\n" text += " %s\n" % status.getTitleURL() subject = "Buildbot: buildslave %s never substantiated" % self.slavename return self._mail_missing_message(subject, text) def canStartBuild(self): if self.insubstantiating: return False return AbstractBuildSlave.canStartBuild(self) def buildStarted(self, sb): assert self.substantiated self._clearBuildWaitTimer() self.building.add(sb.builder_name) def buildFinished(self, sb): AbstractBuildSlave.buildFinished(self, sb) self.building.remove(sb.builder_name) if not self.building: if self.build_wait_timeout == 0: self.insubstantiate() else: self._setBuildWaitTimer() def _clearBuildWaitTimer(self): if self.build_wait_timer is not None: if self.build_wait_timer.active(): self.build_wait_timer.cancel() self.build_wait_timer = None def _setBuildWaitTimer(self): self._clearBuildWaitTimer() if self.build_wait_timeout <= 0: return self.build_wait_timer = reactor.callLater( self.build_wait_timeout, self._soft_disconnect) @defer.inlineCallbacks def insubstantiate(self, fast=False): self.insubstantiating = True self._clearBuildWaitTimer() d = self.stop_instance(fast) if self._shutdown_callback_handle is not None: handle = self._shutdown_callback_handle del self._shutdown_callback_handle reactor.removeSystemEventTrigger(handle) self.substantiated = False self.building.clear() # just to be sure yield d self.insubstantiating = False @defer.inlineCallbacks def _soft_disconnect(self, fast=False): # a negative build_wait_timeout means the slave should never be shut # down, so just disconnect. if self.build_wait_timeout < 0: yield AbstractBuildSlave.disconnect(self) return if self.missing_timer: self.missing_timer.cancel() self.missing_timer = None if self.substantiation_deferred is not None: log.msg("Weird: Got request to stop before started. Allowing " "slave to start cleanly to avoid inconsistent state") yield self.substantiation_deferred self.substantiation_deferred = None self.substantiation_build = None log.msg("Substantiation complete, immediately terminating.") if self.slave is not None: # this could be called when the slave needs to shut down, such as # in BotMaster.removeSlave, *or* when a new slave requests a # connection when we already have a slave. It's not clear what to # do in the second case: this shouldn't happen, and if it # does...if it's a latent slave, shutting down will probably kill # something we want...but we can't know what the status is. So, # here, we just do what should be appropriate for the first case, # and put our heads in the sand for the second, at least for now. # The best solution to the odd situation is removing it as a # possibility: make the master in charge of connecting to the # slave, rather than vice versa. TODO. yield defer.DeferredList([ AbstractBuildSlave.disconnect(self), self.insubstantiate(fast) ], consumeErrors=True, fireOnOneErrback=True) else: yield AbstractBuildSlave.disconnect(self) yield self.stop_instance(fast) def disconnect(self): # This returns a Deferred but we don't use it self._soft_disconnect() # this removes the slave from all builders. It won't come back # without a restart (or maybe a sighup) self.botmaster.slaveLost(self) def stopService(self): res = defer.maybeDeferred(AbstractBuildSlave.stopService, self) if self.slave is not None: d = self._soft_disconnect() res = defer.DeferredList([res, d]) return res def updateSlave(self): """Called to add or remove builders after the slave has connected. Also called after botmaster's builders are initially set. @return: a Deferred that indicates when an attached slave has accepted the new builders and/or released the old ones.""" for b in self.botmaster.getBuildersForSlave(self.slavename): if b.name not in self.slavebuilders: b.addLatentSlave(self) return AbstractBuildSlave.updateSlave(self) def sendBuilderList(self): d = AbstractBuildSlave.sendBuilderList(self) def _sent(slist): if not slist: return dl = [] for name, remote in slist.items(): # use get() since we might have changed our mind since then. # we're checking on the builder in addition to the # slavebuilders out of a bit of paranoia. b = self.botmaster.builders.get(name) sb = self.slavebuilders.get(name) if b and sb: d1 = sb.attached(self, remote, self.slave_commands) dl.append(d1) return defer.DeferredList(dl) def _set_failed(why): log.msg("BuildSlave.sendBuilderList (%s) failed" % self) log.err(why) # TODO: hang up on them?, without setBuilderList we can't use # them if self.substantiation_deferred: d = self.substantiation_deferred self.substantiation_deferred = None self.substantiation_build = None d.errback(why) if self.missing_timer: self.missing_timer.cancel() self.missing_timer = None # TODO: maybe log? send an email? return why d.addCallbacks(_sent, _set_failed) def _substantiated(res): log.msg("Slave %s substantiated \o/" % self.slavename) self.substantiated = True if not self.substantiation_deferred: log.msg("No substantiation deferred for %s" % self.slavename) if self.substantiation_deferred: log.msg("Firing %s substantiation deferred with success" % self.slavename) d = self.substantiation_deferred self.substantiation_deferred = None self.substantiation_build = None d.callback(True) # note that the missing_timer is already handled within # ``attached`` if not self.building: self._setBuildWaitTimer() d.addCallback(_substantiated) return d
gpl-2.0
[ 3, 961, 570, 365, 1777, 402, 6516, 3018, 14, 221, 6516, 3018, 365, 2867, 2032, 26, 1265, 883, 199, 3, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 12, 1015, 499, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 199, 3, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 199, 3, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 3, 199, 3, 20825, 1898, 6516, 3018, 11682, 14409, 83, 199, 3, 20825, 1898, 6855, 7174, 12126, 14, 8937, 199, 199, 646, 900, 199, 504, 3031, 14, 2209, 492, 6430, 199, 504, 3031, 14, 7535, 492, 1475, 602, 199, 504, 20110, 14, 3266, 492, 9031, 199, 504, 7390, 14, 1548, 492, 943, 199, 504, 7390, 14, 4901, 492, 10133, 12, 9655, 199, 504, 7390, 14, 3578, 492, 2435, 199, 504, 7390, 14, 29889, 492, 10446, 199, 504, 7390, 14, 1548, 14, 21963, 492, 4310, 2377, 199, 199, 504, 21306, 14, 1205, 14, 12384, 492, 428, 8007, 3694, 199, 504, 21306, 14, 1205, 14, 1198, 492, 18027, 26884, 199, 504, 21306, 14, 1412, 492, 7186, 12, 5888, 4133, 199, 504, 21306, 14, 7436, 492, 473, 3425, 28950, 12, 473, 16500, 343, 3425, 28950, 199, 504, 21306, 14, 1412, 14, 3282, 492, 19329, 199, 504, 21306, 14, 1974, 492, 9966, 199, 504, 21306, 14, 1974, 14, 1430, 1061, 492, 21356, 199, 504, 21306, 492, 1101, 199, 199, 533, 11836, 3425, 28950, 8, 888, 14, 497, 888, 15684, 3167, 4256, 12, 10446, 14, 24916, 12, 717, 2435, 14, 3947, 3167, 304, 272, 408, 2765, 365, 314, 5288, 13, 2441, 2954, 1905, 367, 282, 3982, 21306, 15494, 14, 272, 6006, 365, 8840, 1373, 367, 1924, 15494, 11736, 315, 314, 1101, 570, 334, 1589, 272, 286, 459, 32175, 418, 769, 680, 3979, 21306, 83, 4907, 315, 17048, 5040, 395, 2985, 664, 282, 272, 3659, 370, 642, 1256, 14, 710, 24896, 12288, 909, 365, 410, 21189, 465, 314, 272, 1275, 3018, 4133, 2225, 14, 710, 24896, 12288, 365, 2597, 4154, 1987, 1708, 7, 7591, 14, 339, 473, 2954, 282, 1900, 15494, 1553, 282, 3982, 6844, 4021, 461, 402, 272, 3879, 14723, 14, 221, 473, 8140, 17544, 701, 314, 2897, 570, 12, 436, 883, 506, 272, 1007, 28271, 370, 1050, 2402, 9330, 1041, 339, 9031, 8, 41, 3425, 28950, 9, 272, 4215, 9631, 63, 7414, 275, 488, 272, 4215, 9631, 63, 4284, 275, 488, 339, 327, 295, 888, 308, 21868, 2410, 27378, 272, 295, 888, 63, 6693, 275, 5049, 339, 347, 636, 826, 721, 277, 12, 536, 12, 2505, 12, 1390, 63, 10838, 29, 403, 12, 326, 11705, 63, 265, 63, 4752, 6034, 4124, 63, 2593, 29, 11035, 12, 326, 4382, 10324, 23340, 29, 403, 12, 4215, 9631, 63, 4284, 29, 11035, 304, 267, 408, 267, 768, 635, 536, 26, 5888, 354, 642, 6844, 911, 17169, 1380, 652, 4907, 83, 267, 768, 635, 2505, 26, 2505, 642, 6844, 911, 17169, 1380, 586, 652, 4907, 83, 267, 768, 635, 1390, 63, 10838, 26, 5696, 1329, 402, 27008, 14723, 626, 911, 2574, 506, 1255, 406, 19767, 641, 642, 1900, 12384, 334, 1589, 2574, 849, 365, 488, 367, 949, 2304, 9, 267, 768, 635, 4382, 26, 4382, 626, 911, 506, 6781, 370, 14723, 1255, 641, 2574, 642, 15494, 267, 768, 466, 4382, 26, 2600, 267, 768, 635, 23340, 26, 437, 769, 402, 23340, 626, 1471, 506, 28320, 2544, 642, 15494, 1993, 883, 506, 1202, 267, 768, 466, 23340, 26, 2600, 267, 408, 267, 2435, 14, 3947, 3167, 855, 826, 721, 277, 9, 267, 291, 14, 83, 416, 1856, 313, 275, 536, 267, 291, 14, 2060, 275, 2505, 398, 327, 510, 34, 10991, 267, 291, 14, 8054, 275, 488, 267, 291, 14, 11616, 63, 719, 275, 488, 398, 327, 3520, 787, 663, 1380, 314, 2435, 365, 8239, 12, 436, 15376, 1380, 652, 365, 267, 327, 15248, 267, 291, 14, 3018, 4133, 275, 488, 267, 291, 14, 4133, 275, 488, 398, 291, 14, 12384, 63, 1205, 275, 428, 8007, 3694, 8, 354, 9, 267, 291, 14, 12384, 275, 488, 327, 282, 17283, 5083, 370, 314, 24896, 12, 1380, 8539, 267, 291, 14, 12384, 63, 4405, 275, 488, 267, 291, 14, 12384, 20968, 275, 1052, 267, 291, 14, 988, 63, 10838, 275, 1390, 63, 10838, 267, 291, 14, 2732, 275, 942, 267, 340, 23340, 26, 288, 291, 14, 2732, 275, 23340, 267, 291, 14, 831, 63, 13233, 275, 942, 398, 291, 14, 3282, 275, 19329, 342, 267, 291, 14, 3282, 14, 873, 8, 3282, 12, 298, 3425, 28950, 531, 267, 291, 14, 3282, 14, 21173, 480, 83, 416, 1856, 313, 401, 536, 12, 298, 3425, 28950, 531, 398, 291, 14, 2019, 2209, 9392, 275, 378, 267, 340, 1228, 8, 6814, 63, 265, 63, 4752, 12, 620, 304, 288, 11705, 63, 265, 63, 4752, 275, 359, 6814, 63, 265, 63, 4752, 61, 267, 291, 14, 6814, 63, 265, 63, 4752, 275, 11705, 63, 265, 63, 4752, 267, 367, 284, 315, 11705, 63, 265, 63, 4752, 26, 288, 340, 440, 1228, 8, 73, 12, 620, 304, 355, 1101, 14, 705, 8, 490, 283, 6814, 63, 265, 63, 4752, 1680, 450, 82, 365, 440, 282, 1059, 7, 450, 334, 73, 4641, 267, 291, 14, 4752, 63, 2593, 275, 4124, 63, 2593, 267, 291, 14, 4752, 63, 7414, 275, 488, 267, 291, 14, 28227, 63, 4284, 275, 4215, 9631, 63, 4284, 398, 291, 14, 271, 7159, 63, 9841, 275, 488, 398, 291, 423, 1753, 63, 5649, 63, 513, 275, 488, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 23054, 83, 450, 82, 4335, 450, 334, 277, 855, 533, 4914, 354, 3108, 291, 14, 83, 416, 1856, 313, 9, 339, 347, 1678, 6432, 83, 8, 277 ]
[ 961, 570, 365, 1777, 402, 6516, 3018, 14, 221, 6516, 3018, 365, 2867, 2032, 26, 1265, 883, 199, 3, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 12, 1015, 499, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 199, 3, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 199, 3, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 3, 199, 3, 20825, 1898, 6516, 3018, 11682, 14409, 83, 199, 3, 20825, 1898, 6855, 7174, 12126, 14, 8937, 199, 199, 646, 900, 199, 504, 3031, 14, 2209, 492, 6430, 199, 504, 3031, 14, 7535, 492, 1475, 602, 199, 504, 20110, 14, 3266, 492, 9031, 199, 504, 7390, 14, 1548, 492, 943, 199, 504, 7390, 14, 4901, 492, 10133, 12, 9655, 199, 504, 7390, 14, 3578, 492, 2435, 199, 504, 7390, 14, 29889, 492, 10446, 199, 504, 7390, 14, 1548, 14, 21963, 492, 4310, 2377, 199, 199, 504, 21306, 14, 1205, 14, 12384, 492, 428, 8007, 3694, 199, 504, 21306, 14, 1205, 14, 1198, 492, 18027, 26884, 199, 504, 21306, 14, 1412, 492, 7186, 12, 5888, 4133, 199, 504, 21306, 14, 7436, 492, 473, 3425, 28950, 12, 473, 16500, 343, 3425, 28950, 199, 504, 21306, 14, 1412, 14, 3282, 492, 19329, 199, 504, 21306, 14, 1974, 492, 9966, 199, 504, 21306, 14, 1974, 14, 1430, 1061, 492, 21356, 199, 504, 21306, 492, 1101, 199, 199, 533, 11836, 3425, 28950, 8, 888, 14, 497, 888, 15684, 3167, 4256, 12, 10446, 14, 24916, 12, 717, 2435, 14, 3947, 3167, 304, 272, 408, 2765, 365, 314, 5288, 13, 2441, 2954, 1905, 367, 282, 3982, 21306, 15494, 14, 272, 6006, 365, 8840, 1373, 367, 1924, 15494, 11736, 315, 314, 1101, 570, 334, 1589, 272, 286, 459, 32175, 418, 769, 680, 3979, 21306, 83, 4907, 315, 17048, 5040, 395, 2985, 664, 282, 272, 3659, 370, 642, 1256, 14, 710, 24896, 12288, 909, 365, 410, 21189, 465, 314, 272, 1275, 3018, 4133, 2225, 14, 710, 24896, 12288, 365, 2597, 4154, 1987, 1708, 7, 7591, 14, 339, 473, 2954, 282, 1900, 15494, 1553, 282, 3982, 6844, 4021, 461, 402, 272, 3879, 14723, 14, 221, 473, 8140, 17544, 701, 314, 2897, 570, 12, 436, 883, 506, 272, 1007, 28271, 370, 1050, 2402, 9330, 1041, 339, 9031, 8, 41, 3425, 28950, 9, 272, 4215, 9631, 63, 7414, 275, 488, 272, 4215, 9631, 63, 4284, 275, 488, 339, 327, 295, 888, 308, 21868, 2410, 27378, 272, 295, 888, 63, 6693, 275, 5049, 339, 347, 636, 826, 721, 277, 12, 536, 12, 2505, 12, 1390, 63, 10838, 29, 403, 12, 326, 11705, 63, 265, 63, 4752, 6034, 4124, 63, 2593, 29, 11035, 12, 326, 4382, 10324, 23340, 29, 403, 12, 4215, 9631, 63, 4284, 29, 11035, 304, 267, 408, 267, 768, 635, 536, 26, 5888, 354, 642, 6844, 911, 17169, 1380, 652, 4907, 83, 267, 768, 635, 2505, 26, 2505, 642, 6844, 911, 17169, 1380, 586, 652, 4907, 83, 267, 768, 635, 1390, 63, 10838, 26, 5696, 1329, 402, 27008, 14723, 626, 911, 2574, 506, 1255, 406, 19767, 641, 642, 1900, 12384, 334, 1589, 2574, 849, 365, 488, 367, 949, 2304, 9, 267, 768, 635, 4382, 26, 4382, 626, 911, 506, 6781, 370, 14723, 1255, 641, 2574, 642, 15494, 267, 768, 466, 4382, 26, 2600, 267, 768, 635, 23340, 26, 437, 769, 402, 23340, 626, 1471, 506, 28320, 2544, 642, 15494, 1993, 883, 506, 1202, 267, 768, 466, 23340, 26, 2600, 267, 408, 267, 2435, 14, 3947, 3167, 855, 826, 721, 277, 9, 267, 291, 14, 83, 416, 1856, 313, 275, 536, 267, 291, 14, 2060, 275, 2505, 398, 327, 510, 34, 10991, 267, 291, 14, 8054, 275, 488, 267, 291, 14, 11616, 63, 719, 275, 488, 398, 327, 3520, 787, 663, 1380, 314, 2435, 365, 8239, 12, 436, 15376, 1380, 652, 365, 267, 327, 15248, 267, 291, 14, 3018, 4133, 275, 488, 267, 291, 14, 4133, 275, 488, 398, 291, 14, 12384, 63, 1205, 275, 428, 8007, 3694, 8, 354, 9, 267, 291, 14, 12384, 275, 488, 327, 282, 17283, 5083, 370, 314, 24896, 12, 1380, 8539, 267, 291, 14, 12384, 63, 4405, 275, 488, 267, 291, 14, 12384, 20968, 275, 1052, 267, 291, 14, 988, 63, 10838, 275, 1390, 63, 10838, 267, 291, 14, 2732, 275, 942, 267, 340, 23340, 26, 288, 291, 14, 2732, 275, 23340, 267, 291, 14, 831, 63, 13233, 275, 942, 398, 291, 14, 3282, 275, 19329, 342, 267, 291, 14, 3282, 14, 873, 8, 3282, 12, 298, 3425, 28950, 531, 267, 291, 14, 3282, 14, 21173, 480, 83, 416, 1856, 313, 401, 536, 12, 298, 3425, 28950, 531, 398, 291, 14, 2019, 2209, 9392, 275, 378, 267, 340, 1228, 8, 6814, 63, 265, 63, 4752, 12, 620, 304, 288, 11705, 63, 265, 63, 4752, 275, 359, 6814, 63, 265, 63, 4752, 61, 267, 291, 14, 6814, 63, 265, 63, 4752, 275, 11705, 63, 265, 63, 4752, 267, 367, 284, 315, 11705, 63, 265, 63, 4752, 26, 288, 340, 440, 1228, 8, 73, 12, 620, 304, 355, 1101, 14, 705, 8, 490, 283, 6814, 63, 265, 63, 4752, 1680, 450, 82, 365, 440, 282, 1059, 7, 450, 334, 73, 4641, 267, 291, 14, 4752, 63, 2593, 275, 4124, 63, 2593, 267, 291, 14, 4752, 63, 7414, 275, 488, 267, 291, 14, 28227, 63, 4284, 275, 4215, 9631, 63, 4284, 398, 291, 14, 271, 7159, 63, 9841, 275, 488, 398, 291, 423, 1753, 63, 5649, 63, 513, 275, 488, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 23054, 83, 450, 82, 4335, 450, 334, 277, 855, 533, 4914, 354, 3108, 291, 14, 83, 416, 1856, 313, 9, 339, 347, 1678, 6432, 83, 8, 277, 0 ]
[ 1, 1, 1, 1, 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server/autotest.py
1
42871
# Copyright 2007 Google Inc. Released under the GPL v2 import re, os, sys, traceback, subprocess, time, pickle, glob, tempfile import logging, getpass from autotest_lib.server import installable_object, prebuild, utils from autotest_lib.client.common_lib import base_job, log, error, autotemp from autotest_lib.client.common_lib import global_config, packages from autotest_lib.client.common_lib import utils as client_utils AUTOTEST_SVN = 'svn://test.kernel.org/autotest/trunk/client' AUTOTEST_HTTP = 'http://test.kernel.org/svn/autotest/trunk/client' # Timeouts for powering down and up respectively HALT_TIME = 300 BOOT_TIME = 1800 CRASH_RECOVERY_TIME = 9000 get_value = global_config.global_config.get_config_value autoserv_prebuild = get_value('AUTOSERV', 'enable_server_prebuild', type=bool, default=False) class AutodirNotFoundError(Exception): """No Autotest installation could be found.""" class BaseAutotest(installable_object.InstallableObject): """ This class represents the Autotest program. Autotest is used to run tests automatically and collect the results. It also supports profilers. Implementation details: This is a leaf class in an abstract class hierarchy, it must implement the unimplemented methods in parent classes. """ def __init__(self, host = None): self.host = host self.got = False self.installed = False self.serverdir = utils.get_server_dir() super(BaseAutotest, self).__init__() install_in_tmpdir = False @classmethod def set_install_in_tmpdir(cls, flag): """ Sets a flag that controls whether or not Autotest should by default be installed in a "standard" directory (e.g. /home/autotest, /usr/local/autotest) or a temporary directory. """ cls.install_in_tmpdir = flag @classmethod def get_client_autodir_paths(cls, host): return global_config.global_config.get_config_value( 'AUTOSERV', 'client_autodir_paths', type=list) @classmethod def get_installed_autodir(cls, host): """ Find where the Autotest client is installed on the host. @returns an absolute path to an installed Autotest client root. @raises AutodirNotFoundError if no Autotest installation can be found. """ autodir = host.get_autodir() if autodir: logging.debug('Using existing host autodir: %s', autodir) return autodir for path in Autotest.get_client_autodir_paths(host): try: autotest_binary = os.path.join(path, 'bin', 'autotest') host.run('test -x %s' % utils.sh_escape(autotest_binary)) host.run('test -w %s' % utils.sh_escape(path)) logging.debug('Found existing autodir at %s', path) return path except error.AutoservRunError: logging.debug('%s does not exist on %s', autotest_binary, host.hostname) raise AutodirNotFoundError @classmethod def get_install_dir(cls, host): """ Determines the location where autotest should be installed on host. If self.install_in_tmpdir is set, it will return a unique temporary directory that autotest can be installed in. Otherwise, looks for an existing installation to use; if none is found, looks for a usable directory in the global config client_autodir_paths. """ try: install_dir = cls.get_installed_autodir(host) except AutodirNotFoundError: install_dir = cls._find_installable_dir(host) if cls.install_in_tmpdir: return host.get_tmp_dir(parent=install_dir) return install_dir @classmethod def _find_installable_dir(cls, host): client_autodir_paths = cls.get_client_autodir_paths(host) for path in client_autodir_paths: try: host.run('mkdir -p %s' % utils.sh_escape(path)) host.run('test -w %s' % utils.sh_escape(path)) return path except error.AutoservRunError: logging.debug('Failed to create %s', path) raise error.AutoservInstallError( 'Unable to find a place to install Autotest; tried %s', ', '.join(client_autodir_paths)) def get_fetch_location(self): c = global_config.global_config repos = c.get_config_value("PACKAGES", 'fetch_location', type=list, default=[]) repos.reverse() return repos def install(self, host=None, autodir=None): self._install(host=host, autodir=autodir) def install_full_client(self, host=None, autodir=None): self._install(host=host, autodir=autodir, use_autoserv=False, use_packaging=False) def install_no_autoserv(self, host=None, autodir=None): self._install(host=host, autodir=autodir, use_autoserv=False) def _install_using_packaging(self, host, autodir): repos = self.get_fetch_location() if not repos: raise error.PackageInstallError("No repos to install an " "autotest client from") pkgmgr = packages.PackageManager(autodir, hostname=host.hostname, repo_urls=repos, do_locking=False, run_function=host.run, run_function_dargs=dict(timeout=600)) # The packages dir is used to store all the packages that # are fetched on that client. (for the tests,deps etc. # too apart from the client) pkg_dir = os.path.join(autodir, 'packages') # clean up the autodir except for the packages directory host.run('cd %s && ls | grep -v "^packages$"' ' | xargs rm -rf && rm -rf .[^.]*' % autodir) pkgmgr.install_pkg('autotest', 'client', pkg_dir, autodir, preserve_install_dir=True) self.installed = True def _install_using_send_file(self, host, autodir): dirs_to_exclude = set(["tests", "site_tests", "deps", "profilers"]) light_files = [os.path.join(self.source_material, f) for f in os.listdir(self.source_material) if f not in dirs_to_exclude] host.send_file(light_files, autodir, delete_dest=True) # create empty dirs for all the stuff we excluded commands = [] for path in dirs_to_exclude: abs_path = os.path.join(autodir, path) abs_path = utils.sh_escape(abs_path) commands.append("mkdir -p '%s'" % abs_path) commands.append("touch '%s'/__init__.py" % abs_path) host.run(';'.join(commands)) def _install(self, host=None, autodir=None, use_autoserv=True, use_packaging=True): """ Install autotest. If get() was not called previously, an attempt will be made to install from the autotest svn repository. @param host A Host instance on which autotest will be installed @param autodir Location on the remote host to install to @param use_autoserv Enable install modes that depend on the client running with the autoserv harness @param use_packaging Enable install modes that use the packaging system @exception AutoservError if a tarball was not specified and the target host does not have svn installed in its path """ if not host: host = self.host if not self.got: self.get() host.wait_up(timeout=30) host.setup() logging.info("Installing autotest on %s", host.hostname) # set up the autotest directory on the remote machine if not autodir: autodir = self.get_install_dir(host) logging.info('Using installation dir %s', autodir) host.set_autodir(autodir) host.run('mkdir -p %s' % utils.sh_escape(autodir)) # make sure there are no files in $AUTODIR/results results_path = os.path.join(autodir, 'results') host.run('rm -rf %s/*' % utils.sh_escape(results_path), ignore_status=True) # Fetch the autotest client from the nearest repository if use_packaging: try: self._install_using_packaging(host, autodir) return except (error.PackageInstallError, error.AutoservRunError, global_config.ConfigError), e: logging.info("Could not install autotest using the packaging " "system: %s. Trying other methods", e) # try to install from file or directory if self.source_material: c = global_config.global_config supports_autoserv_packaging = c.get_config_value( "PACKAGES", "serve_packages_from_autoserv", type=bool) # Copy autotest recursively if supports_autoserv_packaging and use_autoserv: self._install_using_send_file(host, autodir) else: host.send_file(self.source_material, autodir, delete_dest=True) logging.info("Installation of autotest completed") self.installed = True return # if that fails try to install using svn if utils.run('which svn').exit_status: raise error.AutoservError('svn not found on target machine: %s' % host.name) try: host.run('svn checkout %s %s' % (AUTOTEST_SVN, autodir)) except error.AutoservRunError, e: host.run('svn checkout %s %s' % (AUTOTEST_HTTP, autodir)) logging.info("Installation of autotest completed") self.installed = True def uninstall(self, host=None): """ Uninstall (i.e. delete) autotest. Removes the autotest client install from the specified host. @params host a Host instance from which the client will be removed """ if not self.installed: return if not host: host = self.host autodir = host.get_autodir() if not autodir: return # perform the actual uninstall host.run("rm -rf %s" % utils.sh_escape(autodir), ignore_status=True) host.set_autodir(None) self.installed = False def get(self, location = None): if not location: location = os.path.join(self.serverdir, '../client') location = os.path.abspath(location) # If there's stuff run on our client directory already, it # can cause problems. Try giving it a quick clean first. cwd = os.getcwd() os.chdir(location) try: utils.system('tools/make_clean', ignore_status=True) finally: os.chdir(cwd) super(BaseAutotest, self).get(location) self.got = True def run(self, control_file, results_dir='.', host=None, timeout=None, tag=None, parallel_flag=False, background=False, client_disconnect_timeout=1800): """ Run an autotest job on the remote machine. @param control_file: An open file-like-obj of the control file. @param results_dir: A str path where the results should be stored on the local filesystem. @param host: A Host instance on which the control file should be run. @param timeout: Maximum number of seconds to wait for the run or None. @param tag: Tag name for the client side instance of autotest. @param parallel_flag: Flag set when multiple jobs are run at the same time. @param background: Indicates that the client should be launched as a background job; the code calling run will be responsible for monitoring the client and collecting the results. @param client_disconnect_timeout: Seconds to wait for the remote host to come back after a reboot. [default: 30 minutes] @raises AutotestRunError: If there is a problem executing the control file. """ host = self._get_host_and_setup(host) results_dir = os.path.abspath(results_dir) if tag: results_dir = os.path.join(results_dir, tag) atrun = _Run(host, results_dir, tag, parallel_flag, background) self._do_run(control_file, results_dir, host, atrun, timeout, client_disconnect_timeout) def _get_host_and_setup(self, host): if not host: host = self.host if not self.installed: self.install(host) host.wait_up(timeout=30) return host def _do_run(self, control_file, results_dir, host, atrun, timeout, client_disconnect_timeout): try: atrun.verify_machine() except: logging.error("Verify failed on %s. Reinstalling autotest", host.hostname) self.install(host) atrun.verify_machine() debug = os.path.join(results_dir, 'debug') try: os.makedirs(debug) except Exception: pass delete_file_list = [atrun.remote_control_file, atrun.remote_control_file + '.state', atrun.manual_control_file, atrun.manual_control_file + '.state'] cmd = ';'.join('rm -f ' + control for control in delete_file_list) host.run(cmd, ignore_status=True) tmppath = utils.get(control_file) # build up the initialization prologue for the control file prologue_lines = [] # Add the additional user arguments prologue_lines.append("args = %r\n" % self.job.args) # If the packaging system is being used, add the repository list. repos = None try: repos = self.get_fetch_location() pkgmgr = packages.PackageManager('autotest', hostname=host.hostname, repo_urls=repos) prologue_lines.append('job.add_repository(%s)\n' % repos) except global_config.ConfigError, e: # If repos is defined packaging is enabled so log the error if repos: logging.error(e) # on full-size installs, turn on any profilers the server is using if not atrun.background: running_profilers = host.job.profilers.add_log.iteritems() for profiler, (args, dargs) in running_profilers: call_args = [repr(profiler)] call_args += [repr(arg) for arg in args] call_args += ["%s=%r" % item for item in dargs.iteritems()] prologue_lines.append("job.profilers.add(%s)\n" % ", ".join(call_args)) cfile = "".join(prologue_lines) cfile += open(tmppath).read() open(tmppath, "w").write(cfile) # Create and copy state file to remote_control_file + '.state' state_file = host.job.preprocess_client_state() host.send_file(state_file, atrun.remote_control_file + '.init.state') os.remove(state_file) # Copy control_file to remote_control_file on the host host.send_file(tmppath, atrun.remote_control_file) if os.path.abspath(tmppath) != os.path.abspath(control_file): os.remove(tmppath) atrun.execute_control( timeout=timeout, client_disconnect_timeout=client_disconnect_timeout) def run_timed_test(self, test_name, results_dir='.', host=None, timeout=None, *args, **dargs): """ Assemble a tiny little control file to just run one test, and run it as an autotest client-side test """ if not host: host = self.host if not self.installed: self.install(host) opts = ["%s=%s" % (o[0], repr(o[1])) for o in dargs.items()] cmd = ", ".join([repr(test_name)] + map(repr, args) + opts) control = "job.run_test(%s)\n" % cmd self.run(control, results_dir, host, timeout=timeout) def run_test(self, test_name, results_dir='.', host=None, *args, **dargs): self.run_timed_test(test_name, results_dir, host, timeout=None, *args, **dargs) class _BaseRun(object): """ Represents a run of autotest control file. This class maintains all the state necessary as an autotest control file is executed. It is not intended to be used directly, rather control files should be run using the run method in Autotest. """ def __init__(self, host, results_dir, tag, parallel_flag, background): self.host = host self.results_dir = results_dir self.env = host.env self.tag = tag self.parallel_flag = parallel_flag self.background = background self.autodir = Autotest.get_installed_autodir(self.host) control = os.path.join(self.autodir, 'control') if tag: control += '.' + tag self.manual_control_file = control self.remote_control_file = control + '.autoserv' self.config_file = os.path.join(self.autodir, 'global_config.ini') def verify_machine(self): binary = os.path.join(self.autodir, 'bin/autotest') try: self.host.run('ls %s > /dev/null 2>&1' % binary) except: raise error.AutoservInstallError( "Autotest does not appear to be installed") if not self.parallel_flag: tmpdir = os.path.join(self.autodir, 'tmp') download = os.path.join(self.autodir, 'tests/download') self.host.run('umount %s' % tmpdir, ignore_status=True) self.host.run('umount %s' % download, ignore_status=True) def get_base_cmd_args(self, section): args = ['--verbose'] if section > 0: args.append('-c') if self.tag: args.append('-t %s' % self.tag) if self.host.job.use_external_logging(): args.append('-l') if self.host.hostname: args.append('--hostname=%s' % self.host.hostname) args.append('--user=%s' % self.host.job.user) args.append(self.remote_control_file) return args def get_background_cmd(self, section): cmd = ['nohup', os.path.join(self.autodir, 'bin/autotest_client')] cmd += self.get_base_cmd_args(section) cmd += ['>/dev/null', '2>/dev/null', '&'] return ' '.join(cmd) def get_daemon_cmd(self, section, monitor_dir): cmd = ['nohup', os.path.join(self.autodir, 'bin/autotestd'), monitor_dir, '-H autoserv'] cmd += self.get_base_cmd_args(section) cmd += ['>/dev/null', '2>/dev/null', '&'] return ' '.join(cmd) def get_monitor_cmd(self, monitor_dir, stdout_read, stderr_read): cmd = [os.path.join(self.autodir, 'bin', 'autotestd_monitor'), monitor_dir, str(stdout_read), str(stderr_read)] return ' '.join(cmd) def get_client_log(self): """Find what the "next" client.* prefix should be @returns A string of the form client.INTEGER that should be prefixed to all client debug log files. """ max_digit = -1 debug_dir = os.path.join(self.results_dir, 'debug') client_logs = glob.glob(os.path.join(debug_dir, 'client.*.*')) for log in client_logs: _, number, _ = log.split('.', 2) if number.isdigit(): max_digit = max(max_digit, int(number)) return 'client.%d' % (max_digit + 1) def copy_client_config_file(self, client_log_prefix=None): """ Create and copy the client config file based on the server config. @param client_log_prefix: Optional prefix to prepend to log files. """ client_config_file = self._create_client_config_file(client_log_prefix) self.host.send_file(client_config_file, self.config_file) os.remove(client_config_file) def _create_client_config_file(self, client_log_prefix=None): """ Create a temporary file with the [CLIENT] section configuration values taken from the server global_config.ini. @param client_log_prefix: Optional prefix to prepend to log files. @return: Path of the temporary file generated. """ config = global_config.global_config.get_section_values('CLIENT') if client_log_prefix: config.set('CLIENT', 'default_logging_name', client_log_prefix) return self._create_aux_file(config.write) def _create_aux_file(self, func, *args): """ Creates a temporary file and writes content to it according to a content creation function. The file object is appended to *args, which is then passed to the content creation function @param func: Function that will be used to write content to the temporary file. @param *args: List of parameters that func takes. @return: Path to the temporary file that was created. """ fd, path = tempfile.mkstemp(dir=self.host.job.tmpdir) aux_file = os.fdopen(fd, "w") try: list_args = list(args) list_args.append(aux_file) func(*list_args) finally: aux_file.close() return path @staticmethod def is_client_job_finished(last_line): return bool(re.match(r'^END .*\t----\t----\t.*$', last_line)) @staticmethod def is_client_job_rebooting(last_line): return bool(re.match(r'^\t*GOOD\t----\treboot\.start.*$', last_line)) def log_unexpected_abort(self, stderr_redirector): stderr_redirector.flush_all_buffers() msg = "Autotest client terminated unexpectedly" self.host.job.record("END ABORT", None, None, msg) def _execute_in_background(self, section, timeout): full_cmd = self.get_background_cmd(section) devnull = open(os.devnull, "w") self.copy_client_config_file(self.get_client_log()) self.host.job.push_execution_context(self.results_dir) try: result = self.host.run(full_cmd, ignore_status=True, timeout=timeout, stdout_tee=devnull, stderr_tee=devnull) finally: self.host.job.pop_execution_context() return result @staticmethod def _strip_stderr_prologue(stderr): """Strips the 'standard' prologue that get pre-pended to every remote command and returns the text that was actually written to stderr by the remote command.""" stderr_lines = stderr.split("\n")[1:] if not stderr_lines: return "" elif stderr_lines[0].startswith("NOTE: autotestd_monitor"): del stderr_lines[0] return "\n".join(stderr_lines) def _execute_daemon(self, section, timeout, stderr_redirector, client_disconnect_timeout): monitor_dir = self.host.get_tmp_dir() daemon_cmd = self.get_daemon_cmd(section, monitor_dir) # grab the location for the server-side client log file client_log_prefix = self.get_client_log() client_log_path = os.path.join(self.results_dir, 'debug', client_log_prefix + '.log') client_log = open(client_log_path, 'w', 0) self.copy_client_config_file(client_log_prefix) stdout_read = stderr_read = 0 self.host.job.push_execution_context(self.results_dir) try: self.host.run(daemon_cmd, ignore_status=True, timeout=timeout) disconnect_warnings = [] while True: monitor_cmd = self.get_monitor_cmd(monitor_dir, stdout_read, stderr_read) try: result = self.host.run(monitor_cmd, ignore_status=True, timeout=timeout, stdout_tee=client_log, stderr_tee=stderr_redirector) except error.AutoservRunError, e: result = e.result_obj result.exit_status = None disconnect_warnings.append(e.description) stderr_redirector.log_warning( "Autotest client was disconnected: %s" % e.description, "NETWORK") except error.AutoservSSHTimeout: result = utils.CmdResult(monitor_cmd, "", "", None, 0) stderr_redirector.log_warning( "Attempt to connect to Autotest client timed out", "NETWORK") stdout_read += len(result.stdout) stderr_read += len(self._strip_stderr_prologue(result.stderr)) if result.exit_status is not None: return result elif not self.host.wait_up(client_disconnect_timeout): raise error.AutoservSSHTimeout( "client was disconnected, reconnect timed out") finally: client_log.close() self.host.job.pop_execution_context() def execute_section(self, section, timeout, stderr_redirector, client_disconnect_timeout): logging.info("Executing %s/bin/autotest %s/control phase %d", self.autodir, self.autodir, section) if self.background: result = self._execute_in_background(section, timeout) else: result = self._execute_daemon(section, timeout, stderr_redirector, client_disconnect_timeout) last_line = stderr_redirector.last_line # check if we failed hard enough to warrant an exception if result.exit_status == 1: err = error.AutotestRunError("client job was aborted") elif not self.background and not result.stderr: err = error.AutotestRunError( "execute_section %s failed to return anything\n" "stdout:%s\n" % (section, result.stdout)) else: err = None # log something if the client failed AND never finished logging if err and not self.is_client_job_finished(last_line): self.log_unexpected_abort(stderr_redirector) if err: raise err else: return stderr_redirector.last_line def _wait_for_reboot(self, old_boot_id): logging.info("Client is rebooting") logging.info("Waiting for client to halt") if not self.host.wait_down(HALT_TIME, old_boot_id=old_boot_id): err = "%s failed to shutdown after %d" err %= (self.host.hostname, HALT_TIME) raise error.AutotestRunError(err) logging.info("Client down, waiting for restart") if not self.host.wait_up(BOOT_TIME): # since reboot failed # hardreset the machine once if possible # before failing this control file warning = "%s did not come back up, hard resetting" warning %= self.host.hostname logging.warning(warning) try: self.host.hardreset(wait=False) except (AttributeError, error.AutoservUnsupportedError): warning = "Hard reset unsupported on %s" warning %= self.host.hostname logging.warning(warning) raise error.AutotestRunError("%s failed to boot after %ds" % (self.host.hostname, BOOT_TIME)) self.host.reboot_followup() def execute_control(self, timeout=None, client_disconnect_timeout=None): if not self.background: collector = log_collector(self.host, self.tag, self.results_dir) hostname = self.host.hostname remote_results = collector.client_results_dir local_results = collector.server_results_dir self.host.job.add_client_log(hostname, remote_results, local_results) job_record_context = self.host.job.get_record_context() section = 0 start_time = time.time() logger = client_logger(self.host, self.tag, self.results_dir) try: while not timeout or time.time() < start_time + timeout: if timeout: section_timeout = start_time + timeout - time.time() else: section_timeout = None boot_id = self.host.get_boot_id() last = self.execute_section(section, section_timeout, logger, client_disconnect_timeout) if self.background: return section += 1 if self.is_client_job_finished(last): logging.info("Client complete") return elif self.is_client_job_rebooting(last): try: self._wait_for_reboot(boot_id) except error.AutotestRunError, e: self.host.job.record("ABORT", None, "reboot", str(e)) self.host.job.record("END ABORT", None, None, str(e)) raise continue # if we reach here, something unexpected happened self.log_unexpected_abort(logger) # give the client machine a chance to recover from a crash self.host.wait_up(CRASH_RECOVERY_TIME) msg = ("Aborting - unexpected final status message from " "client on %s: %s\n") % (self.host.hostname, last) raise error.AutotestRunError(msg) finally: logger.close() if not self.background: collector.collect_client_job_results() collector.remove_redundant_client_logs() state_file = os.path.basename(self.remote_control_file + '.state') state_path = os.path.join(self.results_dir, state_file) self.host.job.postprocess_client_state(state_path) self.host.job.remove_client_log(hostname, remote_results, local_results) job_record_context.restore() # should only get here if we timed out assert timeout raise error.AutotestTimeoutError() class log_collector(object): def __init__(self, host, client_tag, results_dir): self.host = host if not client_tag: client_tag = "default" self.client_results_dir = os.path.join(host.get_autodir(), "results", client_tag) self.server_results_dir = results_dir def collect_client_job_results(self): """ A method that collects all the current results of a running client job into the results dir. By default does nothing as no client job is running, but when running a client job you can override this with something that will actually do something. """ # make an effort to wait for the machine to come up try: self.host.wait_up(timeout=30) except error.AutoservError: # don't worry about any errors, we'll try and # get the results anyway pass # Copy all dirs in default to results_dir try: self.host.get_file(self.client_results_dir + '/', self.server_results_dir, preserve_symlinks=True) except Exception: # well, don't stop running just because we couldn't get logs e_msg = "Unexpected error copying test result logs, continuing ..." logging.error(e_msg) traceback.print_exc(file=sys.stdout) def remove_redundant_client_logs(self): """Remove client.*.log files in favour of client.*.DEBUG files.""" debug_dir = os.path.join(self.server_results_dir, 'debug') debug_files = [f for f in os.listdir(debug_dir) if re.search(r'^client\.\d+\.DEBUG$', f)] for debug_file in debug_files: log_file = debug_file.replace('DEBUG', 'log') log_file = os.path.join(debug_dir, log_file) if os.path.exists(log_file): os.remove(log_file) # a file-like object for catching stderr from an autotest client and # extracting status logs from it class client_logger(object): """Partial file object to write to both stdout and the status log file. We only implement those methods utils.run() actually calls. """ status_parser = re.compile(r"^AUTOTEST_STATUS:([^:]*):(.*)$") test_complete_parser = re.compile(r"^AUTOTEST_TEST_COMPLETE:(.*)$") fetch_package_parser = re.compile( r"^AUTOTEST_FETCH_PACKAGE:([^:]*):([^:]*):(.*)$") extract_indent = re.compile(r"^(\t*).*$") extract_timestamp = re.compile(r".*\ttimestamp=(\d+)\t.*$") def __init__(self, host, tag, server_results_dir): self.host = host self.job = host.job self.log_collector = log_collector(host, tag, server_results_dir) self.leftover = "" self.last_line = "" self.logs = {} def _process_log_dict(self, log_dict): log_list = log_dict.pop("logs", []) for key in sorted(log_dict.iterkeys()): log_list += self._process_log_dict(log_dict.pop(key)) return log_list def _process_logs(self): """Go through the accumulated logs in self.log and print them out to stdout and the status log. Note that this processes logs in an ordering where: 1) logs to different tags are never interleaved 2) logs to x.y come before logs to x.y.z for all z 3) logs to x.y come before x.z whenever y < z Note that this will in general not be the same as the chronological ordering of the logs. However, if a chronological ordering is desired that one can be reconstructed from the status log by looking at timestamp lines.""" log_list = self._process_log_dict(self.logs) for entry in log_list: self.job.record_entry(entry, log_in_subdir=False) if log_list: self.last_line = log_list[-1].render() def _process_quoted_line(self, tag, line): """Process a line quoted with an AUTOTEST_STATUS flag. If the tag is blank then we want to push out all the data we've been building up in self.logs, and then the newest line. If the tag is not blank, then push the line into the logs for handling later.""" entry = base_job.status_log_entry.parse(line) if entry is None: return # the line contains no status lines if tag == "": self._process_logs() self.job.record_entry(entry, log_in_subdir=False) self.last_line = line else: tag_parts = [int(x) for x in tag.split(".")] log_dict = self.logs for part in tag_parts: log_dict = log_dict.setdefault(part, {}) log_list = log_dict.setdefault("logs", []) log_list.append(entry) def _process_info_line(self, line): """Check if line is an INFO line, and if it is, interpret any control messages (e.g. enabling/disabling warnings) that it may contain.""" match = re.search(r"^\t*INFO\t----\t----(.*)\t[^\t]*$", line) if not match: return # not an INFO line for field in match.group(1).split('\t'): if field.startswith("warnings.enable="): func = self.job.warning_manager.enable_warnings elif field.startswith("warnings.disable="): func = self.job.warning_manager.disable_warnings else: continue warning_type = field.split("=", 1)[1] func(warning_type) def _process_line(self, line): """Write out a line of data to the appropriate stream. Status lines sent by autotest will be prepended with "AUTOTEST_STATUS", and all other lines are ssh error messages.""" status_match = self.status_parser.search(line) test_complete_match = self.test_complete_parser.search(line) fetch_package_match = self.fetch_package_parser.search(line) if status_match: tag, line = status_match.groups() self._process_info_line(line) self._process_quoted_line(tag, line) elif test_complete_match: self._process_logs() fifo_path, = test_complete_match.groups() try: self.log_collector.collect_client_job_results() self.host.run("echo A > %s" % fifo_path) except Exception: msg = "Post-test log collection failed, continuing anyway" logging.exception(msg) elif fetch_package_match: pkg_name, dest_path, fifo_path = fetch_package_match.groups() serve_packages = global_config.global_config.get_config_value( "PACKAGES", "serve_packages_from_autoserv", type=bool) if serve_packages and pkg_name.endswith(".tar.bz2"): try: self._send_tarball(pkg_name, dest_path) except Exception: msg = "Package tarball creation failed, continuing anyway" logging.exception(msg) try: self.host.run("echo B > %s" % fifo_path) except Exception: msg = "Package tarball installation failed, continuing anyway" logging.exception(msg) else: logging.info(line) def _send_tarball(self, pkg_name, remote_dest): name, pkg_type = self.job.pkgmgr.parse_tarball_name(pkg_name) src_dirs = [] if pkg_type == 'test': for test_dir in ['site_tests', 'tests']: src_dir = os.path.join(self.job.clientdir, test_dir, name) if os.path.exists(src_dir): src_dirs += [src_dir] if autoserv_prebuild: prebuild.setup(self.job.clientdir, src_dir) break elif pkg_type == 'profiler': src_dirs += [os.path.join(self.job.clientdir, 'profilers', name)] if autoserv_prebuild: prebuild.setup(self.job.clientdir, src_dir) elif pkg_type == 'dep': src_dirs += [os.path.join(self.job.clientdir, 'deps', name)] elif pkg_type == 'client': return # you must already have a client to hit this anyway else: return # no other types are supported # iterate over src_dirs until we find one that exists, then tar it for src_dir in src_dirs: if os.path.exists(src_dir): try: logging.info('Bundling %s into %s', src_dir, pkg_name) temp_dir = autotemp.tempdir(unique_id='autoserv-packager', dir=self.job.tmpdir) tarball_path = self.job.pkgmgr.tar_package( pkg_name, src_dir, temp_dir.name, " .") self.host.send_file(tarball_path, remote_dest) finally: temp_dir.clean() return def log_warning(self, msg, warning_type): """Injects a WARN message into the current status logging stream.""" timestamp = int(time.time()) if self.job.warning_manager.is_valid(timestamp, warning_type): self.job.record('WARN', None, None, msg) def write(self, data): # now start processing the existing buffer and the new data data = self.leftover + data lines = data.split('\n') processed_lines = 0 try: # process all the buffered data except the last line # ignore the last line since we may not have all of it yet for line in lines[:-1]: self._process_line(line) processed_lines += 1 finally: # save any unprocessed lines for future processing self.leftover = '\n'.join(lines[processed_lines:]) def flush(self): sys.stdout.flush() def flush_all_buffers(self): if self.leftover: self._process_line(self.leftover) self.leftover = "" self._process_logs() self.flush() def close(self): self.flush_all_buffers() SiteAutotest = client_utils.import_site_class( __file__, "autotest_lib.server.site_autotest", "SiteAutotest", BaseAutotest) _SiteRun = client_utils.import_site_class( __file__, "autotest_lib.server.site_autotest", "_SiteRun", _BaseRun) class Autotest(SiteAutotest): pass class _Run(_SiteRun): pass class AutotestHostMixin(object): """A generic mixin to add a run_test method to classes, which will allow you to run an autotest client test on a machine directly.""" # for testing purposes _Autotest = Autotest def run_test(self, test_name, **dargs): """Run an autotest client test on the host. @param test_name: The name of the client test. @param dargs: Keyword arguments to pass to the test. @returns: True if the test passes, False otherwise.""" at = self._Autotest() control_file = ('result = job.run_test(%s)\n' 'job.set_state("test_result", result)\n') test_args = [repr(test_name)] test_args += ['%s=%r' % (k, v) for k, v in dargs.iteritems()] control_file %= ', '.join(test_args) at.run(control_file, host=self) return at.job.get_state('test_result', default=False)
gpl-2.0
[ 3, 1898, 10219, 4475, 3277, 14, 17646, 68, 1334, 314, 14629, 373, 18, 199, 199, 646, 295, 12, 747, 12, 984, 12, 5190, 12, 3873, 12, 900, 12, 5927, 12, 5739, 12, 5549, 199, 646, 2050, 12, 18354, 199, 504, 2599, 396, 63, 773, 14, 1000, 492, 3907, 461, 63, 785, 12, 876, 1506, 12, 3778, 199, 504, 2599, 396, 63, 773, 14, 1258, 14, 2330, 63, 773, 492, 1300, 63, 2423, 12, 943, 12, 1125, 12, 2599, 808, 199, 504, 2599, 396, 63, 773, 14, 1258, 14, 2330, 63, 773, 492, 2288, 63, 888, 12, 6117, 199, 504, 2599, 396, 63, 773, 14, 1258, 14, 2330, 63, 773, 492, 3778, 465, 1890, 63, 1208, 199, 199, 10774, 1387, 1719, 63, 31222, 221, 275, 283, 6836, 921, 396, 14, 4989, 14, 1308, 15, 2495, 396, 15, 13409, 15, 1258, 7, 199, 10774, 1387, 1719, 63, 2856, 275, 283, 1014, 921, 396, 14, 4989, 14, 1308, 15, 6836, 15, 2495, 396, 15, 13409, 15, 1258, 7, 199, 199, 3, 12878, 83, 367, 7074, 316, 3224, 436, 1536, 17342, 199, 40, 19600, 63, 4961, 275, 9601, 199, 22679, 63, 4961, 275, 6155, 383, 199, 2944, 8100, 63, 907, 19052, 57, 63, 4961, 275, 1749, 1493, 421, 199, 362, 63, 585, 275, 2288, 63, 888, 14, 2966, 63, 888, 14, 362, 63, 888, 63, 585, 199, 2495, 7297, 63, 657, 1506, 275, 664, 63, 585, 360, 10774, 3100, 540, 54, 297, 283, 4296, 63, 1000, 63, 657, 1506, 297, 2892, 730, 29, 2245, 12, 849, 29, 797, 9, 421, 199, 533, 9195, 694, 10870, 8, 1726, 304, 272, 408, 1944, 9195, 396, 12096, 4293, 506, 1911, 1041, 421, 199, 533, 3523, 3358, 396, 8, 21762, 63, 785, 14, 8154, 461, 1692, 304, 272, 408, 272, 961, 1021, 8469, 314, 9195, 396, 2240, 14, 339, 9195, 396, 365, 1202, 370, 1255, 2295, 5847, 436, 8775, 314, 2058, 14, 272, 2779, 2597, 5171, 4690, 2393, 14, 339, 24425, 2436, 26, 272, 961, 365, 282, 11747, 1021, 315, 376, 9006, 1021, 14446, 12, 652, 1471, 272, 5669, 314, 625, 13825, 3102, 315, 1676, 3992, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1591, 275, 488, 304, 267, 291, 14, 1102, 275, 1591, 267, 291, 14, 7808, 275, 756, 267, 291, 14, 7657, 275, 756, 267, 291, 14, 1000, 694, 275, 3778, 14, 362, 63, 1000, 63, 694, 342, 267, 1613, 8, 1563, 3358, 396, 12, 291, 2843, 826, 4533, 2378, 3907, 63, 262, 63, 8616, 275, 756, 272, 768, 3744, 272, 347, 663, 63, 3174, 63, 262, 63, 8616, 8, 1886, 12, 3305, 304, 267, 408, 10729, 282, 3305, 626, 13467, 3775, 503, 440, 9195, 396, 1077, 701, 267, 849, 506, 4903, 315, 282, 298, 6807, 2, 2082, 334, 69, 14, 71, 14, 267, 1182, 4219, 15, 2495, 396, 12, 1182, 2647, 15, 1832, 15, 2495, 396, 9, 503, 282, 7937, 2082, 14, 408, 267, 843, 14, 3174, 63, 262, 63, 8616, 275, 3305, 2378, 768, 3744, 272, 347, 664, 63, 1258, 63, 2495, 694, 63, 3771, 8, 1886, 12, 1591, 304, 267, 372, 2288, 63, 888, 14, 2966, 63, 888, 14, 362, 63, 888, 63, 585, 8, 355, 283, 10774, 3100, 540, 54, 297, 283, 1258, 63, 2495, 694, 63, 3771, 297, 730, 29, 513, 9, 2378, 768, 3744, 272, 347, 664, 63, 7657, 63, 2495, 694, 8, 1886, 12, 1591, 304, 267, 408, 267, 6668, 2382, 314, 9195, 396, 1890, 365, 4903, 641, 314, 1591, 14, 267, 768, 5808, 376, 3679, 931, 370, 376, 4903, 9195, 396, 1890, 1738, 14, 267, 768, 3536, 9195, 694, 10870, 340, 949, 9195, 396, 12096, 883, 506, 1911, 14, 267, 408, 267, 2599, 694, 275, 1591, 14, 362, 63, 2495, 694, 342, 267, 340, 2599, 694, 26, 288, 2050, 14, 1757, 360, 10369, 3411, 1591, 2599, 694, 26, 450, 83, 297, 2599, 694, 9, 288, 372, 2599, 694, 398, 367, 931, 315, 9195, 396, 14, 362, 63, 1258, 63, 2495, 694, 63, 3771, 8, 1102, 304, 288, 862, 26, 355, 2599, 396, 63, 3008, 275, 747, 14, 515, 14, 904, 8, 515, 12, 283, 1393, 297, 283, 2495, 396, 358, 355, 1591, 14, 1065, 360, 396, 446, 88, 450, 83, 7, 450, 3778, 14, 609, 63, 3765, 8, 2495, 396, 63, 3008, 430, 355, 1591, 14, 1065, 360, 396, 446, 87, 450, 83, 7, 450, 3778, 14, 609, 63, 3765, 8, 515, 430, 355, 2050, 14, 1757, 360, 3601, 3411, 2599, 694, 737, 450, 83, 297, 931, 9, 355, 372, 931, 288, 871, 1125, 14, 3358, 7297, 2540, 547, 26, 355, 2050, 14, 1757, 3508, 83, 1630, 440, 2187, 641, 450, 83, 297, 2599, 396, 63, 3008, 12, 2892, 1591, 14, 4269, 9, 267, 746, 9195, 694, 10870, 2378, 768, 3744, 272, 347, 664, 63, 3174, 63, 694, 8, 1886, 12, 1591, 304, 267, 408, 267, 22391, 314, 2909, 2382, 2599, 396, 1077, 506, 4903, 641, 267, 1591, 14, 982, 291, 14, 3174, 63, 262, 63, 8616, 365, 663, 12, 652, 911, 372, 282, 3747, 267, 7937, 2082, 626, 2599, 396, 883, 506, 4903, 315, 14, 6630, 12, 10734, 267, 367, 376, 3411, 12096, 370, 675, 27, 340, 7179, 365, 1911, 12, 10734, 367, 282, 267, 18025, 2082, 315, 314, 2288, 1101, 1890, 63, 2495, 694, 63, 3771, 14, 267, 408, 267, 862, 26, 288, 3907, 63, 694, 275, 843, 14, 362, 63, 7657, 63, 2495, 694, 8, 1102, 9, 267, 871, 9195, 694, 10870, 26, 288, 3907, 63, 694, 275, 843, 423, 1623, 63, 21762, 63, 694, 8, 1102, 9, 398, 340, 843, 14, 3174, 63, 262, 63, 8616, 26, 288, 372, 1591, 14, 362, 63, 2791, 63, 694, 8, 1708, 29, 3174, 63, 694, 9, 267, 372, 3907, 63, 694, 2378, 768, 3744, 272, 347, 485, 1623, 63, 21762, 63, 694, 8, 1886, 12, 1591, 304, 267, 1890, 63, 2495, 694, 63, 3771, 275, 843, 14, 362, 63, 1258, 63, 2495, 694, 63, 3771, 8, 1102, 9, 267, 367, 931, 315, 1890, 63, 2495, 694, 63, 3771, 26, 288, 862, 26, 355, 1591, 14, 1065, 360, 8215, 446, 80, 450, 83, 7, 450, 3778, 14, 609, 63, 3765, 8, 515, 430, 355, 1591, 14, 1065, 360, 396, 446 ]
[ 1898, 10219, 4475, 3277, 14, 17646, 68, 1334, 314, 14629, 373, 18, 199, 199, 646, 295, 12, 747, 12, 984, 12, 5190, 12, 3873, 12, 900, 12, 5927, 12, 5739, 12, 5549, 199, 646, 2050, 12, 18354, 199, 504, 2599, 396, 63, 773, 14, 1000, 492, 3907, 461, 63, 785, 12, 876, 1506, 12, 3778, 199, 504, 2599, 396, 63, 773, 14, 1258, 14, 2330, 63, 773, 492, 1300, 63, 2423, 12, 943, 12, 1125, 12, 2599, 808, 199, 504, 2599, 396, 63, 773, 14, 1258, 14, 2330, 63, 773, 492, 2288, 63, 888, 12, 6117, 199, 504, 2599, 396, 63, 773, 14, 1258, 14, 2330, 63, 773, 492, 3778, 465, 1890, 63, 1208, 199, 199, 10774, 1387, 1719, 63, 31222, 221, 275, 283, 6836, 921, 396, 14, 4989, 14, 1308, 15, 2495, 396, 15, 13409, 15, 1258, 7, 199, 10774, 1387, 1719, 63, 2856, 275, 283, 1014, 921, 396, 14, 4989, 14, 1308, 15, 6836, 15, 2495, 396, 15, 13409, 15, 1258, 7, 199, 199, 3, 12878, 83, 367, 7074, 316, 3224, 436, 1536, 17342, 199, 40, 19600, 63, 4961, 275, 9601, 199, 22679, 63, 4961, 275, 6155, 383, 199, 2944, 8100, 63, 907, 19052, 57, 63, 4961, 275, 1749, 1493, 421, 199, 362, 63, 585, 275, 2288, 63, 888, 14, 2966, 63, 888, 14, 362, 63, 888, 63, 585, 199, 2495, 7297, 63, 657, 1506, 275, 664, 63, 585, 360, 10774, 3100, 540, 54, 297, 283, 4296, 63, 1000, 63, 657, 1506, 297, 2892, 730, 29, 2245, 12, 849, 29, 797, 9, 421, 199, 533, 9195, 694, 10870, 8, 1726, 304, 272, 408, 1944, 9195, 396, 12096, 4293, 506, 1911, 1041, 421, 199, 533, 3523, 3358, 396, 8, 21762, 63, 785, 14, 8154, 461, 1692, 304, 272, 408, 272, 961, 1021, 8469, 314, 9195, 396, 2240, 14, 339, 9195, 396, 365, 1202, 370, 1255, 2295, 5847, 436, 8775, 314, 2058, 14, 272, 2779, 2597, 5171, 4690, 2393, 14, 339, 24425, 2436, 26, 272, 961, 365, 282, 11747, 1021, 315, 376, 9006, 1021, 14446, 12, 652, 1471, 272, 5669, 314, 625, 13825, 3102, 315, 1676, 3992, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1591, 275, 488, 304, 267, 291, 14, 1102, 275, 1591, 267, 291, 14, 7808, 275, 756, 267, 291, 14, 7657, 275, 756, 267, 291, 14, 1000, 694, 275, 3778, 14, 362, 63, 1000, 63, 694, 342, 267, 1613, 8, 1563, 3358, 396, 12, 291, 2843, 826, 4533, 2378, 3907, 63, 262, 63, 8616, 275, 756, 272, 768, 3744, 272, 347, 663, 63, 3174, 63, 262, 63, 8616, 8, 1886, 12, 3305, 304, 267, 408, 10729, 282, 3305, 626, 13467, 3775, 503, 440, 9195, 396, 1077, 701, 267, 849, 506, 4903, 315, 282, 298, 6807, 2, 2082, 334, 69, 14, 71, 14, 267, 1182, 4219, 15, 2495, 396, 12, 1182, 2647, 15, 1832, 15, 2495, 396, 9, 503, 282, 7937, 2082, 14, 408, 267, 843, 14, 3174, 63, 262, 63, 8616, 275, 3305, 2378, 768, 3744, 272, 347, 664, 63, 1258, 63, 2495, 694, 63, 3771, 8, 1886, 12, 1591, 304, 267, 372, 2288, 63, 888, 14, 2966, 63, 888, 14, 362, 63, 888, 63, 585, 8, 355, 283, 10774, 3100, 540, 54, 297, 283, 1258, 63, 2495, 694, 63, 3771, 297, 730, 29, 513, 9, 2378, 768, 3744, 272, 347, 664, 63, 7657, 63, 2495, 694, 8, 1886, 12, 1591, 304, 267, 408, 267, 6668, 2382, 314, 9195, 396, 1890, 365, 4903, 641, 314, 1591, 14, 267, 768, 5808, 376, 3679, 931, 370, 376, 4903, 9195, 396, 1890, 1738, 14, 267, 768, 3536, 9195, 694, 10870, 340, 949, 9195, 396, 12096, 883, 506, 1911, 14, 267, 408, 267, 2599, 694, 275, 1591, 14, 362, 63, 2495, 694, 342, 267, 340, 2599, 694, 26, 288, 2050, 14, 1757, 360, 10369, 3411, 1591, 2599, 694, 26, 450, 83, 297, 2599, 694, 9, 288, 372, 2599, 694, 398, 367, 931, 315, 9195, 396, 14, 362, 63, 1258, 63, 2495, 694, 63, 3771, 8, 1102, 304, 288, 862, 26, 355, 2599, 396, 63, 3008, 275, 747, 14, 515, 14, 904, 8, 515, 12, 283, 1393, 297, 283, 2495, 396, 358, 355, 1591, 14, 1065, 360, 396, 446, 88, 450, 83, 7, 450, 3778, 14, 609, 63, 3765, 8, 2495, 396, 63, 3008, 430, 355, 1591, 14, 1065, 360, 396, 446, 87, 450, 83, 7, 450, 3778, 14, 609, 63, 3765, 8, 515, 430, 355, 2050, 14, 1757, 360, 3601, 3411, 2599, 694, 737, 450, 83, 297, 931, 9, 355, 372, 931, 288, 871, 1125, 14, 3358, 7297, 2540, 547, 26, 355, 2050, 14, 1757, 3508, 83, 1630, 440, 2187, 641, 450, 83, 297, 2599, 396, 63, 3008, 12, 2892, 1591, 14, 4269, 9, 267, 746, 9195, 694, 10870, 2378, 768, 3744, 272, 347, 664, 63, 3174, 63, 694, 8, 1886, 12, 1591, 304, 267, 408, 267, 22391, 314, 2909, 2382, 2599, 396, 1077, 506, 4903, 641, 267, 1591, 14, 982, 291, 14, 3174, 63, 262, 63, 8616, 365, 663, 12, 652, 911, 372, 282, 3747, 267, 7937, 2082, 626, 2599, 396, 883, 506, 4903, 315, 14, 6630, 12, 10734, 267, 367, 376, 3411, 12096, 370, 675, 27, 340, 7179, 365, 1911, 12, 10734, 367, 282, 267, 18025, 2082, 315, 314, 2288, 1101, 1890, 63, 2495, 694, 63, 3771, 14, 267, 408, 267, 862, 26, 288, 3907, 63, 694, 275, 843, 14, 362, 63, 7657, 63, 2495, 694, 8, 1102, 9, 267, 871, 9195, 694, 10870, 26, 288, 3907, 63, 694, 275, 843, 423, 1623, 63, 21762, 63, 694, 8, 1102, 9, 398, 340, 843, 14, 3174, 63, 262, 63, 8616, 26, 288, 372, 1591, 14, 362, 63, 2791, 63, 694, 8, 1708, 29, 3174, 63, 694, 9, 267, 372, 3907, 63, 694, 2378, 768, 3744, 272, 347, 485, 1623, 63, 21762, 63, 694, 8, 1886, 12, 1591, 304, 267, 1890, 63, 2495, 694, 63, 3771, 275, 843, 14, 362, 63, 1258, 63, 2495, 694, 63, 3771, 8, 1102, 9, 267, 367, 931, 315, 1890, 63, 2495, 694, 63, 3771, 26, 288, 862, 26, 355, 1591, 14, 1065, 360, 8215, 446, 80, 450, 83, 7, 450, 3778, 14, 609, 63, 3765, 8, 515, 430, 355, 1591, 14, 1065, 360, 396, 446, 0 ]
[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]
knxd/PyKNyX
pyknyx/core/dptXlator/dptXlator4ByteSigned.py
2
4124
# -*- coding: utf-8 -*- """ Python KNX framework License ======= - B{PyKNyX} (U{https://github.com/knxd/pyknyx}) is Copyright: - © 2016-2017 Matthias Urlichs - PyKNyX is a fork of pKNyX - © 2013-2015 Frédéric Mantegazza This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or see: - U{http://www.gnu.org/licenses/gpl.html} Module purpose ============== Datapoint Types management Implements ========== - B{DPTXlator4ByteSigned} Usage ===== see L{DPTXlatorBoolean} @author: Frédéric Mantegazza @author: B. Malinowsky @copyright: (C) 2013-2015 Frédéric Mantegazza @copyright: (C) 2006, 2011 B. Malinowsky @license: GPL """ import struct from pyknyx.services.logger import logging; logger = logging.getLogger(__name__) from pyknyx.core.dptXlator.dptId import DPTID from pyknyx.core.dptXlator.dpt import DPT from pyknyx.core.dptXlator.dptXlatorBase import DPTXlatorBase, DPTXlatorValueError class DPTXlator4ByteSigned(DPTXlatorBase): """ DPTXlator class for 4-Byte-Signed (V32) KNX Datapoint Type - 4 Byte Signed: VVVVVVVV VVVVVVVV VVVVVVVV VVVVVVVV - V: Bytes [-2147483648:2147483647] . """ DPT_Generic = DPT("13.xxx", "Generic", (-2147483648, 2147483647)) DPT_Value_4_Count = DPT("13.001", "Signed count", (-2147483648, 2147483647), "pulses") DPT_Value_FlowRate_m3h = DPT("13.001", "Flow rate", (-214748.3648, 214748.3647), "m³/h") DPT_ActiveEnergy = DPT("13.010", "Active energy", (-214748.3648, 214748.3647), "W.h") DPT_ApparentEnergy = DPT("13.011", "Apparent energy", (-214748.3648, 214748.3647), "VA.h") DPT_ReactiveEnergy = DPT("13.012", "Reactive energy", (-214748.3648, 214748.3647), "VAR.h") DPT_ActiveEnergy_kWh = DPT("13.013", "Active energy (kWh)", (-214748.3648, 214748.3647), "kW.h") DPT_ApparentEnergy_kVAh = DPT("13.014", "Apparent energy (kVAh)", (-214748.3648, 214748.3647), "kVA.h") DPT_ReactiveEnergy_KVARh = DPT("13.015", "Reactive energy (kVARh)", (-214748.3648, 214748.3647), "kVAR.h") DPT_LongDeltaTimeSec = DPT("13.100", "Long delta time", (-214748.3648, 214748.3647), "s") def __init__(self, dptId): super(DPTXlator4ByteSigned, self).__init__(dptId, 4) def checkData(self, data): if not 0x00000000 <= data <= 0xffffffff: raise DPTXlatorValueError("data %s not in (0x00000000, 0xffffffff)" % hex(data)) def checkValue(self, value): if not self._dpt.limits[0] <= value <= self._dpt.limits[1]: raise DPTXlatorValueError("Value not in range %s" % repr(self._dpt.limits)) def dataToValue(self, data): if data >= 0x80000000: data = -((data - 1) ^ 0xffffffff) # invert twos complement else: data = data if self._dpt is self.DPT_Value_FlowRate_m3h: value = data / 10000. else: value = data #logger.debug("DPTXlator4ByteSigned._toValue(): value=%d" % value) return value def valueToData(self, value): if value < 0: value = (abs(value) ^ 0xffffffff) + 1 # twos complement if self._dpt is self.DPT_Value_FlowRate_m3h: data = int(round(value * 10000.)) else: data = value #logger.debug("DPTXlator4ByteSigned.valueToData(): data=%s" % hex(data)) return data def dataToFrame(self, data): return bytearray(struct.pack(">L", data)) def frameToData(self, frame): data = struct.unpack(">L", frame)[0] return data
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 2018, 1804, 16764, 10059, 199, 199, 3761, 199, 18673, 421, 446, 699, 91, 2713, 43, 22781, 56, 93, 334, 53, 91, 2859, 921, 5031, 14, 957, 15, 18974, 2207, 15, 647, 75, 9745, 88, 1552, 365, 1898, 26, 523, 446, 22405, 103, 7800, 13, 10680, 18619, 273, 2241, 738, 82, 317, 32556, 523, 446, 1611, 43, 22781, 56, 365, 282, 14926, 402, 299, 43, 22781, 56, 2043, 446, 22405, 103, 6171, 13, 7806, 481, 82, 5741, 68, 5741, 1567, 4688, 266, 5294, 4348, 65, 199, 199, 2765, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 2765, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 30216, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 8217, 199, 269, 1937, 26, 421, 446, 738, 91, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 14, 1360, 93, 199, 199, 2377, 12016, 199, 17224, 199, 199, 1451, 1403, 18851, 10041, 199, 199, 29452, 199, 17575, 421, 446, 699, 91, 36, 4189, 56, 13693, 20, 4861, 23013, 93, 199, 199, 7692, 199, 19989, 199, 199, 3239, 491, 91, 36, 4189, 56, 13693, 4082, 93, 199, 199, 32, 2502, 26, 481, 82, 5741, 68, 5741, 1567, 4688, 266, 5294, 4348, 65, 199, 32, 2502, 26, 699, 14, 29936, 262, 583, 12267, 199, 32, 7307, 26, 334, 35, 9, 6171, 13, 7806, 481, 82, 5741, 68, 5741, 1567, 4688, 266, 5294, 4348, 65, 199, 32, 7307, 26, 334, 35, 9, 8315, 12, 7760, 699, 14, 29936, 262, 583, 12267, 199, 32, 1682, 26, 14629, 199, 624, 199, 199, 646, 2702, 199, 199, 504, 1134, 75, 9745, 88, 14, 5950, 14, 2921, 492, 2050, 27, 2512, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 504, 1134, 75, 9745, 88, 14, 1018, 14, 68, 541, 56, 13693, 14, 68, 541, 1304, 492, 577, 4189, 998, 199, 504, 1134, 75, 9745, 88, 14, 1018, 14, 68, 541, 56, 13693, 14, 68, 541, 492, 577, 4189, 199, 504, 1134, 75, 9745, 88, 14, 1018, 14, 68, 541, 56, 13693, 14, 68, 541, 56, 13693, 1563, 492, 577, 4189, 56, 13693, 1563, 12, 577, 4189, 56, 13693, 3393, 421, 199, 533, 577, 4189, 56, 13693, 20, 4861, 23013, 8, 36, 4189, 56, 13693, 1563, 304, 272, 408, 577, 4189, 56, 13693, 1021, 367, 841, 13, 4861, 13, 23013, 334, 54, 708, 9, 1804, 16764, 3918, 1403, 2434, 10813, 446, 841, 20301, 6632, 379, 26, 812, 17578, 17578, 17578, 54, 812, 17578, 17578, 17578, 54, 812, 17578, 17578, 17578, 54, 812, 17578, 17578, 17578, 54, 1362, 446, 812, 26, 9879, 5243, 22519, 10552, 26, 22519, 8557, 61, 339, 1275, 272, 408, 272, 577, 4189, 63, 9417, 275, 577, 4189, 480, 969, 14, 10013, 401, 298, 9417, 401, 5868, 22519, 10552, 12, 21237, 16809, 8557, 430, 339, 577, 4189, 63, 1110, 63, 20, 63, 2353, 275, 577, 4189, 480, 969, 14, 4587, 401, 298, 23013, 2338, 401, 5868, 22519, 10552, 12, 21237, 16809, 8557, 395, 298, 80, 348, 874, 531, 272, 577, 4189, 63, 1110, 63, 5060, 6621, 63, 77, 19, 72, 275, 577, 4189, 480, 969, 14, 4587, 401, 298, 5060, 6634, 401, 5868, 6886, 18770, 14, 19, 10552, 12, 21237, 18770, 14, 19, 8557, 395, 298, 77, 127, 112, 15, 72, 531, 272, 577, 4189, 63, 7472, 9900, 275, 577, 4189, 480, 969, 14, 9523, 401, 298, 7472, 12304, 401, 5868, 6886, 18770, 14, 19, 10552, 12, 21237, 18770, 14, 19, 8557, 395, 298, 55, 14, 72, 531, 272, 577, 4189, 63, 13117, 1708, 9900, 275, 577, 4189, 480, 969, 14, 13059, 401, 298, 13117, 1708, 12304, 401, 5868, 6886, 18770, 14, 19, 10552, 12, 21237, 18770, 14, 19, 8557, 395, 298, 15162, 14, 72, 531, 272, 577, 4189, 63, 497, 2682, 9900, 275, 577, 4189, 480, 969, 14, 11533, 401, 298, 497, 2682, 12304, 401, 5868, 6886, 18770, 14, 19, 10552, 12, 21237, 18770, 14, 19, 8557, 395, 298, 5568, 14, 72, 531, 272, 577, 4189, 63, 7472, 9900, 63, 75, 5879, 275, 577, 4189, 480, 969, 14, 13264, 401, 298, 7472, 12304, 334, 75, 5879, 4186, 5868, 6886, 18770, 14, 19, 10552, 12, 21237, 18770, 14, 19, 8557, 395, 298, 75, 55, 14, 72, 531, 272, 577, 4189, 63, 13117, 1708, 9900, 63, 75, 15162, 72, 275, 577, 4189, 480, 969, 14, 10752, 401, 298, 13117, 1708, 12304, 334, 75, 15162, 72, 4186, 5868, 6886, 18770, 14, 19, 10552, 12, 21237, 18770, 14, 19, 8557, 395, 298, 75, 15162, 14, 72, 531, 272, 577, 4189, 63, 497, 2682, 9900, 63, 43, 5568, 72, 275, 577, 4189, 480, 969, 14, 11164, 401, 298, 497, 2682, 12304, 334, 75, 5568, 72, 4186, 5868, 6886, 18770, 14, 19, 10552, 12, 21237, 18770, 14, 19, 8557, 395, 298, 75, 5568, 14, 72, 531, 272, 577, 4189, 63, 9551, 13411, 1366, 4933, 275, 577, 4189, 480, 969, 14, 1960, 401, 298, 9551, 5762, 900, 401, 5868, 6886, 18770, 14, 19, 10552, 12, 21237, 18770, 14, 19, 8557, 395, 298, 83, 531, 339, 347, 636, 826, 721, 277, 12, 366, 541, 1304, 304, 267, 1613, 8, 36, 4189, 56, 13693, 20, 4861, 23013, 12, 291, 2843, 826, 721, 68, 541, 1304, 12, 841, 9, 339, 347, 1104, 1451, 8, 277, 12, 666, 304, 267, 340, 440, 378, 88, 3607, 2695, 666, 2695, 378, 21870, 26, 288, 746, 577, 4189, 56, 13693, 3393, 480, 576, 450, 83, 440, 315, 334, 16, 88, 3607, 12, 378, 21870, 2924 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 2018, 1804, 16764, 10059, 199, 199, 3761, 199, 18673, 421, 446, 699, 91, 2713, 43, 22781, 56, 93, 334, 53, 91, 2859, 921, 5031, 14, 957, 15, 18974, 2207, 15, 647, 75, 9745, 88, 1552, 365, 1898, 26, 523, 446, 22405, 103, 7800, 13, 10680, 18619, 273, 2241, 738, 82, 317, 32556, 523, 446, 1611, 43, 22781, 56, 365, 282, 14926, 402, 299, 43, 22781, 56, 2043, 446, 22405, 103, 6171, 13, 7806, 481, 82, 5741, 68, 5741, 1567, 4688, 266, 5294, 4348, 65, 199, 199, 2765, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 2765, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 30216, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 8217, 199, 269, 1937, 26, 421, 446, 738, 91, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 14, 1360, 93, 199, 199, 2377, 12016, 199, 17224, 199, 199, 1451, 1403, 18851, 10041, 199, 199, 29452, 199, 17575, 421, 446, 699, 91, 36, 4189, 56, 13693, 20, 4861, 23013, 93, 199, 199, 7692, 199, 19989, 199, 199, 3239, 491, 91, 36, 4189, 56, 13693, 4082, 93, 199, 199, 32, 2502, 26, 481, 82, 5741, 68, 5741, 1567, 4688, 266, 5294, 4348, 65, 199, 32, 2502, 26, 699, 14, 29936, 262, 583, 12267, 199, 32, 7307, 26, 334, 35, 9, 6171, 13, 7806, 481, 82, 5741, 68, 5741, 1567, 4688, 266, 5294, 4348, 65, 199, 32, 7307, 26, 334, 35, 9, 8315, 12, 7760, 699, 14, 29936, 262, 583, 12267, 199, 32, 1682, 26, 14629, 199, 624, 199, 199, 646, 2702, 199, 199, 504, 1134, 75, 9745, 88, 14, 5950, 14, 2921, 492, 2050, 27, 2512, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 504, 1134, 75, 9745, 88, 14, 1018, 14, 68, 541, 56, 13693, 14, 68, 541, 1304, 492, 577, 4189, 998, 199, 504, 1134, 75, 9745, 88, 14, 1018, 14, 68, 541, 56, 13693, 14, 68, 541, 492, 577, 4189, 199, 504, 1134, 75, 9745, 88, 14, 1018, 14, 68, 541, 56, 13693, 14, 68, 541, 56, 13693, 1563, 492, 577, 4189, 56, 13693, 1563, 12, 577, 4189, 56, 13693, 3393, 421, 199, 533, 577, 4189, 56, 13693, 20, 4861, 23013, 8, 36, 4189, 56, 13693, 1563, 304, 272, 408, 577, 4189, 56, 13693, 1021, 367, 841, 13, 4861, 13, 23013, 334, 54, 708, 9, 1804, 16764, 3918, 1403, 2434, 10813, 446, 841, 20301, 6632, 379, 26, 812, 17578, 17578, 17578, 54, 812, 17578, 17578, 17578, 54, 812, 17578, 17578, 17578, 54, 812, 17578, 17578, 17578, 54, 1362, 446, 812, 26, 9879, 5243, 22519, 10552, 26, 22519, 8557, 61, 339, 1275, 272, 408, 272, 577, 4189, 63, 9417, 275, 577, 4189, 480, 969, 14, 10013, 401, 298, 9417, 401, 5868, 22519, 10552, 12, 21237, 16809, 8557, 430, 339, 577, 4189, 63, 1110, 63, 20, 63, 2353, 275, 577, 4189, 480, 969, 14, 4587, 401, 298, 23013, 2338, 401, 5868, 22519, 10552, 12, 21237, 16809, 8557, 395, 298, 80, 348, 874, 531, 272, 577, 4189, 63, 1110, 63, 5060, 6621, 63, 77, 19, 72, 275, 577, 4189, 480, 969, 14, 4587, 401, 298, 5060, 6634, 401, 5868, 6886, 18770, 14, 19, 10552, 12, 21237, 18770, 14, 19, 8557, 395, 298, 77, 127, 112, 15, 72, 531, 272, 577, 4189, 63, 7472, 9900, 275, 577, 4189, 480, 969, 14, 9523, 401, 298, 7472, 12304, 401, 5868, 6886, 18770, 14, 19, 10552, 12, 21237, 18770, 14, 19, 8557, 395, 298, 55, 14, 72, 531, 272, 577, 4189, 63, 13117, 1708, 9900, 275, 577, 4189, 480, 969, 14, 13059, 401, 298, 13117, 1708, 12304, 401, 5868, 6886, 18770, 14, 19, 10552, 12, 21237, 18770, 14, 19, 8557, 395, 298, 15162, 14, 72, 531, 272, 577, 4189, 63, 497, 2682, 9900, 275, 577, 4189, 480, 969, 14, 11533, 401, 298, 497, 2682, 12304, 401, 5868, 6886, 18770, 14, 19, 10552, 12, 21237, 18770, 14, 19, 8557, 395, 298, 5568, 14, 72, 531, 272, 577, 4189, 63, 7472, 9900, 63, 75, 5879, 275, 577, 4189, 480, 969, 14, 13264, 401, 298, 7472, 12304, 334, 75, 5879, 4186, 5868, 6886, 18770, 14, 19, 10552, 12, 21237, 18770, 14, 19, 8557, 395, 298, 75, 55, 14, 72, 531, 272, 577, 4189, 63, 13117, 1708, 9900, 63, 75, 15162, 72, 275, 577, 4189, 480, 969, 14, 10752, 401, 298, 13117, 1708, 12304, 334, 75, 15162, 72, 4186, 5868, 6886, 18770, 14, 19, 10552, 12, 21237, 18770, 14, 19, 8557, 395, 298, 75, 15162, 14, 72, 531, 272, 577, 4189, 63, 497, 2682, 9900, 63, 43, 5568, 72, 275, 577, 4189, 480, 969, 14, 11164, 401, 298, 497, 2682, 12304, 334, 75, 5568, 72, 4186, 5868, 6886, 18770, 14, 19, 10552, 12, 21237, 18770, 14, 19, 8557, 395, 298, 75, 5568, 14, 72, 531, 272, 577, 4189, 63, 9551, 13411, 1366, 4933, 275, 577, 4189, 480, 969, 14, 1960, 401, 298, 9551, 5762, 900, 401, 5868, 6886, 18770, 14, 19, 10552, 12, 21237, 18770, 14, 19, 8557, 395, 298, 83, 531, 339, 347, 636, 826, 721, 277, 12, 366, 541, 1304, 304, 267, 1613, 8, 36, 4189, 56, 13693, 20, 4861, 23013, 12, 291, 2843, 826, 721, 68, 541, 1304, 12, 841, 9, 339, 347, 1104, 1451, 8, 277, 12, 666, 304, 267, 340, 440, 378, 88, 3607, 2695, 666, 2695, 378, 21870, 26, 288, 746, 577, 4189, 56, 13693, 3393, 480, 576, 450, 83, 440, 315, 334, 16, 88, 3607, 12, 378, 21870, 2924, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
pacifica/pacifica-archiveinterface
tests/cherrypy_test.py
2
3915
#!/usr/bin/python # -*- coding: utf-8 -*- """Test the example module.""" import requests import cherrypy from cherrypy.test import helper from pacifica.archiveinterface.globals import CHERRYPY_CONFIG from pacifica.archiveinterface.archive_utils import bytes_type from pacifica.archiveinterface.rest_generator import ArchiveInterfaceGenerator, error_page_default, BLOCK_SIZE from pacifica.archiveinterface.backends.factory import ArchiveBackendFactory from .common_setup_test import SetupTearDown class ArchiveInterfaceCPTest(helper.CPWebCase, SetupTearDown): """Base class for all testing classes.""" HOST = '127.0.0.1' PORT = 8080 url = 'http://{0}:{1}'.format(HOST, PORT) headers = {'content-type': 'application/json'} @staticmethod def setup_server(): """Bind tables to in memory db and start service.""" cherrypy.config.update({'error_page.default': error_page_default}) cherrypy.config.update(CHERRYPY_CONFIG) cherrypy.tree.mount( ArchiveInterfaceGenerator( ArchiveBackendFactory().get_backend_archive('posix', '/tmp/cptests') ), '/', CHERRYPY_CONFIG ) def test_interface(self): """Try a simple put and get.""" resp = requests.put('{}/1234'.format(self.url), data='The data in 1234') self.assertEqual(resp.status_code, 201) resp = requests.get('{}/1234'.format(self.url), stream=True) self.assertEqual(resp.status_code, 200) self.assertEqual(resp.raw.read(), bytes_type('The data in 1234')) resp = requests.head('{}/1234'.format(self.url)) self.assertEqual(resp.status_code, 204) resp = requests.post('{}/1234'.format(self.url)) self.assertEqual(resp.status_code, 200) resp = requests.delete('{}/1234'.format(self.url)) self.assertEqual(resp.status_code, 200) with open('/tmp/cptests/222', 'w') as test_fd: test_fd.write('this is file 222') resp = requests.patch( '{}/1235'.format(self.url), headers={'Content-Type': 'application/json'}, data='{ "path": "/tmp/cptests/222" }' ) self.assertEqual(resp.status_code, 200) def test_large_file(self): """Test a large file.""" resp = requests.put( '{}/5432'.format(self.url), data='0'*(BLOCK_SIZE+BLOCK_SIZE+17) ) self.assertEqual(resp.status_code, 201) resp = requests.get( '{}/5432'.format(self.url), params={'byte_range': '{}-{}'.format(BLOCK_SIZE, BLOCK_SIZE+BLOCK_SIZE+1)}, stream=True ) self.assertEqual(resp.status_code, 200) data = resp.raw.read() self.assertEqual(len(data), BLOCK_SIZE+1, '{} does not equal {}'.format(len(data), BLOCK_SIZE+1)) def test_byte_range_error(self): """Test the byte range error code.""" resp = requests.put( '{}/5432'.format(self.url), data='0'*20 ) self.assertEqual(resp.status_code, 201) resp = requests.get( '{}/5432'.format(self.url), params={'byte_range': 'blah-blah'}, stream=True ) self.assertEqual(resp.status_code, 500) self.assertTrue( 'Invalid byte range format' in resp.json()['traceback']) def test_error_interface(self): """Test some error states.""" resp = requests.get('{}/12345'.format(self.url), stream=True) self.assertEqual(resp.status_code, 500) self.assertTrue( 'No such file or directory' in resp.json()['traceback']) resp = requests.delete('{}/12345'.format(self.url), stream=True) self.assertEqual(resp.status_code, 500) self.assertTrue( 'No such file or directory' in resp.json()['traceback'])
lgpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 774, 314, 2893, 859, 1041, 199, 646, 4145, 199, 646, 13397, 199, 504, 13397, 14, 396, 492, 5922, 199, 504, 691, 559, 329, 696, 14, 6404, 3266, 14, 8473, 492, 6624, 2666, 57, 4521, 63, 5569, 199, 504, 691, 559, 329, 696, 14, 6404, 3266, 14, 6404, 63, 1208, 492, 2783, 63, 466, 199, 504, 691, 559, 329, 696, 14, 6404, 3266, 14, 3911, 63, 4679, 492, 19521, 1912, 4267, 7599, 12, 1125, 63, 1606, 63, 885, 12, 8068, 63, 4305, 199, 504, 691, 559, 329, 696, 14, 6404, 3266, 14, 7765, 14, 3702, 492, 19521, 1912, 8447, 2927, 199, 504, 1275, 2330, 63, 2758, 63, 396, 492, 12439, 30711, 421, 199, 533, 19521, 1912, 4267, 2890, 774, 8, 3676, 14, 2890, 5926, 1538, 12, 12439, 30711, 304, 272, 408, 1563, 1021, 367, 1006, 5343, 3992, 1041, 339, 25741, 275, 283, 4195, 14, 16, 14, 16, 14, 17, 7, 272, 25562, 275, 30220, 272, 1166, 275, 283, 1014, 20193, 16, 16495, 17, 5285, 908, 8, 5449, 12, 25562, 9, 272, 2323, 275, 791, 1317, 13, 466, 356, 283, 3578, 15, 1001, 936, 339, 768, 4639, 272, 347, 3272, 63, 1000, 837, 267, 408, 8198, 6716, 370, 315, 4402, 1592, 436, 1343, 2435, 1041, 267, 13397, 14, 888, 14, 873, 3252, 705, 63, 1606, 14, 885, 356, 1125, 63, 1606, 63, 885, 1552, 267, 13397, 14, 888, 14, 873, 8, 1244, 2666, 57, 4521, 63, 5569, 9, 267, 13397, 14, 2350, 14, 3956, 8, 288, 19521, 1912, 4267, 7599, 8, 355, 19521, 1912, 8447, 2927, 1252, 362, 63, 4620, 63, 6404, 360, 9228, 297, 1994, 2791, 15, 1850, 2219, 358, 288, 2318, 288, 17220, 288, 6624, 2666, 57, 4521, 63, 5569, 267, 776, 339, 347, 511, 63, 3266, 8, 277, 304, 267, 408, 12357, 282, 3486, 5324, 436, 664, 1041, 267, 3085, 275, 4145, 14, 524, 17519, 15, 4321, 1370, 908, 8, 277, 14, 633, 395, 1169, 666, 534, 1918, 666, 315, 14763, 358, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1784, 9, 267, 3085, 275, 4145, 14, 362, 17519, 15, 4321, 1370, 908, 8, 277, 14, 633, 395, 2547, 29, 549, 9, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 629, 8, 4518, 14, 1773, 14, 739, 1062, 2783, 63, 466, 360, 1918, 666, 315, 14763, 1333, 267, 3085, 275, 4145, 14, 2993, 17519, 15, 4321, 1370, 908, 8, 277, 14, 633, 430, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 14785, 9, 267, 3085, 275, 4145, 14, 1932, 17519, 15, 4321, 1370, 908, 8, 277, 14, 633, 430, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 267, 3085, 275, 4145, 14, 1807, 17519, 15, 4321, 1370, 908, 8, 277, 14, 633, 430, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 398, 543, 1551, 2336, 2791, 15, 1850, 2219, 15, 9485, 297, 283, 87, 358, 465, 511, 63, 2592, 26, 288, 511, 63, 2592, 14, 952, 360, 3749, 365, 570, 26485, 358, 267, 3085, 275, 4145, 14, 2068, 8, 288, 9005, 15, 713, 1276, 1370, 908, 8, 277, 14, 633, 395, 288, 2323, 3713, 2714, 13, 804, 356, 283, 3578, 15, 1001, 2267, 288, 666, 32134, 298, 515, 582, 3286, 2791, 15, 1850, 2219, 15, 9485, 2, 789, 7, 267, 776, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 339, 347, 511, 63, 9629, 63, 493, 8, 277, 304, 267, 408, 774, 282, 7031, 570, 1041, 267, 3085, 275, 4145, 14, 524, 8, 288, 9005, 15, 1477, 708, 1370, 908, 8, 277, 14, 633, 395, 288, 666, 534, 16, 7, 5830, 8475, 63, 4305, 11, 8475, 63, 4305, 11, 1196, 9, 267, 776, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1784, 9, 267, 3085, 275, 4145, 14, 362, 8, 288, 9005, 15, 1477, 708, 1370, 908, 8, 277, 14, 633, 395, 288, 1862, 3713, 4414, 63, 1842, 356, 9005, 13, 11123, 908, 8, 8475, 63, 4305, 12, 8068, 63, 4305, 11, 8475, 63, 4305, 11, 17, 16658, 288, 2547, 29, 549, 267, 776, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 267, 666, 275, 3085, 14, 1773, 14, 739, 342, 267, 291, 14, 629, 8, 552, 8, 576, 395, 8068, 63, 4305, 11, 17, 12, 9005, 1630, 440, 4472, 9499, 908, 8, 552, 8, 576, 395, 8068, 63, 4305, 11, 17, 430, 339, 347, 511, 63, 4414, 63, 1842, 63, 705, 8, 277, 304, 267, 408, 774, 314, 3696, 1425, 1125, 1233, 1041, 267, 3085, 275, 4145, 14, 524, 8, 288, 9005, 15, 1477, 708, 1370, 908, 8, 277, 14, 633, 395, 288, 666, 534, 16, 16804, 1165, 267, 776, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1784, 9, 267, 3085, 275, 4145, 14, 362, 8, 288, 9005, 15, 1477, 708, 1370, 908, 8, 277, 14, 633, 395, 288, 1862, 3713, 4414, 63, 1842, 356, 283, 12702, 13, 12702, 2267, 288, 2547, 29, 549, 267, 776, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 6891, 9, 267, 291, 14, 1815, 8, 288, 283, 3364, 3696, 1425, 1475, 7, 315, 3085, 14, 1001, 12047, 6894, 1105, 339, 347, 511, 63, 705, 63, 3266, 8, 277, 304, 267, 408, 774, 2005, 1125, 6363, 1041, 267, 3085, 275, 4145, 14, 362, 17519, 15, 13261, 1370, 908, 8, 277, 14, 633, 395, 2547, 29, 549, 9, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 6891, 9, 267, 291, 14, 1815, 8, 288, 283, 1944, 4066, 570, 503, 2082, 7, 315, 3085, 14, 1001, 12047, 6894, 1105, 267, 3085, 275, 4145, 14, 1807, 17519, 15, 13261, 1370, 908, 8, 277, 14, 633, 395, 2547, 29, 549, 9, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 6891, 9, 267, 291, 14, 1815, 8, 288, 283, 1944, 4066, 570, 503, 2082, 7, 315, 3085, 14, 1001, 12047, 6894, 1105, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 774, 314, 2893, 859, 1041, 199, 646, 4145, 199, 646, 13397, 199, 504, 13397, 14, 396, 492, 5922, 199, 504, 691, 559, 329, 696, 14, 6404, 3266, 14, 8473, 492, 6624, 2666, 57, 4521, 63, 5569, 199, 504, 691, 559, 329, 696, 14, 6404, 3266, 14, 6404, 63, 1208, 492, 2783, 63, 466, 199, 504, 691, 559, 329, 696, 14, 6404, 3266, 14, 3911, 63, 4679, 492, 19521, 1912, 4267, 7599, 12, 1125, 63, 1606, 63, 885, 12, 8068, 63, 4305, 199, 504, 691, 559, 329, 696, 14, 6404, 3266, 14, 7765, 14, 3702, 492, 19521, 1912, 8447, 2927, 199, 504, 1275, 2330, 63, 2758, 63, 396, 492, 12439, 30711, 421, 199, 533, 19521, 1912, 4267, 2890, 774, 8, 3676, 14, 2890, 5926, 1538, 12, 12439, 30711, 304, 272, 408, 1563, 1021, 367, 1006, 5343, 3992, 1041, 339, 25741, 275, 283, 4195, 14, 16, 14, 16, 14, 17, 7, 272, 25562, 275, 30220, 272, 1166, 275, 283, 1014, 20193, 16, 16495, 17, 5285, 908, 8, 5449, 12, 25562, 9, 272, 2323, 275, 791, 1317, 13, 466, 356, 283, 3578, 15, 1001, 936, 339, 768, 4639, 272, 347, 3272, 63, 1000, 837, 267, 408, 8198, 6716, 370, 315, 4402, 1592, 436, 1343, 2435, 1041, 267, 13397, 14, 888, 14, 873, 3252, 705, 63, 1606, 14, 885, 356, 1125, 63, 1606, 63, 885, 1552, 267, 13397, 14, 888, 14, 873, 8, 1244, 2666, 57, 4521, 63, 5569, 9, 267, 13397, 14, 2350, 14, 3956, 8, 288, 19521, 1912, 4267, 7599, 8, 355, 19521, 1912, 8447, 2927, 1252, 362, 63, 4620, 63, 6404, 360, 9228, 297, 1994, 2791, 15, 1850, 2219, 358, 288, 2318, 288, 17220, 288, 6624, 2666, 57, 4521, 63, 5569, 267, 776, 339, 347, 511, 63, 3266, 8, 277, 304, 267, 408, 12357, 282, 3486, 5324, 436, 664, 1041, 267, 3085, 275, 4145, 14, 524, 17519, 15, 4321, 1370, 908, 8, 277, 14, 633, 395, 1169, 666, 534, 1918, 666, 315, 14763, 358, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1784, 9, 267, 3085, 275, 4145, 14, 362, 17519, 15, 4321, 1370, 908, 8, 277, 14, 633, 395, 2547, 29, 549, 9, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 629, 8, 4518, 14, 1773, 14, 739, 1062, 2783, 63, 466, 360, 1918, 666, 315, 14763, 1333, 267, 3085, 275, 4145, 14, 2993, 17519, 15, 4321, 1370, 908, 8, 277, 14, 633, 430, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 14785, 9, 267, 3085, 275, 4145, 14, 1932, 17519, 15, 4321, 1370, 908, 8, 277, 14, 633, 430, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 267, 3085, 275, 4145, 14, 1807, 17519, 15, 4321, 1370, 908, 8, 277, 14, 633, 430, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 398, 543, 1551, 2336, 2791, 15, 1850, 2219, 15, 9485, 297, 283, 87, 358, 465, 511, 63, 2592, 26, 288, 511, 63, 2592, 14, 952, 360, 3749, 365, 570, 26485, 358, 267, 3085, 275, 4145, 14, 2068, 8, 288, 9005, 15, 713, 1276, 1370, 908, 8, 277, 14, 633, 395, 288, 2323, 3713, 2714, 13, 804, 356, 283, 3578, 15, 1001, 2267, 288, 666, 32134, 298, 515, 582, 3286, 2791, 15, 1850, 2219, 15, 9485, 2, 789, 7, 267, 776, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 339, 347, 511, 63, 9629, 63, 493, 8, 277, 304, 267, 408, 774, 282, 7031, 570, 1041, 267, 3085, 275, 4145, 14, 524, 8, 288, 9005, 15, 1477, 708, 1370, 908, 8, 277, 14, 633, 395, 288, 666, 534, 16, 7, 5830, 8475, 63, 4305, 11, 8475, 63, 4305, 11, 1196, 9, 267, 776, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1784, 9, 267, 3085, 275, 4145, 14, 362, 8, 288, 9005, 15, 1477, 708, 1370, 908, 8, 277, 14, 633, 395, 288, 1862, 3713, 4414, 63, 1842, 356, 9005, 13, 11123, 908, 8, 8475, 63, 4305, 12, 8068, 63, 4305, 11, 8475, 63, 4305, 11, 17, 16658, 288, 2547, 29, 549, 267, 776, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 267, 666, 275, 3085, 14, 1773, 14, 739, 342, 267, 291, 14, 629, 8, 552, 8, 576, 395, 8068, 63, 4305, 11, 17, 12, 9005, 1630, 440, 4472, 9499, 908, 8, 552, 8, 576, 395, 8068, 63, 4305, 11, 17, 430, 339, 347, 511, 63, 4414, 63, 1842, 63, 705, 8, 277, 304, 267, 408, 774, 314, 3696, 1425, 1125, 1233, 1041, 267, 3085, 275, 4145, 14, 524, 8, 288, 9005, 15, 1477, 708, 1370, 908, 8, 277, 14, 633, 395, 288, 666, 534, 16, 16804, 1165, 267, 776, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1784, 9, 267, 3085, 275, 4145, 14, 362, 8, 288, 9005, 15, 1477, 708, 1370, 908, 8, 277, 14, 633, 395, 288, 1862, 3713, 4414, 63, 1842, 356, 283, 12702, 13, 12702, 2267, 288, 2547, 29, 549, 267, 776, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 6891, 9, 267, 291, 14, 1815, 8, 288, 283, 3364, 3696, 1425, 1475, 7, 315, 3085, 14, 1001, 12047, 6894, 1105, 339, 347, 511, 63, 705, 63, 3266, 8, 277, 304, 267, 408, 774, 2005, 1125, 6363, 1041, 267, 3085, 275, 4145, 14, 362, 17519, 15, 13261, 1370, 908, 8, 277, 14, 633, 395, 2547, 29, 549, 9, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 6891, 9, 267, 291, 14, 1815, 8, 288, 283, 1944, 4066, 570, 503, 2082, 7, 315, 3085, 14, 1001, 12047, 6894, 1105, 267, 3085, 275, 4145, 14, 1807, 17519, 15, 13261, 1370, 908, 8, 277, 14, 633, 395, 2547, 29, 549, 9, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 6891, 9, 267, 291, 14, 1815, 8, 288, 283, 1944, 4066, 570, 503, 2082, 7, 315, 3085, 14, 1001, 12047, 6894, 1105, 199, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
CCharlieLi/StaffManagmentSystem
rest_framework/tests/test_routers.py
21
7115
from __future__ import unicode_literals from django.db import models from django.test import TestCase from django.core.exceptions import ImproperlyConfigured from rest_framework import serializers, viewsets, permissions from rest_framework.compat import include, patterns, url from rest_framework.decorators import link, action from rest_framework.response import Response from rest_framework.routers import SimpleRouter, DefaultRouter from rest_framework.test import APIRequestFactory factory = APIRequestFactory() urlpatterns = patterns('',) class BasicViewSet(viewsets.ViewSet): def list(self, request, *args, **kwargs): return Response({'method': 'list'}) @action() def action1(self, request, *args, **kwargs): return Response({'method': 'action1'}) @action() def action2(self, request, *args, **kwargs): return Response({'method': 'action2'}) @action(methods=['post', 'delete']) def action3(self, request, *args, **kwargs): return Response({'method': 'action2'}) @link() def link1(self, request, *args, **kwargs): return Response({'method': 'link1'}) @link() def link2(self, request, *args, **kwargs): return Response({'method': 'link2'}) class TestSimpleRouter(TestCase): def setUp(self): self.router = SimpleRouter() def test_link_and_action_decorator(self): routes = self.router.get_routes(BasicViewSet) decorator_routes = routes[2:] # Make sure all these endpoints exist and none have been clobbered for i, endpoint in enumerate(['action1', 'action2', 'action3', 'link1', 'link2']): route = decorator_routes[i] # check url listing self.assertEqual(route.url, '^{{prefix}}/{{lookup}}/{0}{{trailing_slash}}$'.format(endpoint)) # check method to function mapping if endpoint == 'action3': methods_map = ['post', 'delete'] elif endpoint.startswith('action'): methods_map = ['post'] else: methods_map = ['get'] for method in methods_map: self.assertEqual(route.mapping[method], endpoint) class RouterTestModel(models.Model): uuid = models.CharField(max_length=20) text = models.CharField(max_length=200) class TestCustomLookupFields(TestCase): """ Ensure that custom lookup fields are correctly routed. """ urls = 'rest_framework.tests.test_routers' def setUp(self): class NoteSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = RouterTestModel lookup_field = 'uuid' fields = ('url', 'uuid', 'text') class NoteViewSet(viewsets.ModelViewSet): queryset = RouterTestModel.objects.all() serializer_class = NoteSerializer lookup_field = 'uuid' RouterTestModel.objects.create(uuid='123', text='foo bar') self.router = SimpleRouter() self.router.register(r'notes', NoteViewSet) from rest_framework.tests import test_routers urls = getattr(test_routers, 'urlpatterns') urls += patterns('', url(r'^', include(self.router.urls)), ) def test_custom_lookup_field_route(self): detail_route = self.router.urls[-1] detail_url_pattern = detail_route.regex.pattern self.assertIn('<uuid>', detail_url_pattern) def test_retrieve_lookup_field_list_view(self): response = self.client.get('/notes/') self.assertEqual(response.data, [{ "url": "http://testserver/notes/123/", "uuid": "123", "text": "foo bar" }] ) def test_retrieve_lookup_field_detail_view(self): response = self.client.get('/notes/123/') self.assertEqual(response.data, { "url": "http://testserver/notes/123/", "uuid": "123", "text": "foo bar" } ) class TestTrailingSlashIncluded(TestCase): def setUp(self): class NoteViewSet(viewsets.ModelViewSet): model = RouterTestModel self.router = SimpleRouter() self.router.register(r'notes', NoteViewSet) self.urls = self.router.urls def test_urls_have_trailing_slash_by_default(self): expected = ['^notes/$', '^notes/(?P<pk>[^/]+)/$'] for idx in range(len(expected)): self.assertEqual(expected[idx], self.urls[idx].regex.pattern) class TestTrailingSlashRemoved(TestCase): def setUp(self): class NoteViewSet(viewsets.ModelViewSet): model = RouterTestModel self.router = SimpleRouter(trailing_slash=False) self.router.register(r'notes', NoteViewSet) self.urls = self.router.urls def test_urls_can_have_trailing_slash_removed(self): expected = ['^notes$', '^notes/(?P<pk>[^/.]+)$'] for idx in range(len(expected)): self.assertEqual(expected[idx], self.urls[idx].regex.pattern) class TestNameableRoot(TestCase): def setUp(self): class NoteViewSet(viewsets.ModelViewSet): model = RouterTestModel self.router = DefaultRouter() self.router.root_view_name = 'nameable-root' self.router.register(r'notes', NoteViewSet) self.urls = self.router.urls def test_router_has_custom_name(self): expected = 'nameable-root' self.assertEqual(expected, self.urls[0].name) class TestActionKeywordArgs(TestCase): """ Ensure keyword arguments passed in the `@action` decorator are properly handled. Refs #940. """ def setUp(self): class TestViewSet(viewsets.ModelViewSet): permission_classes = [] @action(permission_classes=[permissions.AllowAny]) def custom(self, request, *args, **kwargs): return Response({ 'permission_classes': self.permission_classes }) self.router = SimpleRouter() self.router.register(r'test', TestViewSet, base_name='test') self.view = self.router.urls[-1].callback def test_action_kwargs(self): request = factory.post('/test/0/custom/') response = self.view(request) self.assertEqual( response.data, {'permission_classes': [permissions.AllowAny]} ) class TestActionAppliedToExistingRoute(TestCase): """ Ensure `@action` decorator raises an except when applied to an existing route """ def test_exception_raised_when_action_applied_to_existing_route(self): class TestViewSet(viewsets.ModelViewSet): @action() def retrieve(self, request, *args, **kwargs): return Response({ 'hello': 'world' }) self.router = SimpleRouter() self.router.register(r'test', TestViewSet, base_name='test') with self.assertRaises(ImproperlyConfigured): self.router.urls
gpl-2.0
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 4618, 63, 4857, 492, 12506, 12, 2455, 2193, 12, 3443, 199, 504, 4618, 63, 4857, 14, 5819, 492, 2387, 12, 7970, 12, 1166, 199, 504, 4618, 63, 4857, 14, 11582, 492, 2142, 12, 1595, 199, 504, 4618, 63, 4857, 14, 1310, 492, 7232, 199, 504, 4618, 63, 4857, 14, 17292, 492, 5870, 11691, 12, 3758, 11691, 199, 504, 4618, 63, 4857, 14, 396, 492, 3261, 2017, 2927, 199, 199, 3702, 275, 3261, 2017, 2927, 342, 199, 199, 20050, 275, 7970, 8594, 9, 421, 199, 533, 10082, 21902, 8, 1345, 2193, 14, 21902, 304, 272, 347, 769, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 7232, 3252, 765, 356, 283, 513, 3071, 339, 768, 1287, 342, 272, 347, 1595, 17, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 7232, 3252, 765, 356, 283, 1287, 17, 3071, 339, 768, 1287, 342, 272, 347, 1595, 18, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 7232, 3252, 765, 356, 283, 1287, 18, 3071, 339, 768, 1287, 8, 2474, 2968, 1932, 297, 283, 1807, 1105, 272, 347, 1595, 19, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 7232, 3252, 765, 356, 283, 1287, 18, 3071, 339, 768, 1073, 342, 272, 347, 2142, 17, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 7232, 3252, 765, 356, 283, 1073, 17, 3071, 339, 768, 1073, 342, 272, 347, 2142, 18, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 7232, 3252, 765, 356, 283, 1073, 18, 3071, 421, 199, 533, 1379, 3184, 11691, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 4995, 275, 5870, 11691, 342, 339, 347, 511, 63, 1073, 63, 460, 63, 1287, 63, 11547, 8, 277, 304, 267, 15777, 275, 291, 14, 4995, 14, 362, 63, 13243, 8, 6845, 21902, 9, 267, 7531, 63, 13243, 275, 15777, 59, 18, 2938, 267, 327, 4155, 3238, 1006, 3520, 16173, 2187, 436, 7179, 1172, 2757, 286, 1191, 18897, 267, 367, 284, 12, 6037, 315, 3874, 2941, 1287, 17, 297, 283, 1287, 18, 297, 283, 1287, 19, 297, 283, 1073, 17, 297, 283, 1073, 18, 9090, 288, 7475, 275, 7531, 63, 13243, 59, 73, 61, 288, 327, 1104, 1166, 13778, 288, 291, 14, 629, 8, 4449, 14, 633, 12, 2490, 14452, 3638, 1861, 4863, 15, 3638, 3892, 4863, 5321, 16, 93, 3638, 15910, 63, 7001, 4863, 4, 1370, 908, 8, 6520, 430, 288, 327, 1104, 1083, 370, 805, 4412, 288, 340, 6037, 508, 283, 1287, 19, 356, 355, 3102, 63, 1130, 275, 788, 1932, 297, 283, 1807, 418, 288, 916, 6037, 14, 2460, 360, 1287, 735, 355, 3102, 63, 1130, 275, 788, 1932, 418, 288, 587, 26, 355, 3102, 63, 1130, 275, 788, 362, 418, 288, 367, 1083, 315, 3102, 63, 1130, 26, 355, 291, 14, 629, 8, 4449, 14, 4745, 59, 765, 467, 6037, 9, 421, 199, 533, 22708, 18282, 8, 992, 14, 1685, 304, 272, 5377, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1165, 9, 272, 1318, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 9, 421, 199, 533, 1379, 7223, 7521, 7304, 8, 1746, 304, 272, 408, 272, 7523, 626, 3537, 4237, 1504, 787, 6657, 882, 4241, 14, 272, 408, 272, 8187, 275, 283, 3911, 63, 4857, 14, 2219, 14, 396, 63, 17292, 7, 339, 347, 3613, 8, 277, 304, 267, 1021, 3390, 7299, 8, 12844, 14, 18727, 12751, 1685, 7299, 304, 288, 1021, 6288, 26, 355, 1402, 275, 22708, 18282, 355, 4237, 63, 698, 275, 283, 2580, 7, 355, 1504, 275, 661, 633, 297, 283, 2580, 297, 283, 505, 358, 398, 1021, 3390, 21902, 8, 1345, 2193, 14, 1685, 21902, 304, 288, 7594, 275, 22708, 18282, 14, 1462, 14, 452, 342, 288, 9146, 63, 533, 275, 3390, 7299, 288, 4237, 63, 698, 275, 283, 2580, 7, 398, 22708, 18282, 14, 1462, 14, 981, 8, 2580, 534, 4288, 297, 1318, 534, 1421, 4681, 358, 398, 291, 14, 4995, 275, 5870, 11691, 342, 267, 291, 14, 4995, 14, 2683, 8, 82, 7, 5983, 297, 3390, 21902, 9, 398, 687, 4618, 63, 4857, 14, 2219, 492, 511, 63, 17292, 267, 8187, 275, 2519, 8, 396, 63, 17292, 12, 283, 20050, 358, 267, 8187, 847, 7970, 8594, 288, 1166, 8, 82, 4289, 297, 2387, 8, 277, 14, 4995, 14, 3603, 1826, 267, 776, 339, 347, 511, 63, 4229, 63, 3892, 63, 698, 63, 4449, 8, 277, 304, 267, 10093, 63, 4449, 275, 291, 14, 4995, 14, 3603, 1988, 17, 61, 267, 10093, 63, 633, 63, 3401, 275, 10093, 63, 4449, 14, 3821, 14, 3401, 267, 291, 14, 4080, 4827, 2580, 4206, 10093, 63, 633, 63, 3401, 9, 339, 347, 511, 63, 14270, 63, 3892, 63, 698, 63, 513, 63, 1345, 8, 277, 304, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5983, 6217, 267, 291, 14, 629, 8, 1310, 14, 576, 12, 288, 8910, 355, 298, 633, 582, 298, 1014, 921, 22471, 15, 5983, 15, 4288, 10665, 355, 298, 2580, 582, 298, 4288, 401, 298, 505, 582, 298, 1421, 4681, 2, 288, 14877, 267, 776, 339, 347, 511, 63, 14270, 63, 3892, 63, 698, 63, 5506, 63, 1345, 8, 277, 304, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5983, 15, 4288, 6217, 267, 291, 14, 629, 8, 1310, 14, 576, 12, 288, 469, 355, 298, 633, 582, 298, 1014, 921, 22471, 15, 5983, 15, 4288, 10665, 355, 298, 2580, 582, 298, 4288, 401, 298, 505, 582, 298, 1421, 4681, 2, 288, 789, 267, 776, 421, 199, 533, 1379, 2437, 5662, 11592, 1119, 607, 3331, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1021, 3390, 21902, 8, 1345, 2193, 14, 1685, 21902, 304, 288, 1402, 275, 22708, 18282, 398, 291, 14, 4995, 275, 5870, 11691, 342, 267, 291, 14, 4995, 14, 2683, 8, 82, 7, 5983, 297, 3390, 21902, 9, 267, 291, 14, 3603, 275, 291, 14, 4995, 14 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 4618, 63, 4857, 492, 12506, 12, 2455, 2193, 12, 3443, 199, 504, 4618, 63, 4857, 14, 5819, 492, 2387, 12, 7970, 12, 1166, 199, 504, 4618, 63, 4857, 14, 11582, 492, 2142, 12, 1595, 199, 504, 4618, 63, 4857, 14, 1310, 492, 7232, 199, 504, 4618, 63, 4857, 14, 17292, 492, 5870, 11691, 12, 3758, 11691, 199, 504, 4618, 63, 4857, 14, 396, 492, 3261, 2017, 2927, 199, 199, 3702, 275, 3261, 2017, 2927, 342, 199, 199, 20050, 275, 7970, 8594, 9, 421, 199, 533, 10082, 21902, 8, 1345, 2193, 14, 21902, 304, 272, 347, 769, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 7232, 3252, 765, 356, 283, 513, 3071, 339, 768, 1287, 342, 272, 347, 1595, 17, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 7232, 3252, 765, 356, 283, 1287, 17, 3071, 339, 768, 1287, 342, 272, 347, 1595, 18, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 7232, 3252, 765, 356, 283, 1287, 18, 3071, 339, 768, 1287, 8, 2474, 2968, 1932, 297, 283, 1807, 1105, 272, 347, 1595, 19, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 7232, 3252, 765, 356, 283, 1287, 18, 3071, 339, 768, 1073, 342, 272, 347, 2142, 17, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 7232, 3252, 765, 356, 283, 1073, 17, 3071, 339, 768, 1073, 342, 272, 347, 2142, 18, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 7232, 3252, 765, 356, 283, 1073, 18, 3071, 421, 199, 533, 1379, 3184, 11691, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 4995, 275, 5870, 11691, 342, 339, 347, 511, 63, 1073, 63, 460, 63, 1287, 63, 11547, 8, 277, 304, 267, 15777, 275, 291, 14, 4995, 14, 362, 63, 13243, 8, 6845, 21902, 9, 267, 7531, 63, 13243, 275, 15777, 59, 18, 2938, 267, 327, 4155, 3238, 1006, 3520, 16173, 2187, 436, 7179, 1172, 2757, 286, 1191, 18897, 267, 367, 284, 12, 6037, 315, 3874, 2941, 1287, 17, 297, 283, 1287, 18, 297, 283, 1287, 19, 297, 283, 1073, 17, 297, 283, 1073, 18, 9090, 288, 7475, 275, 7531, 63, 13243, 59, 73, 61, 288, 327, 1104, 1166, 13778, 288, 291, 14, 629, 8, 4449, 14, 633, 12, 2490, 14452, 3638, 1861, 4863, 15, 3638, 3892, 4863, 5321, 16, 93, 3638, 15910, 63, 7001, 4863, 4, 1370, 908, 8, 6520, 430, 288, 327, 1104, 1083, 370, 805, 4412, 288, 340, 6037, 508, 283, 1287, 19, 356, 355, 3102, 63, 1130, 275, 788, 1932, 297, 283, 1807, 418, 288, 916, 6037, 14, 2460, 360, 1287, 735, 355, 3102, 63, 1130, 275, 788, 1932, 418, 288, 587, 26, 355, 3102, 63, 1130, 275, 788, 362, 418, 288, 367, 1083, 315, 3102, 63, 1130, 26, 355, 291, 14, 629, 8, 4449, 14, 4745, 59, 765, 467, 6037, 9, 421, 199, 533, 22708, 18282, 8, 992, 14, 1685, 304, 272, 5377, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1165, 9, 272, 1318, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 9, 421, 199, 533, 1379, 7223, 7521, 7304, 8, 1746, 304, 272, 408, 272, 7523, 626, 3537, 4237, 1504, 787, 6657, 882, 4241, 14, 272, 408, 272, 8187, 275, 283, 3911, 63, 4857, 14, 2219, 14, 396, 63, 17292, 7, 339, 347, 3613, 8, 277, 304, 267, 1021, 3390, 7299, 8, 12844, 14, 18727, 12751, 1685, 7299, 304, 288, 1021, 6288, 26, 355, 1402, 275, 22708, 18282, 355, 4237, 63, 698, 275, 283, 2580, 7, 355, 1504, 275, 661, 633, 297, 283, 2580, 297, 283, 505, 358, 398, 1021, 3390, 21902, 8, 1345, 2193, 14, 1685, 21902, 304, 288, 7594, 275, 22708, 18282, 14, 1462, 14, 452, 342, 288, 9146, 63, 533, 275, 3390, 7299, 288, 4237, 63, 698, 275, 283, 2580, 7, 398, 22708, 18282, 14, 1462, 14, 981, 8, 2580, 534, 4288, 297, 1318, 534, 1421, 4681, 358, 398, 291, 14, 4995, 275, 5870, 11691, 342, 267, 291, 14, 4995, 14, 2683, 8, 82, 7, 5983, 297, 3390, 21902, 9, 398, 687, 4618, 63, 4857, 14, 2219, 492, 511, 63, 17292, 267, 8187, 275, 2519, 8, 396, 63, 17292, 12, 283, 20050, 358, 267, 8187, 847, 7970, 8594, 288, 1166, 8, 82, 4289, 297, 2387, 8, 277, 14, 4995, 14, 3603, 1826, 267, 776, 339, 347, 511, 63, 4229, 63, 3892, 63, 698, 63, 4449, 8, 277, 304, 267, 10093, 63, 4449, 275, 291, 14, 4995, 14, 3603, 1988, 17, 61, 267, 10093, 63, 633, 63, 3401, 275, 10093, 63, 4449, 14, 3821, 14, 3401, 267, 291, 14, 4080, 4827, 2580, 4206, 10093, 63, 633, 63, 3401, 9, 339, 347, 511, 63, 14270, 63, 3892, 63, 698, 63, 513, 63, 1345, 8, 277, 304, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5983, 6217, 267, 291, 14, 629, 8, 1310, 14, 576, 12, 288, 8910, 355, 298, 633, 582, 298, 1014, 921, 22471, 15, 5983, 15, 4288, 10665, 355, 298, 2580, 582, 298, 4288, 401, 298, 505, 582, 298, 1421, 4681, 2, 288, 14877, 267, 776, 339, 347, 511, 63, 14270, 63, 3892, 63, 698, 63, 5506, 63, 1345, 8, 277, 304, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5983, 15, 4288, 6217, 267, 291, 14, 629, 8, 1310, 14, 576, 12, 288, 469, 355, 298, 633, 582, 298, 1014, 921, 22471, 15, 5983, 15, 4288, 10665, 355, 298, 2580, 582, 298, 4288, 401, 298, 505, 582, 298, 1421, 4681, 2, 288, 789, 267, 776, 421, 199, 533, 1379, 2437, 5662, 11592, 1119, 607, 3331, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1021, 3390, 21902, 8, 1345, 2193, 14, 1685, 21902, 304, 288, 1402, 275, 22708, 18282, 398, 291, 14, 4995, 275, 5870, 11691, 342, 267, 291, 14, 4995, 14, 2683, 8, 82, 7, 5983, 297, 3390, 21902, 9, 267, 291, 14, 3603, 275, 291, 14, 4995, 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,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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 ]
mosbasik/buzhug
javasrc/lib/Jython/Lib/distutils/tests/test_install.py
155
1861
"""Tests for distutils.command.install.""" import os import unittest from distutils.command.install import install from distutils.core import Distribution from distutils.tests import support class InstallTestCase(support.TempdirManager, unittest.TestCase): def test_home_installation_scheme(self): # This ensure two things: # - that --home generates the desired set of directory names # - test --home is supported on all platforms builddir = self.mkdtemp() destination = os.path.join(builddir, "installation") dist = Distribution({"name": "foopkg"}) # script_name need not exist, it just need to be initialized dist.script_name = os.path.join(builddir, "setup.py") dist.command_obj["build"] = support.DummyCommand( build_base=builddir, build_lib=os.path.join(builddir, "lib"), ) cmd = install(dist) cmd.home = destination cmd.ensure_finalized() self.assertEqual(cmd.install_base, destination) self.assertEqual(cmd.install_platbase, destination) def check_path(got, expected): got = os.path.normpath(got) expected = os.path.normpath(expected) self.assertEqual(got, expected) libdir = os.path.join(destination, "lib", "python") check_path(cmd.install_lib, libdir) check_path(cmd.install_platlib, libdir) check_path(cmd.install_purelib, libdir) check_path(cmd.install_headers, os.path.join(destination, "include", "python", "foopkg")) check_path(cmd.install_scripts, os.path.join(destination, "bin")) check_path(cmd.install_data, destination) def test_suite(): return unittest.makeSuite(InstallTestCase) if __name__ == "__main__": unittest.main(defaultTest="test_suite")
bsd-3-clause
[ 624, 2925, 367, 7065, 14, 1531, 14, 3174, 1041, 199, 199, 646, 747, 199, 646, 2882, 199, 199, 504, 7065, 14, 1531, 14, 3174, 492, 3907, 199, 504, 7065, 14, 1018, 492, 11839, 199, 199, 504, 7065, 14, 2219, 492, 2291, 421, 199, 533, 13276, 1746, 8, 4058, 14, 6530, 694, 2988, 12, 2882, 14, 1746, 304, 339, 347, 511, 63, 4219, 63, 23048, 63, 5512, 8, 277, 304, 267, 327, 961, 4868, 2877, 7645, 26, 267, 327, 446, 626, 1553, 4219, 12821, 314, 6387, 663, 402, 2082, 1561, 267, 327, 446, 511, 1553, 4219, 365, 3748, 641, 1006, 10677, 267, 1900, 694, 275, 291, 14, 11983, 342, 267, 5724, 275, 747, 14, 515, 14, 904, 8, 21728, 12, 298, 23048, 531, 398, 2917, 275, 11839, 6333, 354, 582, 298, 545, 411, 9761, 5984, 267, 327, 2884, 63, 354, 1929, 440, 2187, 12, 652, 2951, 1929, 370, 506, 10038, 267, 2917, 14, 1579, 63, 354, 275, 747, 14, 515, 14, 904, 8, 21728, 12, 298, 2758, 14, 647, 531, 267, 2917, 14, 1531, 63, 1113, 905, 1506, 937, 275, 2291, 14, 11324, 3110, 8, 288, 1900, 63, 1095, 29, 21728, 12, 288, 1900, 63, 773, 29, 736, 14, 515, 14, 904, 8, 21728, 12, 298, 773, 1288, 288, 776, 398, 2088, 275, 3907, 8, 2686, 9, 267, 2088, 14, 4219, 275, 5724, 267, 2088, 14, 7505, 63, 19231, 342, 398, 291, 14, 629, 8, 1760, 14, 3174, 63, 1095, 12, 5724, 9, 267, 291, 14, 629, 8, 1760, 14, 3174, 63, 14156, 1095, 12, 5724, 9, 398, 347, 1104, 63, 515, 8, 7808, 12, 1420, 304, 288, 4788, 275, 747, 14, 515, 14, 9267, 8, 7808, 9, 288, 1420, 275, 747, 14, 515, 14, 9267, 8, 2062, 9, 288, 291, 14, 629, 8, 7808, 12, 1420, 9, 398, 1973, 694, 275, 747, 14, 515, 14, 904, 8, 6881, 12, 298, 773, 401, 298, 1548, 531, 267, 1104, 63, 515, 8, 1760, 14, 3174, 63, 773, 12, 1973, 694, 9, 267, 1104, 63, 515, 8, 1760, 14, 3174, 63, 14156, 773, 12, 1973, 694, 9, 267, 1104, 63, 515, 8, 1760, 14, 3174, 63, 31882, 12, 1973, 694, 9, 267, 1104, 63, 515, 8, 1760, 14, 3174, 63, 2139, 12, 673, 747, 14, 515, 14, 904, 8, 6881, 12, 298, 2613, 401, 298, 1548, 401, 298, 545, 411, 9761, 2237, 267, 1104, 63, 515, 8, 1760, 14, 3174, 63, 6429, 12, 747, 14, 515, 14, 904, 8, 6881, 12, 298, 1393, 2237, 267, 1104, 63, 515, 8, 1760, 14, 3174, 63, 576, 12, 5724, 9, 421, 199, 318, 511, 63, 5768, 837, 272, 372, 2882, 14, 18275, 8, 8154, 1746, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2882, 14, 973, 8, 885, 774, 628, 396, 63, 5768, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2925, 367, 7065, 14, 1531, 14, 3174, 1041, 199, 199, 646, 747, 199, 646, 2882, 199, 199, 504, 7065, 14, 1531, 14, 3174, 492, 3907, 199, 504, 7065, 14, 1018, 492, 11839, 199, 199, 504, 7065, 14, 2219, 492, 2291, 421, 199, 533, 13276, 1746, 8, 4058, 14, 6530, 694, 2988, 12, 2882, 14, 1746, 304, 339, 347, 511, 63, 4219, 63, 23048, 63, 5512, 8, 277, 304, 267, 327, 961, 4868, 2877, 7645, 26, 267, 327, 446, 626, 1553, 4219, 12821, 314, 6387, 663, 402, 2082, 1561, 267, 327, 446, 511, 1553, 4219, 365, 3748, 641, 1006, 10677, 267, 1900, 694, 275, 291, 14, 11983, 342, 267, 5724, 275, 747, 14, 515, 14, 904, 8, 21728, 12, 298, 23048, 531, 398, 2917, 275, 11839, 6333, 354, 582, 298, 545, 411, 9761, 5984, 267, 327, 2884, 63, 354, 1929, 440, 2187, 12, 652, 2951, 1929, 370, 506, 10038, 267, 2917, 14, 1579, 63, 354, 275, 747, 14, 515, 14, 904, 8, 21728, 12, 298, 2758, 14, 647, 531, 267, 2917, 14, 1531, 63, 1113, 905, 1506, 937, 275, 2291, 14, 11324, 3110, 8, 288, 1900, 63, 1095, 29, 21728, 12, 288, 1900, 63, 773, 29, 736, 14, 515, 14, 904, 8, 21728, 12, 298, 773, 1288, 288, 776, 398, 2088, 275, 3907, 8, 2686, 9, 267, 2088, 14, 4219, 275, 5724, 267, 2088, 14, 7505, 63, 19231, 342, 398, 291, 14, 629, 8, 1760, 14, 3174, 63, 1095, 12, 5724, 9, 267, 291, 14, 629, 8, 1760, 14, 3174, 63, 14156, 1095, 12, 5724, 9, 398, 347, 1104, 63, 515, 8, 7808, 12, 1420, 304, 288, 4788, 275, 747, 14, 515, 14, 9267, 8, 7808, 9, 288, 1420, 275, 747, 14, 515, 14, 9267, 8, 2062, 9, 288, 291, 14, 629, 8, 7808, 12, 1420, 9, 398, 1973, 694, 275, 747, 14, 515, 14, 904, 8, 6881, 12, 298, 773, 401, 298, 1548, 531, 267, 1104, 63, 515, 8, 1760, 14, 3174, 63, 773, 12, 1973, 694, 9, 267, 1104, 63, 515, 8, 1760, 14, 3174, 63, 14156, 773, 12, 1973, 694, 9, 267, 1104, 63, 515, 8, 1760, 14, 3174, 63, 31882, 12, 1973, 694, 9, 267, 1104, 63, 515, 8, 1760, 14, 3174, 63, 2139, 12, 673, 747, 14, 515, 14, 904, 8, 6881, 12, 298, 2613, 401, 298, 1548, 401, 298, 545, 411, 9761, 2237, 267, 1104, 63, 515, 8, 1760, 14, 3174, 63, 6429, 12, 747, 14, 515, 14, 904, 8, 6881, 12, 298, 1393, 2237, 267, 1104, 63, 515, 8, 1760, 14, 3174, 63, 576, 12, 5724, 9, 421, 199, 318, 511, 63, 5768, 837, 272, 372, 2882, 14, 18275, 8, 8154, 1746, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2882, 14, 973, 8, 885, 774, 628, 396, 63, 5768, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
gauribhoite/personfinder
env/google_appengine/lib/django-1.5/django/contrib/gis/db/backends/oracle/introspection.py
119
1779
import cx_Oracle from django.db.backends.oracle.introspection import DatabaseIntrospection class OracleIntrospection(DatabaseIntrospection): # Associating any OBJECTVAR instances with GeometryField. Of course, # this won't work right on Oracle objects that aren't MDSYS.SDO_GEOMETRY, # but it is the only object type supported within Django anyways. data_types_reverse = DatabaseIntrospection.data_types_reverse.copy() data_types_reverse[cx_Oracle.OBJECT] = 'GeometryField' def get_geometry_type(self, table_name, geo_col): cursor = self.connection.cursor() try: # Querying USER_SDO_GEOM_METADATA to get the SRID and dimension information. try: cursor.execute('SELECT "DIMINFO", "SRID" FROM "USER_SDO_GEOM_METADATA" WHERE "TABLE_NAME"=%s AND "COLUMN_NAME"=%s', (table_name.upper(), geo_col.upper())) row = cursor.fetchone() except Exception as msg: raise Exception('Could not find entry in USER_SDO_GEOM_METADATA corresponding to "%s"."%s"\n' 'Error message: %s.' % (table_name, geo_col, msg)) # TODO: Research way to find a more specific geometry field type for # the column's contents. field_type = 'GeometryField' # Getting the field parameters. field_params = {} dim, srid = row if srid != 4326: field_params['srid'] = srid # Length of object array ( SDO_DIM_ARRAY ) is number of dimensions. dim = len(dim) if dim != 2: field_params['dim'] = dim finally: cursor.close() return field_type, field_params
apache-2.0
[ 646, 17280, 63, 21202, 199, 504, 1639, 14, 697, 14, 7765, 14, 16404, 14, 21627, 492, 8692, 30516, 199, 199, 533, 15309, 30516, 8, 7243, 30516, 304, 272, 327, 24207, 1958, 1263, 28652, 5550, 5568, 4454, 543, 30490, 14, 221, 24545, 2518, 12, 272, 327, 642, 7859, 1133, 1736, 2451, 641, 15309, 2251, 626, 10621, 1133, 603, 3177, 20238, 14, 24399, 63, 28472, 12, 272, 327, 1325, 652, 365, 314, 1454, 909, 730, 3748, 4453, 5634, 1263, 2885, 14, 272, 666, 63, 1313, 63, 4471, 275, 8692, 30516, 14, 576, 63, 1313, 63, 4471, 14, 1574, 342, 272, 666, 63, 1313, 63, 4471, 59, 11859, 63, 21202, 14, 9868, 61, 275, 283, 6831, 792, 7, 339, 347, 664, 63, 7660, 63, 466, 8, 277, 12, 1817, 63, 354, 12, 8509, 63, 761, 304, 267, 3920, 275, 291, 14, 2105, 14, 3937, 342, 267, 862, 26, 288, 327, 8133, 316, 13044, 63, 24399, 63, 31080, 63, 8314, 370, 664, 314, 22425, 436, 6240, 2556, 14, 288, 862, 26, 355, 3920, 14, 2526, 360, 4859, 298, 19080, 4531, 401, 298, 5943, 998, 2, 4442, 298, 3791, 63, 24399, 63, 31080, 63, 8314, 2, 6038, 298, 8723, 63, 2339, 2, 2458, 83, 2401, 298, 21436, 63, 2339, 2, 2458, 83, 297, 3044, 334, 1224, 63, 354, 14, 4142, 1062, 8509, 63, 761, 14, 4142, 4059, 355, 1962, 275, 3920, 14, 11591, 342, 288, 871, 2186, 465, 1499, 26, 355, 746, 2186, 360, 6531, 440, 2342, 2397, 315, 13044, 63, 24399, 63, 31080, 63, 8314, 5226, 370, 2071, 83, 1674, 6808, 83, 3212, 78, 7, 1816, 283, 547, 1245, 26, 450, 83, 3530, 450, 334, 1224, 63, 354, 12, 8509, 63, 761, 12, 1499, 430, 953, 327, 3254, 26, 26993, 4340, 370, 2342, 282, 1655, 2488, 3400, 901, 730, 367, 288, 327, 314, 2763, 1159, 4072, 14, 288, 901, 63, 466, 275, 283, 6831, 792, 7, 953, 327, 20703, 314, 901, 2633, 14, 288, 901, 63, 1162, 275, 1052, 288, 8134, 12, 15627, 275, 1962, 288, 340, 15627, 1137, 26719, 26, 355, 901, 63, 1162, 459, 10498, 418, 275, 15627, 288, 327, 19893, 402, 909, 1625, 334, 428, 1649, 63, 19080, 63, 12322, 776, 365, 1329, 402, 7365, 14, 288, 8134, 275, 822, 8, 3572, 9, 288, 340, 8134, 1137, 499, 26, 355, 901, 63, 1162, 459, 3572, 418, 275, 8134, 267, 3753, 26, 288, 3920, 14, 1600, 342, 398, 372, 901, 63, 466, 12, 901, 63, 1162, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 17280, 63, 21202, 199, 504, 1639, 14, 697, 14, 7765, 14, 16404, 14, 21627, 492, 8692, 30516, 199, 199, 533, 15309, 30516, 8, 7243, 30516, 304, 272, 327, 24207, 1958, 1263, 28652, 5550, 5568, 4454, 543, 30490, 14, 221, 24545, 2518, 12, 272, 327, 642, 7859, 1133, 1736, 2451, 641, 15309, 2251, 626, 10621, 1133, 603, 3177, 20238, 14, 24399, 63, 28472, 12, 272, 327, 1325, 652, 365, 314, 1454, 909, 730, 3748, 4453, 5634, 1263, 2885, 14, 272, 666, 63, 1313, 63, 4471, 275, 8692, 30516, 14, 576, 63, 1313, 63, 4471, 14, 1574, 342, 272, 666, 63, 1313, 63, 4471, 59, 11859, 63, 21202, 14, 9868, 61, 275, 283, 6831, 792, 7, 339, 347, 664, 63, 7660, 63, 466, 8, 277, 12, 1817, 63, 354, 12, 8509, 63, 761, 304, 267, 3920, 275, 291, 14, 2105, 14, 3937, 342, 267, 862, 26, 288, 327, 8133, 316, 13044, 63, 24399, 63, 31080, 63, 8314, 370, 664, 314, 22425, 436, 6240, 2556, 14, 288, 862, 26, 355, 3920, 14, 2526, 360, 4859, 298, 19080, 4531, 401, 298, 5943, 998, 2, 4442, 298, 3791, 63, 24399, 63, 31080, 63, 8314, 2, 6038, 298, 8723, 63, 2339, 2, 2458, 83, 2401, 298, 21436, 63, 2339, 2, 2458, 83, 297, 3044, 334, 1224, 63, 354, 14, 4142, 1062, 8509, 63, 761, 14, 4142, 4059, 355, 1962, 275, 3920, 14, 11591, 342, 288, 871, 2186, 465, 1499, 26, 355, 746, 2186, 360, 6531, 440, 2342, 2397, 315, 13044, 63, 24399, 63, 31080, 63, 8314, 5226, 370, 2071, 83, 1674, 6808, 83, 3212, 78, 7, 1816, 283, 547, 1245, 26, 450, 83, 3530, 450, 334, 1224, 63, 354, 12, 8509, 63, 761, 12, 1499, 430, 953, 327, 3254, 26, 26993, 4340, 370, 2342, 282, 1655, 2488, 3400, 901, 730, 367, 288, 327, 314, 2763, 1159, 4072, 14, 288, 901, 63, 466, 275, 283, 6831, 792, 7, 953, 327, 20703, 314, 901, 2633, 14, 288, 901, 63, 1162, 275, 1052, 288, 8134, 12, 15627, 275, 1962, 288, 340, 15627, 1137, 26719, 26, 355, 901, 63, 1162, 459, 10498, 418, 275, 15627, 288, 327, 19893, 402, 909, 1625, 334, 428, 1649, 63, 19080, 63, 12322, 776, 365, 1329, 402, 7365, 14, 288, 8134, 275, 822, 8, 3572, 9, 288, 340, 8134, 1137, 499, 26, 355, 901, 63, 1162, 459, 3572, 418, 275, 8134, 267, 3753, 26, 288, 3920, 14, 1600, 342, 398, 372, 901, 63, 466, 12, 901, 63, 1162, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
aminert/scikit-learn
sklearn/linear_model/logistic.py
105
56686
""" Logistic Regression """ # Author: Gael Varoquaux <gael.varoquaux@normalesup.org> # Fabian Pedregosa <f@bianp.net> # Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> # Manoj Kumar <manojkumarsivaraj334@gmail.com> # Lars Buitinck # Simon Wu <s8wu@uwaterloo.ca> import numbers import warnings import numpy as np from scipy import optimize, sparse from .base import LinearClassifierMixin, SparseCoefMixin, BaseEstimator from ..feature_selection.from_model import _LearntSelectorMixin from ..preprocessing import LabelEncoder, LabelBinarizer from ..svm.base import _fit_liblinear from ..utils import check_array, check_consistent_length, compute_class_weight from ..utils import check_random_state from ..utils.extmath import (logsumexp, log_logistic, safe_sparse_dot, squared_norm) from ..utils.optimize import newton_cg from ..utils.validation import (as_float_array, DataConversionWarning, check_X_y) from ..utils.fixes import expit from ..externals.joblib import Parallel, delayed from ..cross_validation import check_cv from ..externals import six from ..metrics import SCORERS # .. some helper functions for logistic_regression_path .. def _intercept_dot(w, X, y): """Computes y * np.dot(X, w). It takes into consideration if the intercept should be fit or not. Parameters ---------- w : ndarray, shape (n_features,) or (n_features + 1,) Coefficient vector. X : {array-like, sparse matrix}, shape (n_samples, n_features) Training data. y : ndarray, shape (n_samples,) Array of labels. """ c = 0. if w.size == X.shape[1] + 1: c = w[-1] w = w[:-1] z = safe_sparse_dot(X, w) + c return w, c, y * z def _logistic_loss_and_grad(w, X, y, alpha, sample_weight=None): """Computes the logistic loss and gradient. Parameters ---------- w : ndarray, shape (n_features,) or (n_features + 1,) Coefficient vector. X : {array-like, sparse matrix}, shape (n_samples, n_features) Training data. y : ndarray, shape (n_samples,) Array of labels. alpha : float Regularization parameter. alpha is equal to 1 / C. sample_weight : ndarray, shape (n_samples,) optional Array of weights that are assigned to individual samples. If not provided, then each sample is given unit weight. Returns ------- out : float Logistic loss. grad : ndarray, shape (n_features,) or (n_features + 1,) Logistic gradient. """ _, n_features = X.shape grad = np.empty_like(w) w, c, yz = _intercept_dot(w, X, y) if sample_weight is None: sample_weight = np.ones(y.shape[0]) # Logistic loss is the negative of the log of the logistic function. out = -np.sum(sample_weight * log_logistic(yz)) + .5 * alpha * np.dot(w, w) z = expit(yz) z0 = sample_weight * (z - 1) * y grad[:n_features] = safe_sparse_dot(X.T, z0) + alpha * w # Case where we fit the intercept. if grad.shape[0] > n_features: grad[-1] = z0.sum() return out, grad def _logistic_loss(w, X, y, alpha, sample_weight=None): """Computes the logistic loss. Parameters ---------- w : ndarray, shape (n_features,) or (n_features + 1,) Coefficient vector. X : {array-like, sparse matrix}, shape (n_samples, n_features) Training data. y : ndarray, shape (n_samples,) Array of labels. alpha : float Regularization parameter. alpha is equal to 1 / C. sample_weight : ndarray, shape (n_samples,) optional Array of weights that are assigned to individual samples. If not provided, then each sample is given unit weight. Returns ------- out : float Logistic loss. """ w, c, yz = _intercept_dot(w, X, y) if sample_weight is None: sample_weight = np.ones(y.shape[0]) # Logistic loss is the negative of the log of the logistic function. out = -np.sum(sample_weight * log_logistic(yz)) + .5 * alpha * np.dot(w, w) return out def _logistic_grad_hess(w, X, y, alpha, sample_weight=None): """Computes the gradient and the Hessian, in the case of a logistic loss. Parameters ---------- w : ndarray, shape (n_features,) or (n_features + 1,) Coefficient vector. X : {array-like, sparse matrix}, shape (n_samples, n_features) Training data. y : ndarray, shape (n_samples,) Array of labels. alpha : float Regularization parameter. alpha is equal to 1 / C. sample_weight : ndarray, shape (n_samples,) optional Array of weights that are assigned to individual samples. If not provided, then each sample is given unit weight. Returns ------- grad : ndarray, shape (n_features,) or (n_features + 1,) Logistic gradient. Hs : callable Function that takes the gradient as a parameter and returns the matrix product of the Hessian and gradient. """ n_samples, n_features = X.shape grad = np.empty_like(w) fit_intercept = grad.shape[0] > n_features w, c, yz = _intercept_dot(w, X, y) if sample_weight is None: sample_weight = np.ones(y.shape[0]) z = expit(yz) z0 = sample_weight * (z - 1) * y grad[:n_features] = safe_sparse_dot(X.T, z0) + alpha * w # Case where we fit the intercept. if fit_intercept: grad[-1] = z0.sum() # The mat-vec product of the Hessian d = sample_weight * z * (1 - z) if sparse.issparse(X): dX = safe_sparse_dot(sparse.dia_matrix((d, 0), shape=(n_samples, n_samples)), X) else: # Precompute as much as possible dX = d[:, np.newaxis] * X if fit_intercept: # Calculate the double derivative with respect to intercept # In the case of sparse matrices this returns a matrix object. dd_intercept = np.squeeze(np.array(dX.sum(axis=0))) def Hs(s): ret = np.empty_like(s) ret[:n_features] = X.T.dot(dX.dot(s[:n_features])) ret[:n_features] += alpha * s[:n_features] # For the fit intercept case. if fit_intercept: ret[:n_features] += s[-1] * dd_intercept ret[-1] = dd_intercept.dot(s[:n_features]) ret[-1] += d.sum() * s[-1] return ret return grad, Hs def _multinomial_loss(w, X, Y, alpha, sample_weight): """Computes multinomial loss and class probabilities. Parameters ---------- w : ndarray, shape (n_classes * n_features,) or (n_classes * (n_features + 1),) Coefficient vector. X : {array-like, sparse matrix}, shape (n_samples, n_features) Training data. Y : ndarray, shape (n_samples, n_classes) Transformed labels according to the output of LabelBinarizer. alpha : float Regularization parameter. alpha is equal to 1 / C. sample_weight : ndarray, shape (n_samples,) optional Array of weights that are assigned to individual samples. If not provided, then each sample is given unit weight. Returns ------- loss : float Multinomial loss. p : ndarray, shape (n_samples, n_classes) Estimated class probabilities. w : ndarray, shape (n_classes, n_features) Reshaped param vector excluding intercept terms. """ n_classes = Y.shape[1] n_features = X.shape[1] fit_intercept = w.size == (n_classes * (n_features + 1)) w = w.reshape(n_classes, -1) sample_weight = sample_weight[:, np.newaxis] if fit_intercept: intercept = w[:, -1] w = w[:, :-1] else: intercept = 0 p = safe_sparse_dot(X, w.T) p += intercept p -= logsumexp(p, axis=1)[:, np.newaxis] loss = -(sample_weight * Y * p).sum() loss += 0.5 * alpha * squared_norm(w) p = np.exp(p, p) return loss, p, w def _multinomial_loss_grad(w, X, Y, alpha, sample_weight): """Computes the multinomial loss, gradient and class probabilities. Parameters ---------- w : ndarray, shape (n_classes * n_features,) or (n_classes * (n_features + 1),) Coefficient vector. X : {array-like, sparse matrix}, shape (n_samples, n_features) Training data. Y : ndarray, shape (n_samples, n_classes) Transformed labels according to the output of LabelBinarizer. alpha : float Regularization parameter. alpha is equal to 1 / C. sample_weight : ndarray, shape (n_samples,) optional Array of weights that are assigned to individual samples. Returns ------- loss : float Multinomial loss. grad : ndarray, shape (n_classes * n_features,) or (n_classes * (n_features + 1),) Ravelled gradient of the multinomial loss. p : ndarray, shape (n_samples, n_classes) Estimated class probabilities """ n_classes = Y.shape[1] n_features = X.shape[1] fit_intercept = (w.size == n_classes * (n_features + 1)) grad = np.zeros((n_classes, n_features + bool(fit_intercept))) loss, p, w = _multinomial_loss(w, X, Y, alpha, sample_weight) sample_weight = sample_weight[:, np.newaxis] diff = sample_weight * (p - Y) grad[:, :n_features] = safe_sparse_dot(diff.T, X) grad[:, :n_features] += alpha * w if fit_intercept: grad[:, -1] = diff.sum(axis=0) return loss, grad.ravel(), p def _multinomial_grad_hess(w, X, Y, alpha, sample_weight): """ Computes the gradient and the Hessian, in the case of a multinomial loss. Parameters ---------- w : ndarray, shape (n_classes * n_features,) or (n_classes * (n_features + 1),) Coefficient vector. X : {array-like, sparse matrix}, shape (n_samples, n_features) Training data. Y : ndarray, shape (n_samples, n_classes) Transformed labels according to the output of LabelBinarizer. alpha : float Regularization parameter. alpha is equal to 1 / C. sample_weight : ndarray, shape (n_samples,) optional Array of weights that are assigned to individual samples. Returns ------- grad : array, shape (n_classes * n_features,) or (n_classes * (n_features + 1),) Ravelled gradient of the multinomial loss. hessp : callable Function that takes in a vector input of shape (n_classes * n_features) or (n_classes * (n_features + 1)) and returns matrix-vector product with hessian. References ---------- Barak A. Pearlmutter (1993). Fast Exact Multiplication by the Hessian. http://www.bcl.hamilton.ie/~barak/papers/nc-hessian.pdf """ n_features = X.shape[1] n_classes = Y.shape[1] fit_intercept = w.size == (n_classes * (n_features + 1)) # `loss` is unused. Refactoring to avoid computing it does not # significantly speed up the computation and decreases readability loss, grad, p = _multinomial_loss_grad(w, X, Y, alpha, sample_weight) sample_weight = sample_weight[:, np.newaxis] # Hessian-vector product derived by applying the R-operator on the gradient # of the multinomial loss function. def hessp(v): v = v.reshape(n_classes, -1) if fit_intercept: inter_terms = v[:, -1] v = v[:, :-1] else: inter_terms = 0 # r_yhat holds the result of applying the R-operator on the multinomial # estimator. r_yhat = safe_sparse_dot(X, v.T) r_yhat += inter_terms r_yhat += (-p * r_yhat).sum(axis=1)[:, np.newaxis] r_yhat *= p r_yhat *= sample_weight hessProd = np.zeros((n_classes, n_features + bool(fit_intercept))) hessProd[:, :n_features] = safe_sparse_dot(r_yhat.T, X) hessProd[:, :n_features] += v * alpha if fit_intercept: hessProd[:, -1] = r_yhat.sum(axis=0) return hessProd.ravel() return grad, hessp def _check_solver_option(solver, multi_class, penalty, dual): if solver not in ['liblinear', 'newton-cg', 'lbfgs']: raise ValueError("Logistic Regression supports only liblinear," " newton-cg and lbfgs solvers, got %s" % solver) if multi_class not in ['multinomial', 'ovr']: raise ValueError("multi_class should be either multinomial or " "ovr, got %s" % multi_class) if multi_class == 'multinomial' and solver == 'liblinear': raise ValueError("Solver %s does not support " "a multinomial backend." % solver) if solver != 'liblinear': if penalty != 'l2': raise ValueError("Solver %s supports only l2 penalties, " "got %s penalty." % (solver, penalty)) if dual: raise ValueError("Solver %s supports only " "dual=False, got dual=%s" % (solver, dual)) def logistic_regression_path(X, y, pos_class=None, Cs=10, fit_intercept=True, max_iter=100, tol=1e-4, verbose=0, solver='lbfgs', coef=None, copy=True, class_weight=None, dual=False, penalty='l2', intercept_scaling=1., multi_class='ovr', random_state=None): """Compute a Logistic Regression model for a list of regularization parameters. This is an implementation that uses the result of the previous model to speed up computations along the set of solutions, making it faster than sequentially calling LogisticRegression for the different parameters. Read more in the :ref:`User Guide <logistic_regression>`. Parameters ---------- X : array-like or sparse matrix, shape (n_samples, n_features) Input data. y : array-like, shape (n_samples,) Input data, target values. Cs : int | array-like, shape (n_cs,) List of values for the regularization parameter or integer specifying the number of regularization parameters that should be used. In this case, the parameters will be chosen in a logarithmic scale between 1e-4 and 1e4. pos_class : int, None The class with respect to which we perform a one-vs-all fit. If None, then it is assumed that the given problem is binary. fit_intercept : bool Whether to fit an intercept for the model. In this case the shape of the returned array is (n_cs, n_features + 1). max_iter : int Maximum number of iterations for the solver. tol : float Stopping criterion. For the newton-cg and lbfgs solvers, the iteration will stop when ``max{|g_i | i = 1, ..., n} <= tol`` where ``g_i`` is the i-th component of the gradient. verbose : int For the liblinear and lbfgs solvers set verbose to any positive number for verbosity. solver : {'lbfgs', 'newton-cg', 'liblinear'} Numerical solver to use. coef : array-like, shape (n_features,), default None Initialization value for coefficients of logistic regression. copy : bool, default True Whether or not to produce a copy of the data. Setting this to True will be useful in cases, when logistic_regression_path is called repeatedly with the same data, as y is modified along the path. class_weight : dict or 'balanced', optional Weights associated with classes in the form ``{class_label: weight}``. If not given, all classes are supposed to have weight one. The "balanced" mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data as ``n_samples / (n_classes * np.bincount(y))`` dual : bool Dual or primal formulation. Dual formulation is only implemented for l2 penalty with liblinear solver. Prefer dual=False when n_samples > n_features. penalty : str, 'l1' or 'l2' Used to specify the norm used in the penalization. The newton-cg and lbfgs solvers support only l2 penalties. intercept_scaling : float, default 1. This parameter is useful only when the solver 'liblinear' is used and self.fit_intercept is set to True. In this case, x becomes [x, self.intercept_scaling], i.e. a "synthetic" feature with constant value equals to intercept_scaling is appended to the instance vector. The intercept becomes intercept_scaling * synthetic feature weight Note! the synthetic feature weight is subject to l1/l2 regularization as all other features. To lessen the effect of regularization on synthetic feature weight (and therefore on the intercept) intercept_scaling has to be increased. multi_class : str, {'ovr', 'multinomial'} Multiclass option can be either 'ovr' or 'multinomial'. If the option chosen is 'ovr', then a binary problem is fit for each label. Else the loss minimised is the multinomial loss fit across the entire probability distribution. Works only for the 'lbfgs' and 'newton-cg' solvers. random_state : int seed, RandomState instance, or None (default) The seed of the pseudo random number generator to use when shuffling the data. Returns ------- coefs : ndarray, shape (n_cs, n_features) or (n_cs, n_features + 1) List of coefficients for the Logistic Regression model. If fit_intercept is set to True then the second dimension will be n_features + 1, where the last item represents the intercept. Cs : ndarray Grid of Cs used for cross-validation. Notes ----- You might get slighly different results with the solver liblinear than with the others since this uses LIBLINEAR which penalizes the intercept. """ if isinstance(Cs, numbers.Integral): Cs = np.logspace(-4, 4, Cs) _check_solver_option(solver, multi_class, penalty, dual) # Preprocessing. X = check_array(X, accept_sparse='csr', dtype=np.float64) y = check_array(y, ensure_2d=False, copy=copy, dtype=None) _, n_features = X.shape check_consistent_length(X, y) classes = np.unique(y) random_state = check_random_state(random_state) if pos_class is None and multi_class != 'multinomial': if (classes.size > 2): raise ValueError('To fit OvR, use the pos_class argument') # np.unique(y) gives labels in sorted order. pos_class = classes[1] # If class_weights is a dict (provided by the user), the weights # are assigned to the original labels. If it is "auto", then # the class_weights are assigned after masking the labels with a OvR. sample_weight = np.ones(X.shape[0]) le = LabelEncoder() if isinstance(class_weight, dict): if solver == "liblinear": if classes.size == 2: # Reconstruct the weights with keys 1 and -1 temp = {1: class_weight[pos_class], -1: class_weight[classes[0]]} class_weight = temp.copy() else: raise ValueError("In LogisticRegressionCV the liblinear " "solver cannot handle multiclass with " "class_weight of type dict. Use the lbfgs, " "newton-cg solvers or set " "class_weight='auto'") else: class_weight_ = compute_class_weight(class_weight, classes, y) sample_weight = class_weight_[le.fit_transform(y)] # For doing a ovr, we need to mask the labels first. for the # multinomial case this is not necessary. if multi_class == 'ovr': w0 = np.zeros(n_features + int(fit_intercept)) mask_classes = [-1, 1] mask = (y == pos_class) y[mask] = 1 y[~mask] = -1 # To take care of object dtypes, i.e 1 and -1 are in the form of # strings. y = as_float_array(y, copy=False) else: lbin = LabelBinarizer() Y_bin = lbin.fit_transform(y) if Y_bin.shape[1] == 1: Y_bin = np.hstack([1 - Y_bin, Y_bin]) w0 = np.zeros((Y_bin.shape[1], n_features + int(fit_intercept)), order='F') mask_classes = classes if class_weight == "auto": class_weight_ = compute_class_weight(class_weight, mask_classes, y) sample_weight = class_weight_[le.fit_transform(y)] if coef is not None: # it must work both giving the bias term and not if multi_class == 'ovr': if coef.size not in (n_features, w0.size): raise ValueError( 'Initialization coef is of shape %d, expected shape ' '%d or %d' % (coef.size, n_features, w0.size)) w0[:coef.size] = coef else: # For binary problems coef.shape[0] should be 1, otherwise it # should be classes.size. n_vectors = classes.size if n_vectors == 2: n_vectors = 1 if (coef.shape[0] != n_vectors or coef.shape[1] not in (n_features, n_features + 1)): raise ValueError( 'Initialization coef is of shape (%d, %d), expected ' 'shape (%d, %d) or (%d, %d)' % ( coef.shape[0], coef.shape[1], classes.size, n_features, classes.size, n_features + 1)) w0[:, :coef.shape[1]] = coef if multi_class == 'multinomial': # fmin_l_bfgs_b and newton-cg accepts only ravelled parameters. w0 = w0.ravel() target = Y_bin if solver == 'lbfgs': func = lambda x, *args: _multinomial_loss_grad(x, *args)[0:2] elif solver == 'newton-cg': func = lambda x, *args: _multinomial_loss(x, *args)[0] grad = lambda x, *args: _multinomial_loss_grad(x, *args)[1] hess = _multinomial_grad_hess else: target = y if solver == 'lbfgs': func = _logistic_loss_and_grad elif solver == 'newton-cg': func = _logistic_loss grad = lambda x, *args: _logistic_loss_and_grad(x, *args)[1] hess = _logistic_grad_hess coefs = list() for C in Cs: if solver == 'lbfgs': try: w0, loss, info = optimize.fmin_l_bfgs_b( func, w0, fprime=None, args=(X, target, 1. / C, sample_weight), iprint=(verbose > 0) - 1, pgtol=tol, maxiter=max_iter) except TypeError: # old scipy doesn't have maxiter w0, loss, info = optimize.fmin_l_bfgs_b( func, w0, fprime=None, args=(X, target, 1. / C, sample_weight), iprint=(verbose > 0) - 1, pgtol=tol) if info["warnflag"] == 1 and verbose > 0: warnings.warn("lbfgs failed to converge. Increase the number " "of iterations.") elif solver == 'newton-cg': args = (X, target, 1. / C, sample_weight) w0 = newton_cg(hess, func, grad, w0, args=args, maxiter=max_iter, tol=tol) elif solver == 'liblinear': coef_, intercept_, _, = _fit_liblinear( X, y, C, fit_intercept, intercept_scaling, class_weight, penalty, dual, verbose, max_iter, tol, random_state) if fit_intercept: w0 = np.concatenate([coef_.ravel(), intercept_]) else: w0 = coef_.ravel() else: raise ValueError("solver must be one of {'liblinear', 'lbfgs', " "'newton-cg'}, got '%s' instead" % solver) if multi_class == 'multinomial': multi_w0 = np.reshape(w0, (classes.size, -1)) if classes.size == 2: multi_w0 = multi_w0[1][np.newaxis, :] coefs.append(multi_w0) else: coefs.append(w0) return coefs, np.array(Cs) # helper function for LogisticCV def _log_reg_scoring_path(X, y, train, test, pos_class=None, Cs=10, scoring=None, fit_intercept=False, max_iter=100, tol=1e-4, class_weight=None, verbose=0, solver='lbfgs', penalty='l2', dual=False, copy=True, intercept_scaling=1., multi_class='ovr'): """Computes scores across logistic_regression_path Parameters ---------- X : {array-like, sparse matrix}, shape (n_samples, n_features) Training data. y : array-like, shape (n_samples,) or (n_samples, n_targets) Target labels. train : list of indices The indices of the train set. test : list of indices The indices of the test set. pos_class : int, None The class with respect to which we perform a one-vs-all fit. If None, then it is assumed that the given problem is binary. Cs : list of floats | int Each of the values in Cs describes the inverse of regularization strength. If Cs is as an int, then a grid of Cs values are chosen in a logarithmic scale between 1e-4 and 1e4. If not provided, then a fixed set of values for Cs are used. scoring : callable For a list of scoring functions that can be used, look at :mod:`sklearn.metrics`. The default scoring option used is accuracy_score. fit_intercept : bool If False, then the bias term is set to zero. Else the last term of each coef_ gives us the intercept. max_iter : int Maximum number of iterations for the solver. tol : float Tolerance for stopping criteria. class_weight : dict or 'balanced', optional Weights associated with classes in the form ``{class_label: weight}``. If not given, all classes are supposed to have weight one. The "balanced" mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data as ``n_samples / (n_classes * np.bincount(y))`` verbose : int For the liblinear and lbfgs solvers set verbose to any positive number for verbosity. solver : {'lbfgs', 'newton-cg', 'liblinear'} Decides which solver to use. penalty : str, 'l1' or 'l2' Used to specify the norm used in the penalization. The newton-cg and lbfgs solvers support only l2 penalties. dual : bool Dual or primal formulation. Dual formulation is only implemented for l2 penalty with liblinear solver. Prefer dual=False when n_samples > n_features. intercept_scaling : float, default 1. This parameter is useful only when the solver 'liblinear' is used and self.fit_intercept is set to True. In this case, x becomes [x, self.intercept_scaling], i.e. a "synthetic" feature with constant value equals to intercept_scaling is appended to the instance vector. The intercept becomes intercept_scaling * synthetic feature weight Note! the synthetic feature weight is subject to l1/l2 regularization as all other features. To lessen the effect of regularization on synthetic feature weight (and therefore on the intercept) intercept_scaling has to be increased. multi_class : str, {'ovr', 'multinomial'} Multiclass option can be either 'ovr' or 'multinomial'. If the option chosen is 'ovr', then a binary problem is fit for each label. Else the loss minimised is the multinomial loss fit across the entire probability distribution. Works only for the 'lbfgs' solver. copy : bool, default True Whether or not to produce a copy of the data. Setting this to True will be useful in cases, when ``_log_reg_scoring_path`` is called repeatedly with the same data, as y is modified along the path. Returns ------- coefs : ndarray, shape (n_cs, n_features) or (n_cs, n_features + 1) List of coefficients for the Logistic Regression model. If fit_intercept is set to True then the second dimension will be n_features + 1, where the last item represents the intercept. Cs : ndarray Grid of Cs used for cross-validation. scores : ndarray, shape (n_cs,) Scores obtained for each Cs. """ _check_solver_option(solver, multi_class, penalty, dual) log_reg = LogisticRegression(fit_intercept=fit_intercept) X_train = X[train] X_test = X[test] y_train = y[train] y_test = y[test] # The score method of Logistic Regression has a classes_ attribute. if multi_class == 'ovr': log_reg.classes_ = np.array([-1, 1]) elif multi_class == 'multinomial': log_reg.classes_ = np.unique(y_train) else: raise ValueError("multi_class should be either multinomial or ovr, " "got %d" % multi_class) if pos_class is not None: mask = (y_test == pos_class) y_test[mask] = 1 y_test[~mask] = -1 # To deal with object dtypes, we need to convert into an array of floats. y_test = as_float_array(y_test, copy=False) coefs, Cs = logistic_regression_path(X_train, y_train, Cs=Cs, fit_intercept=fit_intercept, solver=solver, max_iter=max_iter, class_weight=class_weight, copy=copy, pos_class=pos_class, multi_class=multi_class, tol=tol, verbose=verbose, dual=dual, penalty=penalty, intercept_scaling=intercept_scaling) scores = list() if isinstance(scoring, six.string_types): scoring = SCORERS[scoring] for w in coefs: if multi_class == 'ovr': w = w[np.newaxis, :] if fit_intercept: log_reg.coef_ = w[:, :-1] log_reg.intercept_ = w[:, -1] else: log_reg.coef_ = w log_reg.intercept_ = 0. if scoring is None: scores.append(log_reg.score(X_test, y_test)) else: scores.append(scoring(log_reg, X_test, y_test)) return coefs, Cs, np.array(scores) class LogisticRegression(BaseEstimator, LinearClassifierMixin, _LearntSelectorMixin, SparseCoefMixin): """Logistic Regression (aka logit, MaxEnt) classifier. In the multiclass case, the training algorithm uses the one-vs-rest (OvR) scheme if the 'multi_class' option is set to 'ovr' and uses the cross-entropy loss, if the 'multi_class' option is set to 'multinomial'. (Currently the 'multinomial' option is supported only by the 'lbfgs' and 'newton-cg' solvers.) This class implements regularized logistic regression using the `liblinear` library, newton-cg and lbfgs solvers. It can handle both dense and sparse input. Use C-ordered arrays or CSR matrices containing 64-bit floats for optimal performance; any other input format will be converted (and copied). The newton-cg and lbfgs solvers support only L2 regularization with primal formulation. The liblinear solver supports both L1 and L2 regularization, with a dual formulation only for the L2 penalty. Read more in the :ref:`User Guide <logistic_regression>`. Parameters ---------- penalty : str, 'l1' or 'l2' Used to specify the norm used in the penalization. The newton-cg and lbfgs solvers support only l2 penalties. dual : bool Dual or primal formulation. Dual formulation is only implemented for l2 penalty with liblinear solver. Prefer dual=False when n_samples > n_features. C : float, optional (default=1.0) Inverse of regularization strength; must be a positive float. Like in support vector machines, smaller values specify stronger regularization. fit_intercept : bool, default: True Specifies if a constant (a.k.a. bias or intercept) should be added the decision function. intercept_scaling : float, default: 1 Useful only if solver is liblinear. when self.fit_intercept is True, instance vector x becomes [x, self.intercept_scaling], i.e. a "synthetic" feature with constant value equals to intercept_scaling is appended to the instance vector. The intercept becomes intercept_scaling * synthetic feature weight Note! the synthetic feature weight is subject to l1/l2 regularization as all other features. To lessen the effect of regularization on synthetic feature weight (and therefore on the intercept) intercept_scaling has to be increased. class_weight : dict or 'balanced', optional Weights associated with classes in the form ``{class_label: weight}``. If not given, all classes are supposed to have weight one. The "balanced" mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data as ``n_samples / (n_classes * np.bincount(y))`` max_iter : int Useful only for the newton-cg and lbfgs solvers. Maximum number of iterations taken for the solvers to converge. random_state : int seed, RandomState instance, or None (default) The seed of the pseudo random number generator to use when shuffling the data. solver : {'newton-cg', 'lbfgs', 'liblinear'} Algorithm to use in the optimization problem. tol : float, optional Tolerance for stopping criteria. multi_class : str, {'ovr', 'multinomial'} Multiclass option can be either 'ovr' or 'multinomial'. If the option chosen is 'ovr', then a binary problem is fit for each label. Else the loss minimised is the multinomial loss fit across the entire probability distribution. Works only for the 'lbfgs' solver. verbose : int For the liblinear and lbfgs solvers set verbose to any positive number for verbosity. Attributes ---------- coef_ : array, shape (n_classes, n_features) Coefficient of the features in the decision function. intercept_ : array, shape (n_classes,) Intercept (a.k.a. bias) added to the decision function. If `fit_intercept` is set to False, the intercept is set to zero. n_iter_ : int Maximum of the actual number of iterations across all classes. Valid only for the liblinear solver. See also -------- SGDClassifier : incrementally trained logistic regression (when given the parameter ``loss="log"``). sklearn.svm.LinearSVC : learns SVM models using the same algorithm. Notes ----- The underlying C implementation uses a random number generator to select features when fitting the model. It is thus not uncommon, to have slightly different results for the same input data. If that happens, try with a smaller tol parameter. Predict output may not match that of standalone liblinear in certain cases. See :ref:`differences from liblinear <liblinear_differences>` in the narrative documentation. References ---------- LIBLINEAR -- A Library for Large Linear Classification http://www.csie.ntu.edu.tw/~cjlin/liblinear/ Hsiang-Fu Yu, Fang-Lan Huang, Chih-Jen Lin (2011). Dual coordinate descent methods for logistic regression and maximum entropy models. Machine Learning 85(1-2):41-75. http://www.csie.ntu.edu.tw/~cjlin/papers/maxent_dual.pdf See also -------- sklearn.linear_model.SGDClassifier """ def __init__(self, penalty='l2', dual=False, tol=1e-4, C=1.0, fit_intercept=True, intercept_scaling=1, class_weight=None, random_state=None, solver='liblinear', max_iter=100, multi_class='ovr', verbose=0): self.penalty = penalty self.dual = dual self.tol = tol self.C = C self.fit_intercept = fit_intercept self.intercept_scaling = intercept_scaling self.class_weight = class_weight self.random_state = random_state self.solver = solver self.max_iter = max_iter self.multi_class = multi_class self.verbose = verbose def fit(self, X, y): """Fit the model according to the given training data. Parameters ---------- X : {array-like, sparse matrix}, shape (n_samples, n_features) Training vector, where n_samples in the number of samples and n_features is the number of features. y : array-like, shape (n_samples,) Target vector relative to X. Returns ------- self : object Returns self. """ if not isinstance(self.C, numbers.Number) or self.C < 0: raise ValueError("Penalty term must be positive; got (C=%r)" % self.C) if not isinstance(self.max_iter, numbers.Number) or self.max_iter < 0: raise ValueError("Maximum number of iteration must be positive;" " got (max_iter=%r)" % self.max_iter) if not isinstance(self.tol, numbers.Number) or self.tol < 0: raise ValueError("Tolerance for stopping criteria must be " "positive; got (tol=%r)" % self.tol) X, y = check_X_y(X, y, accept_sparse='csr', dtype=np.float64, order="C") self.classes_ = np.unique(y) _check_solver_option(self.solver, self.multi_class, self.penalty, self.dual) if self.solver == 'liblinear': self.coef_, self.intercept_, self.n_iter_ = _fit_liblinear( X, y, self.C, self.fit_intercept, self.intercept_scaling, self.class_weight, self.penalty, self.dual, self.verbose, self.max_iter, self.tol, self.random_state) return self n_classes = len(self.classes_) classes_ = self.classes_ if n_classes < 2: raise ValueError("This solver needs samples of at least 2 classes" " in the data, but the data contains only one" " class: %r" % classes_[0]) if len(self.classes_) == 2: n_classes = 1 classes_ = classes_[1:] self.coef_ = list() self.intercept_ = np.zeros(n_classes) # Hack so that we iterate only once for the multinomial case. if self.multi_class == 'multinomial': classes_ = [None] for ind, class_ in enumerate(classes_): coef_, _ = logistic_regression_path( X, y, pos_class=class_, Cs=[self.C], fit_intercept=self.fit_intercept, tol=self.tol, verbose=self.verbose, solver=self.solver, multi_class=self.multi_class, max_iter=self.max_iter, class_weight=self.class_weight) self.coef_.append(coef_[0]) self.coef_ = np.squeeze(self.coef_) # For the binary case, this get squeezed to a 1-D array. if self.coef_.ndim == 1: self.coef_ = self.coef_[np.newaxis, :] self.coef_ = np.asarray(self.coef_) if self.fit_intercept: self.intercept_ = self.coef_[:, -1] self.coef_ = self.coef_[:, :-1] return self def predict_proba(self, X): """Probability estimates. The returned estimates for all classes are ordered by the label of classes. Parameters ---------- X : array-like, shape = [n_samples, n_features] Returns ------- T : array-like, shape = [n_samples, n_classes] Returns the probability of the sample for each class in the model, where classes are ordered as they are in ``self.classes_``. """ return self._predict_proba_lr(X) def predict_log_proba(self, X): """Log of probability estimates. The returned estimates for all classes are ordered by the label of classes. Parameters ---------- X : array-like, shape = [n_samples, n_features] Returns ------- T : array-like, shape = [n_samples, n_classes] Returns the log-probability of the sample for each class in the model, where classes are ordered as they are in ``self.classes_``. """ return np.log(self.predict_proba(X)) class LogisticRegressionCV(LogisticRegression, BaseEstimator, LinearClassifierMixin, _LearntSelectorMixin): """Logistic Regression CV (aka logit, MaxEnt) classifier. This class implements logistic regression using liblinear, newton-cg or LBFGS optimizer. The newton-cg and lbfgs solvers support only L2 regularization with primal formulation. The liblinear solver supports both L1 and L2 regularization, with a dual formulation only for the L2 penalty. For the grid of Cs values (that are set by default to be ten values in a logarithmic scale between 1e-4 and 1e4), the best hyperparameter is selected by the cross-validator StratifiedKFold, but it can be changed using the cv parameter. In the case of newton-cg and lbfgs solvers, we warm start along the path i.e guess the initial coefficients of the present fit to be the coefficients got after convergence in the previous fit, so it is supposed to be faster for high-dimensional dense data. For a multiclass problem, the hyperparameters for each class are computed using the best scores got by doing a one-vs-rest in parallel across all folds and classes. Hence this is not the true multinomial loss. Read more in the :ref:`User Guide <logistic_regression>`. Parameters ---------- Cs : list of floats | int Each of the values in Cs describes the inverse of regularization strength. If Cs is as an int, then a grid of Cs values are chosen in a logarithmic scale between 1e-4 and 1e4. Like in support vector machines, smaller values specify stronger regularization. fit_intercept : bool, default: True Specifies if a constant (a.k.a. bias or intercept) should be added the decision function. class_weight : dict or 'balanced', optional Weights associated with classes in the form ``{class_label: weight}``. If not given, all classes are supposed to have weight one. The "balanced" mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data as ``n_samples / (n_classes * np.bincount(y))`` cv : integer or cross-validation generator The default cross-validation generator used is Stratified K-Folds. If an integer is provided, then it is the number of folds used. See the module :mod:`sklearn.cross_validation` module for the list of possible cross-validation objects. penalty : str, 'l1' or 'l2' Used to specify the norm used in the penalization. The newton-cg and lbfgs solvers support only l2 penalties. dual : bool Dual or primal formulation. Dual formulation is only implemented for l2 penalty with liblinear solver. Prefer dual=False when n_samples > n_features. scoring : callabale Scoring function to use as cross-validation criteria. For a list of scoring functions that can be used, look at :mod:`sklearn.metrics`. The default scoring option used is accuracy_score. solver : {'newton-cg', 'lbfgs', 'liblinear'} Algorithm to use in the optimization problem. tol : float, optional Tolerance for stopping criteria. max_iter : int, optional Maximum number of iterations of the optimization algorithm. class_weight : dict or 'balanced', optional Weights associated with classes in the form ``{class_label: weight}``. If not given, all classes are supposed to have weight one. The "balanced" mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data as ``n_samples / (n_classes * np.bincount(y))`` n_jobs : int, optional Number of CPU cores used during the cross-validation loop. If given a value of -1, all cores are used. verbose : int For the liblinear and lbfgs solvers set verbose to any positive number for verbosity. refit : bool If set to True, the scores are averaged across all folds, and the coefs and the C that corresponds to the best score is taken, and a final refit is done using these parameters. Otherwise the coefs, intercepts and C that correspond to the best scores across folds are averaged. multi_class : str, {'ovr', 'multinomial'} Multiclass option can be either 'ovr' or 'multinomial'. If the option chosen is 'ovr', then a binary problem is fit for each label. Else the loss minimised is the multinomial loss fit across the entire probability distribution. Works only for the 'lbfgs' solver. intercept_scaling : float, default 1. Useful only if solver is liblinear. This parameter is useful only when the solver 'liblinear' is used and self.fit_intercept is set to True. In this case, x becomes [x, self.intercept_scaling], i.e. a "synthetic" feature with constant value equals to intercept_scaling is appended to the instance vector. The intercept becomes intercept_scaling * synthetic feature weight Note! the synthetic feature weight is subject to l1/l2 regularization as all other features. To lessen the effect of regularization on synthetic feature weight (and therefore on the intercept) intercept_scaling has to be increased. Attributes ---------- coef_ : array, shape (1, n_features) or (n_classes, n_features) Coefficient of the features in the decision function. `coef_` is of shape (1, n_features) when the given problem is binary. `coef_` is readonly property derived from `raw_coef_` that follows the internal memory layout of liblinear. intercept_ : array, shape (1,) or (n_classes,) Intercept (a.k.a. bias) added to the decision function. It is available only when parameter intercept is set to True and is of shape(1,) when the problem is binary. Cs_ : array Array of C i.e. inverse of regularization parameter values used for cross-validation. coefs_paths_ : array, shape ``(n_folds, len(Cs_), n_features)`` or \ ``(n_folds, len(Cs_), n_features + 1)`` dict with classes as the keys, and the path of coefficients obtained during cross-validating across each fold and then across each Cs after doing an OvR for the corresponding class as values. If the 'multi_class' option is set to 'multinomial', then the coefs_paths are the coefficients corresponding to each class. Each dict value has shape ``(n_folds, len(Cs_), n_features)`` or ``(n_folds, len(Cs_), n_features + 1)`` depending on whether the intercept is fit or not. scores_ : dict dict with classes as the keys, and the values as the grid of scores obtained during cross-validating each fold, after doing an OvR for the corresponding class. If the 'multi_class' option given is 'multinomial' then the same scores are repeated across all classes, since this is the multinomial class. Each dict value has shape (n_folds, len(Cs)) C_ : array, shape (n_classes,) or (n_classes - 1,) Array of C that maps to the best scores across every class. If refit is set to False, then for each class, the best C is the average of the C's that correspond to the best scores for each fold. See also -------- LogisticRegression """ def __init__(self, Cs=10, fit_intercept=True, cv=None, dual=False, penalty='l2', scoring=None, solver='lbfgs', tol=1e-4, max_iter=100, class_weight=None, n_jobs=1, verbose=0, refit=True, intercept_scaling=1., multi_class='ovr'): self.Cs = Cs self.fit_intercept = fit_intercept self.cv = cv self.dual = dual self.penalty = penalty self.scoring = scoring self.tol = tol self.max_iter = max_iter self.class_weight = class_weight self.n_jobs = n_jobs self.verbose = verbose self.solver = solver self.refit = refit self.intercept_scaling = intercept_scaling self.multi_class = multi_class def fit(self, X, y): """Fit the model according to the given training data. Parameters ---------- X : {array-like, sparse matrix}, shape (n_samples, n_features) Training vector, where n_samples in the number of samples and n_features is the number of features. y : array-like, shape (n_samples,) Target vector relative to X. Returns ------- self : object Returns self. """ _check_solver_option(self.solver, self.multi_class, self.penalty, self.dual) if not isinstance(self.max_iter, numbers.Number) or self.max_iter < 0: raise ValueError("Maximum number of iteration must be positive;" " got (max_iter=%r)" % self.max_iter) if not isinstance(self.tol, numbers.Number) or self.tol < 0: raise ValueError("Tolerance for stopping criteria must be " "positive; got (tol=%r)" % self.tol) X = check_array(X, accept_sparse='csr', dtype=np.float64) y = check_array(y, ensure_2d=False, dtype=None) if y.ndim == 2 and y.shape[1] == 1: warnings.warn( "A column-vector y was passed when a 1d array was" " expected. Please change the shape of y to " "(n_samples, ), for example using ravel().", DataConversionWarning) y = np.ravel(y) check_consistent_length(X, y) # init cross-validation generator cv = check_cv(self.cv, X, y, classifier=True) folds = list(cv) self._enc = LabelEncoder() self._enc.fit(y) labels = self.classes_ = np.unique(y) n_classes = len(labels) if n_classes < 2: raise ValueError("This solver needs samples of at least 2 classes" " in the data, but the data contains only one" " class: %r" % self.classes_[0]) if n_classes == 2: # OvR in case of binary problems is as good as fitting # the higher label n_classes = 1 labels = labels[1:] # We need this hack to iterate only once over labels, in the case of # multi_class = multinomial, without changing the value of the labels. iter_labels = labels if self.multi_class == 'multinomial': iter_labels = [None] if self.class_weight and not(isinstance(self.class_weight, dict) or self.class_weight in ['balanced', 'auto']): raise ValueError("class_weight provided should be a " "dict or 'balanced'") path_func = delayed(_log_reg_scoring_path) fold_coefs_ = Parallel(n_jobs=self.n_jobs, verbose=self.verbose)( path_func(X, y, train, test, pos_class=label, Cs=self.Cs, fit_intercept=self.fit_intercept, penalty=self.penalty, dual=self.dual, solver=self.solver, tol=self.tol, max_iter=self.max_iter, verbose=self.verbose, class_weight=self.class_weight, scoring=self.scoring, multi_class=self.multi_class, intercept_scaling=self.intercept_scaling ) for label in iter_labels for train, test in folds) if self.multi_class == 'multinomial': multi_coefs_paths, Cs, multi_scores = zip(*fold_coefs_) multi_coefs_paths = np.asarray(multi_coefs_paths) multi_scores = np.asarray(multi_scores) # This is just to maintain API similarity between the ovr and # multinomial option. # Coefs_paths in now n_folds X len(Cs) X n_classes X n_features # we need it to be n_classes X len(Cs) X n_folds X n_features # to be similar to "ovr". coefs_paths = np.rollaxis(multi_coefs_paths, 2, 0) # Multinomial has a true score across all labels. Hence the # shape is n_folds X len(Cs). We need to repeat this score # across all labels for API similarity. scores = np.tile(multi_scores, (n_classes, 1, 1)) self.Cs_ = Cs[0] else: coefs_paths, Cs, scores = zip(*fold_coefs_) self.Cs_ = Cs[0] coefs_paths = np.reshape(coefs_paths, (n_classes, len(folds), len(self.Cs_), -1)) self.coefs_paths_ = dict(zip(labels, coefs_paths)) scores = np.reshape(scores, (n_classes, len(folds), -1)) self.scores_ = dict(zip(labels, scores)) self.C_ = list() self.coef_ = np.empty((n_classes, X.shape[1])) self.intercept_ = np.zeros(n_classes) # hack to iterate only once for multinomial case. if self.multi_class == 'multinomial': scores = multi_scores coefs_paths = multi_coefs_paths for index, label in enumerate(iter_labels): if self.multi_class == 'ovr': scores = self.scores_[label] coefs_paths = self.coefs_paths_[label] if self.refit: best_index = scores.sum(axis=0).argmax() C_ = self.Cs_[best_index] self.C_.append(C_) if self.multi_class == 'multinomial': coef_init = np.mean(coefs_paths[:, best_index, :, :], axis=0) else: coef_init = np.mean(coefs_paths[:, best_index, :], axis=0) w, _ = logistic_regression_path( X, y, pos_class=label, Cs=[C_], solver=self.solver, fit_intercept=self.fit_intercept, coef=coef_init, max_iter=self.max_iter, tol=self.tol, penalty=self.penalty, class_weight=self.class_weight, multi_class=self.multi_class, verbose=max(0, self.verbose - 1)) w = w[0] else: # Take the best scores across every fold and the average of all # coefficients corresponding to the best scores. best_indices = np.argmax(scores, axis=1) w = np.mean([coefs_paths[i][best_indices[i]] for i in range(len(folds))], axis=0) self.C_.append(np.mean(self.Cs_[best_indices])) if self.multi_class == 'multinomial': self.C_ = np.tile(self.C_, n_classes) self.coef_ = w[:, :X.shape[1]] if self.fit_intercept: self.intercept_ = w[:, -1] else: self.coef_[index] = w[: X.shape[1]] if self.fit_intercept: self.intercept_[index] = w[-1] self.C_ = np.asarray(self.C_) return self
bsd-3-clause
[ 624, 199, 2445, 6937, 13262, 199, 624, 199, 199, 3, 6529, 26, 9647, 352, 21084, 79, 392, 10962, 665, 5294, 352, 14, 1391, 79, 392, 10962, 32, 6505, 17667, 1961, 14, 1308, 30, 199, 3, 260, 481, 371, 5653, 510, 379, 1135, 29295, 665, 70, 32, 9662, 80, 14, 846, 30, 199, 3, 260, 22986, 28547, 27211, 10279, 665, 24421, 28547, 14, 1679, 10279, 32, 15253, 957, 13, 462, 374, 15970, 14, 4391, 30, 199, 3, 260, 4688, 79, 74, 1804, 453, 285, 665, 1237, 79, 17421, 453, 285, 338, 1391, 9091, 8425, 32, 6799, 14, 957, 30, 199, 3, 260, 491, 4291, 4779, 390, 262, 346, 199, 3, 260, 10751, 265, 644, 85, 665, 83, 24, 87, 85, 32, 85, 17217, 320, 79, 14, 696, 30, 199, 199, 646, 5579, 199, 646, 3598, 199, 199, 646, 2680, 465, 980, 199, 504, 7026, 492, 13497, 12, 5178, 199, 199, 504, 1275, 1095, 492, 12489, 8508, 4256, 12, 14531, 967, 2829, 4256, 12, 3523, 13183, 199, 504, 2508, 4445, 63, 5592, 14, 504, 63, 1238, 492, 485, 44, 2210, 343, 11212, 4256, 199, 504, 2508, 21402, 492, 10354, 6679, 12, 10354, 13394, 31008, 199, 504, 2508, 16820, 14, 1095, 492, 485, 3269, 63, 773, 6676, 199, 504, 2508, 1208, 492, 1104, 63, 1144, 12, 1104, 63, 15478, 63, 1267, 12, 4526, 63, 533, 63, 3463, 199, 504, 2508, 1208, 492, 1104, 63, 2355, 63, 929, 199, 504, 2508, 1208, 14, 832, 3442, 492, 334, 7270, 940, 9290, 12, 943, 63, 23452, 12, 5048, 63, 4421, 63, 3287, 12, 2490, 20478, 63, 4791, 9, 199, 504, 2508, 1208, 14, 13416, 492, 892, 1860, 63, 12595, 199, 504, 2508, 1208, 14, 6136, 492, 334, 305, 63, 1609, 63, 1144, 12, 3918, 20403, 3849, 12, 1816, 1104, 63, 56, 63, 89, 9, 199, 504, 2508, 1208, 14, 26205, 492, 1437, 390, 199, 504, 2508, 24688, 14, 2423, 773, 492, 27311, 12, 24725, 199, 504, 2508, 7925, 63, 6136, 492, 1104, 63, 5107, 199, 504, 2508, 24688, 492, 3816, 199, 504, 2508, 6759, 492, 12075, 726, 3960, 421, 199, 3, 2508, 2005, 5922, 3423, 367, 30360, 63, 12513, 63, 515, 2508, 199, 318, 485, 10863, 63, 3287, 8, 87, 12, 1323, 12, 612, 304, 272, 408, 22594, 612, 627, 980, 14, 3287, 8, 56, 12, 336, 680, 339, 2779, 6181, 1901, 8219, 1754, 340, 314, 13926, 1077, 506, 5542, 503, 440, 14, 339, 3897, 272, 4143, 272, 336, 520, 6800, 12, 2215, 334, 78, 63, 3179, 4258, 503, 334, 78, 63, 3179, 435, 413, 4258, 267, 1849, 21069, 5477, 14, 339, 1323, 520, 469, 1144, 13, 2930, 12, 5178, 3634, 1386, 2215, 334, 78, 63, 3356, 12, 302, 63, 3179, 9, 267, 22859, 666, 14, 339, 612, 520, 6800, 12, 2215, 334, 78, 63, 3356, 4258, 267, 8725, 402, 3628, 14, 272, 408, 272, 286, 275, 378, 14, 272, 340, 336, 14, 890, 508, 1323, 14, 1392, 59, 17, 61, 435, 413, 26, 267, 286, 275, 336, 1988, 17, 61, 267, 336, 275, 336, 4439, 17, 61, 339, 1315, 275, 5048, 63, 4421, 63, 3287, 8, 56, 12, 336, 9, 435, 286, 272, 372, 336, 12, 286, 12, 612, 627, 1315, 421, 199, 318, 485, 23452, 63, 4358, 63, 460, 63, 6017, 8, 87, 12, 1323, 12, 612, 12, 5131, 12, 2690, 63, 3463, 29, 403, 304, 272, 408, 22594, 314, 30360, 5621, 436, 6709, 14, 339, 3897, 272, 4143, 272, 336, 520, 6800, 12, 2215, 334, 78, 63, 3179, 4258, 503, 334, 78, 63, 3179, 435, 413, 4258, 267, 1849, 21069, 5477, 14, 339, 1323, 520, 469, 1144, 13, 2930, 12, 5178, 3634, 1386, 2215, 334, 78, 63, 3356, 12, 302, 63, 3179, 9, 267, 22859, 666, 14, 339, 612, 520, 6800, 12, 2215, 334, 78, 63, 3356, 4258, 267, 8725, 402, 3628, 14, 339, 5131, 520, 2069, 267, 18528, 2072, 2725, 14, 5131, 365, 4472, 370, 413, 1182, 445, 14, 339, 2690, 63, 3463, 520, 6800, 12, 2215, 334, 78, 63, 3356, 4258, 2716, 267, 8725, 402, 4931, 626, 787, 7943, 370, 8212, 5845, 14, 267, 982, 440, 2741, 12, 2066, 1924, 2690, 365, 1627, 4137, 5401, 14, 339, 1803, 272, 5514, 272, 734, 520, 2069, 267, 5297, 6937, 5621, 14, 339, 7659, 520, 6800, 12, 2215, 334, 78, 63, 3179, 4258, 503, 334, 78, 63, 3179, 435, 413, 4258, 267, 5297, 6937, 6709, 14, 272, 408, 272, 5501, 302, 63, 3179, 275, 1323, 14, 1392, 272, 7659, 275, 980, 14, 1667, 63, 2930, 8, 87, 9, 339, 336, 12, 286, 12, 612, 90, 275, 485, 10863, 63, 3287, 8, 87, 12, 1323, 12, 612, 9, 339, 340, 2690, 63, 3463, 365, 488, 26, 267, 2690, 63, 3463, 275, 980, 14, 4548, 8, 89, 14, 1392, 59, 16, 566, 339, 327, 5297, 6937, 5621, 365, 314, 6946, 402, 314, 943, 402, 314, 30360, 805, 14, 272, 734, 275, 446, 1590, 14, 1838, 8, 3271, 63, 3463, 627, 943, 63, 23452, 8, 19873, 430, 435, 1275, 21, 627, 5131, 627, 980, 14, 3287, 8, 87, 12, 336, 9, 339, 1315, 275, 1437, 390, 8, 19873, 9, 272, 1315, 16, 275, 2690, 63, 3463, 627, 334, 90, 446, 413, 9, 627, 612, 339, 7659, 1491, 78, 63, 3179, 61, 275, 5048, 63, 4421, 63, 3287, 8, 56, 14, 52, 12, 1315, 16, 9, 435, 5131, 627, 336, 339, 327, 12425, 2382, 781, 5542, 314, 13926, 14, 272, 340, 7659, 14, 1392, 59, 16, 61, 690, 302, 63, 3179, 26, 267, 7659, 1988, 17, 61, 275, 1315, 16, 14, 1838, 342, 272, 372, 734, 12, 7659, 421, 199, 318, 485, 23452, 63, 4358, 8, 87, 12, 1323, 12, 612, 12, 5131, 12, 2690, 63, 3463, 29, 403, 304, 272, 408, 22594, 314, 30360, 5621, 14, 339, 3897, 272, 4143, 272, 336, 520, 6800, 12, 2215, 334, 78, 63, 3179, 4258, 503, 334, 78, 63, 3179, 435, 413, 4258, 267, 1849, 21069, 5477, 14, 339, 1323, 520, 469, 1144, 13, 2930, 12, 5178, 3634, 1386, 2215, 334, 78, 63, 3356, 12, 302, 63, 3179, 9, 267, 22859, 666, 14, 339, 612, 520, 6800, 12, 2215, 334, 78, 63, 3356, 4258, 267, 8725, 402, 3628, 14, 339, 5131, 520, 2069, 267, 18528 ]
[ 199, 2445, 6937, 13262, 199, 624, 199, 199, 3, 6529, 26, 9647, 352, 21084, 79, 392, 10962, 665, 5294, 352, 14, 1391, 79, 392, 10962, 32, 6505, 17667, 1961, 14, 1308, 30, 199, 3, 260, 481, 371, 5653, 510, 379, 1135, 29295, 665, 70, 32, 9662, 80, 14, 846, 30, 199, 3, 260, 22986, 28547, 27211, 10279, 665, 24421, 28547, 14, 1679, 10279, 32, 15253, 957, 13, 462, 374, 15970, 14, 4391, 30, 199, 3, 260, 4688, 79, 74, 1804, 453, 285, 665, 1237, 79, 17421, 453, 285, 338, 1391, 9091, 8425, 32, 6799, 14, 957, 30, 199, 3, 260, 491, 4291, 4779, 390, 262, 346, 199, 3, 260, 10751, 265, 644, 85, 665, 83, 24, 87, 85, 32, 85, 17217, 320, 79, 14, 696, 30, 199, 199, 646, 5579, 199, 646, 3598, 199, 199, 646, 2680, 465, 980, 199, 504, 7026, 492, 13497, 12, 5178, 199, 199, 504, 1275, 1095, 492, 12489, 8508, 4256, 12, 14531, 967, 2829, 4256, 12, 3523, 13183, 199, 504, 2508, 4445, 63, 5592, 14, 504, 63, 1238, 492, 485, 44, 2210, 343, 11212, 4256, 199, 504, 2508, 21402, 492, 10354, 6679, 12, 10354, 13394, 31008, 199, 504, 2508, 16820, 14, 1095, 492, 485, 3269, 63, 773, 6676, 199, 504, 2508, 1208, 492, 1104, 63, 1144, 12, 1104, 63, 15478, 63, 1267, 12, 4526, 63, 533, 63, 3463, 199, 504, 2508, 1208, 492, 1104, 63, 2355, 63, 929, 199, 504, 2508, 1208, 14, 832, 3442, 492, 334, 7270, 940, 9290, 12, 943, 63, 23452, 12, 5048, 63, 4421, 63, 3287, 12, 2490, 20478, 63, 4791, 9, 199, 504, 2508, 1208, 14, 13416, 492, 892, 1860, 63, 12595, 199, 504, 2508, 1208, 14, 6136, 492, 334, 305, 63, 1609, 63, 1144, 12, 3918, 20403, 3849, 12, 1816, 1104, 63, 56, 63, 89, 9, 199, 504, 2508, 1208, 14, 26205, 492, 1437, 390, 199, 504, 2508, 24688, 14, 2423, 773, 492, 27311, 12, 24725, 199, 504, 2508, 7925, 63, 6136, 492, 1104, 63, 5107, 199, 504, 2508, 24688, 492, 3816, 199, 504, 2508, 6759, 492, 12075, 726, 3960, 421, 199, 3, 2508, 2005, 5922, 3423, 367, 30360, 63, 12513, 63, 515, 2508, 199, 318, 485, 10863, 63, 3287, 8, 87, 12, 1323, 12, 612, 304, 272, 408, 22594, 612, 627, 980, 14, 3287, 8, 56, 12, 336, 680, 339, 2779, 6181, 1901, 8219, 1754, 340, 314, 13926, 1077, 506, 5542, 503, 440, 14, 339, 3897, 272, 4143, 272, 336, 520, 6800, 12, 2215, 334, 78, 63, 3179, 4258, 503, 334, 78, 63, 3179, 435, 413, 4258, 267, 1849, 21069, 5477, 14, 339, 1323, 520, 469, 1144, 13, 2930, 12, 5178, 3634, 1386, 2215, 334, 78, 63, 3356, 12, 302, 63, 3179, 9, 267, 22859, 666, 14, 339, 612, 520, 6800, 12, 2215, 334, 78, 63, 3356, 4258, 267, 8725, 402, 3628, 14, 272, 408, 272, 286, 275, 378, 14, 272, 340, 336, 14, 890, 508, 1323, 14, 1392, 59, 17, 61, 435, 413, 26, 267, 286, 275, 336, 1988, 17, 61, 267, 336, 275, 336, 4439, 17, 61, 339, 1315, 275, 5048, 63, 4421, 63, 3287, 8, 56, 12, 336, 9, 435, 286, 272, 372, 336, 12, 286, 12, 612, 627, 1315, 421, 199, 318, 485, 23452, 63, 4358, 63, 460, 63, 6017, 8, 87, 12, 1323, 12, 612, 12, 5131, 12, 2690, 63, 3463, 29, 403, 304, 272, 408, 22594, 314, 30360, 5621, 436, 6709, 14, 339, 3897, 272, 4143, 272, 336, 520, 6800, 12, 2215, 334, 78, 63, 3179, 4258, 503, 334, 78, 63, 3179, 435, 413, 4258, 267, 1849, 21069, 5477, 14, 339, 1323, 520, 469, 1144, 13, 2930, 12, 5178, 3634, 1386, 2215, 334, 78, 63, 3356, 12, 302, 63, 3179, 9, 267, 22859, 666, 14, 339, 612, 520, 6800, 12, 2215, 334, 78, 63, 3356, 4258, 267, 8725, 402, 3628, 14, 339, 5131, 520, 2069, 267, 18528, 2072, 2725, 14, 5131, 365, 4472, 370, 413, 1182, 445, 14, 339, 2690, 63, 3463, 520, 6800, 12, 2215, 334, 78, 63, 3356, 4258, 2716, 267, 8725, 402, 4931, 626, 787, 7943, 370, 8212, 5845, 14, 267, 982, 440, 2741, 12, 2066, 1924, 2690, 365, 1627, 4137, 5401, 14, 339, 1803, 272, 5514, 272, 734, 520, 2069, 267, 5297, 6937, 5621, 14, 339, 7659, 520, 6800, 12, 2215, 334, 78, 63, 3179, 4258, 503, 334, 78, 63, 3179, 435, 413, 4258, 267, 5297, 6937, 6709, 14, 272, 408, 272, 5501, 302, 63, 3179, 275, 1323, 14, 1392, 272, 7659, 275, 980, 14, 1667, 63, 2930, 8, 87, 9, 339, 336, 12, 286, 12, 612, 90, 275, 485, 10863, 63, 3287, 8, 87, 12, 1323, 12, 612, 9, 339, 340, 2690, 63, 3463, 365, 488, 26, 267, 2690, 63, 3463, 275, 980, 14, 4548, 8, 89, 14, 1392, 59, 16, 566, 339, 327, 5297, 6937, 5621, 365, 314, 6946, 402, 314, 943, 402, 314, 30360, 805, 14, 272, 734, 275, 446, 1590, 14, 1838, 8, 3271, 63, 3463, 627, 943, 63, 23452, 8, 19873, 430, 435, 1275, 21, 627, 5131, 627, 980, 14, 3287, 8, 87, 12, 336, 9, 339, 1315, 275, 1437, 390, 8, 19873, 9, 272, 1315, 16, 275, 2690, 63, 3463, 627, 334, 90, 446, 413, 9, 627, 612, 339, 7659, 1491, 78, 63, 3179, 61, 275, 5048, 63, 4421, 63, 3287, 8, 56, 14, 52, 12, 1315, 16, 9, 435, 5131, 627, 336, 339, 327, 12425, 2382, 781, 5542, 314, 13926, 14, 272, 340, 7659, 14, 1392, 59, 16, 61, 690, 302, 63, 3179, 26, 267, 7659, 1988, 17, 61, 275, 1315, 16, 14, 1838, 342, 272, 372, 734, 12, 7659, 421, 199, 318, 485, 23452, 63, 4358, 8, 87, 12, 1323, 12, 612, 12, 5131, 12, 2690, 63, 3463, 29, 403, 304, 272, 408, 22594, 314, 30360, 5621, 14, 339, 3897, 272, 4143, 272, 336, 520, 6800, 12, 2215, 334, 78, 63, 3179, 4258, 503, 334, 78, 63, 3179, 435, 413, 4258, 267, 1849, 21069, 5477, 14, 339, 1323, 520, 469, 1144, 13, 2930, 12, 5178, 3634, 1386, 2215, 334, 78, 63, 3356, 12, 302, 63, 3179, 9, 267, 22859, 666, 14, 339, 612, 520, 6800, 12, 2215, 334, 78, 63, 3356, 4258, 267, 8725, 402, 3628, 14, 339, 5131, 520, 2069, 267, 18528, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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py
2
4411
#! /usr/bin/python """ test_zbsmartplug.py By James Saunders, 2017 Tests PyAlertMe Module. """ import sys sys.path.insert(0, '../') from pyalertme import * import unittest from mock_serial import Serial class TestZBSmartPlug(unittest.TestCase): """ Test PyAlertMe ZBSmartPlug Class. """ def setUp(self): """ Create a node object for each test. """ self.ser = Serial() self.device_obj = ZBSmartPlug(self.ser) self.device_obj.addr_long = b'\x00\x1e\x5e\x09\x02\x14\xc5\xab' def tearDown(self): """ Teardown node object. """ self.device_obj.halt() def test_generate_version_info_update(self): """ Test Generate Version Information Update. """ result = self.device_obj.message_version_info_update() expected = { 'src_endpoint': b'\x02', 'dest_endpoint': b'\x02', 'cluster': b'\x00\xf6', 'profile': b'\xc2\x16', 'data': b'\tq\xfeHA\xd2\x1b\x19\x00\x00o\r\x009\x10\x07\x00\x01\x1c-{\x09PyAlertMe\x0bZBSmartPlug\n2017-01-01' } self.assertEqual(result, expected) def test_state_change(self): """ Test State Change. """ message_on = { 'cluster': b'\x00\xee', 'dest_endpoint': b'\x02', 'id': 'rx_explicit', 'options': b'\x01', 'profile': b'\xc2\x16', 'rf_data': b'\x11\x00\x02\x01\x01', 'source_addr': b'\x88\x9f', 'source_addr_long': b'\x00\ro\x00\x03\xbb\xb9\xf8', 'src_endpoint': b'\x02' } self.device_obj.receive_message(message_on) self.assertEqual(self.device_obj.switch_state, True) message_off = { 'cluster': b'\x00\xee', 'dest_endpoint': b'\x02', 'id': 'rx_explicit', 'options': b'\x01', 'profile': b'\xc2\x16', 'rf_data': b'\x11\x00\x02\x00\x01', 'source_addr': b'\x88\x9f', 'source_addr_long': b'\x00\ro\x00\x03\xbb\xb9\xf8', 'src_endpoint': b'\x02' } self.device_obj.receive_message(message_off) self.assertEqual(self.device_obj.switch_state, False) def test_message_switch_state_update(self): """ Test State Change Message Generate. """ self.device_obj.switch_state = 1 result = self.device_obj.message_switch_state_update() expected = { 'profile': b'\xc2\x16', 'src_endpoint': b'\x02', 'cluster': b'\x00\xee', 'data': b'\th\x80\x07\x01', 'dest_endpoint': b'\x02' } self.assertEqual(result, expected) self.device_obj.switch_state = 0 result = self.device_obj.message_switch_state_update() expected = { 'profile': b'\xc2\x16', 'src_endpoint': b'\x02', 'cluster': b'\x00\xee', 'data': b'\th\x80\x06\x00', 'dest_endpoint': b'\x02' } self.assertEqual(result, expected) def test_message_power_demand_update(self): """ Test Power Domand Update Message Generate. """ self.device_obj.power_demand = 0 result = self.device_obj.message_power_demand_update() expected = { 'profile': b'\xc2\x16', 'cluster': b'\x00\xef', 'src_endpoint': b'\x02', 'dest_endpoint': b'\x02', 'data': b'\tj\x81\x00\x00' } self.assertEqual(result, expected) self.device_obj.power_demand = 37 result = self.device_obj.message_power_demand_update() expected = { 'profile': b'\xc2\x16', 'cluster': b'\x00\xef', 'src_endpoint': b'\x02', 'dest_endpoint': b'\x02', 'data': b'\tj\x81%\x00' } self.assertEqual(result, expected) self.device_obj.power_demand = 22.4 result = self.device_obj.message_power_demand_update() expected = { 'profile': b'\xc2\x16', 'cluster': b'\x00\xef', 'src_endpoint': b'\x02', 'dest_endpoint': b'\x02', 'data': b'\tj\x81\x16\x00' } self.assertEqual(result, expected) if __name__ == '__main__': unittest.main(verbosity=2)
mit
[ 3168, 1182, 2647, 15, 1393, 15, 1548, 199, 624, 199, 396, 63, 90, 1533, 77, 580, 13963, 14, 647, 199, 199, 2175, 1603, 14015, 428, 65, 7138, 83, 12, 9708, 199, 199, 2925, 1611, 18758, 1352, 5673, 14, 199, 624, 199, 646, 984, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 20644, 358, 199, 504, 1134, 9241, 278, 492, 627, 199, 646, 2882, 199, 504, 1683, 63, 2171, 492, 11973, 421, 199, 533, 1379, 58, 11087, 77, 580, 19173, 8, 2796, 14, 1746, 304, 272, 408, 272, 1379, 1611, 18758, 1352, 3107, 11087, 77, 580, 19173, 8089, 14, 272, 408, 272, 347, 3613, 8, 277, 304, 267, 408, 267, 2790, 282, 1031, 909, 367, 1924, 511, 14, 267, 408, 267, 291, 14, 332, 275, 11973, 342, 267, 291, 14, 1782, 63, 1113, 275, 3107, 11087, 77, 580, 19173, 8, 277, 14, 332, 9, 267, 291, 14, 1782, 63, 1113, 14, 2697, 63, 2809, 275, 330, 1154, 88, 383, 60, 88, 17, 69, 60, 88, 21, 69, 60, 88, 1643, 60, 88, 996, 60, 88, 1079, 60, 1812, 21, 60, 10097, 7, 339, 347, 6766, 8, 277, 304, 267, 408, 267, 5773, 10549, 1031, 909, 14, 267, 408, 267, 291, 14, 1782, 63, 1113, 14, 72, 4478, 342, 339, 347, 511, 63, 4208, 63, 1023, 63, 815, 63, 873, 8, 277, 304, 267, 408, 267, 1379, 7958, 3394, 17064, 6162, 14, 267, 408, 267, 754, 275, 291, 14, 1782, 63, 1113, 14, 1188, 63, 1023, 63, 815, 63, 873, 342, 267, 1420, 275, 469, 288, 283, 2164, 63, 6520, 356, 330, 1154, 88, 996, 297, 288, 283, 2614, 63, 6520, 356, 330, 1154, 88, 996, 297, 288, 283, 4201, 356, 330, 1154, 88, 383, 60, 1949, 22, 297, 288, 283, 2913, 356, 330, 1154, 1812, 18, 60, 88, 975, 297, 288, 283, 576, 356, 330, 1154, 84, 81, 60, 8371, 6294, 60, 2207, 18, 60, 88, 17, 66, 60, 88, 1167, 60, 88, 383, 60, 88, 383, 79, 60, 82, 60, 88, 8581, 60, 88, 709, 60, 88, 1780, 60, 88, 383, 60, 88, 614, 60, 88, 17, 67, 13, 12911, 88, 1643, 2713, 18758, 1352, 60, 88, 16, 66, 58, 11087, 77, 580, 19173, 60, 78, 10680, 13, 614, 13, 614, 7, 267, 789, 267, 291, 14, 629, 8, 1099, 12, 1420, 9, 339, 347, 511, 63, 929, 63, 1461, 8, 277, 304, 267, 408, 267, 1379, 8511, 7743, 14, 267, 408, 267, 1245, 63, 265, 275, 469, 288, 283, 4201, 356, 330, 1154, 88, 383, 60, 11127, 297, 288, 283, 2614, 63, 6520, 356, 330, 1154, 88, 996, 297, 288, 283, 344, 356, 283, 6872, 63, 10306, 297, 288, 283, 1419, 356, 330, 1154, 88, 614, 297, 288, 283, 2913, 356, 330, 1154, 1812, 18, 60, 88, 975, 297, 288, 283, 3941, 63, 576, 356, 330, 1154, 88, 845, 60, 88, 383, 60, 88, 996, 60, 88, 614, 60, 88, 614, 297, 288, 283, 1365, 63, 2697, 356, 330, 1154, 88, 1299, 60, 88, 25, 70, 297, 288, 283, 1365, 63, 2697, 63, 2809, 356, 330, 1154, 88, 383, 60, 293, 60, 88, 383, 60, 88, 1644, 60, 9932, 60, 1774, 25, 60, 1949, 24, 297, 288, 283, 2164, 63, 6520, 356, 330, 1154, 88, 996, 7, 267, 789, 267, 291, 14, 1782, 63, 1113, 14, 9391, 63, 1188, 8, 1188, 63, 265, 9, 267, 291, 14, 629, 8, 277, 14, 1782, 63, 1113, 14, 5656, 63, 929, 12, 715, 9, 398, 1245, 63, 1997, 275, 469, 288, 283, 4201, 356, 330, 1154, 88, 383, 60, 11127, 297, 288, 283, 2614, 63, 6520, 356, 330, 1154, 88, 996, 297, 288, 283, 344, 356, 283, 6872, 63, 10306, 297, 288, 283, 1419, 356, 330, 1154, 88, 614, 297, 288, 283, 2913, 356, 330, 1154, 1812, 18, 60, 88, 975, 297, 288, 283, 3941, 63, 576, 356, 330, 1154, 88, 845, 60, 88, 383, 60, 88, 996, 60, 88, 383, 60, 88, 614, 297, 288, 283, 1365, 63, 2697, 356, 330, 1154, 88, 1299, 60, 88, 25, 70, 297, 288, 283, 1365, 63, 2697, 63, 2809, 356, 330, 1154, 88, 383, 60, 293, 60, 88, 383, 60, 88, 1644, 60, 9932, 60, 1774, 25, 60, 1949, 24, 297, 288, 283, 2164, 63, 6520, 356, 330, 1154, 88, 996, 7, 267, 789, 267, 291, 14, 1782, 63, 1113, 14, 9391, 63, 1188, 8, 1188, 63, 1997, 9, 267, 291, 14, 629, 8, 277, 14, 1782, 63, 1113, 14, 5656, 63, 929, 12, 756, 9, 339, 347, 511, 63, 1188, 63, 5656, 63, 929, 63, 873, 8, 277, 304, 267, 408, 267, 1379, 8511, 7743, 6430, 7958, 14, 267, 408, 267, 291, 14, 1782, 63, 1113, 14, 5656, 63, 929, 275, 413, 267, 754, 275, 291, 14, 1782, 63, 1113, 14, 1188, 63, 5656, 63, 929, 63, 873, 342, 267, 1420, 275, 469, 288, 283, 2913, 356, 330, 1154, 1812, 18, 60, 88, 975, 297, 288, 283, 2164, 63, 6520, 356, 330, 1154, 88, 996, 297, 288, 283, 4201, 356, 330, 1154, 88, 383, 60, 11127, 297, 288, 283, 576, 356, 330, 1154, 273, 60, 88, 1257, 60, 88, 1780, 60, 88, 614, 297, 288, 283, 2614, 63, 6520, 356, 330, 1154, 88, 996, 7, 267, 789, 267, 291, 14, 629, 8, 1099, 12, 1420, 9, 267, 291, 14, 1782, 63, 1113, 14, 5656, 63, 929, 275, 378, 267, 754, 275, 291, 14, 1782, 63, 1113, 14, 1188, 63, 5656, 63, 929, 63, 873, 342, 267, 1420, 275, 469, 288, 283, 2913, 356, 330, 1154, 1812, 18, 60, 88, 975, 297, 288, 283, 2164, 63, 6520, 356, 330, 1154, 88, 996, 297, 288, 283, 4201, 356, 330, 1154, 88, 383, 60, 11127, 297, 288, 283, 576, 356, 330, 1154, 273, 60, 88, 1257, 60, 88, 1690, 60, 88, 383, 297, 288, 283, 2614, 63, 6520, 356, 330, 1154, 88, 996, 7, 267, 789, 267, 291, 14, 629, 8, 1099, 12, 1420, 9, 339, 347, 511, 63, 1188, 63, 5652, 63, 24152, 63, 873, 8, 277, 304, 267, 408, 267, 1379, 18879, 577, 676, 460, 6162, 6430, 7958, 14, 267, 408, 267, 291, 14, 1782, 63, 1113, 14, 5652, 63, 24152, 275, 378, 267, 754, 275, 291 ]
[ 1182, 2647, 15, 1393, 15, 1548, 199, 624, 199, 396, 63, 90, 1533, 77, 580, 13963, 14, 647, 199, 199, 2175, 1603, 14015, 428, 65, 7138, 83, 12, 9708, 199, 199, 2925, 1611, 18758, 1352, 5673, 14, 199, 624, 199, 646, 984, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 20644, 358, 199, 504, 1134, 9241, 278, 492, 627, 199, 646, 2882, 199, 504, 1683, 63, 2171, 492, 11973, 421, 199, 533, 1379, 58, 11087, 77, 580, 19173, 8, 2796, 14, 1746, 304, 272, 408, 272, 1379, 1611, 18758, 1352, 3107, 11087, 77, 580, 19173, 8089, 14, 272, 408, 272, 347, 3613, 8, 277, 304, 267, 408, 267, 2790, 282, 1031, 909, 367, 1924, 511, 14, 267, 408, 267, 291, 14, 332, 275, 11973, 342, 267, 291, 14, 1782, 63, 1113, 275, 3107, 11087, 77, 580, 19173, 8, 277, 14, 332, 9, 267, 291, 14, 1782, 63, 1113, 14, 2697, 63, 2809, 275, 330, 1154, 88, 383, 60, 88, 17, 69, 60, 88, 21, 69, 60, 88, 1643, 60, 88, 996, 60, 88, 1079, 60, 1812, 21, 60, 10097, 7, 339, 347, 6766, 8, 277, 304, 267, 408, 267, 5773, 10549, 1031, 909, 14, 267, 408, 267, 291, 14, 1782, 63, 1113, 14, 72, 4478, 342, 339, 347, 511, 63, 4208, 63, 1023, 63, 815, 63, 873, 8, 277, 304, 267, 408, 267, 1379, 7958, 3394, 17064, 6162, 14, 267, 408, 267, 754, 275, 291, 14, 1782, 63, 1113, 14, 1188, 63, 1023, 63, 815, 63, 873, 342, 267, 1420, 275, 469, 288, 283, 2164, 63, 6520, 356, 330, 1154, 88, 996, 297, 288, 283, 2614, 63, 6520, 356, 330, 1154, 88, 996, 297, 288, 283, 4201, 356, 330, 1154, 88, 383, 60, 1949, 22, 297, 288, 283, 2913, 356, 330, 1154, 1812, 18, 60, 88, 975, 297, 288, 283, 576, 356, 330, 1154, 84, 81, 60, 8371, 6294, 60, 2207, 18, 60, 88, 17, 66, 60, 88, 1167, 60, 88, 383, 60, 88, 383, 79, 60, 82, 60, 88, 8581, 60, 88, 709, 60, 88, 1780, 60, 88, 383, 60, 88, 614, 60, 88, 17, 67, 13, 12911, 88, 1643, 2713, 18758, 1352, 60, 88, 16, 66, 58, 11087, 77, 580, 19173, 60, 78, 10680, 13, 614, 13, 614, 7, 267, 789, 267, 291, 14, 629, 8, 1099, 12, 1420, 9, 339, 347, 511, 63, 929, 63, 1461, 8, 277, 304, 267, 408, 267, 1379, 8511, 7743, 14, 267, 408, 267, 1245, 63, 265, 275, 469, 288, 283, 4201, 356, 330, 1154, 88, 383, 60, 11127, 297, 288, 283, 2614, 63, 6520, 356, 330, 1154, 88, 996, 297, 288, 283, 344, 356, 283, 6872, 63, 10306, 297, 288, 283, 1419, 356, 330, 1154, 88, 614, 297, 288, 283, 2913, 356, 330, 1154, 1812, 18, 60, 88, 975, 297, 288, 283, 3941, 63, 576, 356, 330, 1154, 88, 845, 60, 88, 383, 60, 88, 996, 60, 88, 614, 60, 88, 614, 297, 288, 283, 1365, 63, 2697, 356, 330, 1154, 88, 1299, 60, 88, 25, 70, 297, 288, 283, 1365, 63, 2697, 63, 2809, 356, 330, 1154, 88, 383, 60, 293, 60, 88, 383, 60, 88, 1644, 60, 9932, 60, 1774, 25, 60, 1949, 24, 297, 288, 283, 2164, 63, 6520, 356, 330, 1154, 88, 996, 7, 267, 789, 267, 291, 14, 1782, 63, 1113, 14, 9391, 63, 1188, 8, 1188, 63, 265, 9, 267, 291, 14, 629, 8, 277, 14, 1782, 63, 1113, 14, 5656, 63, 929, 12, 715, 9, 398, 1245, 63, 1997, 275, 469, 288, 283, 4201, 356, 330, 1154, 88, 383, 60, 11127, 297, 288, 283, 2614, 63, 6520, 356, 330, 1154, 88, 996, 297, 288, 283, 344, 356, 283, 6872, 63, 10306, 297, 288, 283, 1419, 356, 330, 1154, 88, 614, 297, 288, 283, 2913, 356, 330, 1154, 1812, 18, 60, 88, 975, 297, 288, 283, 3941, 63, 576, 356, 330, 1154, 88, 845, 60, 88, 383, 60, 88, 996, 60, 88, 383, 60, 88, 614, 297, 288, 283, 1365, 63, 2697, 356, 330, 1154, 88, 1299, 60, 88, 25, 70, 297, 288, 283, 1365, 63, 2697, 63, 2809, 356, 330, 1154, 88, 383, 60, 293, 60, 88, 383, 60, 88, 1644, 60, 9932, 60, 1774, 25, 60, 1949, 24, 297, 288, 283, 2164, 63, 6520, 356, 330, 1154, 88, 996, 7, 267, 789, 267, 291, 14, 1782, 63, 1113, 14, 9391, 63, 1188, 8, 1188, 63, 1997, 9, 267, 291, 14, 629, 8, 277, 14, 1782, 63, 1113, 14, 5656, 63, 929, 12, 756, 9, 339, 347, 511, 63, 1188, 63, 5656, 63, 929, 63, 873, 8, 277, 304, 267, 408, 267, 1379, 8511, 7743, 6430, 7958, 14, 267, 408, 267, 291, 14, 1782, 63, 1113, 14, 5656, 63, 929, 275, 413, 267, 754, 275, 291, 14, 1782, 63, 1113, 14, 1188, 63, 5656, 63, 929, 63, 873, 342, 267, 1420, 275, 469, 288, 283, 2913, 356, 330, 1154, 1812, 18, 60, 88, 975, 297, 288, 283, 2164, 63, 6520, 356, 330, 1154, 88, 996, 297, 288, 283, 4201, 356, 330, 1154, 88, 383, 60, 11127, 297, 288, 283, 576, 356, 330, 1154, 273, 60, 88, 1257, 60, 88, 1780, 60, 88, 614, 297, 288, 283, 2614, 63, 6520, 356, 330, 1154, 88, 996, 7, 267, 789, 267, 291, 14, 629, 8, 1099, 12, 1420, 9, 267, 291, 14, 1782, 63, 1113, 14, 5656, 63, 929, 275, 378, 267, 754, 275, 291, 14, 1782, 63, 1113, 14, 1188, 63, 5656, 63, 929, 63, 873, 342, 267, 1420, 275, 469, 288, 283, 2913, 356, 330, 1154, 1812, 18, 60, 88, 975, 297, 288, 283, 2164, 63, 6520, 356, 330, 1154, 88, 996, 297, 288, 283, 4201, 356, 330, 1154, 88, 383, 60, 11127, 297, 288, 283, 576, 356, 330, 1154, 273, 60, 88, 1257, 60, 88, 1690, 60, 88, 383, 297, 288, 283, 2614, 63, 6520, 356, 330, 1154, 88, 996, 7, 267, 789, 267, 291, 14, 629, 8, 1099, 12, 1420, 9, 339, 347, 511, 63, 1188, 63, 5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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 ]
frnhr/django-cms
cms/south_migrations/0035_auto__add_field_globalpagepermission_can_view__add_field_pagepermissio.py
1680
20032
# -*- coding: utf-8 -*- import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models try: from django.contrib.auth import get_user_model except ImportError: # django < 1.5 from django.contrib.auth.models import User else: User = get_user_model() user_orm_label = '%s.%s' % (User._meta.app_label, User._meta.object_name) user_model_label = '%s.%s' % (User._meta.app_label, User._meta.model_name) user_ptr_name = '%s_ptr' % User._meta.object_name.lower() class Migration(SchemaMigration): def forwards(self, orm): # Dummy migration pass def backwards(self, orm): # Dummy migration pass models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, 'id': ( 'django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, 'auth.permission': { 'Meta': { 'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, 'codename': ( 'django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), 'id': ( 'django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, user_model_label: { 'Meta': {'object_name': User.__name__, 'db_table': "'%s'" % User._meta.db_table}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), 'id': ( 'django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ( 'django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ( 'django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ( 'django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ( 'django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ( 'django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, 'cms.cmsplugin': { 'Meta': {'object_name': 'CMSPlugin'}, 'changed_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'id': ( 'django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}), 'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}), 'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}), 'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}), 'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}), 'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}) }, 'cms.globalpagepermission': { 'Meta': {'object_name': 'GlobalPagePermission'}, 'can_add': ( 'django.db.models.fields.BooleanField', [], {'default': 'True'}), 'can_change': ( 'django.db.models.fields.BooleanField', [], {'default': 'True'}), 'can_change_advanced_settings': ( 'django.db.models.fields.BooleanField', [], {'default': 'False'}), 'can_change_permissions': ( 'django.db.models.fields.BooleanField', [], {'default': 'False'}), 'can_delete': ( 'django.db.models.fields.BooleanField', [], {'default': 'True'}), 'can_moderate': ( 'django.db.models.fields.BooleanField', [], {'default': 'True'}), 'can_move_page': ( 'django.db.models.fields.BooleanField', [], {'default': 'True'}), 'can_publish': ( 'django.db.models.fields.BooleanField', [], {'default': 'True'}), 'can_recover_page': ( 'django.db.models.fields.BooleanField', [], {'default': 'True'}), 'can_view': ( 'django.db.models.fields.BooleanField', [], {'default': 'False'}), 'group': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.Group']", 'null': 'True', 'blank': 'True'}), 'id': ( 'django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'sites': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['sites.Site']", 'null': 'True', 'blank': 'True'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['%s']" % user_orm_label, 'null': 'True', 'blank': 'True'}) }, 'cms.page': { 'Meta': {'ordering': "('site', 'tree_id', 'lft')", 'object_name': 'Page'}, 'changed_by': ( 'django.db.models.fields.CharField', [], {'max_length': '70'}), 'changed_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'created_by': ( 'django.db.models.fields.CharField', [], {'max_length': '70'}), 'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'id': ( 'django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'in_navigation': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}), 'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 'limit_visibility_in_menu': ( 'django.db.models.fields.SmallIntegerField', [], {'default': 'None', 'null': 'True', 'db_index': 'True', 'blank': 'True'}), 'login_required': ( 'django.db.models.fields.BooleanField', [], {'default': 'False'}), 'moderator_state': ('django.db.models.fields.SmallIntegerField', [], {'default': '1', 'blank': 'True'}), 'navigation_extenders': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '80', 'null': 'True', 'blank': 'True'}), 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['cms.Page']"}), 'placeholders': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['cms.Placeholder']", 'symmetrical': 'False'}), 'publication_date': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), 'publication_end_date': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), 'published': ( 'django.db.models.fields.BooleanField', [], {'default': 'False'}), 'publisher_is_draft': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}), 'publisher_public': ( 'django.db.models.fields.related.OneToOneField', [], {'related_name': "'publisher_draft'", 'unique': 'True', 'null': 'True', 'to': "orm['cms.Page']"}), 'publisher_state': ('django.db.models.fields.SmallIntegerField', [], {'default': '0', 'db_index': 'True'}), 'reverse_id': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '40', 'null': 'True', 'blank': 'True'}), 'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 'site': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['sites.Site']"}), 'soft_root': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}), 'template': ( 'django.db.models.fields.CharField', [], {'max_length': '100'}), 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}) }, 'cms.pagemoderator': { 'Meta': {'object_name': 'PageModerator'}, 'id': ( 'django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'moderate_children': ( 'django.db.models.fields.BooleanField', [], {'default': 'False'}), 'moderate_descendants': ( 'django.db.models.fields.BooleanField', [], {'default': 'False'}), 'moderate_page': ( 'django.db.models.fields.BooleanField', [], {'default': 'False'}), 'page': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Page']"}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['%s']" % user_orm_label}) }, 'cms.pagemoderatorstate': { 'Meta': {'ordering': "('page', 'action', '-created')", 'object_name': 'PageModeratorState'}, 'action': ('django.db.models.fields.CharField', [], {'max_length': '3', 'null': 'True', 'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'id': ( 'django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'message': ('django.db.models.fields.TextField', [], {'default': "''", 'max_length': '1000', 'blank': 'True'}), 'page': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Page']"}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['%s']" % user_orm_label, 'null': 'True'}) }, 'cms.pagepermission': { 'Meta': {'object_name': 'PagePermission'}, 'can_add': ( 'django.db.models.fields.BooleanField', [], {'default': 'True'}), 'can_change': ( 'django.db.models.fields.BooleanField', [], {'default': 'True'}), 'can_change_advanced_settings': ( 'django.db.models.fields.BooleanField', [], {'default': 'False'}), 'can_change_permissions': ( 'django.db.models.fields.BooleanField', [], {'default': 'False'}), 'can_delete': ( 'django.db.models.fields.BooleanField', [], {'default': 'True'}), 'can_moderate': ( 'django.db.models.fields.BooleanField', [], {'default': 'True'}), 'can_move_page': ( 'django.db.models.fields.BooleanField', [], {'default': 'True'}), 'can_publish': ( 'django.db.models.fields.BooleanField', [], {'default': 'True'}), 'can_view': ( 'django.db.models.fields.BooleanField', [], {'default': 'False'}), 'grant_on': ( 'django.db.models.fields.IntegerField', [], {'default': '5'}), 'group': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.Group']", 'null': 'True', 'blank': 'True'}), 'id': ( 'django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'page': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Page']", 'null': 'True', 'blank': 'True'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['%s']" % user_orm_label, 'null': 'True', 'blank': 'True'}) }, 'cms.pageuser': { 'Meta': {'object_name': 'PageUser', '_ormbases': [user_orm_label]}, 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'created_users'", 'to': "orm['%s']" % user_orm_label}), 'user_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['%s']" % user_orm_label, 'unique': 'True', 'primary_key': 'True'}) }, 'cms.pageusergroup': { 'Meta': {'object_name': 'PageUserGroup', '_ormbases': ['auth.Group']}, 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'created_usergroups'", 'to': "orm['%s']" % user_orm_label}), 'group_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.Group']", 'unique': 'True', 'primary_key': 'True'}) }, 'cms.placeholder': { 'Meta': {'object_name': 'Placeholder'}, 'default_width': ( 'django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}), 'id': ( 'django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}) }, 'cms.title': { 'Meta': {'unique_together': "(('language', 'page'),)", 'object_name': 'Title'}, 'application_urls': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '200', 'null': 'True', 'blank': 'True'}), 'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'has_url_overwrite': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}), 'id': ( 'django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}), 'menu_title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'meta_description': ('django.db.models.fields.TextField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'meta_keywords': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'page': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'title_set'", 'to': "orm['cms.Page']"}), 'page_title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'path': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'redirect': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'slug': ( 'django.db.models.fields.SlugField', [], {'max_length': '255'}), 'title': ( 'django.db.models.fields.CharField', [], {'max_length': '255'}) }, 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ( 'django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ( 'django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ( 'django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, 'sites.site': { 'Meta': {'ordering': "('domain',)", 'object_name': 'Site', 'db_table': "'django_site'"}, 'domain': ( 'django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ( 'django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) } } complete_apps = ['cms']
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 893, 26, 272, 687, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 63, 1238, 199, 2590, 3545, 26, 327, 1639, 665, 413, 14, 21, 272, 687, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 2836, 26, 272, 2876, 275, 664, 63, 751, 63, 1238, 342, 199, 199, 751, 63, 1025, 63, 1302, 275, 1543, 83, 4111, 83, 7, 450, 334, 1899, 423, 2024, 14, 571, 63, 1302, 12, 2876, 423, 2024, 14, 785, 63, 354, 9, 199, 751, 63, 1238, 63, 1302, 275, 1543, 83, 4111, 83, 7, 450, 334, 1899, 423, 2024, 14, 571, 63, 1302, 12, 2876, 423, 2024, 14, 1238, 63, 354, 9, 199, 751, 63, 4695, 63, 354, 275, 1543, 83, 63, 4695, 7, 450, 2876, 423, 2024, 14, 785, 63, 354, 14, 2325, 342, 199, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 9762, 8367, 267, 986, 16478, 347, 8552, 8, 277, 12, 9813, 304, 272, 327, 9762, 8367, 267, 986, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 334, 355, 283, 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, 2151, 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, 1169, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 2490, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 469, 355, 283, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 355, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 355, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 334, 355, 283, 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, 2490, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 334, 355, 283, 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, 922, 63, 1238, 63, 1302, 26, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 2876, 855, 354, 3108, 283, 697, 63, 1224, 356, 17648, 83, 4065, 450, 2876, 423, 2024, 14, 697, 63, 1224, 1386, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 1169, 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, 1993, 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, 2574, 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, 2432, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 717, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 334, 355, 283, 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, 334, 355, 283, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 334, 355, 283, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 334, 355, 283, 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, 2574, 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, 2079, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 334, 355, 283, 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, 334, 355, 283, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 355, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 326, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 586, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 283, 10781, 14, 4400, 30873, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 17834, 5061, 2267, 288, 283, 2489, 63, 602, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 2490, 791, 2495, 63, 2131, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 8782, 63, 602, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 2892, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 344, 356 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 893, 26, 272, 687, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 63, 1238, 199, 2590, 3545, 26, 327, 1639, 665, 413, 14, 21, 272, 687, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 2836, 26, 272, 2876, 275, 664, 63, 751, 63, 1238, 342, 199, 199, 751, 63, 1025, 63, 1302, 275, 1543, 83, 4111, 83, 7, 450, 334, 1899, 423, 2024, 14, 571, 63, 1302, 12, 2876, 423, 2024, 14, 785, 63, 354, 9, 199, 751, 63, 1238, 63, 1302, 275, 1543, 83, 4111, 83, 7, 450, 334, 1899, 423, 2024, 14, 571, 63, 1302, 12, 2876, 423, 2024, 14, 1238, 63, 354, 9, 199, 751, 63, 4695, 63, 354, 275, 1543, 83, 63, 4695, 7, 450, 2876, 423, 2024, 14, 785, 63, 354, 14, 2325, 342, 199, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 9762, 8367, 267, 986, 16478, 347, 8552, 8, 277, 12, 9813, 304, 272, 327, 9762, 8367, 267, 986, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 334, 355, 283, 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, 2151, 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, 1169, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 2490, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 469, 355, 283, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 355, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 355, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 334, 355, 283, 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, 2490, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 334, 355, 283, 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, 922, 63, 1238, 63, 1302, 26, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 2876, 855, 354, 3108, 283, 697, 63, 1224, 356, 17648, 83, 4065, 450, 2876, 423, 2024, 14, 697, 63, 1224, 1386, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 1169, 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, 1993, 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, 2574, 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, 2432, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 717, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 334, 355, 283, 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, 334, 355, 283, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 334, 355, 283, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 334, 355, 283, 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, 2574, 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, 2079, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 334, 355, 283, 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, 334, 355, 283, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 355, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 326, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 586, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 283, 10781, 14, 4400, 30873, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 17834, 5061, 2267, 288, 283, 2489, 63, 602, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 2490, 791, 2495, 63, 2131, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 8782, 63, 602, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 2892, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 344, 356, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ashhher3/invenio
modules/websubmit/lib/functions/Get_Info.py
33
4960
## This file is part of Invenio. ## Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 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$" ## ## Name: Get_Info.py ## Description: function Get_Info ## This function retrieves some bibliographic data (title, ## submitter email, author and sets global variables with ## the values, so that other functions may use them. ## Author: T.Baron ## PARAMETERS: authorFile: name of the file in which the author is stored ## emailFile: name of the file in which the email is stored ## titleFile: name of the file in which the title is stored ## OUTPUT: HTML ## import os from invenio.websubmit_config import InvenioWebSubmitFunctionStop from invenio.websubmit_functions.Retrieve_Data import Get_Field titlevalue = "" emailvalue = "" authorvalue = "" def Get_Info(parameters, curdir, form, user_info=None): """ This function tries to retrieve in the 'pending' directory or directly in the documents database, some information about the document: title, original submitter's email and author(s). If found, this information is stored in 3 global variables: $emailvalue, $titlevalue, $authorvalue to be used in other functions. If not found, an error message is displayed. Parameters: * authorFile: Name of the file in which the author may be found if the document has not yet been integrated (in this case it is still in the 'pending' directory). * emailFile: Name of the file in which the email of the riginal submitter may be found if the document has not yet been integrated (in this case it is still in the 'pending' directory). * titleFile: Name of the file in which the title may be found if the document has not yet been integrated (in this case it is still in the 'pending' directory). """ global titlevalue,emailvalue,authorvalue,rn doctype = form['doctype'] titlefile = parameters["titleFile"] emailfile = parameters["emailFile"] authorfile = parameters["authorFile"] if not Get_Info_In_Curdir(rn,titlefile,emailfile,authorfile,doctype): if not Get_Info_In_DB(rn,parameters,curdir): DocumentNotFound(rn) return "" def Get_Info_In_Curdir(repno,titlefile,emailfile,authorfile,doctype): global titlevalue,emailvalue,authorvalue if not os.path.exists("%s/%s" % (curdir,titlefile)): return 0 else: if os.path.exists("%s/%s" % (curdir,titlefile)): fp = open("%s/%s" % (curdir,titlefile),"r") titlevalue = fp.read() fp.close() else : titlevalue = "-" if os.path.exists("%s/%s" % (curdir,emailfile)): fp = open("%s/%s" % (curdir,emailfile),"r") emailvalue = fp.read() fp.close() else : emailvalue = "-" if os.path.exists("%s/%s" % (curdir,authorfile)): fp = open("%s/%s" % (curdir,authorfile),"r") authorvalue = fp.read() fp.close() else : authorvalue = "-" return 1 def Get_Info_In_DB(rn,parameters,curdir): global titlevalue,emailvalue,authorvalue,sysno if sysno != "": titlevalue = Get_Field('245__a',sysno) emailvalue = Get_Field('8560_f',sysno) authorvalue = Get_Field('100__a',sysno) authorvalue += "\n%s" % Get_Field('700__a',sysno) # save result fp = open("%s/SN" % curdir,"w") fp.write(sysno) fp.close() return 1 else: return 0 def DocumentNotFound(repno): raise InvenioWebSubmitFunctionStop(""" <SCRIPT> document.forms[0].action="/submit"; document.forms[0].curpage.value = 1; document.forms[0].step.value = 0; user_must_confirm_before_leaving_page = false; alert('The document %s cannot be found in our database.\\nAnyway, you can still choose another document if you wish.'); document.forms[0].submit(); </SCRIPT>""" % repno) return 0
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, 8937, 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, 2043, 925, 2812, 26, 3515, 2372, 63, 2354, 14, 647, 2043, 925, 11994, 26, 257, 805, 2372, 63, 2354, 2043, 925, 4483, 961, 805, 9619, 2310, 2005, 11314, 24623, 666, 334, 1213, 12, 2043, 925, 4483, 11482, 351, 3031, 12, 4132, 436, 5951, 2288, 2860, 543, 2043, 925, 4483, 314, 1338, 12, 880, 626, 1163, 3423, 1443, 675, 3062, 14, 2043, 925, 6529, 26, 260, 377, 14, 5281, 265, 2043, 925, 23710, 26, 259, 4132, 1173, 26, 536, 402, 314, 570, 315, 1314, 314, 4132, 365, 5489, 2043, 925, 3777, 3031, 1173, 26, 536, 402, 314, 570, 315, 1314, 314, 3031, 365, 5489, 2043, 925, 3777, 2538, 1173, 26, 536, 402, 314, 570, 315, 1314, 314, 2538, 365, 5489, 2043, 925, 18746, 26, 4163, 2043, 925, 199, 199, 646, 747, 199, 199, 504, 13640, 14, 2520, 7275, 63, 888, 492, 12235, 5926, 17187, 3481, 6293, 199, 504, 13640, 14, 2520, 7275, 63, 5777, 14, 15310, 63, 1451, 492, 2372, 63, 792, 199, 199, 1213, 585, 275, 3087, 199, 2123, 585, 275, 3087, 199, 2502, 585, 275, 3087, 199, 199, 318, 2372, 63, 2354, 8, 3214, 12, 1094, 694, 12, 1824, 12, 922, 63, 815, 29, 403, 304, 272, 408, 272, 961, 805, 11275, 370, 8044, 315, 314, 283, 6455, 7, 2082, 503, 272, 5370, 315, 314, 8247, 3050, 12, 2005, 2556, 3595, 314, 272, 2213, 26, 2538, 12, 3379, 11482, 351, 1159, 3031, 436, 4132, 8, 83, 680, 221, 982, 1911, 12, 272, 642, 2556, 365, 5489, 315, 650, 2288, 2860, 26, 2672, 2123, 585, 12, 272, 2672, 1213, 585, 12, 2672, 2502, 585, 370, 506, 1202, 315, 1163, 3423, 14, 221, 982, 440, 272, 1911, 12, 376, 1125, 1245, 365, 9080, 14, 339, 3897, 26, 13359, 627, 4132, 1173, 26, 2812, 402, 314, 570, 315, 1314, 314, 4132, 1443, 506, 2432, 1911, 340, 314, 2213, 965, 440, 5966, 2757, 2432, 17806, 972, 334, 262, 642, 1930, 652, 365, 5139, 315, 314, 2432, 283, 6455, 7, 2082, 680, 13359, 627, 3031, 1173, 26, 2812, 402, 314, 570, 315, 1314, 314, 3031, 402, 314, 1993, 221, 9507, 11482, 351, 1443, 506, 1911, 340, 314, 2213, 1993, 965, 440, 5966, 2757, 17806, 972, 334, 262, 642, 1930, 652, 365, 1993, 5139, 315, 314, 283, 6455, 7, 2082, 680, 13359, 627, 2538, 1173, 26, 2812, 402, 314, 570, 315, 1314, 314, 2538, 1443, 506, 1911, 1993, 340, 314, 2213, 965, 440, 5966, 2757, 17806, 972, 334, 262, 1993, 642, 1930, 652, 365, 5139, 315, 314, 283, 6455, 7, 1993, 2082, 680, 272, 408, 272, 2288, 2538, 585, 12, 2123, 585, 12, 2502, 585, 12, 11641, 272, 13265, 275, 1824, 459, 6356, 418, 272, 2538, 493, 275, 2633, 905, 1213, 1173, 937, 272, 325, 391, 73, 12059, 275, 2633, 905, 2123, 1173, 937, 272, 4132, 493, 275, 2633, 905, 2502, 1173, 937, 272, 340, 440, 2372, 63, 2354, 63, 607, 63, 3864, 694, 8, 11641, 12, 1213, 493, 12, 69, 391, 73, 12059, 12, 2502, 493, 12, 6356, 304, 267, 340, 440, 2372, 63, 2354, 63, 607, 63, 2846, 8, 11641, 12, 3214, 12, 15594, 304, 288, 7543, 4667, 8, 11641, 9, 272, 372, 3087, 199, 199, 318, 2372, 63, 2354, 63, 607, 63, 3864, 694, 8, 1155, 889, 12, 1213, 493, 12, 69, 391, 73, 12059, 12, 2502, 493, 12, 6356, 304, 272, 2288, 2538, 585, 12, 2123, 585, 12, 2502, 585, 272, 340, 440, 747, 14, 515, 14, 2444, 3647, 83, 3149, 83, 2, 450, 334, 15594, 12, 1213, 493, 2298, 267, 372, 378, 272, 587, 26, 267, 340, 747, 14, 515, 14, 2444, 3647, 83, 3149, 83, 2, 450, 334, 15594, 12, 1213, 493, 2298, 288, 4090, 275, 1551, 3647, 83, 3149, 83, 2, 450, 334, 15594, 12, 1213, 493, 395, 2, 82, 531, 288, 2538, 585, 275, 4090, 14, 739, 342, 288, 4090, 14, 1600, 342, 267, 587, 520, 288, 2538, 585, 275, 17155, 267, 340, 747, 14, 515, 14, 2444, 3647, 83, 3149, 83, 2, 450, 334, 15594, 12, 69, 391, 73, 12059, 2298, 288, 4090, 275, 1551, 3647, 83, 3149, 83, 2, 450, 334, 15594, 12, 69, 391, 73, 12059, 395, 2, 82, 531, 288, 3031, 585, 275, 4090, 14, 739, 342, 288, 4090, 14, 1600, 342, 267, 587, 520, 288, 3031, 585, 275, 17155, 267, 340, 747, 14, 515, 14, 2444, 3647, 83, 3149, 83, 2, 450, 334, 15594, 12, 2502, 493, 2298, 288, 4090, 275, 1551, 3647, 83, 3149, 83, 2, 450, 334, 15594, 12, 2502, 493, 395, 2, 82, 531, 288, 4132, 585, 275, 4090, 14, 739, 342, 288, 4090, 14, 1600, 342, 267, 587, 520, 288, 4132, 585, 275, 17155, 272, 372, 413, 199, 199, 318, 2372, 63, 2354, 63, 607, 63, 2846, 8, 11641, 12, 3214, 12, 15594, 304, 272, 2288, 2538, 585, 12, 2123, 585, 12, 2502, 585, 12, 1274, 889, 272, 340, 984, 889, 1137, 10812, 267, 2538, 585, 275, 2372, 63, 792, 360, 11677, 363, 65, 297, 1274, 889, 9 ]
[ 961, 570, 365, 1777, 402, 12235, 14, 199, 309, 1898, 334, 35, 9, 8353, 12, 11811, 12, 8315, 12, 10219, 12, 9079, 12, 8937, 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, 2043, 925, 2812, 26, 3515, 2372, 63, 2354, 14, 647, 2043, 925, 11994, 26, 257, 805, 2372, 63, 2354, 2043, 925, 4483, 961, 805, 9619, 2310, 2005, 11314, 24623, 666, 334, 1213, 12, 2043, 925, 4483, 11482, 351, 3031, 12, 4132, 436, 5951, 2288, 2860, 543, 2043, 925, 4483, 314, 1338, 12, 880, 626, 1163, 3423, 1443, 675, 3062, 14, 2043, 925, 6529, 26, 260, 377, 14, 5281, 265, 2043, 925, 23710, 26, 259, 4132, 1173, 26, 536, 402, 314, 570, 315, 1314, 314, 4132, 365, 5489, 2043, 925, 3777, 3031, 1173, 26, 536, 402, 314, 570, 315, 1314, 314, 3031, 365, 5489, 2043, 925, 3777, 2538, 1173, 26, 536, 402, 314, 570, 315, 1314, 314, 2538, 365, 5489, 2043, 925, 18746, 26, 4163, 2043, 925, 199, 199, 646, 747, 199, 199, 504, 13640, 14, 2520, 7275, 63, 888, 492, 12235, 5926, 17187, 3481, 6293, 199, 504, 13640, 14, 2520, 7275, 63, 5777, 14, 15310, 63, 1451, 492, 2372, 63, 792, 199, 199, 1213, 585, 275, 3087, 199, 2123, 585, 275, 3087, 199, 2502, 585, 275, 3087, 199, 199, 318, 2372, 63, 2354, 8, 3214, 12, 1094, 694, 12, 1824, 12, 922, 63, 815, 29, 403, 304, 272, 408, 272, 961, 805, 11275, 370, 8044, 315, 314, 283, 6455, 7, 2082, 503, 272, 5370, 315, 314, 8247, 3050, 12, 2005, 2556, 3595, 314, 272, 2213, 26, 2538, 12, 3379, 11482, 351, 1159, 3031, 436, 4132, 8, 83, 680, 221, 982, 1911, 12, 272, 642, 2556, 365, 5489, 315, 650, 2288, 2860, 26, 2672, 2123, 585, 12, 272, 2672, 1213, 585, 12, 2672, 2502, 585, 370, 506, 1202, 315, 1163, 3423, 14, 221, 982, 440, 272, 1911, 12, 376, 1125, 1245, 365, 9080, 14, 339, 3897, 26, 13359, 627, 4132, 1173, 26, 2812, 402, 314, 570, 315, 1314, 314, 4132, 1443, 506, 2432, 1911, 340, 314, 2213, 965, 440, 5966, 2757, 2432, 17806, 972, 334, 262, 642, 1930, 652, 365, 5139, 315, 314, 2432, 283, 6455, 7, 2082, 680, 13359, 627, 3031, 1173, 26, 2812, 402, 314, 570, 315, 1314, 314, 3031, 402, 314, 1993, 221, 9507, 11482, 351, 1443, 506, 1911, 340, 314, 2213, 1993, 965, 440, 5966, 2757, 17806, 972, 334, 262, 642, 1930, 652, 365, 1993, 5139, 315, 314, 283, 6455, 7, 2082, 680, 13359, 627, 2538, 1173, 26, 2812, 402, 314, 570, 315, 1314, 314, 2538, 1443, 506, 1911, 1993, 340, 314, 2213, 965, 440, 5966, 2757, 17806, 972, 334, 262, 1993, 642, 1930, 652, 365, 5139, 315, 314, 283, 6455, 7, 1993, 2082, 680, 272, 408, 272, 2288, 2538, 585, 12, 2123, 585, 12, 2502, 585, 12, 11641, 272, 13265, 275, 1824, 459, 6356, 418, 272, 2538, 493, 275, 2633, 905, 1213, 1173, 937, 272, 325, 391, 73, 12059, 275, 2633, 905, 2123, 1173, 937, 272, 4132, 493, 275, 2633, 905, 2502, 1173, 937, 272, 340, 440, 2372, 63, 2354, 63, 607, 63, 3864, 694, 8, 11641, 12, 1213, 493, 12, 69, 391, 73, 12059, 12, 2502, 493, 12, 6356, 304, 267, 340, 440, 2372, 63, 2354, 63, 607, 63, 2846, 8, 11641, 12, 3214, 12, 15594, 304, 288, 7543, 4667, 8, 11641, 9, 272, 372, 3087, 199, 199, 318, 2372, 63, 2354, 63, 607, 63, 3864, 694, 8, 1155, 889, 12, 1213, 493, 12, 69, 391, 73, 12059, 12, 2502, 493, 12, 6356, 304, 272, 2288, 2538, 585, 12, 2123, 585, 12, 2502, 585, 272, 340, 440, 747, 14, 515, 14, 2444, 3647, 83, 3149, 83, 2, 450, 334, 15594, 12, 1213, 493, 2298, 267, 372, 378, 272, 587, 26, 267, 340, 747, 14, 515, 14, 2444, 3647, 83, 3149, 83, 2, 450, 334, 15594, 12, 1213, 493, 2298, 288, 4090, 275, 1551, 3647, 83, 3149, 83, 2, 450, 334, 15594, 12, 1213, 493, 395, 2, 82, 531, 288, 2538, 585, 275, 4090, 14, 739, 342, 288, 4090, 14, 1600, 342, 267, 587, 520, 288, 2538, 585, 275, 17155, 267, 340, 747, 14, 515, 14, 2444, 3647, 83, 3149, 83, 2, 450, 334, 15594, 12, 69, 391, 73, 12059, 2298, 288, 4090, 275, 1551, 3647, 83, 3149, 83, 2, 450, 334, 15594, 12, 69, 391, 73, 12059, 395, 2, 82, 531, 288, 3031, 585, 275, 4090, 14, 739, 342, 288, 4090, 14, 1600, 342, 267, 587, 520, 288, 3031, 585, 275, 17155, 267, 340, 747, 14, 515, 14, 2444, 3647, 83, 3149, 83, 2, 450, 334, 15594, 12, 2502, 493, 2298, 288, 4090, 275, 1551, 3647, 83, 3149, 83, 2, 450, 334, 15594, 12, 2502, 493, 395, 2, 82, 531, 288, 4132, 585, 275, 4090, 14, 739, 342, 288, 4090, 14, 1600, 342, 267, 587, 520, 288, 4132, 585, 275, 17155, 272, 372, 413, 199, 199, 318, 2372, 63, 2354, 63, 607, 63, 2846, 8, 11641, 12, 3214, 12, 15594, 304, 272, 2288, 2538, 585, 12, 2123, 585, 12, 2502, 585, 12, 1274, 889, 272, 340, 984, 889, 1137, 10812, 267, 2538, 585, 275, 2372, 63, 792, 360, 11677, 363, 65, 297, 1274, 889, 9, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
flodolo/bedrock
bedrock/firefox/firefox_details.py
2
19519
# coding=utf-8 import re from collections import OrderedDict from operator import itemgetter from urllib.parse import urlencode from django.conf import settings from everett.manager import ListOf from product_details import ProductDetails from bedrock.base.waffle import config from lib.l10n_utils.dotlang import _lazy as _ # TODO: port this to django-mozilla-product-details class _ProductDetails(ProductDetails): bouncer_url = settings.BOUNCER_URL def _matches_query(self, info, query): words = re.split(r',|,?\s+', query.strip().lower()) return all((word in info['name_en'].lower() or word in info['name_native'].lower()) for word in words) class FirefoxDesktop(_ProductDetails): download_base_url_transition = '/firefox/download/thanks/' # Human-readable platform names platform_labels = OrderedDict([ ('win64', 'Windows 64-bit'), ('win64-msi', 'Windows 64-bit MSI'), ('win', 'Windows 32-bit'), ('win-msi', 'Windows 32-bit MSI'), ('osx', 'macOS'), ('linux64', 'Linux 64-bit'), ('linux', 'Linux 32-bit'), ]) # Recommended/modern vs traditional/legacy platforms platform_classification = OrderedDict([ ('recommended', ('win64', 'win64-msi', 'osx', 'linux64')), ('traditional', ('linux', 'win', 'win-msi')), ]) # Human-readable channel names channel_labels = { 'nightly': _('Firefox Nightly'), 'alpha': _('Developer Edition'), 'devedition': _('Developer Edition'), 'beta': _('Firefox Beta'), 'esr': _('Firefox Extended Support Release'), 'release': _('Firefox'), } # Version property names in product-details version_map = { 'nightly': 'FIREFOX_NIGHTLY', 'alpha': 'FIREFOX_DEVEDITION', 'devedition': 'FIREFOX_DEVEDITION', 'beta': 'LATEST_FIREFOX_DEVEL_VERSION', 'esr': 'FIREFOX_ESR', 'esr_next': 'FIREFOX_ESR_NEXT', 'release': 'LATEST_FIREFOX_VERSION', } def __init__(self, **kwargs): super(FirefoxDesktop, self).__init__(**kwargs) def platforms(self, channel='release', classified=False): """ Get the desktop platform dictionary containing slugs and corresponding labels. If the classified option is True, it will be ordered by the classification where recommended platforms go first, otherwise a simple copy of platform_labels will be returned. """ if classified: platforms = OrderedDict() for k, v in self.platform_classification.items(): for platform in v: platforms[platform] = self.platform_labels[platform] else: platforms = self.platform_labels.copy() return list(platforms.items()) def latest_version(self, channel='release'): version = self.version_map.get(channel, 'LATEST_FIREFOX_VERSION') try: return self.firefox_versions[version] except KeyError: if channel in ['alpha', 'devedition']: # beta as a fall-back until all product-details data is updated return self.latest_version('beta') return None def latest_major_version(self, channel): """Return latest major version as an int.""" lv = self.latest_version(channel) if lv is None: return 0 try: return int(lv.split('.')[0]) except ValueError: return 0 @property def esr_major_versions(self): versions = [] for channel in ('esr', 'esr_next'): version_int = self.latest_major_version(channel) if version_int: versions.append(version_int) return versions @property def esr_minor_versions(self): versions = [] for channel in ('esr', 'esr_next'): version = self.latest_version(channel) version_int = self.latest_major_version(channel) if version and version_int: versions.append(str(version).replace('esr', '')) return versions def latest_builds(self, locale, channel='release'): """Return build info for a locale and channel. :param locale: locale string of the build :param channel: channel of the build: release, beta, or aurora :return: dict or None """ all_builds = (self.firefox_primary_builds, self.firefox_beta_builds) version = self.latest_version(channel) for builds in all_builds: if locale in builds and version in builds[locale]: _builds = builds[locale][version] # Append 64-bit builds if 'Windows' in _builds: _builds['Windows 64-bit'] = _builds['Windows'] if 'Linux' in _builds: _builds['Linux 64-bit'] = _builds['Linux'] return version, _builds def _get_filtered_builds(self, builds, channel, version=None, query=None): """ Get a list of builds, sorted by english locale name, for a specific Firefox version. :param builds: a build dict from the JSON :param channel: one of self.version_map.keys(). :param version: a firefox version. one of self.latest_versions. :param query: a string to match against native or english locale name :return: list """ version = version or self.latest_version(channel) f_builds = [] for locale, build in builds.items(): if locale not in self.languages or not build.get(version): continue build_info = { 'locale': locale, 'name_en': self.languages[locale]['English'], 'name_native': self.languages[locale]['native'], 'platforms': {}, } # only include builds that match a search query if query is not None and not self._matches_query(build_info, query): continue for platform, label in self.platform_labels.items(): build_info['platforms'][platform] = { 'download_url': self.get_download_url(channel, version, platform, locale, True, True), } f_builds.append(build_info) return sorted(f_builds, key=itemgetter('name_en')) def get_filtered_full_builds(self, channel, version=None, query=None): """ Return filtered builds for the fully translated releases. :param channel: one of self.version_map.keys(). :param version: a firefox version. one of self.latest_version. :param query: a string to match against native or english locale name :return: list """ return self._get_filtered_builds(self.firefox_primary_builds, channel, version, query) def get_filtered_test_builds(self, channel, version=None, query=None): """ Return filtered builds for the translated releases in beta. :param channel: one of self.version_map.keys(). :param version: a firefox version. one of self.latest_version. :param query: a string to match against native or english locale name :return: list """ return self._get_filtered_builds(self.firefox_beta_builds, channel, version, query) def get_download_url(self, channel, version, platform, locale, force_direct=False, force_full_installer=False, force_funnelcake=False, funnelcake_id=None, locale_in_transition=False): """ Get direct download url for the product. :param channel: one of self.version_map.keys(). :param version: a firefox version. one of self.latest_version. :param platform: OS. one of self.platform_labels.keys(). :param locale: e.g. pt-BR. one exception is ja-JP-mac. :param force_direct: Force the download URL to be direct. always True for non-release URLs. :param force_full_installer: Force the installer download to not be the stub installer (for aurora). :param force_funnelcake: Force the download version for en-US Windows to be 'latest', which bouncer will translate to the funnelcake build. :param funnelcake_id: ID for the the funnelcake build. :param locale_in_transition: Include the locale in the transition URL :return: string url """ # no longer used, but still passed in. leaving here for now # as it will likely be used in future. # _version = version _locale = 'ja-JP-mac' if platform == 'osx' and locale == 'ja' else locale channel = 'devedition' if channel == 'alpha' else channel force_direct = True if channel != 'release' else force_direct stub_platforms = ['win', 'win64'] esr_channels = ['esr', 'esr_next'] include_funnelcake_param = False # support optional MSI installer downloads # bug 1493205 is_msi = platform.endswith('-msi') if is_msi: platform = platform[:-4] # Bug 1345467 - Only allow specifically configured funnelcake builds if funnelcake_id: fc_platforms = config('FUNNELCAKE_%s_PLATFORMS' % funnelcake_id, default='', parser=ListOf(str)) fc_locales = config('FUNNELCAKE_%s_LOCALES' % funnelcake_id, default='', parser=ListOf(str)) include_funnelcake_param = platform in fc_platforms and _locale in fc_locales # Check if direct download link has been requested # if not just use transition URL if not force_direct: # build a link to the transition page transition_url = self.download_base_url_transition if funnelcake_id: # include funnelcake in scene 2 URL transition_url += '?f=%s' % funnelcake_id if locale_in_transition: transition_url = '/%s%s' % (locale, transition_url) return transition_url # otherwise build a full download URL prod_name = 'firefox' if channel == 'release' else 'firefox-%s' % channel suffix = 'latest-ssl' if is_msi: suffix = 'msi-' + suffix if channel in esr_channels: # nothing special about ESR other than there is no stub. # included in this contitional to avoid the following elif. if channel == 'esr_next': prod_name = 'firefox-esr-next' elif platform in stub_platforms and not is_msi and not force_full_installer: # Use the stub installer for approved platforms # append funnelcake id to version if we have one if include_funnelcake_param: suffix = 'stub-f%s' % funnelcake_id else: suffix = 'stub' elif channel == 'nightly' and locale != 'en-US': # Nightly uses a different product name for localized builds, # and is the only one ಠ_ಠ suffix = 'latest-l10n-ssl' if is_msi: suffix = 'msi-' + suffix product = '%s-%s' % (prod_name, suffix) return '?'.join([self.bouncer_url, urlencode([ ('product', product), ('os', platform), # Order matters, lang must be last for bouncer. ('lang', _locale), ])]) class FirefoxAndroid(_ProductDetails): # Human-readable architecture names platform_labels = OrderedDict([ ('arm', _('ARM devices\n(Android %s+)')), ('x86', _('Intel devices\n(Android %s+ x86 CPU)')), ]) # Recommended/modern vs traditional/legacy platforms # Unused but required to match FirefoxDesktop platform_classification = None # Human-readable channel names channel_labels = { 'nightly': _('Firefox Nightly'), 'beta': _('Firefox Beta'), 'release': _('Firefox'), } # Version property names in product-details version_map = { 'nightly': 'nightly_version', 'beta': 'beta_version', 'release': 'version', } # Build property names in product-details build_map = { 'beta': 'beta_builds', 'release': 'builds', } # Platform names defined in bouncer platform_map = OrderedDict([ ('arm', 'android'), ('x86', 'android-x86'), ]) # Product names defined in bouncer product_map = { 'nightly': 'fennec-nightly-latest', 'beta': 'fennec-beta-latest', 'release': 'fennec-latest', } store_url = settings.GOOGLE_PLAY_FIREFOX_LINK_UTMS # Product IDs defined on Google Play # Nightly reuses the Aurora ID to migrate the user base store_product_ids = { 'nightly': 'org.mozilla.fennec_aurora', 'beta': 'org.mozilla.firefox_beta', 'release': 'org.mozilla.firefox', } archive_url_base = ('https://archive.mozilla.org/pub/mobile/nightly/' 'latest-mozilla-%s-android') archive_repo = { 'nightly': 'central', } archive_urls = { 'arm': archive_url_base + '-%s/fennec-%s.multi.android-arm.apk', 'x86': archive_url_base + '-%s/fennec-%s.multi.android-i386.apk', } def platforms(self, channel='release', classified=False): """ Get the Android platform dictionary containing slugs and corresponding labels. The classified option is unused but required to match the FirefoxDesktop implementation. """ # Use an OrderedDict to always put the ARM build in front platforms = OrderedDict() # Supported Android version has been changed with Firefox 56 version_int = self.latest_major_version(channel) min_version = '4.0.3' if version_int < 56 else '4.1' # key is a bouncer platform name, value is the human-readable label for arch, platform in self.platform_map.items(): platforms[platform] = self.platform_labels[arch] % min_version return list(platforms.items()) def latest_version(self, channel): version = self.version_map.get(channel, 'version') return self.mobile_details[version] def latest_major_version(self, channel): """Return latest major version as an int.""" lv = self.latest_version(channel) if lv is None: return 0 try: return int(lv.split('.')[0]) except ValueError: return 0 def _get_filtered_builds(self, builds, channel, version=None, query=None): """ Get a list of builds, sorted by english locale name, for a specific Firefox version. :param builds: a build dict from the JSON :param channel: one of self.version_map.keys(). :param version: a firefox version. one of self.latest_versions. :param query: a string to match against native or english locale name :return: list """ locales = [build['locale']['code'] for build in builds] f_builds = [] # For now, only list the multi-locale builds because the single-locale # builds are fragile (Bug 1301650) locales = ['multi'] for locale in locales: if locale == 'multi': name_en = _('Multi-locale') name_native = '' elif locale in self.languages: name_en = self.languages[locale]['English'] name_native = self.languages[locale]['native'] else: continue build_info = { 'locale': locale, 'name_en': name_en, 'name_native': name_native, 'platforms': {}, } # only include builds that match a search query if query is not None and not self._matches_query(build_info, query): continue for arch, platform in self.platform_map.items(): # x86 builds are not localized yet if arch == 'x86' and locale not in ['multi', 'en-US']: continue # Use a direct link instead of Google Play for the /all/ page url = self.get_download_url(channel, arch, locale, True) build_info['platforms'][platform] = {'download_url': url} f_builds.append(build_info) return f_builds def get_filtered_full_builds(self, channel, version=None, query=None): """ Return filtered builds for the fully translated releases. :param channel: one of self.version_map.keys(). :param version: a firefox version. one of self.latest_version. :param query: a string to match against native or english locale name :return: list """ builds = self.mobile_details[self.build_map.get(channel, 'builds')] return self._get_filtered_builds(builds, channel, version, query) def get_filtered_test_builds(self, channel, version=None, query=None): # We don't have pre-release builds yet return [] def get_download_url(self, channel='release', arch='arm', locale='multi', force_direct=False): """ Get direct download url for the product. :param channel: one of self.version_map.keys() such as nightly, beta. :param arch: one of self.platform_map.keys() either arm or x86. :param locale: e.g. pt-BR. :param force_direct: Force the download URL to be direct or bouncer instead of Google Play. :return: string url """ if force_direct: # Use a bouncer link return '?'.join([self.bouncer_url, urlencode([ ('product', self.product_map.get(channel, 'fennec-latest')), ('os', self.platform_map[arch]), # Order matters, lang must be last for bouncer. ('lang', locale), ])]) if channel != 'release': product_id = self.store_product_ids.get(channel, 'org.mozilla.firefox') return self.store_url.replace(self.store_product_ids['release'], product_id) return self.store_url class FirefoxIOS(_ProductDetails): # Version property names in product-details version_map = { 'beta': 'ios_beta_version', 'release': 'ios_version', } store_url = settings.APPLE_APPSTORE_FIREFOX_LINK def latest_version(self, channel): version = self.version_map.get(channel, 'ios_version') return self.mobile_details[version] def get_download_url(self, channel='release', locale='en-US'): countries = settings.APPLE_APPSTORE_COUNTRY_MAP if locale in countries: return self.store_url.format(country=countries[locale]) return self.store_url.replace('/{country}/', '/') firefox_desktop = FirefoxDesktop() firefox_android = FirefoxAndroid() firefox_ios = FirefoxIOS()
mpl-2.0
[ 3, 2803, 29, 1624, 13, 24, 199, 199, 646, 295, 199, 504, 5055, 492, 8773, 199, 504, 4182, 492, 1242, 7416, 199, 504, 4011, 14, 1122, 492, 16511, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 199, 504, 325, 432, 3292, 84, 14, 2609, 492, 3820, 3466, 199, 504, 3336, 63, 5087, 492, 12705, 11347, 199, 199, 504, 30739, 24892, 14, 1095, 14, 758, 556, 274, 492, 1101, 199, 504, 1973, 14, 76, 709, 78, 63, 1208, 14, 3287, 4159, 492, 485, 6395, 465, 485, 421, 199, 3, 3254, 26, 1844, 642, 370, 1639, 13, 12102, 13, 2558, 13, 5087, 199, 533, 485, 5884, 11347, 8, 5884, 11347, 304, 272, 1234, 31794, 63, 633, 275, 2202, 14, 3973, 17192, 540, 63, 2632, 339, 347, 485, 6742, 63, 1131, 8, 277, 12, 2256, 12, 1827, 304, 267, 5932, 275, 295, 14, 1294, 8, 82, 297, 18712, 8995, 83, 7386, 1827, 14, 1913, 1252, 2325, 1012, 267, 372, 1006, 1332, 1027, 315, 2256, 459, 354, 63, 287, 2278, 2325, 342, 503, 490, 4349, 315, 2256, 459, 354, 63, 6106, 2278, 2325, 1012, 367, 4349, 315, 5932, 9, 421, 199, 533, 24584, 20436, 1547, 5884, 11347, 304, 272, 5235, 63, 1095, 63, 633, 63, 14143, 275, 1994, 15394, 15, 4249, 15, 273, 25088, 4805, 339, 327, 869, 7652, 13, 11875, 4298, 1561, 272, 4298, 63, 3512, 275, 8773, 779, 267, 661, 2676, 772, 297, 283, 8647, 5049, 13, 2075, 659, 267, 661, 2676, 772, 13, 77, 338, 297, 283, 8647, 5049, 13, 2075, 603, 2684, 659, 267, 661, 2676, 297, 283, 8647, 4337, 13, 2075, 659, 267, 661, 2676, 13, 77, 338, 297, 283, 8647, 4337, 13, 2075, 603, 2684, 659, 267, 661, 28197, 297, 283, 3088, 3100, 659, 267, 661, 5135, 772, 297, 283, 14091, 5049, 13, 2075, 659, 267, 661, 5135, 297, 283, 14091, 4337, 13, 2075, 659, 272, 4794, 339, 327, 799, 11902, 15, 632, 11641, 8118, 1468, 2603, 15, 10000, 10677, 272, 4298, 63, 14368, 275, 8773, 779, 267, 661, 264, 11902, 297, 661, 2676, 772, 297, 283, 2676, 772, 13, 77, 338, 297, 283, 28197, 297, 283, 5135, 772, 3855, 267, 661, 1239, 2603, 297, 661, 5135, 297, 283, 2676, 297, 283, 2676, 13, 77, 338, 3855, 272, 4794, 339, 327, 869, 7652, 13, 11875, 3623, 1561, 272, 3623, 63, 3512, 275, 469, 267, 283, 14873, 590, 356, 4018, 27983, 653, 1070, 590, 659, 267, 283, 4468, 356, 4018, 31032, 662, 1671, 659, 267, 283, 271, 432, 1671, 356, 4018, 31032, 662, 1671, 659, 267, 283, 5683, 356, 4018, 27983, 29521, 659, 267, 283, 397, 82, 356, 4018, 27983, 13706, 12502, 17646, 659, 267, 283, 3221, 356, 4018, 27983, 659, 272, 789, 339, 327, 3394, 3324, 1561, 315, 3336, 13, 5087, 272, 1015, 63, 1130, 275, 469, 267, 283, 14873, 590, 356, 283, 1976, 907, 3230, 56, 63, 46, 2830, 6084, 297, 267, 283, 4468, 356, 283, 1976, 907, 3230, 56, 63, 13260, 1149, 12039, 297, 267, 283, 271, 432, 1671, 356, 283, 1976, 907, 3230, 56, 63, 13260, 1149, 12039, 297, 267, 283, 5683, 356, 283, 20307, 1719, 63, 1976, 907, 3230, 56, 63, 1093, 10429, 63, 4612, 297, 267, 283, 397, 82, 356, 283, 1976, 907, 3230, 56, 63, 654, 50, 297, 267, 283, 397, 82, 63, 2184, 356, 283, 1976, 907, 3230, 56, 63, 654, 50, 63, 21917, 297, 267, 283, 3221, 356, 283, 20307, 1719, 63, 1976, 907, 3230, 56, 63, 4612, 297, 272, 789, 339, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 1613, 8, 27983, 20436, 12, 291, 2843, 826, 14155, 958, 9, 339, 347, 10677, 8, 277, 12, 3623, 534, 3221, 297, 11534, 1290, 29, 797, 304, 267, 408, 267, 2372, 314, 19763, 4298, 2600, 3035, 5340, 85, 458, 436, 5226, 267, 3628, 14, 982, 314, 11534, 1290, 945, 365, 715, 12, 652, 911, 506, 7741, 701, 314, 267, 12505, 2382, 14318, 10677, 2621, 1642, 12, 4257, 282, 3486, 267, 1331, 402, 4298, 63, 3512, 911, 506, 2138, 14, 267, 408, 267, 340, 11534, 1290, 26, 288, 10677, 275, 8773, 342, 288, 367, 1022, 12, 373, 315, 291, 14, 3246, 63, 14368, 14, 1744, 837, 355, 367, 4298, 315, 373, 26, 490, 10677, 59, 3246, 61, 275, 291, 14, 3246, 63, 3512, 59, 3246, 61, 267, 587, 26, 288, 10677, 275, 291, 14, 3246, 63, 3512, 14, 1574, 342, 398, 372, 769, 8, 19601, 14, 1744, 1012, 339, 347, 8839, 63, 1023, 8, 277, 12, 3623, 534, 3221, 735, 267, 1015, 275, 291, 14, 1023, 63, 1130, 14, 362, 8, 2775, 12, 283, 20307, 1719, 63, 1976, 907, 3230, 56, 63, 4612, 358, 267, 862, 26, 288, 372, 291, 14, 15394, 63, 6234, 59, 1023, 61, 267, 871, 4067, 26, 288, 340, 3623, 315, 788, 4468, 297, 283, 271, 432, 1671, 2565, 355, 327, 8201, 465, 282, 11264, 13, 894, 5133, 1006, 3336, 13, 5087, 666, 365, 4588, 355, 372, 291, 14, 7410, 63, 1023, 360, 5683, 358, 953, 372, 488, 339, 347, 8839, 63, 8452, 63, 1023, 8, 277, 12, 3623, 304, 267, 408, 1767, 8839, 12160, 1015, 465, 376, 1109, 1041, 267, 20604, 275, 291, 14, 7410, 63, 1023, 8, 2775, 9, 267, 340, 20604, 365, 488, 26, 288, 372, 378, 398, 862, 26, 288, 372, 1109, 8, 6371, 14, 1294, 19237, 16, 566, 267, 871, 1722, 26, 288, 372, 378, 339, 768, 1829, 272, 347, 325, 5474, 63, 8452, 63, 6234, 8, 277, 304, 267, 5459, 275, 942, 267, 367, 3623, 315, 661, 397, 82, 297, 283, 397, 82, 63, 2184, 735, 288, 1015, 63, 442, 275, 291, 14, 7410, 63, 8452, 63, 1023, 8, 2775, 9, 288, 340, 1015, 63, 442, 26, 355, 5459, 14, 740, 8, 1023, 63, 442, 9, 398, 372, 5459, 339, 768, 1829, 272, 347, 325, 5474, 63, 11067, 63, 6234, 8, 277, 304, 267, 5459, 275, 942, 267, 367, 3623, 315, 661, 397, 82, 297, 283, 397, 82, 63, 2184, 735, 288, 1015, 275, 291, 14, 7410, 63, 1023, 8, 2775, 9, 288, 1015, 63, 442, 275, 291, 14, 7410, 63, 8452, 63, 1023, 8, 2775, 9, 288, 340, 1015, 436, 1015, 63, 442, 26, 355, 5459, 14, 740, 8, 495, 8, 1023 ]
[ 2803, 29, 1624, 13, 24, 199, 199, 646, 295, 199, 504, 5055, 492, 8773, 199, 504, 4182, 492, 1242, 7416, 199, 504, 4011, 14, 1122, 492, 16511, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 199, 504, 325, 432, 3292, 84, 14, 2609, 492, 3820, 3466, 199, 504, 3336, 63, 5087, 492, 12705, 11347, 199, 199, 504, 30739, 24892, 14, 1095, 14, 758, 556, 274, 492, 1101, 199, 504, 1973, 14, 76, 709, 78, 63, 1208, 14, 3287, 4159, 492, 485, 6395, 465, 485, 421, 199, 3, 3254, 26, 1844, 642, 370, 1639, 13, 12102, 13, 2558, 13, 5087, 199, 533, 485, 5884, 11347, 8, 5884, 11347, 304, 272, 1234, 31794, 63, 633, 275, 2202, 14, 3973, 17192, 540, 63, 2632, 339, 347, 485, 6742, 63, 1131, 8, 277, 12, 2256, 12, 1827, 304, 267, 5932, 275, 295, 14, 1294, 8, 82, 297, 18712, 8995, 83, 7386, 1827, 14, 1913, 1252, 2325, 1012, 267, 372, 1006, 1332, 1027, 315, 2256, 459, 354, 63, 287, 2278, 2325, 342, 503, 490, 4349, 315, 2256, 459, 354, 63, 6106, 2278, 2325, 1012, 367, 4349, 315, 5932, 9, 421, 199, 533, 24584, 20436, 1547, 5884, 11347, 304, 272, 5235, 63, 1095, 63, 633, 63, 14143, 275, 1994, 15394, 15, 4249, 15, 273, 25088, 4805, 339, 327, 869, 7652, 13, 11875, 4298, 1561, 272, 4298, 63, 3512, 275, 8773, 779, 267, 661, 2676, 772, 297, 283, 8647, 5049, 13, 2075, 659, 267, 661, 2676, 772, 13, 77, 338, 297, 283, 8647, 5049, 13, 2075, 603, 2684, 659, 267, 661, 2676, 297, 283, 8647, 4337, 13, 2075, 659, 267, 661, 2676, 13, 77, 338, 297, 283, 8647, 4337, 13, 2075, 603, 2684, 659, 267, 661, 28197, 297, 283, 3088, 3100, 659, 267, 661, 5135, 772, 297, 283, 14091, 5049, 13, 2075, 659, 267, 661, 5135, 297, 283, 14091, 4337, 13, 2075, 659, 272, 4794, 339, 327, 799, 11902, 15, 632, 11641, 8118, 1468, 2603, 15, 10000, 10677, 272, 4298, 63, 14368, 275, 8773, 779, 267, 661, 264, 11902, 297, 661, 2676, 772, 297, 283, 2676, 772, 13, 77, 338, 297, 283, 28197, 297, 283, 5135, 772, 3855, 267, 661, 1239, 2603, 297, 661, 5135, 297, 283, 2676, 297, 283, 2676, 13, 77, 338, 3855, 272, 4794, 339, 327, 869, 7652, 13, 11875, 3623, 1561, 272, 3623, 63, 3512, 275, 469, 267, 283, 14873, 590, 356, 4018, 27983, 653, 1070, 590, 659, 267, 283, 4468, 356, 4018, 31032, 662, 1671, 659, 267, 283, 271, 432, 1671, 356, 4018, 31032, 662, 1671, 659, 267, 283, 5683, 356, 4018, 27983, 29521, 659, 267, 283, 397, 82, 356, 4018, 27983, 13706, 12502, 17646, 659, 267, 283, 3221, 356, 4018, 27983, 659, 272, 789, 339, 327, 3394, 3324, 1561, 315, 3336, 13, 5087, 272, 1015, 63, 1130, 275, 469, 267, 283, 14873, 590, 356, 283, 1976, 907, 3230, 56, 63, 46, 2830, 6084, 297, 267, 283, 4468, 356, 283, 1976, 907, 3230, 56, 63, 13260, 1149, 12039, 297, 267, 283, 271, 432, 1671, 356, 283, 1976, 907, 3230, 56, 63, 13260, 1149, 12039, 297, 267, 283, 5683, 356, 283, 20307, 1719, 63, 1976, 907, 3230, 56, 63, 1093, 10429, 63, 4612, 297, 267, 283, 397, 82, 356, 283, 1976, 907, 3230, 56, 63, 654, 50, 297, 267, 283, 397, 82, 63, 2184, 356, 283, 1976, 907, 3230, 56, 63, 654, 50, 63, 21917, 297, 267, 283, 3221, 356, 283, 20307, 1719, 63, 1976, 907, 3230, 56, 63, 4612, 297, 272, 789, 339, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 1613, 8, 27983, 20436, 12, 291, 2843, 826, 14155, 958, 9, 339, 347, 10677, 8, 277, 12, 3623, 534, 3221, 297, 11534, 1290, 29, 797, 304, 267, 408, 267, 2372, 314, 19763, 4298, 2600, 3035, 5340, 85, 458, 436, 5226, 267, 3628, 14, 982, 314, 11534, 1290, 945, 365, 715, 12, 652, 911, 506, 7741, 701, 314, 267, 12505, 2382, 14318, 10677, 2621, 1642, 12, 4257, 282, 3486, 267, 1331, 402, 4298, 63, 3512, 911, 506, 2138, 14, 267, 408, 267, 340, 11534, 1290, 26, 288, 10677, 275, 8773, 342, 288, 367, 1022, 12, 373, 315, 291, 14, 3246, 63, 14368, 14, 1744, 837, 355, 367, 4298, 315, 373, 26, 490, 10677, 59, 3246, 61, 275, 291, 14, 3246, 63, 3512, 59, 3246, 61, 267, 587, 26, 288, 10677, 275, 291, 14, 3246, 63, 3512, 14, 1574, 342, 398, 372, 769, 8, 19601, 14, 1744, 1012, 339, 347, 8839, 63, 1023, 8, 277, 12, 3623, 534, 3221, 735, 267, 1015, 275, 291, 14, 1023, 63, 1130, 14, 362, 8, 2775, 12, 283, 20307, 1719, 63, 1976, 907, 3230, 56, 63, 4612, 358, 267, 862, 26, 288, 372, 291, 14, 15394, 63, 6234, 59, 1023, 61, 267, 871, 4067, 26, 288, 340, 3623, 315, 788, 4468, 297, 283, 271, 432, 1671, 2565, 355, 327, 8201, 465, 282, 11264, 13, 894, 5133, 1006, 3336, 13, 5087, 666, 365, 4588, 355, 372, 291, 14, 7410, 63, 1023, 360, 5683, 358, 953, 372, 488, 339, 347, 8839, 63, 8452, 63, 1023, 8, 277, 12, 3623, 304, 267, 408, 1767, 8839, 12160, 1015, 465, 376, 1109, 1041, 267, 20604, 275, 291, 14, 7410, 63, 1023, 8, 2775, 9, 267, 340, 20604, 365, 488, 26, 288, 372, 378, 398, 862, 26, 288, 372, 1109, 8, 6371, 14, 1294, 19237, 16, 566, 267, 871, 1722, 26, 288, 372, 378, 339, 768, 1829, 272, 347, 325, 5474, 63, 8452, 63, 6234, 8, 277, 304, 267, 5459, 275, 942, 267, 367, 3623, 315, 661, 397, 82, 297, 283, 397, 82, 63, 2184, 735, 288, 1015, 63, 442, 275, 291, 14, 7410, 63, 8452, 63, 1023, 8, 2775, 9, 288, 340, 1015, 63, 442, 26, 355, 5459, 14, 740, 8, 1023, 63, 442, 9, 398, 372, 5459, 339, 768, 1829, 272, 347, 325, 5474, 63, 11067, 63, 6234, 8, 277, 304, 267, 5459, 275, 942, 267, 367, 3623, 315, 661, 397, 82, 297, 283, 397, 82, 63, 2184, 735, 288, 1015, 275, 291, 14, 7410, 63, 1023, 8, 2775, 9, 288, 1015, 63, 442, 275, 291, 14, 7410, 63, 8452, 63, 1023, 8, 2775, 9, 288, 340, 1015, 436, 1015, 63, 442, 26, 355, 5459, 14, 740, 8, 495, 8, 1023, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sanghinitin/golismero
thirdparty_libs/django/db/models/loading.py
104
10633
"Utilities for loading models and the modules that contain them." from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.utils.datastructures import SortedDict from django.utils.importlib import import_module from django.utils.module_loading import module_has_submodule from django.utils._os import upath from django.utils import six import imp import sys import os __all__ = ('get_apps', 'get_app', 'get_models', 'get_model', 'register_models', 'load_app', 'app_cache_ready') class AppCache(object): """ A cache that stores installed applications and their models. Used to provide reverse-relations and for app introspection (e.g. admin). """ # Use the Borg pattern to share state between all instances. Details at # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531. __shared_state = dict( # Keys of app_store are the model modules for each application. app_store=SortedDict(), # Mapping of installed app_labels to model modules for that app. app_labels={}, # Mapping of app_labels to a dictionary of model names to model code. # May contain apps that are not installed. app_models=SortedDict(), # Mapping of app_labels to errors raised when trying to import the app. app_errors={}, # -- Everything below here is only used when populating the cache -- loaded=False, handled={}, postponed=[], nesting_level=0, _get_models_cache={}, ) def __init__(self): self.__dict__ = self.__shared_state def _populate(self): """ Fill in all the cache information. This method is threadsafe, in the sense that every caller will see the same state upon return, and if the cache is already initialised, it does no work. """ if self.loaded: return # Note that we want to use the import lock here - the app loading is # in many cases initiated implicitly by importing, and thus it is # possible to end up in deadlock when one thread initiates loading # without holding the importer lock and another thread then tries to # import something which also launches the app loading. For details of # this situation see #18251. imp.acquire_lock() try: if self.loaded: return for app_name in settings.INSTALLED_APPS: if app_name in self.handled: continue self.load_app(app_name, True) if not self.nesting_level: for app_name in self.postponed: self.load_app(app_name) self.loaded = True finally: imp.release_lock() def _label_for(self, app_mod): """ Return app_label for given models module. """ return app_mod.__name__.split('.')[-2] def load_app(self, app_name, can_postpone=False): """ Loads the app with the provided fully qualified name, and returns the model module. """ self.handled[app_name] = None self.nesting_level += 1 app_module = import_module(app_name) try: models = import_module('.models', app_name) except ImportError: self.nesting_level -= 1 # If the app doesn't have a models module, we can just ignore the # ImportError and return no models for it. if not module_has_submodule(app_module, 'models'): return None # But if the app does have a models module, we need to figure out # whether to suppress or propagate the error. If can_postpone is # True then it may be that the package is still being imported by # Python and the models module isn't available yet. So we add the # app to the postponed list and we'll try it again after all the # recursion has finished (in populate). If can_postpone is False # then it's time to raise the ImportError. else: if can_postpone: self.postponed.append(app_name) return None else: raise self.nesting_level -= 1 if models not in self.app_store: self.app_store[models] = len(self.app_store) self.app_labels[self._label_for(models)] = models return models def app_cache_ready(self): """ Returns true if the model cache is fully populated. Useful for code that wants to cache the results of get_models() for themselves once it is safe to do so. """ return self.loaded def get_apps(self): "Returns a list of all installed modules that contain models." self._populate() # Ensure the returned list is always in the same order (with new apps # added at the end). This avoids unstable ordering on the admin app # list page, for example. apps = [(v, k) for k, v in self.app_store.items()] apps.sort() return [elt[1] for elt in apps] def get_app(self, app_label, emptyOK=False): """ Returns the module containing the models for the given app_label. If the app has no models in it and 'emptyOK' is True, returns None. """ self._populate() imp.acquire_lock() try: for app_name in settings.INSTALLED_APPS: if app_label == app_name.split('.')[-1]: mod = self.load_app(app_name, False) if mod is None: if emptyOK: return None raise ImproperlyConfigured("App with label %s is missing a models.py module." % app_label) else: return mod raise ImproperlyConfigured("App with label %s could not be found" % app_label) finally: imp.release_lock() def get_app_errors(self): "Returns the map of known problems with the INSTALLED_APPS." self._populate() return self.app_errors def get_models(self, app_mod=None, include_auto_created=False, include_deferred=False, only_installed=True, include_swapped=False): """ Given a module containing models, returns a list of the models. Otherwise returns a list of all installed models. By default, auto-created models (i.e., m2m models without an explicit intermediate table) are not included. However, if you specify include_auto_created=True, they will be. By default, models created to satisfy deferred attribute queries are *not* included in the list of models. However, if you specify include_deferred, they will be. By default, models that aren't part of installed apps will *not* be included in the list of models. However, if you specify only_installed=False, they will be. By default, models that have been swapped out will *not* be included in the list of models. However, if you specify include_swapped, they will be. """ cache_key = (app_mod, include_auto_created, include_deferred, only_installed, include_swapped) try: return self._get_models_cache[cache_key] except KeyError: pass self._populate() if app_mod: if app_mod in self.app_store: app_list = [self.app_models.get(self._label_for(app_mod), SortedDict())] else: app_list = [] else: if only_installed: app_list = [self.app_models.get(app_label, SortedDict()) for app_label in six.iterkeys(self.app_labels)] else: app_list = six.itervalues(self.app_models) model_list = [] for app in app_list: model_list.extend( model for model in app.values() if ((not model._deferred or include_deferred) and (not model._meta.auto_created or include_auto_created) and (not model._meta.swapped or include_swapped)) ) self._get_models_cache[cache_key] = model_list return model_list def get_model(self, app_label, model_name, seed_cache=True, only_installed=True): """ Returns the model matching the given app_label and case-insensitive model_name. Returns None if no model is found. """ if seed_cache: self._populate() if only_installed and app_label not in self.app_labels: return None return self.app_models.get(app_label, SortedDict()).get(model_name.lower()) def register_models(self, app_label, *models): """ Register a set of models as belonging to an app. """ for model in models: # Store as 'name: model' pair in a dictionary # in the app_models dictionary model_name = model._meta.object_name.lower() model_dict = self.app_models.setdefault(app_label, SortedDict()) if model_name in model_dict: # The same model may be imported via different paths (e.g. # appname.models and project.appname.models). We use the source # filename as a means to detect identity. fname1 = os.path.abspath(upath(sys.modules[model.__module__].__file__)) fname2 = os.path.abspath(upath(sys.modules[model_dict[model_name].__module__].__file__)) # Since the filename extension could be .py the first time and # .pyc or .pyo the second time, ignore the extension when # comparing. if os.path.splitext(fname1)[0] == os.path.splitext(fname2)[0]: continue model_dict[model_name] = model self._get_models_cache.clear() cache = AppCache() # These methods were always module level, so are kept that way for backwards # compatibility. get_apps = cache.get_apps get_app = cache.get_app get_app_errors = cache.get_app_errors get_models = cache.get_models get_model = cache.get_model register_models = cache.register_models load_app = cache.load_app app_cache_ready = cache.app_cache_ready
gpl-2.0
[ 2, 22905, 367, 8697, 1709, 436, 314, 4621, 626, 1395, 3062, 2122, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1208, 14, 23004, 492, 27432, 2141, 199, 504, 1639, 14, 1208, 14, 25893, 492, 492, 63, 578, 199, 504, 1639, 14, 1208, 14, 578, 63, 8786, 492, 859, 63, 1989, 63, 16229, 199, 504, 1639, 14, 1208, 423, 736, 492, 1536, 1619, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 646, 1742, 199, 646, 984, 199, 646, 747, 199, 199, 363, 452, 363, 275, 661, 362, 63, 5181, 297, 283, 362, 63, 571, 297, 283, 362, 63, 992, 297, 283, 362, 63, 1238, 297, 283, 2683, 63, 992, 297, 267, 283, 912, 63, 571, 297, 283, 571, 63, 1637, 63, 2179, 358, 421, 199, 533, 4693, 4437, 8, 785, 304, 272, 408, 272, 437, 2581, 626, 14086, 4903, 13103, 436, 3932, 1709, 14, 8051, 370, 272, 5647, 3837, 13, 15741, 436, 367, 1145, 1109, 14254, 334, 69, 14, 71, 14, 4628, 680, 272, 408, 272, 327, 3645, 314, 699, 1308, 3851, 370, 8663, 1174, 3382, 1006, 4454, 14, 15621, 737, 272, 327, 1455, 921, 305, 4812, 14, 32595, 14, 957, 15, 1179, 9060, 15, 967, 32632, 15, 4718, 15, 25879, 15, 16373, 2192, 14, 272, 636, 5555, 63, 929, 275, 1211, 8, 267, 327, 17276, 402, 1145, 63, 1617, 787, 314, 1402, 4621, 367, 1924, 4223, 14, 267, 1145, 63, 1617, 29, 22861, 2141, 1062, 398, 327, 12340, 402, 4903, 1145, 63, 3512, 370, 1402, 4621, 367, 626, 1145, 14, 267, 1145, 63, 3512, 10324, 398, 327, 12340, 402, 1145, 63, 3512, 370, 282, 2600, 402, 1402, 1561, 370, 1402, 1233, 14, 267, 327, 10162, 1395, 8686, 626, 787, 440, 4903, 14, 267, 1145, 63, 992, 29, 22861, 2141, 1062, 398, 327, 12340, 402, 1145, 63, 3512, 370, 2552, 4915, 1380, 9936, 370, 492, 314, 1145, 14, 267, 1145, 63, 2550, 10324, 398, 327, 1553, 18414, 2127, 5084, 2348, 365, 1454, 1202, 1380, 4560, 20529, 314, 2581, 1553, 267, 6511, 29, 797, 12, 267, 8860, 10324, 267, 2963, 80, 28918, 6034, 267, 19500, 63, 1896, 29, 16, 12, 267, 485, 362, 63, 992, 63, 1637, 10324, 272, 776, 339, 347, 636, 826, 721, 277, 304, 267, 291, 855, 807, 363, 275, 291, 855, 5555, 63, 929, 339, 347, 485, 13817, 8, 277, 304, 267, 408, 267, 24797, 315, 1006, 314, 2581, 2556, 14, 961, 1083, 365, 2462, 3489, 12, 315, 314, 267, 12249, 626, 4036, 8025, 911, 1937, 314, 2011, 1174, 12188, 372, 12, 436, 340, 314, 267, 2581, 365, 2575, 2536, 9096, 12, 652, 1630, 949, 1736, 14, 267, 408, 267, 340, 291, 14, 4591, 26, 288, 372, 267, 327, 3390, 626, 781, 2934, 370, 675, 314, 492, 4650, 2348, 446, 314, 1145, 8697, 365, 267, 327, 315, 5002, 5560, 11023, 972, 19796, 701, 16306, 12, 436, 12850, 652, 365, 267, 327, 3962, 370, 1284, 1536, 315, 12314, 831, 1380, 1373, 2462, 11023, 2335, 8697, 267, 327, 1928, 17573, 314, 13479, 4650, 436, 4573, 2462, 2066, 11275, 370, 267, 327, 492, 6020, 1314, 2597, 10623, 397, 314, 1145, 8697, 14, 2104, 2436, 402, 267, 327, 642, 25781, 1937, 327, 1085, 12140, 14, 267, 1742, 14, 8174, 63, 831, 342, 267, 862, 26, 288, 340, 291, 14, 4591, 26, 355, 372, 288, 367, 1145, 63, 354, 315, 2202, 14, 15942, 63, 14219, 26, 355, 340, 1145, 63, 354, 315, 291, 14, 11217, 26, 490, 1980, 355, 291, 14, 912, 63, 571, 8, 571, 63, 354, 12, 715, 9, 288, 340, 440, 291, 14, 15272, 316, 63, 1896, 26, 355, 367, 1145, 63, 354, 315, 291, 14, 1932, 80, 28918, 26, 490, 291, 14, 912, 63, 571, 8, 571, 63, 354, 9, 355, 291, 14, 4591, 275, 715, 267, 3753, 26, 288, 1742, 14, 3221, 63, 831, 342, 339, 347, 485, 1302, 63, 509, 8, 277, 12, 1145, 63, 1494, 304, 267, 408, 267, 1432, 1145, 63, 1302, 367, 1627, 1709, 859, 14, 398, 408, 267, 372, 1145, 63, 1494, 855, 354, 4343, 1294, 29084, 18, 61, 339, 347, 2248, 63, 571, 8, 277, 12, 1145, 63, 354, 12, 883, 63, 1932, 80, 368, 29, 797, 304, 267, 408, 267, 30367, 314, 1145, 543, 314, 2741, 9999, 12313, 536, 12, 436, 2529, 314, 267, 1402, 859, 14, 267, 408, 267, 291, 14, 11217, 59, 571, 63, 354, 61, 275, 488, 267, 291, 14, 15272, 316, 63, 1896, 847, 413, 267, 1145, 63, 578, 275, 492, 63, 578, 8, 571, 63, 354, 9, 267, 862, 26, 288, 1709, 275, 492, 63, 578, 5175, 992, 297, 1145, 63, 354, 9, 267, 871, 3545, 26, 288, 291, 14, 15272, 316, 63, 1896, 4862, 413, 288, 327, 982, 314, 1145, 3181, 1133, 1172, 282, 1709, 859, 12, 781, 883, 2951, 3686, 314, 288, 327, 3545, 436, 372, 949, 1709, 367, 652, 14, 288, 340, 440, 859, 63, 1989, 63, 16229, 8, 571, 63, 578, 12, 283, 992, 735, 355, 372, 488, 288, 327, 11017, 340, 314, 1145, 1630, 1172, 282, 1709, 859, 12, 781, 1929, 370, 9658, 734, 288, 327, 3775, 370, 15678, 503, 19843, 314, 1125, 14, 982, 883, 63, 1932, 80, 368, 365, 288, 327, 715, 2066, 652, 1443, 506, 626, 314, 2559, 365, 5139, 3769, 8439, 701, 288, 327, 2018, 436, 314, 1709, 859, 5712, 1133, 2808, 5966, 14, 2002, 781, 1050, 314, 288, 327, 1145, 370, 314, 2963, 80, 28918, 769, 436, 781, 7171, 862, 652, 4020, 2410, 1006, 314, 288, 327, 16189, 965, 9158, 334, 262, 13904, 680, 982, 883, 63, 1932, 80, 368, 365, 756, 288, 327, 2066, 652, 1159, 900, 370, 746, 314, 3545, 14, 288, 587, 26, 355, 340, 883, 63, 1932, 80, 368, 26, 490, 291, 14, 1932, 80, 28918, 14, 740, 8, 571, 63, 354, 9, 490, 372, 488, 355, 587, 26, 490, 746, 398, 291, 14, 15272, 316, 63, 1896, 4862, 413, 267, 340, 1709, 440, 315, 291, 14, 571, 63, 1617, 26, 288, 291, 14, 571, 63, 1617, 59, 992, 61, 275, 822, 8, 277, 14, 571, 63, 1617, 9, 288, 291, 14, 571, 63, 3512, 59, 277, 423, 1302, 63, 509, 8 ]
[ 22905, 367, 8697, 1709, 436, 314, 4621, 626, 1395, 3062, 2122, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1208, 14, 23004, 492, 27432, 2141, 199, 504, 1639, 14, 1208, 14, 25893, 492, 492, 63, 578, 199, 504, 1639, 14, 1208, 14, 578, 63, 8786, 492, 859, 63, 1989, 63, 16229, 199, 504, 1639, 14, 1208, 423, 736, 492, 1536, 1619, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 646, 1742, 199, 646, 984, 199, 646, 747, 199, 199, 363, 452, 363, 275, 661, 362, 63, 5181, 297, 283, 362, 63, 571, 297, 283, 362, 63, 992, 297, 283, 362, 63, 1238, 297, 283, 2683, 63, 992, 297, 267, 283, 912, 63, 571, 297, 283, 571, 63, 1637, 63, 2179, 358, 421, 199, 533, 4693, 4437, 8, 785, 304, 272, 408, 272, 437, 2581, 626, 14086, 4903, 13103, 436, 3932, 1709, 14, 8051, 370, 272, 5647, 3837, 13, 15741, 436, 367, 1145, 1109, 14254, 334, 69, 14, 71, 14, 4628, 680, 272, 408, 272, 327, 3645, 314, 699, 1308, 3851, 370, 8663, 1174, 3382, 1006, 4454, 14, 15621, 737, 272, 327, 1455, 921, 305, 4812, 14, 32595, 14, 957, 15, 1179, 9060, 15, 967, 32632, 15, 4718, 15, 25879, 15, 16373, 2192, 14, 272, 636, 5555, 63, 929, 275, 1211, 8, 267, 327, 17276, 402, 1145, 63, 1617, 787, 314, 1402, 4621, 367, 1924, 4223, 14, 267, 1145, 63, 1617, 29, 22861, 2141, 1062, 398, 327, 12340, 402, 4903, 1145, 63, 3512, 370, 1402, 4621, 367, 626, 1145, 14, 267, 1145, 63, 3512, 10324, 398, 327, 12340, 402, 1145, 63, 3512, 370, 282, 2600, 402, 1402, 1561, 370, 1402, 1233, 14, 267, 327, 10162, 1395, 8686, 626, 787, 440, 4903, 14, 267, 1145, 63, 992, 29, 22861, 2141, 1062, 398, 327, 12340, 402, 1145, 63, 3512, 370, 2552, 4915, 1380, 9936, 370, 492, 314, 1145, 14, 267, 1145, 63, 2550, 10324, 398, 327, 1553, 18414, 2127, 5084, 2348, 365, 1454, 1202, 1380, 4560, 20529, 314, 2581, 1553, 267, 6511, 29, 797, 12, 267, 8860, 10324, 267, 2963, 80, 28918, 6034, 267, 19500, 63, 1896, 29, 16, 12, 267, 485, 362, 63, 992, 63, 1637, 10324, 272, 776, 339, 347, 636, 826, 721, 277, 304, 267, 291, 855, 807, 363, 275, 291, 855, 5555, 63, 929, 339, 347, 485, 13817, 8, 277, 304, 267, 408, 267, 24797, 315, 1006, 314, 2581, 2556, 14, 961, 1083, 365, 2462, 3489, 12, 315, 314, 267, 12249, 626, 4036, 8025, 911, 1937, 314, 2011, 1174, 12188, 372, 12, 436, 340, 314, 267, 2581, 365, 2575, 2536, 9096, 12, 652, 1630, 949, 1736, 14, 267, 408, 267, 340, 291, 14, 4591, 26, 288, 372, 267, 327, 3390, 626, 781, 2934, 370, 675, 314, 492, 4650, 2348, 446, 314, 1145, 8697, 365, 267, 327, 315, 5002, 5560, 11023, 972, 19796, 701, 16306, 12, 436, 12850, 652, 365, 267, 327, 3962, 370, 1284, 1536, 315, 12314, 831, 1380, 1373, 2462, 11023, 2335, 8697, 267, 327, 1928, 17573, 314, 13479, 4650, 436, 4573, 2462, 2066, 11275, 370, 267, 327, 492, 6020, 1314, 2597, 10623, 397, 314, 1145, 8697, 14, 2104, 2436, 402, 267, 327, 642, 25781, 1937, 327, 1085, 12140, 14, 267, 1742, 14, 8174, 63, 831, 342, 267, 862, 26, 288, 340, 291, 14, 4591, 26, 355, 372, 288, 367, 1145, 63, 354, 315, 2202, 14, 15942, 63, 14219, 26, 355, 340, 1145, 63, 354, 315, 291, 14, 11217, 26, 490, 1980, 355, 291, 14, 912, 63, 571, 8, 571, 63, 354, 12, 715, 9, 288, 340, 440, 291, 14, 15272, 316, 63, 1896, 26, 355, 367, 1145, 63, 354, 315, 291, 14, 1932, 80, 28918, 26, 490, 291, 14, 912, 63, 571, 8, 571, 63, 354, 9, 355, 291, 14, 4591, 275, 715, 267, 3753, 26, 288, 1742, 14, 3221, 63, 831, 342, 339, 347, 485, 1302, 63, 509, 8, 277, 12, 1145, 63, 1494, 304, 267, 408, 267, 1432, 1145, 63, 1302, 367, 1627, 1709, 859, 14, 398, 408, 267, 372, 1145, 63, 1494, 855, 354, 4343, 1294, 29084, 18, 61, 339, 347, 2248, 63, 571, 8, 277, 12, 1145, 63, 354, 12, 883, 63, 1932, 80, 368, 29, 797, 304, 267, 408, 267, 30367, 314, 1145, 543, 314, 2741, 9999, 12313, 536, 12, 436, 2529, 314, 267, 1402, 859, 14, 267, 408, 267, 291, 14, 11217, 59, 571, 63, 354, 61, 275, 488, 267, 291, 14, 15272, 316, 63, 1896, 847, 413, 267, 1145, 63, 578, 275, 492, 63, 578, 8, 571, 63, 354, 9, 267, 862, 26, 288, 1709, 275, 492, 63, 578, 5175, 992, 297, 1145, 63, 354, 9, 267, 871, 3545, 26, 288, 291, 14, 15272, 316, 63, 1896, 4862, 413, 288, 327, 982, 314, 1145, 3181, 1133, 1172, 282, 1709, 859, 12, 781, 883, 2951, 3686, 314, 288, 327, 3545, 436, 372, 949, 1709, 367, 652, 14, 288, 340, 440, 859, 63, 1989, 63, 16229, 8, 571, 63, 578, 12, 283, 992, 735, 355, 372, 488, 288, 327, 11017, 340, 314, 1145, 1630, 1172, 282, 1709, 859, 12, 781, 1929, 370, 9658, 734, 288, 327, 3775, 370, 15678, 503, 19843, 314, 1125, 14, 982, 883, 63, 1932, 80, 368, 365, 288, 327, 715, 2066, 652, 1443, 506, 626, 314, 2559, 365, 5139, 3769, 8439, 701, 288, 327, 2018, 436, 314, 1709, 859, 5712, 1133, 2808, 5966, 14, 2002, 781, 1050, 314, 288, 327, 1145, 370, 314, 2963, 80, 28918, 769, 436, 781, 7171, 862, 652, 4020, 2410, 1006, 314, 288, 327, 16189, 965, 9158, 334, 262, 13904, 680, 982, 883, 63, 1932, 80, 368, 365, 756, 288, 327, 2066, 652, 1159, 900, 370, 746, 314, 3545, 14, 288, 587, 26, 355, 340, 883, 63, 1932, 80, 368, 26, 490, 291, 14, 1932, 80, 28918, 14, 740, 8, 571, 63, 354, 9, 490, 372, 488, 355, 587, 26, 490, 746, 398, 291, 14, 15272, 316, 63, 1896, 4862, 413, 267, 340, 1709, 440, 315, 291, 14, 571, 63, 1617, 26, 288, 291, 14, 571, 63, 1617, 59, 992, 61, 275, 822, 8, 277, 14, 571, 63, 1617, 9, 288, 291, 14, 571, 63, 3512, 59, 277, 423, 1302, 63, 509, 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,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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 ]
Dhivyap/ansible
test/units/modules/network/fortios/test_fortios_switch_controller_vlan.py
21
10989
# Copyright 2019 Fortinet, Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <https://www.gnu.org/licenses/>. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type import pytest from mock import ANY from ansible.module_utils.network.fortios.fortios import FortiOSHandler try: from ansible.modules.network.fortios import fortios_switch_controller_vlan except ImportError: pytest.skip("Could not load required modules for testing", allow_module_level=True) @pytest.fixture(autouse=True) def connection_mock(mocker): connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_vlan.Connection') return connection_class_mock fos_instance = FortiOSHandler(connection_mock) def test_switch_controller_vlan_creation(mocker): schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema') set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200} set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result) input_data = { 'username': 'admin', 'state': 'present', 'switch_controller_vlan': { 'auth': 'radius', 'color': '4', 'comments': 'test_value_5', 'name': 'default_name_6', 'portal_message_override_group': 'test_value_7', 'radius_server': 'test_value_8', 'security': 'open', 'usergroup': 'test_value_10', 'vdom': 'test_value_11', 'vlanid': '12' }, 'vdom': 'root'} is_error, changed, response = fortios_switch_controller_vlan.fortios_switch_controller(input_data, fos_instance) expected_data = { 'auth': 'radius', 'color': '4', 'comments': 'test_value_5', 'name': 'default_name_6', 'portal-message-override-group': 'test_value_7', 'radius-server': 'test_value_8', 'security': 'open', 'usergroup': 'test_value_10', 'vdom': 'test_value_11', 'vlanid': '12' } set_method_mock.assert_called_with('switch-controller', 'vlan', data=expected_data, vdom='root') schema_method_mock.assert_not_called() assert not is_error assert changed assert response['status'] == 'success' assert response['http_status'] == 200 def test_switch_controller_vlan_creation_fails(mocker): schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema') set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500} set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result) input_data = { 'username': 'admin', 'state': 'present', 'switch_controller_vlan': { 'auth': 'radius', 'color': '4', 'comments': 'test_value_5', 'name': 'default_name_6', 'portal_message_override_group': 'test_value_7', 'radius_server': 'test_value_8', 'security': 'open', 'usergroup': 'test_value_10', 'vdom': 'test_value_11', 'vlanid': '12' }, 'vdom': 'root'} is_error, changed, response = fortios_switch_controller_vlan.fortios_switch_controller(input_data, fos_instance) expected_data = { 'auth': 'radius', 'color': '4', 'comments': 'test_value_5', 'name': 'default_name_6', 'portal-message-override-group': 'test_value_7', 'radius-server': 'test_value_8', 'security': 'open', 'usergroup': 'test_value_10', 'vdom': 'test_value_11', 'vlanid': '12' } set_method_mock.assert_called_with('switch-controller', 'vlan', data=expected_data, vdom='root') schema_method_mock.assert_not_called() assert is_error assert not changed assert response['status'] == 'error' assert response['http_status'] == 500 def test_switch_controller_vlan_removal(mocker): schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema') delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200} delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result) input_data = { 'username': 'admin', 'state': 'absent', 'switch_controller_vlan': { 'auth': 'radius', 'color': '4', 'comments': 'test_value_5', 'name': 'default_name_6', 'portal_message_override_group': 'test_value_7', 'radius_server': 'test_value_8', 'security': 'open', 'usergroup': 'test_value_10', 'vdom': 'test_value_11', 'vlanid': '12' }, 'vdom': 'root'} is_error, changed, response = fortios_switch_controller_vlan.fortios_switch_controller(input_data, fos_instance) delete_method_mock.assert_called_with('switch-controller', 'vlan', mkey=ANY, vdom='root') schema_method_mock.assert_not_called() assert not is_error assert changed assert response['status'] == 'success' assert response['http_status'] == 200 def test_switch_controller_vlan_deletion_fails(mocker): schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema') delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500} delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result) input_data = { 'username': 'admin', 'state': 'absent', 'switch_controller_vlan': { 'auth': 'radius', 'color': '4', 'comments': 'test_value_5', 'name': 'default_name_6', 'portal_message_override_group': 'test_value_7', 'radius_server': 'test_value_8', 'security': 'open', 'usergroup': 'test_value_10', 'vdom': 'test_value_11', 'vlanid': '12' }, 'vdom': 'root'} is_error, changed, response = fortios_switch_controller_vlan.fortios_switch_controller(input_data, fos_instance) delete_method_mock.assert_called_with('switch-controller', 'vlan', mkey=ANY, vdom='root') schema_method_mock.assert_not_called() assert is_error assert not changed assert response['status'] == 'error' assert response['http_status'] == 500 def test_switch_controller_vlan_idempotent(mocker): schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema') set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404} set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result) input_data = { 'username': 'admin', 'state': 'present', 'switch_controller_vlan': { 'auth': 'radius', 'color': '4', 'comments': 'test_value_5', 'name': 'default_name_6', 'portal_message_override_group': 'test_value_7', 'radius_server': 'test_value_8', 'security': 'open', 'usergroup': 'test_value_10', 'vdom': 'test_value_11', 'vlanid': '12' }, 'vdom': 'root'} is_error, changed, response = fortios_switch_controller_vlan.fortios_switch_controller(input_data, fos_instance) expected_data = { 'auth': 'radius', 'color': '4', 'comments': 'test_value_5', 'name': 'default_name_6', 'portal-message-override-group': 'test_value_7', 'radius-server': 'test_value_8', 'security': 'open', 'usergroup': 'test_value_10', 'vdom': 'test_value_11', 'vlanid': '12' } set_method_mock.assert_called_with('switch-controller', 'vlan', data=expected_data, vdom='root') schema_method_mock.assert_not_called() assert not is_error assert not changed assert response['status'] == 'error' assert response['http_status'] == 404 def test_switch_controller_vlan_filter_foreign_attributes(mocker): schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema') set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200} set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result) input_data = { 'username': 'admin', 'state': 'present', 'switch_controller_vlan': { 'random_attribute_not_valid': 'tag', 'auth': 'radius', 'color': '4', 'comments': 'test_value_5', 'name': 'default_name_6', 'portal_message_override_group': 'test_value_7', 'radius_server': 'test_value_8', 'security': 'open', 'usergroup': 'test_value_10', 'vdom': 'test_value_11', 'vlanid': '12' }, 'vdom': 'root'} is_error, changed, response = fortios_switch_controller_vlan.fortios_switch_controller(input_data, fos_instance) expected_data = { 'auth': 'radius', 'color': '4', 'comments': 'test_value_5', 'name': 'default_name_6', 'portal-message-override-group': 'test_value_7', 'radius-server': 'test_value_8', 'security': 'open', 'usergroup': 'test_value_10', 'vdom': 'test_value_11', 'vlanid': '12' } set_method_mock.assert_called_with('switch-controller', 'vlan', data=expected_data, vdom='root') schema_method_mock.assert_not_called() assert not is_error assert changed assert response['status'] == 'success' assert response['http_status'] == 200
gpl-3.0
[ 3, 1898, 20312, 30205, 10811, 12, 3277, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 2859, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 4613, 199, 504, 1683, 492, 1821, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 492, 22913, 2461, 199, 199, 893, 26, 272, 687, 3242, 14, 3112, 14, 1200, 14, 14551, 492, 19516, 63, 5656, 63, 5538, 63, 7175, 199, 2590, 3545, 26, 272, 4613, 14, 2759, 480, 6531, 440, 2248, 1415, 4621, 367, 5343, 401, 2040, 63, 578, 63, 1896, 29, 549, 9, 421, 199, 32, 4462, 14, 5997, 8, 6898, 7130, 29, 549, 9, 199, 318, 1950, 63, 1805, 8, 27899, 304, 272, 1950, 63, 533, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 3112, 14, 1200, 14, 14551, 14, 14551, 63, 5656, 63, 5538, 63, 7175, 14, 3225, 358, 272, 372, 1950, 63, 533, 63, 1805, 421, 199, 545, 83, 63, 842, 275, 22913, 2461, 8, 2105, 63, 1805, 9, 421, 199, 318, 511, 63, 5656, 63, 5538, 63, 7175, 63, 8782, 8, 27899, 304, 272, 4177, 63, 765, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 14, 29089, 14, 3629, 358, 339, 663, 63, 765, 63, 1099, 275, 791, 1205, 356, 283, 3742, 297, 283, 1014, 63, 765, 356, 283, 4030, 297, 283, 1014, 63, 1205, 356, 1926, 93, 272, 663, 63, 765, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 14, 29089, 14, 409, 297, 372, 63, 585, 29, 409, 63, 765, 63, 1099, 9, 339, 1324, 63, 576, 275, 469, 267, 283, 2473, 356, 283, 2113, 297, 267, 283, 929, 356, 283, 1881, 297, 267, 283, 5656, 63, 5538, 63, 7175, 356, 469, 288, 283, 1178, 356, 283, 8017, 297, 288, 283, 2326, 356, 283, 20, 297, 288, 283, 6223, 356, 283, 396, 63, 585, 63, 21, 297, 288, 283, 354, 356, 283, 885, 63, 354, 63, 22, 297, 288, 283, 8707, 63, 1188, 63, 4415, 63, 923, 356, 283, 396, 63, 585, 63, 23, 297, 288, 283, 8017, 63, 1000, 356, 283, 396, 63, 585, 63, 24, 297, 288, 283, 4416, 356, 283, 1490, 297, 288, 283, 751, 923, 356, 283, 396, 63, 585, 63, 709, 297, 288, 283, 23779, 356, 283, 396, 63, 585, 63, 845, 297, 288, 283, 7175, 344, 356, 283, 713, 7, 267, 1660, 267, 283, 23779, 356, 283, 1231, 936, 339, 365, 63, 705, 12, 2896, 12, 1177, 275, 19516, 63, 5656, 63, 5538, 63, 7175, 14, 14551, 63, 5656, 63, 5538, 8, 1210, 63, 576, 12, 15509, 63, 842, 9, 339, 1420, 63, 576, 275, 469, 267, 283, 1178, 356, 283, 8017, 297, 355, 283, 2326, 356, 283, 20, 297, 355, 283, 6223, 356, 283, 396, 63, 585, 63, 21, 297, 355, 283, 354, 356, 283, 885, 63, 354, 63, 22, 297, 355, 283, 8707, 13, 1188, 13, 4415, 13, 923, 356, 283, 396, 63, 585, 63, 23, 297, 355, 283, 8017, 13, 1000, 356, 283, 396, 63, 585, 63, 24, 297, 355, 283, 4416, 356, 283, 1490, 297, 355, 283, 751, 923, 356, 283, 396, 63, 585, 63, 709, 297, 355, 283, 23779, 356, 283, 396, 63, 585, 63, 845, 297, 355, 283, 7175, 344, 356, 283, 713, 7, 272, 789, 339, 663, 63, 765, 63, 1805, 14, 479, 63, 3527, 63, 1045, 360, 5656, 13, 5538, 297, 283, 7175, 297, 666, 29, 2062, 63, 576, 12, 20822, 534, 1231, 358, 272, 4177, 63, 765, 63, 1805, 14, 479, 63, 1397, 63, 3527, 342, 272, 702, 440, 365, 63, 705, 272, 702, 2896, 272, 702, 1177, 459, 1205, 418, 508, 283, 3742, 7, 272, 702, 1177, 459, 1014, 63, 1205, 418, 508, 1926, 421, 199, 318, 511, 63, 5656, 63, 5538, 63, 7175, 63, 8782, 63, 15762, 8, 27899, 304, 272, 4177, 63, 765, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 14, 29089, 14, 3629, 358, 339, 663, 63, 765, 63, 1099, 275, 791, 1205, 356, 283, 705, 297, 283, 1014, 63, 765, 356, 283, 4030, 297, 283, 1014, 63, 1205, 356, 6891, 93, 272, 663, 63, 765, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 14, 29089, 14, 409, 297, 372, 63, 585, 29, 409, 63, 765, 63, 1099, 9, 339, 1324, 63, 576, 275, 469, 267, 283, 2473, 356, 283, 2113, 297, 267, 283, 929, 356, 283, 1881, 297, 267, 283, 5656, 63, 5538, 63, 7175, 356, 469, 288, 283, 1178, 356, 283, 8017, 297, 288, 283, 2326, 356, 283, 20, 297, 288, 283, 6223, 356, 283, 396, 63, 585, 63, 21, 297, 288, 283, 354, 356, 283, 885, 63, 354, 63, 22, 297, 288, 283, 8707, 63, 1188, 63, 4415, 63, 923, 356, 283, 396, 63, 585, 63, 23, 297, 288, 283, 8017, 63, 1000, 356, 283, 396, 63, 585, 63, 24, 297, 288, 283, 4416, 356, 283, 1490, 297, 288, 283, 751, 923, 356, 283, 396, 63, 585, 63, 709, 297, 288, 283, 23779, 356, 283 ]
[ 1898, 20312, 30205, 10811, 12, 3277, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 2859, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 4613, 199, 504, 1683, 492, 1821, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 492, 22913, 2461, 199, 199, 893, 26, 272, 687, 3242, 14, 3112, 14, 1200, 14, 14551, 492, 19516, 63, 5656, 63, 5538, 63, 7175, 199, 2590, 3545, 26, 272, 4613, 14, 2759, 480, 6531, 440, 2248, 1415, 4621, 367, 5343, 401, 2040, 63, 578, 63, 1896, 29, 549, 9, 421, 199, 32, 4462, 14, 5997, 8, 6898, 7130, 29, 549, 9, 199, 318, 1950, 63, 1805, 8, 27899, 304, 272, 1950, 63, 533, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 3112, 14, 1200, 14, 14551, 14, 14551, 63, 5656, 63, 5538, 63, 7175, 14, 3225, 358, 272, 372, 1950, 63, 533, 63, 1805, 421, 199, 545, 83, 63, 842, 275, 22913, 2461, 8, 2105, 63, 1805, 9, 421, 199, 318, 511, 63, 5656, 63, 5538, 63, 7175, 63, 8782, 8, 27899, 304, 272, 4177, 63, 765, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 14, 29089, 14, 3629, 358, 339, 663, 63, 765, 63, 1099, 275, 791, 1205, 356, 283, 3742, 297, 283, 1014, 63, 765, 356, 283, 4030, 297, 283, 1014, 63, 1205, 356, 1926, 93, 272, 663, 63, 765, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 14, 29089, 14, 409, 297, 372, 63, 585, 29, 409, 63, 765, 63, 1099, 9, 339, 1324, 63, 576, 275, 469, 267, 283, 2473, 356, 283, 2113, 297, 267, 283, 929, 356, 283, 1881, 297, 267, 283, 5656, 63, 5538, 63, 7175, 356, 469, 288, 283, 1178, 356, 283, 8017, 297, 288, 283, 2326, 356, 283, 20, 297, 288, 283, 6223, 356, 283, 396, 63, 585, 63, 21, 297, 288, 283, 354, 356, 283, 885, 63, 354, 63, 22, 297, 288, 283, 8707, 63, 1188, 63, 4415, 63, 923, 356, 283, 396, 63, 585, 63, 23, 297, 288, 283, 8017, 63, 1000, 356, 283, 396, 63, 585, 63, 24, 297, 288, 283, 4416, 356, 283, 1490, 297, 288, 283, 751, 923, 356, 283, 396, 63, 585, 63, 709, 297, 288, 283, 23779, 356, 283, 396, 63, 585, 63, 845, 297, 288, 283, 7175, 344, 356, 283, 713, 7, 267, 1660, 267, 283, 23779, 356, 283, 1231, 936, 339, 365, 63, 705, 12, 2896, 12, 1177, 275, 19516, 63, 5656, 63, 5538, 63, 7175, 14, 14551, 63, 5656, 63, 5538, 8, 1210, 63, 576, 12, 15509, 63, 842, 9, 339, 1420, 63, 576, 275, 469, 267, 283, 1178, 356, 283, 8017, 297, 355, 283, 2326, 356, 283, 20, 297, 355, 283, 6223, 356, 283, 396, 63, 585, 63, 21, 297, 355, 283, 354, 356, 283, 885, 63, 354, 63, 22, 297, 355, 283, 8707, 13, 1188, 13, 4415, 13, 923, 356, 283, 396, 63, 585, 63, 23, 297, 355, 283, 8017, 13, 1000, 356, 283, 396, 63, 585, 63, 24, 297, 355, 283, 4416, 356, 283, 1490, 297, 355, 283, 751, 923, 356, 283, 396, 63, 585, 63, 709, 297, 355, 283, 23779, 356, 283, 396, 63, 585, 63, 845, 297, 355, 283, 7175, 344, 356, 283, 713, 7, 272, 789, 339, 663, 63, 765, 63, 1805, 14, 479, 63, 3527, 63, 1045, 360, 5656, 13, 5538, 297, 283, 7175, 297, 666, 29, 2062, 63, 576, 12, 20822, 534, 1231, 358, 272, 4177, 63, 765, 63, 1805, 14, 479, 63, 1397, 63, 3527, 342, 272, 702, 440, 365, 63, 705, 272, 702, 2896, 272, 702, 1177, 459, 1205, 418, 508, 283, 3742, 7, 272, 702, 1177, 459, 1014, 63, 1205, 418, 508, 1926, 421, 199, 318, 511, 63, 5656, 63, 5538, 63, 7175, 63, 8782, 63, 15762, 8, 27899, 304, 272, 4177, 63, 765, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 14, 29089, 14, 3629, 358, 339, 663, 63, 765, 63, 1099, 275, 791, 1205, 356, 283, 705, 297, 283, 1014, 63, 765, 356, 283, 4030, 297, 283, 1014, 63, 1205, 356, 6891, 93, 272, 663, 63, 765, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 14, 29089, 14, 409, 297, 372, 63, 585, 29, 409, 63, 765, 63, 1099, 9, 339, 1324, 63, 576, 275, 469, 267, 283, 2473, 356, 283, 2113, 297, 267, 283, 929, 356, 283, 1881, 297, 267, 283, 5656, 63, 5538, 63, 7175, 356, 469, 288, 283, 1178, 356, 283, 8017, 297, 288, 283, 2326, 356, 283, 20, 297, 288, 283, 6223, 356, 283, 396, 63, 585, 63, 21, 297, 288, 283, 354, 356, 283, 885, 63, 354, 63, 22, 297, 288, 283, 8707, 63, 1188, 63, 4415, 63, 923, 356, 283, 396, 63, 585, 63, 23, 297, 288, 283, 8017, 63, 1000, 356, 283, 396, 63, 585, 63, 24, 297, 288, 283, 4416, 356, 283, 1490, 297, 288, 283, 751, 923, 356, 283,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Lightmatter/django-inlineformfield
.tox/py27/lib/python2.7/site-packages/IPython/html/services/notebooks/tests/test_notebooks_api.py
8
13601
# coding: utf-8 """Test the notebooks webservice API.""" import io import json import os import shutil from unicodedata import normalize pjoin = os.path.join import requests from IPython.html.utils import url_path_join, url_escape from IPython.html.tests.launchnotebook import NotebookTestBase, assert_http_error from IPython.nbformat import current from IPython.nbformat.current import (new_notebook, write, read, new_worksheet, new_heading_cell, to_notebook_json) from IPython.nbformat import v2 from IPython.utils import py3compat from IPython.utils.data import uniq_stable # TODO: Remove this after we create the contents web service and directories are # no longer listed by the notebook web service. def notebooks_only(nb_list): return [nb for nb in nb_list if nb['type']=='notebook'] def dirs_only(nb_list): return [x for x in nb_list if x['type']=='directory'] class NBAPI(object): """Wrapper for notebook API calls.""" def __init__(self, base_url): self.base_url = base_url def _req(self, verb, path, body=None): response = requests.request(verb, url_path_join(self.base_url, 'api/notebooks', path), data=body, ) response.raise_for_status() return response def list(self, path='/'): return self._req('GET', path) def read(self, name, path='/'): return self._req('GET', url_path_join(path, name)) def create_untitled(self, path='/'): return self._req('POST', path) def upload_untitled(self, body, path='/'): return self._req('POST', path, body) def copy_untitled(self, copy_from, path='/'): body = json.dumps({'copy_from':copy_from}) return self._req('POST', path, body) def create(self, name, path='/'): return self._req('PUT', url_path_join(path, name)) def upload(self, name, body, path='/'): return self._req('PUT', url_path_join(path, name), body) def copy(self, copy_from, copy_to, path='/'): body = json.dumps({'copy_from':copy_from}) return self._req('PUT', url_path_join(path, copy_to), body) def save(self, name, body, path='/'): return self._req('PUT', url_path_join(path, name), body) def delete(self, name, path='/'): return self._req('DELETE', url_path_join(path, name)) def rename(self, name, path, new_name): body = json.dumps({'name': new_name}) return self._req('PATCH', url_path_join(path, name), body) def get_checkpoints(self, name, path): return self._req('GET', url_path_join(path, name, 'checkpoints')) def new_checkpoint(self, name, path): return self._req('POST', url_path_join(path, name, 'checkpoints')) def restore_checkpoint(self, name, path, checkpoint_id): return self._req('POST', url_path_join(path, name, 'checkpoints', checkpoint_id)) def delete_checkpoint(self, name, path, checkpoint_id): return self._req('DELETE', url_path_join(path, name, 'checkpoints', checkpoint_id)) class APITest(NotebookTestBase): """Test the kernels web service API""" dirs_nbs = [('', 'inroot'), ('Directory with spaces in', 'inspace'), (u'unicodé', 'innonascii'), ('foo', 'a'), ('foo', 'b'), ('foo', 'name with spaces'), ('foo', u'unicodé'), ('foo/bar', 'baz'), ('ordering', 'A'), ('ordering', 'b'), ('ordering', 'C'), (u'å b', u'ç d'), ] hidden_dirs = ['.hidden', '__pycache__'] dirs = uniq_stable([py3compat.cast_unicode(d) for (d,n) in dirs_nbs]) del dirs[0] # remove '' top_level_dirs = {normalize('NFC', d.split('/')[0]) for d in dirs} def setUp(self): nbdir = self.notebook_dir.name for d in (self.dirs + self.hidden_dirs): d.replace('/', os.sep) if not os.path.isdir(pjoin(nbdir, d)): os.mkdir(pjoin(nbdir, d)) for d, name in self.dirs_nbs: d = d.replace('/', os.sep) with io.open(pjoin(nbdir, d, '%s.ipynb' % name), 'w', encoding='utf-8') as f: nb = new_notebook(name=name) write(nb, f, format='ipynb') self.nb_api = NBAPI(self.base_url()) def tearDown(self): nbdir = self.notebook_dir.name for dname in (list(self.top_level_dirs) + self.hidden_dirs): shutil.rmtree(pjoin(nbdir, dname), ignore_errors=True) if os.path.isfile(pjoin(nbdir, 'inroot.ipynb')): os.unlink(pjoin(nbdir, 'inroot.ipynb')) def test_list_notebooks(self): nbs = notebooks_only(self.nb_api.list().json()) self.assertEqual(len(nbs), 1) self.assertEqual(nbs[0]['name'], 'inroot.ipynb') nbs = notebooks_only(self.nb_api.list('/Directory with spaces in/').json()) self.assertEqual(len(nbs), 1) self.assertEqual(nbs[0]['name'], 'inspace.ipynb') nbs = notebooks_only(self.nb_api.list(u'/unicodé/').json()) self.assertEqual(len(nbs), 1) self.assertEqual(nbs[0]['name'], 'innonascii.ipynb') self.assertEqual(nbs[0]['path'], u'unicodé') nbs = notebooks_only(self.nb_api.list('/foo/bar/').json()) self.assertEqual(len(nbs), 1) self.assertEqual(nbs[0]['name'], 'baz.ipynb') self.assertEqual(nbs[0]['path'], 'foo/bar') nbs = notebooks_only(self.nb_api.list('foo').json()) self.assertEqual(len(nbs), 4) nbnames = { normalize('NFC', n['name']) for n in nbs } expected = [ u'a.ipynb', u'b.ipynb', u'name with spaces.ipynb', u'unicodé.ipynb'] expected = { normalize('NFC', name) for name in expected } self.assertEqual(nbnames, expected) nbs = notebooks_only(self.nb_api.list('ordering').json()) nbnames = [n['name'] for n in nbs] expected = ['A.ipynb', 'b.ipynb', 'C.ipynb'] self.assertEqual(nbnames, expected) def test_list_dirs(self): dirs = dirs_only(self.nb_api.list().json()) dir_names = {normalize('NFC', d['name']) for d in dirs} self.assertEqual(dir_names, self.top_level_dirs) # Excluding hidden dirs def test_list_nonexistant_dir(self): with assert_http_error(404): self.nb_api.list('nonexistant') def test_get_contents(self): for d, name in self.dirs_nbs: nb = self.nb_api.read('%s.ipynb' % name, d+'/').json() self.assertEqual(nb['name'], u'%s.ipynb' % name) self.assertIn('content', nb) self.assertIn('metadata', nb['content']) self.assertIsInstance(nb['content']['metadata'], dict) # Name that doesn't exist - should be a 404 with assert_http_error(404): self.nb_api.read('q.ipynb', 'foo') def _check_nb_created(self, resp, name, path): self.assertEqual(resp.status_code, 201) location_header = py3compat.str_to_unicode(resp.headers['Location']) self.assertEqual(location_header, url_escape(url_path_join(u'/api/notebooks', path, name))) self.assertEqual(resp.json()['name'], name) assert os.path.isfile(pjoin( self.notebook_dir.name, path.replace('/', os.sep), name, )) def test_create_untitled(self): resp = self.nb_api.create_untitled(path=u'å b') self._check_nb_created(resp, 'Untitled0.ipynb', u'å b') # Second time resp = self.nb_api.create_untitled(path=u'å b') self._check_nb_created(resp, 'Untitled1.ipynb', u'å b') # And two directories down resp = self.nb_api.create_untitled(path='foo/bar') self._check_nb_created(resp, 'Untitled0.ipynb', 'foo/bar') def test_upload_untitled(self): nb = new_notebook(name='Upload test') nbmodel = {'content': nb} resp = self.nb_api.upload_untitled(path=u'å b', body=json.dumps(nbmodel)) self._check_nb_created(resp, 'Untitled0.ipynb', u'å b') def test_upload(self): nb = new_notebook(name=u'ignored') nbmodel = {'content': nb} resp = self.nb_api.upload(u'Upload tést.ipynb', path=u'å b', body=json.dumps(nbmodel)) self._check_nb_created(resp, u'Upload tést.ipynb', u'å b') def test_upload_v2(self): nb = v2.new_notebook() ws = v2.new_worksheet() nb.worksheets.append(ws) ws.cells.append(v2.new_code_cell(input='print("hi")')) nbmodel = {'content': nb} resp = self.nb_api.upload(u'Upload tést.ipynb', path=u'å b', body=json.dumps(nbmodel)) self._check_nb_created(resp, u'Upload tést.ipynb', u'å b') resp = self.nb_api.read(u'Upload tést.ipynb', u'å b') data = resp.json() self.assertEqual(data['content']['nbformat'], current.nbformat) self.assertEqual(data['content']['orig_nbformat'], 2) def test_copy_untitled(self): resp = self.nb_api.copy_untitled(u'ç d.ipynb', path=u'å b') self._check_nb_created(resp, u'ç d-Copy0.ipynb', u'å b') def test_copy(self): resp = self.nb_api.copy(u'ç d.ipynb', u'cøpy.ipynb', path=u'å b') self._check_nb_created(resp, u'cøpy.ipynb', u'å b') def test_delete(self): for d, name in self.dirs_nbs: resp = self.nb_api.delete('%s.ipynb' % name, d) self.assertEqual(resp.status_code, 204) for d in self.dirs + ['/']: nbs = notebooks_only(self.nb_api.list(d).json()) self.assertEqual(len(nbs), 0) def test_rename(self): resp = self.nb_api.rename('a.ipynb', 'foo', 'z.ipynb') self.assertEqual(resp.headers['Location'].split('/')[-1], 'z.ipynb') self.assertEqual(resp.json()['name'], 'z.ipynb') assert os.path.isfile(pjoin(self.notebook_dir.name, 'foo', 'z.ipynb')) nbs = notebooks_only(self.nb_api.list('foo').json()) nbnames = set(n['name'] for n in nbs) self.assertIn('z.ipynb', nbnames) self.assertNotIn('a.ipynb', nbnames) def test_rename_existing(self): with assert_http_error(409): self.nb_api.rename('a.ipynb', 'foo', 'b.ipynb') def test_save(self): resp = self.nb_api.read('a.ipynb', 'foo') nbcontent = json.loads(resp.text)['content'] nb = to_notebook_json(nbcontent) ws = new_worksheet() nb.worksheets = [ws] ws.cells.append(new_heading_cell(u'Created by test ³')) nbmodel= {'name': 'a.ipynb', 'path':'foo', 'content': nb} resp = self.nb_api.save('a.ipynb', path='foo', body=json.dumps(nbmodel)) nbfile = pjoin(self.notebook_dir.name, 'foo', 'a.ipynb') with io.open(nbfile, 'r', encoding='utf-8') as f: newnb = read(f, format='ipynb') self.assertEqual(newnb.worksheets[0].cells[0].source, u'Created by test ³') nbcontent = self.nb_api.read('a.ipynb', 'foo').json()['content'] newnb = to_notebook_json(nbcontent) self.assertEqual(newnb.worksheets[0].cells[0].source, u'Created by test ³') # Save and rename nbmodel= {'name': 'a2.ipynb', 'path':'foo/bar', 'content': nb} resp = self.nb_api.save('a.ipynb', path='foo', body=json.dumps(nbmodel)) saved = resp.json() self.assertEqual(saved['name'], 'a2.ipynb') self.assertEqual(saved['path'], 'foo/bar') assert os.path.isfile(pjoin(self.notebook_dir.name,'foo','bar','a2.ipynb')) assert not os.path.isfile(pjoin(self.notebook_dir.name, 'foo', 'a.ipynb')) with assert_http_error(404): self.nb_api.read('a.ipynb', 'foo') def test_checkpoints(self): resp = self.nb_api.read('a.ipynb', 'foo') r = self.nb_api.new_checkpoint('a.ipynb', 'foo') self.assertEqual(r.status_code, 201) cp1 = r.json() self.assertEqual(set(cp1), {'id', 'last_modified'}) self.assertEqual(r.headers['Location'].split('/')[-1], cp1['id']) # Modify it nbcontent = json.loads(resp.text)['content'] nb = to_notebook_json(nbcontent) ws = new_worksheet() nb.worksheets = [ws] hcell = new_heading_cell('Created by test') ws.cells.append(hcell) # Save nbmodel= {'name': 'a.ipynb', 'path':'foo', 'content': nb} resp = self.nb_api.save('a.ipynb', path='foo', body=json.dumps(nbmodel)) # List checkpoints cps = self.nb_api.get_checkpoints('a.ipynb', 'foo').json() self.assertEqual(cps, [cp1]) nbcontent = self.nb_api.read('a.ipynb', 'foo').json()['content'] nb = to_notebook_json(nbcontent) self.assertEqual(nb.worksheets[0].cells[0].source, 'Created by test') # Restore cp1 r = self.nb_api.restore_checkpoint('a.ipynb', 'foo', cp1['id']) self.assertEqual(r.status_code, 204) nbcontent = self.nb_api.read('a.ipynb', 'foo').json()['content'] nb = to_notebook_json(nbcontent) self.assertEqual(nb.worksheets, []) # Delete cp1 r = self.nb_api.delete_checkpoint('a.ipynb', 'foo', cp1['id']) self.assertEqual(r.status_code, 204) cps = self.nb_api.get_checkpoints('a.ipynb', 'foo').json() self.assertEqual(cps, [])
mit
[ 3, 2803, 26, 2774, 13, 24, 199, 624, 774, 314, 5317, 8858, 3330, 1364, 3261, 1041, 199, 199, 646, 5890, 199, 646, 2022, 199, 646, 747, 199, 646, 5145, 199, 504, 23128, 492, 7666, 199, 199, 80, 904, 275, 747, 14, 515, 14, 904, 199, 199, 646, 4145, 199, 199, 504, 16243, 14, 1360, 14, 1208, 492, 1166, 63, 515, 63, 904, 12, 1166, 63, 3765, 199, 504, 16243, 14, 1360, 14, 2219, 14, 9850, 19174, 492, 3390, 2706, 14440, 12, 702, 63, 1014, 63, 705, 199, 504, 16243, 14, 4994, 908, 492, 1453, 199, 504, 16243, 14, 4994, 908, 14, 1818, 492, 334, 1222, 63, 19174, 12, 2218, 12, 1586, 12, 892, 63, 29776, 12, 4228, 892, 63, 13983, 63, 3890, 12, 370, 63, 19174, 63, 1001, 9, 199, 504, 16243, 14, 4994, 908, 492, 373, 18, 199, 504, 16243, 14, 1208, 492, 1134, 19, 5819, 199, 504, 16243, 14, 1208, 14, 576, 492, 625, 9962, 63, 11989, 421, 199, 3, 3254, 26, 5852, 642, 2410, 781, 1218, 314, 4072, 3330, 2435, 436, 6602, 787, 199, 3, 949, 8088, 10532, 701, 314, 20751, 3330, 2435, 14, 199, 318, 5317, 8858, 63, 2118, 8, 4994, 63, 513, 304, 272, 372, 359, 4994, 367, 8526, 315, 8526, 63, 513, 340, 8526, 459, 466, 418, 6803, 19174, 418, 199, 199, 318, 7606, 63, 2118, 8, 4994, 63, 513, 304, 272, 372, 359, 88, 367, 671, 315, 8526, 63, 513, 340, 671, 459, 466, 418, 6803, 3619, 418, 421, 199, 533, 25377, 3735, 8, 785, 304, 272, 408, 4590, 367, 20751, 3261, 4882, 1041, 272, 347, 636, 826, 721, 277, 12, 1300, 63, 633, 304, 267, 291, 14, 1095, 63, 633, 275, 1300, 63, 633, 339, 347, 485, 2103, 8, 277, 12, 16041, 12, 931, 12, 2396, 29, 403, 304, 267, 1177, 275, 4145, 14, 1069, 8, 17050, 12, 355, 1166, 63, 515, 63, 904, 8, 277, 14, 1095, 63, 633, 12, 283, 1246, 15, 4610, 8858, 297, 931, 395, 355, 666, 29, 2030, 12, 267, 776, 267, 1177, 14, 3730, 63, 509, 63, 1205, 342, 267, 372, 1177, 339, 347, 769, 8, 277, 12, 931, 8805, 735, 267, 372, 291, 423, 2103, 360, 2970, 297, 931, 9, 339, 347, 1586, 8, 277, 12, 536, 12, 931, 8805, 735, 267, 372, 291, 423, 2103, 360, 2970, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 430, 339, 347, 1218, 63, 324, 1213, 68, 8, 277, 12, 931, 8805, 735, 267, 372, 291, 423, 2103, 360, 4030, 297, 931, 9, 339, 347, 5802, 63, 324, 1213, 68, 8, 277, 12, 2396, 12, 931, 8805, 735, 267, 372, 291, 423, 2103, 360, 4030, 297, 931, 12, 2396, 9, 339, 347, 1331, 63, 324, 1213, 68, 8, 277, 12, 1331, 63, 504, 12, 931, 8805, 735, 267, 2396, 275, 2022, 14, 4180, 3252, 1574, 63, 504, 356, 1574, 63, 504, 1552, 267, 372, 291, 423, 2103, 360, 4030, 297, 931, 12, 2396, 9, 339, 347, 1218, 8, 277, 12, 536, 12, 931, 8805, 735, 267, 372, 291, 423, 2103, 360, 4013, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 430, 339, 347, 5802, 8, 277, 12, 536, 12, 2396, 12, 931, 8805, 735, 267, 372, 291, 423, 2103, 360, 4013, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 395, 2396, 9, 339, 347, 1331, 8, 277, 12, 1331, 63, 504, 12, 1331, 63, 475, 12, 931, 8805, 735, 267, 2396, 275, 2022, 14, 4180, 3252, 1574, 63, 504, 356, 1574, 63, 504, 1552, 267, 372, 291, 423, 2103, 360, 4013, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 1331, 63, 475, 395, 2396, 9, 339, 347, 3354, 8, 277, 12, 536, 12, 2396, 12, 931, 8805, 735, 267, 372, 291, 423, 2103, 360, 4013, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 395, 2396, 9, 339, 347, 3145, 8, 277, 12, 536, 12, 931, 8805, 735, 267, 372, 291, 423, 2103, 360, 7014, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 430, 339, 347, 11441, 8, 277, 12, 536, 12, 931, 12, 892, 63, 354, 304, 267, 2396, 275, 2022, 14, 4180, 3252, 354, 356, 892, 63, 354, 1552, 267, 372, 291, 423, 2103, 360, 17073, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 395, 2396, 9, 339, 347, 664, 63, 32475, 8, 277, 12, 536, 12, 931, 304, 267, 372, 291, 423, 2103, 360, 2970, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 12, 283, 32475, 1333, 339, 347, 892, 63, 10109, 8, 277, 12, 536, 12, 931, 304, 267, 372, 291, 423, 2103, 360, 4030, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 12, 283, 32475, 1333, 339, 347, 9066, 63, 10109, 8, 277, 12, 536, 12, 931, 12, 9997, 63, 344, 304, 267, 372, 291, 423, 2103, 360, 4030, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 12, 283, 32475, 297, 9997, 63, 344, 430, 339, 347, 3145, 63, 10109, 8, 277, 12, 536, 12, 931, 12, 9997, 63, 344, 304, 267, 372, 291, 423, 2103, 360, 7014, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 12, 283, 32475, 297, 9997, 63, 344, 430, 199, 199, 533, 10319, 649, 597, 8, 20114, 14440, 304, 272, 408, 774, 314, 26091, 3330, 2435, 3261, 624, 272, 7606, 63, 78, 1533, 275, 4274, 297, 283, 262, 1231, 659, 355, 661, 6231, 543, 7883, 315, 297, 283, 262, 2638, 659, 355, 334, 85, 7, 5411, 7889, 5741, 297, 283, 262, 2865, 4371, 659, 355, 661, 1421, 297, 283, 65, 659, 355, 661, 1421, 297, 283, 66, 659, 355, 661, 1421, 297, 283, 354, 543, 7883, 659, 355, 661, 1421, 297, 399, 7, 5411, 7889, 5741, 659, 355, 661, 1421, 15, 1700, 297, 283, 6185, 659, 355, 661, 7128, 297, 283, 33, 659, 355, 661, 7128, 297, 283, 66, 659, 355, 661, 7128, 297, 283, 35, 659, 355, 334, 85, 7, 30234, 330, 297, 399, 7, 15368, 366, 659, 2049, 1622, 272, 8752, 63, 3220, 275, 18953, 5642, 297, 2560, 647, 1637, 17501, 339, 7606, 275, 625, 9962, 63, 11989, 779, 647, 19, 5819, 14, 2931, 63, 2975, 8, 68, 9, 367 ]
[ 2803, 26, 2774, 13, 24, 199, 624, 774, 314, 5317, 8858, 3330, 1364, 3261, 1041, 199, 199, 646, 5890, 199, 646, 2022, 199, 646, 747, 199, 646, 5145, 199, 504, 23128, 492, 7666, 199, 199, 80, 904, 275, 747, 14, 515, 14, 904, 199, 199, 646, 4145, 199, 199, 504, 16243, 14, 1360, 14, 1208, 492, 1166, 63, 515, 63, 904, 12, 1166, 63, 3765, 199, 504, 16243, 14, 1360, 14, 2219, 14, 9850, 19174, 492, 3390, 2706, 14440, 12, 702, 63, 1014, 63, 705, 199, 504, 16243, 14, 4994, 908, 492, 1453, 199, 504, 16243, 14, 4994, 908, 14, 1818, 492, 334, 1222, 63, 19174, 12, 2218, 12, 1586, 12, 892, 63, 29776, 12, 4228, 892, 63, 13983, 63, 3890, 12, 370, 63, 19174, 63, 1001, 9, 199, 504, 16243, 14, 4994, 908, 492, 373, 18, 199, 504, 16243, 14, 1208, 492, 1134, 19, 5819, 199, 504, 16243, 14, 1208, 14, 576, 492, 625, 9962, 63, 11989, 421, 199, 3, 3254, 26, 5852, 642, 2410, 781, 1218, 314, 4072, 3330, 2435, 436, 6602, 787, 199, 3, 949, 8088, 10532, 701, 314, 20751, 3330, 2435, 14, 199, 318, 5317, 8858, 63, 2118, 8, 4994, 63, 513, 304, 272, 372, 359, 4994, 367, 8526, 315, 8526, 63, 513, 340, 8526, 459, 466, 418, 6803, 19174, 418, 199, 199, 318, 7606, 63, 2118, 8, 4994, 63, 513, 304, 272, 372, 359, 88, 367, 671, 315, 8526, 63, 513, 340, 671, 459, 466, 418, 6803, 3619, 418, 421, 199, 533, 25377, 3735, 8, 785, 304, 272, 408, 4590, 367, 20751, 3261, 4882, 1041, 272, 347, 636, 826, 721, 277, 12, 1300, 63, 633, 304, 267, 291, 14, 1095, 63, 633, 275, 1300, 63, 633, 339, 347, 485, 2103, 8, 277, 12, 16041, 12, 931, 12, 2396, 29, 403, 304, 267, 1177, 275, 4145, 14, 1069, 8, 17050, 12, 355, 1166, 63, 515, 63, 904, 8, 277, 14, 1095, 63, 633, 12, 283, 1246, 15, 4610, 8858, 297, 931, 395, 355, 666, 29, 2030, 12, 267, 776, 267, 1177, 14, 3730, 63, 509, 63, 1205, 342, 267, 372, 1177, 339, 347, 769, 8, 277, 12, 931, 8805, 735, 267, 372, 291, 423, 2103, 360, 2970, 297, 931, 9, 339, 347, 1586, 8, 277, 12, 536, 12, 931, 8805, 735, 267, 372, 291, 423, 2103, 360, 2970, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 430, 339, 347, 1218, 63, 324, 1213, 68, 8, 277, 12, 931, 8805, 735, 267, 372, 291, 423, 2103, 360, 4030, 297, 931, 9, 339, 347, 5802, 63, 324, 1213, 68, 8, 277, 12, 2396, 12, 931, 8805, 735, 267, 372, 291, 423, 2103, 360, 4030, 297, 931, 12, 2396, 9, 339, 347, 1331, 63, 324, 1213, 68, 8, 277, 12, 1331, 63, 504, 12, 931, 8805, 735, 267, 2396, 275, 2022, 14, 4180, 3252, 1574, 63, 504, 356, 1574, 63, 504, 1552, 267, 372, 291, 423, 2103, 360, 4030, 297, 931, 12, 2396, 9, 339, 347, 1218, 8, 277, 12, 536, 12, 931, 8805, 735, 267, 372, 291, 423, 2103, 360, 4013, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 430, 339, 347, 5802, 8, 277, 12, 536, 12, 2396, 12, 931, 8805, 735, 267, 372, 291, 423, 2103, 360, 4013, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 395, 2396, 9, 339, 347, 1331, 8, 277, 12, 1331, 63, 504, 12, 1331, 63, 475, 12, 931, 8805, 735, 267, 2396, 275, 2022, 14, 4180, 3252, 1574, 63, 504, 356, 1574, 63, 504, 1552, 267, 372, 291, 423, 2103, 360, 4013, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 1331, 63, 475, 395, 2396, 9, 339, 347, 3354, 8, 277, 12, 536, 12, 2396, 12, 931, 8805, 735, 267, 372, 291, 423, 2103, 360, 4013, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 395, 2396, 9, 339, 347, 3145, 8, 277, 12, 536, 12, 931, 8805, 735, 267, 372, 291, 423, 2103, 360, 7014, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 430, 339, 347, 11441, 8, 277, 12, 536, 12, 931, 12, 892, 63, 354, 304, 267, 2396, 275, 2022, 14, 4180, 3252, 354, 356, 892, 63, 354, 1552, 267, 372, 291, 423, 2103, 360, 17073, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 395, 2396, 9, 339, 347, 664, 63, 32475, 8, 277, 12, 536, 12, 931, 304, 267, 372, 291, 423, 2103, 360, 2970, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 12, 283, 32475, 1333, 339, 347, 892, 63, 10109, 8, 277, 12, 536, 12, 931, 304, 267, 372, 291, 423, 2103, 360, 4030, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 12, 283, 32475, 1333, 339, 347, 9066, 63, 10109, 8, 277, 12, 536, 12, 931, 12, 9997, 63, 344, 304, 267, 372, 291, 423, 2103, 360, 4030, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 12, 283, 32475, 297, 9997, 63, 344, 430, 339, 347, 3145, 63, 10109, 8, 277, 12, 536, 12, 931, 12, 9997, 63, 344, 304, 267, 372, 291, 423, 2103, 360, 7014, 297, 1166, 63, 515, 63, 904, 8, 515, 12, 536, 12, 283, 32475, 297, 9997, 63, 344, 430, 199, 199, 533, 10319, 649, 597, 8, 20114, 14440, 304, 272, 408, 774, 314, 26091, 3330, 2435, 3261, 624, 272, 7606, 63, 78, 1533, 275, 4274, 297, 283, 262, 1231, 659, 355, 661, 6231, 543, 7883, 315, 297, 283, 262, 2638, 659, 355, 334, 85, 7, 5411, 7889, 5741, 297, 283, 262, 2865, 4371, 659, 355, 661, 1421, 297, 283, 65, 659, 355, 661, 1421, 297, 283, 66, 659, 355, 661, 1421, 297, 283, 354, 543, 7883, 659, 355, 661, 1421, 297, 399, 7, 5411, 7889, 5741, 659, 355, 661, 1421, 15, 1700, 297, 283, 6185, 659, 355, 661, 7128, 297, 283, 33, 659, 355, 661, 7128, 297, 283, 66, 659, 355, 661, 7128, 297, 283, 35, 659, 355, 334, 85, 7, 30234, 330, 297, 399, 7, 15368, 366, 659, 2049, 1622, 272, 8752, 63, 3220, 275, 18953, 5642, 297, 2560, 647, 1637, 17501, 339, 7606, 275, 625, 9962, 63, 11989, 779, 647, 19, 5819, 14, 2931, 63, 2975, 8, 68, 9, 367, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Vimos/scikit-learn
sklearn/kernel_approximation.py
7
18505
""" The :mod:`sklearn.kernel_approximation` module implements several approximate kernel feature maps base on Fourier transforms. """ # Author: Andreas Mueller <amueller@ais.uni-bonn.de> # # License: BSD 3 clause import warnings import numpy as np import scipy.sparse as sp from scipy.linalg import svd from .base import BaseEstimator from .base import TransformerMixin from .utils import check_array, check_random_state, as_float_array from .utils.extmath import safe_sparse_dot from .utils.validation import check_is_fitted from .metrics.pairwise import pairwise_kernels class RBFSampler(BaseEstimator, TransformerMixin): """Approximates feature map of an RBF kernel by Monte Carlo approximation of its Fourier transform. It implements a variant of Random Kitchen Sinks.[1] Read more in the :ref:`User Guide <rbf_kernel_approx>`. Parameters ---------- gamma : float Parameter of RBF kernel: exp(-gamma * x^2) n_components : int Number of Monte Carlo samples per original feature. Equals the dimensionality of the computed feature space. random_state : int, RandomState instance or None, optional (default=None) If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by `np.random`. Notes ----- See "Random Features for Large-Scale Kernel Machines" by A. Rahimi and Benjamin Recht. [1] "Weighted Sums of Random Kitchen Sinks: Replacing minimization with randomization in learning" by A. Rahimi and Benjamin Recht. (http://people.eecs.berkeley.edu/~brecht/papers/08.rah.rec.nips.pdf) """ def __init__(self, gamma=1., n_components=100, random_state=None): self.gamma = gamma self.n_components = n_components self.random_state = random_state def fit(self, X, y=None): """Fit the model with X. Samples random projection according to n_features. Parameters ---------- X : {array-like, sparse matrix}, shape (n_samples, n_features) Training data, where n_samples in the number of samples and n_features is the number of features. Returns ------- self : object Returns the transformer. """ X = check_array(X, accept_sparse='csr') random_state = check_random_state(self.random_state) n_features = X.shape[1] self.random_weights_ = (np.sqrt(2 * self.gamma) * random_state.normal( size=(n_features, self.n_components))) self.random_offset_ = random_state.uniform(0, 2 * np.pi, size=self.n_components) return self def transform(self, X, y=None): """Apply the approximate feature map to X. Parameters ---------- X : {array-like, sparse matrix}, shape (n_samples, n_features) New data, where n_samples in the number of samples and n_features is the number of features. Returns ------- X_new : array-like, shape (n_samples, n_components) """ check_is_fitted(self, 'random_weights_') X = check_array(X, accept_sparse='csr') projection = safe_sparse_dot(X, self.random_weights_) projection += self.random_offset_ np.cos(projection, projection) projection *= np.sqrt(2.) / np.sqrt(self.n_components) return projection class SkewedChi2Sampler(BaseEstimator, TransformerMixin): """Approximates feature map of the "skewed chi-squared" kernel by Monte Carlo approximation of its Fourier transform. Read more in the :ref:`User Guide <skewed_chi_kernel_approx>`. Parameters ---------- skewedness : float "skewedness" parameter of the kernel. Needs to be cross-validated. n_components : int number of Monte Carlo samples per original feature. Equals the dimensionality of the computed feature space. random_state : int, RandomState instance or None, optional (default=None) If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by `np.random`. References ---------- See "Random Fourier Approximations for Skewed Multiplicative Histogram Kernels" by Fuxin Li, Catalin Ionescu and Cristian Sminchisescu. See also -------- AdditiveChi2Sampler : A different approach for approximating an additive variant of the chi squared kernel. sklearn.metrics.pairwise.chi2_kernel : The exact chi squared kernel. """ def __init__(self, skewedness=1., n_components=100, random_state=None): self.skewedness = skewedness self.n_components = n_components self.random_state = random_state def fit(self, X, y=None): """Fit the model with X. Samples random projection according to n_features. Parameters ---------- X : array-like, shape (n_samples, n_features) Training data, where n_samples in the number of samples and n_features is the number of features. Returns ------- self : object Returns the transformer. """ X = check_array(X) random_state = check_random_state(self.random_state) n_features = X.shape[1] uniform = random_state.uniform(size=(n_features, self.n_components)) # transform by inverse CDF of sech self.random_weights_ = (1. / np.pi * np.log(np.tan(np.pi / 2. * uniform))) self.random_offset_ = random_state.uniform(0, 2 * np.pi, size=self.n_components) return self def transform(self, X, y=None): """Apply the approximate feature map to X. Parameters ---------- X : array-like, shape (n_samples, n_features) New data, where n_samples in the number of samples and n_features is the number of features. All values of X must be strictly greater than "-skewedness". Returns ------- X_new : array-like, shape (n_samples, n_components) """ check_is_fitted(self, 'random_weights_') X = as_float_array(X, copy=True) X = check_array(X, copy=False) if (X <= -self.skewedness).any(): raise ValueError("X may not contain entries smaller than" " -skewedness.") X += self.skewedness np.log(X, X) projection = safe_sparse_dot(X, self.random_weights_) projection += self.random_offset_ np.cos(projection, projection) projection *= np.sqrt(2.) / np.sqrt(self.n_components) return projection class AdditiveChi2Sampler(BaseEstimator, TransformerMixin): """Approximate feature map for additive chi2 kernel. Uses sampling the fourier transform of the kernel characteristic at regular intervals. Since the kernel that is to be approximated is additive, the components of the input vectors can be treated separately. Each entry in the original space is transformed into 2*sample_steps+1 features, where sample_steps is a parameter of the method. Typical values of sample_steps include 1, 2 and 3. Optimal choices for the sampling interval for certain data ranges can be computed (see the reference). The default values should be reasonable. Read more in the :ref:`User Guide <additive_chi_kernel_approx>`. Parameters ---------- sample_steps : int, optional Gives the number of (complex) sampling points. sample_interval : float, optional Sampling interval. Must be specified when sample_steps not in {1,2,3}. Notes ----- This estimator approximates a slightly different version of the additive chi squared kernel then ``metric.additive_chi2`` computes. See also -------- SkewedChi2Sampler : A Fourier-approximation to a non-additive variant of the chi squared kernel. sklearn.metrics.pairwise.chi2_kernel : The exact chi squared kernel. sklearn.metrics.pairwise.additive_chi2_kernel : The exact additive chi squared kernel. References ---------- See `"Efficient additive kernels via explicit feature maps" <http://www.robots.ox.ac.uk/~vedaldi/assets/pubs/vedaldi11efficient.pdf>`_ A. Vedaldi and A. Zisserman, Pattern Analysis and Machine Intelligence, 2011 """ def __init__(self, sample_steps=2, sample_interval=None): self.sample_steps = sample_steps self.sample_interval = sample_interval def fit(self, X, y=None): """Set parameters.""" X = check_array(X, accept_sparse='csr') if self.sample_interval is None: # See reference, figure 2 c) if self.sample_steps == 1: self.sample_interval_ = 0.8 elif self.sample_steps == 2: self.sample_interval_ = 0.5 elif self.sample_steps == 3: self.sample_interval_ = 0.4 else: raise ValueError("If sample_steps is not in [1, 2, 3]," " you need to provide sample_interval") else: self.sample_interval_ = self.sample_interval return self def transform(self, X, y=None): """Apply approximate feature map to X. Parameters ---------- X : {array-like, sparse matrix}, shape = (n_samples, n_features) Returns ------- X_new : {array, sparse matrix}, \ shape = (n_samples, n_features * (2*sample_steps + 1)) Whether the return value is an array of sparse matrix depends on the type of the input X. """ msg = ("%(name)s is not fitted. Call fit to set the parameters before" " calling transform") check_is_fitted(self, "sample_interval_", msg=msg) X = check_array(X, accept_sparse='csr') sparse = sp.issparse(X) # check if X has negative values. Doesn't play well with np.log. if ((X.data if sparse else X) < 0).any(): raise ValueError("Entries of X must be non-negative.") # zeroth component # 1/cosh = sech # cosh(0) = 1.0 transf = self._transform_sparse if sparse else self._transform_dense return transf(X) def _transform_dense(self, X): non_zero = (X != 0.0) X_nz = X[non_zero] X_step = np.zeros_like(X) X_step[non_zero] = np.sqrt(X_nz * self.sample_interval_) X_new = [X_step] log_step_nz = self.sample_interval_ * np.log(X_nz) step_nz = 2 * X_nz * self.sample_interval_ for j in range(1, self.sample_steps): factor_nz = np.sqrt(step_nz / np.cosh(np.pi * j * self.sample_interval_)) X_step = np.zeros_like(X) X_step[non_zero] = factor_nz * np.cos(j * log_step_nz) X_new.append(X_step) X_step = np.zeros_like(X) X_step[non_zero] = factor_nz * np.sin(j * log_step_nz) X_new.append(X_step) return np.hstack(X_new) def _transform_sparse(self, X): indices = X.indices.copy() indptr = X.indptr.copy() data_step = np.sqrt(X.data * self.sample_interval_) X_step = sp.csr_matrix((data_step, indices, indptr), shape=X.shape, dtype=X.dtype, copy=False) X_new = [X_step] log_step_nz = self.sample_interval_ * np.log(X.data) step_nz = 2 * X.data * self.sample_interval_ for j in range(1, self.sample_steps): factor_nz = np.sqrt(step_nz / np.cosh(np.pi * j * self.sample_interval_)) data_step = factor_nz * np.cos(j * log_step_nz) X_step = sp.csr_matrix((data_step, indices, indptr), shape=X.shape, dtype=X.dtype, copy=False) X_new.append(X_step) data_step = factor_nz * np.sin(j * log_step_nz) X_step = sp.csr_matrix((data_step, indices, indptr), shape=X.shape, dtype=X.dtype, copy=False) X_new.append(X_step) return sp.hstack(X_new) class Nystroem(BaseEstimator, TransformerMixin): """Approximate a kernel map using a subset of the training data. Constructs an approximate feature map for an arbitrary kernel using a subset of the data as basis. Read more in the :ref:`User Guide <nystroem_kernel_approx>`. Parameters ---------- kernel : string or callable, default="rbf" Kernel map to be approximated. A callable should accept two arguments and the keyword arguments passed to this object as kernel_params, and should return a floating point number. n_components : int Number of features to construct. How many data points will be used to construct the mapping. gamma : float, default=None Gamma parameter for the RBF, laplacian, polynomial, exponential chi2 and sigmoid kernels. Interpretation of the default value is left to the kernel; see the documentation for sklearn.metrics.pairwise. Ignored by other kernels. degree : float, default=3 Degree of the polynomial kernel. Ignored by other kernels. coef0 : float, default=1 Zero coefficient for polynomial and sigmoid kernels. Ignored by other kernels. kernel_params : mapping of string to any, optional Additional parameters (keyword arguments) for kernel function passed as callable object. random_state : int, RandomState instance or None, optional (default=None) If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by `np.random`. Attributes ---------- components_ : array, shape (n_components, n_features) Subset of training points used to construct the feature map. component_indices_ : array, shape (n_components) Indices of ``components_`` in the training set. normalization_ : array, shape (n_components, n_components) Normalization matrix needed for embedding. Square root of the kernel matrix on ``components_``. References ---------- * Williams, C.K.I. and Seeger, M. "Using the Nystroem method to speed up kernel machines", Advances in neural information processing systems 2001 * T. Yang, Y. Li, M. Mahdavi, R. Jin and Z. Zhou "Nystroem Method vs Random Fourier Features: A Theoretical and Empirical Comparison", Advances in Neural Information Processing Systems 2012 See also -------- RBFSampler : An approximation to the RBF kernel using random Fourier features. sklearn.metrics.pairwise.kernel_metrics : List of built-in kernels. """ def __init__(self, kernel="rbf", gamma=None, coef0=1, degree=3, kernel_params=None, n_components=100, random_state=None): self.kernel = kernel self.gamma = gamma self.coef0 = coef0 self.degree = degree self.kernel_params = kernel_params self.n_components = n_components self.random_state = random_state def fit(self, X, y=None): """Fit estimator to data. Samples a subset of training points, computes kernel on these and computes normalization matrix. Parameters ---------- X : array-like, shape=(n_samples, n_feature) Training data. """ X = check_array(X, accept_sparse='csr') rnd = check_random_state(self.random_state) n_samples = X.shape[0] # get basis vectors if self.n_components > n_samples: # XXX should we just bail? n_components = n_samples warnings.warn("n_components > n_samples. This is not possible.\n" "n_components was set to n_samples, which results" " in inefficient evaluation of the full kernel.") else: n_components = self.n_components n_components = min(n_samples, n_components) inds = rnd.permutation(n_samples) basis_inds = inds[:n_components] basis = X[basis_inds] basis_kernel = pairwise_kernels(basis, metric=self.kernel, filter_params=True, **self._get_kernel_params()) # sqrt of kernel matrix on basis vectors U, S, V = svd(basis_kernel) S = np.maximum(S, 1e-12) self.normalization_ = np.dot(U / np.sqrt(S), V) self.components_ = basis self.component_indices_ = inds return self def transform(self, X): """Apply feature map to X. Computes an approximate feature map using the kernel between some training points and X. Parameters ---------- X : array-like, shape=(n_samples, n_features) Data to transform. Returns ------- X_transformed : array, shape=(n_samples, n_components) Transformed data. """ check_is_fitted(self, 'components_') X = check_array(X, accept_sparse='csr') kernel_params = self._get_kernel_params() embedded = pairwise_kernels(X, self.components_, metric=self.kernel, filter_params=True, **kernel_params) return np.dot(embedded, self.normalization_.T) def _get_kernel_params(self): params = self.kernel_params if params is None: params = {} if not callable(self.kernel): params['gamma'] = self.gamma params['degree'] = self.degree params['coef0'] = self.coef0 return params
bsd-3-clause
[ 624, 199, 1918, 520, 1494, 1705, 27993, 14, 4989, 63, 11227, 20030, 64, 859, 9031, 9978, 199, 16815, 6897, 5114, 3878, 9033, 1300, 641, 23843, 4446, 18501, 14, 199, 624, 199, 199, 3, 6529, 26, 6061, 264, 305, 603, 13086, 1435, 665, 455, 13086, 1435, 32, 65, 374, 14, 5411, 13, 13520, 78, 14, 271, 30, 199, 3, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 3598, 199, 199, 646, 2680, 465, 980, 199, 646, 7026, 14, 4421, 465, 2249, 199, 504, 7026, 14, 10096, 492, 26937, 199, 199, 504, 1275, 1095, 492, 3523, 13183, 199, 504, 1275, 1095, 492, 30486, 4256, 199, 504, 1275, 1208, 492, 1104, 63, 1144, 12, 1104, 63, 2355, 63, 929, 12, 465, 63, 1609, 63, 1144, 199, 504, 1275, 1208, 14, 832, 3442, 492, 5048, 63, 4421, 63, 3287, 199, 504, 1275, 1208, 14, 6136, 492, 1104, 63, 374, 63, 21903, 199, 504, 1275, 6759, 14, 25069, 492, 24859, 63, 29824, 421, 199, 533, 820, 34, 7079, 865, 82, 8, 1563, 13183, 12, 30486, 4256, 304, 272, 408, 13117, 8221, 18187, 3878, 2341, 402, 376, 820, 12659, 5114, 701, 10953, 266, 14243, 320, 22772, 272, 402, 2399, 23843, 4446, 5793, 14, 339, 2779, 9031, 282, 9854, 402, 9571, 1804, 9414, 287, 428, 2292, 83, 24097, 17, 61, 339, 5574, 1655, 315, 314, 520, 1121, 1705, 1899, 15423, 665, 25853, 63, 4989, 63, 16815, 14943, 339, 3897, 272, 4143, 272, 10169, 520, 2069, 267, 12009, 402, 820, 12659, 5114, 26, 1437, 2801, 7325, 627, 671, 62, 18, 9, 339, 302, 63, 4608, 520, 1109, 267, 4860, 402, 10953, 266, 14243, 320, 5845, 1126, 3379, 3878, 14, 267, 221, 13317, 314, 6240, 6712, 402, 314, 9235, 3878, 4601, 14, 339, 2196, 63, 929, 520, 1109, 12, 22233, 1256, 503, 488, 12, 2716, 334, 885, 29, 403, 9, 267, 982, 1109, 12, 2196, 63, 929, 365, 314, 6347, 1202, 701, 314, 2196, 1329, 4306, 27, 267, 982, 22233, 1256, 12, 2196, 63, 929, 365, 314, 2196, 1329, 4306, 27, 267, 982, 488, 12, 314, 2196, 1329, 4306, 365, 314, 22233, 1256, 1202, 267, 701, 658, 1590, 14, 2355, 2313, 339, 8144, 272, 9063, 272, 1666, 298, 3883, 7949, 2093, 367, 29095, 13, 9944, 24901, 30611, 3746, 2, 701, 437, 14, 3898, 72, 1017, 73, 436, 272, 26844, 16997, 262, 799, 335, 84, 14, 339, 359, 17, 61, 298, 6004, 8364, 12094, 83, 402, 9571, 1804, 9414, 287, 428, 2292, 83, 26, 16000, 13121, 272, 18790, 2072, 543, 2196, 2072, 315, 9328, 2, 701, 437, 14, 3898, 72, 1017, 73, 436, 272, 26844, 16997, 262, 799, 335, 84, 14, 272, 334, 1014, 921, 13562, 14, 69, 23075, 14, 605, 415, 15515, 14, 8654, 22500, 10205, 335, 84, 15, 10443, 83, 15, 2036, 14, 345, 72, 14, 2761, 14, 78, 6142, 14, 5607, 9, 272, 408, 339, 347, 636, 826, 721, 277, 12, 10169, 29, 17, 2020, 302, 63, 4608, 29, 1960, 12, 2196, 63, 929, 29, 403, 304, 267, 291, 14, 7325, 275, 10169, 267, 291, 14, 78, 63, 4608, 275, 302, 63, 4608, 267, 291, 14, 2355, 63, 929, 275, 2196, 63, 929, 339, 347, 5542, 8, 277, 12, 1323, 12, 612, 29, 403, 304, 267, 408, 13776, 314, 1402, 543, 1323, 14, 398, 428, 1889, 2196, 14777, 7182, 370, 302, 63, 3179, 14, 398, 3897, 267, 4143, 267, 1323, 520, 469, 1144, 13, 2930, 12, 5178, 3634, 1386, 2215, 334, 78, 63, 3356, 12, 302, 63, 3179, 9, 288, 22859, 666, 12, 2382, 302, 63, 3356, 315, 314, 1329, 402, 5845, 288, 436, 302, 63, 3179, 365, 314, 1329, 402, 4534, 14, 398, 1803, 267, 5514, 267, 291, 520, 909, 288, 1803, 314, 21484, 14, 267, 408, 398, 1323, 275, 1104, 63, 1144, 8, 56, 12, 4729, 63, 4421, 534, 10101, 358, 267, 2196, 63, 929, 275, 1104, 63, 2355, 63, 929, 8, 277, 14, 2355, 63, 929, 9, 267, 302, 63, 3179, 275, 1323, 14, 1392, 59, 17, 61, 398, 291, 14, 2355, 63, 4916, 63, 275, 334, 1590, 14, 5079, 8, 18, 627, 291, 14, 7325, 9, 627, 2196, 63, 929, 14, 3302, 8, 288, 1568, 2687, 78, 63, 3179, 12, 291, 14, 78, 63, 4608, 1724, 398, 291, 14, 2355, 63, 2743, 63, 275, 2196, 63, 929, 14, 8830, 8, 16, 12, 499, 627, 980, 14, 1038, 12, 8962, 1568, 29, 277, 14, 78, 63, 4608, 9, 267, 372, 291, 339, 347, 5793, 8, 277, 12, 1323, 12, 612, 29, 403, 304, 267, 408, 16581, 314, 19917, 3878, 2341, 370, 1323, 14, 398, 3897, 267, 4143, 267, 1323, 520, 469, 1144, 13, 2930, 12, 5178, 3634, 1386, 2215, 334, 78, 63, 3356, 12, 302, 63, 3179, 9, 288, 7053, 666, 12, 2382, 302, 63, 3356, 315, 314, 1329, 402, 5845, 288, 436, 302, 63, 3179, 365, 314, 1329, 402, 4534, 14, 398, 1803, 267, 5514, 267, 1323, 63, 1222, 520, 1625, 13, 2930, 12, 2215, 334, 78, 63, 3356, 12, 302, 63, 4608, 9, 267, 408, 267, 1104, 63, 374, 63, 21903, 8, 277, 12, 283, 2355, 63, 4916, 15452, 398, 1323, 275, 1104, 63, 1144, 8, 56, 12, 4729, 63, 4421, 534, 10101, 358, 267, 14777, 275, 5048, 63, 4421, 63, 3287, 8, 56, 12, 291, 14, 2355, 63, 4916, 4602, 267, 14777, 847, 291, 14, 2355, 63, 2743, 63, 267, 980, 14, 5197, 8, 16539, 12, 14777, 9, 267, 14777, 9000, 980, 14, 5079, 8, 18, 4959, 1182, 980, 14, 5079, 8, 277, 14, 78, 63, 4608, 9, 267, 372, 14777, 421, 199, 533, 428, 415, 24084, 29218, 18, 27434, 8, 1563, 13183, 12, 30486, 4256, 304, 272, 408, 13117, 8221, 18187, 3878, 2341, 402, 314, 298, 16866, 24084, 23275, 13, 12973, 2, 5114, 701, 10953, 266, 272, 14243, 320, 22772, 402, 2399, 23843, 4446, 5793, 14, 339, 5574, 1655, 315, 314, 520, 1121, 1705, 1899, 15423, 665, 16866, 24084, 63, 13175, 63, 4989, 63, 16815, 14943, 339, 3897, 272, 4143, 272, 18380, 24084, 4171, 520, 2069, 267, 298, 16866, 24084, 4171, 2, 2725, 402, 314, 5114, 14, 29613, 370, 506, 8059, 13, 24372, 14, 339, 302, 63, 4608, 520, 1109, 267, 1329, 402, 10953, 266, 14243, 320, 5845, 1126, 3379, 3878, 14 ]
[ 199, 1918, 520, 1494, 1705, 27993, 14, 4989, 63, 11227, 20030, 64, 859, 9031, 9978, 199, 16815, 6897, 5114, 3878, 9033, 1300, 641, 23843, 4446, 18501, 14, 199, 624, 199, 199, 3, 6529, 26, 6061, 264, 305, 603, 13086, 1435, 665, 455, 13086, 1435, 32, 65, 374, 14, 5411, 13, 13520, 78, 14, 271, 30, 199, 3, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 3598, 199, 199, 646, 2680, 465, 980, 199, 646, 7026, 14, 4421, 465, 2249, 199, 504, 7026, 14, 10096, 492, 26937, 199, 199, 504, 1275, 1095, 492, 3523, 13183, 199, 504, 1275, 1095, 492, 30486, 4256, 199, 504, 1275, 1208, 492, 1104, 63, 1144, 12, 1104, 63, 2355, 63, 929, 12, 465, 63, 1609, 63, 1144, 199, 504, 1275, 1208, 14, 832, 3442, 492, 5048, 63, 4421, 63, 3287, 199, 504, 1275, 1208, 14, 6136, 492, 1104, 63, 374, 63, 21903, 199, 504, 1275, 6759, 14, 25069, 492, 24859, 63, 29824, 421, 199, 533, 820, 34, 7079, 865, 82, 8, 1563, 13183, 12, 30486, 4256, 304, 272, 408, 13117, 8221, 18187, 3878, 2341, 402, 376, 820, 12659, 5114, 701, 10953, 266, 14243, 320, 22772, 272, 402, 2399, 23843, 4446, 5793, 14, 339, 2779, 9031, 282, 9854, 402, 9571, 1804, 9414, 287, 428, 2292, 83, 24097, 17, 61, 339, 5574, 1655, 315, 314, 520, 1121, 1705, 1899, 15423, 665, 25853, 63, 4989, 63, 16815, 14943, 339, 3897, 272, 4143, 272, 10169, 520, 2069, 267, 12009, 402, 820, 12659, 5114, 26, 1437, 2801, 7325, 627, 671, 62, 18, 9, 339, 302, 63, 4608, 520, 1109, 267, 4860, 402, 10953, 266, 14243, 320, 5845, 1126, 3379, 3878, 14, 267, 221, 13317, 314, 6240, 6712, 402, 314, 9235, 3878, 4601, 14, 339, 2196, 63, 929, 520, 1109, 12, 22233, 1256, 503, 488, 12, 2716, 334, 885, 29, 403, 9, 267, 982, 1109, 12, 2196, 63, 929, 365, 314, 6347, 1202, 701, 314, 2196, 1329, 4306, 27, 267, 982, 22233, 1256, 12, 2196, 63, 929, 365, 314, 2196, 1329, 4306, 27, 267, 982, 488, 12, 314, 2196, 1329, 4306, 365, 314, 22233, 1256, 1202, 267, 701, 658, 1590, 14, 2355, 2313, 339, 8144, 272, 9063, 272, 1666, 298, 3883, 7949, 2093, 367, 29095, 13, 9944, 24901, 30611, 3746, 2, 701, 437, 14, 3898, 72, 1017, 73, 436, 272, 26844, 16997, 262, 799, 335, 84, 14, 339, 359, 17, 61, 298, 6004, 8364, 12094, 83, 402, 9571, 1804, 9414, 287, 428, 2292, 83, 26, 16000, 13121, 272, 18790, 2072, 543, 2196, 2072, 315, 9328, 2, 701, 437, 14, 3898, 72, 1017, 73, 436, 272, 26844, 16997, 262, 799, 335, 84, 14, 272, 334, 1014, 921, 13562, 14, 69, 23075, 14, 605, 415, 15515, 14, 8654, 22500, 10205, 335, 84, 15, 10443, 83, 15, 2036, 14, 345, 72, 14, 2761, 14, 78, 6142, 14, 5607, 9, 272, 408, 339, 347, 636, 826, 721, 277, 12, 10169, 29, 17, 2020, 302, 63, 4608, 29, 1960, 12, 2196, 63, 929, 29, 403, 304, 267, 291, 14, 7325, 275, 10169, 267, 291, 14, 78, 63, 4608, 275, 302, 63, 4608, 267, 291, 14, 2355, 63, 929, 275, 2196, 63, 929, 339, 347, 5542, 8, 277, 12, 1323, 12, 612, 29, 403, 304, 267, 408, 13776, 314, 1402, 543, 1323, 14, 398, 428, 1889, 2196, 14777, 7182, 370, 302, 63, 3179, 14, 398, 3897, 267, 4143, 267, 1323, 520, 469, 1144, 13, 2930, 12, 5178, 3634, 1386, 2215, 334, 78, 63, 3356, 12, 302, 63, 3179, 9, 288, 22859, 666, 12, 2382, 302, 63, 3356, 315, 314, 1329, 402, 5845, 288, 436, 302, 63, 3179, 365, 314, 1329, 402, 4534, 14, 398, 1803, 267, 5514, 267, 291, 520, 909, 288, 1803, 314, 21484, 14, 267, 408, 398, 1323, 275, 1104, 63, 1144, 8, 56, 12, 4729, 63, 4421, 534, 10101, 358, 267, 2196, 63, 929, 275, 1104, 63, 2355, 63, 929, 8, 277, 14, 2355, 63, 929, 9, 267, 302, 63, 3179, 275, 1323, 14, 1392, 59, 17, 61, 398, 291, 14, 2355, 63, 4916, 63, 275, 334, 1590, 14, 5079, 8, 18, 627, 291, 14, 7325, 9, 627, 2196, 63, 929, 14, 3302, 8, 288, 1568, 2687, 78, 63, 3179, 12, 291, 14, 78, 63, 4608, 1724, 398, 291, 14, 2355, 63, 2743, 63, 275, 2196, 63, 929, 14, 8830, 8, 16, 12, 499, 627, 980, 14, 1038, 12, 8962, 1568, 29, 277, 14, 78, 63, 4608, 9, 267, 372, 291, 339, 347, 5793, 8, 277, 12, 1323, 12, 612, 29, 403, 304, 267, 408, 16581, 314, 19917, 3878, 2341, 370, 1323, 14, 398, 3897, 267, 4143, 267, 1323, 520, 469, 1144, 13, 2930, 12, 5178, 3634, 1386, 2215, 334, 78, 63, 3356, 12, 302, 63, 3179, 9, 288, 7053, 666, 12, 2382, 302, 63, 3356, 315, 314, 1329, 402, 5845, 288, 436, 302, 63, 3179, 365, 314, 1329, 402, 4534, 14, 398, 1803, 267, 5514, 267, 1323, 63, 1222, 520, 1625, 13, 2930, 12, 2215, 334, 78, 63, 3356, 12, 302, 63, 4608, 9, 267, 408, 267, 1104, 63, 374, 63, 21903, 8, 277, 12, 283, 2355, 63, 4916, 15452, 398, 1323, 275, 1104, 63, 1144, 8, 56, 12, 4729, 63, 4421, 534, 10101, 358, 267, 14777, 275, 5048, 63, 4421, 63, 3287, 8, 56, 12, 291, 14, 2355, 63, 4916, 4602, 267, 14777, 847, 291, 14, 2355, 63, 2743, 63, 267, 980, 14, 5197, 8, 16539, 12, 14777, 9, 267, 14777, 9000, 980, 14, 5079, 8, 18, 4959, 1182, 980, 14, 5079, 8, 277, 14, 78, 63, 4608, 9, 267, 372, 14777, 421, 199, 533, 428, 415, 24084, 29218, 18, 27434, 8, 1563, 13183, 12, 30486, 4256, 304, 272, 408, 13117, 8221, 18187, 3878, 2341, 402, 314, 298, 16866, 24084, 23275, 13, 12973, 2, 5114, 701, 10953, 266, 272, 14243, 320, 22772, 402, 2399, 23843, 4446, 5793, 14, 339, 5574, 1655, 315, 314, 520, 1121, 1705, 1899, 15423, 665, 16866, 24084, 63, 13175, 63, 4989, 63, 16815, 14943, 339, 3897, 272, 4143, 272, 18380, 24084, 4171, 520, 2069, 267, 298, 16866, 24084, 4171, 2, 2725, 402, 314, 5114, 14, 29613, 370, 506, 8059, 13, 24372, 14, 339, 302, 63, 4608, 520, 1109, 267, 1329, 402, 10953, 266, 14243, 320, 5845, 1126, 3379, 3878, 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, 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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 ]
FederatedAI/FATE
examples/pipeline/hetero_feature_selection/pipeline-hetero-feature-selection-select-cols.py
1
3581
# # Copyright 2019 The FATE Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import argparse import os import sys cur_path = os.path.realpath(__file__) for i in range(4): cur_path = os.path.dirname(cur_path) print(f'fate_path: {cur_path}') sys.path.append(cur_path) from examples.pipeline.hetero_feature_selection import common_tools from pipeline.utils.tools import load_job_config from pipeline.runtime.entity import JobParameters def main(config="../../config.yaml", namespace=""): # obtain config if isinstance(config, str): config = load_job_config(config) backend = config.backend work_mode = config.work_mode binning_param = { "name": 'hetero_feature_binning_0', "method": "quantile", "compress_thres": 10000, "head_size": 10000, "error": 0.001, "bin_num": 10, "bin_indexes": -1, "bin_names": None, "category_indexes": None, "category_names": None, "adjustment_factor": 0.5, "local_only": False, "transform_param": { "transform_cols": -1, "transform_names": None, "transform_type": "bin_num" } } selection_param = { "name": "hetero_feature_selection_0", "select_col_indexes": [ 1, 2, 3, 4 ], "select_names": [], "filter_methods": [ "manually", "unique_value", "iv_value_thres", "coefficient_of_variation_value_thres", "iv_percentile", "outlier_cols" ], "manually_param": { "filter_out_indexes": [], "filter_out_names": [] }, "unique_param": { "eps": 1e-06 }, "iv_value_param": { "value_threshold": 0.1 }, "iv_percentile_param": { "percentile_threshold": 0.9 }, "variance_coe_param": { "value_threshold": 0.3 }, "outlier_param": { "percentile": 0.95, "upper_threshold": 2.0 }} statistic_param = { "name": "statistic_0", "statistics": ["95%", "coefficient_of_variance", "stddev"], "column_indexes": -1, "column_names": [] } pipeline = common_tools.make_normal_dsl(config, namespace, selection_param, binning_param=binning_param, statistic_param=statistic_param) job_parameters = JobParameters(backend=backend, work_mode=work_mode) pipeline.fit(job_parameters) common_tools.prettify(pipeline.get_component("hetero_feature_selection_0").get_summary()) if __name__ == "__main__": parser = argparse.ArgumentParser("PIPELINE DEMO") parser.add_argument("-config", type=str, help="config file") args = parser.parse_args() if args.config is not None: main(args.config) else: main()
apache-2.0
[ 3, 199, 3, 221, 1898, 20312, 710, 481, 1951, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 221, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 221, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 221, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 221, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 221, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 221, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 221, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 7534, 199, 646, 747, 199, 646, 984, 199, 199, 895, 63, 515, 275, 747, 14, 515, 14, 11091, 3460, 493, 3368, 199, 509, 284, 315, 1425, 8, 20, 304, 272, 1094, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 895, 63, 515, 9, 199, 1361, 8, 70, 7, 70, 323, 63, 515, 26, 469, 895, 63, 515, 12216, 199, 1274, 14, 515, 14, 740, 8, 895, 63, 515, 9, 199, 199, 504, 7251, 14, 7379, 14, 426, 24208, 63, 4445, 63, 5592, 492, 2863, 63, 2537, 199, 504, 7679, 14, 1208, 14, 2537, 492, 2248, 63, 2423, 63, 888, 199, 504, 7679, 14, 7726, 14, 4502, 492, 15057, 5976, 421, 199, 318, 2446, 8, 888, 628, 9707, 888, 14, 5963, 401, 3231, 17364, 272, 327, 3332, 1101, 272, 340, 1228, 8, 888, 12, 620, 304, 267, 1101, 275, 2248, 63, 2423, 63, 888, 8, 888, 9, 272, 4865, 275, 1101, 14, 4620, 272, 1736, 63, 632, 275, 1101, 14, 800, 63, 632, 339, 2517, 1835, 63, 635, 275, 469, 267, 298, 354, 582, 283, 426, 24208, 63, 4445, 63, 1393, 1835, 63, 16, 297, 267, 298, 765, 582, 298, 29249, 401, 267, 298, 6447, 63, 273, 470, 582, 11630, 12, 267, 298, 2993, 63, 890, 582, 11630, 12, 267, 298, 705, 582, 378, 14, 4587, 12, 267, 298, 1393, 63, 1507, 582, 1616, 12, 267, 298, 1393, 63, 10116, 582, 446, 17, 12, 267, 298, 1393, 63, 1247, 582, 488, 12, 267, 298, 3710, 63, 10116, 582, 488, 12, 267, 298, 3710, 63, 1247, 582, 488, 12, 267, 298, 21806, 63, 4778, 582, 378, 14, 21, 12, 267, 298, 1832, 63, 2118, 582, 756, 12, 267, 298, 4711, 63, 635, 582, 469, 288, 298, 4711, 63, 4574, 582, 446, 17, 12, 288, 298, 4711, 63, 1247, 582, 488, 12, 288, 298, 4711, 63, 466, 582, 298, 1393, 63, 1507, 2, 267, 789, 272, 789, 339, 7267, 63, 635, 275, 469, 267, 298, 354, 582, 298, 426, 24208, 63, 4445, 63, 5592, 63, 16, 401, 267, 298, 2416, 63, 761, 63, 10116, 582, 359, 288, 413, 12, 288, 499, 12, 288, 650, 12, 288, 841, 267, 2156, 267, 298, 2416, 63, 1247, 582, 990, 267, 298, 1541, 63, 2474, 582, 359, 288, 298, 1237, 3163, 401, 288, 298, 3235, 63, 585, 401, 288, 298, 1003, 63, 585, 63, 273, 470, 401, 288, 298, 21329, 63, 1618, 63, 3808, 425, 63, 585, 63, 273, 470, 401, 288, 298, 1003, 63, 21188, 401, 288, 298, 548, 5697, 63, 4574, 2, 267, 2156, 267, 298, 1237, 3163, 63, 635, 582, 469, 288, 298, 1541, 63, 548, 63, 10116, 582, 990, 288, 298, 1541, 63, 548, 63, 1247, 582, 942, 267, 1660, 267, 298, 3235, 63, 635, 582, 469, 288, 298, 8277, 582, 413, 69, 13, 1690, 267, 1660, 267, 298, 1003, 63, 585, 63, 635, 582, 469, 288, 298, 585, 63, 7227, 582, 378, 14, 17, 267, 1660, 267, 298, 1003, 63, 21188, 63, 635, 582, 469, 288, 298, 21188, 63, 7227, 582, 378, 14, 25, 267, 1660, 267, 298, 6221, 63, 331, 69, 63, 635, 582, 469, 288, 298, 585, 63, 7227, 582, 378, 14, 19, 267, 1660, 267, 298, 548, 5697, 63, 635, 582, 469, 288, 298, 21188, 582, 378, 14, 2720, 12, 288, 298, 4142, 63, 7227, 582, 499, 14, 16, 267, 3586, 339, 22394, 63, 635, 275, 469, 267, 298, 354, 582, 298, 26065, 63, 16, 401, 267, 298, 13724, 582, 2097, 2720, 31181, 298, 21329, 63, 1618, 63, 6221, 401, 298, 21672, 2255, 267, 298, 2301, 63, 10116, 582, 446, 17, 12, 267, 298, 2301, 63, 1247, 582, 942, 272, 789, 339, 7679, 275, 2863, 63, 2537, 14, 1875, 63, 3302, 63, 795, 76, 8, 888, 12, 3231, 12, 7267, 63, 635, 12, 4490, 2517, 1835, 63, 635, 29, 1393, 1835, 63, 635, 12, 4490, 22394, 63, 635, 29, 26065, 63, 635, 9, 272, 3906, 63, 3214, 275, 15057, 5976, 8, 4620, 29, 4620, 12, 1736, 63, 632, 29, 800, 63, 632, 9, 272, 7679, 14, 3269, 8, 2423, 63, 3214, 9, 272, 2863, 63, 2537, 14, 25133, 3338, 8, 7379, 14, 362, 63, 3173, 480, 426, 24208, 63, 4445, 63, 5592, 63, 16, 3471, 362, 63, 4705, 1012, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 1798, 275, 7534, 14, 10730, 480, 6089, 6174, 3265, 2679, 531, 272, 1798, 14, 525, 63, 2094, 6096, 888, 401, 730, 29, 495, 12, 717, 1720, 628, 888, 570, 531, 272, 1249, 275, 1798, 14, 1122, 63, 589, 342, 272, 340, 1249, 14, 888, 365, 440, 488, 26, 267, 2446, 8, 589, 14, 888, 9, 272, 587, 26, 267, 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 ]
[ 199, 3, 221, 1898, 20312, 710, 481, 1951, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 221, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 221, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 221, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 221, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 221, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 221, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 221, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 7534, 199, 646, 747, 199, 646, 984, 199, 199, 895, 63, 515, 275, 747, 14, 515, 14, 11091, 3460, 493, 3368, 199, 509, 284, 315, 1425, 8, 20, 304, 272, 1094, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 895, 63, 515, 9, 199, 1361, 8, 70, 7, 70, 323, 63, 515, 26, 469, 895, 63, 515, 12216, 199, 1274, 14, 515, 14, 740, 8, 895, 63, 515, 9, 199, 199, 504, 7251, 14, 7379, 14, 426, 24208, 63, 4445, 63, 5592, 492, 2863, 63, 2537, 199, 504, 7679, 14, 1208, 14, 2537, 492, 2248, 63, 2423, 63, 888, 199, 504, 7679, 14, 7726, 14, 4502, 492, 15057, 5976, 421, 199, 318, 2446, 8, 888, 628, 9707, 888, 14, 5963, 401, 3231, 17364, 272, 327, 3332, 1101, 272, 340, 1228, 8, 888, 12, 620, 304, 267, 1101, 275, 2248, 63, 2423, 63, 888, 8, 888, 9, 272, 4865, 275, 1101, 14, 4620, 272, 1736, 63, 632, 275, 1101, 14, 800, 63, 632, 339, 2517, 1835, 63, 635, 275, 469, 267, 298, 354, 582, 283, 426, 24208, 63, 4445, 63, 1393, 1835, 63, 16, 297, 267, 298, 765, 582, 298, 29249, 401, 267, 298, 6447, 63, 273, 470, 582, 11630, 12, 267, 298, 2993, 63, 890, 582, 11630, 12, 267, 298, 705, 582, 378, 14, 4587, 12, 267, 298, 1393, 63, 1507, 582, 1616, 12, 267, 298, 1393, 63, 10116, 582, 446, 17, 12, 267, 298, 1393, 63, 1247, 582, 488, 12, 267, 298, 3710, 63, 10116, 582, 488, 12, 267, 298, 3710, 63, 1247, 582, 488, 12, 267, 298, 21806, 63, 4778, 582, 378, 14, 21, 12, 267, 298, 1832, 63, 2118, 582, 756, 12, 267, 298, 4711, 63, 635, 582, 469, 288, 298, 4711, 63, 4574, 582, 446, 17, 12, 288, 298, 4711, 63, 1247, 582, 488, 12, 288, 298, 4711, 63, 466, 582, 298, 1393, 63, 1507, 2, 267, 789, 272, 789, 339, 7267, 63, 635, 275, 469, 267, 298, 354, 582, 298, 426, 24208, 63, 4445, 63, 5592, 63, 16, 401, 267, 298, 2416, 63, 761, 63, 10116, 582, 359, 288, 413, 12, 288, 499, 12, 288, 650, 12, 288, 841, 267, 2156, 267, 298, 2416, 63, 1247, 582, 990, 267, 298, 1541, 63, 2474, 582, 359, 288, 298, 1237, 3163, 401, 288, 298, 3235, 63, 585, 401, 288, 298, 1003, 63, 585, 63, 273, 470, 401, 288, 298, 21329, 63, 1618, 63, 3808, 425, 63, 585, 63, 273, 470, 401, 288, 298, 1003, 63, 21188, 401, 288, 298, 548, 5697, 63, 4574, 2, 267, 2156, 267, 298, 1237, 3163, 63, 635, 582, 469, 288, 298, 1541, 63, 548, 63, 10116, 582, 990, 288, 298, 1541, 63, 548, 63, 1247, 582, 942, 267, 1660, 267, 298, 3235, 63, 635, 582, 469, 288, 298, 8277, 582, 413, 69, 13, 1690, 267, 1660, 267, 298, 1003, 63, 585, 63, 635, 582, 469, 288, 298, 585, 63, 7227, 582, 378, 14, 17, 267, 1660, 267, 298, 1003, 63, 21188, 63, 635, 582, 469, 288, 298, 21188, 63, 7227, 582, 378, 14, 25, 267, 1660, 267, 298, 6221, 63, 331, 69, 63, 635, 582, 469, 288, 298, 585, 63, 7227, 582, 378, 14, 19, 267, 1660, 267, 298, 548, 5697, 63, 635, 582, 469, 288, 298, 21188, 582, 378, 14, 2720, 12, 288, 298, 4142, 63, 7227, 582, 499, 14, 16, 267, 3586, 339, 22394, 63, 635, 275, 469, 267, 298, 354, 582, 298, 26065, 63, 16, 401, 267, 298, 13724, 582, 2097, 2720, 31181, 298, 21329, 63, 1618, 63, 6221, 401, 298, 21672, 2255, 267, 298, 2301, 63, 10116, 582, 446, 17, 12, 267, 298, 2301, 63, 1247, 582, 942, 272, 789, 339, 7679, 275, 2863, 63, 2537, 14, 1875, 63, 3302, 63, 795, 76, 8, 888, 12, 3231, 12, 7267, 63, 635, 12, 4490, 2517, 1835, 63, 635, 29, 1393, 1835, 63, 635, 12, 4490, 22394, 63, 635, 29, 26065, 63, 635, 9, 272, 3906, 63, 3214, 275, 15057, 5976, 8, 4620, 29, 4620, 12, 1736, 63, 632, 29, 800, 63, 632, 9, 272, 7679, 14, 3269, 8, 2423, 63, 3214, 9, 272, 2863, 63, 2537, 14, 25133, 3338, 8, 7379, 14, 362, 63, 3173, 480, 426, 24208, 63, 4445, 63, 5592, 63, 16, 3471, 362, 63, 4705, 1012, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 1798, 275, 7534, 14, 10730, 480, 6089, 6174, 3265, 2679, 531, 272, 1798, 14, 525, 63, 2094, 6096, 888, 401, 730, 29, 495, 12, 717, 1720, 628, 888, 570, 531, 272, 1249, 275, 1798, 14, 1122, 63, 589, 342, 272, 340, 1249, 14, 888, 365, 440, 488, 26, 267, 2446, 8, 589, 14, 888, 9, 272, 587, 26, 267, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
saimn/glue
glue/core/tests/test_simpleforms.py
5
1401
from __future__ import absolute_import, division, print_function import pytest from ..simpleforms import IntOption, FloatOption, BoolOption class Stub(object): int_opt = IntOption(min=0, max=10, default=3) float_opt = FloatOption(min=1, max=2, default=1.5) bool_opt = BoolOption() class TestSimpleForms(object): def test_get_set_int(self): assert Stub.int_opt.min == 0 assert Stub.int_opt.max == 10 assert Stub().int_opt == 3 def test_get_set_bool(self): s = Stub() assert s.bool_opt is False s.bool_opt = True assert s.bool_opt def test_get_set_float(self): s = Stub() assert s.float_opt == 1.5 s.float_opt = 1 assert s.float_opt == 1.0 assert isinstance(s.float_opt, float) def test_invalid_int(self): s = Stub() s.int_opt = 4 with pytest.raises(ValueError): s.int_opt = -1 with pytest.raises(ValueError): s.int_opt = 11 with pytest.raises(ValueError): s.int_opt = 2.5 def test_invalid_float(self): s = Stub() with pytest.raises(ValueError): s.float_opt = -0.1 with pytest.raises(ValueError): s.float_opt = 10.1 def test_invalid(self): s = Stub() with pytest.raises(ValueError): s.bool_opt = 3
bsd-3-clause
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 199, 646, 4613, 199, 199, 504, 2508, 4129, 3351, 492, 9805, 2602, 12, 11140, 2602, 12, 19287, 2602, 421, 199, 533, 23429, 8, 785, 304, 272, 1109, 63, 2992, 275, 9805, 2602, 8, 827, 29, 16, 12, 1390, 29, 709, 12, 849, 29, 19, 9, 272, 2069, 63, 2992, 275, 11140, 2602, 8, 827, 29, 17, 12, 1390, 29, 18, 12, 849, 29, 17, 14, 21, 9, 272, 2155, 63, 2992, 275, 19287, 2602, 342, 421, 199, 533, 1379, 3184, 26028, 8, 785, 304, 339, 347, 511, 63, 362, 63, 409, 63, 442, 8, 277, 304, 267, 702, 23429, 14, 442, 63, 2992, 14, 827, 508, 378, 267, 702, 23429, 14, 442, 63, 2992, 14, 988, 508, 1616, 267, 702, 23429, 1252, 442, 63, 2992, 508, 650, 339, 347, 511, 63, 362, 63, 409, 63, 2245, 8, 277, 304, 267, 308, 275, 23429, 342, 267, 702, 308, 14, 2245, 63, 2992, 365, 756, 267, 308, 14, 2245, 63, 2992, 275, 715, 267, 702, 308, 14, 2245, 63, 2992, 339, 347, 511, 63, 362, 63, 409, 63, 1609, 8, 277, 304, 398, 308, 275, 23429, 342, 267, 702, 308, 14, 1609, 63, 2992, 508, 413, 14, 21, 398, 308, 14, 1609, 63, 2992, 275, 413, 267, 702, 308, 14, 1609, 63, 2992, 508, 413, 14, 16, 267, 702, 1228, 8, 83, 14, 1609, 63, 2992, 12, 2069, 9, 339, 347, 511, 63, 3197, 63, 442, 8, 277, 304, 398, 308, 275, 23429, 342, 267, 308, 14, 442, 63, 2992, 275, 841, 398, 543, 4613, 14, 3536, 8, 3393, 304, 288, 308, 14, 442, 63, 2992, 275, 446, 17, 398, 543, 4613, 14, 3536, 8, 3393, 304, 288, 308, 14, 442, 63, 2992, 275, 4119, 398, 543, 4613, 14, 3536, 8, 3393, 304, 288, 308, 14, 442, 63, 2992, 275, 499, 14, 21, 339, 347, 511, 63, 3197, 63, 1609, 8, 277, 304, 267, 308, 275, 23429, 342, 398, 543, 4613, 14, 3536, 8, 3393, 304, 288, 308, 14, 1609, 63, 2992, 275, 446, 16, 14, 17, 398, 543, 4613, 14, 3536, 8, 3393, 304, 288, 308, 14, 1609, 63, 2992, 275, 1616, 14, 17, 339, 347, 511, 63, 3197, 8, 277, 304, 267, 308, 275, 23429, 342, 398, 543, 4613, 14, 3536, 8, 3393, 304, 288, 308, 14, 2245, 63, 2992, 275, 650, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 199, 646, 4613, 199, 199, 504, 2508, 4129, 3351, 492, 9805, 2602, 12, 11140, 2602, 12, 19287, 2602, 421, 199, 533, 23429, 8, 785, 304, 272, 1109, 63, 2992, 275, 9805, 2602, 8, 827, 29, 16, 12, 1390, 29, 709, 12, 849, 29, 19, 9, 272, 2069, 63, 2992, 275, 11140, 2602, 8, 827, 29, 17, 12, 1390, 29, 18, 12, 849, 29, 17, 14, 21, 9, 272, 2155, 63, 2992, 275, 19287, 2602, 342, 421, 199, 533, 1379, 3184, 26028, 8, 785, 304, 339, 347, 511, 63, 362, 63, 409, 63, 442, 8, 277, 304, 267, 702, 23429, 14, 442, 63, 2992, 14, 827, 508, 378, 267, 702, 23429, 14, 442, 63, 2992, 14, 988, 508, 1616, 267, 702, 23429, 1252, 442, 63, 2992, 508, 650, 339, 347, 511, 63, 362, 63, 409, 63, 2245, 8, 277, 304, 267, 308, 275, 23429, 342, 267, 702, 308, 14, 2245, 63, 2992, 365, 756, 267, 308, 14, 2245, 63, 2992, 275, 715, 267, 702, 308, 14, 2245, 63, 2992, 339, 347, 511, 63, 362, 63, 409, 63, 1609, 8, 277, 304, 398, 308, 275, 23429, 342, 267, 702, 308, 14, 1609, 63, 2992, 508, 413, 14, 21, 398, 308, 14, 1609, 63, 2992, 275, 413, 267, 702, 308, 14, 1609, 63, 2992, 508, 413, 14, 16, 267, 702, 1228, 8, 83, 14, 1609, 63, 2992, 12, 2069, 9, 339, 347, 511, 63, 3197, 63, 442, 8, 277, 304, 398, 308, 275, 23429, 342, 267, 308, 14, 442, 63, 2992, 275, 841, 398, 543, 4613, 14, 3536, 8, 3393, 304, 288, 308, 14, 442, 63, 2992, 275, 446, 17, 398, 543, 4613, 14, 3536, 8, 3393, 304, 288, 308, 14, 442, 63, 2992, 275, 4119, 398, 543, 4613, 14, 3536, 8, 3393, 304, 288, 308, 14, 442, 63, 2992, 275, 499, 14, 21, 339, 347, 511, 63, 3197, 63, 1609, 8, 277, 304, 267, 308, 275, 23429, 342, 398, 543, 4613, 14, 3536, 8, 3393, 304, 288, 308, 14, 1609, 63, 2992, 275, 446, 16, 14, 17, 398, 543, 4613, 14, 3536, 8, 3393, 304, 288, 308, 14, 1609, 63, 2992, 275, 1616, 14, 17, 339, 347, 511, 63, 3197, 8, 277, 304, 267, 308, 275, 23429, 342, 398, 543, 4613, 14, 3536, 8, 3393, 304, 288, 308, 14, 2245, 63, 2992, 275, 650, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
s0undt3ch/cookiecutter-pytest-plugin
pytest-{{cookiecutter.plugin_name}}/tests/test_{{cookiecutter.plugin_name}}.py
1
1500
# -*- coding: utf-8 -*- def test_bar_fixture(testdir): """Make sure that pytest accepts our fixture.""" # create a temporary pytest test module testdir.makepyfile(""" def test_sth(bar): assert bar == "europython2015" """) # run pytest with the following cmd args result = testdir.runpytest( '--foo=europython2015', '-v' ) # fnmatch_lines does an assertion internally result.stdout.fnmatch_lines([ '*::test_sth PASSED', ]) # make sure that that we get a '0' exit code for the testsuite assert result.ret == 0 def test_help_message(testdir): result = testdir.runpytest( '--help', ) # fnmatch_lines does an assertion internally result.stdout.fnmatch_lines([ '{{cookiecutter.plugin_name}}:', '*--foo=DEST_FOO*Set the value for the fixture "bar".', ]) def test_hello_ini_setting(testdir): testdir.makeini(""" [pytest] HELLO = world """) testdir.makepyfile(""" import pytest @pytest.fixture def hello(request): return request.config.getini('HELLO') def test_hello_world(hello): assert hello == 'world' """) result = testdir.runpytest('-v') # fnmatch_lines does an assertion internally result.stdout.fnmatch_lines([ '*::test_hello_world PASSED', ]) # make sure that that we get a '0' exit code for the testsuite assert result.ret == 0
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 421, 199, 318, 511, 63, 1700, 63, 5997, 8, 16634, 304, 272, 408, 5483, 3238, 626, 4613, 11479, 4154, 10949, 1041, 339, 327, 1218, 282, 7937, 4613, 511, 859, 272, 7368, 14, 17358, 4852, 267, 347, 511, 63, 17082, 8, 1700, 304, 288, 702, 4681, 508, 298, 27089, 1548, 7806, 2, 272, 7857, 339, 327, 1255, 4613, 543, 314, 2569, 2088, 1249, 272, 754, 275, 7368, 14, 19889, 8, 267, 2850, 1421, 29, 27089, 1548, 7806, 297, 267, 2475, 86, 7, 272, 776, 339, 327, 15951, 63, 1278, 1630, 376, 14412, 14448, 272, 754, 14, 2703, 14, 15359, 63, 1278, 779, 267, 6438, 447, 396, 63, 17082, 510, 32032, 297, 272, 4794, 339, 327, 1852, 3238, 626, 626, 781, 664, 282, 283, 16, 7, 4458, 1233, 367, 314, 2295, 2577, 272, 702, 754, 14, 3292, 508, 378, 421, 199, 318, 511, 63, 3437, 63, 1188, 8, 16634, 304, 272, 754, 275, 7368, 14, 19889, 8, 267, 2850, 3437, 297, 272, 776, 272, 327, 15951, 63, 1278, 1630, 376, 14412, 14448, 272, 754, 14, 2703, 14, 15359, 63, 1278, 779, 267, 11400, 331, 745, 73, 825, 18404, 14, 2718, 63, 354, 4863, 6536, 267, 6438, 306, 1421, 29, 19374, 63, 13046, 10, 1084, 314, 574, 367, 314, 10949, 298, 1700, 1674, 297, 272, 4794, 421, 199, 318, 511, 63, 5006, 63, 2730, 63, 6031, 8, 16634, 304, 272, 7368, 14, 1875, 2730, 4852, 267, 359, 4462, 61, 267, 25734, 1484, 275, 6701, 272, 7857, 339, 7368, 14, 17358, 4852, 267, 492, 4613, 398, 768, 4462, 14, 5997, 267, 347, 16509, 8, 1069, 304, 288, 372, 1056, 14, 888, 14, 362, 2730, 360, 24771, 1484, 358, 398, 347, 511, 63, 5006, 63, 7617, 8, 5006, 304, 288, 702, 16509, 508, 283, 7617, 7, 272, 7857, 339, 754, 275, 7368, 14, 19889, 3654, 86, 358, 339, 327, 15951, 63, 1278, 1630, 376, 14412, 14448, 272, 754, 14, 2703, 14, 15359, 63, 1278, 779, 267, 6438, 447, 396, 63, 5006, 63, 7617, 510, 32032, 297, 272, 4794, 339, 327, 1852, 3238, 626, 626, 781, 664, 282, 283, 16, 7, 4458, 1233, 367, 314, 2295, 2577, 272, 702, 754, 14, 3292, 508, 378, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 421, 199, 318, 511, 63, 1700, 63, 5997, 8, 16634, 304, 272, 408, 5483, 3238, 626, 4613, 11479, 4154, 10949, 1041, 339, 327, 1218, 282, 7937, 4613, 511, 859, 272, 7368, 14, 17358, 4852, 267, 347, 511, 63, 17082, 8, 1700, 304, 288, 702, 4681, 508, 298, 27089, 1548, 7806, 2, 272, 7857, 339, 327, 1255, 4613, 543, 314, 2569, 2088, 1249, 272, 754, 275, 7368, 14, 19889, 8, 267, 2850, 1421, 29, 27089, 1548, 7806, 297, 267, 2475, 86, 7, 272, 776, 339, 327, 15951, 63, 1278, 1630, 376, 14412, 14448, 272, 754, 14, 2703, 14, 15359, 63, 1278, 779, 267, 6438, 447, 396, 63, 17082, 510, 32032, 297, 272, 4794, 339, 327, 1852, 3238, 626, 626, 781, 664, 282, 283, 16, 7, 4458, 1233, 367, 314, 2295, 2577, 272, 702, 754, 14, 3292, 508, 378, 421, 199, 318, 511, 63, 3437, 63, 1188, 8, 16634, 304, 272, 754, 275, 7368, 14, 19889, 8, 267, 2850, 3437, 297, 272, 776, 272, 327, 15951, 63, 1278, 1630, 376, 14412, 14448, 272, 754, 14, 2703, 14, 15359, 63, 1278, 779, 267, 11400, 331, 745, 73, 825, 18404, 14, 2718, 63, 354, 4863, 6536, 267, 6438, 306, 1421, 29, 19374, 63, 13046, 10, 1084, 314, 574, 367, 314, 10949, 298, 1700, 1674, 297, 272, 4794, 421, 199, 318, 511, 63, 5006, 63, 2730, 63, 6031, 8, 16634, 304, 272, 7368, 14, 1875, 2730, 4852, 267, 359, 4462, 61, 267, 25734, 1484, 275, 6701, 272, 7857, 339, 7368, 14, 17358, 4852, 267, 492, 4613, 398, 768, 4462, 14, 5997, 267, 347, 16509, 8, 1069, 304, 288, 372, 1056, 14, 888, 14, 362, 2730, 360, 24771, 1484, 358, 398, 347, 511, 63, 5006, 63, 7617, 8, 5006, 304, 288, 702, 16509, 508, 283, 7617, 7, 272, 7857, 339, 754, 275, 7368, 14, 19889, 3654, 86, 358, 339, 327, 15951, 63, 1278, 1630, 376, 14412, 14448, 272, 754, 14, 2703, 14, 15359, 63, 1278, 779, 267, 6438, 447, 396, 63, 5006, 63, 7617, 510, 32032, 297, 272, 4794, 339, 327, 1852, 3238, 626, 626, 781, 664, 282, 283, 16, 7, 4458, 1233, 367, 314, 2295, 2577, 272, 702, 754, 14, 3292, 508, 378, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
pforret/python-for-android
python3-alpha/python-libs/bs4/tests/test_tree.py
46
59853
# -*- coding: utf-8 -*- """Tests for Beautiful Soup's tree traversal methods. The tree traversal methods are the main advantage of using Beautiful Soup over just using a parser. Different parsers will build different Beautiful Soup trees given the same markup, but all Beautiful Soup trees can be traversed with the methods tested here. """ import copy import pickle import re import warnings from bs4 import BeautifulSoup from bs4.builder import ( builder_registry, HTMLParserTreeBuilder, ) from bs4.element import ( CData, Doctype, NavigableString, SoupStrainer, Tag, ) from bs4.testing import ( SoupTest, skipIf, ) XML_BUILDER_PRESENT = (builder_registry.lookup("xml") is not None) LXML_PRESENT = (builder_registry.lookup("lxml") is not None) class TreeTest(SoupTest): def assertSelects(self, tags, should_match): """Make sure that the given tags have the correct text. This is used in tests that define a bunch of tags, each containing a single string, and then select certain strings by some mechanism. """ self.assertEqual([tag.string for tag in tags], should_match) def assertSelectsIDs(self, tags, should_match): """Make sure that the given tags have the correct IDs. This is used in tests that define a bunch of tags, each containing a single string, and then select certain strings by some mechanism. """ self.assertEqual([tag['id'] for tag in tags], should_match) class TestFind(TreeTest): """Basic tests of the find() method. find() just calls find_all() with limit=1, so it's not tested all that thouroughly here. """ def test_find_tag(self): soup = self.soup("<a>1</a><b>2</b><a>3</a><b>4</b>") self.assertEqual(soup.find("b").string, "2") def test_unicode_text_find(self): soup = self.soup('<h1>Räksmörgås</h1>') self.assertEqual(soup.find(text='Räksmörgås'), 'Räksmörgås') class TestFindAll(TreeTest): """Basic tests of the find_all() method.""" def test_find_all_text_nodes(self): """You can search the tree for text nodes.""" soup = self.soup("<html>Foo<b>bar</b>\xbb</html>") # Exact match. self.assertEqual(soup.find_all(text="bar"), ["bar"]) # Match any of a number of strings. self.assertEqual( soup.find_all(text=["Foo", "bar"]), ["Foo", "bar"]) # Match a regular expression. self.assertEqual(soup.find_all(text=re.compile('.*')), ["Foo", "bar", '\xbb']) # Match anything. self.assertEqual(soup.find_all(text=True), ["Foo", "bar", '\xbb']) def test_find_all_limit(self): """You can limit the number of items returned by find_all.""" soup = self.soup("<a>1</a><a>2</a><a>3</a><a>4</a><a>5</a>") self.assertSelects(soup.find_all('a', limit=3), ["1", "2", "3"]) self.assertSelects(soup.find_all('a', limit=1), ["1"]) self.assertSelects( soup.find_all('a', limit=10), ["1", "2", "3", "4", "5"]) # A limit of 0 means no limit. self.assertSelects( soup.find_all('a', limit=0), ["1", "2", "3", "4", "5"]) def test_calling_a_tag_is_calling_findall(self): soup = self.soup("<a>1</a><b>2<a id='foo'>3</a></b>") self.assertSelects(soup('a', limit=1), ["1"]) self.assertSelects(soup.b(id="foo"), ["3"]) class TestFindAllBasicNamespaces(TreeTest): def test_find_by_namespaced_name(self): soup = self.soup('<mathml:msqrt>4</mathml:msqrt><a svg:fill="red">') self.assertEqual("4", soup.find("mathml:msqrt").string) self.assertEqual("a", soup.find(attrs= { "svg:fill" : "red" }).name) class TestFindAllByName(TreeTest): """Test ways of finding tags by tag name.""" def setUp(self): super(TreeTest, self).setUp() self.tree = self.soup("""<a>First tag.</a> <b>Second tag.</b> <c>Third <a>Nested tag.</a> tag.</c>""") def test_find_all_by_tag_name(self): # Find all the <a> tags. self.assertSelects( self.tree.find_all('a'), ['First tag.', 'Nested tag.']) def test_find_all_on_non_root_element(self): # You can call find_all on any node, not just the root. self.assertSelects(self.tree.c.find_all('a'), ['Nested tag.']) def test_calling_element_invokes_find_all(self): self.assertSelects(self.tree('a'), ['First tag.', 'Nested tag.']) def test_find_all_by_tag_strainer(self): self.assertSelects( self.tree.find_all(SoupStrainer('a')), ['First tag.', 'Nested tag.']) def test_find_all_by_tag_names(self): self.assertSelects( self.tree.find_all(['a', 'b']), ['First tag.', 'Second tag.', 'Nested tag.']) def test_find_all_by_tag_dict(self): self.assertSelects( self.tree.find_all({'a' : True, 'b' : True}), ['First tag.', 'Second tag.', 'Nested tag.']) def test_find_all_by_tag_re(self): self.assertSelects( self.tree.find_all(re.compile('^[ab]$')), ['First tag.', 'Second tag.', 'Nested tag.']) def test_find_all_with_tags_matching_method(self): # You can define an oracle method that determines whether # a tag matches the search. def id_matches_name(tag): return tag.name == tag.get('id') tree = self.soup("""<a id="a">Match 1.</a> <a id="1">Does not match.</a> <b id="b">Match 2.</a>""") self.assertSelects( tree.find_all(id_matches_name), ["Match 1.", "Match 2."]) class TestFindAllByAttribute(TreeTest): def test_find_all_by_attribute_name(self): # You can pass in keyword arguments to find_all to search by # attribute. tree = self.soup(""" <a id="first">Matching a.</a> <a id="second"> Non-matching <b id="first">Matching b.</b>a. </a>""") self.assertSelects(tree.find_all(id='first'), ["Matching a.", "Matching b."]) def test_find_all_by_attribute_dict(self): # You can pass in a dictionary as the argument 'attrs'. This # lets you search for attributes like 'name' (a fixed argument # to find_all) and 'class' (a reserved word in Python.) tree = self.soup(""" <a name="name1" class="class1">Name match.</a> <a name="name2" class="class2">Class match.</a> <a name="name3" class="class3">Non-match.</a> <name1>A tag called 'name1'.</name1> """) # This doesn't do what you want. self.assertSelects(tree.find_all(name='name1'), ["A tag called 'name1'."]) # This does what you want. self.assertSelects(tree.find_all(attrs={'name' : 'name1'}), ["Name match."]) # Passing class='class2' would cause a syntax error. self.assertSelects(tree.find_all(attrs={'class' : 'class2'}), ["Class match."]) def test_find_all_by_class(self): # Passing in a string to 'attrs' will search the CSS class. tree = self.soup(""" <a class="1">Class 1.</a> <a class="2">Class 2.</a> <b class="1">Class 1.</b> <c class="3 4">Class 3 and 4.</c> """) self.assertSelects(tree.find_all('a', '1'), ['Class 1.']) self.assertSelects(tree.find_all(attrs='1'), ['Class 1.', 'Class 1.']) self.assertSelects(tree.find_all('c', '3'), ['Class 3 and 4.']) self.assertSelects(tree.find_all('c', '4'), ['Class 3 and 4.']) def test_find_by_class_when_multiple_classes_present(self): tree = self.soup("<gar class='foo bar'>Found it</gar>") attrs = { 'class' : re.compile("o") } f = tree.find_all("gar", attrs=attrs) self.assertSelects(f, ["Found it"]) f = tree.find_all("gar", re.compile("a")) self.assertSelects(f, ["Found it"]) # Since the class is not the string "foo bar", but the two # strings "foo" and "bar", this will not find anything. attrs = { 'class' : re.compile("o b") } f = tree.find_all("gar", attrs=attrs) self.assertSelects(f, []) def test_find_all_with_non_dictionary_for_attrs_finds_by_class(self): soup = self.soup("<a class='bar'>Found it</a>") self.assertSelects(soup.find_all("a", re.compile("ba")), ["Found it"]) def big_attribute_value(value): return len(value) > 3 self.assertSelects(soup.find_all("a", big_attribute_value), []) def small_attribute_value(value): return len(value) <= 3 self.assertSelects( soup.find_all("a", small_attribute_value), ["Found it"]) def test_find_all_with_string_for_attrs_finds_multiple_classes(self): soup = self.soup('<a class="foo bar"></a><a class="foo"></a>') a, a2 = soup.find_all("a") self.assertEqual([a, a2], soup.find_all("a", "foo")) self.assertEqual([a], soup.find_all("a", "bar")) # If you specify the attribute as a string that contains a # space, only that specific value will be found. self.assertEqual([a], soup.find_all("a", "foo bar")) self.assertEqual([], soup.find_all("a", "bar foo")) def test_find_all_by_attribute_soupstrainer(self): tree = self.soup(""" <a id="first">Match.</a> <a id="second">Non-match.</a>""") strainer = SoupStrainer(attrs={'id' : 'first'}) self.assertSelects(tree.find_all(strainer), ['Match.']) def test_find_all_with_missing_atribute(self): # You can pass in None as the value of an attribute to find_all. # This will match tags that do not have that attribute set. tree = self.soup("""<a id="1">ID present.</a> <a>No ID present.</a> <a id="">ID is empty.</a>""") self.assertSelects(tree.find_all('a', id=None), ["No ID present."]) def test_find_all_with_defined_attribute(self): # You can pass in None as the value of an attribute to find_all. # This will match tags that have that attribute set to any value. tree = self.soup("""<a id="1">ID present.</a> <a>No ID present.</a> <a id="">ID is empty.</a>""") self.assertSelects( tree.find_all(id=True), ["ID present.", "ID is empty."]) def test_find_all_with_numeric_attribute(self): # If you search for a number, it's treated as a string. tree = self.soup("""<a id=1>Unquoted attribute.</a> <a id="1">Quoted attribute.</a>""") expected = ["Unquoted attribute.", "Quoted attribute."] self.assertSelects(tree.find_all(id=1), expected) self.assertSelects(tree.find_all(id="1"), expected) def test_find_all_with_list_attribute_values(self): # You can pass a list of attribute values instead of just one, # and you'll get tags that match any of the values. tree = self.soup("""<a id="1">1</a> <a id="2">2</a> <a id="3">3</a> <a>No ID.</a>""") self.assertSelects(tree.find_all(id=["1", "3", "4"]), ["1", "3"]) def test_find_all_with_regular_expression_attribute_value(self): # You can pass a regular expression as an attribute value, and # you'll get tags whose values for that attribute match the # regular expression. tree = self.soup("""<a id="a">One a.</a> <a id="aa">Two as.</a> <a id="ab">Mixed as and bs.</a> <a id="b">One b.</a> <a>No ID.</a>""") self.assertSelects(tree.find_all(id=re.compile("^a+$")), ["One a.", "Two as."]) def test_find_by_name_and_containing_string(self): soup = self.soup("<b>foo</b><b>bar</b><a>foo</a>") a = soup.a self.assertEqual([a], soup.find_all("a", text="foo")) self.assertEqual([], soup.find_all("a", text="bar")) self.assertEqual([], soup.find_all("a", text="bar")) def test_find_by_name_and_containing_string_when_string_is_buried(self): soup = self.soup("<a>foo</a><a><b><c>foo</c></b></a>") self.assertEqual(soup.find_all("a"), soup.find_all("a", text="foo")) def test_find_by_attribute_and_containing_string(self): soup = self.soup('<b id="1">foo</b><a id="2">foo</a>') a = soup.a self.assertEqual([a], soup.find_all(id=2, text="foo")) self.assertEqual([], soup.find_all(id=1, text="bar")) class TestIndex(TreeTest): """Test Tag.index""" def test_index(self): tree = self.soup("""<wrap> <a>Identical</a> <b>Not identical</b> <a>Identical</a> <c><d>Identical with child</d></c> <b>Also not identical</b> <c><d>Identical with child</d></c> </wrap>""") wrap = tree.wrap for i, element in enumerate(wrap.contents): self.assertEqual(i, wrap.index(element)) self.assertRaises(ValueError, tree.index, 1) class TestParentOperations(TreeTest): """Test navigation and searching through an element's parents.""" def setUp(self): super(TestParentOperations, self).setUp() self.tree = self.soup('''<ul id="empty"></ul> <ul id="top"> <ul id="middle"> <ul id="bottom"> <b>Start here</b> </ul> </ul>''') self.start = self.tree.b def test_parent(self): self.assertEqual(self.start.parent['id'], 'bottom') self.assertEqual(self.start.parent.parent['id'], 'middle') self.assertEqual(self.start.parent.parent.parent['id'], 'top') def test_parent_of_top_tag_is_soup_object(self): top_tag = self.tree.contents[0] self.assertEqual(top_tag.parent, self.tree) def test_soup_object_has_no_parent(self): self.assertEqual(None, self.tree.parent) def test_find_parents(self): self.assertSelectsIDs( self.start.find_parents('ul'), ['bottom', 'middle', 'top']) self.assertSelectsIDs( self.start.find_parents('ul', id="middle"), ['middle']) def test_find_parent(self): self.assertEqual(self.start.find_parent('ul')['id'], 'bottom') def test_parent_of_text_element(self): text = self.tree.find(text="Start here") self.assertEqual(text.parent.name, 'b') def test_text_element_find_parent(self): text = self.tree.find(text="Start here") self.assertEqual(text.find_parent('ul')['id'], 'bottom') def test_parent_generator(self): parents = [parent['id'] for parent in self.start.parents if parent is not None and 'id' in parent.attrs] self.assertEqual(parents, ['bottom', 'middle', 'top']) class ProximityTest(TreeTest): def setUp(self): super(TreeTest, self).setUp() self.tree = self.soup( '<html id="start"><head></head><body><b id="1">One</b><b id="2">Two</b><b id="3">Three</b></body></html>') class TestNextOperations(ProximityTest): def setUp(self): super(TestNextOperations, self).setUp() self.start = self.tree.b def test_next(self): self.assertEqual(self.start.next_element, "One") self.assertEqual(self.start.next_element.next_element['id'], "2") def test_next_of_last_item_is_none(self): last = self.tree.find(text="Three") self.assertEqual(last.next_element, None) def test_next_of_root_is_none(self): # The document root is outside the next/previous chain. self.assertEqual(self.tree.next_element, None) def test_find_all_next(self): self.assertSelects(self.start.find_all_next('b'), ["Two", "Three"]) self.start.find_all_next(id=3) self.assertSelects(self.start.find_all_next(id=3), ["Three"]) def test_find_next(self): self.assertEqual(self.start.find_next('b')['id'], '2') self.assertEqual(self.start.find_next(text="Three"), "Three") def test_find_next_for_text_element(self): text = self.tree.find(text="One") self.assertEqual(text.find_next("b").string, "Two") self.assertSelects(text.find_all_next("b"), ["Two", "Three"]) def test_next_generator(self): start = self.tree.find(text="Two") successors = [node for node in start.next_elements] # There are two successors: the final <b> tag and its text contents. tag, contents = successors self.assertEqual(tag['id'], '3') self.assertEqual(contents, "Three") class TestPreviousOperations(ProximityTest): def setUp(self): super(TestPreviousOperations, self).setUp() self.end = self.tree.find(text="Three") def test_previous(self): self.assertEqual(self.end.previous_element['id'], "3") self.assertEqual(self.end.previous_element.previous_element, "Two") def test_previous_of_first_item_is_none(self): first = self.tree.find('html') self.assertEqual(first.previous_element, None) def test_previous_of_root_is_none(self): # The document root is outside the next/previous chain. # XXX This is broken! #self.assertEqual(self.tree.previous_element, None) pass def test_find_all_previous(self): # The <b> tag containing the "Three" node is the predecessor # of the "Three" node itself, which is why "Three" shows up # here. self.assertSelects( self.end.find_all_previous('b'), ["Three", "Two", "One"]) self.assertSelects(self.end.find_all_previous(id=1), ["One"]) def test_find_previous(self): self.assertEqual(self.end.find_previous('b')['id'], '3') self.assertEqual(self.end.find_previous(text="One"), "One") def test_find_previous_for_text_element(self): text = self.tree.find(text="Three") self.assertEqual(text.find_previous("b").string, "Three") self.assertSelects( text.find_all_previous("b"), ["Three", "Two", "One"]) def test_previous_generator(self): start = self.tree.find(text="One") predecessors = [node for node in start.previous_elements] # There are four predecessors: the <b> tag containing "One" # the <body> tag, the <head> tag, and the <html> tag. b, body, head, html = predecessors self.assertEqual(b['id'], '1') self.assertEqual(body.name, "body") self.assertEqual(head.name, "head") self.assertEqual(html.name, "html") class SiblingTest(TreeTest): def setUp(self): super(SiblingTest, self).setUp() markup = '''<html> <span id="1"> <span id="1.1"></span> </span> <span id="2"> <span id="2.1"></span> </span> <span id="3"> <span id="3.1"></span> </span> <span id="4"></span> </html>''' # All that whitespace looks good but makes the tests more # difficult. Get rid of it. markup = re.compile("\n\s*").sub("", markup) self.tree = self.soup(markup) class TestNextSibling(SiblingTest): def setUp(self): super(TestNextSibling, self).setUp() self.start = self.tree.find(id="1") def test_next_sibling_of_root_is_none(self): self.assertEqual(self.tree.next_sibling, None) def test_next_sibling(self): self.assertEqual(self.start.next_sibling['id'], '2') self.assertEqual(self.start.next_sibling.next_sibling['id'], '3') # Note the difference between next_sibling and next_element. self.assertEqual(self.start.next_element['id'], '1.1') def test_next_sibling_may_not_exist(self): self.assertEqual(self.tree.html.next_sibling, None) nested_span = self.tree.find(id="1.1") self.assertEqual(nested_span.next_sibling, None) last_span = self.tree.find(id="4") self.assertEqual(last_span.next_sibling, None) def test_find_next_sibling(self): self.assertEqual(self.start.find_next_sibling('span')['id'], '2') def test_next_siblings(self): self.assertSelectsIDs(self.start.find_next_siblings("span"), ['2', '3', '4']) self.assertSelectsIDs(self.start.find_next_siblings(id='3'), ['3']) def test_next_sibling_for_text_element(self): soup = self.soup("Foo<b>bar</b>baz") start = soup.find(text="Foo") self.assertEqual(start.next_sibling.name, 'b') self.assertEqual(start.next_sibling.next_sibling, 'baz') self.assertSelects(start.find_next_siblings('b'), ['bar']) self.assertEqual(start.find_next_sibling(text="baz"), "baz") self.assertEqual(start.find_next_sibling(text="nonesuch"), None) class TestPreviousSibling(SiblingTest): def setUp(self): super(TestPreviousSibling, self).setUp() self.end = self.tree.find(id="4") def test_previous_sibling_of_root_is_none(self): self.assertEqual(self.tree.previous_sibling, None) def test_previous_sibling(self): self.assertEqual(self.end.previous_sibling['id'], '3') self.assertEqual(self.end.previous_sibling.previous_sibling['id'], '2') # Note the difference between previous_sibling and previous_element. self.assertEqual(self.end.previous_element['id'], '3.1') def test_previous_sibling_may_not_exist(self): self.assertEqual(self.tree.html.previous_sibling, None) nested_span = self.tree.find(id="1.1") self.assertEqual(nested_span.previous_sibling, None) first_span = self.tree.find(id="1") self.assertEqual(first_span.previous_sibling, None) def test_find_previous_sibling(self): self.assertEqual(self.end.find_previous_sibling('span')['id'], '3') def test_previous_siblings(self): self.assertSelectsIDs(self.end.find_previous_siblings("span"), ['3', '2', '1']) self.assertSelectsIDs(self.end.find_previous_siblings(id='1'), ['1']) def test_previous_sibling_for_text_element(self): soup = self.soup("Foo<b>bar</b>baz") start = soup.find(text="baz") self.assertEqual(start.previous_sibling.name, 'b') self.assertEqual(start.previous_sibling.previous_sibling, 'Foo') self.assertSelects(start.find_previous_siblings('b'), ['bar']) self.assertEqual(start.find_previous_sibling(text="Foo"), "Foo") self.assertEqual(start.find_previous_sibling(text="nonesuch"), None) class TestTagCreation(SoupTest): """Test the ability to create new tags.""" def test_new_tag(self): soup = self.soup("") new_tag = soup.new_tag("foo", bar="baz") self.assertTrue(isinstance(new_tag, Tag)) self.assertEqual("foo", new_tag.name) self.assertEqual(dict(bar="baz"), new_tag.attrs) self.assertEqual(None, new_tag.parent) def test_tag_inherits_self_closing_rules_from_builder(self): if XML_BUILDER_PRESENT: xml_soup = BeautifulSoup("", "xml") xml_br = xml_soup.new_tag("br") xml_p = xml_soup.new_tag("p") # Both the <br> and <p> tag are empty-element, just because # they have no contents. self.assertEqual(b"<br/>", xml_br.encode()) self.assertEqual(b"<p/>", xml_p.encode()) html_soup = BeautifulSoup("", "html") html_br = html_soup.new_tag("br") html_p = html_soup.new_tag("p") # The HTML builder users HTML's rules about which tags are # empty-element tags, and the new tags reflect these rules. self.assertEqual(b"<br/>", html_br.encode()) self.assertEqual(b"<p></p>", html_p.encode()) def test_new_string_creates_navigablestring(self): soup = self.soup("") s = soup.new_string("foo") self.assertEqual("foo", s) self.assertTrue(isinstance(s, NavigableString)) class TestTreeModification(SoupTest): def test_attribute_modification(self): soup = self.soup('<a id="1"></a>') soup.a['id'] = 2 self.assertEqual(soup.decode(), self.document_for('<a id="2"></a>')) del(soup.a['id']) self.assertEqual(soup.decode(), self.document_for('<a></a>')) soup.a['id2'] = 'foo' self.assertEqual(soup.decode(), self.document_for('<a id2="foo"></a>')) def test_new_tag_creation(self): builder = builder_registry.lookup('html')() soup = self.soup("<body></body>", builder=builder) a = Tag(soup, builder, 'a') ol = Tag(soup, builder, 'ol') a['href'] = 'http://foo.com/' soup.body.insert(0, a) soup.body.insert(1, ol) self.assertEqual( soup.body.encode(), b'<body><a href="http://foo.com/"></a><ol></ol></body>') def test_append_to_contents_moves_tag(self): doc = """<p id="1">Don't leave me <b>here</b>.</p> <p id="2">Don\'t leave!</p>""" soup = self.soup(doc) second_para = soup.find(id='2') bold = soup.b # Move the <b> tag to the end of the second paragraph. soup.find(id='2').append(soup.b) # The <b> tag is now a child of the second paragraph. self.assertEqual(bold.parent, second_para) self.assertEqual( soup.decode(), self.document_for( '<p id="1">Don\'t leave me .</p>\n' '<p id="2">Don\'t leave!<b>here</b></p>')) def test_replace_with_returns_thing_that_was_replaced(self): text = "<a></a><b><c></c></b>" soup = self.soup(text) a = soup.a new_a = a.replace_with(soup.c) self.assertEqual(a, new_a) def test_replace_with_children_returns_thing_that_was_replaced(self): text = "<a><b></b><c></c></a>" soup = self.soup(text) a = soup.a new_a = a.replace_with_children() self.assertEqual(a, new_a) def test_replace_tag_with_itself(self): text = "<a><b></b><c>Foo<d></d></c></a><a><e></e></a>" soup = self.soup(text) c = soup.c soup.c.replace_with(c) self.assertEqual(soup.decode(), self.document_for(text)) def test_replace_tag_with_its_parent_raises_exception(self): text = "<a><b></b></a>" soup = self.soup(text) self.assertRaises(ValueError, soup.b.replace_with, soup.a) def test_insert_tag_into_itself_raises_exception(self): text = "<a><b></b></a>" soup = self.soup(text) self.assertRaises(ValueError, soup.a.insert, 0, soup.a) def test_replace_with_maintains_next_element_throughout(self): soup = self.soup('<p><a>one</a><b>three</b></p>') a = soup.a b = a.contents[0] # Make it so the <a> tag has two text children. a.insert(1, "two") # Now replace each one with the empty string. left, right = a.contents left.replaceWith('') right.replaceWith('') # The <b> tag is still connected to the tree. self.assertEqual("three", soup.b.string) def test_replace_final_node(self): soup = self.soup("<b>Argh!</b>") soup.find(text="Argh!").replace_with("Hooray!") new_text = soup.find(text="Hooray!") b = soup.b self.assertEqual(new_text.previous_element, b) self.assertEqual(new_text.parent, b) self.assertEqual(new_text.previous_element.next_element, new_text) self.assertEqual(new_text.next_element, None) def test_consecutive_text_nodes(self): # A builder should never create two consecutive text nodes, # but if you insert one next to another, Beautiful Soup will # handle it correctly. soup = self.soup("<a><b>Argh!</b><c></c></a>") soup.b.insert(1, "Hooray!") self.assertEqual( soup.decode(), self.document_for( "<a><b>Argh!Hooray!</b><c></c></a>")) new_text = soup.find(text="Hooray!") self.assertEqual(new_text.previous_element, "Argh!") self.assertEqual(new_text.previous_element.next_element, new_text) self.assertEqual(new_text.previous_sibling, "Argh!") self.assertEqual(new_text.previous_sibling.next_sibling, new_text) self.assertEqual(new_text.next_sibling, None) self.assertEqual(new_text.next_element, soup.c) def test_insert_string(self): soup = self.soup("<a></a>") soup.a.insert(0, "bar") soup.a.insert(0, "foo") # The string were added to the tag. self.assertEqual(["foo", "bar"], soup.a.contents) # And they were converted to NavigableStrings. self.assertEqual(soup.a.contents[0].next_element, "bar") def test_insert_tag(self): builder = self.default_builder soup = self.soup( "<a><b>Find</b><c>lady!</c><d></d></a>", builder=builder) magic_tag = Tag(soup, builder, 'magictag') magic_tag.insert(0, "the") soup.a.insert(1, magic_tag) self.assertEqual( soup.decode(), self.document_for( "<a><b>Find</b><magictag>the</magictag><c>lady!</c><d></d></a>")) # Make sure all the relationships are hooked up correctly. b_tag = soup.b self.assertEqual(b_tag.next_sibling, magic_tag) self.assertEqual(magic_tag.previous_sibling, b_tag) find = b_tag.find(text="Find") self.assertEqual(find.next_element, magic_tag) self.assertEqual(magic_tag.previous_element, find) c_tag = soup.c self.assertEqual(magic_tag.next_sibling, c_tag) self.assertEqual(c_tag.previous_sibling, magic_tag) the = magic_tag.find(text="the") self.assertEqual(the.parent, magic_tag) self.assertEqual(the.next_element, c_tag) self.assertEqual(c_tag.previous_element, the) def test_insert_works_on_empty_element_tag(self): # This is a little strange, since most HTML parsers don't allow # markup like this to come through. But in general, we don't # know what the parser would or wouldn't have allowed, so # I'm letting this succeed for now. soup = self.soup("<br/>") soup.br.insert(1, "Contents") self.assertEqual(str(soup.br), "<br>Contents</br>") def test_insert_before(self): soup = self.soup("<a>foo</a><b>bar</b>") soup.b.insert_before("BAZ") soup.a.insert_before("QUUX") self.assertEqual( soup.decode(), self.document_for("QUUX<a>foo</a>BAZ<b>bar</b>")) soup.a.insert_before(soup.b) self.assertEqual( soup.decode(), self.document_for("QUUX<b>bar</b><a>foo</a>BAZ")) def test_insert_after(self): soup = self.soup("<a>foo</a><b>bar</b>") soup.b.insert_after("BAZ") soup.a.insert_after("QUUX") self.assertEqual( soup.decode(), self.document_for("<a>foo</a>QUUX<b>bar</b>BAZ")) soup.b.insert_after(soup.a) self.assertEqual( soup.decode(), self.document_for("QUUX<b>bar</b><a>foo</a>BAZ")) def test_insert_after_raises_valueerror_if_after_has_no_meaning(self): soup = self.soup("") tag = soup.new_tag("a") string = soup.new_string("") self.assertRaises(ValueError, string.insert_after, tag) self.assertRaises(ValueError, soup.insert_after, tag) self.assertRaises(ValueError, tag.insert_after, tag) def test_insert_before_raises_valueerror_if_before_has_no_meaning(self): soup = self.soup("") tag = soup.new_tag("a") string = soup.new_string("") self.assertRaises(ValueError, string.insert_before, tag) self.assertRaises(ValueError, soup.insert_before, tag) self.assertRaises(ValueError, tag.insert_before, tag) def test_replace_with(self): soup = self.soup( "<p>There's <b>no</b> business like <b>show</b> business</p>") no, show = soup.find_all('b') show.replace_with(no) self.assertEqual( soup.decode(), self.document_for( "<p>There's business like <b>no</b> business</p>")) self.assertEqual(show.parent, None) self.assertEqual(no.parent, soup.p) self.assertEqual(no.next_element, "no") self.assertEqual(no.next_sibling, " business") def test_nested_tag_replace_with(self): soup = self.soup( """<a>We<b>reserve<c>the</c><d>right</d></b></a><e>to<f>refuse</f><g>service</g></e>""") # Replace the entire <b> tag and its contents ("reserve the # right") with the <f> tag ("refuse"). remove_tag = soup.b move_tag = soup.f remove_tag.replace_with(move_tag) self.assertEqual( soup.decode(), self.document_for( "<a>We<f>refuse</f></a><e>to<g>service</g></e>")) # The <b> tag is now an orphan. self.assertEqual(remove_tag.parent, None) self.assertEqual(remove_tag.find(text="right").next_element, None) self.assertEqual(remove_tag.previous_element, None) self.assertEqual(remove_tag.next_sibling, None) self.assertEqual(remove_tag.previous_sibling, None) # The <f> tag is now connected to the <a> tag. self.assertEqual(move_tag.parent, soup.a) self.assertEqual(move_tag.previous_element, "We") self.assertEqual(move_tag.next_element.next_element, soup.e) self.assertEqual(move_tag.next_sibling, None) # The gap where the <f> tag used to be has been mended, and # the word "to" is now connected to the <g> tag. to_text = soup.find(text="to") g_tag = soup.g self.assertEqual(to_text.next_element, g_tag) self.assertEqual(to_text.next_sibling, g_tag) self.assertEqual(g_tag.previous_element, to_text) self.assertEqual(g_tag.previous_sibling, to_text) def test_replace_with_children(self): tree = self.soup(""" <p>Unneeded <em>formatting</em> is unneeded</p> """) tree.em.replace_with_children() self.assertEqual(tree.em, None) self.assertEqual(tree.p.text, "Unneeded formatting is unneeded") def test_extract(self): soup = self.soup( '<html><body>Some content. <div id="nav">Nav crap</div> More content.</body></html>') self.assertEqual(len(soup.body.contents), 3) extracted = soup.find(id="nav").extract() self.assertEqual( soup.decode(), "<html><body>Some content. More content.</body></html>") self.assertEqual(extracted.decode(), '<div id="nav">Nav crap</div>') # The extracted tag is now an orphan. self.assertEqual(len(soup.body.contents), 2) self.assertEqual(extracted.parent, None) self.assertEqual(extracted.previous_element, None) self.assertEqual(extracted.next_element.next_element, None) # The gap where the extracted tag used to be has been mended. content_1 = soup.find(text="Some content. ") content_2 = soup.find(text=" More content.") self.assertEqual(content_1.next_element, content_2) self.assertEqual(content_1.next_sibling, content_2) self.assertEqual(content_2.previous_element, content_1) self.assertEqual(content_2.previous_sibling, content_1) def test_extract_distinguishes_between_identical_strings(self): soup = self.soup("<a>foo</a><b>bar</b>") foo_1 = soup.a.string bar_1 = soup.b.string foo_2 = soup.new_string("foo") bar_2 = soup.new_string("bar") soup.a.append(foo_2) soup.b.append(bar_2) # Now there are two identical strings in the <a> tag, and two # in the <b> tag. Let's remove the first "foo" and the second # "bar". foo_1.extract() bar_2.extract() self.assertEqual(foo_2, soup.a.string) self.assertEqual(bar_2, soup.b.string) def test_clear(self): """Tag.clear()""" soup = self.soup("<p><a>String <em>Italicized</em></a> and another</p>") # clear using extract() a = soup.a soup.p.clear() self.assertEqual(len(soup.p.contents), 0) self.assertTrue(hasattr(a, "contents")) # clear using decompose() em = a.em a.clear(decompose=True) self.assertFalse(hasattr(em, "contents")) def test_string_set(self): """Tag.string = 'string'""" soup = self.soup("<a></a> <b><c></c></b>") soup.a.string = "foo" self.assertEqual(soup.a.contents, ["foo"]) soup.b.string = "bar" self.assertEqual(soup.b.contents, ["bar"]) class TestElementObjects(SoupTest): """Test various features of element objects.""" def test_len(self): """The length of an element is its number of children.""" soup = self.soup("<top>1<b>2</b>3</top>") # The BeautifulSoup object itself contains one element: the # <top> tag. self.assertEqual(len(soup.contents), 1) self.assertEqual(len(soup), 1) # The <top> tag contains three elements: the text node "1", the # <b> tag, and the text node "3". self.assertEqual(len(soup.top), 3) self.assertEqual(len(soup.top.contents), 3) def test_member_access_invokes_find(self): """Accessing a Python member .foo invokes find('foo')""" soup = self.soup('<b><i></i></b>') self.assertEqual(soup.b, soup.find('b')) self.assertEqual(soup.b.i, soup.find('b').find('i')) self.assertEqual(soup.a, None) def test_deprecated_member_access(self): soup = self.soup('<b><i></i></b>') with warnings.catch_warnings(record=True) as w: tag = soup.bTag self.assertEqual(soup.b, tag) self.assertEqual( '.bTag is deprecated, use .find("b") instead.', str(w[0].message)) def test_has_attr(self): """has_attr() checks for the presence of an attribute. Please note note: has_attr() is different from __in__. has_attr() checks the tag's attributes and __in__ checks the tag's chidlren. """ soup = self.soup("<foo attr='bar'>") self.assertTrue(soup.foo.has_attr('attr')) self.assertFalse(soup.foo.has_attr('attr2')) def test_attributes_come_out_in_alphabetical_order(self): markup = '<b a="1" z="5" m="3" f="2" y="4"></b>' self.assertSoupEquals(markup, '<b a="1" f="2" m="3" y="4" z="5"></b>') def test_string(self): # A tag that contains only a text node makes that node # available as .string. soup = self.soup("<b>foo</b>") self.assertEqual(soup.b.string, 'foo') def test_empty_tag_has_no_string(self): # A tag with no children has no .stirng. soup = self.soup("<b></b>") self.assertEqual(soup.b.string, None) def test_tag_with_multiple_children_has_no_string(self): # A tag with no children has no .string. soup = self.soup("<a>foo<b></b><b></b></b>") self.assertEqual(soup.b.string, None) soup = self.soup("<a>foo<b></b>bar</b>") self.assertEqual(soup.b.string, None) # Even if all the children are strings, due to trickery, # it won't work--but this would be a good optimization. soup = self.soup("<a>foo</b>") soup.a.insert(1, "bar") self.assertEqual(soup.a.string, None) def test_tag_with_recursive_string_has_string(self): # A tag with a single child which has a .string inherits that # .string. soup = self.soup("<a><b>foo</b></a>") self.assertEqual(soup.a.string, "foo") self.assertEqual(soup.string, "foo") def test_lack_of_string(self): """Only a tag containing a single text node has a .string.""" soup = self.soup("<b>f<i>e</i>o</b>") self.assertFalse(soup.b.string) soup = self.soup("<b></b>") self.assertFalse(soup.b.string) def test_all_text(self): """Tag.text and Tag.get_text(sep=u"") -> all child text, concatenated""" soup = self.soup("<a>a<b>r</b> <r> t </r></a>") self.assertEqual(soup.a.text, "ar t ") self.assertEqual(soup.a.get_text(strip=True), "art") self.assertEqual(soup.a.get_text(","), "a,r, , t ") self.assertEqual(soup.a.get_text(",", strip=True), "a,r,t") class TestCDAtaListAttributes(SoupTest): """Testing cdata-list attributes like 'class'. """ def test_single_value_becomes_list(self): soup = self.soup("<a class='foo'>") self.assertEqual(["foo"],soup.a['class']) def test_multiple_values_becomes_list(self): soup = self.soup("<a class='foo bar'>") self.assertEqual(["foo", "bar"], soup.a['class']) def test_multiple_values_separated_by_weird_whitespace(self): soup = self.soup("<a class='foo\tbar\nbaz'>") self.assertEqual(["foo", "bar", "baz"],soup.a['class']) def test_attributes_joined_into_string_on_output(self): soup = self.soup("<a class='foo\tbar'>") self.assertEqual(b'<a class="foo bar"></a>', soup.a.encode()) def test_accept_charset(self): soup = self.soup('<form accept-charset="ISO-8859-1 UTF-8">') self.assertEqual(['ISO-8859-1', 'UTF-8'], soup.form['accept-charset']) def test_cdata_attribute_applying_only_to_one_tag(self): data = '<a accept-charset="ISO-8859-1 UTF-8"></a>' soup = self.soup(data) # We saw in another test that accept-charset is a cdata-list # attribute for the <form> tag. But it's not a cdata-list # attribute for any other tag. self.assertEqual('ISO-8859-1 UTF-8', soup.a['accept-charset']) class TestPersistence(SoupTest): "Testing features like pickle and deepcopy." def setUp(self): super(TestPersistence, self).setUp() self.page = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Beautiful Soup: We called him Tortoise because he taught us.</title> <link rev="made" href="mailto:leonardr@segfault.org"> <meta name="Description" content="Beautiful Soup: an HTML parser optimized for screen-scraping."> <meta name="generator" content="Markov Approximation 1.4 (module: leonardr)"> <meta name="author" content="Leonard Richardson"> </head> <body> <a href="foo">foo</a> <a href="foo"><b>bar</b></a> </body> </html>""" self.tree = self.soup(self.page) def test_pickle_and_unpickle_identity(self): # Pickling a tree, then unpickling it, yields a tree identical # to the original. dumped = pickle.dumps(self.tree, 2) loaded = pickle.loads(dumped) self.assertEqual(loaded.__class__, BeautifulSoup) self.assertEqual(loaded.decode(), self.tree.decode()) def test_deepcopy_identity(self): # Making a deepcopy of a tree yields an identical tree. copied = copy.deepcopy(self.tree) self.assertEqual(copied.decode(), self.tree.decode()) def test_unicode_pickle(self): # A tree containing Unicode characters can be pickled. html = "<b>\N{SNOWMAN}</b>" soup = self.soup(html) dumped = pickle.dumps(soup, pickle.HIGHEST_PROTOCOL) loaded = pickle.loads(dumped) self.assertEqual(loaded.decode(), soup.decode()) class TestSubstitutions(SoupTest): def test_default_formatter_is_minimal(self): markup = "<b>&lt;&lt;Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!&gt;&gt;</b>" soup = self.soup(markup) decoded = soup.decode(formatter="minimal") # The < is converted back into &lt; but the e-with-acute is left alone. self.assertEqual( decoded, self.document_for( "<b>&lt;&lt;Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!&gt;&gt;</b>")) def test_formatter_html(self): markup = "<b>&lt;&lt;Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!&gt;&gt;</b>" soup = self.soup(markup) decoded = soup.decode(formatter="html") self.assertEqual( decoded, self.document_for("<b>&lt;&lt;Sacr&eacute; bleu!&gt;&gt;</b>")) def test_formatter_minimal(self): markup = "<b>&lt;&lt;Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!&gt;&gt;</b>" soup = self.soup(markup) decoded = soup.decode(formatter="minimal") # The < is converted back into &lt; but the e-with-acute is left alone. self.assertEqual( decoded, self.document_for( "<b>&lt;&lt;Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!&gt;&gt;</b>")) def test_formatter_null(self): markup = "<b>&lt;&lt;Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!&gt;&gt;</b>" soup = self.soup(markup) decoded = soup.decode(formatter=None) # Neither the angle brackets nor the e-with-acute are converted. # This is not valid HTML, but it's what the user wanted. self.assertEqual(decoded, self.document_for("<b><<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>></b>")) def test_formatter_custom(self): markup = "<b>&lt;foo&gt;</b><b>bar</b>" soup = self.soup(markup) decoded = soup.decode(formatter = lambda x: x.upper()) # Instead of normal entity conversion code, the custom # callable is called on every string. self.assertEqual( decoded, self.document_for("<b><FOO></b><b>BAR</b>")) def test_prettify_accepts_formatter(self): soup = BeautifulSoup("<html><body>foo</body></html>") pretty = soup.prettify(formatter = lambda x: x.upper()) self.assertTrue("FOO" in pretty) def test_prettify_outputs_unicode_by_default(self): soup = self.soup("<a></a>") self.assertEqual(str, type(soup.prettify())) def test_prettify_can_encode_data(self): soup = self.soup("<a></a>") self.assertEqual(bytes, type(soup.prettify("utf-8"))) def test_html_entity_substitution_off_by_default(self): markup = "<b>Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!</b>" soup = self.soup(markup) encoded = soup.b.encode("utf-8") self.assertEqual(encoded, markup.encode('utf-8')) def test_encoding_substitution(self): # Here's the <meta> tag saying that a document is # encoded in Shift-JIS. meta_tag = ('<meta content="text/html; charset=x-sjis" ' 'http-equiv="Content-type"/>') soup = self.soup(meta_tag) # Parse the document, and the charset is replaced with a # generic value. self.assertEqual(soup.meta['content'], 'text/html; charset=%SOUP-ENCODING%') # Encode the document into some encoding, and the encoding is # substituted into the meta tag. utf_8 = soup.encode("utf-8") self.assertTrue(b"charset=utf-8" in utf_8) euc_jp = soup.encode("euc_jp") self.assertTrue(b"charset=euc_jp" in euc_jp) shift_jis = soup.encode("shift-jis") self.assertTrue(b"charset=shift-jis" in shift_jis) utf_16_u = soup.encode("utf-16").decode("utf-16") self.assertTrue("charset=utf-16" in utf_16_u) def test_encoding_substitution_doesnt_happen_if_tag_is_strained(self): markup = ('<head><meta content="text/html; charset=x-sjis" ' 'http-equiv="Content-type"/></head><pre>foo</pre>') # Beautiful Soup used to try to rewrite the meta tag even if the # meta tag got filtered out by the strainer. This test makes # sure that doesn't happen. strainer = SoupStrainer('pre') soup = self.soup(markup, parse_only=strainer) self.assertEqual(soup.contents[0].name, 'pre') class TestEncoding(SoupTest): """Test the ability to encode objects into strings.""" def test_unicode_string_can_be_encoded(self): html = "<b>\N{SNOWMAN}</b>" soup = self.soup(html) self.assertEqual(soup.b.string.encode("utf-8"), "\N{SNOWMAN}".encode("utf-8")) def test_tag_containing_unicode_string_can_be_encoded(self): html = "<b>\N{SNOWMAN}</b>" soup = self.soup(html) self.assertEqual( soup.b.encode("utf-8"), html.encode("utf-8")) def test_encoding_substitutes_unrecognized_characters_by_default(self): html = "<b>\N{SNOWMAN}</b>" soup = self.soup(html) self.assertEqual(soup.b.encode("ascii"), b"<b>&#9731;</b>") def test_encoding_can_be_made_strict(self): html = "<b>\N{SNOWMAN}</b>" soup = self.soup(html) self.assertRaises( UnicodeEncodeError, soup.encode, "ascii", errors="strict") class TestNavigableStringSubclasses(SoupTest): def test_cdata(self): # None of the current builders turn CDATA sections into CData # objects, but you can create them manually. soup = self.soup("") cdata = CData("foo") soup.insert(1, cdata) self.assertEqual(str(soup), "<![CDATA[foo]]>") self.assertEqual(soup.find(text="foo"), "foo") self.assertEqual(soup.contents[0], "foo") def test_doctype_ends_in_newline(self): # Unlike other NavigableString subclasses, a DOCTYPE always ends # in a newline. doctype = Doctype("foo") soup = self.soup("") soup.insert(1, doctype) self.assertEqual(soup.encode(), b"<!DOCTYPE foo>\n") class TestSoupSelector(TreeTest): HTML = """ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>The title</title> <link rel="stylesheet" href="blah.css" type="text/css" id="l1"> </head> <body> <div id="main"> <div id="inner"> <h1 id="header1">An H1</h1> <p>Some text</p> <p class="onep" id="p1">Some more text</p> <h2 id="header2">An H2</h2> <p class="class1 class2 class3" id="pmulti">Another</p> <a href="http://bob.example.org/" rel="friend met" id="bob">Bob</a> <h2 id="header3">Another H2</h2> <a id="me" href="http://simonwillison.net/" rel="me">me</a> <span class="s1"> <a href="#" id="s1a1">span1a1</a> <a href="#" id="s1a2">span1a2 <span id="s1a2s1">test</span></a> <span class="span2"> <a href="#" id="s2a1">span2a1</a> </span> <span class="span3"></span> </span> </div> <p lang="en" id="lang-en">English</p> <p lang="en-gb" id="lang-en-gb">English UK</p> <p lang="en-us" id="lang-en-us">English US</p> <p lang="fr" id="lang-fr">French</p> </div> <div id="footer"> </div> """ def setUp(self): self.soup = BeautifulSoup(self.HTML) def assertSelects(self, selector, expected_ids): el_ids = [el['id'] for el in self.soup.select(selector)] el_ids.sort() expected_ids.sort() self.assertEqual(expected_ids, el_ids, "Selector %s, expected [%s], got [%s]" % ( selector, ', '.join(expected_ids), ', '.join(el_ids) ) ) assertSelect = assertSelects def assertSelectMultiple(self, *tests): for selector, expected_ids in tests: self.assertSelect(selector, expected_ids) def test_one_tag_one(self): els = self.soup.select('title') self.assertEqual(len(els), 1) self.assertEqual(els[0].name, 'title') self.assertEqual(els[0].contents, ['The title']) def test_one_tag_many(self): els = self.soup.select('div') self.assertEqual(len(els), 3) for div in els: self.assertEqual(div.name, 'div') def test_tag_in_tag_one(self): els = self.soup.select('div div') self.assertSelects('div div', ['inner']) def test_tag_in_tag_many(self): for selector in ('html div', 'html body div', 'body div'): self.assertSelects(selector, ['main', 'inner', 'footer']) def test_tag_no_match(self): self.assertEqual(len(self.soup.select('del')), 0) def test_invalid_tag(self): self.assertEqual(len(self.soup.select('tag%t')), 0) def test_header_tags(self): self.assertSelectMultiple( ('h1', ['header1']), ('h2', ['header2', 'header3']), ) def test_class_one(self): for selector in ('.onep', 'p.onep', 'html p.onep'): els = self.soup.select(selector) self.assertEqual(len(els), 1) self.assertEqual(els[0].name, 'p') self.assertEqual(els[0]['class'], ['onep']) def test_class_mismatched_tag(self): els = self.soup.select('div.onep') self.assertEqual(len(els), 0) def test_one_id(self): for selector in ('div#inner', '#inner', 'div div#inner'): self.assertSelects(selector, ['inner']) def test_bad_id(self): els = self.soup.select('#doesnotexist') self.assertEqual(len(els), 0) def test_items_in_id(self): els = self.soup.select('div#inner p') self.assertEqual(len(els), 3) for el in els: self.assertEqual(el.name, 'p') self.assertEqual(els[1]['class'], ['onep']) self.assertFalse('class' in els[0]) def test_a_bunch_of_emptys(self): for selector in ('div#main del', 'div#main div.oops', 'div div#main'): self.assertEqual(len(self.soup.select(selector)), 0) def test_multi_class_support(self): for selector in ('.class1', 'p.class1', '.class2', 'p.class2', '.class3', 'p.class3', 'html p.class2', 'div#inner .class2'): self.assertSelects(selector, ['pmulti']) def test_multi_class_selection(self): for selector in ('.class1.class3', '.class3.class2', '.class1.class2.class3'): self.assertSelects(selector, ['pmulti']) def test_child_selector(self): self.assertSelects('.s1 > a', ['s1a1', 's1a2']) self.assertSelects('.s1 > a span', ['s1a2s1']) def test_attribute_equals(self): self.assertSelectMultiple( ('p[class="onep"]', ['p1']), ('p[id="p1"]', ['p1']), ('[class="onep"]', ['p1']), ('[id="p1"]', ['p1']), ('link[rel="stylesheet"]', ['l1']), ('link[type="text/css"]', ['l1']), ('link[href="blah.css"]', ['l1']), ('link[href="no-blah.css"]', []), ('[rel="stylesheet"]', ['l1']), ('[type="text/css"]', ['l1']), ('[href="blah.css"]', ['l1']), ('[href="no-blah.css"]', []), ('p[href="no-blah.css"]', []), ('[href="no-blah.css"]', []), ) def test_attribute_tilde(self): self.assertSelectMultiple( ('p[class~="class1"]', ['pmulti']), ('p[class~="class2"]', ['pmulti']), ('p[class~="class3"]', ['pmulti']), ('[class~="class1"]', ['pmulti']), ('[class~="class2"]', ['pmulti']), ('[class~="class3"]', ['pmulti']), ('a[rel~="friend"]', ['bob']), ('a[rel~="met"]', ['bob']), ('[rel~="friend"]', ['bob']), ('[rel~="met"]', ['bob']), ) def test_attribute_startswith(self): self.assertSelectMultiple( ('[rel^="style"]', ['l1']), ('link[rel^="style"]', ['l1']), ('notlink[rel^="notstyle"]', []), ('[rel^="notstyle"]', []), ('link[rel^="notstyle"]', []), ('link[href^="bla"]', ['l1']), ('a[href^="http://"]', ['bob', 'me']), ('[href^="http://"]', ['bob', 'me']), ('[id^="p"]', ['pmulti', 'p1']), ('[id^="m"]', ['me', 'main']), ('div[id^="m"]', ['main']), ('a[id^="m"]', ['me']), ) def test_attribute_endswith(self): self.assertSelectMultiple( ('[href$=".css"]', ['l1']), ('link[href$=".css"]', ['l1']), ('link[id$="1"]', ['l1']), ('[id$="1"]', ['l1', 'p1', 'header1', 's1a1', 's2a1', 's1a2s1']), ('div[id$="1"]', []), ('[id$="noending"]', []), ) def test_attribute_contains(self): self.assertSelectMultiple( # From test_attribute_startswith ('[rel*="style"]', ['l1']), ('link[rel*="style"]', ['l1']), ('notlink[rel*="notstyle"]', []), ('[rel*="notstyle"]', []), ('link[rel*="notstyle"]', []), ('link[href*="bla"]', ['l1']), ('a[href*="http://"]', ['bob', 'me']), ('[href*="http://"]', ['bob', 'me']), ('[id*="p"]', ['pmulti', 'p1']), ('div[id*="m"]', ['main']), ('a[id*="m"]', ['me']), # From test_attribute_endswith ('[href*=".css"]', ['l1']), ('link[href*=".css"]', ['l1']), ('link[id*="1"]', ['l1']), ('[id*="1"]', ['l1', 'p1', 'header1', 's1a1', 's1a2', 's2a1', 's1a2s1']), ('div[id*="1"]', []), ('[id*="noending"]', []), # New for this test ('[href*="."]', ['bob', 'me', 'l1']), ('a[href*="."]', ['bob', 'me']), ('link[href*="."]', ['l1']), ('div[id*="n"]', ['main', 'inner']), ('div[id*="nn"]', ['inner']), ) def test_attribute_exact_or_hypen(self): self.assertSelectMultiple( ('p[lang|="en"]', ['lang-en', 'lang-en-gb', 'lang-en-us']), ('[lang|="en"]', ['lang-en', 'lang-en-gb', 'lang-en-us']), ('p[lang|="fr"]', ['lang-fr']), ('p[lang|="gb"]', []), ) def test_attribute_exists(self): self.assertSelectMultiple( ('[rel]', ['l1', 'bob', 'me']), ('link[rel]', ['l1']), ('a[rel]', ['bob', 'me']), ('[lang]', ['lang-en', 'lang-en-gb', 'lang-en-us', 'lang-fr']), ('p[class]', ['p1', 'pmulti']), ('[blah]', []), ('p[blah]', []), ) def test_select_on_element(self): # Other tests operate on the tree; this operates on an element # within the tree. inner = self.soup.find("div", id="main") selected = inner.select("div") # The <div id="inner"> tag was selected. The <div id="footer"> # tag was not. self.assertSelectsIDs(selected, ['inner'])
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 2925, 367, 14562, 28028, 1159, 3123, 27773, 3102, 14, 199, 199, 1918, 3123, 27773, 3102, 787, 314, 2446, 30268, 402, 1808, 14562, 199, 12341, 1806, 2951, 1808, 282, 1798, 14, 199, 199, 31409, 21295, 911, 1900, 3365, 14562, 28028, 14416, 1627, 314, 199, 7191, 9189, 12, 1325, 1006, 14562, 28028, 14416, 883, 506, 1468, 7460, 543, 314, 199, 2474, 12470, 2348, 14, 199, 624, 199, 199, 646, 1331, 199, 646, 5927, 199, 646, 295, 199, 646, 3598, 199, 504, 9922, 20, 492, 17132, 199, 504, 9922, 20, 14, 5649, 492, 334, 272, 6545, 63, 5189, 12, 272, 24581, 20437, 12, 199, 9, 199, 504, 9922, 20, 14, 2108, 492, 334, 272, 445, 1451, 12, 272, 4226, 3667, 12, 272, 20721, 16725, 1558, 12, 272, 28028, 933, 6322, 281, 12, 272, 8053, 12, 199, 9, 199, 504, 9922, 20, 14, 4776, 492, 334, 272, 28028, 774, 12, 272, 3372, 3917, 12, 199, 9, 199, 199, 4317, 63, 8248, 540, 63, 19743, 275, 334, 5649, 63, 5189, 14, 3892, 480, 1652, 531, 365, 440, 488, 9, 199, 44, 4317, 63, 19743, 275, 334, 5649, 63, 5189, 14, 3892, 480, 22899, 531, 365, 440, 488, 9, 199, 199, 533, 12178, 774, 8, 12341, 774, 304, 339, 347, 702, 5446, 83, 8, 277, 12, 3762, 12, 1077, 63, 1431, 304, 267, 408, 5483, 3238, 626, 314, 1627, 3762, 1172, 314, 3211, 1318, 14, 398, 961, 365, 1202, 315, 2295, 626, 5627, 282, 22219, 402, 3762, 12, 1924, 267, 3035, 282, 2849, 1059, 12, 436, 2066, 3504, 9842, 3326, 701, 267, 2005, 14729, 14, 267, 408, 267, 291, 14, 629, 779, 1450, 14, 875, 367, 1947, 315, 3762, 467, 1077, 63, 1431, 9, 339, 347, 702, 5446, 83, 12818, 8, 277, 12, 3762, 12, 1077, 63, 1431, 304, 267, 408, 5483, 3238, 626, 314, 1627, 3762, 1172, 314, 3211, 11449, 14, 398, 961, 365, 1202, 315, 2295, 626, 5627, 282, 22219, 402, 3762, 12, 1924, 267, 3035, 282, 2849, 1059, 12, 436, 2066, 3504, 9842, 3326, 701, 267, 2005, 14729, 14, 267, 408, 267, 291, 14, 629, 779, 1450, 459, 344, 418, 367, 1947, 315, 3762, 467, 1077, 63, 1431, 9, 421, 199, 533, 1379, 6591, 8, 3987, 774, 304, 272, 408, 6845, 2295, 402, 314, 2342, 342, 1083, 14, 339, 2342, 342, 2951, 4882, 2342, 63, 452, 342, 543, 2304, 29, 17, 12, 880, 652, 1159, 440, 12470, 1006, 272, 626, 294, 810, 3202, 590, 2348, 14, 272, 408, 339, 347, 511, 63, 1623, 63, 1450, 8, 277, 304, 267, 9108, 275, 291, 14, 9317, 6757, 65, 30, 17, 1108, 65, 2535, 66, 30, 18, 1108, 66, 2535, 65, 30, 19, 1108, 65, 2535, 66, 30, 20, 1108, 66, 9579, 267, 291, 14, 629, 8, 9317, 14, 1623, 480, 66, 3471, 875, 12, 298, 18, 531, 339, 347, 511, 63, 2975, 63, 505, 63, 1623, 8, 277, 304, 267, 9108, 275, 291, 14, 9317, 4827, 72, 17, 30, 50, 13733, 75, 3300, 14614, 12430, 30234, 83, 1108, 72, 17, 5971, 267, 291, 14, 629, 8, 9317, 14, 1623, 8, 505, 534, 50, 13733, 75, 3300, 14614, 12430, 30234, 83, 659, 283, 50, 13733, 75, 3300, 14614, 12430, 30234, 83, 358, 199, 199, 533, 1379, 6591, 2422, 8, 3987, 774, 304, 272, 408, 6845, 2295, 402, 314, 2342, 63, 452, 342, 1083, 1041, 339, 347, 511, 63, 1623, 63, 452, 63, 505, 63, 2415, 8, 277, 304, 267, 408, 5556, 883, 2754, 314, 3123, 367, 1318, 3380, 1041, 267, 9108, 275, 291, 14, 9317, 6757, 1360, 30, 5686, 28, 66, 30, 1700, 1108, 66, 3072, 9932, 1108, 1360, 9579, 267, 327, 1316, 2442, 1336, 14, 267, 291, 14, 629, 8, 9317, 14, 1623, 63, 452, 8, 505, 628, 1700, 1288, 2097, 1700, 3135, 267, 327, 9814, 1263, 402, 282, 1329, 402, 3326, 14, 267, 291, 14, 629, 8, 288, 9108, 14, 1623, 63, 452, 8, 505, 6270, 5686, 401, 298, 1700, 10252, 2097, 5686, 401, 298, 1700, 3135, 267, 327, 9814, 282, 5578, 3965, 14, 267, 291, 14, 629, 8, 9317, 14, 1623, 63, 452, 8, 505, 29, 264, 14, 2014, 360, 2795, 3855, 586, 2097, 5686, 401, 298, 1700, 401, 1557, 9932, 1105, 267, 327, 9814, 7003, 14, 267, 291, 14, 629, 8, 9317, 14, 1623, 63, 452, 8, 505, 29, 549, 395, 586, 2097, 5686, 401, 298, 1700, 401, 1557, 9932, 1105, 339, 347, 511, 63, 1623, 63, 452, 63, 3097, 8, 277, 304, 267, 408, 5556, 883, 2304, 314, 1329, 402, 2974, 2138, 701, 2342, 63, 452, 1041, 267, 9108, 275, 291, 14, 9317, 6757, 65, 30, 17, 1108, 65, 2535, 65, 30, 18, 1108, 65, 2535, 65, 30, 19, 1108, 65, 2535, 65, 30, 20, 1108, 65, 2535, 65, 30, 21, 1108, 65, 9579, 267, 291, 14, 28761, 8, 9317, 14, 1623, 63, 452, 360, 65, 297, 2304, 29, 19, 395, 2097, 17, 401, 298, 18, 401, 298, 19, 3135, 267, 291, 14, 28761, 8, 9317, 14, 1623, 63, 452, 360, 65, 297, 2304, 29, 17, 395, 2097, 17, 3135, 267, 291, 14, 28761, 8, 288, 9108, 14, 1623, 63, 452, 360, 65, 297, 2304, 29, 709, 395, 2097, 17, 401, 298, 18, 401, 298, 19, 401, 298, 20, 401, 298, 21, 3135, 398, 327, 437, 2304, 402, 378, 4910, 949, 2304, 14, 267, 291, 14, 28761, 8, 288, 9108, 14, 1623, 63, 452, 360, 65, 297, 2304, 29, 16, 395, 2097, 17, 401, 298, 18, 401, 298, 19, 401, 298, 20, 401, 298, 21, 3135, 339, 347, 511, 63, 25566, 63, 65, 63, 1450, 63, 374, 63, 25566, 63, 6452, 8, 277, 304, 267, 9108, 275, 291, 14, 9317, 6757, 65, 30, 17, 1108, 65, 2535, 66, 30, 18, 28, 65, 1305, 534, 1421, 8423, 19, 1108, 65, 2957, 66, 9579, 267, 291, 14, 28761, 8, 9317, 360, 65, 297, 2304, 29, 17, 395, 2097, 17, 3135, 267, 291, 14, 28761, 8, 9317, 14, 66, 8, 344, 628, 1421, 1288, 2097, 19, 3135, 199, 199, 533, 1379, 6591, 2422, 6845, 985, 10749, 8, 3987, 774, 304, 339, 347, 511, 63, 1623, 63, 991, 63, 19980, 63, 354, 8, 277, 304, 267, 9108, 275, 291 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 2925, 367, 14562, 28028, 1159, 3123, 27773, 3102, 14, 199, 199, 1918, 3123, 27773, 3102, 787, 314, 2446, 30268, 402, 1808, 14562, 199, 12341, 1806, 2951, 1808, 282, 1798, 14, 199, 199, 31409, 21295, 911, 1900, 3365, 14562, 28028, 14416, 1627, 314, 199, 7191, 9189, 12, 1325, 1006, 14562, 28028, 14416, 883, 506, 1468, 7460, 543, 314, 199, 2474, 12470, 2348, 14, 199, 624, 199, 199, 646, 1331, 199, 646, 5927, 199, 646, 295, 199, 646, 3598, 199, 504, 9922, 20, 492, 17132, 199, 504, 9922, 20, 14, 5649, 492, 334, 272, 6545, 63, 5189, 12, 272, 24581, 20437, 12, 199, 9, 199, 504, 9922, 20, 14, 2108, 492, 334, 272, 445, 1451, 12, 272, 4226, 3667, 12, 272, 20721, 16725, 1558, 12, 272, 28028, 933, 6322, 281, 12, 272, 8053, 12, 199, 9, 199, 504, 9922, 20, 14, 4776, 492, 334, 272, 28028, 774, 12, 272, 3372, 3917, 12, 199, 9, 199, 199, 4317, 63, 8248, 540, 63, 19743, 275, 334, 5649, 63, 5189, 14, 3892, 480, 1652, 531, 365, 440, 488, 9, 199, 44, 4317, 63, 19743, 275, 334, 5649, 63, 5189, 14, 3892, 480, 22899, 531, 365, 440, 488, 9, 199, 199, 533, 12178, 774, 8, 12341, 774, 304, 339, 347, 702, 5446, 83, 8, 277, 12, 3762, 12, 1077, 63, 1431, 304, 267, 408, 5483, 3238, 626, 314, 1627, 3762, 1172, 314, 3211, 1318, 14, 398, 961, 365, 1202, 315, 2295, 626, 5627, 282, 22219, 402, 3762, 12, 1924, 267, 3035, 282, 2849, 1059, 12, 436, 2066, 3504, 9842, 3326, 701, 267, 2005, 14729, 14, 267, 408, 267, 291, 14, 629, 779, 1450, 14, 875, 367, 1947, 315, 3762, 467, 1077, 63, 1431, 9, 339, 347, 702, 5446, 83, 12818, 8, 277, 12, 3762, 12, 1077, 63, 1431, 304, 267, 408, 5483, 3238, 626, 314, 1627, 3762, 1172, 314, 3211, 11449, 14, 398, 961, 365, 1202, 315, 2295, 626, 5627, 282, 22219, 402, 3762, 12, 1924, 267, 3035, 282, 2849, 1059, 12, 436, 2066, 3504, 9842, 3326, 701, 267, 2005, 14729, 14, 267, 408, 267, 291, 14, 629, 779, 1450, 459, 344, 418, 367, 1947, 315, 3762, 467, 1077, 63, 1431, 9, 421, 199, 533, 1379, 6591, 8, 3987, 774, 304, 272, 408, 6845, 2295, 402, 314, 2342, 342, 1083, 14, 339, 2342, 342, 2951, 4882, 2342, 63, 452, 342, 543, 2304, 29, 17, 12, 880, 652, 1159, 440, 12470, 1006, 272, 626, 294, 810, 3202, 590, 2348, 14, 272, 408, 339, 347, 511, 63, 1623, 63, 1450, 8, 277, 304, 267, 9108, 275, 291, 14, 9317, 6757, 65, 30, 17, 1108, 65, 2535, 66, 30, 18, 1108, 66, 2535, 65, 30, 19, 1108, 65, 2535, 66, 30, 20, 1108, 66, 9579, 267, 291, 14, 629, 8, 9317, 14, 1623, 480, 66, 3471, 875, 12, 298, 18, 531, 339, 347, 511, 63, 2975, 63, 505, 63, 1623, 8, 277, 304, 267, 9108, 275, 291, 14, 9317, 4827, 72, 17, 30, 50, 13733, 75, 3300, 14614, 12430, 30234, 83, 1108, 72, 17, 5971, 267, 291, 14, 629, 8, 9317, 14, 1623, 8, 505, 534, 50, 13733, 75, 3300, 14614, 12430, 30234, 83, 659, 283, 50, 13733, 75, 3300, 14614, 12430, 30234, 83, 358, 199, 199, 533, 1379, 6591, 2422, 8, 3987, 774, 304, 272, 408, 6845, 2295, 402, 314, 2342, 63, 452, 342, 1083, 1041, 339, 347, 511, 63, 1623, 63, 452, 63, 505, 63, 2415, 8, 277, 304, 267, 408, 5556, 883, 2754, 314, 3123, 367, 1318, 3380, 1041, 267, 9108, 275, 291, 14, 9317, 6757, 1360, 30, 5686, 28, 66, 30, 1700, 1108, 66, 3072, 9932, 1108, 1360, 9579, 267, 327, 1316, 2442, 1336, 14, 267, 291, 14, 629, 8, 9317, 14, 1623, 63, 452, 8, 505, 628, 1700, 1288, 2097, 1700, 3135, 267, 327, 9814, 1263, 402, 282, 1329, 402, 3326, 14, 267, 291, 14, 629, 8, 288, 9108, 14, 1623, 63, 452, 8, 505, 6270, 5686, 401, 298, 1700, 10252, 2097, 5686, 401, 298, 1700, 3135, 267, 327, 9814, 282, 5578, 3965, 14, 267, 291, 14, 629, 8, 9317, 14, 1623, 63, 452, 8, 505, 29, 264, 14, 2014, 360, 2795, 3855, 586, 2097, 5686, 401, 298, 1700, 401, 1557, 9932, 1105, 267, 327, 9814, 7003, 14, 267, 291, 14, 629, 8, 9317, 14, 1623, 63, 452, 8, 505, 29, 549, 395, 586, 2097, 5686, 401, 298, 1700, 401, 1557, 9932, 1105, 339, 347, 511, 63, 1623, 63, 452, 63, 3097, 8, 277, 304, 267, 408, 5556, 883, 2304, 314, 1329, 402, 2974, 2138, 701, 2342, 63, 452, 1041, 267, 9108, 275, 291, 14, 9317, 6757, 65, 30, 17, 1108, 65, 2535, 65, 30, 18, 1108, 65, 2535, 65, 30, 19, 1108, 65, 2535, 65, 30, 20, 1108, 65, 2535, 65, 30, 21, 1108, 65, 9579, 267, 291, 14, 28761, 8, 9317, 14, 1623, 63, 452, 360, 65, 297, 2304, 29, 19, 395, 2097, 17, 401, 298, 18, 401, 298, 19, 3135, 267, 291, 14, 28761, 8, 9317, 14, 1623, 63, 452, 360, 65, 297, 2304, 29, 17, 395, 2097, 17, 3135, 267, 291, 14, 28761, 8, 288, 9108, 14, 1623, 63, 452, 360, 65, 297, 2304, 29, 709, 395, 2097, 17, 401, 298, 18, 401, 298, 19, 401, 298, 20, 401, 298, 21, 3135, 398, 327, 437, 2304, 402, 378, 4910, 949, 2304, 14, 267, 291, 14, 28761, 8, 288, 9108, 14, 1623, 63, 452, 360, 65, 297, 2304, 29, 16, 395, 2097, 17, 401, 298, 18, 401, 298, 19, 401, 298, 20, 401, 298, 21, 3135, 339, 347, 511, 63, 25566, 63, 65, 63, 1450, 63, 374, 63, 25566, 63, 6452, 8, 277, 304, 267, 9108, 275, 291, 14, 9317, 6757, 65, 30, 17, 1108, 65, 2535, 66, 30, 18, 28, 65, 1305, 534, 1421, 8423, 19, 1108, 65, 2957, 66, 9579, 267, 291, 14, 28761, 8, 9317, 360, 65, 297, 2304, 29, 17, 395, 2097, 17, 3135, 267, 291, 14, 28761, 8, 9317, 14, 66, 8, 344, 628, 1421, 1288, 2097, 19, 3135, 199, 199, 533, 1379, 6591, 2422, 6845, 985, 10749, 8, 3987, 774, 304, 339, 347, 511, 63, 1623, 63, 991, 63, 19980, 63, 354, 8, 277, 304, 267, 9108, 275, 291, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
makersauce/ConstructSecur
Overlord/newAdmin.py
1
1055
#!/usr/bin/env python from dblayer import DBlayer import getpass db = DBlayer(DEBUG=True) print 'so you want to add an admin, eh?' name = raw_input("full name: ") usern = raw_input("user name: ") trys = 0 while True: pw = getpass.getpass("password: ") pw2 = getpass.getpass("re-type password: ") if pw == pw2: print 'hey, great password, btw.' break else: print 'passwords didn\'t match... try again' if trys > 2: print 'get better soon.' exit(0) trys += 1 trys = 0 while True: swipe = getpass.getpass("swipe card and press enter: ") swipe2 = getpass.getpass("re-swipe card and press enter: ") if swipe == swipe2: print 'swipe worked.' break else: print 'swipe didn\'t work... try again' if trys > 2: print 'get a better card.' exit(0) trys += 1 admin = { 'name' : name, 'admin-user' : usern, 'admin-pw' : pw, 'class' : 'admin', 'ident' : swipe } db.addInitial(admin)
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 504, 1592, 1897, 492, 6249, 1897, 199, 646, 18354, 199, 199, 697, 275, 6249, 1897, 8, 5287, 29, 549, 9, 199, 199, 1361, 283, 1152, 1265, 2934, 370, 1050, 376, 4628, 12, 325, 72, 14069, 199, 354, 275, 3066, 63, 1210, 480, 2861, 536, 26, 6099, 199, 751, 78, 275, 3066, 63, 1210, 480, 751, 536, 26, 6099, 199, 454, 588, 275, 378, 199, 6710, 715, 26, 272, 19206, 275, 18354, 14, 27481, 480, 2060, 26, 6099, 272, 19206, 18, 275, 18354, 14, 27481, 480, 264, 13, 466, 2505, 26, 6099, 272, 340, 19206, 508, 19206, 18, 26, 6722, 870, 283, 426, 89, 12, 27254, 2505, 12, 330, 8122, 3530, 6722, 2059, 272, 587, 26, 6722, 870, 283, 28608, 9980, 3985, 84, 1336, 1396, 862, 4020, 7, 272, 340, 5651, 588, 690, 499, 26, 267, 870, 283, 362, 8034, 18930, 3530, 267, 4458, 8, 16, 9, 272, 5651, 588, 847, 413, 199, 454, 588, 275, 378, 199, 6710, 715, 26, 272, 5584, 3662, 275, 18354, 14, 27481, 480, 3519, 3662, 12564, 436, 15105, 9509, 26, 6099, 272, 5584, 3662, 18, 275, 18354, 14, 27481, 480, 264, 13, 3519, 3662, 12564, 436, 15105, 9509, 26, 6099, 272, 340, 5584, 3662, 508, 5584, 3662, 18, 26, 6722, 870, 283, 3519, 3662, 26731, 3530, 6722, 2059, 272, 587, 26, 6722, 870, 283, 3519, 3662, 9980, 3985, 84, 1736, 1396, 862, 4020, 7, 272, 340, 5651, 588, 690, 499, 26, 267, 870, 283, 362, 282, 8034, 12564, 3530, 267, 4458, 8, 16, 9, 272, 5651, 588, 847, 413, 6905, 199, 2113, 275, 469, 288, 283, 354, 7, 520, 536, 12, 288, 283, 2113, 13, 751, 7, 520, 922, 78, 12, 288, 283, 2113, 13, 8796, 7, 520, 19206, 12, 288, 283, 533, 7, 520, 283, 2113, 297, 288, 283, 5425, 7, 520, 5584, 3662, 267, 789, 199, 199, 697, 14, 525, 5733, 8, 2113, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 504, 1592, 1897, 492, 6249, 1897, 199, 646, 18354, 199, 199, 697, 275, 6249, 1897, 8, 5287, 29, 549, 9, 199, 199, 1361, 283, 1152, 1265, 2934, 370, 1050, 376, 4628, 12, 325, 72, 14069, 199, 354, 275, 3066, 63, 1210, 480, 2861, 536, 26, 6099, 199, 751, 78, 275, 3066, 63, 1210, 480, 751, 536, 26, 6099, 199, 454, 588, 275, 378, 199, 6710, 715, 26, 272, 19206, 275, 18354, 14, 27481, 480, 2060, 26, 6099, 272, 19206, 18, 275, 18354, 14, 27481, 480, 264, 13, 466, 2505, 26, 6099, 272, 340, 19206, 508, 19206, 18, 26, 6722, 870, 283, 426, 89, 12, 27254, 2505, 12, 330, 8122, 3530, 6722, 2059, 272, 587, 26, 6722, 870, 283, 28608, 9980, 3985, 84, 1336, 1396, 862, 4020, 7, 272, 340, 5651, 588, 690, 499, 26, 267, 870, 283, 362, 8034, 18930, 3530, 267, 4458, 8, 16, 9, 272, 5651, 588, 847, 413, 199, 454, 588, 275, 378, 199, 6710, 715, 26, 272, 5584, 3662, 275, 18354, 14, 27481, 480, 3519, 3662, 12564, 436, 15105, 9509, 26, 6099, 272, 5584, 3662, 18, 275, 18354, 14, 27481, 480, 264, 13, 3519, 3662, 12564, 436, 15105, 9509, 26, 6099, 272, 340, 5584, 3662, 508, 5584, 3662, 18, 26, 6722, 870, 283, 3519, 3662, 26731, 3530, 6722, 2059, 272, 587, 26, 6722, 870, 283, 3519, 3662, 9980, 3985, 84, 1736, 1396, 862, 4020, 7, 272, 340, 5651, 588, 690, 499, 26, 267, 870, 283, 362, 282, 8034, 12564, 3530, 267, 4458, 8, 16, 9, 272, 5651, 588, 847, 413, 6905, 199, 2113, 275, 469, 288, 283, 354, 7, 520, 536, 12, 288, 283, 2113, 13, 751, 7, 520, 922, 78, 12, 288, 283, 2113, 13, 8796, 7, 520, 19206, 12, 288, 283, 533, 7, 520, 283, 2113, 297, 288, 283, 5425, 7, 520, 5584, 3662, 267, 789, 199, 199, 697, 14, 525, 5733, 8, 2113, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
Yukarumya/Yukarum-Redfoxes
testing/talos/talos/mainthreadio.py
1
5541
# -*- Mode: python; tab-width: 8; indent-tabs-mode: nil -*- # vim: set ts=8 sts=4 et sw=4 tw=80: # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. import os import utils import whitelist SCRIPT_DIR = os.path.abspath(os.path.realpath(os.path.dirname(__file__))) STAGE_STARTUP = 0 STAGE_STRINGS = ('startup', 'normal', 'shutdown') LENGTH_IO_ENTRY = 5 LENGTH_NEXT_STAGE_ENTRY = 2 TOKEN_NEXT_STAGE = 'NEXT-STAGE' INDEX_OPERATION = 1 INDEX_DURATION = 2 INDEX_EVENT_SOURCE = 3 INDEX_FILENAME = 4 KEY_COUNT = 'Count' KEY_DURATION = 'Duration' KEY_NO_FILENAME = '(not available)' KEY_RUN_COUNT = 'RunCount' LEAKED_SYMLINK_PREFIX = "::\\{" PATH_SUBSTITUTIONS = {'profile': '{profile}', 'firefox': '{xre}', 'desktop': '{desktop}', 'fonts': '{fonts}', 'appdata': ' {appdata}'} NAME_SUBSTITUTIONS = {'installtime': '{time}', 'prefetch': '{prefetch}', 'thumbnails': '{thumbnails}', 'windows media player': '{media_player}'} TUPLE_FILENAME_INDEX = 2 WHITELIST_FILENAME = os.path.join(SCRIPT_DIR, 'mtio-whitelist.json') def parse(logfilename, data): try: with open(logfilename, 'r') as logfile: if not logfile: return False stage = STAGE_STARTUP for line in logfile: prev_filename = str() entries = line.strip().split(',') if len(entries) == LENGTH_IO_ENTRY: if stage == STAGE_STARTUP: continue if entries[INDEX_FILENAME] == KEY_NO_FILENAME: continue # Format 1: I/O entry # Temporary hack: logs are leaking Windows NT symlinks. # We need to ignore those. if entries[INDEX_FILENAME]\ .startswith(LEAKED_SYMLINK_PREFIX): continue # We'll key each entry on (stage, event source, # filename, operation) key_tuple = (STAGE_STRINGS[stage], entries[INDEX_EVENT_SOURCE], entries[INDEX_FILENAME], entries[INDEX_OPERATION]) if key_tuple not in data: data[key_tuple] = { KEY_COUNT: 1, KEY_RUN_COUNT: 1, KEY_DURATION: float(entries[INDEX_DURATION]) } else: if prev_filename != entries[INDEX_FILENAME]: data[key_tuple][KEY_RUN_COUNT] += 1 data[key_tuple][KEY_COUNT] += 1 data[key_tuple][KEY_DURATION] += \ float(entries[INDEX_DURATION]) prev_filename = entries[INDEX_FILENAME] elif len(entries) == LENGTH_NEXT_STAGE_ENTRY and \ entries[1] == TOKEN_NEXT_STAGE: # Format 2: next stage stage = stage + 1 return True except IOError as e: print("%s: %s" % (e.filename, e.strerror)) return False def write_output(outfilename, data): # Write the data out so that we can track it try: with open(outfilename, 'w') as outfile: outfile.write("[\n") for idx, (key, value) in utils.indexed_items(data.iteritems()): output = " [\"%s\", \"%s\", \"%s\", \"%s\", %d, %d, %f]" % ( key[0], key[1], key[2], key[3], value[KEY_COUNT], value[KEY_RUN_COUNT], value[KEY_DURATION]) outfile.write(output) if idx >= 0: outfile.write(",\n") else: outfile.write("\n") outfile.write("]\n") return True except IOError as e: print("%s: %s" % (e.filename, e.strerror)) return False def main(argv): if len(argv) < 4: print("Usage: %s <main_thread_io_log_file> <output_file> <xre_path>" % argv[0]) return 1 if not os.path.exists(argv[3]): print("XRE Path \"%s\" does not exist" % argv[3]) return 1 data = {} if not parse(argv[1], data): print("Log parsing failed") return 1 wl = whitelist.Whitelist(test_name='mainthreadio', paths={"{xre}": argv[3]}, path_substitutions=PATH_SUBSTITUTIONS, name_substitutions=NAME_SUBSTITUTIONS) if not wl.load(WHITELIST_FILENAME): print("Failed to load whitelist") return 1 wl.filter(data, TUPLE_FILENAME_INDEX) if not write_output(argv[2], data): return 1 # Disabled until we enable TBPL oranges # search for unknown filenames errors = wl.check(data, TUPLE_FILENAME_INDEX) if errors: strs = wl.get_error_strings(errors) wl.print_errors(strs) # search for duration > 1.0 errors = wl.checkDuration(data, TUPLE_FILENAME_INDEX, 'Duration') if errors: strs = wl.get_error_strings(errors) wl.print_errors(strs) return 0 if __name__ == "__main__": import sys sys.exit(main(sys.argv))
mpl-2.0
[ 3, 1882, 4900, 26, 2366, 27, 5174, 13, 2063, 26, 1695, 27, 4363, 13, 8741, 13, 632, 26, 32644, 1882, 199, 3, 6695, 26, 663, 6714, 29, 24, 23014, 29, 20, 10844, 5584, 29, 20, 8900, 29, 1257, 26, 199, 3, 961, 5800, 5495, 8204, 365, 5420, 370, 314, 2895, 402, 314, 17728, 1684, 199, 3, 844, 12, 373, 14, 499, 14, 16, 14, 982, 282, 1331, 402, 314, 28481, 1990, 440, 1854, 543, 642, 199, 3, 570, 12, 2047, 883, 3332, 1373, 737, 1455, 921, 12102, 14, 1308, 15, 3950, 15, 18, 14, 16, 8083, 199, 199, 646, 747, 199, 646, 3778, 199, 646, 22671, 199, 199, 10484, 63, 3022, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 11091, 8, 736, 14, 515, 14, 3475, 3460, 493, 29658, 199, 199, 840, 2962, 63, 7363, 2160, 275, 378, 199, 840, 2962, 63, 31271, 275, 661, 16480, 297, 283, 3302, 297, 283, 8831, 358, 199, 199, 9127, 63, 2090, 63, 7285, 275, 959, 199, 9127, 63, 21917, 63, 840, 2962, 63, 7285, 275, 499, 199, 8803, 63, 21917, 63, 840, 2962, 275, 283, 21917, 13, 840, 2962, 7, 199, 199, 10215, 63, 31324, 275, 413, 199, 10215, 63, 36, 15301, 275, 499, 199, 10215, 63, 8193, 63, 10187, 275, 650, 199, 10215, 63, 15440, 275, 841, 199, 199, 3078, 63, 8760, 275, 283, 2353, 7, 199, 3078, 63, 36, 15301, 275, 283, 13283, 7, 199, 3078, 63, 2826, 63, 15440, 275, 8189, 1397, 2808, 3171, 199, 3078, 63, 9390, 63, 8760, 275, 283, 2540, 2353, 7, 199, 199, 906, 7872, 1149, 63, 4669, 1698, 12394, 63, 6351, 275, 27472, 1103, 6641, 199, 199, 3243, 63, 6348, 8821, 934, 2823, 275, 791, 2913, 356, 5041, 2913, 7293, 283, 15394, 356, 5041, 88, 264, 7293, 1993, 283, 14487, 356, 5041, 14487, 7293, 1993, 283, 19864, 356, 5041, 19864, 7293, 283, 571, 576, 356, 283, 469, 571, 576, 93, 936, 199, 2339, 63, 6348, 8821, 934, 2823, 275, 791, 3174, 521, 356, 5041, 521, 7293, 283, 15576, 356, 5041, 15576, 7293, 1993, 283, 8311, 83, 356, 5041, 8311, 83, 7293, 1993, 283, 8258, 5898, 7748, 356, 5041, 4603, 63, 6147, 93, 936, 199, 199, 52, 28970, 63, 15440, 63, 10215, 275, 499, 199, 18817, 4924, 63, 15440, 275, 747, 14, 515, 14, 904, 8, 10484, 63, 3022, 12, 283, 77, 4538, 13, 14189, 14, 1001, 358, 421, 199, 318, 2198, 8, 793, 1501, 12, 666, 304, 272, 862, 26, 267, 543, 1551, 8, 793, 1501, 12, 283, 82, 358, 465, 17251, 26, 288, 340, 440, 17251, 26, 355, 372, 756, 288, 9546, 275, 4384, 2962, 63, 7363, 2160, 288, 367, 1004, 315, 17251, 26, 355, 5071, 63, 1501, 275, 620, 342, 355, 4811, 275, 1004, 14, 1913, 1252, 1294, 11917, 355, 340, 822, 8, 3189, 9, 508, 491, 32106, 63, 2090, 63, 7285, 26, 490, 340, 9546, 508, 4384, 2962, 63, 7363, 2160, 26, 717, 1980, 490, 340, 4811, 59, 10215, 63, 15440, 61, 508, 9301, 63, 2826, 63, 15440, 26, 717, 1980, 490, 327, 9701, 413, 26, 473, 15, 47, 2397, 4951, 327, 21791, 11176, 26, 9610, 787, 1026, 11124, 5417, 23350, 19891, 14, 490, 327, 2136, 1929, 370, 3686, 5204, 14, 490, 340, 4811, 59, 10215, 63, 15440, 7272, 1169, 1275, 2460, 8, 906, 7872, 1149, 63, 4669, 1698, 12394, 63, 6351, 304, 717, 1980, 4951, 327, 2136, 7171, 790, 1924, 2397, 641, 334, 8614, 12, 1566, 1350, 12, 490, 327, 1788, 12, 3439, 9, 490, 790, 63, 2960, 275, 334, 840, 2962, 63, 31271, 59, 8614, 467, 639, 4811, 59, 10215, 63, 8193, 63, 10187, 467, 639, 4811, 59, 10215, 63, 15440, 467, 639, 4811, 59, 10215, 63, 31324, 566, 490, 340, 790, 63, 2960, 440, 315, 666, 26, 717, 666, 59, 498, 63, 2960, 61, 275, 469, 1169, 9301, 63, 8760, 26, 413, 12, 1169, 9301, 63, 9390, 63, 8760, 26, 413, 12, 1169, 9301, 63, 36, 15301, 26, 2069, 8, 3189, 59, 10215, 63, 36, 15301, 566, 717, 789, 490, 587, 26, 717, 340, 5071, 63, 1501, 1137, 4811, 59, 10215, 63, 15440, 2189, 1169, 666, 59, 498, 63, 2960, 1527, 3078, 63, 9390, 63, 8760, 61, 847, 413, 717, 666, 59, 498, 63, 2960, 1527, 3078, 63, 8760, 61, 847, 413, 717, 666, 59, 498, 63, 2960, 1527, 3078, 63, 36, 15301, 61, 847, 971, 1169, 2069, 8, 3189, 59, 10215, 63, 36, 15301, 566, 490, 5071, 63, 1501, 275, 4811, 59, 10215, 63, 15440, 61, 355, 916, 822, 8, 3189, 9, 508, 491, 32106, 63, 21917, 63, 840, 2962, 63, 7285, 436, 971, 717, 4811, 59, 17, 61, 508, 18243, 63, 21917, 63, 840, 2962, 26, 490, 327, 9701, 499, 26, 2163, 9546, 490, 9546, 275, 9546, 435, 413, 288, 372, 715, 272, 871, 5925, 465, 325, 26, 267, 870, 3647, 83, 26, 450, 83, 2, 450, 334, 69, 14, 1501, 12, 325, 14, 20395, 430, 267, 372, 756, 421, 199, 318, 2218, 63, 1199, 8, 548, 1501, 12, 666, 304, 272, 327, 6990, 314, 666, 734, 880, 626, 781, 883, 4426, 652, 272, 862, 26, 267, 543, 1551, 8, 548, 1501, 12, 283, 87, 358, 465, 4386, 26, 288, 4386, 14, 952, 480, 7023, 78, 531, 288, 367, 4280, 12, 334, 498, 12, 574, 9, 315, 3778, 14, 16821, 63, 1744, 8, 576, 14, 4611, 5109, 355, 1072, 275, 298, 259, 359, 4451, 5, 83, 20756, 18321, 83, 20756, 18321, 83, 20756, 18321, 83, 20756, 450, 68, 12, 450, 68, 12, 450, 70, 8480, 450, 334, 490, 790, 59, 16, 467, 790, 59, 17, 467, 790, 59, 18, 467, 790, 59, 19, 467, 574, 59, 3078, 63, 8760, 467, 490, 574, 59, 3078, 63, 9390, 63, 8760, 467, 574, 59, 3078, 63, 36, 15301, 566, 355, 4386, 14, 952, 8, 1199, 9, 355, 340, 4280, 2356, 378, 26, 490, 4386, 14, 952, 11854, 60, 78, 531, 355, 587, 26, 490, 4386, 14, 952, 4582, 78, 531, 288, 4386, 14, 952, 480, 7272, 78, 531, 288, 372, 715, 272, 871, 5925, 465, 325, 26, 267, 870, 3647, 83, 26, 450, 83, 2, 450, 334, 69, 14, 1501, 12, 325, 14, 20395, 430, 267, 372, 756, 421, 199, 318 ]
[ 1882, 4900, 26, 2366, 27, 5174, 13, 2063, 26, 1695, 27, 4363, 13, 8741, 13, 632, 26, 32644, 1882, 199, 3, 6695, 26, 663, 6714, 29, 24, 23014, 29, 20, 10844, 5584, 29, 20, 8900, 29, 1257, 26, 199, 3, 961, 5800, 5495, 8204, 365, 5420, 370, 314, 2895, 402, 314, 17728, 1684, 199, 3, 844, 12, 373, 14, 499, 14, 16, 14, 982, 282, 1331, 402, 314, 28481, 1990, 440, 1854, 543, 642, 199, 3, 570, 12, 2047, 883, 3332, 1373, 737, 1455, 921, 12102, 14, 1308, 15, 3950, 15, 18, 14, 16, 8083, 199, 199, 646, 747, 199, 646, 3778, 199, 646, 22671, 199, 199, 10484, 63, 3022, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 11091, 8, 736, 14, 515, 14, 3475, 3460, 493, 29658, 199, 199, 840, 2962, 63, 7363, 2160, 275, 378, 199, 840, 2962, 63, 31271, 275, 661, 16480, 297, 283, 3302, 297, 283, 8831, 358, 199, 199, 9127, 63, 2090, 63, 7285, 275, 959, 199, 9127, 63, 21917, 63, 840, 2962, 63, 7285, 275, 499, 199, 8803, 63, 21917, 63, 840, 2962, 275, 283, 21917, 13, 840, 2962, 7, 199, 199, 10215, 63, 31324, 275, 413, 199, 10215, 63, 36, 15301, 275, 499, 199, 10215, 63, 8193, 63, 10187, 275, 650, 199, 10215, 63, 15440, 275, 841, 199, 199, 3078, 63, 8760, 275, 283, 2353, 7, 199, 3078, 63, 36, 15301, 275, 283, 13283, 7, 199, 3078, 63, 2826, 63, 15440, 275, 8189, 1397, 2808, 3171, 199, 3078, 63, 9390, 63, 8760, 275, 283, 2540, 2353, 7, 199, 199, 906, 7872, 1149, 63, 4669, 1698, 12394, 63, 6351, 275, 27472, 1103, 6641, 199, 199, 3243, 63, 6348, 8821, 934, 2823, 275, 791, 2913, 356, 5041, 2913, 7293, 283, 15394, 356, 5041, 88, 264, 7293, 1993, 283, 14487, 356, 5041, 14487, 7293, 1993, 283, 19864, 356, 5041, 19864, 7293, 283, 571, 576, 356, 283, 469, 571, 576, 93, 936, 199, 2339, 63, 6348, 8821, 934, 2823, 275, 791, 3174, 521, 356, 5041, 521, 7293, 283, 15576, 356, 5041, 15576, 7293, 1993, 283, 8311, 83, 356, 5041, 8311, 83, 7293, 1993, 283, 8258, 5898, 7748, 356, 5041, 4603, 63, 6147, 93, 936, 199, 199, 52, 28970, 63, 15440, 63, 10215, 275, 499, 199, 18817, 4924, 63, 15440, 275, 747, 14, 515, 14, 904, 8, 10484, 63, 3022, 12, 283, 77, 4538, 13, 14189, 14, 1001, 358, 421, 199, 318, 2198, 8, 793, 1501, 12, 666, 304, 272, 862, 26, 267, 543, 1551, 8, 793, 1501, 12, 283, 82, 358, 465, 17251, 26, 288, 340, 440, 17251, 26, 355, 372, 756, 288, 9546, 275, 4384, 2962, 63, 7363, 2160, 288, 367, 1004, 315, 17251, 26, 355, 5071, 63, 1501, 275, 620, 342, 355, 4811, 275, 1004, 14, 1913, 1252, 1294, 11917, 355, 340, 822, 8, 3189, 9, 508, 491, 32106, 63, 2090, 63, 7285, 26, 490, 340, 9546, 508, 4384, 2962, 63, 7363, 2160, 26, 717, 1980, 490, 340, 4811, 59, 10215, 63, 15440, 61, 508, 9301, 63, 2826, 63, 15440, 26, 717, 1980, 490, 327, 9701, 413, 26, 473, 15, 47, 2397, 4951, 327, 21791, 11176, 26, 9610, 787, 1026, 11124, 5417, 23350, 19891, 14, 490, 327, 2136, 1929, 370, 3686, 5204, 14, 490, 340, 4811, 59, 10215, 63, 15440, 7272, 1169, 1275, 2460, 8, 906, 7872, 1149, 63, 4669, 1698, 12394, 63, 6351, 304, 717, 1980, 4951, 327, 2136, 7171, 790, 1924, 2397, 641, 334, 8614, 12, 1566, 1350, 12, 490, 327, 1788, 12, 3439, 9, 490, 790, 63, 2960, 275, 334, 840, 2962, 63, 31271, 59, 8614, 467, 639, 4811, 59, 10215, 63, 8193, 63, 10187, 467, 639, 4811, 59, 10215, 63, 15440, 467, 639, 4811, 59, 10215, 63, 31324, 566, 490, 340, 790, 63, 2960, 440, 315, 666, 26, 717, 666, 59, 498, 63, 2960, 61, 275, 469, 1169, 9301, 63, 8760, 26, 413, 12, 1169, 9301, 63, 9390, 63, 8760, 26, 413, 12, 1169, 9301, 63, 36, 15301, 26, 2069, 8, 3189, 59, 10215, 63, 36, 15301, 566, 717, 789, 490, 587, 26, 717, 340, 5071, 63, 1501, 1137, 4811, 59, 10215, 63, 15440, 2189, 1169, 666, 59, 498, 63, 2960, 1527, 3078, 63, 9390, 63, 8760, 61, 847, 413, 717, 666, 59, 498, 63, 2960, 1527, 3078, 63, 8760, 61, 847, 413, 717, 666, 59, 498, 63, 2960, 1527, 3078, 63, 36, 15301, 61, 847, 971, 1169, 2069, 8, 3189, 59, 10215, 63, 36, 15301, 566, 490, 5071, 63, 1501, 275, 4811, 59, 10215, 63, 15440, 61, 355, 916, 822, 8, 3189, 9, 508, 491, 32106, 63, 21917, 63, 840, 2962, 63, 7285, 436, 971, 717, 4811, 59, 17, 61, 508, 18243, 63, 21917, 63, 840, 2962, 26, 490, 327, 9701, 499, 26, 2163, 9546, 490, 9546, 275, 9546, 435, 413, 288, 372, 715, 272, 871, 5925, 465, 325, 26, 267, 870, 3647, 83, 26, 450, 83, 2, 450, 334, 69, 14, 1501, 12, 325, 14, 20395, 430, 267, 372, 756, 421, 199, 318, 2218, 63, 1199, 8, 548, 1501, 12, 666, 304, 272, 327, 6990, 314, 666, 734, 880, 626, 781, 883, 4426, 652, 272, 862, 26, 267, 543, 1551, 8, 548, 1501, 12, 283, 87, 358, 465, 4386, 26, 288, 4386, 14, 952, 480, 7023, 78, 531, 288, 367, 4280, 12, 334, 498, 12, 574, 9, 315, 3778, 14, 16821, 63, 1744, 8, 576, 14, 4611, 5109, 355, 1072, 275, 298, 259, 359, 4451, 5, 83, 20756, 18321, 83, 20756, 18321, 83, 20756, 18321, 83, 20756, 450, 68, 12, 450, 68, 12, 450, 70, 8480, 450, 334, 490, 790, 59, 16, 467, 790, 59, 17, 467, 790, 59, 18, 467, 790, 59, 19, 467, 574, 59, 3078, 63, 8760, 467, 490, 574, 59, 3078, 63, 9390, 63, 8760, 467, 574, 59, 3078, 63, 36, 15301, 566, 355, 4386, 14, 952, 8, 1199, 9, 355, 340, 4280, 2356, 378, 26, 490, 4386, 14, 952, 11854, 60, 78, 531, 355, 587, 26, 490, 4386, 14, 952, 4582, 78, 531, 288, 4386, 14, 952, 480, 7272, 78, 531, 288, 372, 715, 272, 871, 5925, 465, 325, 26, 267, 870, 3647, 83, 26, 450, 83, 2, 450, 334, 69, 14, 1501, 12, 325, 14, 20395, 430, 267, 372, 756, 421, 199, 318, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
nvie/python-mode
pymode/libs/pylama/core.py
13
5335
""" Pylama's core functionality. Prepare params, check a modeline and run the checkers. """ import re import logging from collections import defaultdict from .config import process_value, LOGGER from .lint.extensions import LINTERS from .errors import DUPLICATES, Error #: The skip pattern SKIP_PATTERN = re.compile(r'# *noqa\b', re.I).search # Parse a modelines MODELINE_RE = re.compile( r'^\s*#\s+(?:pylama:)\s*((?:[\w_]*=[^:\n\s]+:?)+)', re.I | re.M) def run(path='', code=None, options=None): """ Run a code checkers with given params. :return errors: list of dictionaries with error's information """ errors = [] fileconfig = dict() params = dict() linters = LINTERS linters_params = dict() if options: linters = options.linters linters_params = options.linters_params for mask in options.file_params: if mask.match(path): fileconfig.update(options.file_params[mask]) try: with CodeContext(code, path) as ctx: code = ctx.code params = prepare_params(parse_modeline(code), fileconfig, options) LOGGER.debug('Checking params: %s', params) if params.get('skip'): return errors for item in linters: if not isinstance(item, tuple): item = (item, LINTERS.get(item)) lname, linter = item if not linter: continue lparams = linters_params.get(lname, dict()) LOGGER.info("Run %s %s", lname, lparams) for er in linter.run( path, code=code, ignore=params.get("ignore", set()), select=params.get("select", set()), params=lparams): errors.append(Error(filename=path, linter=lname, **er)) except IOError as e: LOGGER.debug("IOError %s", e) errors.append(Error(text=str(e), filename=path, linter=lname)) except SyntaxError as e: LOGGER.debug("SyntaxError %s", e) errors.append( Error(linter=lname, lnum=e.lineno, col=e.offset, text=e.args[0], filename=path)) except Exception as e: import traceback LOGGER.info(traceback.format_exc()) errors = filter_errors(errors, **params) errors = list(remove_duplicates(errors)) if code and errors: errors = filter_skiplines(code, errors) return sorted(errors, key=lambda e: e.lnum) def parse_modeline(code): """ Parse params from file's modeline. :return dict: Linter params. """ seek = MODELINE_RE.search(code) if seek: return dict(v.split('=') for v in seek.group(1).split(':')) return dict() def prepare_params(modeline, fileconfig, options): """ Prepare and merge a params from modelines and configs. :return dict: """ params = dict(skip=False, ignore=[], select=[]) if options: params['ignore'] = options.ignore params['select'] = options.select for config in filter(None, [modeline, fileconfig]): for key in ('ignore', 'select'): params[key] += process_value(key, config.get(key, [])) params['skip'] = bool(int(config.get('skip', False))) params['ignore'] = set(params['ignore']) params['select'] = set(params['select']) return params def filter_errors(errors, select=None, ignore=None, **params): """ Filter a erros by select and ignore options. :return bool: """ select = select or [] ignore = ignore or [] for e in errors: for s in select: if e.number.startswith(s): yield e break else: for s in ignore: if e.number.startswith(s): break else: yield e def filter_skiplines(code, errors): """ Filter lines by `noqa`. :return list: A filtered errors """ if not errors: return errors enums = set(er.lnum for er in errors) removed = set([ num for num, l in enumerate(code.split('\n'), 1) if num in enums and SKIP_PATTERN(l) ]) if removed: errors = [er for er in errors if er.lnum not in removed] return errors def remove_duplicates(errors): """ Remove same errors from others linters. """ passed = defaultdict(list) for error in errors: key = error.linter, error.number if key in DUPLICATES: if key in passed[error.lnum]: continue passed[error.lnum] = DUPLICATES[key] yield error class CodeContext(object): """ Read file if code is None. """ def __init__(self, code, path): """ Init context. """ self.code = code self.path = path self._file = None def __enter__(self): """ Open file and read a code. """ if self.code is None: self._file = open(self.path, 'rU') self.code = self._file.read() return self def __exit__(self, t, value, traceback): """ Close opened file. """ if self._file is not None: self._file.close() if t and LOGGER.level == logging.DEBUG: LOGGER.debug(traceback)
lgpl-3.0
[ 624, 1611, 416, 391, 1159, 6170, 9330, 14, 199, 199, 22281, 1862, 12, 1104, 282, 818, 604, 436, 1255, 314, 1104, 1192, 14, 199, 199, 624, 199, 646, 295, 199, 199, 646, 2050, 199, 504, 5055, 492, 10018, 199, 199, 504, 1275, 888, 492, 2112, 63, 585, 12, 20184, 199, 504, 1275, 3854, 14, 5359, 492, 491, 3843, 51, 199, 504, 1275, 2550, 492, 577, 2160, 2507, 16601, 12, 4520, 421, 199, 12573, 710, 3372, 3851, 199, 13525, 63, 10764, 275, 295, 14, 2014, 8, 82, 11525, 627, 889, 7096, 60, 66, 297, 295, 14, 41, 680, 1733, 199, 199, 3, 6077, 282, 818, 1278, 199, 11429, 3565, 63, 907, 275, 295, 14, 2014, 8, 272, 519, 15542, 83, 10, 20262, 83, 11, 5169, 647, 416, 391, 26, 2862, 83, 10, 17304, 26, 7023, 87, 15555, 1524, 62, 3427, 78, 60, 83, 2807, 26, 31, 6393, 3196, 272, 295, 14, 41, 1204, 295, 14, 45, 9, 421, 199, 318, 1255, 8, 515, 4581, 1233, 29, 403, 12, 1511, 29, 403, 304, 272, 408, 3378, 282, 1233, 1104, 1192, 543, 1627, 1862, 14, 339, 520, 1107, 2552, 26, 769, 402, 11196, 543, 1125, 1159, 2556, 339, 408, 272, 2552, 275, 942, 272, 570, 888, 275, 1211, 342, 272, 1862, 275, 1211, 342, 272, 7403, 878, 275, 491, 3843, 51, 272, 7403, 878, 63, 1162, 275, 1211, 342, 339, 340, 1511, 26, 267, 7403, 878, 275, 1511, 14, 472, 878, 267, 7403, 878, 63, 1162, 275, 1511, 14, 472, 878, 63, 1162, 267, 367, 3656, 315, 1511, 14, 493, 63, 1162, 26, 288, 340, 3656, 14, 1431, 8, 515, 304, 355, 570, 888, 14, 873, 8, 1419, 14, 493, 63, 1162, 59, 2629, 566, 339, 862, 26, 267, 543, 5495, 2998, 8, 600, 12, 931, 9, 465, 4027, 26, 288, 1233, 275, 4027, 14, 600, 288, 1862, 275, 9275, 63, 1162, 8, 1122, 63, 632, 604, 8, 600, 395, 570, 888, 12, 1511, 9, 288, 20184, 14, 1757, 360, 14740, 1862, 26, 450, 83, 297, 1862, 9, 953, 340, 1862, 14, 362, 360, 2759, 735, 355, 372, 2552, 953, 367, 1242, 315, 7403, 878, 26, 2234, 340, 440, 1228, 8, 1053, 12, 2008, 304, 490, 1242, 275, 334, 1053, 12, 491, 3843, 51, 14, 362, 8, 1053, 430, 2234, 634, 354, 12, 7403, 351, 275, 1242, 2234, 340, 440, 7403, 351, 26, 490, 1980, 2234, 634, 1162, 275, 7403, 878, 63, 1162, 14, 362, 8, 76, 354, 12, 1211, 1012, 355, 20184, 14, 815, 480, 2540, 450, 83, 450, 83, 401, 634, 354, 12, 634, 1162, 9, 2234, 367, 9266, 315, 7403, 351, 14, 1065, 8, 717, 931, 12, 1233, 29, 600, 12, 3686, 29, 1162, 14, 362, 480, 4247, 401, 663, 4000, 717, 3504, 29, 1162, 14, 362, 480, 2416, 401, 663, 4000, 1862, 29, 76, 1162, 304, 490, 2552, 14, 740, 8, 547, 8, 1501, 29, 515, 12, 7403, 351, 29, 76, 354, 12, 1011, 281, 430, 339, 871, 5925, 465, 325, 26, 267, 20184, 14, 1757, 480, 13760, 450, 83, 401, 325, 9, 267, 2552, 14, 740, 8, 547, 8, 505, 29, 495, 8, 69, 395, 1788, 29, 515, 12, 7403, 351, 29, 76, 354, 430, 339, 871, 12053, 465, 325, 26, 267, 20184, 14, 1757, 480, 9294, 450, 83, 401, 325, 9, 267, 2552, 14, 740, 8, 288, 4520, 8, 25240, 29, 76, 354, 12, 634, 1507, 29, 69, 14, 3469, 12, 1048, 29, 69, 14, 2743, 12, 1318, 29, 69, 14, 589, 59, 16, 467, 2116, 1788, 29, 515, 430, 339, 871, 2186, 465, 325, 26, 267, 492, 5190, 267, 20184, 14, 815, 8, 6894, 14, 908, 63, 2804, 1012, 339, 2552, 275, 2457, 63, 2550, 8, 2550, 12, 1011, 1162, 9, 339, 2552, 275, 769, 8, 2168, 63, 18563, 8, 2550, 430, 339, 340, 1233, 436, 2552, 26, 267, 2552, 275, 2457, 63, 2759, 1278, 8, 600, 12, 2552, 9, 339, 372, 3355, 8, 2550, 12, 790, 29, 2734, 325, 26, 325, 14, 30898, 9, 421, 199, 318, 2198, 63, 632, 604, 8, 600, 304, 272, 408, 6077, 1862, 687, 570, 1159, 818, 604, 14, 339, 520, 1107, 1211, 26, 491, 1058, 1862, 14, 339, 408, 272, 12005, 275, 10362, 4424, 3565, 63, 907, 14, 1733, 8, 600, 9, 272, 340, 12005, 26, 267, 372, 1211, 8, 86, 14, 1294, 23917, 367, 373, 315, 12005, 14, 923, 8, 17, 680, 1294, 6176, 1333, 339, 372, 1211, 342, 421, 199, 318, 9275, 63, 1162, 8, 632, 604, 12, 570, 888, 12, 1511, 304, 272, 408, 17008, 436, 5389, 282, 1862, 687, 818, 1278, 436, 11585, 14, 339, 520, 1107, 1211, 26, 339, 408, 272, 1862, 275, 1211, 8, 2759, 29, 797, 12, 3686, 6034, 3504, 14285, 272, 340, 1511, 26, 267, 1862, 459, 4247, 418, 275, 1511, 14, 4247, 267, 1862, 459, 2416, 418, 275, 1511, 14, 2416, 339, 367, 1101, 315, 2457, 8, 403, 12, 359, 632, 604, 12, 570, 888, 4682, 267, 367, 790, 315, 661, 4247, 297, 283, 2416, 735, 288, 1862, 59, 498, 61, 847, 2112, 63, 585, 8, 498, 12, 1101, 14, 362, 8, 498, 12, 15927, 267, 1862, 459, 2759, 418, 275, 2155, 8, 442, 8, 888, 14, 362, 360, 2759, 297, 756, 1724, 339, 1862, 459, 4247, 418, 275, 663, 8, 1162, 459, 4247, 1105, 272, 1862, 459, 2416, 418, 275, 663, 8, 1162, 459, 2416, 1105, 339, 372, 1862, 421, 199, 318, 2457, 63, 2550, 8, 2550, 12, 3504, 29, 403, 12, 3686, 29, 403, 12, 1011, 1162, 304, 272, 408, 9388, 282, 9266, 4796, 701, 3504, 436, 3686, 1511, 14, 339, 520, 1107, 2155, 26, 339, 408, 272, 3504, 275, 3504, 503, 942, 272, 3686, 275, 3686, 503, 942, 339, 367, 325, 315, 2552, 26, 267, 367, 308, 315, 3504, 26, 288, 340, 325, 14, 1955, 14, 2460, 8, 83, 304, 355, 1995, 325, 355, 2059, 267, 587, 26, 288, 367, 308, 315, 3686, 26, 355, 340, 325, 14, 1955, 14, 2460, 8, 83, 304, 490, 2059, 288, 587, 26, 355, 1995, 325, 421, 199, 318, 2457, 63, 2759, 1278, 8, 600, 12, 2552, 304, 272, 408, 9388, 2385, 701, 658, 889, 7096, 2313, 339, 520, 1107, 769, 26, 437, 9806, 2552 ]
[ 1611, 416, 391, 1159, 6170, 9330, 14, 199, 199, 22281, 1862, 12, 1104, 282, 818, 604, 436, 1255, 314, 1104, 1192, 14, 199, 199, 624, 199, 646, 295, 199, 199, 646, 2050, 199, 504, 5055, 492, 10018, 199, 199, 504, 1275, 888, 492, 2112, 63, 585, 12, 20184, 199, 504, 1275, 3854, 14, 5359, 492, 491, 3843, 51, 199, 504, 1275, 2550, 492, 577, 2160, 2507, 16601, 12, 4520, 421, 199, 12573, 710, 3372, 3851, 199, 13525, 63, 10764, 275, 295, 14, 2014, 8, 82, 11525, 627, 889, 7096, 60, 66, 297, 295, 14, 41, 680, 1733, 199, 199, 3, 6077, 282, 818, 1278, 199, 11429, 3565, 63, 907, 275, 295, 14, 2014, 8, 272, 519, 15542, 83, 10, 20262, 83, 11, 5169, 647, 416, 391, 26, 2862, 83, 10, 17304, 26, 7023, 87, 15555, 1524, 62, 3427, 78, 60, 83, 2807, 26, 31, 6393, 3196, 272, 295, 14, 41, 1204, 295, 14, 45, 9, 421, 199, 318, 1255, 8, 515, 4581, 1233, 29, 403, 12, 1511, 29, 403, 304, 272, 408, 3378, 282, 1233, 1104, 1192, 543, 1627, 1862, 14, 339, 520, 1107, 2552, 26, 769, 402, 11196, 543, 1125, 1159, 2556, 339, 408, 272, 2552, 275, 942, 272, 570, 888, 275, 1211, 342, 272, 1862, 275, 1211, 342, 272, 7403, 878, 275, 491, 3843, 51, 272, 7403, 878, 63, 1162, 275, 1211, 342, 339, 340, 1511, 26, 267, 7403, 878, 275, 1511, 14, 472, 878, 267, 7403, 878, 63, 1162, 275, 1511, 14, 472, 878, 63, 1162, 267, 367, 3656, 315, 1511, 14, 493, 63, 1162, 26, 288, 340, 3656, 14, 1431, 8, 515, 304, 355, 570, 888, 14, 873, 8, 1419, 14, 493, 63, 1162, 59, 2629, 566, 339, 862, 26, 267, 543, 5495, 2998, 8, 600, 12, 931, 9, 465, 4027, 26, 288, 1233, 275, 4027, 14, 600, 288, 1862, 275, 9275, 63, 1162, 8, 1122, 63, 632, 604, 8, 600, 395, 570, 888, 12, 1511, 9, 288, 20184, 14, 1757, 360, 14740, 1862, 26, 450, 83, 297, 1862, 9, 953, 340, 1862, 14, 362, 360, 2759, 735, 355, 372, 2552, 953, 367, 1242, 315, 7403, 878, 26, 2234, 340, 440, 1228, 8, 1053, 12, 2008, 304, 490, 1242, 275, 334, 1053, 12, 491, 3843, 51, 14, 362, 8, 1053, 430, 2234, 634, 354, 12, 7403, 351, 275, 1242, 2234, 340, 440, 7403, 351, 26, 490, 1980, 2234, 634, 1162, 275, 7403, 878, 63, 1162, 14, 362, 8, 76, 354, 12, 1211, 1012, 355, 20184, 14, 815, 480, 2540, 450, 83, 450, 83, 401, 634, 354, 12, 634, 1162, 9, 2234, 367, 9266, 315, 7403, 351, 14, 1065, 8, 717, 931, 12, 1233, 29, 600, 12, 3686, 29, 1162, 14, 362, 480, 4247, 401, 663, 4000, 717, 3504, 29, 1162, 14, 362, 480, 2416, 401, 663, 4000, 1862, 29, 76, 1162, 304, 490, 2552, 14, 740, 8, 547, 8, 1501, 29, 515, 12, 7403, 351, 29, 76, 354, 12, 1011, 281, 430, 339, 871, 5925, 465, 325, 26, 267, 20184, 14, 1757, 480, 13760, 450, 83, 401, 325, 9, 267, 2552, 14, 740, 8, 547, 8, 505, 29, 495, 8, 69, 395, 1788, 29, 515, 12, 7403, 351, 29, 76, 354, 430, 339, 871, 12053, 465, 325, 26, 267, 20184, 14, 1757, 480, 9294, 450, 83, 401, 325, 9, 267, 2552, 14, 740, 8, 288, 4520, 8, 25240, 29, 76, 354, 12, 634, 1507, 29, 69, 14, 3469, 12, 1048, 29, 69, 14, 2743, 12, 1318, 29, 69, 14, 589, 59, 16, 467, 2116, 1788, 29, 515, 430, 339, 871, 2186, 465, 325, 26, 267, 492, 5190, 267, 20184, 14, 815, 8, 6894, 14, 908, 63, 2804, 1012, 339, 2552, 275, 2457, 63, 2550, 8, 2550, 12, 1011, 1162, 9, 339, 2552, 275, 769, 8, 2168, 63, 18563, 8, 2550, 430, 339, 340, 1233, 436, 2552, 26, 267, 2552, 275, 2457, 63, 2759, 1278, 8, 600, 12, 2552, 9, 339, 372, 3355, 8, 2550, 12, 790, 29, 2734, 325, 26, 325, 14, 30898, 9, 421, 199, 318, 2198, 63, 632, 604, 8, 600, 304, 272, 408, 6077, 1862, 687, 570, 1159, 818, 604, 14, 339, 520, 1107, 1211, 26, 491, 1058, 1862, 14, 339, 408, 272, 12005, 275, 10362, 4424, 3565, 63, 907, 14, 1733, 8, 600, 9, 272, 340, 12005, 26, 267, 372, 1211, 8, 86, 14, 1294, 23917, 367, 373, 315, 12005, 14, 923, 8, 17, 680, 1294, 6176, 1333, 339, 372, 1211, 342, 421, 199, 318, 9275, 63, 1162, 8, 632, 604, 12, 570, 888, 12, 1511, 304, 272, 408, 17008, 436, 5389, 282, 1862, 687, 818, 1278, 436, 11585, 14, 339, 520, 1107, 1211, 26, 339, 408, 272, 1862, 275, 1211, 8, 2759, 29, 797, 12, 3686, 6034, 3504, 14285, 272, 340, 1511, 26, 267, 1862, 459, 4247, 418, 275, 1511, 14, 4247, 267, 1862, 459, 2416, 418, 275, 1511, 14, 2416, 339, 367, 1101, 315, 2457, 8, 403, 12, 359, 632, 604, 12, 570, 888, 4682, 267, 367, 790, 315, 661, 4247, 297, 283, 2416, 735, 288, 1862, 59, 498, 61, 847, 2112, 63, 585, 8, 498, 12, 1101, 14, 362, 8, 498, 12, 15927, 267, 1862, 459, 2759, 418, 275, 2155, 8, 442, 8, 888, 14, 362, 360, 2759, 297, 756, 1724, 339, 1862, 459, 4247, 418, 275, 663, 8, 1162, 459, 4247, 1105, 272, 1862, 459, 2416, 418, 275, 663, 8, 1162, 459, 2416, 1105, 339, 372, 1862, 421, 199, 318, 2457, 63, 2550, 8, 2550, 12, 3504, 29, 403, 12, 3686, 29, 403, 12, 1011, 1162, 304, 272, 408, 9388, 282, 9266, 4796, 701, 3504, 436, 3686, 1511, 14, 339, 520, 1107, 2155, 26, 339, 408, 272, 3504, 275, 3504, 503, 942, 272, 3686, 275, 3686, 503, 942, 339, 367, 325, 315, 2552, 26, 267, 367, 308, 315, 3504, 26, 288, 340, 325, 14, 1955, 14, 2460, 8, 83, 304, 355, 1995, 325, 355, 2059, 267, 587, 26, 288, 367, 308, 315, 3686, 26, 355, 340, 325, 14, 1955, 14, 2460, 8, 83, 304, 490, 2059, 288, 587, 26, 355, 1995, 325, 421, 199, 318, 2457, 63, 2759, 1278, 8, 600, 12, 2552, 304, 272, 408, 9388, 2385, 701, 658, 889, 7096, 2313, 339, 520, 1107, 769, 26, 437, 9806, 2552, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bliti/django-nonrel-1.5
django/contrib/staticfiles/handlers.py
106
2513
try: from urllib.parse import urlparse from urllib.request import url2pathname except ImportError: # Python 2 from urllib import url2pathname from urlparse import urlparse from django.conf import settings from django.core.handlers.base import get_path_info from django.core.handlers.wsgi import WSGIHandler from django.contrib.staticfiles import utils from django.contrib.staticfiles.views import serve class StaticFilesHandler(WSGIHandler): """ WSGI middleware that intercepts calls to the static files directory, as defined by the STATIC_URL setting, and serves those files. """ def __init__(self, application, base_dir=None): self.application = application if base_dir: self.base_dir = base_dir else: self.base_dir = self.get_base_dir() self.base_url = urlparse(self.get_base_url()) super(StaticFilesHandler, self).__init__() def get_base_dir(self): return settings.STATIC_ROOT def get_base_url(self): utils.check_settings() return settings.STATIC_URL def _should_handle(self, path): """ Checks if the path should be handled. Ignores the path if: * the host is provided as part of the base_url * the request's path isn't under the media path (or equal) """ return path.startswith(self.base_url[2]) and not self.base_url[1] def file_path(self, url): """ Returns the relative path to the media file on disk for the given URL. """ relative_url = url[len(self.base_url[2]):] return url2pathname(relative_url) def serve(self, request): """ Actually serves the request path. """ return serve(request, self.file_path(request.path), insecure=True) def get_response(self, request): from django.http import Http404 if self._should_handle(request.path): try: return self.serve(request) except Http404 as e: if settings.DEBUG: from django.views import debug return debug.technical_404_response(request, e) return super(StaticFilesHandler, self).get_response(request) def __call__(self, environ, start_response): if not self._should_handle(get_path_info(environ)): return self.application(environ, start_response) return super(StaticFilesHandler, self).__call__(environ, start_response)
bsd-3-clause
[ 893, 26, 272, 687, 4011, 14, 1122, 492, 7097, 272, 687, 4011, 14, 1069, 492, 1166, 18, 12445, 199, 2590, 3545, 26, 258, 327, 2018, 499, 272, 687, 4011, 492, 1166, 18, 12445, 272, 687, 7097, 492, 7097, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 5586, 14, 1095, 492, 664, 63, 515, 63, 815, 199, 504, 1639, 14, 1018, 14, 5586, 14, 6508, 492, 9279, 2461, 199, 199, 504, 1639, 14, 2828, 14, 18373, 492, 3778, 199, 504, 1639, 14, 2828, 14, 18373, 14, 4196, 492, 14062, 199, 199, 533, 13599, 5535, 2461, 8, 16828, 2461, 304, 272, 408, 272, 9279, 10816, 626, 13926, 83, 4882, 370, 314, 2955, 1584, 2082, 12, 465, 272, 3247, 701, 314, 27815, 63, 2632, 4260, 12, 436, 23739, 5204, 1584, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 4223, 12, 1300, 63, 694, 29, 403, 304, 267, 291, 14, 3578, 275, 4223, 267, 340, 1300, 63, 694, 26, 288, 291, 14, 1095, 63, 694, 275, 1300, 63, 694, 267, 587, 26, 288, 291, 14, 1095, 63, 694, 275, 291, 14, 362, 63, 1095, 63, 694, 342, 267, 291, 14, 1095, 63, 633, 275, 7097, 8, 277, 14, 362, 63, 1095, 63, 633, 1012, 267, 1613, 8, 9278, 5535, 2461, 12, 291, 2843, 826, 4533, 339, 347, 664, 63, 1095, 63, 694, 8, 277, 304, 267, 372, 2202, 14, 10449, 63, 5441, 339, 347, 664, 63, 1095, 63, 633, 8, 277, 304, 267, 3778, 14, 1074, 63, 1751, 342, 267, 372, 2202, 14, 10449, 63, 2632, 339, 347, 485, 5626, 63, 2479, 8, 277, 12, 931, 304, 267, 408, 267, 13813, 340, 314, 931, 1077, 506, 8860, 14, 20489, 7944, 314, 931, 340, 26, 398, 627, 314, 1591, 365, 2741, 465, 1777, 402, 314, 1300, 63, 633, 267, 627, 314, 1056, 1159, 931, 5712, 1133, 1334, 314, 5898, 931, 334, 269, 4472, 9, 267, 408, 267, 372, 931, 14, 2460, 8, 277, 14, 1095, 63, 633, 59, 18, 566, 436, 440, 291, 14, 1095, 63, 633, 59, 17, 61, 339, 347, 570, 63, 515, 8, 277, 12, 1166, 304, 267, 408, 267, 1803, 314, 3847, 931, 370, 314, 5898, 570, 641, 4543, 367, 314, 1627, 2851, 14, 267, 408, 267, 3847, 63, 633, 275, 1166, 59, 552, 8, 277, 14, 1095, 63, 633, 59, 18, 4682, 61, 267, 372, 1166, 18, 12445, 8, 6188, 63, 633, 9, 339, 347, 14062, 8, 277, 12, 1056, 304, 267, 408, 267, 18982, 3163, 23739, 314, 1056, 931, 14, 267, 408, 267, 372, 14062, 8, 1069, 12, 291, 14, 493, 63, 515, 8, 1069, 14, 515, 395, 26097, 29, 549, 9, 339, 347, 664, 63, 1310, 8, 277, 12, 1056, 304, 267, 687, 1639, 14, 1014, 492, 4760, 5188, 398, 340, 291, 423, 5626, 63, 2479, 8, 1069, 14, 515, 304, 288, 862, 26, 355, 372, 291, 14, 4909, 8, 1069, 9, 288, 871, 4760, 5188, 465, 325, 26, 355, 340, 2202, 14, 5287, 26, 490, 687, 1639, 14, 4196, 492, 3105, 490, 372, 3105, 14, 266, 28836, 63, 5188, 63, 1310, 8, 1069, 12, 325, 9, 267, 372, 1613, 8, 9278, 5535, 2461, 12, 291, 680, 362, 63, 1310, 8, 1069, 9, 339, 347, 636, 1250, 721, 277, 12, 6160, 12, 1343, 63, 1310, 304, 267, 340, 440, 291, 423, 5626, 63, 2479, 8, 362, 63, 515, 63, 815, 8, 2314, 2298, 288, 372, 291, 14, 3578, 8, 2314, 12, 1343, 63, 1310, 9, 267, 372, 1613, 8, 9278, 5535, 2461, 12, 291, 2843, 1250, 721, 2314, 12, 1343, 63, 1310, 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 ]
[ 26, 272, 687, 4011, 14, 1122, 492, 7097, 272, 687, 4011, 14, 1069, 492, 1166, 18, 12445, 199, 2590, 3545, 26, 258, 327, 2018, 499, 272, 687, 4011, 492, 1166, 18, 12445, 272, 687, 7097, 492, 7097, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 5586, 14, 1095, 492, 664, 63, 515, 63, 815, 199, 504, 1639, 14, 1018, 14, 5586, 14, 6508, 492, 9279, 2461, 199, 199, 504, 1639, 14, 2828, 14, 18373, 492, 3778, 199, 504, 1639, 14, 2828, 14, 18373, 14, 4196, 492, 14062, 199, 199, 533, 13599, 5535, 2461, 8, 16828, 2461, 304, 272, 408, 272, 9279, 10816, 626, 13926, 83, 4882, 370, 314, 2955, 1584, 2082, 12, 465, 272, 3247, 701, 314, 27815, 63, 2632, 4260, 12, 436, 23739, 5204, 1584, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 4223, 12, 1300, 63, 694, 29, 403, 304, 267, 291, 14, 3578, 275, 4223, 267, 340, 1300, 63, 694, 26, 288, 291, 14, 1095, 63, 694, 275, 1300, 63, 694, 267, 587, 26, 288, 291, 14, 1095, 63, 694, 275, 291, 14, 362, 63, 1095, 63, 694, 342, 267, 291, 14, 1095, 63, 633, 275, 7097, 8, 277, 14, 362, 63, 1095, 63, 633, 1012, 267, 1613, 8, 9278, 5535, 2461, 12, 291, 2843, 826, 4533, 339, 347, 664, 63, 1095, 63, 694, 8, 277, 304, 267, 372, 2202, 14, 10449, 63, 5441, 339, 347, 664, 63, 1095, 63, 633, 8, 277, 304, 267, 3778, 14, 1074, 63, 1751, 342, 267, 372, 2202, 14, 10449, 63, 2632, 339, 347, 485, 5626, 63, 2479, 8, 277, 12, 931, 304, 267, 408, 267, 13813, 340, 314, 931, 1077, 506, 8860, 14, 20489, 7944, 314, 931, 340, 26, 398, 627, 314, 1591, 365, 2741, 465, 1777, 402, 314, 1300, 63, 633, 267, 627, 314, 1056, 1159, 931, 5712, 1133, 1334, 314, 5898, 931, 334, 269, 4472, 9, 267, 408, 267, 372, 931, 14, 2460, 8, 277, 14, 1095, 63, 633, 59, 18, 566, 436, 440, 291, 14, 1095, 63, 633, 59, 17, 61, 339, 347, 570, 63, 515, 8, 277, 12, 1166, 304, 267, 408, 267, 1803, 314, 3847, 931, 370, 314, 5898, 570, 641, 4543, 367, 314, 1627, 2851, 14, 267, 408, 267, 3847, 63, 633, 275, 1166, 59, 552, 8, 277, 14, 1095, 63, 633, 59, 18, 4682, 61, 267, 372, 1166, 18, 12445, 8, 6188, 63, 633, 9, 339, 347, 14062, 8, 277, 12, 1056, 304, 267, 408, 267, 18982, 3163, 23739, 314, 1056, 931, 14, 267, 408, 267, 372, 14062, 8, 1069, 12, 291, 14, 493, 63, 515, 8, 1069, 14, 515, 395, 26097, 29, 549, 9, 339, 347, 664, 63, 1310, 8, 277, 12, 1056, 304, 267, 687, 1639, 14, 1014, 492, 4760, 5188, 398, 340, 291, 423, 5626, 63, 2479, 8, 1069, 14, 515, 304, 288, 862, 26, 355, 372, 291, 14, 4909, 8, 1069, 9, 288, 871, 4760, 5188, 465, 325, 26, 355, 340, 2202, 14, 5287, 26, 490, 687, 1639, 14, 4196, 492, 3105, 490, 372, 3105, 14, 266, 28836, 63, 5188, 63, 1310, 8, 1069, 12, 325, 9, 267, 372, 1613, 8, 9278, 5535, 2461, 12, 291, 680, 362, 63, 1310, 8, 1069, 9, 339, 347, 636, 1250, 721, 277, 12, 6160, 12, 1343, 63, 1310, 304, 267, 340, 440, 291, 423, 5626, 63, 2479, 8, 362, 63, 515, 63, 815, 8, 2314, 2298, 288, 372, 291, 14, 3578, 8, 2314, 12, 1343, 63, 1310, 9, 267, 372, 1613, 8, 9278, 5535, 2461, 12, 291, 2843, 1250, 721, 2314, 12, 1343, 63, 1310, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Hybrid-Cloud/cinder
cinder/tests/unit/test_coprhd.py
5
41455
# Copyright (c) 2012 - 2016 EMC Corporation, 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. from mock import Mock from cinder import context from cinder import exception from cinder.objects import fields from cinder import test from cinder.volume.drivers.coprhd import common as coprhd_common from cinder.volume.drivers.coprhd import fc as coprhd_fc from cinder.volume.drivers.coprhd import iscsi as coprhd_iscsi from cinder.volume.drivers.coprhd import scaleio as coprhd_scaleio from cinder.volume import volume_types """ Test Data required for mocking """ export_group_details_data = { "inactive": False, "initiators": [{"creation_time": 1392194176020, "host": {"id": "urn:storageos:Host:3e21edff-8662-4e60-ab5", "link": {"href": "/compute/hosts/urn:storageos:H", "rel": "self"}}, "hostname": "lglw7134", "id": "urn:storageos:Initiator:13945431-06b7-44a0-838c-50", "inactive": False, "initiator_node": "20:00:00:90:FA:13:81:8D", "initiator_port": "iqn.1993-08.org.deb:01:222", "link": {"href": "/compute/initiators/urn:storageos:Initi", "rel": "self"}, "protocol": "iSCSI", "registration_status": "REGISTERED", "tags": []}], "name": "ccgroup", "project": 'project', "tags": [], "tenant": 'tenant', "type": "Host", "varray": {"id": "urn:storageos:VirtualArray:5af376e9-ce2f-493d-9079-a872", "link": {"href": "/vdc/varrays/urn:storageos:VirtualArray:5af3", "rel": "self"} }, "volumes": [{"id": "urn:storageos:Volume:6dc64865-bb25-431c-b321-ac268f16" "a7ae:vdc1", "lun": 1 }] } varray_detail_data = {"name": "varray"} export_group_list = ["urn:storageos:ExportGroup:2dbce233-7da0-47cb-8ff3-68f48"] iscsi_itl_list = {"itl": [{"hlu": 3, "initiator": {"id": "urn:storageos:Initiator:13945", "link": {"rel": "self", "href": "/comput"}, "port": "iqn.1993-08.org.deb:01:222"}, "export": {"id": "urn:storageos:ExportGroup:2dbce2", "name": "ccgroup", "link": {"rel": "self", "href": "/block/expo"}}, "device": {"id": "urn:storageos:Volume:aa1fc84a-af", "link": {"rel": "self", "href": "/block/volumes/urn:s"}, "wwn": "600009700001957015735330303535"}, "target": {"id": "urn:storageos:StoragePort:d7e42", "link": {"rel": "self", "href": "/vdc/stor:"}, "port": "50:00:09:73:00:18:95:19", 'ip_address': "10.10.10.10", 'tcp_port': '22'}}, {"hlu": 3, "initiator": {"id": "urn:storageos:Initiator:13945", "link": {"rel": "self", "href": "/comput"}, "port": "iqn.1993-08.org.deb:01:222"}, "export": {"id": "urn:storageos:ExportGroup:2dbce2", "name": "ccgroup", "link": {"rel": "self", "href": "/block/expo"}}, "device": {"id": "urn:storageos:Volume:aa1fc84a-af", "link": {"rel": "self", "href": "/block/volumes/urn:s"}, "wwn": "600009700001957015735330303535"}, "target": {"id": "urn:storageos:StoragePort:d7e42", "link": {"rel": "self", "href": "/vdc/stor:"}, "port": "50:00:09:73:00:18:95:19", 'ip_address': "10.10.10.10", 'tcp_port': '22'}}]} fcitl_itl_list = {"itl": [{"hlu": 3, "initiator": {"id": "urn:storageos:Initiator:13945", "link": {"rel": "self", "href": "/comput"}, "port": "12:34:56:78:90:12:34:56"}, "export": {"id": "urn:storageos:ExportGroup:2dbce2", "name": "ccgroup", "link": {"rel": "self", "href": "/block/expo"}}, "device": {"id": "urn:storageos:Volume:aa1fc84a-af", "link": {"rel": "self", "href": "/block/volumes/urn:s"}, "wwn": "600009700001957015735330303535"}, "target": {"id": "urn:storageos:StoragePort:d7e42", "link": {"rel": "self", "href": "/vdc/stor:"}, "port": "12:34:56:78:90:12:34:56", 'ip_address': "10.10.10.10", 'tcp_port': '22'}}, {"hlu": 3, "initiator": {"id": "urn:storageos:Initiator:13945", "link": {"rel": "self", "href": "/comput"}, "port": "12:34:56:78:90:12:34:56"}, "export": {"id": "urn:storageos:ExportGroup:2dbce2", "name": "ccgroup", "link": {"rel": "self", "href": "/block/expo"}}, "device": {"id": "urn:storageos:Volume:aa1fc84a-af", "link": {"rel": "self", "href": "/block/volumes/urn:s"}, "wwn": "600009700001957015735330303535"}, "target": {"id": "urn:storageos:StoragePort:d7e42", "link": {"rel": "self", "href": "/vdc/stor:"}, "port": "12:34:56:78:90:12:34:56", 'ip_address': "10.10.10.10", 'tcp_port': '22'}}]} scaleio_itl_list = {"itl": [{"hlu": -1, "initiator": {"id": "urn:storageos:Initiator:920aee", "link": {"rel": "self", "href": "/compute/initiators"}, "port": "bfdf432500000004"}, "export": {"id": "urn:storageos:ExportGroup:5449235", "name": "10.108.225.109", "link": {"rel": "self", "href": "/block/exports/urn:stor"}}, "device": {"id": "urn:storageos:Volume:b3624a83-3eb", "link": {"rel": "self", "href": "/block/volume"}, "wwn": "4F48CC4C27A43248092128B400000004"}, "target": {}}, {"hlu": -1, "initiator": {"id": "urn:storageos:Initiator:920aee", "link": {"rel": "self", "href": "/compute/initiators/"}, "port": "bfdf432500000004"}, "export": {"id": "urn:storageos:ExportGroup:5449235", "name": "10.108.225.109", "link": {"rel": "self", "href": "/block/exports/urn:stor"}}, "device": {"id": "urn:storageos:Volume:c014e96a-557", "link": {"rel": "self", "href": "/block/volumes/urn:stor"}, "wwn": "4F48CC4C27A43248092129320000000E"}, "target": {}}]} def get_test_volume_data(volume_type_id): test_volume = {'name': 'test-vol1', 'size': 1, 'volume_name': 'test-vol1', 'id': '1', 'consistencygroup_id': None, 'provider_auth': None, 'project_id': 'project', 'display_name': 'test-vol1', 'display_description': 'test volume', 'volume_type_id': volume_type_id, 'provider_id': '1', } return test_volume def get_source_test_volume_data(volume_type_id): test_volume = {'name': 'source_test-vol1', 'size': 1, 'volume_name': 'source_test-vol1', 'id': '1234', 'consistencygroup_id': None, 'provider_auth': None, 'project_id': 'project', 'display_name': 'source_test-vol1', 'display_description': 'test volume', 'volume_type_id': volume_type_id} return test_volume def get_clone_volume_data(volume_type_id): clone_test_volume = {'name': 'clone-test-vol1', 'size': 1, 'volume_name': 'clone-test-vol1', 'id': '2', 'provider_auth': None, 'project_id': 'project', 'display_name': 'clone-test-vol1', 'display_description': 'clone test volume', 'volume_type_id': volume_type_id} return clone_test_volume def get_test_snapshot_data(src_volume): test_snapshot = {'name': 'snapshot1', 'display_name': 'snapshot1', 'size': 1, 'id': '1111', 'volume_name': 'test-vol1', 'volume_id': '1234', 'volume': src_volume, 'volume_size': 1, 'project_id': 'project'} return test_snapshot def get_connector_data(): connector = {'ip': '10.0.0.2', 'initiator': 'iqn.1993-08.org.deb:01:222', 'wwpns': ["1234567890123456", "1234567890543211"], 'wwnns': ["223456789012345", "223456789054321"], 'host': 'fakehost'} return connector def get_test_CG_data(volume_type_id): test_CG = {'name': 'consistency_group_name', 'id': '12345abcde', 'volume_type_id': volume_type_id, 'status': fields.ConsistencyGroupStatus.AVAILABLE } return test_CG def get_test_CG_snap_data(volume_type_id): test_CG_snapshot = {'name': 'cg_snap_name', 'id': '12345abcde', 'consistencygroup_id': '123456789', 'status': fields.ConsistencyGroupStatus.AVAILABLE, 'snapshots': [], 'consistencygroup': get_test_CG_data(volume_type_id), 'cgsnapshot_id': '1', } return test_CG_snapshot class MockedEMCCoprHDDriverCommon(coprhd_common.EMCCoprHDDriverCommon): def __init__(self, protocol, default_backend_name, configuration=None): super(MockedEMCCoprHDDriverCommon, self).__init__( protocol, default_backend_name, configuration) def authenticate_user(self): pass def get_exports_count_by_initiators(self, initiator_ports): return 0 def _get_coprhd_volume_name(self, vol, verbose=False): if verbose is True: return {'volume_name': "coprhd_vol_name", 'volume_uri': "coprhd_vol_uri"} else: return "coprhd_vol_name" def _get_coprhd_snapshot_name(self, snapshot, resUri): return "coprhd_snapshot_name" def _get_coprhd_cgid(self, cgid): return "cg_uri" def init_volume_api(self): self.volume_api = Mock() self.volume_api.get.return_value = { 'name': 'source_test-vol1', 'size': 1, 'volume_name': 'source_test-vol1', 'id': '1234', 'consistencygroup_id': '12345', 'provider_auth': None, 'project_id': 'project', 'display_name': 'source_test-vol1', 'display_description': 'test volume', 'volume_type_id': "vol_type_id-for-snap"} def init_coprhd_api_components(self): self.volume_obj = Mock() self.volume_obj.create.return_value = "volume_created" self.volume_obj.volume_query.return_value = "volume_uri" self.volume_obj.get_storageAttributes.return_value = ( 'block', 'volume_name') self.volume_obj.storage_resource_query.return_value = "volume_uri" self.volume_obj.is_volume_detachable.return_value = False self.volume_obj.volume_clone_detach.return_value = 'detached' self.volume_obj.getTags.return_value = ( ["Openstack-vol", "Openstack-vol1"]) self.volume_obj.tag.return_value = "tagged" self.volume_obj.clone.return_value = "volume-cloned" if(self.protocol == "iSCSI"): self.volume_obj.get_exports_by_uri.return_value = ( iscsi_itl_list) elif(self.protocol == "FC"): self.volume_obj.get_exports_by_uri.return_value = ( fcitl_itl_list) else: self.volume_obj.get_exports_by_uri.return_value = ( scaleio_itl_list) self.volume_obj.list_volumes.return_value = [] self.volume_obj.show.return_value = {"id": "vol_id"} self.volume_obj.expand.return_value = "expanded" self.tag_obj = Mock() self.tag_obj.list_tags.return_value = [ "Openstack-vol", "Openstack-vol1"] self.tag_obj.tag_resource.return_value = "Tagged" self.exportgroup_obj = Mock() self.exportgroup_obj.exportgroup_list.return_value = ( export_group_list) self.exportgroup_obj.exportgroup_show.return_value = ( export_group_details_data) self.exportgroup_obj.exportgroup_add_volumes.return_value = ( "volume-added") self.host_obj = Mock() self.host_obj.list_by_tenant.return_value = [] self.host_obj.list_all.return_value = [{'id': "host1_id", 'name': "host1"}] self.host_obj.list_initiators.return_value = [ {'name': "12:34:56:78:90:12:34:56"}, {'name': "12:34:56:78:90:54:32:11"}, {'name': "bfdf432500000004"}] self.hostinitiator_obj = Mock() self.varray_obj = Mock() self.varray_obj.varray_show.return_value = varray_detail_data self.snapshot_obj = Mock() mocked_snap_obj = self.snapshot_obj.return_value mocked_snap_obj.storageResource_query.return_value = ( "resourceUri") mocked_snap_obj.snapshot_create.return_value = ( "snapshot_created") mocked_snap_obj.snapshot_query.return_value = "snapshot_uri" self.consistencygroup_obj = Mock() mocked_cg_object = self.consistencygroup_obj.return_value mocked_cg_object.create.return_value = "CG-Created" mocked_cg_object.consistencygroup_query.return_value = "CG-uri" class EMCCoprHDISCSIDriverTest(test.TestCase): def setUp(self): super(EMCCoprHDISCSIDriverTest, self).setUp() self.create_coprhd_setup() def create_coprhd_setup(self): self.configuration = Mock() self.configuration.coprhd_hostname = "10.10.10.10" self.configuration.coprhd_port = "4443" self.configuration.volume_backend_name = "EMCCoprHDISCSIDriver" self.configuration.coprhd_username = "user-name" self.configuration.coprhd_password = "password" self.configuration.coprhd_tenant = "tenant" self.configuration.coprhd_project = "project" self.configuration.coprhd_varray = "varray" self.configuration.coprhd_emulate_snapshot = False self.volume_type_id = self.create_coprhd_volume_type() self.mock_object(coprhd_iscsi.EMCCoprHDISCSIDriver, '_get_common_driver', self._get_mocked_common_driver) self.driver = coprhd_iscsi.EMCCoprHDISCSIDriver( configuration=self.configuration) def tearDown(self): self._cleanUp() super(EMCCoprHDISCSIDriverTest, self).tearDown() def _cleanUp(self): self.delete_vipr_volume_type() def create_coprhd_volume_type(self): ctx = context.get_admin_context() vipr_volume_type = volume_types.create(ctx, "coprhd-volume-type", {'CoprHD:VPOOL': 'vpool_coprhd'}) volume_id = vipr_volume_type['id'] return volume_id def _get_mocked_common_driver(self): return MockedEMCCoprHDDriverCommon( protocol="iSCSI", default_backend_name="EMCViPRISCSIDriver", configuration=self.configuration) def delete_vipr_volume_type(self): ctx = context.get_admin_context() volume_types.destroy(ctx, self.volume_type_id) def test_create_destroy(self): volume = get_test_volume_data(self.volume_type_id) self.driver.create_volume(volume) self.driver.delete_volume(volume) def test_get_volume_stats(self): vol_stats = self.driver.get_volume_stats(True) self.assertTrue(vol_stats['free_capacity_gb'], 'unknown') def test_create_volume_clone(self): src_volume_data = get_test_volume_data(self.volume_type_id) clone_volume_data = get_clone_volume_data(self.volume_type_id) self.driver.create_volume(src_volume_data) self.driver.create_cloned_volume(clone_volume_data, src_volume_data) self.driver.delete_volume(src_volume_data) self.driver.delete_volume(clone_volume_data) def test_create_destroy_snapshot(self): volume_data = get_test_volume_data(self.volume_type_id) snapshot_data = get_test_snapshot_data( get_source_test_volume_data(self.volume_type_id)) self.driver.create_volume(volume_data) self.driver.create_snapshot(snapshot_data) self.driver.delete_snapshot(snapshot_data) self.driver.delete_volume(volume_data) def test_create_volume_from_snapshot(self): src_vol_data = get_source_test_volume_data(self.volume_type_id) self.driver.create_volume(src_vol_data) volume_data = get_test_volume_data(self.volume_type_id) snapshot_data = get_test_snapshot_data(src_vol_data) self.driver.create_snapshot(snapshot_data) self.driver.create_volume_from_snapshot(volume_data, snapshot_data) self.driver.delete_snapshot(snapshot_data) self.driver.delete_volume(src_vol_data) self.driver.delete_volume(volume_data) def test_extend_volume(self): volume_data = get_test_volume_data(self.volume_type_id) self.driver.create_volume(volume_data) self.driver.extend_volume(volume_data, 2) self.driver.delete_volume(volume_data) def test_initialize_and_terminate_connection(self): connector_data = get_connector_data() volume_data = get_test_volume_data(self.volume_type_id) self.driver.create_volume(volume_data) res_initialize = self.driver.initialize_connection( volume_data, connector_data) expected_initialize = {'driver_volume_type': 'iscsi', 'data': {'target_lun': 3, 'target_portal': '10.10.10.10:22', 'target_iqn': '50:00:09:73:00:18:95:19', 'target_discovered': False, 'volume_id': '1'}} self.assertEqual( expected_initialize, res_initialize, 'Unexpected return data') self.driver.terminate_connection(volume_data, connector_data) self.driver.delete_volume(volume_data) def test_create_delete_empty_CG(self): cg_data = get_test_CG_data(self.volume_type_id) ctx = context.get_admin_context() self.driver.create_consistencygroup(ctx, cg_data) model_update, volumes_model_update = ( self.driver.delete_consistencygroup(ctx, cg_data, [])) self.assertEqual([], volumes_model_update, 'Unexpected return data') def test_create_update_delete_CG(self): cg_data = get_test_CG_data(self.volume_type_id) ctx = context.get_admin_context() self.driver.create_consistencygroup(ctx, cg_data) volume = get_test_volume_data(self.volume_type_id) self.driver.create_volume(volume) model_update, ret1, ret2 = ( self.driver.update_consistencygroup(ctx, cg_data, [volume], [])) self.assertEqual({'status': fields.ConsistencyGroupStatus.AVAILABLE}, model_update) model_update, volumes_model_update = ( self.driver.delete_consistencygroup(ctx, cg_data, [volume])) self.assertEqual({'status': fields.ConsistencyGroupStatus.AVAILABLE}, model_update) self.assertEqual([{'status': 'deleted', 'id': '1'}], volumes_model_update) def test_create_delete_CG_snap(self): cg_snap_data = get_test_CG_snap_data(self.volume_type_id) ctx = context.get_admin_context() model_update, snapshots_model_update = ( self.driver.create_cgsnapshot(ctx, cg_snap_data, [])) self.assertEqual({'status': fields.ConsistencyGroupStatus.AVAILABLE}, model_update) self.assertEqual([], snapshots_model_update, 'Unexpected return data') model_update, snapshots_model_update = ( self.driver.delete_cgsnapshot(ctx, cg_snap_data, [])) self.assertEqual({}, model_update, 'Unexpected return data') self.assertEqual([], snapshots_model_update, 'Unexpected return data') class EMCCoprHDFCDriverTest(test.TestCase): def setUp(self): super(EMCCoprHDFCDriverTest, self).setUp() self.create_coprhd_setup() def create_coprhd_setup(self): self.configuration = Mock() self.configuration.coprhd_hostname = "10.10.10.10" self.configuration.coprhd_port = "4443" self.configuration.volume_backend_name = "EMCCoprHDFCDriver" self.configuration.coprhd_username = "user-name" self.configuration.coprhd_password = "password" self.configuration.coprhd_tenant = "tenant" self.configuration.coprhd_project = "project" self.configuration.coprhd_varray = "varray" self.configuration.coprhd_emulate_snapshot = False self.volume_type_id = self.create_coprhd_volume_type() self.mock_object(coprhd_fc.EMCCoprHDFCDriver, '_get_common_driver', self._get_mocked_common_driver) self.driver = coprhd_fc.EMCCoprHDFCDriver( configuration=self.configuration) def tearDown(self): self._cleanUp() super(EMCCoprHDFCDriverTest, self).tearDown() def _cleanUp(self): self.delete_vipr_volume_type() def create_coprhd_volume_type(self): ctx = context.get_admin_context() vipr_volume_type = volume_types.create(ctx, "coprhd-volume-type", {'CoprHD:VPOOL': 'vpool_vipr'}) volume_id = vipr_volume_type['id'] return volume_id def _get_mocked_common_driver(self): return MockedEMCCoprHDDriverCommon( protocol="FC", default_backend_name="EMCViPRFCDriver", configuration=self.configuration) def delete_vipr_volume_type(self): ctx = context.get_admin_context() volume_types.destroy(ctx, self.volume_type_id) def test_create_destroy(self): volume = get_test_volume_data(self.volume_type_id) self.driver.create_volume(volume) self.driver.delete_volume(volume) def test_get_volume_stats(self): vol_stats = self.driver.get_volume_stats(True) self.assertTrue(vol_stats['free_capacity_gb'], 'unknown') def test_create_volume_clone(self): src_volume_data = get_test_volume_data(self.volume_type_id) clone_volume_data = get_clone_volume_data(self.volume_type_id) self.driver.create_volume(src_volume_data) self.driver.create_cloned_volume(clone_volume_data, src_volume_data) self.driver.delete_volume(src_volume_data) self.driver.delete_volume(clone_volume_data) def test_create_destroy_snapshot(self): volume_data = get_test_volume_data(self.volume_type_id) snapshot_data = get_test_snapshot_data( get_source_test_volume_data(self.volume_type_id)) self.driver.create_volume(volume_data) self.driver.create_snapshot(snapshot_data) self.driver.delete_snapshot(snapshot_data) self.driver.delete_volume(volume_data) def test_create_volume_from_snapshot(self): src_vol_data = get_source_test_volume_data(self.volume_type_id) self.driver.create_volume(src_vol_data) volume_data = get_test_volume_data(self.volume_type_id) snapshot_data = get_test_snapshot_data(src_vol_data) self.driver.create_snapshot(snapshot_data) self.driver.create_volume_from_snapshot(volume_data, snapshot_data) self.driver.delete_snapshot(snapshot_data) self.driver.delete_volume(src_vol_data) self.driver.delete_volume(volume_data) def test_create_volume_from_cg_snapshot(self): ctx = context.get_admin_context() volume_data = get_test_volume_data(self.volume_type_id) cg_snap_data = get_test_CG_snap_data(self.volume_type_id) self.driver.create_cgsnapshot(ctx, cg_snap_data, []) self.assertRaises(exception.VolumeBackendAPIException, self.driver.create_volume_from_snapshot, volume_data, cg_snap_data) self.driver.delete_cgsnapshot(ctx, cg_snap_data, []) self.driver.delete_volume(volume_data) def test_extend_volume(self): volume_data = get_test_volume_data(self.volume_type_id) self.driver.create_volume(volume_data) self.driver.extend_volume(volume_data, 2) self.driver.delete_volume(volume_data) def test_initialize_and_terminate_connection(self): connector_data = get_connector_data() volume_data = get_test_volume_data(self.volume_type_id) self.driver.create_volume(volume_data) res_initiatlize = self.driver.initialize_connection( volume_data, connector_data) expected_initialize = {'driver_volume_type': 'fibre_channel', 'data': {'target_lun': 3, 'initiator_target_map': {'1234567890543211': ['1234567890123456', '1234567890123456'], '1234567890123456': ['1234567890123456', '1234567890123456']}, 'target_wwn': ['1234567890123456', '1234567890123456'], 'target_discovered': False, 'volume_id': '1'}} self.assertEqual( expected_initialize, res_initiatlize, 'Unexpected return data') res_terminate = self.driver.terminate_connection( volume_data, connector_data) expected_terminate = {'driver_volume_type': 'fibre_channel', 'data': {'initiator_target_map': {'1234567890543211': ['1234567890123456', '1234567890123456'], '1234567890123456': ['1234567890123456', '1234567890123456']}, 'target_wwn': ['1234567890123456', '1234567890123456']}} self.assertEqual( expected_terminate, res_terminate, 'Unexpected return data') self.driver.delete_volume(volume_data) def test_create_delete_empty_CG(self): cg_data = get_test_CG_data(self.volume_type_id) ctx = context.get_admin_context() self.driver.create_consistencygroup(ctx, cg_data) model_update, volumes_model_update = ( self.driver.delete_consistencygroup(ctx, cg_data, [])) self.assertEqual([], volumes_model_update, 'Unexpected return data') def test_create_update_delete_CG(self): cg_data = get_test_CG_data(self.volume_type_id) ctx = context.get_admin_context() self.driver.create_consistencygroup(ctx, cg_data) volume = get_test_volume_data(self.volume_type_id) self.driver.create_volume(volume) model_update, ret1, ret2 = ( self.driver.update_consistencygroup(ctx, cg_data, [volume], [])) self.assertEqual({'status': fields.ConsistencyGroupStatus.AVAILABLE}, model_update) model_update, volumes_model_update = ( self.driver.delete_consistencygroup(ctx, cg_data, [volume])) self.assertEqual({'status': fields.ConsistencyGroupStatus.AVAILABLE}, model_update) self.assertEqual([{'status': 'deleted', 'id': '1'}], volumes_model_update) def test_create_delete_CG_snap(self): cg_snap_data = get_test_CG_snap_data(self.volume_type_id) ctx = context.get_admin_context() model_update, snapshots_model_update = ( self.driver.create_cgsnapshot(ctx, cg_snap_data, [])) self.assertEqual({'status': fields.ConsistencyGroupStatus.AVAILABLE}, model_update) self.assertEqual([], snapshots_model_update, 'Unexpected return data') model_update, snapshots_model_update = ( self.driver.delete_cgsnapshot(ctx, cg_snap_data, [])) self.assertEqual({}, model_update, 'Unexpected return data') self.assertEqual([], snapshots_model_update, 'Unexpected return data') class EMCCoprHDScaleIODriverTest(test.TestCase): def setUp(self): super(EMCCoprHDScaleIODriverTest, self).setUp() self.create_coprhd_setup() def create_coprhd_setup(self): self.configuration = Mock() self.configuration.coprhd_hostname = "10.10.10.10" self.configuration.coprhd_port = "4443" self.configuration.volume_backend_name = "EMCCoprHDFCDriver" self.configuration.coprhd_username = "user-name" self.configuration.coprhd_password = "password" self.configuration.coprhd_tenant = "tenant" self.configuration.coprhd_project = "project" self.configuration.coprhd_varray = "varray" self.configuration.coprhd_scaleio_rest_gateway_host = "10.10.10.11" self.configuration.coprhd_scaleio_rest_gateway_port = 443 self.configuration.coprhd_scaleio_rest_server_username = ( "scaleio_username") self.configuration.coprhd_scaleio_rest_server_password = ( "scaleio_password") self.configuration.scaleio_verify_server_certificate = False self.configuration.scaleio_server_certificate_path = ( "/etc/scaleio/certs") self.volume_type_id = self.create_coprhd_volume_type() self.mock_object(coprhd_scaleio.EMCCoprHDScaleIODriver, '_get_common_driver', self._get_mocked_common_driver) self.mock_object(coprhd_scaleio.EMCCoprHDScaleIODriver, '_get_client_id', self._get_client_id) self.driver = coprhd_scaleio.EMCCoprHDScaleIODriver( configuration=self.configuration) def tearDown(self): self._cleanUp() super(EMCCoprHDScaleIODriverTest, self).tearDown() def _cleanUp(self): self.delete_vipr_volume_type() def create_coprhd_volume_type(self): ctx = context.get_admin_context() vipr_volume_type = volume_types.create(ctx, "coprhd-volume-type", {'CoprHD:VPOOL': 'vpool_vipr'}) volume_id = vipr_volume_type['id'] return volume_id def _get_mocked_common_driver(self): return MockedEMCCoprHDDriverCommon( protocol="scaleio", default_backend_name="EMCCoprHDScaleIODriver", configuration=self.configuration) def _get_client_id(self, server_ip, server_port, server_username, server_password, sdc_ip): return "bfdf432500000004" def delete_vipr_volume_type(self): ctx = context.get_admin_context() volume_types.destroy(ctx, self.volume_type_id) def test_create_destroy(self): volume = get_test_volume_data(self.volume_type_id) self.driver.create_volume(volume) self.driver.delete_volume(volume) def test_get_volume_stats(self): vol_stats = self.driver.get_volume_stats(True) self.assertTrue(vol_stats['free_capacity_gb'], 'unknown') def test_create_volume_clone(self): src_volume_data = get_test_volume_data(self.volume_type_id) clone_volume_data = get_clone_volume_data(self.volume_type_id) self.driver.create_volume(src_volume_data) self.driver.create_cloned_volume(clone_volume_data, src_volume_data) self.driver.delete_volume(src_volume_data) self.driver.delete_volume(clone_volume_data) def test_create_destroy_snapshot(self): volume_data = get_test_volume_data(self.volume_type_id) snapshot_data = get_test_snapshot_data( get_source_test_volume_data(self.volume_type_id)) self.driver.create_volume(volume_data) self.driver.create_snapshot(snapshot_data) self.driver.delete_snapshot(snapshot_data) self.driver.delete_volume(volume_data) def test_create_volume_from_snapshot(self): src_vol_data = get_source_test_volume_data(self.volume_type_id) self.driver.create_volume(src_vol_data) volume_data = get_test_volume_data(self.volume_type_id) snapshot_data = get_test_snapshot_data(src_vol_data) self.driver.create_snapshot(snapshot_data) self.driver.create_volume_from_snapshot(volume_data, snapshot_data) self.driver.delete_snapshot(snapshot_data) self.driver.delete_volume(src_vol_data) self.driver.delete_volume(volume_data) def test_extend_volume(self): volume_data = get_test_volume_data(self.volume_type_id) self.driver.create_volume(volume_data) self.driver.extend_volume(volume_data, 2) self.driver.delete_volume(volume_data) def test_initialize_and_terminate_connection(self): connector_data = get_connector_data() volume_data = get_test_volume_data(self.volume_type_id) self.driver.create_volume(volume_data) res_initiatlize = self.driver.initialize_connection( volume_data, connector_data) expected_initialize = {'data': {'bandwidthLimit': None, 'hostIP': '10.0.0.2', 'iopsLimit': None, 'scaleIO_volname': 'test-vol1', 'scaleIO_volume_id': '1', 'serverIP': '10.10.10.11', 'serverPassword': 'scaleio_password', 'serverPort': 443, 'serverToken': None, 'serverUsername': 'scaleio_username'}, 'driver_volume_type': 'scaleio'} self.assertEqual( expected_initialize, res_initiatlize, 'Unexpected return data') self.driver.terminate_connection( volume_data, connector_data) self.driver.delete_volume(volume_data) def test_create_delete_empty_CG(self): cg_data = get_test_CG_data(self.volume_type_id) ctx = context.get_admin_context() self.driver.create_consistencygroup(ctx, cg_data) model_update, volumes_model_update = ( self.driver.delete_consistencygroup(ctx, cg_data, [])) self.assertEqual([], volumes_model_update, 'Unexpected return data') def test_create_update_delete_CG(self): cg_data = get_test_CG_data(self.volume_type_id) ctx = context.get_admin_context() self.driver.create_consistencygroup(ctx, cg_data) volume = get_test_volume_data(self.volume_type_id) self.driver.create_volume(volume) model_update, ret1, ret2 = ( self.driver.update_consistencygroup(ctx, cg_data, [volume], [])) self.assertEqual({'status': fields.ConsistencyGroupStatus.AVAILABLE}, model_update) model_update, volumes_model_update = ( self.driver.delete_consistencygroup(ctx, cg_data, [volume])) self.assertEqual({'status': fields.ConsistencyGroupStatus.AVAILABLE}, model_update) self.assertEqual([{'status': 'deleted', 'id': '1'}], volumes_model_update) def test_create_delete_CG_snap(self): cg_snap_data = get_test_CG_snap_data(self.volume_type_id) ctx = context.get_admin_context() model_update, snapshots_model_update = ( self.driver.create_cgsnapshot(ctx, cg_snap_data, [])) self.assertEqual({'status': fields.ConsistencyGroupStatus.AVAILABLE}, model_update) self.assertEqual([], snapshots_model_update, 'Unexpected return data') model_update, snapshots_model_update = ( self.driver.delete_cgsnapshot(ctx, cg_snap_data, [])) self.assertEqual({}, model_update, 'Unexpected return data') self.assertEqual([], snapshots_model_update, 'Unexpected return data')
apache-2.0
[ 3, 1898, 334, 67, 9, 6029, 446, 7800, 662, 7608, 11098, 12, 3277, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 1683, 492, 4420, 199, 199, 504, 13069, 492, 1067, 199, 504, 13069, 492, 1919, 199, 504, 13069, 14, 1462, 492, 1504, 199, 504, 13069, 492, 511, 199, 504, 13069, 14, 2405, 14, 13337, 14, 331, 2700, 7952, 492, 2863, 465, 4870, 82, 7952, 63, 2330, 199, 504, 13069, 14, 2405, 14, 13337, 14, 331, 2700, 7952, 492, 10821, 465, 4870, 82, 7952, 63, 3003, 199, 504, 13069, 14, 2405, 14, 13337, 14, 331, 2700, 7952, 492, 22144, 465, 4870, 82, 7952, 63, 17139, 199, 504, 13069, 14, 2405, 14, 13337, 14, 331, 2700, 7952, 492, 4666, 2308, 465, 4870, 82, 7952, 63, 3467, 2308, 199, 504, 13069, 14, 2405, 492, 3301, 63, 1313, 199, 199, 624, 199, 774, 3918, 1415, 367, 1683, 316, 199, 624, 199, 3790, 63, 923, 63, 5087, 63, 576, 275, 469, 272, 298, 16856, 582, 756, 12, 272, 298, 14188, 2750, 582, 16870, 8782, 63, 521, 582, 22317, 8867, 20, 10216, 10173, 12, 490, 298, 1102, 582, 2420, 344, 582, 298, 349, 26, 3494, 736, 26, 4965, 26, 19, 69, 2025, 379, 556, 13, 1184, 2789, 13, 20, 69, 2259, 13, 371, 21, 401, 2490, 298, 1073, 582, 2420, 6399, 582, 3286, 3357, 15, 5146, 15, 349, 26, 3494, 736, 26, 40, 401, 4228, 298, 3369, 582, 298, 277, 3570, 1386, 490, 298, 4269, 582, 298, 76, 3528, 87, 23, 7582, 401, 490, 298, 344, 582, 298, 349, 26, 3494, 736, 26, 607, 5277, 707, 26, 26980, 1477, 2192, 13, 1690, 66, 23, 13, 1602, 65, 16, 13, 24, 1703, 67, 13, 1400, 401, 490, 298, 16856, 582, 756, 12, 490, 298, 17974, 63, 932, 582, 298, 1165, 26, 383, 26, 383, 26, 2710, 26, 2078, 26, 969, 26, 2835, 26, 24, 36, 401, 490, 298, 17974, 63, 719, 582, 298, 27071, 14, 7155, 19, 13, 2036, 14, 1308, 14, 16762, 26, 614, 26, 9485, 401, 490, 298, 1073, 582, 2420, 6399, 582, 3286, 3357, 15, 14188, 2750, 15, 349, 26, 3494, 736, 26, 607, 5277, 401, 2490, 298, 3369, 582, 298, 277, 6018, 490, 298, 3922, 582, 298, 21534, 401, 490, 298, 8054, 63, 1205, 582, 298, 23986, 1149, 401, 490, 298, 2969, 582, 942, 22140, 272, 298, 354, 582, 298, 2055, 923, 401, 272, 298, 1715, 582, 283, 1715, 297, 272, 298, 2969, 582, 990, 272, 298, 4647, 582, 283, 4647, 297, 272, 298, 466, 582, 298, 4965, 401, 272, 298, 86, 1144, 582, 2420, 344, 582, 298, 349, 26, 3494, 736, 26, 8735, 3836, 26, 21, 2756, 11452, 69, 25, 13, 301, 18, 70, 13, 25919, 68, 13, 25, 19000, 13, 65, 16357, 401, 2049, 298, 1073, 582, 2420, 6399, 582, 3286, 86, 3833, 15, 1391, 4814, 15, 349, 26, 3494, 736, 26, 8735, 3836, 26, 21, 2756, 19, 401, 717, 298, 3369, 582, 298, 277, 3570, 2049, 1660, 272, 298, 8838, 582, 16870, 344, 582, 298, 349, 26, 3494, 736, 26, 6464, 26, 22, 3833, 772, 15102, 13, 2501, 821, 13, 32042, 67, 13, 66, 12638, 13, 645, 13731, 70, 975, 2, 326, 298, 65, 23, 3624, 26, 86, 3833, 17, 401, 326, 298, 13542, 582, 413, 326, 14877, 199, 93, 199, 199, 86, 1144, 63, 5506, 63, 576, 275, 2420, 354, 582, 298, 86, 1144, 3570, 199, 199, 3790, 63, 923, 63, 513, 275, 2097, 349, 26, 3494, 736, 26, 11399, 2448, 26, 18, 697, 301, 10034, 13, 23, 983, 16, 13, 2417, 2894, 13, 24, 556, 19, 13, 2333, 70, 2006, 937, 199, 199, 17139, 63, 390, 76, 63, 513, 275, 2420, 390, 76, 582, 16870, 72, 10836, 582, 650, 12, 2574, 298, 17974, 582, 2420, 344, 582, 298, 349, 26, 3494, 736, 26, 607, 5277, 707, 26, 7491, 2322, 401, 1460, 298, 1073, 582, 2420, 3369, 582, 298, 277, 401, 8179, 298, 6399, 582, 3286, 863, 337, 6018, 1460, 298, 719, 582, 298, 27071, 14, 7155, 19, 13, 2036, 14, 1308, 14, 16762, 26, 614, 26, 9485, 6018, 2574, 298, 3790, 582, 2420, 344, 582, 298, 349, 26, 3494, 736, 26, 11399, 2448, 26, 18, 697, 301, 18, 401, 4228, 298, 354, 582, 298, 2055, 923, 401, 4228, 298, 1073, 582, 2420, 3369, 582, 298, 277, 401, 6901, 298, 6399, 582, 3286, 1457, 15, 476, 555, 3570, 1386, 2574, 298, 1782, 582, 2420, 344, 582, 298, 349, 26, 3494, 736, 26, 6464, 26, 2158, 17, 3003, 1349, 65, 13, 2756, 401, 4228, 298, 1073, 582, 2420, 3369, 582, 298, 277, 401, 6901, 298, 6399, 582, 3286, 1457, 15, 8838, 15, 349, 26, 83, 6018, 4228, 298, 10988, 582, 298, 22, 993, 2576, 993, 1167, 1641, 614, 1641, 1276, 14137, 1216, 1276, 1276, 6018, 2574, 298, 1375, 582, 2420, 344, 582, 298, 349, 26, 3494, 736, 26, 6408, 4313, 26, 68, 23, 69, 2260, 401, 4228, 298, 1073, 582, 2420, 3369, 582, 298, 277, 401, 6901, 298, 6399, 582, 3286, 86, 3833, 15, 8041, 5424, 1386, 4228, 298, 719, 582, 298, 1400, 26, 383, 26, 1643, 26, 2898, 26, 383, 26, 1085, 26, 2720, 26, 1167, 401, 4228, 283, 711, 63, 1562, 356, 298, 709, 14, 709, 14, 709, 14, 709, 401, 4228, 283, 8815, 63, 719, 356, 283, 1081, 28400, 2079, 2420, 72, 10836, 582, 650, 12, 2574, 298, 17974, 582 ]
[ 1898, 334, 67, 9, 6029, 446, 7800, 662, 7608, 11098, 12, 3277, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 1683, 492, 4420, 199, 199, 504, 13069, 492, 1067, 199, 504, 13069, 492, 1919, 199, 504, 13069, 14, 1462, 492, 1504, 199, 504, 13069, 492, 511, 199, 504, 13069, 14, 2405, 14, 13337, 14, 331, 2700, 7952, 492, 2863, 465, 4870, 82, 7952, 63, 2330, 199, 504, 13069, 14, 2405, 14, 13337, 14, 331, 2700, 7952, 492, 10821, 465, 4870, 82, 7952, 63, 3003, 199, 504, 13069, 14, 2405, 14, 13337, 14, 331, 2700, 7952, 492, 22144, 465, 4870, 82, 7952, 63, 17139, 199, 504, 13069, 14, 2405, 14, 13337, 14, 331, 2700, 7952, 492, 4666, 2308, 465, 4870, 82, 7952, 63, 3467, 2308, 199, 504, 13069, 14, 2405, 492, 3301, 63, 1313, 199, 199, 624, 199, 774, 3918, 1415, 367, 1683, 316, 199, 624, 199, 3790, 63, 923, 63, 5087, 63, 576, 275, 469, 272, 298, 16856, 582, 756, 12, 272, 298, 14188, 2750, 582, 16870, 8782, 63, 521, 582, 22317, 8867, 20, 10216, 10173, 12, 490, 298, 1102, 582, 2420, 344, 582, 298, 349, 26, 3494, 736, 26, 4965, 26, 19, 69, 2025, 379, 556, 13, 1184, 2789, 13, 20, 69, 2259, 13, 371, 21, 401, 2490, 298, 1073, 582, 2420, 6399, 582, 3286, 3357, 15, 5146, 15, 349, 26, 3494, 736, 26, 40, 401, 4228, 298, 3369, 582, 298, 277, 3570, 1386, 490, 298, 4269, 582, 298, 76, 3528, 87, 23, 7582, 401, 490, 298, 344, 582, 298, 349, 26, 3494, 736, 26, 607, 5277, 707, 26, 26980, 1477, 2192, 13, 1690, 66, 23, 13, 1602, 65, 16, 13, 24, 1703, 67, 13, 1400, 401, 490, 298, 16856, 582, 756, 12, 490, 298, 17974, 63, 932, 582, 298, 1165, 26, 383, 26, 383, 26, 2710, 26, 2078, 26, 969, 26, 2835, 26, 24, 36, 401, 490, 298, 17974, 63, 719, 582, 298, 27071, 14, 7155, 19, 13, 2036, 14, 1308, 14, 16762, 26, 614, 26, 9485, 401, 490, 298, 1073, 582, 2420, 6399, 582, 3286, 3357, 15, 14188, 2750, 15, 349, 26, 3494, 736, 26, 607, 5277, 401, 2490, 298, 3369, 582, 298, 277, 6018, 490, 298, 3922, 582, 298, 21534, 401, 490, 298, 8054, 63, 1205, 582, 298, 23986, 1149, 401, 490, 298, 2969, 582, 942, 22140, 272, 298, 354, 582, 298, 2055, 923, 401, 272, 298, 1715, 582, 283, 1715, 297, 272, 298, 2969, 582, 990, 272, 298, 4647, 582, 283, 4647, 297, 272, 298, 466, 582, 298, 4965, 401, 272, 298, 86, 1144, 582, 2420, 344, 582, 298, 349, 26, 3494, 736, 26, 8735, 3836, 26, 21, 2756, 11452, 69, 25, 13, 301, 18, 70, 13, 25919, 68, 13, 25, 19000, 13, 65, 16357, 401, 2049, 298, 1073, 582, 2420, 6399, 582, 3286, 86, 3833, 15, 1391, 4814, 15, 349, 26, 3494, 736, 26, 8735, 3836, 26, 21, 2756, 19, 401, 717, 298, 3369, 582, 298, 277, 3570, 2049, 1660, 272, 298, 8838, 582, 16870, 344, 582, 298, 349, 26, 3494, 736, 26, 6464, 26, 22, 3833, 772, 15102, 13, 2501, 821, 13, 32042, 67, 13, 66, 12638, 13, 645, 13731, 70, 975, 2, 326, 298, 65, 23, 3624, 26, 86, 3833, 17, 401, 326, 298, 13542, 582, 413, 326, 14877, 199, 93, 199, 199, 86, 1144, 63, 5506, 63, 576, 275, 2420, 354, 582, 298, 86, 1144, 3570, 199, 199, 3790, 63, 923, 63, 513, 275, 2097, 349, 26, 3494, 736, 26, 11399, 2448, 26, 18, 697, 301, 10034, 13, 23, 983, 16, 13, 2417, 2894, 13, 24, 556, 19, 13, 2333, 70, 2006, 937, 199, 199, 17139, 63, 390, 76, 63, 513, 275, 2420, 390, 76, 582, 16870, 72, 10836, 582, 650, 12, 2574, 298, 17974, 582, 2420, 344, 582, 298, 349, 26, 3494, 736, 26, 607, 5277, 707, 26, 7491, 2322, 401, 1460, 298, 1073, 582, 2420, 3369, 582, 298, 277, 401, 8179, 298, 6399, 582, 3286, 863, 337, 6018, 1460, 298, 719, 582, 298, 27071, 14, 7155, 19, 13, 2036, 14, 1308, 14, 16762, 26, 614, 26, 9485, 6018, 2574, 298, 3790, 582, 2420, 344, 582, 298, 349, 26, 3494, 736, 26, 11399, 2448, 26, 18, 697, 301, 18, 401, 4228, 298, 354, 582, 298, 2055, 923, 401, 4228, 298, 1073, 582, 2420, 3369, 582, 298, 277, 401, 6901, 298, 6399, 582, 3286, 1457, 15, 476, 555, 3570, 1386, 2574, 298, 1782, 582, 2420, 344, 582, 298, 349, 26, 3494, 736, 26, 6464, 26, 2158, 17, 3003, 1349, 65, 13, 2756, 401, 4228, 298, 1073, 582, 2420, 3369, 582, 298, 277, 401, 6901, 298, 6399, 582, 3286, 1457, 15, 8838, 15, 349, 26, 83, 6018, 4228, 298, 10988, 582, 298, 22, 993, 2576, 993, 1167, 1641, 614, 1641, 1276, 14137, 1216, 1276, 1276, 6018, 2574, 298, 1375, 582, 2420, 344, 582, 298, 349, 26, 3494, 736, 26, 6408, 4313, 26, 68, 23, 69, 2260, 401, 4228, 298, 1073, 582, 2420, 3369, 582, 298, 277, 401, 6901, 298, 6399, 582, 3286, 86, 3833, 15, 8041, 5424, 1386, 4228, 298, 719, 582, 298, 1400, 26, 383, 26, 1643, 26, 2898, 26, 383, 26, 1085, 26, 2720, 26, 1167, 401, 4228, 283, 711, 63, 1562, 356, 298, 709, 14, 709, 14, 709, 14, 709, 401, 4228, 283, 8815, 63, 719, 356, 283, 1081, 28400, 2079, 2420, 72, 10836, 582, 650, 12, 2574, 298, 17974, 582, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jesramirez/odoo
addons/account_followup/wizard/__init__.py
437
1076
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import account_followup_print # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 2933, 63, 25872, 63, 1361, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 2933, 63, 25872, 63, 1361, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
songmonit/CTTMSONLINE_V8
addons/purchase/partner.py
53
2711
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import fields, osv class res_partner(osv.osv): _name = 'res.partner' _inherit = 'res.partner' def _purchase_invoice_count(self, cr, uid, ids, field_name, arg, context=None): PurchaseOrder = self.pool['purchase.order'] Invoice = self.pool['account.invoice'] res = {} for partner_id in ids: res[partner_id] = {} if 'purchase_order_count' in field_name: res[partner_id]['purchase_order_count'] = PurchaseOrder.search_count(cr,uid, [('partner_id', 'child_of', partner_id)], context=context) if 'supplier_invoice_count' in field_name: res[partner_id]['supplier_invoice_count'] = Invoice.search_count(cr,uid, [('partner_id', 'child_of', partner_id), ('type','=','in_invoice')], context=context) return res def _commercial_fields(self, cr, uid, context=None): return super(res_partner, self)._commercial_fields(cr, uid, context=context) + ['property_product_pricelist_purchase'] _columns = { 'property_product_pricelist_purchase': fields.property( type='many2one', relation='product.pricelist', domain=[('type','=','purchase')], string="Purchase Pricelist", help="This pricelist will be used, instead of the default one, for purchases from the current partner"), 'purchase_order_count': fields.function(_purchase_invoice_count, string='# of Purchase Order', type='integer', multi="count"), 'supplier_invoice_count': fields.function(_purchase_invoice_count, string='# Supplier Invoices', type='integer', multi="count"), } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 258, 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, 420, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 533, 522, 63, 3899, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 283, 470, 14, 3899, 7, 272, 485, 6486, 275, 283, 470, 14, 3899, 7, 339, 347, 485, 9533, 63, 5404, 63, 835, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 901, 63, 354, 12, 1680, 12, 1067, 29, 403, 304, 267, 23177, 6703, 4738, 275, 291, 14, 2293, 459, 9533, 14, 1648, 418, 267, 19868, 275, 291, 14, 2293, 459, 2048, 14, 5404, 418, 267, 522, 275, 1052, 398, 367, 5854, 63, 344, 315, 2762, 26, 288, 522, 59, 3899, 63, 344, 61, 275, 1052, 953, 340, 283, 9533, 63, 1648, 63, 835, 7, 315, 901, 63, 354, 26, 355, 522, 59, 3899, 63, 344, 2733, 9533, 63, 1648, 63, 835, 418, 275, 23177, 6703, 4738, 14, 1733, 63, 835, 8, 1556, 12, 1535, 12, 4274, 3899, 63, 344, 297, 283, 1739, 63, 1618, 297, 5854, 63, 344, 4360, 1067, 29, 1100, 9, 288, 340, 283, 17294, 63, 5404, 63, 835, 7, 315, 901, 63, 354, 26, 355, 522, 59, 3899, 63, 344, 2733, 17294, 63, 5404, 63, 835, 418, 275, 19868, 14, 1733, 63, 835, 8, 1556, 12, 1535, 12, 4274, 3899, 63, 344, 297, 283, 1739, 63, 1618, 297, 5854, 63, 344, 395, 661, 466, 1673, 29511, 262, 63, 5404, 2665, 1067, 29, 1100, 9, 398, 372, 522, 339, 347, 485, 957, 23012, 63, 955, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 372, 1613, 8, 470, 63, 3899, 12, 291, 10445, 957, 23012, 63, 955, 8, 1556, 12, 1747, 12, 1067, 29, 1100, 9, 435, 788, 1829, 63, 2558, 63, 17385, 63, 9533, 418, 339, 485, 3406, 275, 469, 267, 283, 1829, 63, 2558, 63, 17385, 63, 9533, 356, 1504, 14, 1829, 8, 881, 730, 534, 3479, 18, 368, 297, 23664, 5850, 534, 2558, 14, 17385, 297, 23664, 2881, 11699, 466, 1673, 29511, 9533, 2665, 881, 1059, 628, 20486, 20276, 513, 401, 23664, 1720, 628, 2765, 25162, 911, 506, 1202, 12, 3140, 402, 314, 849, 1373, 12, 367, 5861, 335, 3274, 687, 314, 1453, 5854, 1288, 267, 283, 9533, 63, 1648, 63, 835, 356, 1504, 14, 1593, 1547, 9533, 63, 5404, 63, 835, 12, 1059, 26431, 402, 23177, 6703, 9240, 297, 730, 534, 4115, 297, 3510, 628, 835, 1288, 267, 283, 17294, 63, 5404, 63, 835, 356, 1504, 14, 1593, 1547, 9533, 63, 5404, 63, 835, 12, 1059, 26431, 29083, 5697, 1010, 16687, 297, 730, 534, 4115, 297, 3510, 628, 835, 1288, 272, 789, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 258, 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, 420, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 533, 522, 63, 3899, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 283, 470, 14, 3899, 7, 272, 485, 6486, 275, 283, 470, 14, 3899, 7, 339, 347, 485, 9533, 63, 5404, 63, 835, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 901, 63, 354, 12, 1680, 12, 1067, 29, 403, 304, 267, 23177, 6703, 4738, 275, 291, 14, 2293, 459, 9533, 14, 1648, 418, 267, 19868, 275, 291, 14, 2293, 459, 2048, 14, 5404, 418, 267, 522, 275, 1052, 398, 367, 5854, 63, 344, 315, 2762, 26, 288, 522, 59, 3899, 63, 344, 61, 275, 1052, 953, 340, 283, 9533, 63, 1648, 63, 835, 7, 315, 901, 63, 354, 26, 355, 522, 59, 3899, 63, 344, 2733, 9533, 63, 1648, 63, 835, 418, 275, 23177, 6703, 4738, 14, 1733, 63, 835, 8, 1556, 12, 1535, 12, 4274, 3899, 63, 344, 297, 283, 1739, 63, 1618, 297, 5854, 63, 344, 4360, 1067, 29, 1100, 9, 288, 340, 283, 17294, 63, 5404, 63, 835, 7, 315, 901, 63, 354, 26, 355, 522, 59, 3899, 63, 344, 2733, 17294, 63, 5404, 63, 835, 418, 275, 19868, 14, 1733, 63, 835, 8, 1556, 12, 1535, 12, 4274, 3899, 63, 344, 297, 283, 1739, 63, 1618, 297, 5854, 63, 344, 395, 661, 466, 1673, 29511, 262, 63, 5404, 2665, 1067, 29, 1100, 9, 398, 372, 522, 339, 347, 485, 957, 23012, 63, 955, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 372, 1613, 8, 470, 63, 3899, 12, 291, 10445, 957, 23012, 63, 955, 8, 1556, 12, 1747, 12, 1067, 29, 1100, 9, 435, 788, 1829, 63, 2558, 63, 17385, 63, 9533, 418, 339, 485, 3406, 275, 469, 267, 283, 1829, 63, 2558, 63, 17385, 63, 9533, 356, 1504, 14, 1829, 8, 881, 730, 534, 3479, 18, 368, 297, 23664, 5850, 534, 2558, 14, 17385, 297, 23664, 2881, 11699, 466, 1673, 29511, 9533, 2665, 881, 1059, 628, 20486, 20276, 513, 401, 23664, 1720, 628, 2765, 25162, 911, 506, 1202, 12, 3140, 402, 314, 849, 1373, 12, 367, 5861, 335, 3274, 687, 314, 1453, 5854, 1288, 267, 283, 9533, 63, 1648, 63, 835, 356, 1504, 14, 1593, 1547, 9533, 63, 5404, 63, 835, 12, 1059, 26431, 402, 23177, 6703, 9240, 297, 730, 534, 4115, 297, 3510, 628, 835, 1288, 267, 283, 17294, 63, 5404, 63, 835, 356, 1504, 14, 1593, 1547, 9533, 63, 5404, 63, 835, 12, 1059, 26431, 29083, 5697, 1010, 16687, 297, 730, 534, 4115, 297, 3510, 628, 835, 1288, 272, 789, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
HybridF5/tempest
tempest/api/hybrid_cloud/volume/test_extensions.py
2
1836
# Copyright 2013 IBM Corp. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from oslo_log import log as logging from tempest.api.hybrid_cloud.volume import base from tempest import config from tempest import test CONF = config.CONF LOG = logging.getLogger(__name__) class HybridExtensionsV2TestJSON(base.BaseVolumeTest): @test.idempotent_id('94607eb0-43a5-47ca-82aa-736b41bd2e2c') def test_list_extensions(self): # List of all extensions extensions = (self.volumes_extension_client.list_extensions() ['extensions']) if len(CONF.volume_feature_enabled.api_extensions) == 0: raise self.skipException('There are not any extensions configured') extension_list = [extension.get('alias') for extension in extensions] LOG.debug("Cinder extensions: %s" % ','.join(extension_list)) ext = CONF.volume_feature_enabled.api_extensions[0] if ext == 'all': self.assertIn('Hosts', map(lambda x: x['name'], extensions)) elif ext: self.assertIn(ext, map(lambda x: x['alias'], extensions)) else: raise self.skipException('There are not any extensions configured') class HybridExtensionsV1TestJSON(HybridExtensionsV2TestJSON): _api_version = 1
apache-2.0
[ 3, 1898, 6171, 26202, 22304, 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, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 199, 504, 24076, 14, 1246, 14, 27758, 63, 4091, 14, 2405, 492, 1300, 199, 504, 24076, 492, 1101, 199, 504, 24076, 492, 511, 199, 199, 3103, 275, 1101, 14, 3103, 421, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 29591, 14601, 10597, 54, 18, 774, 6243, 8, 1095, 14, 1563, 6464, 774, 304, 339, 768, 396, 14, 21307, 63, 344, 360, 30626, 1780, 2871, 16, 13, 2824, 65, 21, 13, 2417, 696, 13, 2564, 2158, 13, 30665, 66, 2953, 3691, 18, 69, 18, 67, 358, 272, 347, 511, 63, 513, 63, 5359, 8, 277, 304, 267, 327, 3820, 402, 1006, 5478, 267, 5478, 275, 334, 277, 14, 8838, 63, 3435, 63, 1258, 14, 513, 63, 5359, 342, 1993, 788, 5359, 1105, 267, 340, 822, 8, 3103, 14, 2405, 63, 4445, 63, 3827, 14, 1246, 63, 5359, 9, 508, 378, 26, 288, 746, 291, 14, 2759, 1726, 360, 10924, 787, 440, 1263, 5478, 7526, 358, 267, 3329, 63, 513, 275, 359, 3435, 14, 362, 360, 3620, 358, 367, 3329, 315, 5478, 61, 267, 5051, 14, 1757, 480, 35, 5755, 5478, 26, 450, 83, 2, 450, 12814, 904, 8, 3435, 63, 513, 430, 267, 1599, 275, 6392, 14, 2405, 63, 4445, 63, 3827, 14, 1246, 63, 5359, 59, 16, 61, 267, 340, 1599, 508, 283, 452, 356, 288, 291, 14, 4080, 360, 19620, 297, 2341, 8, 2734, 671, 26, 671, 459, 354, 995, 5478, 430, 267, 916, 1599, 26, 288, 291, 14, 4080, 8, 832, 12, 2341, 8, 2734, 671, 26, 671, 459, 3620, 995, 5478, 430, 267, 587, 26, 288, 746, 291, 14, 2759, 1726, 360, 10924, 787, 440, 1263, 5478, 7526, 358, 421, 199, 533, 29591, 14601, 10597, 54, 17, 774, 6243, 8, 21568, 14601, 10597, 54, 18, 774, 6243, 304, 272, 485, 1246, 63, 1023, 275, 413, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 26202, 22304, 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, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 199, 504, 24076, 14, 1246, 14, 27758, 63, 4091, 14, 2405, 492, 1300, 199, 504, 24076, 492, 1101, 199, 504, 24076, 492, 511, 199, 199, 3103, 275, 1101, 14, 3103, 421, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 29591, 14601, 10597, 54, 18, 774, 6243, 8, 1095, 14, 1563, 6464, 774, 304, 339, 768, 396, 14, 21307, 63, 344, 360, 30626, 1780, 2871, 16, 13, 2824, 65, 21, 13, 2417, 696, 13, 2564, 2158, 13, 30665, 66, 2953, 3691, 18, 69, 18, 67, 358, 272, 347, 511, 63, 513, 63, 5359, 8, 277, 304, 267, 327, 3820, 402, 1006, 5478, 267, 5478, 275, 334, 277, 14, 8838, 63, 3435, 63, 1258, 14, 513, 63, 5359, 342, 1993, 788, 5359, 1105, 267, 340, 822, 8, 3103, 14, 2405, 63, 4445, 63, 3827, 14, 1246, 63, 5359, 9, 508, 378, 26, 288, 746, 291, 14, 2759, 1726, 360, 10924, 787, 440, 1263, 5478, 7526, 358, 267, 3329, 63, 513, 275, 359, 3435, 14, 362, 360, 3620, 358, 367, 3329, 315, 5478, 61, 267, 5051, 14, 1757, 480, 35, 5755, 5478, 26, 450, 83, 2, 450, 12814, 904, 8, 3435, 63, 513, 430, 267, 1599, 275, 6392, 14, 2405, 63, 4445, 63, 3827, 14, 1246, 63, 5359, 59, 16, 61, 267, 340, 1599, 508, 283, 452, 356, 288, 291, 14, 4080, 360, 19620, 297, 2341, 8, 2734, 671, 26, 671, 459, 354, 995, 5478, 430, 267, 916, 1599, 26, 288, 291, 14, 4080, 8, 832, 12, 2341, 8, 2734, 671, 26, 671, 459, 3620, 995, 5478, 430, 267, 587, 26, 288, 746, 291, 14, 2759, 1726, 360, 10924, 787, 440, 1263, 5478, 7526, 358, 421, 199, 533, 29591, 14601, 10597, 54, 17, 774, 6243, 8, 21568, 14601, 10597, 54, 18, 774, 6243, 304, 272, 485, 1246, 63, 1023, 275, 413, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
jelugbo/ddi
cms/djangoapps/contentstore/views/tests/test_group_configurations.py
6
23032
""" Group Configuration Tests. """ import json from mock import patch from contentstore.utils import reverse_course_url, reverse_usage_url from contentstore.views.component import SPLIT_TEST_COMPONENT_TYPE from contentstore.views.course import GroupConfiguration from contentstore.tests.utils import CourseTestCase from xmodule.partitions.partitions import Group, UserPartition from xmodule.modulestore.tests.factories import ItemFactory from xmodule.split_test_module import ValidationMessage, ValidationMessageType from xmodule.modulestore.django import modulestore from xmodule.modulestore import ModuleStoreEnum GROUP_CONFIGURATION_JSON = { u'name': u'Test name', u'description': u'Test description', u'groups': [ {u'name': u'Group A'}, {u'name': u'Group B'}, ], } # pylint: disable=no-member class HelperMethods(object): """ Mixin that provides useful methods for Group Configuration tests. """ def _create_content_experiment(self, cid=-1, name_suffix=''): """ Create content experiment. Assign Group Configuration to the experiment if cid is provided. """ vertical = ItemFactory.create( category='vertical', parent_location=self.course.location, display_name='Test Unit {}'.format(name_suffix) ) c0_url = self.course.id.make_usage_key("vertical", "split_test_cond0") c1_url = self.course.id.make_usage_key("vertical", "split_test_cond1") c2_url = self.course.id.make_usage_key("vertical", "split_test_cond2") split_test = ItemFactory.create( category='split_test', parent_location=vertical.location, user_partition_id=cid, display_name='Test Content Experiment {}'.format(name_suffix), group_id_to_child={"0": c0_url, "1": c1_url, "2": c2_url} ) ItemFactory.create( parent_location=split_test.location, category="vertical", display_name="Condition 0 vertical", location=c0_url, ) ItemFactory.create( parent_location=split_test.location, category="vertical", display_name="Condition 1 vertical", location=c1_url, ) ItemFactory.create( parent_location=split_test.location, category="vertical", display_name="Condition 2 vertical", location=c2_url, ) partitions_json = [p.to_json() for p in self.course.user_partitions] self.client.ajax_post( reverse_usage_url("xblock_handler", split_test.location), data={'metadata': {'user_partitions': partitions_json}} ) self.save_course() return (vertical, split_test) def _add_user_partitions(self, count=1): """ Create user partitions for the course. """ partitions = [ UserPartition( i, 'Name ' + str(i), 'Description ' + str(i), [Group(0, 'Group A'), Group(1, 'Group B'), Group(2, 'Group C')] ) for i in xrange(0, count) ] self.course.user_partitions = partitions self.save_course() # pylint: disable=no-member class GroupConfigurationsBaseTestCase(object): """ Mixin with base test cases for the group configurations. """ def _remove_ids(self, content): """ Remove ids from the response. We cannot predict IDs, because they're generated randomly. We use this method to clean up response when creating new group configurations. Returns a tuple that contains removed group configuration ID and group IDs. """ configuration_id = content.pop("id") group_ids = [group.pop("id") for group in content["groups"]] return (configuration_id, group_ids) def test_required_fields_are_absent(self): """ Test required fields are absent. """ bad_jsons = [ # must have name of the configuration { u'description': 'Test description', u'groups': [ {u'name': u'Group A'}, {u'name': u'Group B'}, ], }, # must have at least one group { u'name': u'Test name', u'description': u'Test description', u'groups': [], }, # an empty json {}, ] for bad_json in bad_jsons: response = self.client.post( self._url(), data=json.dumps(bad_json), content_type="application/json", HTTP_ACCEPT="application/json", HTTP_X_REQUESTED_WITH="XMLHttpRequest", ) self.assertEqual(response.status_code, 400) self.assertNotIn("Location", response) content = json.loads(response.content) self.assertIn("error", content) def test_invalid_json(self): """ Test invalid json handling. """ # No property name. invalid_json = "{u'name': 'Test Name', []}" response = self.client.post( self._url(), data=invalid_json, content_type="application/json", HTTP_ACCEPT="application/json", HTTP_X_REQUESTED_WITH="XMLHttpRequest", ) self.assertEqual(response.status_code, 400) self.assertNotIn("Location", response) content = json.loads(response.content) self.assertIn("error", content) # pylint: disable=no-member class GroupConfigurationsListHandlerTestCase(CourseTestCase, GroupConfigurationsBaseTestCase, HelperMethods): """ Test cases for group_configurations_list_handler. """ def setUp(self): """ Set up GroupConfigurationsListHandlerTestCase. """ super(GroupConfigurationsListHandlerTestCase, self).setUp() def _url(self): """ Return url for the handler. """ return reverse_course_url('group_configurations_list_handler', self.course.id) def test_view_index_ok(self): """ Basic check that the groups configuration page responds correctly. """ self.course.user_partitions = [ UserPartition(0, 'First name', 'First description', [Group(0, 'Group A'), Group(1, 'Group B'), Group(2, 'Group C')]), ] self.save_course() if SPLIT_TEST_COMPONENT_TYPE not in self.course.advanced_modules: self.course.advanced_modules.append(SPLIT_TEST_COMPONENT_TYPE) self.store.update_item(self.course, self.user.id) response = self.client.get(self._url()) self.assertEqual(response.status_code, 200) self.assertContains(response, 'First name') self.assertContains(response, 'Group C') def test_view_index_disabled(self): """ Check that group configuration page is not displayed when turned off. """ if SPLIT_TEST_COMPONENT_TYPE in self.course.advanced_modules: self.course.advanced_modules.remove(SPLIT_TEST_COMPONENT_TYPE) self.store.update_item(self.course, self.user.id) resp = self.client.get(self._url()) self.assertContains(resp, "module is disabled") def test_unsupported_http_accept_header(self): """ Test if not allowed header present in request. """ response = self.client.get( self._url(), HTTP_ACCEPT="text/plain", ) self.assertEqual(response.status_code, 406) def test_can_create_group_configuration(self): """ Test that you can create a group configuration. """ expected = { u'description': u'Test description', u'name': u'Test name', u'version': 1, u'groups': [ {u'name': u'Group A', u'version': 1}, {u'name': u'Group B', u'version': 1}, ], } response = self.client.post( self._url(), data=json.dumps(GROUP_CONFIGURATION_JSON), content_type="application/json", HTTP_ACCEPT="application/json", HTTP_X_REQUESTED_WITH="XMLHttpRequest", ) self.assertEqual(response.status_code, 201) self.assertIn("Location", response) content = json.loads(response.content) configuration_id, group_ids = self._remove_ids(content) # pylint: disable=unused-variable self.assertEqual(content, expected) # IDs are unique self.assertEqual(len(group_ids), len(set(group_ids))) self.assertEqual(len(group_ids), 2) self.reload_course() # Verify that user_partitions in the course contains the new group configuration. user_partititons = self.course.user_partitions self.assertEqual(len(user_partititons), 1) self.assertEqual(user_partititons[0].name, u'Test name') self.assertEqual(len(user_partititons[0].groups), 2) self.assertEqual(user_partititons[0].groups[0].name, u'Group A') self.assertEqual(user_partititons[0].groups[1].name, u'Group B') # pylint: disable=no-member class GroupConfigurationsDetailHandlerTestCase(CourseTestCase, GroupConfigurationsBaseTestCase, HelperMethods): """ Test cases for group_configurations_detail_handler. """ ID = 0 def _url(self, cid=-1): """ Return url for the handler. """ cid = cid if cid > 0 else self.ID return reverse_course_url( 'group_configurations_detail_handler', self.course.id, kwargs={'group_configuration_id': cid}, ) def test_can_create_new_group_configuration_if_it_is_not_exist(self): """ PUT new group configuration when no configurations exist in the course. """ expected = { u'id': 999, u'name': u'Test name', u'description': u'Test description', u'version': 1, u'groups': [ {u'id': 0, u'name': u'Group A', u'version': 1}, {u'id': 1, u'name': u'Group B', u'version': 1}, ], u'usage': [], } response = self.client.put( self._url(cid=999), data=json.dumps(expected), content_type="application/json", HTTP_ACCEPT="application/json", HTTP_X_REQUESTED_WITH="XMLHttpRequest", ) content = json.loads(response.content) self.assertEqual(content, expected) self.reload_course() # Verify that user_partitions in the course contains the new group configuration. user_partititons = self.course.user_partitions self.assertEqual(len(user_partititons), 1) self.assertEqual(user_partititons[0].name, u'Test name') self.assertEqual(len(user_partititons[0].groups), 2) self.assertEqual(user_partititons[0].groups[0].name, u'Group A') self.assertEqual(user_partititons[0].groups[1].name, u'Group B') def test_can_edit_group_configuration(self): """ Edit group configuration and check its id and modified fields. """ self._add_user_partitions() self.save_course() expected = { u'id': self.ID, u'name': u'New Test name', u'description': u'New Test description', u'version': 1, u'groups': [ {u'id': 0, u'name': u'New Group Name', u'version': 1}, {u'id': 2, u'name': u'Group C', u'version': 1}, ], u'usage': [], } response = self.client.put( self._url(), data=json.dumps(expected), content_type="application/json", HTTP_ACCEPT="application/json", HTTP_X_REQUESTED_WITH="XMLHttpRequest", ) content = json.loads(response.content) self.assertEqual(content, expected) self.reload_course() # Verify that user_partitions is properly updated in the course. user_partititons = self.course.user_partitions self.assertEqual(len(user_partititons), 1) self.assertEqual(user_partititons[0].name, u'New Test name') self.assertEqual(len(user_partititons[0].groups), 2) self.assertEqual(user_partititons[0].groups[0].name, u'New Group Name') self.assertEqual(user_partititons[0].groups[1].name, u'Group C') def test_can_delete_group_configuration(self): """ Delete group configuration and check user partitions. """ self._add_user_partitions(count=2) self.save_course() response = self.client.delete( self._url(cid=0), content_type="application/json", HTTP_ACCEPT="application/json", HTTP_X_REQUESTED_WITH="XMLHttpRequest", ) self.assertEqual(response.status_code, 204) self.reload_course() # Verify that user_partitions is properly updated in the course. user_partititons = self.course.user_partitions self.assertEqual(len(user_partititons), 1) self.assertEqual(user_partititons[0].name, 'Name 1') def test_cannot_delete_used_group_configuration(self): """ Cannot delete group configuration if it is in use. """ self._add_user_partitions(count=2) self._create_content_experiment(cid=0) response = self.client.delete( self._url(cid=0), content_type="application/json", HTTP_ACCEPT="application/json", HTTP_X_REQUESTED_WITH="XMLHttpRequest", ) self.assertEqual(response.status_code, 400) content = json.loads(response.content) self.assertTrue(content['error']) self.reload_course() # Verify that user_partitions is still the same. user_partititons = self.course.user_partitions self.assertEqual(len(user_partititons), 2) self.assertEqual(user_partititons[0].name, 'Name 0') def test_cannot_delete_non_existent_group_configuration(self): """ Cannot delete group configuration if it is doesn't exist. """ self._add_user_partitions(count=2) response = self.client.delete( self._url(cid=999), content_type="application/json", HTTP_ACCEPT="application/json", HTTP_X_REQUESTED_WITH="XMLHttpRequest", ) self.assertEqual(response.status_code, 404) # Verify that user_partitions is still the same. user_partititons = self.course.user_partitions self.assertEqual(len(user_partititons), 2) self.assertEqual(user_partititons[0].name, 'Name 0') # pylint: disable=no-member class GroupConfigurationsUsageInfoTestCase(CourseTestCase, HelperMethods): """ Tests for usage information of configurations. """ def setUp(self): super(GroupConfigurationsUsageInfoTestCase, self).setUp() def test_group_configuration_not_used(self): """ Test that right data structure will be created if group configuration is not used. """ self._add_user_partitions() actual = GroupConfiguration.add_usage_info(self.course, self.store) expected = [{ 'id': 0, 'name': 'Name 0', 'description': 'Description 0', 'version': 1, 'groups': [ {'id': 0, 'name': 'Group A', 'version': 1}, {'id': 1, 'name': 'Group B', 'version': 1}, {'id': 2, 'name': 'Group C', 'version': 1}, ], 'usage': [], }] self.assertEqual(actual, expected) def test_can_get_correct_usage_info(self): """ Test if group configurations json updated successfully with usage information. """ self._add_user_partitions(count=2) vertical, __ = self._create_content_experiment(cid=0, name_suffix='0') self._create_content_experiment(name_suffix='1') actual = GroupConfiguration.add_usage_info(self.course, self.store) expected = [{ 'id': 0, 'name': 'Name 0', 'description': 'Description 0', 'version': 1, 'groups': [ {'id': 0, 'name': 'Group A', 'version': 1}, {'id': 1, 'name': 'Group B', 'version': 1}, {'id': 2, 'name': 'Group C', 'version': 1}, ], 'usage': [{ 'url': '/container/{}'.format(vertical.location), 'label': 'Test Unit 0 / Test Content Experiment 0', 'validation': None, }], }, { 'id': 1, 'name': 'Name 1', 'description': 'Description 1', 'version': 1, 'groups': [ {'id': 0, 'name': 'Group A', 'version': 1}, {'id': 1, 'name': 'Group B', 'version': 1}, {'id': 2, 'name': 'Group C', 'version': 1}, ], 'usage': [], }] self.assertEqual(actual, expected) def test_can_use_one_configuration_in_multiple_experiments(self): """ Test if multiple experiments are present in usage info when they use same group configuration. """ self._add_user_partitions() vertical, __ = self._create_content_experiment(cid=0, name_suffix='0') vertical1, __ = self._create_content_experiment(cid=0, name_suffix='1') actual = GroupConfiguration.add_usage_info(self.course, self.store) expected = [{ 'id': 0, 'name': 'Name 0', 'description': 'Description 0', 'version': 1, 'groups': [ {'id': 0, 'name': 'Group A', 'version': 1}, {'id': 1, 'name': 'Group B', 'version': 1}, {'id': 2, 'name': 'Group C', 'version': 1}, ], 'usage': [{ 'url': '/container/{}'.format(vertical.location), 'label': 'Test Unit 0 / Test Content Experiment 0', 'validation': None, }, { 'url': '/container/{}'.format(vertical1.location), 'label': 'Test Unit 1 / Test Content Experiment 1', 'validation': None, }], }] self.assertEqual(actual, expected) def test_can_handle_without_parent(self): """ Test if it possible to handle case when split_test has no parent. """ self._add_user_partitions() # Create split test without parent. with modulestore().branch_setting(ModuleStoreEnum.Branch.published_only): orphan = modulestore().create_item( ModuleStoreEnum.UserID.test, self.course.id, 'split_test', ) orphan.user_partition_id = 0 orphan.display_name = 'Test Content Experiment' modulestore().update_item(orphan, ModuleStoreEnum.UserID.test) self.save_course() actual = GroupConfiguration.get_usage_info(self.course, self.store) self.assertEqual(actual, {0: []}) class GroupConfigurationsValidationTestCase(CourseTestCase, HelperMethods): """ Tests for validation in Group Configurations. """ def setUp(self): super(GroupConfigurationsValidationTestCase, self).setUp() @patch('xmodule.split_test_module.SplitTestDescriptor.validation_messages') def test_error_message_present(self, mocked_validation_messages): """ Tests if validation message is present. """ self._add_user_partitions() split_test = self._create_content_experiment(cid=0, name_suffix='0')[1] mocked_validation_messages.return_value = [ ValidationMessage( split_test, u"Validation message", ValidationMessageType.error ) ] group_configuration = GroupConfiguration.add_usage_info(self.course, self.store)[0] self.assertEqual( group_configuration['usage'][0]['validation'], { 'message': u'This content experiment has issues that affect content visibility.', 'type': 'error' } ) @patch('xmodule.split_test_module.SplitTestDescriptor.validation_messages') def test_warning_message_present(self, mocked_validation_messages): """ Tests if validation message is present. """ self._add_user_partitions() split_test = self._create_content_experiment(cid=0, name_suffix='0')[1] mocked_validation_messages.return_value = [ ValidationMessage( split_test, u"Validation message", ValidationMessageType.warning ) ] group_configuration = GroupConfiguration.add_usage_info(self.course, self.store)[0] self.assertEqual( group_configuration['usage'][0]['validation'], { 'message': u'This content experiment has issues that affect content visibility.', 'type': 'warning' } ) @patch('xmodule.split_test_module.SplitTestDescriptor.validation_messages') def test_update_usage_info(self, mocked_validation_messages): """ Tests if validation message is present when updating usage info. """ self._add_user_partitions() split_test = self._create_content_experiment(cid=0, name_suffix='0')[1] mocked_validation_messages.return_value = [ ValidationMessage( split_test, u"Validation message", ValidationMessageType.warning ) ] group_configuration = GroupConfiguration.update_usage_info(self.store, self.course, self.course.user_partitions[0]) self.assertEqual( group_configuration['usage'][0]['validation'], { 'message': u'This content experiment has issues that affect content visibility.', 'type': 'warning' } ) @patch('xmodule.split_test_module.SplitTestDescriptor.validation_messages') def test_update_usage_info_no_message(self, mocked_validation_messages): """ Tests if validation message is not present when updating usage info. """ self._add_user_partitions() self._create_content_experiment(cid=0, name_suffix='0') mocked_validation_messages.return_value = [] group_configuration = GroupConfiguration.update_usage_info(self.store, self.course, self.course.user_partitions[0]) self.assertEqual(group_configuration['usage'][0]['validation'], None)
agpl-3.0
[ 624, 199, 2448, 11595, 6496, 14, 199, 624, 199, 646, 2022, 199, 504, 1683, 492, 3371, 199, 504, 23061, 14, 1208, 492, 3837, 63, 1972, 63, 633, 12, 3837, 63, 3807, 63, 633, 199, 504, 23061, 14, 4196, 14, 3173, 492, 428, 2749, 649, 63, 2864, 63, 20360, 63, 2711, 199, 504, 23061, 14, 4196, 14, 1972, 492, 5611, 5688, 199, 504, 23061, 14, 2219, 14, 1208, 492, 5531, 1746, 199, 504, 9872, 14, 12553, 14, 12553, 492, 5611, 12, 2876, 13068, 199, 504, 9872, 14, 10012, 14, 2219, 14, 15406, 492, 19319, 199, 504, 9872, 14, 1294, 63, 396, 63, 578, 492, 19381, 2209, 12, 19381, 12091, 199, 504, 9872, 14, 10012, 14, 1176, 492, 10996, 199, 504, 9872, 14, 10012, 492, 23431, 199, 199, 7823, 63, 22212, 63, 6243, 275, 469, 272, 399, 7, 354, 356, 399, 7, 774, 536, 297, 272, 399, 5121, 397, 4802, 356, 399, 7, 774, 1369, 297, 272, 399, 7, 2634, 356, 359, 267, 469, 85, 7, 354, 356, 399, 7, 2448, 437, 2267, 267, 469, 85, 7, 354, 356, 399, 7, 2448, 699, 2267, 272, 2156, 199, 93, 421, 199, 3, 4287, 26, 3507, 29, 889, 13, 1114, 199, 533, 11642, 10385, 8, 785, 304, 272, 408, 272, 28438, 626, 6571, 2997, 3102, 367, 5611, 11595, 2295, 14, 272, 408, 272, 347, 485, 981, 63, 1317, 63, 10873, 8, 277, 12, 12229, 4022, 17, 12, 536, 63, 4511, 9280, 267, 408, 267, 2790, 1564, 11805, 14, 398, 16927, 5611, 11595, 370, 314, 11805, 340, 12229, 365, 2741, 14, 267, 408, 267, 13763, 275, 19319, 14, 981, 8, 288, 4637, 534, 7870, 297, 288, 1676, 63, 1985, 29, 277, 14, 1972, 14, 1985, 12, 288, 2929, 63, 354, 534, 774, 12008, 9499, 908, 8, 354, 63, 4511, 9, 267, 776, 267, 286, 16, 63, 633, 275, 291, 14, 1972, 14, 344, 14, 1875, 63, 3807, 63, 498, 480, 7870, 401, 298, 1294, 63, 396, 63, 2067, 16, 531, 267, 286, 17, 63, 633, 275, 291, 14, 1972, 14, 344, 14, 1875, 63, 3807, 63, 498, 480, 7870, 401, 298, 1294, 63, 396, 63, 2067, 17, 531, 267, 286, 18, 63, 633, 275, 291, 14, 1972, 14, 344, 14, 1875, 63, 3807, 63, 498, 480, 7870, 401, 298, 1294, 63, 396, 63, 2067, 18, 531, 267, 3715, 63, 396, 275, 19319, 14, 981, 8, 288, 4637, 534, 1294, 63, 396, 297, 288, 1676, 63, 1985, 29, 7870, 14, 1985, 12, 288, 922, 63, 5312, 63, 344, 29, 7504, 12, 288, 2929, 63, 354, 534, 774, 6646, 23997, 9499, 908, 8, 354, 63, 4511, 395, 288, 1572, 63, 344, 63, 475, 63, 1739, 8871, 16, 582, 286, 16, 63, 633, 12, 298, 17, 582, 286, 17, 63, 633, 12, 298, 18, 582, 286, 18, 63, 633, 93, 267, 776, 267, 19319, 14, 981, 8, 288, 1676, 63, 1985, 29, 1294, 63, 396, 14, 1985, 12, 288, 4637, 628, 7870, 401, 288, 2929, 63, 354, 628, 9558, 378, 13763, 401, 288, 2909, 29, 67, 16, 63, 633, 12, 267, 776, 267, 19319, 14, 981, 8, 288, 1676, 63, 1985, 29, 1294, 63, 396, 14, 1985, 12, 288, 4637, 628, 7870, 401, 288, 2929, 63, 354, 628, 9558, 413, 13763, 401, 288, 2909, 29, 67, 17, 63, 633, 12, 267, 776, 267, 19319, 14, 981, 8, 288, 1676, 63, 1985, 29, 1294, 63, 396, 14, 1985, 12, 288, 4637, 628, 7870, 401, 288, 2929, 63, 354, 628, 9558, 499, 13763, 401, 288, 2909, 29, 67, 18, 63, 633, 12, 267, 776, 398, 16394, 63, 1001, 275, 359, 80, 14, 475, 63, 1001, 342, 367, 299, 315, 291, 14, 1972, 14, 751, 63, 12553, 61, 398, 291, 14, 1258, 14, 12774, 63, 1932, 8, 288, 3837, 63, 3807, 63, 633, 480, 11283, 63, 2232, 401, 3715, 63, 396, 14, 1985, 395, 288, 666, 3713, 2343, 356, 791, 751, 63, 12553, 356, 16394, 63, 1001, 4863, 267, 776, 398, 291, 14, 2117, 63, 1972, 342, 267, 372, 334, 7870, 12, 3715, 63, 396, 9, 339, 347, 485, 525, 63, 751, 63, 12553, 8, 277, 12, 2338, 29, 17, 304, 267, 408, 267, 2790, 922, 16394, 367, 314, 2518, 14, 267, 408, 267, 16394, 275, 359, 288, 2876, 13068, 8, 355, 284, 12, 283, 985, 283, 435, 620, 8, 73, 395, 283, 5831, 283, 435, 620, 8, 73, 395, 359, 2448, 8, 16, 12, 283, 2448, 437, 659, 5611, 8, 17, 12, 283, 2448, 699, 659, 5611, 8, 18, 12, 283, 2448, 445, 5440, 288, 776, 367, 284, 315, 4945, 8, 16, 12, 2338, 9, 267, 1622, 398, 291, 14, 1972, 14, 751, 63, 12553, 275, 16394, 267, 291, 14, 2117, 63, 1972, 342, 421, 199, 3, 4287, 26, 3507, 29, 889, 13, 1114, 199, 533, 5611, 25808, 20760, 8, 785, 304, 272, 408, 272, 28438, 543, 1300, 511, 5560, 367, 314, 1572, 13422, 14, 272, 408, 272, 347, 485, 2168, 63, 1580, 8, 277, 12, 1564, 304, 267, 408, 267, 5852, 2762, 687, 314, 1177, 14, 2136, 3913, 12610, 11449, 12, 2952, 2985, 3984, 267, 4046, 19311, 14, 267, 2136, 675, 642, 1083, 370, 3633, 1536, 1177, 1380, 6425, 892, 1572, 13422, 14, 267, 1803, 282, 2008, 626, 3509, 4829, 1572, 2897, 2870, 436, 1572, 11449, 14, 267, 408, 267, 2897, 63, 344, 275, 1564, 14, 1935, 480, 344, 531, 267, 1572, 63, 1580, 275, 359, 923, 14, 1935, 480, 344, 531, 367, 1572, 315, 1564, 905, 2634, 15261, 398, 372, 334, 4758, 63, 344, 12, 1572, 63, 1580, 9, 339, 347, 511, 63, 2427, 63, 955, 63, 1530, 63, 5575, 8, 277, 304, 267, 408, 267, 1379, 1415, 1504, 787, 9552, 14, 267, 408, 267, 4875, 63, 1001, 83, 275, 359, 288, 327, 1471, 1172, 536, 402, 314, 2897, 288, 469, 355, 399, 5121, 397, 4802, 356, 283, 774, 1369, 297, 355, 399, 7, 2634, 356, 359, 490, 469, 85, 7, 354, 356, 399, 7, 2448, 437, 2267, 490, 469, 85, 7, 354, 356, 399, 7, 2448, 699, 2267, 355, 2156, 288, 1660, 288, 327, 1471, 1172, 737, 5210, 1373, 1572, 288, 469, 355, 399, 7, 354, 356, 399, 7, 774, 536, 297, 355, 399, 5121, 397, 4802, 356, 399, 7, 774 ]
[ 199, 2448, 11595, 6496, 14, 199, 624, 199, 646, 2022, 199, 504, 1683, 492, 3371, 199, 504, 23061, 14, 1208, 492, 3837, 63, 1972, 63, 633, 12, 3837, 63, 3807, 63, 633, 199, 504, 23061, 14, 4196, 14, 3173, 492, 428, 2749, 649, 63, 2864, 63, 20360, 63, 2711, 199, 504, 23061, 14, 4196, 14, 1972, 492, 5611, 5688, 199, 504, 23061, 14, 2219, 14, 1208, 492, 5531, 1746, 199, 504, 9872, 14, 12553, 14, 12553, 492, 5611, 12, 2876, 13068, 199, 504, 9872, 14, 10012, 14, 2219, 14, 15406, 492, 19319, 199, 504, 9872, 14, 1294, 63, 396, 63, 578, 492, 19381, 2209, 12, 19381, 12091, 199, 504, 9872, 14, 10012, 14, 1176, 492, 10996, 199, 504, 9872, 14, 10012, 492, 23431, 199, 199, 7823, 63, 22212, 63, 6243, 275, 469, 272, 399, 7, 354, 356, 399, 7, 774, 536, 297, 272, 399, 5121, 397, 4802, 356, 399, 7, 774, 1369, 297, 272, 399, 7, 2634, 356, 359, 267, 469, 85, 7, 354, 356, 399, 7, 2448, 437, 2267, 267, 469, 85, 7, 354, 356, 399, 7, 2448, 699, 2267, 272, 2156, 199, 93, 421, 199, 3, 4287, 26, 3507, 29, 889, 13, 1114, 199, 533, 11642, 10385, 8, 785, 304, 272, 408, 272, 28438, 626, 6571, 2997, 3102, 367, 5611, 11595, 2295, 14, 272, 408, 272, 347, 485, 981, 63, 1317, 63, 10873, 8, 277, 12, 12229, 4022, 17, 12, 536, 63, 4511, 9280, 267, 408, 267, 2790, 1564, 11805, 14, 398, 16927, 5611, 11595, 370, 314, 11805, 340, 12229, 365, 2741, 14, 267, 408, 267, 13763, 275, 19319, 14, 981, 8, 288, 4637, 534, 7870, 297, 288, 1676, 63, 1985, 29, 277, 14, 1972, 14, 1985, 12, 288, 2929, 63, 354, 534, 774, 12008, 9499, 908, 8, 354, 63, 4511, 9, 267, 776, 267, 286, 16, 63, 633, 275, 291, 14, 1972, 14, 344, 14, 1875, 63, 3807, 63, 498, 480, 7870, 401, 298, 1294, 63, 396, 63, 2067, 16, 531, 267, 286, 17, 63, 633, 275, 291, 14, 1972, 14, 344, 14, 1875, 63, 3807, 63, 498, 480, 7870, 401, 298, 1294, 63, 396, 63, 2067, 17, 531, 267, 286, 18, 63, 633, 275, 291, 14, 1972, 14, 344, 14, 1875, 63, 3807, 63, 498, 480, 7870, 401, 298, 1294, 63, 396, 63, 2067, 18, 531, 267, 3715, 63, 396, 275, 19319, 14, 981, 8, 288, 4637, 534, 1294, 63, 396, 297, 288, 1676, 63, 1985, 29, 7870, 14, 1985, 12, 288, 922, 63, 5312, 63, 344, 29, 7504, 12, 288, 2929, 63, 354, 534, 774, 6646, 23997, 9499, 908, 8, 354, 63, 4511, 395, 288, 1572, 63, 344, 63, 475, 63, 1739, 8871, 16, 582, 286, 16, 63, 633, 12, 298, 17, 582, 286, 17, 63, 633, 12, 298, 18, 582, 286, 18, 63, 633, 93, 267, 776, 267, 19319, 14, 981, 8, 288, 1676, 63, 1985, 29, 1294, 63, 396, 14, 1985, 12, 288, 4637, 628, 7870, 401, 288, 2929, 63, 354, 628, 9558, 378, 13763, 401, 288, 2909, 29, 67, 16, 63, 633, 12, 267, 776, 267, 19319, 14, 981, 8, 288, 1676, 63, 1985, 29, 1294, 63, 396, 14, 1985, 12, 288, 4637, 628, 7870, 401, 288, 2929, 63, 354, 628, 9558, 413, 13763, 401, 288, 2909, 29, 67, 17, 63, 633, 12, 267, 776, 267, 19319, 14, 981, 8, 288, 1676, 63, 1985, 29, 1294, 63, 396, 14, 1985, 12, 288, 4637, 628, 7870, 401, 288, 2929, 63, 354, 628, 9558, 499, 13763, 401, 288, 2909, 29, 67, 18, 63, 633, 12, 267, 776, 398, 16394, 63, 1001, 275, 359, 80, 14, 475, 63, 1001, 342, 367, 299, 315, 291, 14, 1972, 14, 751, 63, 12553, 61, 398, 291, 14, 1258, 14, 12774, 63, 1932, 8, 288, 3837, 63, 3807, 63, 633, 480, 11283, 63, 2232, 401, 3715, 63, 396, 14, 1985, 395, 288, 666, 3713, 2343, 356, 791, 751, 63, 12553, 356, 16394, 63, 1001, 4863, 267, 776, 398, 291, 14, 2117, 63, 1972, 342, 267, 372, 334, 7870, 12, 3715, 63, 396, 9, 339, 347, 485, 525, 63, 751, 63, 12553, 8, 277, 12, 2338, 29, 17, 304, 267, 408, 267, 2790, 922, 16394, 367, 314, 2518, 14, 267, 408, 267, 16394, 275, 359, 288, 2876, 13068, 8, 355, 284, 12, 283, 985, 283, 435, 620, 8, 73, 395, 283, 5831, 283, 435, 620, 8, 73, 395, 359, 2448, 8, 16, 12, 283, 2448, 437, 659, 5611, 8, 17, 12, 283, 2448, 699, 659, 5611, 8, 18, 12, 283, 2448, 445, 5440, 288, 776, 367, 284, 315, 4945, 8, 16, 12, 2338, 9, 267, 1622, 398, 291, 14, 1972, 14, 751, 63, 12553, 275, 16394, 267, 291, 14, 2117, 63, 1972, 342, 421, 199, 3, 4287, 26, 3507, 29, 889, 13, 1114, 199, 533, 5611, 25808, 20760, 8, 785, 304, 272, 408, 272, 28438, 543, 1300, 511, 5560, 367, 314, 1572, 13422, 14, 272, 408, 272, 347, 485, 2168, 63, 1580, 8, 277, 12, 1564, 304, 267, 408, 267, 5852, 2762, 687, 314, 1177, 14, 2136, 3913, 12610, 11449, 12, 2952, 2985, 3984, 267, 4046, 19311, 14, 267, 2136, 675, 642, 1083, 370, 3633, 1536, 1177, 1380, 6425, 892, 1572, 13422, 14, 267, 1803, 282, 2008, 626, 3509, 4829, 1572, 2897, 2870, 436, 1572, 11449, 14, 267, 408, 267, 2897, 63, 344, 275, 1564, 14, 1935, 480, 344, 531, 267, 1572, 63, 1580, 275, 359, 923, 14, 1935, 480, 344, 531, 367, 1572, 315, 1564, 905, 2634, 15261, 398, 372, 334, 4758, 63, 344, 12, 1572, 63, 1580, 9, 339, 347, 511, 63, 2427, 63, 955, 63, 1530, 63, 5575, 8, 277, 304, 267, 408, 267, 1379, 1415, 1504, 787, 9552, 14, 267, 408, 267, 4875, 63, 1001, 83, 275, 359, 288, 327, 1471, 1172, 536, 402, 314, 2897, 288, 469, 355, 399, 5121, 397, 4802, 356, 283, 774, 1369, 297, 355, 399, 7, 2634, 356, 359, 490, 469, 85, 7, 354, 356, 399, 7, 2448, 437, 2267, 490, 469, 85, 7, 354, 356, 399, 7, 2448, 699, 2267, 355, 2156, 288, 1660, 288, 327, 1471, 1172, 737, 5210, 1373, 1572, 288, 469, 355, 399, 7, 354, 356, 399, 7, 774, 536, 297, 355, 399, 5121, 397, 4802, 356, 399, 7, 774, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Unow/edx-platform
lms/djangoapps/certificates/queue.py
44
10443
from certificates.models import GeneratedCertificate from certificates.models import certificate_status_for_student from certificates.models import CertificateStatuses as status from certificates.models import CertificateWhitelist from courseware import grades, courses from django.test.client import RequestFactory from capa.xqueue_interface import XQueueInterface from capa.xqueue_interface import make_xheader, make_hashkey from django.conf import settings from requests.auth import HTTPBasicAuth from student.models import UserProfile, CourseEnrollment from verify_student.models import SoftwareSecurePhotoVerification import json import random import logging import lxml.html from lxml.etree import XMLSyntaxError, ParserError logger = logging.getLogger(__name__) class XQueueCertInterface(object): """ XQueueCertificateInterface provides an interface to the xqueue server for managing student certificates. Instantiating an object will create a new connection to the queue server. See models.py for valid state transitions, summary of methods: add_cert: Add a new certificate. Puts a single request on the queue for the student/course. Once the certificate is generated a post will be made to the update_certificate view which will save the certificate download URL. regen_cert: Regenerate an existing certificate. For a user that already has a certificate this will delete the existing one and generate a new cert. del_cert: Delete an existing certificate For a user that already has a certificate this will delete his cert. """ def __init__(self, request=None): # Get basic auth (username/password) for # xqueue connection if it's in the settings if settings.XQUEUE_INTERFACE.get('basic_auth') is not None: requests_auth = HTTPBasicAuth( *settings.XQUEUE_INTERFACE['basic_auth']) else: requests_auth = None if request is None: factory = RequestFactory() self.request = factory.get('/') else: self.request = request self.xqueue_interface = XQueueInterface( settings.XQUEUE_INTERFACE['url'], settings.XQUEUE_INTERFACE['django_auth'], requests_auth, ) self.whitelist = CertificateWhitelist.objects.all() self.restricted = UserProfile.objects.filter(allow_certificate=False) self.use_https = True def regen_cert(self, student, course_id, course=None, forced_grade=None, template_file=None): """(Re-)Make certificate for a particular student in a particular course Arguments: student - User.object course_id - courseenrollment.course_id (string) WARNING: this command will leave the old certificate, if one exists, laying around in AWS taking up space. If this is a problem, take pains to clean up storage before running this command. Change the certificate status to unavailable (if it exists) and request grading. Passing grades will put a certificate request on the queue. Return the status object. """ # TODO: when del_cert is implemented and plumbed through certificates # repo also, do a deletion followed by a creation r/t a simple # recreation. XXX: this leaves orphan cert files laying around in # AWS. See note in the docstring too. try: certificate = GeneratedCertificate.objects.get(user=student, course_id=course_id) certificate.status = status.unavailable certificate.save() except GeneratedCertificate.DoesNotExist: pass return self.add_cert(student, course_id, course, forced_grade, template_file) def del_cert(self, student, course_id): """ Arguments: student - User.object course_id - courseenrollment.course_id (string) Removes certificate for a student, will change the certificate status to 'deleting'. Certificate must be in the 'error' or 'downloadable' state otherwise it will return the current state """ raise NotImplementedError def add_cert(self, student, course_id, course=None, forced_grade=None, template_file=None, title='None'): """ Request a new certificate for a student. Arguments: student - User.object course_id - courseenrollment.course_id (CourseKey) forced_grade - a string indicating a grade parameter to pass with the certificate request. If this is given, grading will be skipped. Will change the certificate status to 'generating'. Certificate must be in the 'unavailable', 'error', 'deleted' or 'generating' state. If a student has a passing grade or is in the whitelist table for the course a request will be made for a new cert. If a student has allow_certificate set to False in the userprofile table the status will change to 'restricted' If a student does not have a passing grade the status will change to status.notpassing Returns the student's status """ VALID_STATUSES = [status.generating, status.unavailable, status.deleted, status.error, status.notpassing] cert_status = certificate_status_for_student(student, course_id)['status'] new_status = cert_status if cert_status in VALID_STATUSES: # grade the student # re-use the course passed in optionally so we don't have to re-fetch everything # for every student if course is None: course = courses.get_course_by_id(course_id) profile = UserProfile.objects.get(user=student) profile_name = profile.name # Needed self.request.user = student self.request.session = {} course_name = course.display_name or course_id.to_deprecated_string() is_whitelisted = self.whitelist.filter(user=student, course_id=course_id, whitelist=True).exists() grade = grades.grade(student, self.request, course) enrollment_mode, __ = CourseEnrollment.enrollment_mode_for_user(student, course_id) mode_is_verified = (enrollment_mode == GeneratedCertificate.MODES.verified) user_is_verified = SoftwareSecurePhotoVerification.user_is_verified(student) user_is_reverified = SoftwareSecurePhotoVerification.user_is_reverified_for_all(course_id, student) cert_mode = enrollment_mode if (mode_is_verified and user_is_verified and user_is_reverified): template_pdf = "certificate-template-{id.org}-{id.course}-verified.pdf".format(id=course_id) elif (mode_is_verified and not (user_is_verified and user_is_reverified)): template_pdf = "certificate-template-{id.org}-{id.course}.pdf".format(id=course_id) cert_mode = GeneratedCertificate.MODES.honor else: # honor code and audit students template_pdf = "certificate-template-{id.org}-{id.course}.pdf".format(id=course_id) if forced_grade: grade['grade'] = forced_grade cert, __ = GeneratedCertificate.objects.get_or_create(user=student, course_id=course_id) cert.mode = cert_mode cert.user = student cert.grade = grade['percent'] cert.course_id = course_id cert.name = profile_name # Strip HTML from grade range label grade_contents = grade.get('grade', None) try: grade_contents = lxml.html.fromstring(grade_contents).text_content() except (TypeError, XMLSyntaxError, ParserError) as e: # Despite blowing up the xml parser, bad values here are fine grade_contents = None if is_whitelisted or grade_contents is not None: # check to see whether the student is on the # the embargoed country restricted list # otherwise, put a new certificate request # on the queue if self.restricted.filter(user=student).exists(): new_status = status.restricted cert.status = new_status cert.save() else: key = make_hashkey(random.random()) cert.key = key contents = { 'action': 'create', 'username': student.username, 'course_id': course_id.to_deprecated_string(), 'course_name': course_name, 'name': profile_name, 'grade': grade_contents, 'template_pdf': template_pdf, } if template_file: contents['template_pdf'] = template_file new_status = status.generating cert.status = new_status cert.save() self._send_to_xqueue(contents, key) else: cert_status = status.notpassing cert.status = cert_status cert.save() return new_status def _send_to_xqueue(self, contents, key): if self.use_https: proto = "https" else: proto = "http" xheader = make_xheader( '{0}://{1}/update_certificate?{2}'.format( proto, settings.SITE_NAME, key), key, settings.CERT_QUEUE) (error, msg) = self.xqueue_interface.send_to_queue( header=xheader, body=json.dumps(contents)) if error: logger.critical('Unable to add a request to the queue: {} {}'.format(error, msg)) raise Exception('Unable to send queue message')
agpl-3.0
[ 504, 14512, 14, 992, 492, 17065, 11414, 199, 504, 14512, 14, 992, 492, 5897, 63, 1205, 63, 509, 63, 5500, 199, 504, 14512, 14, 992, 492, 12904, 11232, 5589, 465, 2004, 199, 504, 14512, 14, 992, 492, 12904, 19803, 513, 199, 199, 504, 20736, 492, 1999, 3424, 12, 13588, 199, 504, 1639, 14, 396, 14, 1258, 492, 18638, 199, 504, 28068, 14, 88, 1825, 63, 3266, 492, 1323, 3737, 4267, 199, 504, 28068, 14, 88, 1825, 63, 3266, 492, 1852, 63, 88, 1291, 12, 1852, 63, 2227, 498, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 4145, 14, 1178, 492, 3101, 6845, 2817, 199, 504, 6474, 14, 992, 492, 19037, 12, 18946, 199, 504, 4911, 63, 5500, 14, 992, 492, 2290, 24117, 21258, 22595, 199, 199, 646, 2022, 199, 646, 2196, 199, 646, 2050, 199, 646, 14490, 14, 1360, 199, 504, 14490, 14, 9464, 492, 4692, 9294, 12, 10191, 547, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 1323, 3737, 14768, 4267, 8, 785, 304, 272, 408, 272, 1323, 3737, 11414, 4267, 6571, 376, 272, 3217, 370, 314, 671, 1825, 1654, 367, 272, 28453, 6474, 14512, 14, 339, 14089, 4466, 1958, 376, 909, 911, 1218, 282, 892, 272, 1950, 370, 314, 4126, 1654, 14, 339, 1666, 1709, 14, 647, 367, 1686, 1174, 19077, 12, 272, 6212, 402, 3102, 26, 10817, 1050, 63, 4736, 26, 257, 2654, 282, 892, 5897, 14, 221, 510, 14608, 282, 2849, 673, 1056, 641, 314, 4126, 367, 314, 6474, 15, 1972, 14, 673, 19468, 314, 5897, 365, 4046, 282, 2963, 673, 911, 506, 6326, 370, 314, 1678, 63, 6999, 673, 2455, 1314, 911, 3354, 314, 5897, 673, 5235, 2851, 14, 10817, 1295, 287, 63, 4736, 26, 799, 4208, 376, 3411, 5897, 14, 673, 2104, 282, 922, 626, 2575, 965, 282, 5897, 673, 642, 911, 3145, 314, 3411, 1373, 436, 673, 3550, 282, 892, 6250, 14, 421, 2126, 2150, 63, 4736, 26, 257, 8496, 376, 3411, 5897, 673, 2104, 282, 922, 626, 2575, 965, 282, 5897, 673, 642, 911, 3145, 17049, 6250, 14, 339, 408, 339, 347, 636, 826, 721, 277, 12, 1056, 29, 403, 304, 398, 327, 2372, 5678, 1790, 334, 2473, 15, 2060, 9, 367, 267, 327, 671, 1825, 1950, 340, 652, 1159, 315, 314, 2202, 398, 340, 2202, 14, 56, 15125, 63, 17598, 14, 362, 360, 4316, 63, 1178, 358, 365, 440, 488, 26, 288, 4145, 63, 1178, 275, 3101, 6845, 2817, 8, 355, 627, 1751, 14, 56, 15125, 63, 17598, 459, 4316, 63, 1178, 1105, 267, 587, 26, 288, 4145, 63, 1178, 275, 488, 398, 340, 1056, 365, 488, 26, 288, 6434, 275, 18638, 342, 288, 291, 14, 1069, 275, 6434, 14, 362, 7825, 267, 587, 26, 288, 291, 14, 1069, 275, 1056, 398, 291, 14, 88, 1825, 63, 3266, 275, 1323, 3737, 4267, 8, 288, 2202, 14, 56, 15125, 63, 17598, 459, 633, 995, 288, 2202, 14, 56, 15125, 63, 17598, 459, 1176, 63, 1178, 995, 288, 4145, 63, 1178, 12, 267, 776, 267, 291, 14, 14189, 275, 12904, 19803, 513, 14, 1462, 14, 452, 342, 267, 291, 14, 17973, 275, 19037, 14, 1462, 14, 1541, 8, 3306, 63, 6999, 29, 797, 9, 267, 291, 14, 1180, 63, 2859, 275, 715, 339, 347, 1295, 287, 63, 4736, 8, 277, 12, 6474, 12, 2518, 63, 344, 12, 2518, 29, 403, 12, 19565, 63, 4523, 29, 403, 12, 1978, 63, 493, 29, 403, 304, 267, 408, 8, 497, 13, 9, 5483, 5897, 367, 282, 6770, 6474, 315, 282, 6770, 2518, 398, 7628, 26, 881, 6474, 257, 446, 2876, 14, 785, 881, 2518, 63, 344, 446, 2518, 12214, 14, 1972, 63, 344, 334, 875, 9, 398, 14750, 26, 642, 1414, 911, 10137, 314, 2269, 5897, 12, 340, 1373, 3495, 12, 326, 27305, 316, 6818, 315, 10168, 16466, 1536, 4601, 14, 982, 642, 365, 282, 5160, 12, 326, 5452, 691, 3617, 370, 3633, 1536, 4887, 2544, 3879, 642, 1414, 14, 398, 7743, 314, 5897, 2004, 370, 18735, 334, 692, 652, 3495, 9, 436, 1056, 267, 22815, 14, 31755, 1999, 3424, 911, 5324, 282, 5897, 1056, 641, 314, 4126, 14, 398, 1432, 314, 2004, 909, 14, 267, 408, 267, 327, 3254, 26, 1380, 2150, 63, 4736, 365, 6366, 436, 1620, 4295, 379, 4012, 14512, 267, 327, 755, 3831, 2597, 12, 886, 282, 14068, 9437, 701, 282, 7143, 519, 15, 84, 282, 3486, 267, 327, 755, 295, 8782, 14, 5787, 26, 642, 16733, 23237, 6250, 1584, 27305, 316, 6818, 315, 267, 327, 755, 10168, 14, 1666, 5317, 315, 314, 9214, 4634, 14, 267, 862, 26, 288, 5897, 275, 17065, 11414, 14, 1462, 14, 362, 8, 751, 29, 5500, 12, 2518, 63, 344, 29, 1972, 63, 344, 9, 288, 5897, 14, 1205, 275, 2004, 14, 28119, 288, 5897, 14, 2117, 342, 267, 871, 17065, 11414, 14, 7400, 26, 288, 986, 398, 372, 291, 14, 525, 63, 4736, 8, 5500, 12, 2518, 63, 344, 12, 2518, 12, 19565, 63, 4523, 12, 1978, 63, 493, 9, 339, 347, 2150, 63, 4736, 8, 277, 12, 6474, 12, 2518, 63, 344, 304, 398, 408, 267, 7628, 26, 881, 6474, 446, 2876, 14, 785, 881, 2518, 63, 344, 446, 2518, 12214, 14, 1972, 63, 344, 334, 875, 9, 398, 23169, 5897, 367, 282, 6474, 12, 911, 1570, 267, 314, 5897, 2004, 370, 283, 7346, 1337, 1370, 398, 12904, 1471, 506, 315, 314, 283, 705, 7, 503, 283, 4249, 461, 7, 1174, 267, 4257, 652, 911, 372, 314, 1453, 1174, 398, 408, 398, 746, 4279, 339, 347, 1050, 63, 4736, 8, 277, 12, 6474, 12, 2518, 63, 344, 12, 2518, 29, 403, 12, 19565, 63, 4523, 29, 403, 12, 1978, 63, 493, 29, 403, 12, 2538, 534, 403, 735, 267, 408, 267, 4784, 282, 892, 5897, 367, 282, 6474, 14, 398, 7628, 26, 881, 6474, 257, 446, 2876, 14, 785, 881, 2518, 63, 344, 446, 2518, 12214, 14, 1972, 63, 344, 334, 18806, 9, 881, 19565, 63, 4523, 446, 282, 1059, 9297, 282, 16183, 2725, 370, 986, 543, 586, 314, 5897, 1056, 14, 982, 642, 365, 1627, 12, 22815, 586, 911, 506, 9645, 14, 398, 12823, 1570, 314, 5897, 2004, 370, 283, 2038, 1958, 1370, 398, 12904, 1471, 506, 315, 314, 283, 28119 ]
[ 14512, 14, 992, 492, 17065, 11414, 199, 504, 14512, 14, 992, 492, 5897, 63, 1205, 63, 509, 63, 5500, 199, 504, 14512, 14, 992, 492, 12904, 11232, 5589, 465, 2004, 199, 504, 14512, 14, 992, 492, 12904, 19803, 513, 199, 199, 504, 20736, 492, 1999, 3424, 12, 13588, 199, 504, 1639, 14, 396, 14, 1258, 492, 18638, 199, 504, 28068, 14, 88, 1825, 63, 3266, 492, 1323, 3737, 4267, 199, 504, 28068, 14, 88, 1825, 63, 3266, 492, 1852, 63, 88, 1291, 12, 1852, 63, 2227, 498, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 4145, 14, 1178, 492, 3101, 6845, 2817, 199, 504, 6474, 14, 992, 492, 19037, 12, 18946, 199, 504, 4911, 63, 5500, 14, 992, 492, 2290, 24117, 21258, 22595, 199, 199, 646, 2022, 199, 646, 2196, 199, 646, 2050, 199, 646, 14490, 14, 1360, 199, 504, 14490, 14, 9464, 492, 4692, 9294, 12, 10191, 547, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 1323, 3737, 14768, 4267, 8, 785, 304, 272, 408, 272, 1323, 3737, 11414, 4267, 6571, 376, 272, 3217, 370, 314, 671, 1825, 1654, 367, 272, 28453, 6474, 14512, 14, 339, 14089, 4466, 1958, 376, 909, 911, 1218, 282, 892, 272, 1950, 370, 314, 4126, 1654, 14, 339, 1666, 1709, 14, 647, 367, 1686, 1174, 19077, 12, 272, 6212, 402, 3102, 26, 10817, 1050, 63, 4736, 26, 257, 2654, 282, 892, 5897, 14, 221, 510, 14608, 282, 2849, 673, 1056, 641, 314, 4126, 367, 314, 6474, 15, 1972, 14, 673, 19468, 314, 5897, 365, 4046, 282, 2963, 673, 911, 506, 6326, 370, 314, 1678, 63, 6999, 673, 2455, 1314, 911, 3354, 314, 5897, 673, 5235, 2851, 14, 10817, 1295, 287, 63, 4736, 26, 799, 4208, 376, 3411, 5897, 14, 673, 2104, 282, 922, 626, 2575, 965, 282, 5897, 673, 642, 911, 3145, 314, 3411, 1373, 436, 673, 3550, 282, 892, 6250, 14, 421, 2126, 2150, 63, 4736, 26, 257, 8496, 376, 3411, 5897, 673, 2104, 282, 922, 626, 2575, 965, 282, 5897, 673, 642, 911, 3145, 17049, 6250, 14, 339, 408, 339, 347, 636, 826, 721, 277, 12, 1056, 29, 403, 304, 398, 327, 2372, 5678, 1790, 334, 2473, 15, 2060, 9, 367, 267, 327, 671, 1825, 1950, 340, 652, 1159, 315, 314, 2202, 398, 340, 2202, 14, 56, 15125, 63, 17598, 14, 362, 360, 4316, 63, 1178, 358, 365, 440, 488, 26, 288, 4145, 63, 1178, 275, 3101, 6845, 2817, 8, 355, 627, 1751, 14, 56, 15125, 63, 17598, 459, 4316, 63, 1178, 1105, 267, 587, 26, 288, 4145, 63, 1178, 275, 488, 398, 340, 1056, 365, 488, 26, 288, 6434, 275, 18638, 342, 288, 291, 14, 1069, 275, 6434, 14, 362, 7825, 267, 587, 26, 288, 291, 14, 1069, 275, 1056, 398, 291, 14, 88, 1825, 63, 3266, 275, 1323, 3737, 4267, 8, 288, 2202, 14, 56, 15125, 63, 17598, 459, 633, 995, 288, 2202, 14, 56, 15125, 63, 17598, 459, 1176, 63, 1178, 995, 288, 4145, 63, 1178, 12, 267, 776, 267, 291, 14, 14189, 275, 12904, 19803, 513, 14, 1462, 14, 452, 342, 267, 291, 14, 17973, 275, 19037, 14, 1462, 14, 1541, 8, 3306, 63, 6999, 29, 797, 9, 267, 291, 14, 1180, 63, 2859, 275, 715, 339, 347, 1295, 287, 63, 4736, 8, 277, 12, 6474, 12, 2518, 63, 344, 12, 2518, 29, 403, 12, 19565, 63, 4523, 29, 403, 12, 1978, 63, 493, 29, 403, 304, 267, 408, 8, 497, 13, 9, 5483, 5897, 367, 282, 6770, 6474, 315, 282, 6770, 2518, 398, 7628, 26, 881, 6474, 257, 446, 2876, 14, 785, 881, 2518, 63, 344, 446, 2518, 12214, 14, 1972, 63, 344, 334, 875, 9, 398, 14750, 26, 642, 1414, 911, 10137, 314, 2269, 5897, 12, 340, 1373, 3495, 12, 326, 27305, 316, 6818, 315, 10168, 16466, 1536, 4601, 14, 982, 642, 365, 282, 5160, 12, 326, 5452, 691, 3617, 370, 3633, 1536, 4887, 2544, 3879, 642, 1414, 14, 398, 7743, 314, 5897, 2004, 370, 18735, 334, 692, 652, 3495, 9, 436, 1056, 267, 22815, 14, 31755, 1999, 3424, 911, 5324, 282, 5897, 1056, 641, 314, 4126, 14, 398, 1432, 314, 2004, 909, 14, 267, 408, 267, 327, 3254, 26, 1380, 2150, 63, 4736, 365, 6366, 436, 1620, 4295, 379, 4012, 14512, 267, 327, 755, 3831, 2597, 12, 886, 282, 14068, 9437, 701, 282, 7143, 519, 15, 84, 282, 3486, 267, 327, 755, 295, 8782, 14, 5787, 26, 642, 16733, 23237, 6250, 1584, 27305, 316, 6818, 315, 267, 327, 755, 10168, 14, 1666, 5317, 315, 314, 9214, 4634, 14, 267, 862, 26, 288, 5897, 275, 17065, 11414, 14, 1462, 14, 362, 8, 751, 29, 5500, 12, 2518, 63, 344, 29, 1972, 63, 344, 9, 288, 5897, 14, 1205, 275, 2004, 14, 28119, 288, 5897, 14, 2117, 342, 267, 871, 17065, 11414, 14, 7400, 26, 288, 986, 398, 372, 291, 14, 525, 63, 4736, 8, 5500, 12, 2518, 63, 344, 12, 2518, 12, 19565, 63, 4523, 12, 1978, 63, 493, 9, 339, 347, 2150, 63, 4736, 8, 277, 12, 6474, 12, 2518, 63, 344, 304, 398, 408, 267, 7628, 26, 881, 6474, 446, 2876, 14, 785, 881, 2518, 63, 344, 446, 2518, 12214, 14, 1972, 63, 344, 334, 875, 9, 398, 23169, 5897, 367, 282, 6474, 12, 911, 1570, 267, 314, 5897, 2004, 370, 283, 7346, 1337, 1370, 398, 12904, 1471, 506, 315, 314, 283, 705, 7, 503, 283, 4249, 461, 7, 1174, 267, 4257, 652, 911, 372, 314, 1453, 1174, 398, 408, 398, 746, 4279, 339, 347, 1050, 63, 4736, 8, 277, 12, 6474, 12, 2518, 63, 344, 12, 2518, 29, 403, 12, 19565, 63, 4523, 29, 403, 12, 1978, 63, 493, 29, 403, 12, 2538, 534, 403, 735, 267, 408, 267, 4784, 282, 892, 5897, 367, 282, 6474, 14, 398, 7628, 26, 881, 6474, 257, 446, 2876, 14, 785, 881, 2518, 63, 344, 446, 2518, 12214, 14, 1972, 63, 344, 334, 18806, 9, 881, 19565, 63, 4523, 446, 282, 1059, 9297, 282, 16183, 2725, 370, 986, 543, 586, 314, 5897, 1056, 14, 982, 642, 365, 1627, 12, 22815, 586, 911, 506, 9645, 14, 398, 12823, 1570, 314, 5897, 2004, 370, 283, 2038, 1958, 1370, 398, 12904, 1471, 506, 315, 314, 283, 28119, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
elbeardmorez/quodlibet
quodlibet/quodlibet/ext/events/iradiolog.py
1
1277
# -*- coding: utf-8 -*- # Copyright 2006 Joe Wreschnig # # 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. from quodlibet import _ from quodlibet import app from quodlibet.plugins.events import EventPlugin from quodlibet.qltk import Icons class IRadioLog(EventPlugin): PLUGIN_ID = "Internet Radio Log" PLUGIN_NAME = _("Internet Radio Log") PLUGIN_DESC = _("Records the last 10 songs played on radio stations, " "and lists them in the seek context menu.") PLUGIN_ICON = Icons.EDIT def plugin_on_song_started(self, song): if song is None: return player = app.player if player.song.multisong and not song.multisong: time = player.get_position() title = song("title") bookmarks = player.song.bookmarks bookmarks.append([time // 1000, title]) try: bookmarks.pop(-10) except IndexError: pass player.song.bookmarks = bookmarks elif song.multisong: song.bookmarks = []
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 8315, 7135, 69, 644, 470, 11019, 528, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 504, 2173, 364, 773, 386, 492, 485, 199, 504, 2173, 364, 773, 386, 492, 1145, 199, 504, 2173, 364, 773, 386, 14, 5265, 14, 4368, 492, 6763, 5061, 199, 504, 2173, 364, 773, 386, 14, 1710, 2663, 492, 473, 8704, 421, 199, 533, 473, 16065, 2445, 8, 2390, 5061, 304, 272, 10092, 10134, 568, 63, 998, 275, 298, 29820, 13514, 5297, 2, 272, 10092, 10134, 568, 63, 2339, 275, 3824, 29820, 13514, 5297, 531, 272, 10092, 10134, 568, 63, 15119, 275, 3824, 14941, 314, 2061, 1616, 308, 12358, 5232, 379, 641, 22008, 410, 1298, 12, 298, 490, 298, 460, 5548, 3062, 315, 314, 12005, 1067, 6269, 2685, 272, 10092, 10134, 568, 63, 15903, 275, 473, 8704, 14, 17929, 339, 347, 3589, 63, 265, 63, 19351, 63, 8924, 8, 277, 12, 20178, 304, 267, 340, 20178, 365, 488, 26, 288, 372, 398, 7748, 275, 1145, 14, 6147, 398, 340, 7748, 14, 19351, 14, 3029, 19351, 436, 440, 20178, 14, 3029, 19351, 26, 288, 900, 275, 7748, 14, 362, 63, 3124, 342, 288, 2538, 275, 20178, 480, 1213, 531, 288, 32410, 275, 7748, 14, 19351, 14, 25799, 288, 32410, 14, 740, 779, 521, 5001, 5198, 12, 2538, 566, 288, 862, 26, 355, 32410, 14, 1935, 2801, 709, 9, 288, 871, 7888, 26, 355, 986, 288, 7748, 14, 19351, 14, 25799, 275, 32410, 267, 916, 20178, 14, 3029, 19351, 26, 288, 20178, 14, 25799, 275, 942, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 1898, 8315, 7135, 69, 644, 470, 11019, 528, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 504, 2173, 364, 773, 386, 492, 485, 199, 504, 2173, 364, 773, 386, 492, 1145, 199, 504, 2173, 364, 773, 386, 14, 5265, 14, 4368, 492, 6763, 5061, 199, 504, 2173, 364, 773, 386, 14, 1710, 2663, 492, 473, 8704, 421, 199, 533, 473, 16065, 2445, 8, 2390, 5061, 304, 272, 10092, 10134, 568, 63, 998, 275, 298, 29820, 13514, 5297, 2, 272, 10092, 10134, 568, 63, 2339, 275, 3824, 29820, 13514, 5297, 531, 272, 10092, 10134, 568, 63, 15119, 275, 3824, 14941, 314, 2061, 1616, 308, 12358, 5232, 379, 641, 22008, 410, 1298, 12, 298, 490, 298, 460, 5548, 3062, 315, 314, 12005, 1067, 6269, 2685, 272, 10092, 10134, 568, 63, 15903, 275, 473, 8704, 14, 17929, 339, 347, 3589, 63, 265, 63, 19351, 63, 8924, 8, 277, 12, 20178, 304, 267, 340, 20178, 365, 488, 26, 288, 372, 398, 7748, 275, 1145, 14, 6147, 398, 340, 7748, 14, 19351, 14, 3029, 19351, 436, 440, 20178, 14, 3029, 19351, 26, 288, 900, 275, 7748, 14, 362, 63, 3124, 342, 288, 2538, 275, 20178, 480, 1213, 531, 288, 32410, 275, 7748, 14, 19351, 14, 25799, 288, 32410, 14, 740, 779, 521, 5001, 5198, 12, 2538, 566, 288, 862, 26, 355, 32410, 14, 1935, 2801, 709, 9, 288, 871, 7888, 26, 355, 986, 288, 7748, 14, 19351, 14, 25799, 275, 32410, 267, 916, 20178, 14, 3029, 19351, 26, 288, 20178, 14, 25799, 275, 942, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
icoxfog417/pykintone
pykintone/application_settings/general_settings.py
1
1816
import pykintone.structure as ps from pykintone.application_settings.base_administration_api import BaseAdministrationAPI import pykintone.application_settings.setting_result as sr class GeneralSettingsAPI(BaseAdministrationAPI): API_ROOT = "https://{0}.cybozu.com/k/v1{1}/app/settings.json" def __init__(self, account, api_token="", requests_options=(), app_id=""): super(GeneralSettingsAPI, self).__init__(account, api_token, requests_options, app_id) def _make_url(self, preview=False): url = self.API_ROOT.format(self.account.domain, "" if not preview else "/preview") return url def get(self, app_id="", lang="default", preview=False): url = self._make_url(preview) params = { "app": app_id if app_id else self.app_id, "lang": lang } r = self._request("GET", url, params_or_data=params, use_api_token=False) return sr.GetGeneralSettingsResult(r) def update(self, json_or_model, app_id="", revision=-1): # update is preview feature. url = self._make_url(preview=True) _body = json_or_model if isinstance(json_or_model, GeneralSettings): _body = json_or_model.serialize() _body["app"] = app_id if app_id else self.app_id if revision > -1: _body["revision"] = revision r = self._request("PUT", url, params_or_data=_body, use_api_token=False) return sr.GetRevisionResult(r) class GeneralSettings(ps.kintoneStructure): def __init__(self): super(GeneralSettings, self).__init__() self.name = "" self.description = "" self.icon = None self.theme = "" self.revision = -1 def __str__(self): return "{0}: {1}".format(self.name, self.description)
apache-2.0
[ 646, 1134, 75, 442, 368, 14, 6976, 465, 7347, 199, 504, 1134, 75, 442, 368, 14, 3578, 63, 1751, 14, 1095, 63, 2113, 4633, 63, 1246, 492, 3523, 4880, 4633, 3735, 199, 646, 1134, 75, 442, 368, 14, 3578, 63, 1751, 14, 6031, 63, 1099, 465, 11483, 421, 199, 533, 1696, 5268, 3735, 8, 1563, 4880, 4633, 3735, 304, 272, 3261, 63, 5441, 275, 298, 2859, 20193, 16, 5565, 1480, 656, 90, 85, 14, 957, 15, 75, 15, 86, 17, 91, 17, 5995, 571, 15, 1751, 14, 1001, 2, 339, 347, 636, 826, 721, 277, 12, 2933, 12, 2986, 63, 1418, 8772, 4145, 63, 1419, 16729, 1145, 63, 344, 17364, 267, 1613, 8, 14109, 5268, 3735, 12, 291, 2843, 826, 721, 2048, 12, 2986, 63, 1418, 12, 4145, 63, 1419, 12, 1145, 63, 344, 9, 339, 347, 485, 1875, 63, 633, 8, 277, 12, 19653, 29, 797, 304, 267, 1166, 275, 291, 14, 3735, 63, 5441, 14, 908, 8, 277, 14, 2048, 14, 2261, 12, 3087, 340, 440, 19653, 587, 3286, 7780, 531, 267, 372, 1166, 339, 347, 664, 8, 277, 12, 1145, 63, 344, 8772, 6339, 628, 885, 401, 19653, 29, 797, 304, 267, 1166, 275, 291, 423, 1875, 63, 633, 8, 7780, 9, 398, 1862, 275, 469, 288, 298, 571, 582, 1145, 63, 344, 340, 1145, 63, 344, 587, 291, 14, 571, 63, 344, 12, 288, 298, 4159, 582, 6339, 267, 789, 398, 519, 275, 291, 423, 1069, 480, 2970, 401, 1166, 12, 1862, 63, 269, 63, 576, 29, 1162, 12, 675, 63, 1246, 63, 1418, 29, 797, 9, 267, 372, 11483, 14, 1002, 14109, 5268, 2889, 8, 82, 9, 339, 347, 1678, 8, 277, 12, 2022, 63, 269, 63, 1238, 12, 1145, 63, 344, 8772, 6974, 4022, 17, 304, 267, 327, 1678, 365, 19653, 3878, 14, 267, 1166, 275, 291, 423, 1875, 63, 633, 8, 7780, 29, 549, 9, 398, 485, 2030, 275, 2022, 63, 269, 63, 1238, 267, 340, 1228, 8, 1001, 63, 269, 63, 1238, 12, 1696, 5268, 304, 288, 485, 2030, 275, 2022, 63, 269, 63, 1238, 14, 3549, 342, 398, 485, 2030, 905, 571, 937, 275, 1145, 63, 344, 340, 1145, 63, 344, 587, 291, 14, 571, 63, 344, 267, 340, 6974, 690, 446, 17, 26, 288, 485, 2030, 905, 5792, 937, 275, 6974, 398, 519, 275, 291, 423, 1069, 480, 4013, 401, 1166, 12, 1862, 63, 269, 63, 576, 3699, 2030, 12, 675, 63, 1246, 63, 1418, 29, 797, 9, 267, 372, 11483, 14, 1002, 12714, 2889, 8, 82, 9, 421, 199, 533, 1696, 5268, 8, 1190, 14, 75, 442, 368, 10766, 304, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 14109, 5268, 12, 291, 2843, 826, 4533, 267, 291, 14, 354, 275, 3087, 267, 291, 14, 1802, 275, 3087, 267, 291, 14, 4677, 275, 488, 267, 291, 14, 7915, 275, 3087, 267, 291, 14, 5792, 275, 446, 17, 339, 347, 636, 495, 721, 277, 304, 267, 372, 5310, 16, 9160, 469, 17, 5469, 908, 8, 277, 14, 354, 12, 291, 14, 1802, 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 ]
[ 1134, 75, 442, 368, 14, 6976, 465, 7347, 199, 504, 1134, 75, 442, 368, 14, 3578, 63, 1751, 14, 1095, 63, 2113, 4633, 63, 1246, 492, 3523, 4880, 4633, 3735, 199, 646, 1134, 75, 442, 368, 14, 3578, 63, 1751, 14, 6031, 63, 1099, 465, 11483, 421, 199, 533, 1696, 5268, 3735, 8, 1563, 4880, 4633, 3735, 304, 272, 3261, 63, 5441, 275, 298, 2859, 20193, 16, 5565, 1480, 656, 90, 85, 14, 957, 15, 75, 15, 86, 17, 91, 17, 5995, 571, 15, 1751, 14, 1001, 2, 339, 347, 636, 826, 721, 277, 12, 2933, 12, 2986, 63, 1418, 8772, 4145, 63, 1419, 16729, 1145, 63, 344, 17364, 267, 1613, 8, 14109, 5268, 3735, 12, 291, 2843, 826, 721, 2048, 12, 2986, 63, 1418, 12, 4145, 63, 1419, 12, 1145, 63, 344, 9, 339, 347, 485, 1875, 63, 633, 8, 277, 12, 19653, 29, 797, 304, 267, 1166, 275, 291, 14, 3735, 63, 5441, 14, 908, 8, 277, 14, 2048, 14, 2261, 12, 3087, 340, 440, 19653, 587, 3286, 7780, 531, 267, 372, 1166, 339, 347, 664, 8, 277, 12, 1145, 63, 344, 8772, 6339, 628, 885, 401, 19653, 29, 797, 304, 267, 1166, 275, 291, 423, 1875, 63, 633, 8, 7780, 9, 398, 1862, 275, 469, 288, 298, 571, 582, 1145, 63, 344, 340, 1145, 63, 344, 587, 291, 14, 571, 63, 344, 12, 288, 298, 4159, 582, 6339, 267, 789, 398, 519, 275, 291, 423, 1069, 480, 2970, 401, 1166, 12, 1862, 63, 269, 63, 576, 29, 1162, 12, 675, 63, 1246, 63, 1418, 29, 797, 9, 267, 372, 11483, 14, 1002, 14109, 5268, 2889, 8, 82, 9, 339, 347, 1678, 8, 277, 12, 2022, 63, 269, 63, 1238, 12, 1145, 63, 344, 8772, 6974, 4022, 17, 304, 267, 327, 1678, 365, 19653, 3878, 14, 267, 1166, 275, 291, 423, 1875, 63, 633, 8, 7780, 29, 549, 9, 398, 485, 2030, 275, 2022, 63, 269, 63, 1238, 267, 340, 1228, 8, 1001, 63, 269, 63, 1238, 12, 1696, 5268, 304, 288, 485, 2030, 275, 2022, 63, 269, 63, 1238, 14, 3549, 342, 398, 485, 2030, 905, 571, 937, 275, 1145, 63, 344, 340, 1145, 63, 344, 587, 291, 14, 571, 63, 344, 267, 340, 6974, 690, 446, 17, 26, 288, 485, 2030, 905, 5792, 937, 275, 6974, 398, 519, 275, 291, 423, 1069, 480, 4013, 401, 1166, 12, 1862, 63, 269, 63, 576, 3699, 2030, 12, 675, 63, 1246, 63, 1418, 29, 797, 9, 267, 372, 11483, 14, 1002, 12714, 2889, 8, 82, 9, 421, 199, 533, 1696, 5268, 8, 1190, 14, 75, 442, 368, 10766, 304, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 14109, 5268, 12, 291, 2843, 826, 4533, 267, 291, 14, 354, 275, 3087, 267, 291, 14, 1802, 275, 3087, 267, 291, 14, 4677, 275, 488, 267, 291, 14, 7915, 275, 3087, 267, 291, 14, 5792, 275, 446, 17, 339, 347, 636, 495, 721, 277, 304, 267, 372, 5310, 16, 9160, 469, 17, 5469, 908, 8, 277, 14, 354, 12, 291, 14, 1802, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
cloudbase/nova-virtualbox
nova/api/openstack/compute/plugins/v3/servers.py
1
49282
# Copyright 2010 OpenStack Foundation # Copyright 2011 Piston Cloud Computing, Inc # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import base64 import re from oslo_config import cfg from oslo_log import log as logging import oslo_messaging as messaging from oslo_utils import strutils from oslo_utils import timeutils import six import stevedore import webob from webob import exc from nova.api.openstack import common from nova.api.openstack.compute.schemas.v3 import servers as schema_servers from nova.api.openstack.compute.views import servers as views_servers from nova.api.openstack import extensions from nova.api.openstack import wsgi from nova.api import validation from nova import compute from nova.compute import flavors from nova import exception from nova.i18n import _ from nova.i18n import _LW from nova.image import glance from nova import objects from nova.openstack.common import uuidutils from nova import policy from nova import utils ALIAS = 'servers' CONF = cfg.CONF CONF.import_opt('enable_instance_password', 'nova.api.openstack.compute.servers') CONF.import_opt('network_api_class', 'nova.network') CONF.import_opt('reclaim_instance_interval', 'nova.compute.manager') CONF.import_opt('extensions_blacklist', 'nova.api.openstack', group='osapi_v3') CONF.import_opt('extensions_whitelist', 'nova.api.openstack', group='osapi_v3') LOG = logging.getLogger(__name__) authorizer = extensions.core_authorizer('compute:v3', 'servers') class ServersController(wsgi.Controller): """The Server API base controller class for the OpenStack API.""" EXTENSION_CREATE_NAMESPACE = 'nova.api.v3.extensions.server.create' EXTENSION_DESERIALIZE_EXTRACT_SERVER_NAMESPACE = ( 'nova.api.v3.extensions.server.create.deserialize') EXTENSION_REBUILD_NAMESPACE = 'nova.api.v3.extensions.server.rebuild' EXTENSION_DESERIALIZE_EXTRACT_REBUILD_NAMESPACE = ( 'nova.api.v3.extensions.server.rebuild.deserialize') EXTENSION_UPDATE_NAMESPACE = 'nova.api.v3.extensions.server.update' EXTENSION_RESIZE_NAMESPACE = 'nova.api.v3.extensions.server.resize' _view_builder_class = views_servers.ViewBuilderV3 schema_server_create = schema_servers.base_create schema_server_update = schema_servers.base_update schema_server_rebuild = schema_servers.base_rebuild schema_server_resize = schema_servers.base_resize @staticmethod def _add_location(robj): # Just in case... if 'server' not in robj.obj: return robj link = filter(lambda l: l['rel'] == 'self', robj.obj['server']['links']) if link: robj['Location'] = utils.utf8(link[0]['href']) # Convenience return return robj def __init__(self, **kwargs): def _check_load_extension(required_function): def check_whiteblack_lists(ext): # Check whitelist is either empty or if not then the extension # is in the whitelist if (not CONF.osapi_v3.extensions_whitelist or ext.obj.alias in CONF.osapi_v3.extensions_whitelist): # Check the extension is not in the blacklist if ext.obj.alias not in CONF.osapi_v3.extensions_blacklist: return True else: LOG.warning(_LW("Not loading %s because it is " "in the blacklist"), ext.obj.alias) return False else: LOG.warning( _LW("Not loading %s because it is not in the " "whitelist"), ext.obj.alias) return False def check_load_extension(ext): if isinstance(ext.obj, extensions.V3APIExtensionBase): # Filter out for the existence of the required # function here rather than on every request. We # don't have a new abstract base class to reduce # duplication in the extensions as they may want # to implement multiple server (and other) entry # points if hasattr(ext.obj, 'server_create'): if hasattr(ext.obj, required_function): LOG.debug('extension %(ext_alias)s detected by ' 'servers extension for function %(func)s', {'ext_alias': ext.obj.alias, 'func': required_function}) return check_whiteblack_lists(ext) else: LOG.debug( 'extension %(ext_alias)s is missing %(func)s', {'ext_alias': ext.obj.alias, 'func': required_function}) return False else: return False return check_load_extension self.extension_info = kwargs.pop('extension_info') super(ServersController, self).__init__(**kwargs) self.compute_api = compute.API() # Look for implementation of extension point of server creation self.create_extension_manager = \ stevedore.enabled.EnabledExtensionManager( namespace=self.EXTENSION_CREATE_NAMESPACE, check_func=_check_load_extension('server_create'), invoke_on_load=True, invoke_kwds={"extension_info": self.extension_info}, propagate_map_exceptions=True) if not list(self.create_extension_manager): LOG.debug("Did not find any server create extensions") # Look for implementation of extension point of server rebuild self.rebuild_extension_manager = \ stevedore.enabled.EnabledExtensionManager( namespace=self.EXTENSION_REBUILD_NAMESPACE, check_func=_check_load_extension('server_rebuild'), invoke_on_load=True, invoke_kwds={"extension_info": self.extension_info}, propagate_map_exceptions=True) if not list(self.rebuild_extension_manager): LOG.debug("Did not find any server rebuild extensions") # Look for implementation of extension point of server update self.update_extension_manager = \ stevedore.enabled.EnabledExtensionManager( namespace=self.EXTENSION_UPDATE_NAMESPACE, check_func=_check_load_extension('server_update'), invoke_on_load=True, invoke_kwds={"extension_info": self.extension_info}, propagate_map_exceptions=True) if not list(self.update_extension_manager): LOG.debug("Did not find any server update extensions") # Look for implementation of extension point of server resize self.resize_extension_manager = \ stevedore.enabled.EnabledExtensionManager( namespace=self.EXTENSION_RESIZE_NAMESPACE, check_func=_check_load_extension('server_resize'), invoke_on_load=True, invoke_kwds={"extension_info": self.extension_info}, propagate_map_exceptions=True) if not list(self.resize_extension_manager): LOG.debug("Did not find any server resize extensions") # Look for API schema of server create extension self.create_schema_manager = \ stevedore.enabled.EnabledExtensionManager( namespace=self.EXTENSION_CREATE_NAMESPACE, check_func=_check_load_extension('get_server_create_schema'), invoke_on_load=True, invoke_kwds={"extension_info": self.extension_info}, propagate_map_exceptions=True) if list(self.create_schema_manager): self.create_schema_manager.map(self._create_extension_schema, self.schema_server_create) else: LOG.debug("Did not find any server create schemas") # Look for API schema of server update extension self.update_schema_manager = \ stevedore.enabled.EnabledExtensionManager( namespace=self.EXTENSION_UPDATE_NAMESPACE, check_func=_check_load_extension('get_server_update_schema'), invoke_on_load=True, invoke_kwds={"extension_info": self.extension_info}, propagate_map_exceptions=True) if list(self.update_schema_manager): self.update_schema_manager.map(self._update_extension_schema, self.schema_server_update) else: LOG.debug("Did not find any server update schemas") # Look for API schema of server rebuild extension self.rebuild_schema_manager = \ stevedore.enabled.EnabledExtensionManager( namespace=self.EXTENSION_REBUILD_NAMESPACE, check_func=_check_load_extension('get_server_rebuild_schema'), invoke_on_load=True, invoke_kwds={"extension_info": self.extension_info}, propagate_map_exceptions=True) if list(self.rebuild_schema_manager): self.rebuild_schema_manager.map(self._rebuild_extension_schema, self.schema_server_rebuild) else: LOG.debug("Did not find any server rebuild schemas") # Look for API schema of server resize extension self.resize_schema_manager = \ stevedore.enabled.EnabledExtensionManager( namespace=self.EXTENSION_RESIZE_NAMESPACE, check_func=_check_load_extension('get_server_resize_schema'), invoke_on_load=True, invoke_kwds={"extension_info": self.extension_info}, propagate_map_exceptions=True) if list(self.resize_schema_manager): self.resize_schema_manager.map(self._resize_extension_schema, self.schema_server_resize) else: LOG.debug("Did not find any server resize schemas") @extensions.expected_errors((400, 403)) def index(self, req): """Returns a list of server names and ids for a given user.""" try: servers = self._get_servers(req, is_detail=False) except exception.Invalid as err: raise exc.HTTPBadRequest(explanation=err.format_message()) return servers @extensions.expected_errors((400, 403)) def detail(self, req): """Returns a list of server details for a given user.""" try: servers = self._get_servers(req, is_detail=True) except exception.Invalid as err: raise exc.HTTPBadRequest(explanation=err.format_message()) return servers def _get_servers(self, req, is_detail): """Returns a list of servers, based on any search options specified.""" search_opts = {} search_opts.update(req.GET) context = req.environ['nova.context'] remove_invalid_options(context, search_opts, self._get_server_search_options()) # Verify search by 'status' contains a valid status. # Convert it to filter by vm_state or task_state for compute_api. search_opts.pop('status', None) if 'status' in req.GET.keys(): statuses = req.GET.getall('status') states = common.task_and_vm_state_from_status(statuses) vm_state, task_state = states if not vm_state and not task_state: return {'servers': []} search_opts['vm_state'] = vm_state # When we search by vm state, task state will return 'default'. # So we don't need task_state search_opt. if 'default' not in task_state: search_opts['task_state'] = task_state if 'changes-since' in search_opts: try: parsed = timeutils.parse_isotime(search_opts['changes-since']) except ValueError: msg = _('Invalid changes-since value') raise exc.HTTPBadRequest(explanation=msg) search_opts['changes-since'] = parsed # By default, compute's get_all() will return deleted instances. # If an admin hasn't specified a 'deleted' search option, we need # to filter out deleted instances by setting the filter ourselves. # ... Unless 'changes-since' is specified, because 'changes-since' # should return recently deleted images according to the API spec. if 'deleted' not in search_opts: if 'changes-since' not in search_opts: # No 'changes-since', so we only want non-deleted servers search_opts['deleted'] = False if search_opts.get("vm_state") == ['deleted']: if context.is_admin: search_opts['deleted'] = True else: msg = _("Only administrators may list deleted instances") raise exc.HTTPForbidden(explanation=msg) # If tenant_id is passed as a search parameter this should # imply that all_tenants is also enabled unless explicitly # disabled. Note that the tenant_id parameter is filtered out # by remove_invalid_options above unless the requestor is an # admin. # TODO(gmann): 'all_tenants' flag should not be required while # searching with 'tenant_id'. Ref bug# 1185290 # +microversions to achieve above mentioned behavior by # uncommenting below code. # if 'tenant_id' in search_opts and 'all_tenants' not in search_opts: # We do not need to add the all_tenants flag if the tenant # id associated with the token is the tenant id # specified. This is done so a request that does not need # the all_tenants flag does not fail because of lack of # policy permission for compute:get_all_tenants when it # doesn't actually need it. # if context.project_id != search_opts.get('tenant_id'): # search_opts['all_tenants'] = 1 # If all tenants is passed with 0 or false as the value # then remove it from the search options. Nothing passed as # the value for all_tenants is considered to enable the feature all_tenants = search_opts.get('all_tenants') if all_tenants: try: if not strutils.bool_from_string(all_tenants, True): del search_opts['all_tenants'] except ValueError as err: raise exception.InvalidInput(six.text_type(err)) if 'all_tenants' in search_opts: policy.enforce(context, 'compute:get_all_tenants', {'project_id': context.project_id, 'user_id': context.user_id}) del search_opts['all_tenants'] else: if context.project_id: search_opts['project_id'] = context.project_id else: search_opts['user_id'] = context.user_id limit, marker = common.get_limit_and_marker(req) sort_keys, sort_dirs = common.get_sort_params(req.params) try: instance_list = self.compute_api.get_all(context, search_opts=search_opts, limit=limit, marker=marker, want_objects=True, expected_attrs=['pci_devices'], sort_keys=sort_keys, sort_dirs=sort_dirs) except exception.MarkerNotFound: msg = _('marker [%s] not found') % marker raise exc.HTTPBadRequest(explanation=msg) except exception.FlavorNotFound: LOG.debug("Flavor '%s' could not be found ", search_opts['flavor']) instance_list = objects.InstanceList() if is_detail: instance_list.fill_faults() response = self._view_builder.detail(req, instance_list) else: response = self._view_builder.index(req, instance_list) req.cache_db_instances(instance_list) return response def _get_server(self, context, req, instance_uuid): """Utility function for looking up an instance by uuid.""" instance = common.get_instance(self.compute_api, context, instance_uuid, want_objects=True, expected_attrs=['pci_devices', 'flavor']) req.cache_db_instance(instance) return instance def _check_string_length(self, value, name, max_length=None): try: if isinstance(value, six.string_types): value = value.strip() utils.check_string_length(value, name, min_length=1, max_length=max_length) except exception.InvalidInput as e: raise exc.HTTPBadRequest(explanation=e.format_message()) def _get_requested_networks(self, requested_networks): """Create a list of requested networks from the networks attribute.""" networks = [] network_uuids = [] for network in requested_networks: request = objects.NetworkRequest() try: # fixed IP address is optional # if the fixed IP address is not provided then # it will use one of the available IP address from the network request.address = network.get('fixed_ip', None) request.port_id = network.get('port', None) if request.port_id: request.network_id = None if not utils.is_neutron(): # port parameter is only for neutron v2.0 msg = _("Unknown argument: port") raise exc.HTTPBadRequest(explanation=msg) if request.address is not None: msg = _("Specified Fixed IP '%(addr)s' cannot be used " "with port '%(port)s': port already has " "a Fixed IP allocated.") % { "addr": request.address, "port": request.port_id} raise exc.HTTPBadRequest(explanation=msg) else: request.network_id = network['uuid'] if (not request.port_id and not uuidutils.is_uuid_like(request.network_id)): br_uuid = request.network_id.split('-', 1)[-1] if not uuidutils.is_uuid_like(br_uuid): msg = _("Bad networks format: network uuid is " "not in proper format " "(%s)") % request.network_id raise exc.HTTPBadRequest(explanation=msg) # duplicate networks are allowed only for neutron v2.0 if (not utils.is_neutron() and request.network_id and request.network_id in network_uuids): expl = (_("Duplicate networks" " (%s) are not allowed") % request.network_id) raise exc.HTTPBadRequest(explanation=expl) network_uuids.append(request.network_id) networks.append(request) except KeyError as key: expl = _('Bad network format: missing %s') % key raise exc.HTTPBadRequest(explanation=expl) except TypeError: expl = _('Bad networks format') raise exc.HTTPBadRequest(explanation=expl) return objects.NetworkRequestList(objects=networks) # NOTE(vish): Without this regex, b64decode will happily # ignore illegal bytes in the base64 encoded # data. B64_REGEX = re.compile('^(?:[A-Za-z0-9+\/]{4})*' '(?:[A-Za-z0-9+\/]{2}==' '|[A-Za-z0-9+\/]{3}=)?$') def _decode_base64(self, data): data = re.sub(r'\s', '', data) if not self.B64_REGEX.match(data): return None try: return base64.b64decode(data) except TypeError: return None @extensions.expected_errors(404) def show(self, req, id): """Returns server details by server id.""" context = req.environ['nova.context'] instance = common.get_instance(self.compute_api, context, id, want_objects=True, expected_attrs=['pci_devices', 'flavor']) req.cache_db_instance(instance) return self._view_builder.show(req, instance) @wsgi.response(202) @extensions.expected_errors((400, 403, 409, 413)) @validation.schema(schema_server_create) def create(self, req, body): """Creates a new server for a given user.""" context = req.environ['nova.context'] server_dict = body['server'] password = self._get_server_admin_password(server_dict) name = server_dict['name'] # Arguments to be passed to instance create function create_kwargs = {} # Query extensions which want to manipulate the keyword # arguments. # NOTE(cyeoh): This is the hook that extensions use # to replace the extension specific code below. # When the extensions are ported this will also result # in some convenience function from this class being # moved to the extension if list(self.create_extension_manager): self.create_extension_manager.map(self._create_extension_point, server_dict, create_kwargs, body) image_uuid = self._image_from_req_data(server_dict, create_kwargs) # NOTE(cyeoh): Although an extension can set # return_reservation_id in order to request that a reservation # id be returned to the client instead of the newly created # instance information we do not want to pass this parameter # to the compute create call which always returns both. We use # this flag after the instance create call to determine what # to return to the client return_reservation_id = create_kwargs.pop('return_reservation_id', False) requested_networks = None if ('os-networks' in self.extension_info.get_extensions() or utils.is_neutron()): requested_networks = server_dict.get('networks') if requested_networks is not None: requested_networks = self._get_requested_networks( requested_networks) try: flavor_id = self._flavor_id_from_req_data(body) except ValueError as error: msg = _("Invalid flavorRef provided.") raise exc.HTTPBadRequest(explanation=msg) try: inst_type = flavors.get_flavor_by_flavor_id( flavor_id, ctxt=context, read_deleted="no") (instances, resv_id) = self.compute_api.create(context, inst_type, image_uuid, display_name=name, display_description=name, metadata=server_dict.get('metadata', {}), admin_password=password, requested_networks=requested_networks, check_server_group_quota=True, **create_kwargs) except (exception.QuotaError, exception.PortLimitExceeded) as error: raise exc.HTTPForbidden( explanation=error.format_message(), headers={'Retry-After': 0}) except exception.ImageNotFound: msg = _("Can not find requested image") raise exc.HTTPBadRequest(explanation=msg) except exception.FlavorNotFound: msg = _("Invalid flavorRef provided.") raise exc.HTTPBadRequest(explanation=msg) except exception.KeypairNotFound: msg = _("Invalid key_name provided.") raise exc.HTTPBadRequest(explanation=msg) except exception.ConfigDriveInvalidValue: msg = _("Invalid config_drive provided.") raise exc.HTTPBadRequest(explanation=msg) except exception.ExternalNetworkAttachForbidden as error: raise exc.HTTPForbidden(explanation=error.format_message()) except messaging.RemoteError as err: msg = "%(err_type)s: %(err_msg)s" % {'err_type': err.exc_type, 'err_msg': err.value} raise exc.HTTPBadRequest(explanation=msg) except UnicodeDecodeError as error: msg = "UnicodeError: %s" % error raise exc.HTTPBadRequest(explanation=msg) except (exception.ImageNotActive, exception.FlavorDiskTooSmall, exception.FlavorMemoryTooSmall, exception.InvalidMetadata, exception.InvalidRequest, exception.InvalidVolume, exception.MultiplePortsNotApplicable, exception.InvalidFixedIpAndMaxCountRequest, exception.InstanceUserDataMalformed, exception.InstanceUserDataTooLarge, exception.PortNotFound, exception.FixedIpAlreadyInUse, exception.SecurityGroupNotFound, exception.PortRequiresFixedIP, exception.NetworkRequiresSubnet, exception.NetworkNotFound, exception.InvalidBDMVolumeNotBootable, exception.InvalidBDMSnapshot, exception.InvalidBDMVolume, exception.InvalidBDMImage, exception.InvalidBDMBootSequence, exception.InvalidBDMLocalsLimit, exception.InvalidBDMVolumeNotBootable, exception.AutoDiskConfigDisabledByImage, exception.ImageNUMATopologyIncomplete, exception.ImageNUMATopologyForbidden, exception.ImageNUMATopologyAsymmetric, exception.ImageNUMATopologyCPUOutOfRange, exception.ImageNUMATopologyCPUDuplicates, exception.ImageNUMATopologyCPUsUnassigned, exception.ImageNUMATopologyMemoryOutOfRange) as error: raise exc.HTTPBadRequest(explanation=error.format_message()) except (exception.PortInUse, exception.InstanceExists, exception.NetworkAmbiguous, exception.NoUniqueMatch) as error: raise exc.HTTPConflict(explanation=error.format_message()) # If the caller wanted a reservation_id, return it if return_reservation_id: # NOTE(cyeoh): In v3 reservation_id was wrapped in # servers_reservation but this is reverted for V2 API # compatibility. In the long term with the tasks API we # will probably just drop the concept of reservation_id return wsgi.ResponseObject({'reservation_id': resv_id}) req.cache_db_instances(instances) server = self._view_builder.create(req, instances[0]) if CONF.enable_instance_password: server['server']['adminPass'] = password robj = wsgi.ResponseObject(server) return self._add_location(robj) # NOTE(gmann): Parameter 'req_body' is placed to handle scheduler_hint # extension for V2.1. No other extension supposed to use this as # it will be removed soon. def _create_extension_point(self, ext, server_dict, create_kwargs, req_body): handler = ext.obj LOG.debug("Running _create_extension_point for %s", ext.obj) handler.server_create(server_dict, create_kwargs, req_body) def _rebuild_extension_point(self, ext, rebuild_dict, rebuild_kwargs): handler = ext.obj LOG.debug("Running _rebuild_extension_point for %s", ext.obj) handler.server_rebuild(rebuild_dict, rebuild_kwargs) def _resize_extension_point(self, ext, resize_dict, resize_kwargs): handler = ext.obj LOG.debug("Running _resize_extension_point for %s", ext.obj) handler.server_resize(resize_dict, resize_kwargs) def _update_extension_point(self, ext, update_dict, update_kwargs): handler = ext.obj LOG.debug("Running _update_extension_point for %s", ext.obj) handler.server_update(update_dict, update_kwargs) def _create_extension_schema(self, ext, create_schema): handler = ext.obj LOG.debug("Running _create_extension_schema for %s", ext.obj) schema = handler.get_server_create_schema() if ext.obj.name == 'SchedulerHints': # NOTE(oomichi): The request parameter position of scheduler-hint # extension is different from the other extensions, so here handles # the difference. create_schema['properties'].update(schema) else: create_schema['properties']['server']['properties'].update(schema) def _update_extension_schema(self, ext, update_schema): handler = ext.obj LOG.debug("Running _update_extension_schema for %s", ext.obj) schema = handler.get_server_update_schema() update_schema['properties']['server']['properties'].update(schema) def _rebuild_extension_schema(self, ext, rebuild_schema): handler = ext.obj LOG.debug("Running _rebuild_extension_schema for %s", ext.obj) schema = handler.get_server_rebuild_schema() rebuild_schema['properties']['rebuild']['properties'].update(schema) def _resize_extension_schema(self, ext, resize_schema): handler = ext.obj LOG.debug("Running _resize_extension_schema for %s", ext.obj) schema = handler.get_server_resize_schema() resize_schema['properties']['resize']['properties'].update(schema) def _delete(self, context, req, instance_uuid): instance = self._get_server(context, req, instance_uuid) if CONF.reclaim_instance_interval: try: self.compute_api.soft_delete(context, instance) except exception.InstanceInvalidState: # Note(yufang521247): instance which has never been active # is not allowed to be soft_deleted. Thus we have to call # delete() to clean up the instance. self.compute_api.delete(context, instance) else: self.compute_api.delete(context, instance) @extensions.expected_errors((400, 404)) @validation.schema(schema_server_update) def update(self, req, id, body): """Update server then pass on to version-specific controller.""" ctxt = req.environ['nova.context'] update_dict = {} if 'name' in body['server']: update_dict['display_name'] = body['server']['name'] if list(self.update_extension_manager): self.update_extension_manager.map(self._update_extension_point, body['server'], update_dict) instance = common.get_instance(self.compute_api, ctxt, id, want_objects=True, expected_attrs=['pci_devices']) try: # NOTE(mikal): this try block needs to stay because save() still # might throw an exception. req.cache_db_instance(instance) policy.enforce(ctxt, 'compute:update', instance) instance.update(update_dict) instance.save() return self._view_builder.show(req, instance) except exception.InstanceNotFound: msg = _("Instance could not be found") raise exc.HTTPNotFound(explanation=msg) # NOTE(gmann): Returns 204 for backwards compatibility but should be 202 # for representing async API as this API just accepts the request and # request hypervisor driver to complete the same in async mode. @wsgi.response(204) @extensions.expected_errors((400, 404, 409)) @wsgi.action('confirmResize') def _action_confirm_resize(self, req, id, body): context = req.environ['nova.context'] instance = self._get_server(context, req, id) try: self.compute_api.confirm_resize(context, instance) except exception.MigrationNotFound: msg = _("Instance has not been resized.") raise exc.HTTPBadRequest(explanation=msg) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'confirmResize', id) @wsgi.response(202) @extensions.expected_errors((400, 404, 409)) @wsgi.action('revertResize') def _action_revert_resize(self, req, id, body): context = req.environ['nova.context'] instance = self._get_server(context, req, id) try: self.compute_api.revert_resize(context, instance) except exception.MigrationNotFound: msg = _("Instance has not been resized.") raise exc.HTTPBadRequest(explanation=msg) except exception.FlavorNotFound: msg = _("Flavor used by the instance could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'revertResize', id) @wsgi.response(202) @extensions.expected_errors((404, 409)) @wsgi.action('reboot') @validation.schema(schema_servers.reboot) def _action_reboot(self, req, id, body): reboot_type = body['reboot']['type'].upper() context = req.environ['nova.context'] instance = self._get_server(context, req, id) try: self.compute_api.reboot(context, instance, reboot_type) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'reboot', id) def _resize(self, req, instance_id, flavor_id, **kwargs): """Begin the resize process with given instance/flavor.""" context = req.environ["nova.context"] instance = self._get_server(context, req, instance_id) try: self.compute_api.resize(context, instance, flavor_id, **kwargs) except exception.QuotaError as error: raise exc.HTTPForbidden( explanation=error.format_message(), headers={'Retry-After': 0}) except exception.FlavorNotFound: msg = _("Unable to locate requested flavor.") raise exc.HTTPBadRequest(explanation=msg) except exception.CannotResizeToSameFlavor: msg = _("Resize requires a flavor change.") raise exc.HTTPBadRequest(explanation=msg) except (exception.CannotResizeDisk, exception.AutoDiskConfigDisabledByImage) as e: raise exc.HTTPBadRequest(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'resize', instance_id) except exception.ImageNotAuthorized: msg = _("You are not authorized to access the image " "the instance was started with.") raise exc.HTTPUnauthorized(explanation=msg) except exception.ImageNotFound: msg = _("Image that the instance was started " "with could not be found.") raise exc.HTTPBadRequest(explanation=msg) except (exception.NoValidHost, exception.AutoDiskConfigDisabledByImage) as e: raise exc.HTTPBadRequest(explanation=e.format_message()) except exception.Invalid: msg = _("Invalid instance image.") raise exc.HTTPBadRequest(explanation=msg) @wsgi.response(204) @extensions.expected_errors((404, 409)) def delete(self, req, id): """Destroys a server.""" try: self._delete(req.environ['nova.context'], req, id) except exception.InstanceNotFound: msg = _("Instance could not be found") raise exc.HTTPNotFound(explanation=msg) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'delete', id) def _image_uuid_from_href(self, image_href): # If the image href was generated by nova api, strip image_href # down to an id and use the default glance connection params image_uuid = image_href.split('/').pop() if not uuidutils.is_uuid_like(image_uuid): msg = _("Invalid imageRef provided.") raise exc.HTTPBadRequest(explanation=msg) return image_uuid def _image_from_req_data(self, server_dict, create_kwargs): """Get image data from the request or raise appropriate exceptions. The field imageRef is mandatory when no block devices have been defined and must be a proper uuid when present. """ image_href = server_dict.get('imageRef') if not image_href and create_kwargs.get('block_device_mapping'): return '' elif image_href: return self._image_uuid_from_href(unicode(image_href)) else: msg = _("Missing imageRef attribute") raise exc.HTTPBadRequest(explanation=msg) def _flavor_id_from_req_data(self, data): flavor_ref = data['server']['flavorRef'] return common.get_id_from_href(flavor_ref) @wsgi.response(202) @extensions.expected_errors((400, 401, 403, 404, 409)) @wsgi.action('resize') @validation.schema(schema_server_resize) def _action_resize(self, req, id, body): """Resizes a given instance to the flavor size requested.""" resize_dict = body['resize'] flavor_ref = str(resize_dict["flavorRef"]) resize_kwargs = {} if list(self.resize_extension_manager): self.resize_extension_manager.map(self._resize_extension_point, resize_dict, resize_kwargs) self._resize(req, id, flavor_ref, **resize_kwargs) @wsgi.response(202) @extensions.expected_errors((400, 403, 404, 409, 413)) @wsgi.action('rebuild') @validation.schema(schema_server_rebuild) def _action_rebuild(self, req, id, body): """Rebuild an instance with the given attributes.""" rebuild_dict = body['rebuild'] image_href = rebuild_dict["imageRef"] image_href = self._image_uuid_from_href(image_href) password = self._get_server_admin_password(rebuild_dict) context = req.environ['nova.context'] instance = self._get_server(context, req, id) attr_map = { 'name': 'display_name', 'metadata': 'metadata', } rebuild_kwargs = {} if list(self.rebuild_extension_manager): self.rebuild_extension_manager.map(self._rebuild_extension_point, rebuild_dict, rebuild_kwargs) for request_attribute, instance_attribute in attr_map.items(): try: rebuild_kwargs[instance_attribute] = rebuild_dict[ request_attribute] except (KeyError, TypeError): pass try: self.compute_api.rebuild(context, instance, image_href, password, **rebuild_kwargs) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'rebuild', id) except exception.InstanceNotFound: msg = _("Instance could not be found") raise exc.HTTPNotFound(explanation=msg) except exception.ImageNotFound: msg = _("Cannot find image for rebuild") raise exc.HTTPBadRequest(explanation=msg) except exception.QuotaError as error: raise exc.HTTPForbidden(explanation=error.format_message()) except (exception.ImageNotActive, exception.FlavorDiskTooSmall, exception.FlavorMemoryTooSmall, exception.InvalidMetadata, exception.AutoDiskConfigDisabledByImage) as error: raise exc.HTTPBadRequest(explanation=error.format_message()) instance = self._get_server(context, req, id) view = self._view_builder.show(req, instance) # Add on the admin_password attribute since the view doesn't do it # unless instance passwords are disabled if CONF.enable_instance_password: view['server']['adminPass'] = password robj = wsgi.ResponseObject(view) return self._add_location(robj) @wsgi.response(202) @extensions.expected_errors((400, 403, 404, 409)) @wsgi.action('createImage') @common.check_snapshots_enabled @validation.schema(schema_servers.create_image) def _action_create_image(self, req, id, body): """Snapshot a server instance.""" context = req.environ['nova.context'] entity = body["createImage"] image_name = entity["name"] metadata = entity.get('metadata', {}) common.check_img_metadata_properties_quota(context, metadata) instance = self._get_server(context, req, id) bdms = objects.BlockDeviceMappingList.get_by_instance_uuid( context, instance.uuid) try: if self.compute_api.is_volume_backed_instance(context, instance, bdms): img = instance.image_ref if not img: properties = bdms.root_metadata( context, self.compute_api.image_api, self.compute_api.volume_api) image_meta = {'properties': properties} else: image_meta = self.compute_api.image_api.get(context, img) image = self.compute_api.snapshot_volume_backed( context, instance, image_meta, image_name, extra_properties= metadata) else: image = self.compute_api.snapshot(context, instance, image_name, extra_properties=metadata) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'createImage', id) except exception.Invalid as err: raise exc.HTTPBadRequest(explanation=err.format_message()) # build location of newly-created image entity image_id = str(image['id']) image_ref = glance.generate_image_url(image_id) resp = webob.Response(status_int=202) resp.headers['Location'] = image_ref return resp def _get_server_admin_password(self, server): """Determine the admin password for a server on creation.""" try: password = server['adminPass'] except KeyError: password = utils.generate_password() return password def _get_server_search_options(self): """Return server search options allowed by non-admin.""" return ('reservation_id', 'name', 'status', 'image', 'flavor', 'ip', 'changes-since', 'all_tenants') def _get_instance(self, context, instance_uuid): try: attrs = ['system_metadata', 'metadata'] return objects.Instance.get_by_uuid(context, instance_uuid, expected_attrs=attrs) except exception.InstanceNotFound as e: raise webob.exc.HTTPNotFound(explanation=e.format_message()) @wsgi.response(202) @extensions.expected_errors((404, 409)) @wsgi.action('os-start') def _start_server(self, req, id, body): """Start an instance.""" context = req.environ['nova.context'] instance = self._get_instance(context, id) authorizer(context, instance, 'start') LOG.debug('start instance', instance=instance) try: self.compute_api.start(context, instance) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'start', id) except (exception.InstanceNotReady, exception.InstanceIsLocked) as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) @wsgi.response(202) @extensions.expected_errors((404, 409)) @wsgi.action('os-stop') def _stop_server(self, req, id, body): """Stop an instance.""" context = req.environ['nova.context'] instance = self._get_instance(context, id) authorizer(context, instance, 'stop') LOG.debug('stop instance', instance=instance) try: self.compute_api.stop(context, instance) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'stop', id) except (exception.InstanceNotReady, exception.InstanceIsLocked) as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) def remove_invalid_options(context, search_options, allowed_search_options): """Remove search options that are not valid for non-admin API/context.""" if context.is_admin: # Allow all options return # Otherwise, strip out all unknown options unknown_options = [opt for opt in search_options if opt not in allowed_search_options] LOG.debug("Removing options '%s' from query", ", ".join(unknown_options)) for opt in unknown_options: search_options.pop(opt, None) class Servers(extensions.V3APIExtensionBase): """Servers.""" name = "Servers" alias = ALIAS version = 1 def get_resources(self): member_actions = {'action': 'POST'} collection_actions = {'detail': 'GET'} resources = [ extensions.ResourceExtension( ALIAS, ServersController(extension_info=self.extension_info), member_name='server', collection_actions=collection_actions, member_actions=member_actions)] return resources def get_controller_extensions(self): return []
apache-2.0
[ 3, 1898, 7129, 14260, 2752, 199, 3, 1898, 7760, 510, 631, 265, 8142, 27799, 12, 3277, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 1300, 772, 199, 646, 295, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 646, 11258, 63, 27782, 465, 30429, 199, 504, 11258, 63, 1208, 492, 620, 1208, 199, 504, 11258, 63, 1208, 492, 23011, 199, 646, 3816, 199, 646, 20345, 1354, 720, 199, 646, 14568, 199, 504, 14568, 492, 3178, 199, 199, 504, 5913, 14, 1246, 14, 8512, 492, 2863, 199, 504, 5913, 14, 1246, 14, 8512, 14, 3357, 14, 9482, 14, 86, 19, 492, 8037, 465, 4177, 63, 5871, 199, 504, 5913, 14, 1246, 14, 8512, 14, 3357, 14, 4196, 492, 8037, 465, 6858, 63, 5871, 199, 504, 5913, 14, 1246, 14, 8512, 492, 5478, 199, 504, 5913, 14, 1246, 14, 8512, 492, 12464, 199, 504, 5913, 14, 1246, 492, 6411, 199, 504, 5913, 492, 4526, 199, 504, 5913, 14, 3357, 492, 23547, 199, 504, 5913, 492, 1919, 199, 504, 5913, 14, 73, 1085, 78, 492, 485, 199, 504, 5913, 14, 73, 1085, 78, 492, 485, 20145, 199, 504, 5913, 14, 1569, 492, 21785, 199, 504, 5913, 492, 2251, 199, 504, 5913, 14, 8512, 14, 2330, 492, 5377, 1208, 199, 504, 5913, 492, 4592, 199, 504, 5913, 492, 3778, 199, 199, 12644, 275, 283, 5871, 7, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 646, 63, 2992, 360, 4296, 63, 842, 63, 2060, 297, 355, 283, 6765, 14, 1246, 14, 8512, 14, 3357, 14, 5871, 358, 199, 3103, 14, 646, 63, 2992, 360, 1200, 63, 1246, 63, 533, 297, 283, 6765, 14, 1200, 358, 199, 3103, 14, 646, 63, 2992, 360, 2761, 416, 1017, 63, 842, 63, 4284, 297, 283, 6765, 14, 3357, 14, 2609, 358, 199, 3103, 14, 646, 63, 2992, 360, 5359, 63, 22126, 297, 283, 6765, 14, 1246, 14, 8512, 297, 1572, 534, 736, 1246, 63, 86, 19, 358, 199, 3103, 14, 646, 63, 2992, 360, 5359, 63, 14189, 297, 283, 6765, 14, 1246, 14, 8512, 297, 1572, 534, 736, 1246, 63, 86, 19, 358, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 2502, 1793, 275, 5478, 14, 1018, 63, 2502, 1793, 360, 3357, 26, 86, 19, 297, 283, 5871, 358, 421, 199, 533, 7146, 83, 7506, 8, 6508, 14, 7506, 304, 272, 408, 1918, 7146, 3261, 1300, 7614, 1021, 367, 314, 14260, 3261, 1041, 339, 20203, 742, 3579, 63, 8366, 63, 13001, 275, 283, 6765, 14, 1246, 14, 86, 19, 14, 5359, 14, 1000, 14, 981, 7, 272, 20203, 742, 3579, 63, 4448, 540, 4938, 11025, 63, 30335, 63, 6613, 63, 13001, 275, 334, 267, 283, 6765, 14, 1246, 14, 86, 19, 14, 5359, 14, 1000, 14, 981, 14, 11143, 358, 339, 20203, 742, 3579, 63, 907, 8248, 63, 13001, 275, 283, 6765, 14, 1246, 14, 86, 19, 14, 5359, 14, 1000, 14, 19278, 7, 272, 20203, 742, 3579, 63, 4448, 540, 4938, 11025, 63, 30335, 63, 907, 8248, 63, 13001, 275, 334, 267, 283, 6765, 14, 1246, 14, 86, 19, 14, 5359, 14, 1000, 14, 19278, 14, 11143, 358, 339, 20203, 742, 3579, 63, 10383, 63, 13001, 275, 283, 6765, 14, 1246, 14, 86, 19, 14, 5359, 14, 1000, 14, 873, 7, 339, 20203, 742, 3579, 63, 3830, 11025, 63, 13001, 275, 283, 6765, 14, 1246, 14, 86, 19, 14, 5359, 14, 1000, 14, 8709, 7, 339, 485, 1345, 63, 5649, 63, 533, 275, 6858, 63, 5871, 14, 2768, 6437, 54, 19, 339, 4177, 63, 1000, 63, 981, 275, 4177, 63, 5871, 14, 1095, 63, 981, 272, 4177, 63, 1000, 63, 873, 275, 4177, 63, 5871, 14, 1095, 63, 873, 272, 4177, 63, 1000, 63, 19278, 275, 4177, 63, 5871, 14, 1095, 63, 19278, 272, 4177, 63, 1000, 63, 8709, 275, 4177, 63, 5871, 14, 1095, 63, 8709, 339, 768, 4639, 272, 347, 485, 525, 63, 1985, 8, 25327, 304, 267, 327, 13870, 315, 1930, 1396, 267, 340, 283, 1000, 7, 440, 315, 882, 468, 14, 1113, 26, 288, 372, 882, 468, 398, 2142, 275, 2457, 8, 2734, 634, 26, 634, 459, 3369, 418, 508, 283, 277, 297, 1993, 882, 468, 14, 1113, 459, 1000, 2545, 4614, 1105, 267, 340, 2142, 26, 288, 882, 468, 459, 6592, 418, 275, 3778, 14, 1624, 24, 8, 1073, 59, 16, 2733, 6399, 1105, 398, 327, 1448, 23329, 372, 267, 372, 882, 468, 339, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 347, 485, 1074, 63, 912, 63, 3435, 8, 2427, 63, 1593, 304, 953, 347, 1104, 63, 7510, 8399, 63, 6717, 8, 832, 304, 355, 327, 2670, 22671, 365, 1902, 2701, 503, 340, 440, 2066, 314, 3329, 355, 327, 365, 315, 314, 22671, 355, 340, 334, 1397, 6392, 14, 736, 1246, 63, 86, 19, 14, 5359, 63, 14189, 503, 717, 1599, 14, 1113, 14, 3620, 315, 6392, 14, 736, 1246, 63, 86, 19, 14, 5359, 63, 14189, 304, 4951, 327, 2670, 314, 3329, 365, 440, 315, 314, 23180, 490, 340, 1599, 14, 1113, 14, 3620, 440, 315, 6392, 14, 736, 1246, 63, 86, 19, 14, 5359, 63, 22126, 26, 717, 372, 715, 490, 587, 26, 717, 5051, 14, 3764, 1547, 20145, 480, 1763, 8697, 450, 83, 2952, 652, 365, 298, 3147, 298, 262, 314, 23180, 1288, 1599, 14, 1113, 14 ]
[ 1898, 7129, 14260, 2752, 199, 3, 1898, 7760, 510, 631, 265, 8142, 27799, 12, 3277, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 1300, 772, 199, 646, 295, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 646, 11258, 63, 27782, 465, 30429, 199, 504, 11258, 63, 1208, 492, 620, 1208, 199, 504, 11258, 63, 1208, 492, 23011, 199, 646, 3816, 199, 646, 20345, 1354, 720, 199, 646, 14568, 199, 504, 14568, 492, 3178, 199, 199, 504, 5913, 14, 1246, 14, 8512, 492, 2863, 199, 504, 5913, 14, 1246, 14, 8512, 14, 3357, 14, 9482, 14, 86, 19, 492, 8037, 465, 4177, 63, 5871, 199, 504, 5913, 14, 1246, 14, 8512, 14, 3357, 14, 4196, 492, 8037, 465, 6858, 63, 5871, 199, 504, 5913, 14, 1246, 14, 8512, 492, 5478, 199, 504, 5913, 14, 1246, 14, 8512, 492, 12464, 199, 504, 5913, 14, 1246, 492, 6411, 199, 504, 5913, 492, 4526, 199, 504, 5913, 14, 3357, 492, 23547, 199, 504, 5913, 492, 1919, 199, 504, 5913, 14, 73, 1085, 78, 492, 485, 199, 504, 5913, 14, 73, 1085, 78, 492, 485, 20145, 199, 504, 5913, 14, 1569, 492, 21785, 199, 504, 5913, 492, 2251, 199, 504, 5913, 14, 8512, 14, 2330, 492, 5377, 1208, 199, 504, 5913, 492, 4592, 199, 504, 5913, 492, 3778, 199, 199, 12644, 275, 283, 5871, 7, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 646, 63, 2992, 360, 4296, 63, 842, 63, 2060, 297, 355, 283, 6765, 14, 1246, 14, 8512, 14, 3357, 14, 5871, 358, 199, 3103, 14, 646, 63, 2992, 360, 1200, 63, 1246, 63, 533, 297, 283, 6765, 14, 1200, 358, 199, 3103, 14, 646, 63, 2992, 360, 2761, 416, 1017, 63, 842, 63, 4284, 297, 283, 6765, 14, 3357, 14, 2609, 358, 199, 3103, 14, 646, 63, 2992, 360, 5359, 63, 22126, 297, 283, 6765, 14, 1246, 14, 8512, 297, 1572, 534, 736, 1246, 63, 86, 19, 358, 199, 3103, 14, 646, 63, 2992, 360, 5359, 63, 14189, 297, 283, 6765, 14, 1246, 14, 8512, 297, 1572, 534, 736, 1246, 63, 86, 19, 358, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 2502, 1793, 275, 5478, 14, 1018, 63, 2502, 1793, 360, 3357, 26, 86, 19, 297, 283, 5871, 358, 421, 199, 533, 7146, 83, 7506, 8, 6508, 14, 7506, 304, 272, 408, 1918, 7146, 3261, 1300, 7614, 1021, 367, 314, 14260, 3261, 1041, 339, 20203, 742, 3579, 63, 8366, 63, 13001, 275, 283, 6765, 14, 1246, 14, 86, 19, 14, 5359, 14, 1000, 14, 981, 7, 272, 20203, 742, 3579, 63, 4448, 540, 4938, 11025, 63, 30335, 63, 6613, 63, 13001, 275, 334, 267, 283, 6765, 14, 1246, 14, 86, 19, 14, 5359, 14, 1000, 14, 981, 14, 11143, 358, 339, 20203, 742, 3579, 63, 907, 8248, 63, 13001, 275, 283, 6765, 14, 1246, 14, 86, 19, 14, 5359, 14, 1000, 14, 19278, 7, 272, 20203, 742, 3579, 63, 4448, 540, 4938, 11025, 63, 30335, 63, 907, 8248, 63, 13001, 275, 334, 267, 283, 6765, 14, 1246, 14, 86, 19, 14, 5359, 14, 1000, 14, 19278, 14, 11143, 358, 339, 20203, 742, 3579, 63, 10383, 63, 13001, 275, 283, 6765, 14, 1246, 14, 86, 19, 14, 5359, 14, 1000, 14, 873, 7, 339, 20203, 742, 3579, 63, 3830, 11025, 63, 13001, 275, 283, 6765, 14, 1246, 14, 86, 19, 14, 5359, 14, 1000, 14, 8709, 7, 339, 485, 1345, 63, 5649, 63, 533, 275, 6858, 63, 5871, 14, 2768, 6437, 54, 19, 339, 4177, 63, 1000, 63, 981, 275, 4177, 63, 5871, 14, 1095, 63, 981, 272, 4177, 63, 1000, 63, 873, 275, 4177, 63, 5871, 14, 1095, 63, 873, 272, 4177, 63, 1000, 63, 19278, 275, 4177, 63, 5871, 14, 1095, 63, 19278, 272, 4177, 63, 1000, 63, 8709, 275, 4177, 63, 5871, 14, 1095, 63, 8709, 339, 768, 4639, 272, 347, 485, 525, 63, 1985, 8, 25327, 304, 267, 327, 13870, 315, 1930, 1396, 267, 340, 283, 1000, 7, 440, 315, 882, 468, 14, 1113, 26, 288, 372, 882, 468, 398, 2142, 275, 2457, 8, 2734, 634, 26, 634, 459, 3369, 418, 508, 283, 277, 297, 1993, 882, 468, 14, 1113, 459, 1000, 2545, 4614, 1105, 267, 340, 2142, 26, 288, 882, 468, 459, 6592, 418, 275, 3778, 14, 1624, 24, 8, 1073, 59, 16, 2733, 6399, 1105, 398, 327, 1448, 23329, 372, 267, 372, 882, 468, 339, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 347, 485, 1074, 63, 912, 63, 3435, 8, 2427, 63, 1593, 304, 953, 347, 1104, 63, 7510, 8399, 63, 6717, 8, 832, 304, 355, 327, 2670, 22671, 365, 1902, 2701, 503, 340, 440, 2066, 314, 3329, 355, 327, 365, 315, 314, 22671, 355, 340, 334, 1397, 6392, 14, 736, 1246, 63, 86, 19, 14, 5359, 63, 14189, 503, 717, 1599, 14, 1113, 14, 3620, 315, 6392, 14, 736, 1246, 63, 86, 19, 14, 5359, 63, 14189, 304, 4951, 327, 2670, 314, 3329, 365, 440, 315, 314, 23180, 490, 340, 1599, 14, 1113, 14, 3620, 440, 315, 6392, 14, 736, 1246, 63, 86, 19, 14, 5359, 63, 22126, 26, 717, 372, 715, 490, 587, 26, 717, 5051, 14, 3764, 1547, 20145, 480, 1763, 8697, 450, 83, 2952, 652, 365, 298, 3147, 298, 262, 314, 23180, 1288, 1599, 14, 1113, 14, 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, 1, 1 ]
zyantific/IDASkins
plugins/idaskins/themeselector.py
1
3976
from __future__ import absolute_import, division, print_function import json import os import idaapi from idaskins import THEMES_DIR, UI_DIR from idaskins.objectinspector import ObjectInspector from idaskins.thememanifest import ManifestError, ThemeManifest from PyQt5 import uic from PyQt5.QtCore import Qt from PyQt5.Qt import qApp from PyQt5.QtGui import QPixmap from PyQt5.QtWidgets import QDialog, QFileSystemModel Ui_ThemeSelector, ThemeSelectorBase = uic.loadUiType( os.path.join(UI_DIR, 'ThemeSelector.ui') ) class ThemeSelector(ThemeSelectorBase): """Theme selector dialog. Pick your poison.""" def __init__(self, *args, **kwargs): super(ThemeSelector, self).__init__(*args, **kwargs) self.setModal(False) self._theme_list = [] self._preview_pixmap = None self._obj_inspector = None self._ui = Ui_ThemeSelector() self._ui.setupUi(self) self._ui.lwSkinSelection.itemSelectionChanged.connect( self.theme_selected ) self._ui.btnObjectInspector.clicked.connect( self.open_object_inspector ) self._ui.btnCopyClr.clicked.connect( self.on_copy_clr_clicked ) self.refresh() def refresh(self): # Load manifests for all themes. try: self._theme_list = [ ( x, ThemeManifest(open( os.path.join(THEMES_DIR, x, 'manifest.json') ), )) for x in os.listdir(THEMES_DIR) if os.path.isdir(os.path.join(THEMES_DIR, x)) ] except ManifestError as exc: print("Bad manifest:", str(exc)) # Populate theme list. self._ui.lwSkinSelection.clear() for _, manifest in self._theme_list: self._ui.lwSkinSelection.addItem(manifest.theme_name) self._ui.lwSkinSelection.setCurrentIndex( self._ui.lwSkinSelection.rootIndex() ) def theme_selected(self): theme_dir, manifest = self._get_selected() abs_theme_dir = os.path.join(THEMES_DIR, theme_dir) self._ui.lblAuthorVal.setText(manifest.author) self._ui.lblVersionVal.setText(manifest.version) self._ui.lblNotesVal.setText(manifest.notes) self._ui.leClrPathVal.setText( os.path.join(abs_theme_dir, manifest.clr_file) if manifest.clr_file else None ) if manifest.preview_image: abs_path = os.path.join(abs_theme_dir, manifest.preview_image) self._preview_pixmap = QPixmap(abs_path) self.update_preview() else: self._ui.lblPreview.setText('no preview available') def _get_selected(self): sel_model = self._ui.lwSkinSelection.selectionModel() sel_indices = sel_model.selectedIndexes() if sel_indices: return self._theme_list[sel_indices[0].row()] else: return None, None def on_copy_clr_clicked(self): _, manifest = self._get_selected() if not manifest.clr_file: return qApp.clipboard().setText(self._ui.leClrPathVal.text()) def update_preview(self): if not self._preview_pixmap: return scaled = self._preview_pixmap.scaled( self._ui.lblPreview.width(), self._ui.lblPreview.height(), Qt.KeepAspectRatio, Qt.SmoothTransformation, ) self._ui.lblPreview.setPixmap(scaled) def open_object_inspector(self): self._obj_inspector = ObjectInspector() self._obj_inspector.show() def resizeEvent(self, *args, **kwargs): super(ThemeSelector, self).resizeEvent(*args, **kwargs) self.update_preview() @property def selected_theme_dir(self): theme_dir, _ = self._get_selected() return theme_dir
mit
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 199, 646, 2022, 199, 646, 747, 199, 199, 646, 284, 983, 1246, 199, 504, 1305, 813, 3617, 492, 2334, 22076, 63, 3022, 12, 14041, 63, 3022, 199, 504, 1305, 813, 3617, 14, 785, 26047, 492, 6935, 13962, 15152, 199, 504, 1305, 813, 3617, 14, 7915, 6418, 492, 4688, 3944, 547, 12, 23978, 11038, 199, 504, 14084, 21, 492, 399, 530, 199, 504, 14084, 21, 14, 10901, 492, 3959, 199, 504, 14084, 21, 14, 4238, 492, 1894, 2640, 199, 504, 14084, 21, 14, 10604, 492, 1413, 16049, 199, 504, 14084, 21, 14, 29081, 492, 1413, 5619, 12, 1413, 17521, 1685, 199, 199, 18203, 63, 16849, 11212, 12, 23978, 11212, 1563, 275, 399, 530, 14, 912, 18203, 804, 8, 272, 747, 14, 515, 14, 904, 8, 6379, 63, 3022, 12, 283, 16849, 11212, 14, 1907, 358, 199, 9, 421, 199, 533, 23978, 11212, 8, 16849, 11212, 1563, 304, 272, 408, 16849, 9759, 9592, 14, 16568, 2195, 1115, 28287, 1041, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 16849, 11212, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 409, 23689, 8, 797, 9, 398, 291, 423, 7915, 63, 513, 275, 942, 267, 291, 423, 7780, 63, 6644, 1130, 275, 488, 267, 291, 423, 1113, 63, 26047, 275, 488, 398, 291, 423, 1907, 275, 32471, 63, 16849, 11212, 342, 267, 291, 423, 1907, 14, 2758, 18203, 8, 277, 9, 267, 291, 423, 1907, 14, 20692, 14194, 262, 7713, 14, 1053, 7713, 6970, 14, 2242, 8, 288, 291, 14, 7915, 63, 5511, 267, 776, 267, 291, 423, 1907, 14, 9633, 1692, 13962, 15152, 14, 11276, 14, 2242, 8, 288, 291, 14, 1490, 63, 785, 63, 26047, 267, 776, 267, 291, 423, 1907, 14, 9633, 5116, 1968, 82, 14, 11276, 14, 2242, 8, 288, 291, 14, 265, 63, 1574, 63, 31553, 63, 11276, 267, 776, 398, 291, 14, 6635, 342, 339, 347, 9236, 8, 277, 304, 267, 327, 7190, 7712, 83, 367, 1006, 17915, 14, 267, 862, 26, 288, 291, 423, 7915, 63, 513, 275, 359, 355, 334, 490, 671, 12, 490, 23978, 11038, 8, 1490, 8, 717, 747, 14, 515, 14, 904, 8, 18061, 22076, 63, 3022, 12, 671, 12, 283, 6418, 14, 1001, 358, 490, 2318, 355, 5082, 355, 367, 671, 315, 747, 14, 7374, 8, 18061, 22076, 63, 3022, 9, 355, 340, 747, 14, 515, 14, 6027, 8, 736, 14, 515, 14, 904, 8, 18061, 22076, 63, 3022, 12, 671, 430, 288, 1622, 267, 871, 4688, 3944, 547, 465, 3178, 26, 288, 870, 480, 5725, 7712, 6783, 620, 8, 2804, 430, 398, 327, 31731, 8879, 769, 14, 267, 291, 423, 1907, 14, 20692, 14194, 262, 7713, 14, 3584, 342, 267, 367, 5501, 7712, 315, 291, 423, 7915, 63, 513, 26, 288, 291, 423, 1907, 14, 20692, 14194, 262, 7713, 14, 19798, 8, 6418, 14, 7915, 63, 354, 9, 398, 291, 423, 1907, 14, 20692, 14194, 262, 7713, 14, 31549, 8, 288, 291, 423, 1907, 14, 20692, 14194, 262, 7713, 14, 1231, 2681, 342, 267, 776, 339, 347, 8879, 63, 5511, 8, 277, 304, 267, 8879, 63, 694, 12, 7712, 275, 291, 423, 362, 63, 5511, 342, 267, 2853, 63, 7915, 63, 694, 275, 747, 14, 515, 14, 904, 8, 18061, 22076, 63, 3022, 12, 8879, 63, 694, 9, 398, 291, 423, 1907, 14, 18842, 5949, 7562, 14, 8341, 8, 6418, 14, 2502, 9, 267, 291, 423, 1907, 14, 18842, 3353, 7562, 14, 8341, 8, 6418, 14, 1023, 9, 267, 291, 423, 1907, 14, 18842, 18685, 7562, 14, 8341, 8, 6418, 14, 5983, 9, 267, 291, 423, 1907, 14, 274, 1968, 82, 2042, 7562, 14, 8341, 8, 288, 747, 14, 515, 14, 904, 8, 2101, 63, 7915, 63, 694, 12, 7712, 14, 31553, 63, 493, 9, 288, 340, 7712, 14, 31553, 63, 493, 587, 288, 488, 267, 776, 398, 340, 7712, 14, 7780, 63, 1569, 26, 288, 2853, 63, 515, 275, 747, 14, 515, 14, 904, 8, 2101, 63, 7915, 63, 694, 12, 7712, 14, 7780, 63, 1569, 9, 288, 291, 423, 7780, 63, 6644, 1130, 275, 1413, 16049, 8, 2101, 63, 515, 9, 288, 291, 14, 873, 63, 7780, 342, 267, 587, 26, 288, 291, 423, 1907, 14, 18842, 27116, 14, 8341, 360, 889, 19653, 2808, 358, 339, 347, 485, 362, 63, 5511, 8, 277, 304, 267, 13680, 63, 1238, 275, 291, 423, 1907, 14, 20692, 14194, 262, 7713, 14, 5592, 1685, 342, 267, 13680, 63, 4108, 275, 13680, 63, 1238, 14, 5511, 2681, 397, 342, 267, 340, 13680, 63, 4108, 26, 288, 372, 291, 423, 7915, 63, 513, 59, 5891, 63, 4108, 59, 16, 1055, 1143, 5106, 267, 587, 26, 288, 372, 488, 12, 488, 339, 347, 641, 63, 1574, 63, 31553, 63, 11276, 8, 277, 304, 267, 5501, 7712, 275, 291, 423, 362, 63, 5511, 342, 267, 340, 440, 7712, 14, 31553, 63, 493, 26, 288, 372, 267, 1894, 2640, 14, 7548, 3576, 1252, 8341, 8, 277, 423, 1907, 14, 274, 1968, 82, 2042, 7562, 14, 505, 1012, 339, 347, 1678, 63, 7780, 8, 277, 304, 267, 340, 440, 291, 423, 7780, 63, 6644, 1130, 26, 288, 372, 398, 17923, 275, 291, 423, 7780, 63, 6644, 1130, 14, 15120, 8, 288, 291, 423, 1907, 14, 18842, 27116, 14, 2063, 1062, 288, 291, 423, 1907, 14, 18842, 27116, 14, 3333, 1062, 288, 3959, 14, 18567, 2822, 1764, 13971, 12, 288, 3959, 14, 51, 11607, 26283, 12, 267, 776, 267, 291, 423, 1907, 14, 18842, 27116, 14, 409, 16049, 8, 15120, 9, 339, 347, 1551, 63, 785, 63, 26047, 8, 277, 304, 267, 291, 423, 1113, 63, 26047, 275, 6935, 13962, 15152, 342, 267, 291, 423, 1113, 63, 26047, 14, 2384, 342, 339, 347, 15210, 2390, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 16849, 11212, 12, 291, 680, 8709, 2390, 2031, 589, 12, 1011, 958, 9, 267, 291, 14, 873, 63, 7780, 342, 339, 768, 1829, 272, 347, 4895, 63, 7915, 63, 694, 8, 277, 304, 267, 8879, 63, 694, 12, 485, 275, 291, 423, 362, 63, 5511, 342, 267, 372, 8879, 63, 694 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 199, 646, 2022, 199, 646, 747, 199, 199, 646, 284, 983, 1246, 199, 504, 1305, 813, 3617, 492, 2334, 22076, 63, 3022, 12, 14041, 63, 3022, 199, 504, 1305, 813, 3617, 14, 785, 26047, 492, 6935, 13962, 15152, 199, 504, 1305, 813, 3617, 14, 7915, 6418, 492, 4688, 3944, 547, 12, 23978, 11038, 199, 504, 14084, 21, 492, 399, 530, 199, 504, 14084, 21, 14, 10901, 492, 3959, 199, 504, 14084, 21, 14, 4238, 492, 1894, 2640, 199, 504, 14084, 21, 14, 10604, 492, 1413, 16049, 199, 504, 14084, 21, 14, 29081, 492, 1413, 5619, 12, 1413, 17521, 1685, 199, 199, 18203, 63, 16849, 11212, 12, 23978, 11212, 1563, 275, 399, 530, 14, 912, 18203, 804, 8, 272, 747, 14, 515, 14, 904, 8, 6379, 63, 3022, 12, 283, 16849, 11212, 14, 1907, 358, 199, 9, 421, 199, 533, 23978, 11212, 8, 16849, 11212, 1563, 304, 272, 408, 16849, 9759, 9592, 14, 16568, 2195, 1115, 28287, 1041, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 16849, 11212, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 409, 23689, 8, 797, 9, 398, 291, 423, 7915, 63, 513, 275, 942, 267, 291, 423, 7780, 63, 6644, 1130, 275, 488, 267, 291, 423, 1113, 63, 26047, 275, 488, 398, 291, 423, 1907, 275, 32471, 63, 16849, 11212, 342, 267, 291, 423, 1907, 14, 2758, 18203, 8, 277, 9, 267, 291, 423, 1907, 14, 20692, 14194, 262, 7713, 14, 1053, 7713, 6970, 14, 2242, 8, 288, 291, 14, 7915, 63, 5511, 267, 776, 267, 291, 423, 1907, 14, 9633, 1692, 13962, 15152, 14, 11276, 14, 2242, 8, 288, 291, 14, 1490, 63, 785, 63, 26047, 267, 776, 267, 291, 423, 1907, 14, 9633, 5116, 1968, 82, 14, 11276, 14, 2242, 8, 288, 291, 14, 265, 63, 1574, 63, 31553, 63, 11276, 267, 776, 398, 291, 14, 6635, 342, 339, 347, 9236, 8, 277, 304, 267, 327, 7190, 7712, 83, 367, 1006, 17915, 14, 267, 862, 26, 288, 291, 423, 7915, 63, 513, 275, 359, 355, 334, 490, 671, 12, 490, 23978, 11038, 8, 1490, 8, 717, 747, 14, 515, 14, 904, 8, 18061, 22076, 63, 3022, 12, 671, 12, 283, 6418, 14, 1001, 358, 490, 2318, 355, 5082, 355, 367, 671, 315, 747, 14, 7374, 8, 18061, 22076, 63, 3022, 9, 355, 340, 747, 14, 515, 14, 6027, 8, 736, 14, 515, 14, 904, 8, 18061, 22076, 63, 3022, 12, 671, 430, 288, 1622, 267, 871, 4688, 3944, 547, 465, 3178, 26, 288, 870, 480, 5725, 7712, 6783, 620, 8, 2804, 430, 398, 327, 31731, 8879, 769, 14, 267, 291, 423, 1907, 14, 20692, 14194, 262, 7713, 14, 3584, 342, 267, 367, 5501, 7712, 315, 291, 423, 7915, 63, 513, 26, 288, 291, 423, 1907, 14, 20692, 14194, 262, 7713, 14, 19798, 8, 6418, 14, 7915, 63, 354, 9, 398, 291, 423, 1907, 14, 20692, 14194, 262, 7713, 14, 31549, 8, 288, 291, 423, 1907, 14, 20692, 14194, 262, 7713, 14, 1231, 2681, 342, 267, 776, 339, 347, 8879, 63, 5511, 8, 277, 304, 267, 8879, 63, 694, 12, 7712, 275, 291, 423, 362, 63, 5511, 342, 267, 2853, 63, 7915, 63, 694, 275, 747, 14, 515, 14, 904, 8, 18061, 22076, 63, 3022, 12, 8879, 63, 694, 9, 398, 291, 423, 1907, 14, 18842, 5949, 7562, 14, 8341, 8, 6418, 14, 2502, 9, 267, 291, 423, 1907, 14, 18842, 3353, 7562, 14, 8341, 8, 6418, 14, 1023, 9, 267, 291, 423, 1907, 14, 18842, 18685, 7562, 14, 8341, 8, 6418, 14, 5983, 9, 267, 291, 423, 1907, 14, 274, 1968, 82, 2042, 7562, 14, 8341, 8, 288, 747, 14, 515, 14, 904, 8, 2101, 63, 7915, 63, 694, 12, 7712, 14, 31553, 63, 493, 9, 288, 340, 7712, 14, 31553, 63, 493, 587, 288, 488, 267, 776, 398, 340, 7712, 14, 7780, 63, 1569, 26, 288, 2853, 63, 515, 275, 747, 14, 515, 14, 904, 8, 2101, 63, 7915, 63, 694, 12, 7712, 14, 7780, 63, 1569, 9, 288, 291, 423, 7780, 63, 6644, 1130, 275, 1413, 16049, 8, 2101, 63, 515, 9, 288, 291, 14, 873, 63, 7780, 342, 267, 587, 26, 288, 291, 423, 1907, 14, 18842, 27116, 14, 8341, 360, 889, 19653, 2808, 358, 339, 347, 485, 362, 63, 5511, 8, 277, 304, 267, 13680, 63, 1238, 275, 291, 423, 1907, 14, 20692, 14194, 262, 7713, 14, 5592, 1685, 342, 267, 13680, 63, 4108, 275, 13680, 63, 1238, 14, 5511, 2681, 397, 342, 267, 340, 13680, 63, 4108, 26, 288, 372, 291, 423, 7915, 63, 513, 59, 5891, 63, 4108, 59, 16, 1055, 1143, 5106, 267, 587, 26, 288, 372, 488, 12, 488, 339, 347, 641, 63, 1574, 63, 31553, 63, 11276, 8, 277, 304, 267, 5501, 7712, 275, 291, 423, 362, 63, 5511, 342, 267, 340, 440, 7712, 14, 31553, 63, 493, 26, 288, 372, 267, 1894, 2640, 14, 7548, 3576, 1252, 8341, 8, 277, 423, 1907, 14, 274, 1968, 82, 2042, 7562, 14, 505, 1012, 339, 347, 1678, 63, 7780, 8, 277, 304, 267, 340, 440, 291, 423, 7780, 63, 6644, 1130, 26, 288, 372, 398, 17923, 275, 291, 423, 7780, 63, 6644, 1130, 14, 15120, 8, 288, 291, 423, 1907, 14, 18842, 27116, 14, 2063, 1062, 288, 291, 423, 1907, 14, 18842, 27116, 14, 3333, 1062, 288, 3959, 14, 18567, 2822, 1764, 13971, 12, 288, 3959, 14, 51, 11607, 26283, 12, 267, 776, 267, 291, 423, 1907, 14, 18842, 27116, 14, 409, 16049, 8, 15120, 9, 339, 347, 1551, 63, 785, 63, 26047, 8, 277, 304, 267, 291, 423, 1113, 63, 26047, 275, 6935, 13962, 15152, 342, 267, 291, 423, 1113, 63, 26047, 14, 2384, 342, 339, 347, 15210, 2390, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 16849, 11212, 12, 291, 680, 8709, 2390, 2031, 589, 12, 1011, 958, 9, 267, 291, 14, 873, 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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 ]
likaiwalkman/phantomjs
src/breakpad/src/tools/gyp/pylib/gyp/generator/gypd.py
151
3320
#!/usr/bin/python # Copyright (c) 2009 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """gypd output module This module produces gyp input as its output. Output files are given the .gypd extension to avoid overwriting the .gyp files that they are generated from. Internal references to .gyp files (such as those found in "dependencies" sections) are not adjusted to point to .gypd files instead; unlike other paths, which are relative to the .gyp or .gypd file, such paths are relative to the directory from which gyp was run to create the .gypd file. This generator module is intended to be a sample and a debugging aid, hence the "d" for "debug" in .gypd. It is useful to inspect the results of the various merges, expansions, and conditional evaluations performed by gyp and to see a representation of what would be fed to a generator module. It's not advisable to rename .gypd files produced by this module to .gyp, because they will have all merges, expansions, and evaluations already performed and the relevant constructs not present in the output; paths to dependencies may be wrong; and various sections that do not belong in .gyp files such as such as "included_files" and "*_excluded" will be present. Output will also be stripped of comments. This is not intended to be a general-purpose gyp pretty-printer; for that, you probably just want to run "pprint.pprint(eval(open('source.gyp').read()))", which will still strip comments but won't do all of the other things done to this module's output. The specific formatting of the output generated by this module is subject to change. """ import gyp.common import errno import os import pprint # These variables should just be spit back out as variable references. _generator_identity_variables = [ 'EXECUTABLE_PREFIX', 'EXECUTABLE_SUFFIX', 'INTERMEDIATE_DIR', 'PRODUCT_DIR', 'RULE_INPUT_ROOT', 'RULE_INPUT_EXT', 'RULE_INPUT_NAME', 'RULE_INPUT_PATH', 'SHARED_INTERMEDIATE_DIR', ] # gypd doesn't define a default value for OS like many other generator # modules. Specify "-D OS=whatever" on the command line to provide a value. generator_default_variables = { } # gypd supports multiple toolsets generator_supports_multiple_toolsets = True # TODO(mark): This always uses <, which isn't right. The input module should # notify the generator to tell it which phase it is operating in, and this # module should use < for the early phase and then switch to > for the late # phase. Bonus points for carrying @ back into the output too. for v in _generator_identity_variables: generator_default_variables[v] = '<(%s)' % v def GenerateOutput(target_list, target_dicts, data, params): output_files = {} for qualified_target in target_list: [input_file, target] = \ gyp.common.ParseQualifiedTarget(qualified_target)[0:2] if input_file[-4:] != '.gyp': continue input_file_stem = input_file[:-4] output_file = input_file_stem + params['options'].suffix + '.gypd' if not output_file in output_files: output_files[output_file] = input_file for output_file, input_file in output_files.iteritems(): output = open(output_file, 'w') pprint.pprint(data[input_file], output) output.close()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 3, 1898, 334, 67, 9, 8937, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 6179, 68, 1072, 859, 199, 199, 2765, 859, 16904, 4902, 1324, 465, 2399, 1072, 14, 221, 7242, 1584, 787, 1627, 314, 199, 14, 6179, 68, 3329, 370, 5126, 32592, 314, 1275, 6179, 1584, 626, 2985, 787, 4046, 199, 504, 14, 221, 12624, 6941, 370, 1275, 6179, 1584, 334, 10180, 465, 5204, 1911, 315, 199, 2, 5714, 2, 10189, 9, 787, 440, 19477, 370, 2376, 370, 1275, 6179, 68, 1584, 3140, 27, 199, 324, 2930, 1163, 3792, 12, 1314, 787, 3847, 370, 314, 1275, 6179, 503, 1275, 6179, 68, 570, 12, 4066, 3792, 199, 1530, 3847, 370, 314, 2082, 687, 1314, 4902, 1990, 1255, 370, 1218, 314, 1275, 6179, 68, 570, 14, 199, 199, 2765, 4306, 859, 365, 11619, 370, 506, 282, 2690, 436, 282, 10201, 23939, 12, 19407, 199, 1589, 298, 68, 2, 367, 298, 1757, 2, 315, 1275, 6179, 68, 14, 221, 2779, 365, 2997, 370, 6485, 314, 2058, 402, 314, 199, 3808, 1785, 32716, 12, 25864, 12, 436, 12303, 8031, 1298, 10585, 701, 4902, 199, 460, 370, 1937, 282, 6025, 402, 4052, 3955, 506, 23036, 370, 282, 4306, 859, 14, 199, 199, 7940, 1159, 440, 1503, 5068, 461, 370, 11441, 1275, 6179, 68, 1584, 13584, 701, 642, 859, 370, 1275, 6179, 12, 199, 20684, 2985, 911, 1172, 1006, 32716, 12, 25864, 12, 436, 8031, 1298, 2575, 199, 31652, 436, 314, 12082, 21638, 440, 3451, 315, 314, 1072, 27, 3792, 370, 199, 5714, 1443, 506, 6835, 27, 436, 7750, 10189, 626, 886, 440, 13511, 315, 1275, 6179, 199, 1725, 4066, 465, 4066, 465, 298, 12409, 63, 1725, 2, 436, 8969, 63, 12144, 2, 911, 506, 3451, 14, 199, 2959, 911, 2597, 506, 14489, 402, 6786, 14, 221, 961, 365, 440, 11619, 370, 506, 282, 199, 10706, 13, 22615, 4902, 7268, 13, 11835, 27, 367, 626, 12, 1265, 8646, 2951, 2934, 370, 199, 1065, 298, 15380, 14, 15380, 8, 2579, 8, 1490, 360, 1365, 14, 6179, 1959, 739, 4059, 401, 1314, 911, 5139, 6202, 199, 6223, 1325, 7859, 1133, 886, 1006, 402, 314, 1163, 7645, 4224, 370, 642, 859, 1159, 1072, 14, 199, 199, 1918, 2488, 10803, 402, 314, 1072, 4046, 701, 642, 859, 365, 5420, 199, 475, 1570, 14, 199, 624, 421, 199, 646, 4902, 14, 2330, 199, 646, 7554, 199, 646, 747, 199, 646, 10933, 421, 199, 3, 5723, 2860, 1077, 2951, 506, 2249, 390, 1771, 734, 465, 1750, 6941, 14, 199, 63, 4679, 63, 5582, 63, 3669, 275, 359, 523, 283, 21623, 63, 6351, 297, 523, 283, 21623, 63, 12273, 297, 523, 283, 23227, 63, 3022, 297, 523, 283, 14853, 63, 3022, 297, 523, 283, 13578, 63, 7321, 63, 5441, 297, 523, 283, 13578, 63, 7321, 63, 2472, 297, 523, 283, 13578, 63, 7321, 63, 2339, 297, 523, 283, 13578, 63, 7321, 63, 3243, 297, 523, 283, 13772, 63, 23227, 63, 3022, 297, 199, 61, 199, 199, 3, 4902, 68, 3181, 1133, 5627, 282, 849, 574, 367, 4403, 2839, 5002, 1163, 4306, 199, 3, 4621, 14, 221, 13327, 3905, 36, 4403, 29, 26517, 2, 641, 314, 1414, 1004, 370, 5647, 282, 574, 14, 199, 4679, 63, 885, 63, 3669, 275, 469, 199, 93, 199, 199, 3, 4902, 68, 5171, 3663, 4744, 2193, 199, 4679, 63, 9823, 63, 6048, 63, 30116, 275, 715, 199, 199, 3, 3254, 8, 1657, 304, 961, 3544, 4440, 665, 12, 1314, 5712, 1133, 2451, 14, 221, 710, 1324, 859, 1077, 199, 3, 11705, 314, 4306, 370, 11480, 652, 1314, 7669, 652, 365, 17406, 315, 12, 436, 642, 199, 3, 859, 1077, 675, 665, 367, 314, 14670, 7669, 436, 2066, 6258, 370, 690, 367, 314, 2465, 199, 3, 7669, 14, 221, 699, 265, 527, 4501, 367, 25176, 316, 768, 1771, 1901, 314, 1072, 4634, 14, 199, 509, 373, 315, 485, 4679, 63, 5582, 63, 3669, 26, 523, 4306, 63, 885, 63, 3669, 59, 86, 61, 275, 2650, 4042, 83, 3171, 450, 373, 421, 199, 318, 7958, 2959, 8, 1375, 63, 513, 12, 1347, 63, 7892, 12, 666, 12, 1862, 304, 523, 1072, 63, 1725, 275, 1052, 523, 367, 12313, 63, 1375, 315, 1347, 63, 513, 26, 272, 359, 1210, 63, 493, 12, 1347, 61, 275, 971, 267, 4902, 14, 2330, 14, 4003, 30663, 8, 11661, 63, 1375, 2788, 16, 26, 18, 61, 339, 340, 1324, 63, 493, 1988, 20, 2938, 1137, 1987, 6179, 356, 489, 1980, 272, 1324, 63, 493, 63, 18446, 275, 1324, 63, 493, 4439, 20, 61, 272, 1072, 63, 493, 275, 1324, 63, 493, 63, 18446, 435, 1862, 459, 1419, 2278, 4511, 435, 1987, 6179, 68, 7, 339, 340, 440, 1072, 63, 493, 315, 1072, 63, 1725, 26, 489, 1072, 63, 1725, 59, 1199, 63, 493, 61, 275, 1324, 63, 493, 819, 367, 1072, 63, 493, 12, 1324, 63, 493, 315, 1072, 63, 1725, 14, 4611, 837, 272, 1072, 275, 1551, 8, 1199, 63, 493, 12, 283, 87, 358, 272, 10933, 14, 15380, 8, 576, 59, 1210, 63, 493, 467, 1072, 9, 272, 1072, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 3, 1898, 334, 67, 9, 8937, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 6179, 68, 1072, 859, 199, 199, 2765, 859, 16904, 4902, 1324, 465, 2399, 1072, 14, 221, 7242, 1584, 787, 1627, 314, 199, 14, 6179, 68, 3329, 370, 5126, 32592, 314, 1275, 6179, 1584, 626, 2985, 787, 4046, 199, 504, 14, 221, 12624, 6941, 370, 1275, 6179, 1584, 334, 10180, 465, 5204, 1911, 315, 199, 2, 5714, 2, 10189, 9, 787, 440, 19477, 370, 2376, 370, 1275, 6179, 68, 1584, 3140, 27, 199, 324, 2930, 1163, 3792, 12, 1314, 787, 3847, 370, 314, 1275, 6179, 503, 1275, 6179, 68, 570, 12, 4066, 3792, 199, 1530, 3847, 370, 314, 2082, 687, 1314, 4902, 1990, 1255, 370, 1218, 314, 1275, 6179, 68, 570, 14, 199, 199, 2765, 4306, 859, 365, 11619, 370, 506, 282, 2690, 436, 282, 10201, 23939, 12, 19407, 199, 1589, 298, 68, 2, 367, 298, 1757, 2, 315, 1275, 6179, 68, 14, 221, 2779, 365, 2997, 370, 6485, 314, 2058, 402, 314, 199, 3808, 1785, 32716, 12, 25864, 12, 436, 12303, 8031, 1298, 10585, 701, 4902, 199, 460, 370, 1937, 282, 6025, 402, 4052, 3955, 506, 23036, 370, 282, 4306, 859, 14, 199, 199, 7940, 1159, 440, 1503, 5068, 461, 370, 11441, 1275, 6179, 68, 1584, 13584, 701, 642, 859, 370, 1275, 6179, 12, 199, 20684, 2985, 911, 1172, 1006, 32716, 12, 25864, 12, 436, 8031, 1298, 2575, 199, 31652, 436, 314, 12082, 21638, 440, 3451, 315, 314, 1072, 27, 3792, 370, 199, 5714, 1443, 506, 6835, 27, 436, 7750, 10189, 626, 886, 440, 13511, 315, 1275, 6179, 199, 1725, 4066, 465, 4066, 465, 298, 12409, 63, 1725, 2, 436, 8969, 63, 12144, 2, 911, 506, 3451, 14, 199, 2959, 911, 2597, 506, 14489, 402, 6786, 14, 221, 961, 365, 440, 11619, 370, 506, 282, 199, 10706, 13, 22615, 4902, 7268, 13, 11835, 27, 367, 626, 12, 1265, 8646, 2951, 2934, 370, 199, 1065, 298, 15380, 14, 15380, 8, 2579, 8, 1490, 360, 1365, 14, 6179, 1959, 739, 4059, 401, 1314, 911, 5139, 6202, 199, 6223, 1325, 7859, 1133, 886, 1006, 402, 314, 1163, 7645, 4224, 370, 642, 859, 1159, 1072, 14, 199, 199, 1918, 2488, 10803, 402, 314, 1072, 4046, 701, 642, 859, 365, 5420, 199, 475, 1570, 14, 199, 624, 421, 199, 646, 4902, 14, 2330, 199, 646, 7554, 199, 646, 747, 199, 646, 10933, 421, 199, 3, 5723, 2860, 1077, 2951, 506, 2249, 390, 1771, 734, 465, 1750, 6941, 14, 199, 63, 4679, 63, 5582, 63, 3669, 275, 359, 523, 283, 21623, 63, 6351, 297, 523, 283, 21623, 63, 12273, 297, 523, 283, 23227, 63, 3022, 297, 523, 283, 14853, 63, 3022, 297, 523, 283, 13578, 63, 7321, 63, 5441, 297, 523, 283, 13578, 63, 7321, 63, 2472, 297, 523, 283, 13578, 63, 7321, 63, 2339, 297, 523, 283, 13578, 63, 7321, 63, 3243, 297, 523, 283, 13772, 63, 23227, 63, 3022, 297, 199, 61, 199, 199, 3, 4902, 68, 3181, 1133, 5627, 282, 849, 574, 367, 4403, 2839, 5002, 1163, 4306, 199, 3, 4621, 14, 221, 13327, 3905, 36, 4403, 29, 26517, 2, 641, 314, 1414, 1004, 370, 5647, 282, 574, 14, 199, 4679, 63, 885, 63, 3669, 275, 469, 199, 93, 199, 199, 3, 4902, 68, 5171, 3663, 4744, 2193, 199, 4679, 63, 9823, 63, 6048, 63, 30116, 275, 715, 199, 199, 3, 3254, 8, 1657, 304, 961, 3544, 4440, 665, 12, 1314, 5712, 1133, 2451, 14, 221, 710, 1324, 859, 1077, 199, 3, 11705, 314, 4306, 370, 11480, 652, 1314, 7669, 652, 365, 17406, 315, 12, 436, 642, 199, 3, 859, 1077, 675, 665, 367, 314, 14670, 7669, 436, 2066, 6258, 370, 690, 367, 314, 2465, 199, 3, 7669, 14, 221, 699, 265, 527, 4501, 367, 25176, 316, 768, 1771, 1901, 314, 1072, 4634, 14, 199, 509, 373, 315, 485, 4679, 63, 5582, 63, 3669, 26, 523, 4306, 63, 885, 63, 3669, 59, 86, 61, 275, 2650, 4042, 83, 3171, 450, 373, 421, 199, 318, 7958, 2959, 8, 1375, 63, 513, 12, 1347, 63, 7892, 12, 666, 12, 1862, 304, 523, 1072, 63, 1725, 275, 1052, 523, 367, 12313, 63, 1375, 315, 1347, 63, 513, 26, 272, 359, 1210, 63, 493, 12, 1347, 61, 275, 971, 267, 4902, 14, 2330, 14, 4003, 30663, 8, 11661, 63, 1375, 2788, 16, 26, 18, 61, 339, 340, 1324, 63, 493, 1988, 20, 2938, 1137, 1987, 6179, 356, 489, 1980, 272, 1324, 63, 493, 63, 18446, 275, 1324, 63, 493, 4439, 20, 61, 272, 1072, 63, 493, 275, 1324, 63, 493, 63, 18446, 435, 1862, 459, 1419, 2278, 4511, 435, 1987, 6179, 68, 7, 339, 340, 440, 1072, 63, 493, 315, 1072, 63, 1725, 26, 489, 1072, 63, 1725, 59, 1199, 63, 493, 61, 275, 1324, 63, 493, 819, 367, 1072, 63, 493, 12, 1324, 63, 493, 315, 1072, 63, 1725, 14, 4611, 837, 272, 1072, 275, 1551, 8, 1199, 63, 493, 12, 283, 87, 358, 272, 10933, 14, 15380, 8, 576, 59, 1210, 63, 493, 467, 1072, 9, 272, 1072, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
TQRG/physalia
physalia/utils/monsoon.py
1
1143
"""Module with util functions to use with Monsoon.""" import usb.core from math import isclose from Monsoon import Operations import click def _device_matcher(device): """Check if device is monsoon. Method copied from official Monsoon API. """ # pylint: disable=bare-except try: return device.idVendor == 0x2AB9 and device.idProduct == 0x0001 except: return False def is_monsoon_available(): """Check wheter there is a Monsoon connnected.""" device = usb.core.find(custom_match=_device_matcher) return device is not None def get_voltage(monsoon): """Get voltage in the output of Monsoon.""" read_voltage = monsoon.Protocol.getValue(Operations.OpCodes.setMainVoltage,1) return read_voltage / Operations.Conversion.FLOAT_TO_INT def set_voltage_if_different(monsoon, voltage): """Set monsoon voltage only if it is different.""" previous_voltage = get_voltage(monsoon) if not isclose(previous_voltage, voltage, abs_tol=0.0001): click.secho('setting voltage {} (previous was {})'.format(voltage, previous_voltage), fg='red') monsoon.setVout(voltage)
mit
[ 624, 2377, 543, 4884, 3423, 370, 675, 543, 10953, 1152, 265, 1041, 199, 199, 646, 27923, 14, 1018, 199, 504, 3473, 492, 365, 1600, 199, 504, 10953, 1152, 265, 492, 29474, 199, 646, 8968, 199, 199, 318, 485, 1782, 63, 16135, 8, 1782, 304, 272, 408, 1799, 340, 2243, 365, 3485, 1152, 265, 14, 339, 9075, 8876, 687, 25410, 10953, 1152, 265, 3261, 14, 272, 408, 272, 327, 4287, 26, 3507, 29, 14890, 13, 2590, 272, 862, 26, 267, 372, 2243, 14, 344, 27111, 508, 378, 88, 18, 1217, 25, 436, 2243, 14, 344, 5884, 508, 378, 88, 4183, 272, 871, 26, 267, 372, 756, 199, 199, 318, 365, 63, 2106, 1152, 265, 63, 4561, 837, 272, 408, 1799, 336, 426, 351, 2337, 365, 282, 10953, 1152, 265, 2557, 4636, 1041, 272, 2243, 275, 27923, 14, 1018, 14, 1623, 8, 4229, 63, 1431, 3699, 1782, 63, 16135, 9, 272, 372, 2243, 365, 440, 488, 199, 199, 318, 664, 63, 27543, 8, 2106, 1152, 265, 304, 272, 408, 1002, 29943, 315, 314, 1072, 402, 10953, 1152, 265, 1041, 272, 1586, 63, 27543, 275, 3485, 1152, 265, 14, 3658, 14, 17186, 8, 12929, 14, 4619, 14060, 14, 409, 6756, 16969, 15028, 12, 17, 9, 272, 372, 1586, 63, 27543, 1182, 29474, 14, 20403, 14, 11783, 63, 2566, 63, 2919, 199, 199, 318, 663, 63, 27543, 63, 692, 63, 14020, 8, 2106, 1152, 265, 12, 29943, 304, 272, 408, 1084, 3485, 1152, 265, 29943, 1454, 340, 652, 365, 3365, 1041, 272, 4136, 63, 27543, 275, 664, 63, 27543, 8, 2106, 1152, 265, 9, 272, 340, 440, 365, 1600, 8, 6352, 63, 27543, 12, 29943, 12, 2853, 63, 6896, 29, 16, 14, 4183, 304, 267, 8968, 14, 261, 2239, 360, 6031, 29943, 1052, 334, 6352, 1990, 5009, 1370, 908, 8, 27543, 12, 4136, 63, 27543, 395, 16587, 534, 581, 358, 267, 3485, 1152, 265, 14, 409, 54, 548, 8, 27543, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2377, 543, 4884, 3423, 370, 675, 543, 10953, 1152, 265, 1041, 199, 199, 646, 27923, 14, 1018, 199, 504, 3473, 492, 365, 1600, 199, 504, 10953, 1152, 265, 492, 29474, 199, 646, 8968, 199, 199, 318, 485, 1782, 63, 16135, 8, 1782, 304, 272, 408, 1799, 340, 2243, 365, 3485, 1152, 265, 14, 339, 9075, 8876, 687, 25410, 10953, 1152, 265, 3261, 14, 272, 408, 272, 327, 4287, 26, 3507, 29, 14890, 13, 2590, 272, 862, 26, 267, 372, 2243, 14, 344, 27111, 508, 378, 88, 18, 1217, 25, 436, 2243, 14, 344, 5884, 508, 378, 88, 4183, 272, 871, 26, 267, 372, 756, 199, 199, 318, 365, 63, 2106, 1152, 265, 63, 4561, 837, 272, 408, 1799, 336, 426, 351, 2337, 365, 282, 10953, 1152, 265, 2557, 4636, 1041, 272, 2243, 275, 27923, 14, 1018, 14, 1623, 8, 4229, 63, 1431, 3699, 1782, 63, 16135, 9, 272, 372, 2243, 365, 440, 488, 199, 199, 318, 664, 63, 27543, 8, 2106, 1152, 265, 304, 272, 408, 1002, 29943, 315, 314, 1072, 402, 10953, 1152, 265, 1041, 272, 1586, 63, 27543, 275, 3485, 1152, 265, 14, 3658, 14, 17186, 8, 12929, 14, 4619, 14060, 14, 409, 6756, 16969, 15028, 12, 17, 9, 272, 372, 1586, 63, 27543, 1182, 29474, 14, 20403, 14, 11783, 63, 2566, 63, 2919, 199, 199, 318, 663, 63, 27543, 63, 692, 63, 14020, 8, 2106, 1152, 265, 12, 29943, 304, 272, 408, 1084, 3485, 1152, 265, 29943, 1454, 340, 652, 365, 3365, 1041, 272, 4136, 63, 27543, 275, 664, 63, 27543, 8, 2106, 1152, 265, 9, 272, 340, 440, 365, 1600, 8, 6352, 63, 27543, 12, 29943, 12, 2853, 63, 6896, 29, 16, 14, 4183, 304, 267, 8968, 14, 261, 2239, 360, 6031, 29943, 1052, 334, 6352, 1990, 5009, 1370, 908, 8, 27543, 12, 4136, 63, 27543, 395, 16587, 534, 581, 358, 267, 3485, 1152, 265, 14, 409, 54, 548, 8, 27543, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
umitanuki/chainer
cupy/io/text.py
4
1166
import numpy def loadtxt(fname, dtype=numpy.float64, comments='#', delimiter=None, converters=None, skiprows=0, usecols=None, unpack=False, ndmin=0): # TODO(beam2d): Implement it raise NotImplementedError def savetxt(fname, X, fmt='%.18e', delimiter=' ', newline='\n', header='', footer='', comments='# '): # TODO(beam2d): Implement it raise NotImplementedError def genfromtxt(fname, dtype=numpy.float64, comments='#', delimiter=None, skiprows=0, skip_header=0, skip_footer=0, converters=None, missing='', missing_values=None, filling_values=None, usecols=None, names=None, excludelist=None, deletechars=None, replace_space='_', autostrip=False, case_sensitive=True, defaultfmt='f%i', unpack=None, usemask=False, loose=True, invalid_raise=True): # TODO(beam2d): Implement it raise NotImplementedError def fromregex(file, regexp, dtype): # TODO(beam2d): Implement it raise NotImplementedError def fromstring(string, dtype=float, count=-1, sep=''): # TODO(beam2d): Implement it raise NotImplementedError
mit
[ 646, 2680, 421, 199, 318, 2248, 2424, 8, 5252, 12, 2152, 29, 4714, 14, 1609, 772, 12, 6786, 534, 23470, 11172, 29, 403, 12, 288, 23172, 29, 403, 12, 2386, 73, 496, 3569, 29, 16, 12, 675, 4574, 29, 403, 12, 7787, 29, 797, 12, 5222, 827, 29, 16, 304, 272, 327, 3254, 8, 14529, 18, 68, 304, 22467, 652, 272, 746, 4279, 421, 199, 318, 308, 1214, 386, 400, 8, 5252, 12, 1323, 12, 7104, 9569, 14, 1085, 69, 297, 11172, 534, 1656, 8057, 17115, 78, 297, 1406, 4581, 288, 14178, 4581, 6786, 26431, 18927, 272, 327, 3254, 8, 14529, 18, 68, 304, 22467, 652, 272, 746, 4279, 421, 199, 318, 3805, 30439, 8, 5252, 12, 2152, 29, 4714, 14, 1609, 772, 12, 6786, 534, 23470, 11172, 29, 403, 12, 2049, 2386, 73, 496, 3569, 29, 16, 12, 3372, 63, 1291, 29, 16, 12, 3372, 63, 12781, 29, 16, 12, 23172, 29, 403, 12, 2049, 4124, 4581, 4124, 63, 1459, 29, 403, 12, 32499, 63, 1459, 29, 403, 12, 2049, 675, 4574, 29, 403, 12, 1561, 29, 403, 12, 5760, 513, 29, 403, 12, 3145, 6574, 29, 403, 12, 2049, 3350, 63, 2638, 534, 14474, 2599, 1913, 29, 797, 12, 1930, 63, 7361, 29, 549, 12, 2049, 849, 5045, 534, 70, 5, 73, 297, 7787, 29, 403, 12, 675, 2629, 29, 797, 12, 560, 3362, 29, 549, 12, 2049, 3866, 63, 3730, 29, 549, 304, 272, 327, 3254, 8, 14529, 18, 68, 304, 22467, 652, 272, 746, 4279, 421, 199, 318, 687, 3821, 8, 493, 12, 13156, 12, 2152, 304, 272, 327, 3254, 8, 14529, 18, 68, 304, 22467, 652, 272, 746, 4279, 421, 199, 318, 687, 875, 8, 875, 12, 2152, 29, 1609, 12, 2338, 4022, 17, 12, 7375, 9280, 272, 327, 3254, 8, 14529, 18, 68, 304, 22467, 652, 272, 746, 4279, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2680, 421, 199, 318, 2248, 2424, 8, 5252, 12, 2152, 29, 4714, 14, 1609, 772, 12, 6786, 534, 23470, 11172, 29, 403, 12, 288, 23172, 29, 403, 12, 2386, 73, 496, 3569, 29, 16, 12, 675, 4574, 29, 403, 12, 7787, 29, 797, 12, 5222, 827, 29, 16, 304, 272, 327, 3254, 8, 14529, 18, 68, 304, 22467, 652, 272, 746, 4279, 421, 199, 318, 308, 1214, 386, 400, 8, 5252, 12, 1323, 12, 7104, 9569, 14, 1085, 69, 297, 11172, 534, 1656, 8057, 17115, 78, 297, 1406, 4581, 288, 14178, 4581, 6786, 26431, 18927, 272, 327, 3254, 8, 14529, 18, 68, 304, 22467, 652, 272, 746, 4279, 421, 199, 318, 3805, 30439, 8, 5252, 12, 2152, 29, 4714, 14, 1609, 772, 12, 6786, 534, 23470, 11172, 29, 403, 12, 2049, 2386, 73, 496, 3569, 29, 16, 12, 3372, 63, 1291, 29, 16, 12, 3372, 63, 12781, 29, 16, 12, 23172, 29, 403, 12, 2049, 4124, 4581, 4124, 63, 1459, 29, 403, 12, 32499, 63, 1459, 29, 403, 12, 2049, 675, 4574, 29, 403, 12, 1561, 29, 403, 12, 5760, 513, 29, 403, 12, 3145, 6574, 29, 403, 12, 2049, 3350, 63, 2638, 534, 14474, 2599, 1913, 29, 797, 12, 1930, 63, 7361, 29, 549, 12, 2049, 849, 5045, 534, 70, 5, 73, 297, 7787, 29, 403, 12, 675, 2629, 29, 797, 12, 560, 3362, 29, 549, 12, 2049, 3866, 63, 3730, 29, 549, 304, 272, 327, 3254, 8, 14529, 18, 68, 304, 22467, 652, 272, 746, 4279, 421, 199, 318, 687, 3821, 8, 493, 12, 13156, 12, 2152, 304, 272, 327, 3254, 8, 14529, 18, 68, 304, 22467, 652, 272, 746, 4279, 421, 199, 318, 687, 875, 8, 875, 12, 2152, 29, 1609, 12, 2338, 4022, 17, 12, 7375, 9280, 272, 327, 3254, 8, 14529, 18, 68, 304, 22467, 652, 272, 746, 4279, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
st0ne/smarthome
plugins/dwd/__init__.py
6
9570
#!/usr/bin/env python3 # vim: set encoding=utf-8 tabstop=4 softtabstop=4 shiftwidth=4 expandtab ######################################################################### # Copyright 2012-2013 Marcus Popp marcus@popp.mx ######################################################################### # This file is part of SmartHome.py. http://mknx.github.io/smarthome/ # # SmartHome.py 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. # # SmartHome.py 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 SmartHome.py. If not, see <http://www.gnu.org/licenses/>. ######################################################################### import logging import csv import ftplib import socket import re import datetime import dateutil.parser import dateutil.tz import dateutil.relativedelta import xml.etree.cElementTree import threading logger = logging.getLogger('') class DWD(): _dwd_host = 'ftp-outgoing2.dwd.de' _warning_cat = {} def __init__(self, smarthome, username, password=True): self._sh = smarthome self._warnings_csv = smarthome.base_dir + '/plugins/dwd/warnings.csv' self._dwd_user = username self._dwd_password = password self.lock = threading.Lock() self.tz = dateutil.tz.gettz('Europe/Berlin') try: warnings = csv.reader(open(self._warnings_csv, "r", encoding='utf_8'), delimiter=';') except IOError as e: logger.error('Could not open warning catalog {}: {}'.format(self._warnings_csv, e)) for row in warnings: self._warning_cat[int(row[0])] = {'summary': row[1], 'kind': row[2]} def _connect(self): # open ftp connection to dwd if not hasattr(self, '_ftp'): try: self._ftp = ftplib.FTP(self._dwd_host, self._dwd_user, self._dwd_password, timeout=1) except (socket.error, socket.gaierror) as e: logger.error('Could not connect to {}: {}'.format(self._dwd_host, e)) self.ftp_quit() except ftplib.error_perm as e: logger.error('Could not login: {}'.format(e)) self.ftp_quit() def run(self): self.alive = True def stop(self): self.ftp_quit() self.alive = False def ftp_quit(self): try: self._ftp.close() except Exception: pass if hasattr(self, '_ftp'): del(self._ftp) def parse_item(self, item): return None def parse_logic(self, logic): return None def _buffer_file(self, data): self._buffer.extend(data) def _retr_file(self, filename): self.lock.acquire() self._connect() self._buffer = bytearray() try: self._ftp.retrbinary("RETR {}".format(filename), self._buffer_file) except Exception as e: logger.info("problem fetching {0}: {1}".format(filename, e)) del(self._buffer) self._buffer = bytearray() self.ftp_quit() self.lock.release() return self._buffer.decode('iso-8859-1') def _retr_list(self, dirname): self.lock.acquire() self._connect() try: filelist = self._ftp.nlst(dirname) except Exception: filelist = [] finally: self.lock.release() return filelist def warnings(self, region, location): directory = 'gds/specials/warnings' warnings = [] filepath = "{0}/{1}/W*_{2}_*".format(directory, region, location) files = self._retr_list(filepath) for filename in files: fb = self._retr_file(filename) if fb == '': continue dates = re.findall(r"\d\d\.\d\d\.\d\d\d\d \d\d:\d\d", fb) now = datetime.datetime.now(self.tz) if len(dates) > 1: # Entwarnungen haben nur ein Datum start = dateutil.parser.parse(dates[0], dayfirst=True) start = start.replace(tzinfo=self.tz) end = dateutil.parser.parse(dates[1], dayfirst=True) end = end.replace(tzinfo=self.tz) notice = dateutil.parser.parse(dates[2]) notice = notice.replace(tzinfo=self.tz) if end > now: area_splitter = re.compile(r'^\r\r\n', re.M) area = area_splitter.split(fb) code = int(re.findall(r"\d\d", area[0])[0]) desc = area[5].replace('\r\r\n', '').strip() kind = self._warning_cat[code]['kind'] warnings.append({'start': start, 'end': end, 'kind': kind, 'notice': notice, 'desc': desc}) return warnings def current(self, location): directory = 'gds/specials/observations/tables/germany' files = self._retr_list(directory) if files == []: return {} last = sorted(files)[-1] fb = self._retr_file(last) fb = fb.splitlines() if len(fb) < 8: logger.info("problem fetching {0}".format(last)) return {} header = fb[4] legend = fb[8].split() date = re.findall(r"\d\d\.\d\d\.\d\d\d\d", header)[0].split('.') date = "{}-{}-{}".format(date[2], date[1], date[0]) for line in fb: if line.count(location): space = re.compile(r' +') line = space.split(line) return dict(zip(legend, line)) return {} def forecast(self, region, location): path = 'gds/specials/forecasts/tables/germany/Daten_' frames = ['frueh', 'mittag', 'spaet', 'nacht', 'morgen_frueh', 'morgen_spaet', 'uebermorgen_frueh', 'uebermorgen_spaet', 'Tag4_frueh', 'Tag4_spaet'] forecast = {} for frame in frames: filepath = "{0}{1}_{2}".format(path, region, frame) fb = self._retr_file(filepath) if fb == '': continue minute = 0 if frame.count('frueh'): hour = 6 elif frame == 'mittag': hour = 12 elif frame == 'nacht': hour = 23 minute = 59 else: hour = 18 for line in fb.splitlines(): if line.count('Termin ist nicht mehr'): # already past date = self._sh.now().replace(hour=hour, minute=minute, second=0, microsecond=0, tzinfo=self.tz) forecast[date] = ['', '', ''] continue elif line.startswith('Vorhersage'): header = line elif line.count(location): header = re.sub(r"/\d\d?", '', header) day, month, year = re.findall(r"\d\d\.\d\d\.\d\d\d\d", header)[0].split('.') date = datetime.datetime(int(year), int(month), int(day), hour, tzinfo=self.tz) space = re.compile(r' +') fc = space.split(line) forecast[date] = fc[1:] return forecast def uvi(self, location): directory = 'gds/specials/warnings/FG' forecast = {} for frame in ['12', '36', '60']: filename = "{0}/u_vindex{1}.xml".format(directory, frame) fb = self._retr_file(filename) try: year, month, day = re.findall(r"\d\d\d\d\-\d\d\-\d\d", fb)[0].split('-') except: continue date = datetime.datetime(int(year), int(month), int(day), 12, 0, 0, 0, tzinfo=self.tz) uv = re.findall(r"{}<\/tns:Ort>\n *<tns:Wert>([^<]+)".format(location), fb) if len(uv) == 1: forecast[date] = int(uv[0]) return forecast def pollen(self, region): filename = 'gds/specials/warnings/FG/s_b31fg.xml' filexml = self._retr_file(filename) if filexml == '': return {} fxp = xml.etree.cElementTree.fromstring(filexml) date = fxp.attrib['last_update'].split()[0].split('-') day0 = datetime.datetime(int(date[0]), int(date[1]), int(date[2]), 12, 0, 0, 0, tzinfo=self.tz) day1 = day0 + dateutil.relativedelta.relativedelta(days=1) day2 = day0 + dateutil.relativedelta.relativedelta(days=2) forecast = {day0: {}, day1: {}, day2: {}} for reg in fxp.findall('region'): for preg in reg.findall('partregion'): if preg.attrib['name'] == region: for kind in preg: for day in kind: value = day.text.replace('/', '') if day.tag == 'today': forecast[day0][kind.tag] = value elif day.tag == 'tomorrow': forecast[day1][kind.tag] = value else: logger.debug("unknown day: {0}".format(day.tag)) fxp.clear() return forecast
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 6695, 26, 663, 2644, 29, 1624, 13, 24, 20849, 29, 20, 25966, 29, 20, 20105, 29, 20, 26414, 199, 3949, 3, 199, 3, 221, 1898, 6029, 13, 6965, 603, 9912, 527, 13244, 80, 12793, 7557, 67, 527, 32, 1935, 80, 14, 9457, 199, 3949, 3, 199, 3, 221, 961, 570, 365, 1777, 402, 26017, 12054, 14, 647, 14, 259, 1455, 921, 3880, 7343, 14, 5031, 14, 2308, 15, 3300, 19677, 1377, 15, 199, 3, 199, 3, 221, 26017, 12054, 14, 647, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 221, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 221, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 221, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 26017, 12054, 14, 647, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 26017, 12054, 14, 647, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3949, 3, 199, 199, 646, 2050, 199, 646, 7392, 199, 646, 14904, 773, 199, 646, 2838, 199, 646, 295, 199, 646, 2197, 199, 646, 22208, 14, 2087, 199, 646, 22208, 14, 3903, 199, 646, 22208, 14, 32300, 199, 646, 2748, 14, 9464, 14, 67, 15325, 199, 646, 5796, 199, 199, 2921, 275, 2050, 14, 5572, 8355, 421, 199, 533, 577, 16698, 837, 272, 485, 68, 2989, 63, 1102, 275, 283, 8915, 13, 19388, 18, 14, 68, 2989, 14, 271, 7, 272, 485, 3764, 63, 3385, 275, 1052, 339, 347, 636, 826, 721, 277, 12, 4383, 19677, 1377, 12, 3434, 12, 2505, 29, 549, 304, 267, 291, 423, 609, 275, 4383, 19677, 1377, 267, 291, 423, 5451, 63, 4737, 275, 4383, 19677, 1377, 14, 1095, 63, 694, 435, 1994, 5265, 15, 68, 2989, 15, 5451, 14, 4737, 7, 267, 291, 423, 68, 2989, 63, 751, 275, 3434, 267, 291, 423, 68, 2989, 63, 2060, 275, 2505, 267, 291, 14, 831, 275, 5796, 14, 6432, 342, 267, 291, 14, 3903, 275, 22208, 14, 3903, 14, 362, 3903, 360, 15201, 15, 24947, 472, 358, 267, 862, 26, 288, 3598, 275, 7392, 14, 5503, 8, 1490, 8, 277, 423, 5451, 63, 4737, 12, 298, 82, 401, 2644, 534, 1624, 63, 24, 659, 11172, 534, 10784, 267, 871, 5925, 465, 325, 26, 288, 2512, 14, 705, 360, 6531, 440, 1551, 5721, 10594, 24702, 9499, 908, 8, 277, 423, 5451, 63, 4737, 12, 325, 430, 267, 367, 1962, 315, 3598, 26, 288, 291, 423, 3764, 63, 3385, 59, 442, 8, 1143, 59, 16, 12457, 275, 791, 4705, 356, 1962, 59, 17, 467, 283, 5091, 356, 1962, 59, 18, 9420, 339, 347, 485, 2242, 8, 277, 304, 267, 327, 1551, 14904, 1950, 370, 366, 2989, 267, 340, 440, 2688, 8, 277, 12, 2513, 8915, 735, 288, 862, 26, 355, 291, 423, 8915, 275, 14904, 773, 14, 15123, 8, 277, 423, 68, 2989, 63, 1102, 12, 291, 423, 68, 2989, 63, 751, 12, 291, 423, 68, 2989, 63, 2060, 12, 2653, 29, 17, 9, 288, 871, 334, 3450, 14, 705, 12, 2838, 14, 5294, 73, 705, 9, 465, 325, 26, 355, 2512, 14, 705, 360, 6531, 440, 4907, 370, 24702, 9499, 908, 8, 277, 423, 68, 2989, 63, 1102, 12, 325, 430, 355, 291, 14, 8915, 63, 10589, 342, 288, 871, 14904, 773, 14, 705, 63, 8220, 465, 325, 26, 355, 2512, 14, 705, 360, 6531, 440, 4676, 26, 9499, 908, 8, 69, 430, 355, 291, 14, 8915, 63, 10589, 342, 339, 347, 1255, 8, 277, 304, 267, 291, 14, 9631, 275, 715, 339, 347, 3631, 8, 277, 304, 267, 291, 14, 8915, 63, 10589, 342, 267, 291, 14, 9631, 275, 756, 339, 347, 14904, 63, 10589, 8, 277, 304, 267, 862, 26, 288, 291, 423, 8915, 14, 1600, 342, 267, 871, 2186, 26, 288, 986, 267, 340, 2688, 8, 277, 12, 2513, 8915, 735, 288, 2150, 8, 277, 423, 8915, 9, 339, 347, 2198, 63, 1053, 8, 277, 12, 1242, 304, 267, 372, 488, 339, 347, 2198, 63, 15370, 8, 277, 12, 9661, 304, 267, 372, 488, 339, 347, 485, 2738, 63, 493, 8, 277, 12, 666, 304, 267, 291, 423, 2738, 14, 2880, 8, 576, 9, 339, 347, 485, 264, 454, 63, 493, 8, 277, 12, 1788, 304, 267, 291, 14, 831, 14, 8174, 342, 267, 291, 423, 2242, 342, 267, 291, 423, 2738, 275, 11640, 342, 267, 862, 26, 288, 291, 423, 8915, 14, 264, 454, 3008, 480, 7341, 50, 8352, 908, 8, 1501, 395, 291, 423, 2738, 63, 493, 9, 267, 871, 2186, 465, 325, 26, 288, 2512, 14, 815, 480, 6462, 21239, 469, 16, 9160, 469, 17, 5469, 908, 8, 1501, 12, 325, 430, 288, 2150, 8, 277, 423, 2738, 9, 288, 291, 423, 2738, 275, 11640, 342, 288, 291, 14, 8915, 63, 10589, 342, 267, 291, 14, 831, 14, 3221, 342, 267, 372, 291, 423, 2738, 14, 2708, 360, 4595, 13, 4830, 13, 17, 358, 339, 347, 485, 264, 454, 63, 513, 8, 277, 12, 9017, 304, 267, 291, 14, 831, 14, 8174, 342, 267, 291, 423, 2242, 342, 267, 862, 26, 288, 26148, 275, 291, 423, 8915, 14, 78, 6916, 8, 3475, 9, 267, 871, 2186, 26, 288, 26148, 275, 942, 267, 3753, 26, 288, 291, 14, 831, 14, 3221, 342, 267, 372, 26148, 339, 347, 3598, 8, 277, 12, 4897, 12, 2909, 304, 267, 2082, 275, 283, 27987, 15, 3017, 2551, 15, 5451, 7, 267, 3598, 275, 942, 267, 9911, 275, 5310, 16, 16152, 17, 5995, 55, 10, 7348, 18, 12585, 10, 1674, 908, 8, 3619, 12, 4897, 12, 2909, 9, 267, 1584, 275, 291, 423, 264, 454, 63, 513, 8, 7218, 9, 267 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 6695, 26, 663, 2644, 29, 1624, 13, 24, 20849, 29, 20, 25966, 29, 20, 20105, 29, 20, 26414, 199, 3949, 3, 199, 3, 221, 1898, 6029, 13, 6965, 603, 9912, 527, 13244, 80, 12793, 7557, 67, 527, 32, 1935, 80, 14, 9457, 199, 3949, 3, 199, 3, 221, 961, 570, 365, 1777, 402, 26017, 12054, 14, 647, 14, 259, 1455, 921, 3880, 7343, 14, 5031, 14, 2308, 15, 3300, 19677, 1377, 15, 199, 3, 199, 3, 221, 26017, 12054, 14, 647, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 221, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 221, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 221, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 26017, 12054, 14, 647, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 26017, 12054, 14, 647, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3949, 3, 199, 199, 646, 2050, 199, 646, 7392, 199, 646, 14904, 773, 199, 646, 2838, 199, 646, 295, 199, 646, 2197, 199, 646, 22208, 14, 2087, 199, 646, 22208, 14, 3903, 199, 646, 22208, 14, 32300, 199, 646, 2748, 14, 9464, 14, 67, 15325, 199, 646, 5796, 199, 199, 2921, 275, 2050, 14, 5572, 8355, 421, 199, 533, 577, 16698, 837, 272, 485, 68, 2989, 63, 1102, 275, 283, 8915, 13, 19388, 18, 14, 68, 2989, 14, 271, 7, 272, 485, 3764, 63, 3385, 275, 1052, 339, 347, 636, 826, 721, 277, 12, 4383, 19677, 1377, 12, 3434, 12, 2505, 29, 549, 304, 267, 291, 423, 609, 275, 4383, 19677, 1377, 267, 291, 423, 5451, 63, 4737, 275, 4383, 19677, 1377, 14, 1095, 63, 694, 435, 1994, 5265, 15, 68, 2989, 15, 5451, 14, 4737, 7, 267, 291, 423, 68, 2989, 63, 751, 275, 3434, 267, 291, 423, 68, 2989, 63, 2060, 275, 2505, 267, 291, 14, 831, 275, 5796, 14, 6432, 342, 267, 291, 14, 3903, 275, 22208, 14, 3903, 14, 362, 3903, 360, 15201, 15, 24947, 472, 358, 267, 862, 26, 288, 3598, 275, 7392, 14, 5503, 8, 1490, 8, 277, 423, 5451, 63, 4737, 12, 298, 82, 401, 2644, 534, 1624, 63, 24, 659, 11172, 534, 10784, 267, 871, 5925, 465, 325, 26, 288, 2512, 14, 705, 360, 6531, 440, 1551, 5721, 10594, 24702, 9499, 908, 8, 277, 423, 5451, 63, 4737, 12, 325, 430, 267, 367, 1962, 315, 3598, 26, 288, 291, 423, 3764, 63, 3385, 59, 442, 8, 1143, 59, 16, 12457, 275, 791, 4705, 356, 1962, 59, 17, 467, 283, 5091, 356, 1962, 59, 18, 9420, 339, 347, 485, 2242, 8, 277, 304, 267, 327, 1551, 14904, 1950, 370, 366, 2989, 267, 340, 440, 2688, 8, 277, 12, 2513, 8915, 735, 288, 862, 26, 355, 291, 423, 8915, 275, 14904, 773, 14, 15123, 8, 277, 423, 68, 2989, 63, 1102, 12, 291, 423, 68, 2989, 63, 751, 12, 291, 423, 68, 2989, 63, 2060, 12, 2653, 29, 17, 9, 288, 871, 334, 3450, 14, 705, 12, 2838, 14, 5294, 73, 705, 9, 465, 325, 26, 355, 2512, 14, 705, 360, 6531, 440, 4907, 370, 24702, 9499, 908, 8, 277, 423, 68, 2989, 63, 1102, 12, 325, 430, 355, 291, 14, 8915, 63, 10589, 342, 288, 871, 14904, 773, 14, 705, 63, 8220, 465, 325, 26, 355, 2512, 14, 705, 360, 6531, 440, 4676, 26, 9499, 908, 8, 69, 430, 355, 291, 14, 8915, 63, 10589, 342, 339, 347, 1255, 8, 277, 304, 267, 291, 14, 9631, 275, 715, 339, 347, 3631, 8, 277, 304, 267, 291, 14, 8915, 63, 10589, 342, 267, 291, 14, 9631, 275, 756, 339, 347, 14904, 63, 10589, 8, 277, 304, 267, 862, 26, 288, 291, 423, 8915, 14, 1600, 342, 267, 871, 2186, 26, 288, 986, 267, 340, 2688, 8, 277, 12, 2513, 8915, 735, 288, 2150, 8, 277, 423, 8915, 9, 339, 347, 2198, 63, 1053, 8, 277, 12, 1242, 304, 267, 372, 488, 339, 347, 2198, 63, 15370, 8, 277, 12, 9661, 304, 267, 372, 488, 339, 347, 485, 2738, 63, 493, 8, 277, 12, 666, 304, 267, 291, 423, 2738, 14, 2880, 8, 576, 9, 339, 347, 485, 264, 454, 63, 493, 8, 277, 12, 1788, 304, 267, 291, 14, 831, 14, 8174, 342, 267, 291, 423, 2242, 342, 267, 291, 423, 2738, 275, 11640, 342, 267, 862, 26, 288, 291, 423, 8915, 14, 264, 454, 3008, 480, 7341, 50, 8352, 908, 8, 1501, 395, 291, 423, 2738, 63, 493, 9, 267, 871, 2186, 465, 325, 26, 288, 2512, 14, 815, 480, 6462, 21239, 469, 16, 9160, 469, 17, 5469, 908, 8, 1501, 12, 325, 430, 288, 2150, 8, 277, 423, 2738, 9, 288, 291, 423, 2738, 275, 11640, 342, 288, 291, 14, 8915, 63, 10589, 342, 267, 291, 14, 831, 14, 3221, 342, 267, 372, 291, 423, 2738, 14, 2708, 360, 4595, 13, 4830, 13, 17, 358, 339, 347, 485, 264, 454, 63, 513, 8, 277, 12, 9017, 304, 267, 291, 14, 831, 14, 8174, 342, 267, 291, 423, 2242, 342, 267, 862, 26, 288, 26148, 275, 291, 423, 8915, 14, 78, 6916, 8, 3475, 9, 267, 871, 2186, 26, 288, 26148, 275, 942, 267, 3753, 26, 288, 291, 14, 831, 14, 3221, 342, 267, 372, 26148, 339, 347, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
alephnullplex/mmdb
mmdb/settings.py
1
3188
""" Django settings for mmdb project. Generated by 'django-admin startproject' using Django 1.8.1. For more information on this file, see https://docs.djangoproject.com/en/1.8/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.8/ref/settings/ """ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '&b$=dqf1lspy7*&-40rc1z!z#3*c!b9sz(!zw-q%j#s^bnjkvx' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = os.environ.get('DEBUG', True) ALLOWED_HOSTS = ['*'] # Application definition INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'corsheaders', 'taggit', 'taggit_serializer', 'movies' ) MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', ) ROOT_URLCONF = 'mmdb.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'mmdb.wsgi.application' # Database # https://docs.djangoproject.com/en/1.8/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } if os.environ.get('DATABASE_URL', None): import dj_database_url DATABASES['default'] = dj_database_url.config() # Internationalization # https://docs.djangoproject.com/en/1.8/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True STATIC_URL = '/static/' STATIC_ROOT = 'staticfiles' STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), ) FIXTURE_DIRS = ( 'movies/fixtures/', ) # They don't really care about us CORS_ORIGIN_ALLOW_ALL = True REST_FRAMEWORK = { 'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.DjangoFilterBackend', 'rest_framework.filters.OrderingFilter') }
mit
[ 624, 199, 9323, 2202, 367, 8562, 697, 2199, 14, 199, 199, 12706, 701, 283, 1176, 13, 2113, 1343, 1715, 7, 1808, 5634, 413, 14, 24, 14, 17, 14, 199, 199, 1858, 1655, 2556, 641, 642, 570, 12, 1937, 199, 2859, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 24, 15, 11299, 15, 1751, 15, 199, 199, 1858, 314, 2615, 769, 402, 2202, 436, 3932, 1338, 12, 1937, 199, 2859, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 24, 15, 1121, 15, 1751, 15, 199, 624, 199, 199, 3, 6516, 3792, 6272, 314, 2199, 2839, 642, 26, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 19172, 199, 646, 747, 199, 199, 5825, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 29658, 421, 199, 3, 27534, 13, 928, 16367, 2202, 446, 625, 83, 10020, 367, 9920, 199, 3, 1666, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 24, 15, 21232, 15, 13605, 15, 1074, 513, 15, 199, 199, 3, 24143, 32712, 14750, 26, 4215, 314, 7565, 790, 1202, 315, 9920, 7565, 1, 199, 12961, 63, 3078, 275, 7673, 66, 4, 29, 27073, 70, 17, 478, 647, 23, 10, 6, 13, 2167, 1195, 17, 90, 1, 90, 3, 19, 10, 67, 1, 66, 25, 11803, 8, 1, 90, 87, 13, 81, 5, 74, 3, 83, 62, 10472, 74, 11475, 88, 7, 199, 199, 3, 24143, 32712, 14750, 26, 2793, 1133, 1255, 543, 3105, 19136, 641, 315, 9920, 1, 199, 5287, 275, 747, 14, 2314, 14, 362, 360, 5287, 297, 715, 9, 199, 199, 17350, 63, 23775, 275, 788, 10, 418, 421, 199, 3, 13515, 5492, 199, 199, 15942, 63, 14219, 275, 334, 272, 283, 1176, 14, 2828, 14, 2113, 297, 272, 283, 1176, 14, 2828, 14, 1178, 297, 272, 283, 1176, 14, 2828, 14, 10778, 297, 272, 283, 1176, 14, 2828, 14, 11676, 297, 272, 283, 1176, 14, 2828, 14, 3431, 297, 272, 283, 1176, 14, 2828, 14, 18373, 297, 272, 283, 3911, 63, 4857, 297, 272, 283, 30967, 2139, 297, 272, 283, 1450, 3187, 297, 272, 283, 1450, 3187, 63, 8349, 297, 272, 283, 20888, 7, 199, 9, 199, 199, 19987, 63, 13748, 275, 334, 272, 283, 1176, 14, 2828, 14, 11676, 14, 5754, 14, 4434, 6608, 297, 272, 283, 30967, 2139, 14, 5754, 14, 35, 1384, 6608, 297, 272, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 272, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 272, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 297, 272, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 4434, 10348, 6608, 297, 272, 283, 1176, 14, 2828, 14, 3431, 14, 5754, 14, 2209, 6608, 297, 272, 283, 1176, 14, 5754, 14, 4891, 19193, 316, 14, 56, 3160, 4558, 6608, 297, 272, 283, 1176, 14, 5754, 14, 4416, 14, 7676, 6608, 297, 199, 9, 199, 199, 5441, 63, 18125, 275, 283, 596, 697, 14, 3603, 7, 199, 199, 25437, 275, 359, 272, 469, 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, 5825, 63, 3022, 12, 283, 5876, 2665, 267, 283, 7121, 63, 14455, 356, 715, 12, 267, 283, 8808, 356, 469, 288, 283, 1100, 63, 10547, 356, 359, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 1757, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 1069, 297, 355, 283, 1176, 14, 2828, 14, 1178, 14, 1100, 63, 10547, 14, 1178, 297, 355, 283, 1176, 14, 2828, 14, 3431, 14, 1100, 63, 10547, 14, 3431, 297, 288, 2156, 267, 1660, 272, 1660, 199, 61, 199, 199, 16828, 63, 24051, 275, 283, 596, 697, 14, 6508, 14, 3578, 7, 421, 199, 3, 8692, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 24, 15, 1121, 15, 1751, 12645, 17439, 199, 27260, 275, 469, 272, 283, 885, 356, 469, 267, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 14, 10659, 19, 297, 267, 283, 2339, 356, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 697, 14, 10659, 19, 659, 272, 789, 199, 93, 199, 199, 692, 747, 14, 2314, 14, 362, 360, 17873, 63, 2632, 297, 488, 304, 272, 492, 366, 74, 63, 4659, 63, 633, 272, 26931, 21983, 459, 885, 418, 275, 366, 74, 63, 4659, 63, 633, 14, 888, 342, 421, 199, 3, 28220, 2072, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 24, 15, 11299, 15, 73, 1085, 78, 15, 199, 199, 13947, 63, 6012, 275, 283, 287, 13, 527, 7, 199, 199, 4961, 63, 15353, 275, 283, 11288, 7, 199, 199, 4701, 63, 41, 1085, 46, 275, 715, 199, 199, 4701, 63, 44, 709, 46, 275, 715, 199, 199, 4701, 63, 14226, 275, 715, 421, 199, 10449, 63, 2632, 275, 1994, 1986, 4805, 199, 10449, 63, 5441, 275, 283, 18373, 7, 199, 10449, 9472, 63, 14455, 275, 334, 272, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 1986, 659, 199, 9, 199, 199, 5192, 52, 3942, 63, 14455, 275, 334, 2043, 283, 20888, 15, 8769, 3678, 199, 9, 199, 199, 3, 9322, 2793, 1133, 7710, 10296, 3595, 2739, 199, 35, 4149, 63, 24832, 63, 12231, 63, 1761, 275, 715, 199, 199, 15740, 63, 12683, 8406, 275, 469, 272, 283, 3472, 63, 9905, 63, 28988, 356, 661, 3911, 63, 4857, 14, 4273, 14, 9323, 4131, 8447, 297, 283, 3911, 63, 4857, 14, 4273, 14, 4738, 316, 4131, 358, 199, 93, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 9323, 2202, 367, 8562, 697, 2199, 14, 199, 199, 12706, 701, 283, 1176, 13, 2113, 1343, 1715, 7, 1808, 5634, 413, 14, 24, 14, 17, 14, 199, 199, 1858, 1655, 2556, 641, 642, 570, 12, 1937, 199, 2859, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 24, 15, 11299, 15, 1751, 15, 199, 199, 1858, 314, 2615, 769, 402, 2202, 436, 3932, 1338, 12, 1937, 199, 2859, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 24, 15, 1121, 15, 1751, 15, 199, 624, 199, 199, 3, 6516, 3792, 6272, 314, 2199, 2839, 642, 26, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 19172, 199, 646, 747, 199, 199, 5825, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 29658, 421, 199, 3, 27534, 13, 928, 16367, 2202, 446, 625, 83, 10020, 367, 9920, 199, 3, 1666, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 24, 15, 21232, 15, 13605, 15, 1074, 513, 15, 199, 199, 3, 24143, 32712, 14750, 26, 4215, 314, 7565, 790, 1202, 315, 9920, 7565, 1, 199, 12961, 63, 3078, 275, 7673, 66, 4, 29, 27073, 70, 17, 478, 647, 23, 10, 6, 13, 2167, 1195, 17, 90, 1, 90, 3, 19, 10, 67, 1, 66, 25, 11803, 8, 1, 90, 87, 13, 81, 5, 74, 3, 83, 62, 10472, 74, 11475, 88, 7, 199, 199, 3, 24143, 32712, 14750, 26, 2793, 1133, 1255, 543, 3105, 19136, 641, 315, 9920, 1, 199, 5287, 275, 747, 14, 2314, 14, 362, 360, 5287, 297, 715, 9, 199, 199, 17350, 63, 23775, 275, 788, 10, 418, 421, 199, 3, 13515, 5492, 199, 199, 15942, 63, 14219, 275, 334, 272, 283, 1176, 14, 2828, 14, 2113, 297, 272, 283, 1176, 14, 2828, 14, 1178, 297, 272, 283, 1176, 14, 2828, 14, 10778, 297, 272, 283, 1176, 14, 2828, 14, 11676, 297, 272, 283, 1176, 14, 2828, 14, 3431, 297, 272, 283, 1176, 14, 2828, 14, 18373, 297, 272, 283, 3911, 63, 4857, 297, 272, 283, 30967, 2139, 297, 272, 283, 1450, 3187, 297, 272, 283, 1450, 3187, 63, 8349, 297, 272, 283, 20888, 7, 199, 9, 199, 199, 19987, 63, 13748, 275, 334, 272, 283, 1176, 14, 2828, 14, 11676, 14, 5754, 14, 4434, 6608, 297, 272, 283, 30967, 2139, 14, 5754, 14, 35, 1384, 6608, 297, 272, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 272, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 272, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 297, 272, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 4434, 10348, 6608, 297, 272, 283, 1176, 14, 2828, 14, 3431, 14, 5754, 14, 2209, 6608, 297, 272, 283, 1176, 14, 5754, 14, 4891, 19193, 316, 14, 56, 3160, 4558, 6608, 297, 272, 283, 1176, 14, 5754, 14, 4416, 14, 7676, 6608, 297, 199, 9, 199, 199, 5441, 63, 18125, 275, 283, 596, 697, 14, 3603, 7, 199, 199, 25437, 275, 359, 272, 469, 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, 5825, 63, 3022, 12, 283, 5876, 2665, 267, 283, 7121, 63, 14455, 356, 715, 12, 267, 283, 8808, 356, 469, 288, 283, 1100, 63, 10547, 356, 359, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 1757, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 1069, 297, 355, 283, 1176, 14, 2828, 14, 1178, 14, 1100, 63, 10547, 14, 1178, 297, 355, 283, 1176, 14, 2828, 14, 3431, 14, 1100, 63, 10547, 14, 3431, 297, 288, 2156, 267, 1660, 272, 1660, 199, 61, 199, 199, 16828, 63, 24051, 275, 283, 596, 697, 14, 6508, 14, 3578, 7, 421, 199, 3, 8692, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 24, 15, 1121, 15, 1751, 12645, 17439, 199, 27260, 275, 469, 272, 283, 885, 356, 469, 267, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 14, 10659, 19, 297, 267, 283, 2339, 356, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 697, 14, 10659, 19, 659, 272, 789, 199, 93, 199, 199, 692, 747, 14, 2314, 14, 362, 360, 17873, 63, 2632, 297, 488, 304, 272, 492, 366, 74, 63, 4659, 63, 633, 272, 26931, 21983, 459, 885, 418, 275, 366, 74, 63, 4659, 63, 633, 14, 888, 342, 421, 199, 3, 28220, 2072, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 24, 15, 11299, 15, 73, 1085, 78, 15, 199, 199, 13947, 63, 6012, 275, 283, 287, 13, 527, 7, 199, 199, 4961, 63, 15353, 275, 283, 11288, 7, 199, 199, 4701, 63, 41, 1085, 46, 275, 715, 199, 199, 4701, 63, 44, 709, 46, 275, 715, 199, 199, 4701, 63, 14226, 275, 715, 421, 199, 10449, 63, 2632, 275, 1994, 1986, 4805, 199, 10449, 63, 5441, 275, 283, 18373, 7, 199, 10449, 9472, 63, 14455, 275, 334, 272, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 1986, 659, 199, 9, 199, 199, 5192, 52, 3942, 63, 14455, 275, 334, 2043, 283, 20888, 15, 8769, 3678, 199, 9, 199, 199, 3, 9322, 2793, 1133, 7710, 10296, 3595, 2739, 199, 35, 4149, 63, 24832, 63, 12231, 63, 1761, 275, 715, 199, 199, 15740, 63, 12683, 8406, 275, 469, 272, 283, 3472, 63, 9905, 63, 28988, 356, 661, 3911, 63, 4857, 14, 4273, 14, 9323, 4131, 8447, 297, 283, 3911, 63, 4857, 14, 4273, 14, 4738, 316, 4131, 358, 199, 93, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
florianpirchner/nndesigner
org.eclipse.athene.nn.model/python/test_nodes_mergeNodes.py
1
1106
from tensorflow.contrib.keras.api.keras.layers import Conv2D, MaxPooling2D, Flatten from tensorflow.contrib.keras.api.keras.layers import Input, LSTM, Embedding, Dense, concatenate from tensorflow.contrib.keras.api.keras.layers import Input, LSTM, Embedding, Dense, concatenate, Add #from keras.layers import Conv2D, MaxPooling2D, Flatten, Layer #from keras.layers import Input, LSTM, Embedding, Dense, concatenate from tensorflow.contrib.keras.api.keras.models import Model, Sequential from tensorflow.python.layers.base import Layer input1 = Input(shape=(16,)) x1 = Dense(8, activation='relu')(input1) input2 = Input(shape=(32,)) x2 = Dense(8, activation='relu')(input2) added = Add()([x1, x2]) # equivalent to added = keras.layers.add([x1, x2]) print("") print("") print("---- iterate inbound nodes and tensors ----") print("") print("") print("added") for n in added.inbound_nodes: print("") print("In-Node ", id(n), n.get_config()) for n in added.outbound_nodes: print("") print("Out-Node ", id(n), n.get_config()) out = Dense(4)(added) model = Model(inputs=[input1, input2], outputs=out)
epl-1.0
[ 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 4359, 492, 19140, 18, 36, 12, 8228, 22349, 18, 36, 12, 19005, 724, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 4359, 492, 6924, 12, 491, 16644, 12, 24297, 1098, 12, 20847, 12, 24788, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 4359, 492, 6924, 12, 491, 16644, 12, 24297, 1098, 12, 20847, 12, 24788, 12, 2654, 199, 3, 504, 11708, 14, 4359, 492, 19140, 18, 36, 12, 8228, 22349, 18, 36, 12, 19005, 724, 12, 11915, 199, 3, 504, 11708, 14, 4359, 492, 6924, 12, 491, 16644, 12, 24297, 1098, 12, 20847, 12, 24788, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 992, 221, 492, 5822, 12, 3240, 9092, 199, 504, 3228, 14, 1548, 14, 4359, 14, 1095, 492, 11915, 199, 199, 1210, 17, 275, 6924, 8, 1392, 2687, 975, 4641, 199, 88, 17, 275, 20847, 8, 24, 12, 10361, 534, 12833, 7533, 1210, 17, 9, 199, 1210, 18, 275, 6924, 8, 1392, 2687, 708, 4641, 199, 88, 18, 275, 20847, 8, 24, 12, 10361, 534, 12833, 7533, 1210, 18, 9, 199, 3270, 275, 2654, 342, 779, 88, 17, 12, 671, 18, 566, 221, 327, 7353, 370, 3483, 275, 11708, 14, 4359, 14, 525, 779, 88, 17, 12, 671, 18, 566, 199, 199, 1361, 10804, 199, 1361, 10804, 199, 1361, 480, 375, 13974, 30819, 3380, 436, 10519, 4099, 531, 199, 1361, 10804, 199, 1361, 10804, 199, 1361, 480, 3270, 531, 199, 509, 302, 315, 3483, 14, 26108, 63, 2415, 26, 199, 198, 1361, 10804, 199, 198, 1361, 480, 607, 13, 1716, 3872, 1305, 8, 78, 395, 302, 14, 362, 63, 888, 1012, 199, 509, 302, 315, 3483, 14, 548, 3556, 63, 2415, 26, 199, 198, 1361, 10804, 199, 198, 1361, 480, 2204, 13, 1716, 3872, 221, 1305, 8, 78, 395, 302, 14, 362, 63, 888, 1012, 421, 199, 548, 275, 20847, 8, 20, 5130, 3270, 9, 199, 1238, 275, 5822, 8, 3711, 1524, 1210, 17, 12, 1324, 18, 467, 4704, 29, 548, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 4359, 492, 19140, 18, 36, 12, 8228, 22349, 18, 36, 12, 19005, 724, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 4359, 492, 6924, 12, 491, 16644, 12, 24297, 1098, 12, 20847, 12, 24788, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 4359, 492, 6924, 12, 491, 16644, 12, 24297, 1098, 12, 20847, 12, 24788, 12, 2654, 199, 3, 504, 11708, 14, 4359, 492, 19140, 18, 36, 12, 8228, 22349, 18, 36, 12, 19005, 724, 12, 11915, 199, 3, 504, 11708, 14, 4359, 492, 6924, 12, 491, 16644, 12, 24297, 1098, 12, 20847, 12, 24788, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 992, 221, 492, 5822, 12, 3240, 9092, 199, 504, 3228, 14, 1548, 14, 4359, 14, 1095, 492, 11915, 199, 199, 1210, 17, 275, 6924, 8, 1392, 2687, 975, 4641, 199, 88, 17, 275, 20847, 8, 24, 12, 10361, 534, 12833, 7533, 1210, 17, 9, 199, 1210, 18, 275, 6924, 8, 1392, 2687, 708, 4641, 199, 88, 18, 275, 20847, 8, 24, 12, 10361, 534, 12833, 7533, 1210, 18, 9, 199, 3270, 275, 2654, 342, 779, 88, 17, 12, 671, 18, 566, 221, 327, 7353, 370, 3483, 275, 11708, 14, 4359, 14, 525, 779, 88, 17, 12, 671, 18, 566, 199, 199, 1361, 10804, 199, 1361, 10804, 199, 1361, 480, 375, 13974, 30819, 3380, 436, 10519, 4099, 531, 199, 1361, 10804, 199, 1361, 10804, 199, 1361, 480, 3270, 531, 199, 509, 302, 315, 3483, 14, 26108, 63, 2415, 26, 199, 198, 1361, 10804, 199, 198, 1361, 480, 607, 13, 1716, 3872, 1305, 8, 78, 395, 302, 14, 362, 63, 888, 1012, 199, 509, 302, 315, 3483, 14, 548, 3556, 63, 2415, 26, 199, 198, 1361, 10804, 199, 198, 1361, 480, 2204, 13, 1716, 3872, 221, 1305, 8, 78, 395, 302, 14, 362, 63, 888, 1012, 421, 199, 548, 275, 20847, 8, 20, 5130, 3270, 9, 199, 1238, 275, 5822, 8, 3711, 1524, 1210, 17, 12, 1324, 18, 467, 4704, 29, 548, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
wheybags/freeablo
extern/fmt/doc/conf.py
16
8122
# -*- coding: utf-8 -*- # # format documentation build configuration file, created by # sphinx-quickstart on Tue Dec 18 06:46:16 2012. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os, re, subprocess # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. needs_sphinx = '1.2' if os.environ.get('READTHEDOCS', None) == 'True': subprocess.call('doxygen') # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.ifconfig', 'breathe'] breathe_default_project = "format" breathe_domain_by_extension = {"h" : "cpp"} # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. #master_doc = 'contents' # General information about the project. project = u'fmt' copyright = u'2012-present, Victor Zverovich' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. # Version and release are passed from CMake. #version = None # The full version, including alpha/beta/rc tags. #release = version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['virtualenv'] # The reST default role (used for this markup: `text`) to use for all documents. default_role = 'cpp:any' # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' highlight_language = 'c++' primary_domain = 'cpp' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'basic-bootstrap' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. html_theme_path = ['.'] # The name for this set of Sphinx documents. If None, it defaults to # "<project> v<release> documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. html_sidebars = { '**': ['localtoc.html', 'relations.html', 'sourcelink.html', 'searchbox.html'] } # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a <link> tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'formatdoc' # -- Options for LaTeX output -------------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'format.tex', u'fmt documentation', u'Victor Zverovich', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'fmt', u'fmt documentation', [u'Victor Zverovich'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ------------------------------------------------ # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'fmt', u'fmt documentation', u'Victor Zverovich', 'fmt', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote'
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1475, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 377, 310, 13966, 6155, 24293, 26, 2466, 26, 975, 6029, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 12, 747, 12, 295, 12, 3873, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 3, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 10065, 63, 8008, 275, 283, 17, 14, 18, 7, 199, 199, 692, 747, 14, 2314, 14, 362, 360, 5670, 2080, 1149, 47, 3298, 297, 488, 9, 508, 283, 549, 356, 523, 3873, 14, 1250, 360, 1117, 20515, 358, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 692, 888, 297, 283, 66, 8273, 1589, 418, 199, 199, 66, 8273, 1589, 63, 885, 63, 1715, 275, 298, 908, 2, 199, 66, 8273, 1589, 63, 2261, 63, 991, 63, 3435, 275, 2420, 72, 2, 520, 298, 5910, 3570, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 3, 4133, 63, 1301, 275, 283, 4407, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 7, 5045, 7, 199, 7307, 275, 399, 7, 7409, 13, 1881, 12, 6561, 630, 3107, 422, 79, 433, 335, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 199, 3, 3394, 436, 4683, 787, 3032, 687, 21355, 14, 199, 3, 1023, 275, 488, 199, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3, 3221, 275, 1015, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 788, 21611, 418, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 8247, 14, 199, 885, 63, 3756, 275, 283, 5910, 26, 1629, 7, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 14337, 63, 3671, 275, 283, 67, 4176, 7, 199, 199, 3327, 63, 2261, 275, 283, 5910, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 9527, 2595, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 4316, 13, 11146, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 1360, 63, 7915, 63, 515, 275, 18953, 418, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 12, 652, 4243, 370, 199, 3, 3886, 1715, 30, 373, 28, 3221, 30, 3794, 1674, 199, 3, 1360, 63, 1213, 275, 488, 199, 199, 3, 437, 18299, 2538, 367, 314, 19191, 4681, 14, 221, 3758, 365 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1475, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 377, 310, 13966, 6155, 24293, 26, 2466, 26, 975, 6029, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 12, 747, 12, 295, 12, 3873, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 3, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 10065, 63, 8008, 275, 283, 17, 14, 18, 7, 199, 199, 692, 747, 14, 2314, 14, 362, 360, 5670, 2080, 1149, 47, 3298, 297, 488, 9, 508, 283, 549, 356, 523, 3873, 14, 1250, 360, 1117, 20515, 358, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 692, 888, 297, 283, 66, 8273, 1589, 418, 199, 199, 66, 8273, 1589, 63, 885, 63, 1715, 275, 298, 908, 2, 199, 66, 8273, 1589, 63, 2261, 63, 991, 63, 3435, 275, 2420, 72, 2, 520, 298, 5910, 3570, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 3, 4133, 63, 1301, 275, 283, 4407, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 7, 5045, 7, 199, 7307, 275, 399, 7, 7409, 13, 1881, 12, 6561, 630, 3107, 422, 79, 433, 335, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 199, 3, 3394, 436, 4683, 787, 3032, 687, 21355, 14, 199, 3, 1023, 275, 488, 199, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3, 3221, 275, 1015, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 788, 21611, 418, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 8247, 14, 199, 885, 63, 3756, 275, 283, 5910, 26, 1629, 7, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 14337, 63, 3671, 275, 283, 67, 4176, 7, 199, 199, 3327, 63, 2261, 275, 283, 5910, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 9527, 2595, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 4316, 13, 11146, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 1360, 63, 7915, 63, 515, 275, 18953, 418, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 12, 652, 4243, 370, 199, 3, 3886, 1715, 30, 373, 28, 3221, 30, 3794, 1674, 199, 3, 1360, 63, 1213, 275, 488, 199, 199, 3, 437, 18299, 2538, 367, 314, 19191, 4681, 14, 221, 3758, 365, 0 ]
[ 1, 1, 1, 1, 1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i
python/build/lib.linux-armv6l-3.4/webiopi/devices/digital/gpio.py
4
6350
# Copyright 2012-2013 Eric Ptak - trouch.com # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from webiopi.utils.types import M_JSON from webiopi.utils.logger import debug from webiopi.devices.digital import GPIOPort from webiopi.decorators.rest import request, response try: import _webiopi.GPIO as GPIO except: pass EXPORT = [] class NativeGPIO(GPIOPort): def __init__(self): GPIOPort.__init__(self, 54) self.export = range(54) self.post_value = True self.post_function = True self.gpio_setup = [] self.gpio_reset = [] def __str__(self): return "GPIO" def addGPIO(self, lst, gpio, params): gpio = int(gpio) params = params.split(" ") func = params[0].lower() if func == "in": func = GPIO.IN elif func == "out": func = GPIO.OUT else: raise Exception("Unknown function") value = -1 if len(params) > 1: value = int(params[1]) lst.append({"gpio": gpio, "func": func, "value": value}) def addGPIOSetup(self, gpio, params): self.addGPIO(self.gpio_setup, gpio, params) def addGPIOReset(self, gpio, params): self.addGPIO(self.gpio_reset, gpio, params) def addSetups(self, gpios): for (gpio, params) in gpios: self.addGPIOSetup(gpio, params) def addResets(self, gpios): for (gpio, params) in gpios: self.addGPIOReset(gpio, params) def setup(self): for g in self.gpio_setup: gpio = g["gpio"] debug("Setup GPIO %d" % gpio) GPIO.setFunction(gpio, g["func"]) if g["value"] >= 0 and GPIO.getFunction(gpio) == GPIO.OUT: GPIO.digitalWrite(gpio, g["value"]) def close(self): for g in self.gpio_reset: gpio = g["gpio"] debug("Reset GPIO %d" % gpio) GPIO.setFunction(gpio, g["func"]) if g["value"] >= 0 and GPIO.getFunction(gpio) == GPIO.OUT: GPIO.digitalWrite(gpio, g["value"]) def checkDigitalChannelExported(self, channel): if not channel in self.export: raise GPIO.InvalidChannelException("Channel %d is not allowed" % channel) def checkPostingFunctionAllowed(self): if not self.post_function: raise ValueError("POSTing function to native GPIO not allowed") def checkPostingValueAllowed(self): if not self.post_value: raise ValueError("POSTing value to native GPIO not allowed") def __digitalRead__(self, channel): self.checkDigitalChannelExported(channel) return GPIO.digitalRead(channel) def __digitalWrite__(self, channel, value): self.checkDigitalChannelExported(channel) self.checkPostingValueAllowed() GPIO.digitalWrite(channel, value) def __getFunction__(self, channel): self.checkDigitalChannelExported(channel) return GPIO.getFunction(channel) def __setFunction__(self, channel, value): self.checkDigitalChannelExported(channel) self.checkPostingFunctionAllowed() GPIO.setFunction(channel, value) def __portRead__(self): value = 0 for i in self.export: value |= GPIO.digitalRead(i) << i return value def __portWrite__(self, value): if len(self.export) < 54: for i in self.export: if GPIO.getFunction(i) == GPIO.OUT: GPIO.digitalWrite(i, (value >> i) & 1) else: raise Exception("Please limit exported GPIO to write integers") @request("GET", "*") @response(contentType=M_JSON) def wildcard(self, compact=False): if compact: f = "f" v = "v" else: f = "function" v = "value" values = {} print(self.export) for i in self.export: if compact: func = GPIO.getFunction(i) else: func = GPIO.getFunctionString(i) values[i] = {f: func, v: int(GPIO.digitalRead(i))} return values @request("GET", "%(channel)d/pulse", "%s") def getPulse(self, channel): self.checkDigitalChannelExported(channel) self.checkDigitalChannel(channel) return GPIO.getPulse(channel) @request("POST", "%(channel)d/sequence/%(args)s") @response("%d") def outputSequence(self, channel, args): self.checkDigitalChannelExported(channel) self.checkPostingValueAllowed() self.checkDigitalChannel(channel) (period, sequence) = args.split(",") period = int(period) GPIO.outputSequence(channel, period, sequence) return int(sequence[-1]) @request("POST", "%(channel)d/pulse/") def pulse(self, channel): self.checkDigitalChannelExported(channel) self.checkPostingValueAllowed() self.checkDigitalChannel(channel) GPIO.pulse(channel) return "OK" @request("POST", "%(channel)d/pulseRatio/%(value)f") def pulseRatio(self, channel, value): self.checkDigitalChannelExported(channel) self.checkPostingValueAllowed() self.checkDigitalChannel(channel) GPIO.pulseRatio(channel, value) return GPIO.getPulse(channel) @request("POST", "%(channel)d/pulseAngle/%(value)f") def pulseAngle(self, channel, value): self.checkDigitalChannelExported(channel) self.checkPostingValueAllowed() self.checkDigitalChannel(channel) GPIO.pulseAngle(channel, value) return GPIO.getPulse(channel)
gpl-3.0
[ 3, 257, 1898, 6029, 13, 6965, 662, 1567, 510, 502, 75, 446, 22621, 2133, 14, 957, 199, 3, 199, 3, 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 257, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 257, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 755, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 257, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 257, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 257, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 257, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 257, 4204, 1334, 314, 844, 14, 199, 199, 504, 3330, 73, 411, 73, 14, 1208, 14, 1313, 492, 603, 63, 6243, 199, 504, 3330, 73, 411, 73, 14, 1208, 14, 2921, 492, 3105, 199, 504, 3330, 73, 411, 73, 14, 6410, 14, 25888, 492, 598, 2252, 1938, 361, 199, 504, 3330, 73, 411, 73, 14, 11582, 14, 3911, 492, 1056, 12, 1177, 199, 893, 26, 272, 492, 485, 2520, 73, 411, 73, 14, 21071, 465, 20899, 199, 2590, 26, 272, 986, 199, 199, 18341, 275, 942, 199, 199, 533, 653, 1905, 21071, 8, 39, 2252, 1938, 361, 304, 272, 347, 636, 826, 721, 277, 304, 267, 598, 2252, 1938, 361, 855, 826, 721, 277, 12, 13470, 9, 267, 291, 14, 3790, 275, 1425, 8, 1477, 9, 267, 291, 14, 1932, 63, 585, 275, 715, 267, 291, 14, 1932, 63, 1593, 275, 715, 267, 291, 14, 21918, 63, 2758, 275, 942, 267, 291, 14, 21918, 63, 3958, 275, 942, 5493, 347, 636, 495, 721, 277, 304, 267, 372, 298, 21071, 2, 2286, 347, 1050, 21071, 8, 277, 12, 9877, 12, 30279, 12, 1862, 304, 267, 30279, 275, 1109, 8, 21918, 9, 267, 1862, 275, 1862, 14, 1294, 480, 6099, 267, 2562, 275, 1862, 59, 16, 1055, 2325, 342, 267, 340, 2562, 508, 298, 262, 582, 288, 2562, 275, 20899, 14, 568, 267, 916, 2562, 508, 298, 548, 582, 288, 2562, 275, 20899, 14, 1877, 267, 587, 26, 288, 746, 2186, 480, 5912, 805, 531, 2728, 574, 275, 446, 17, 267, 340, 822, 8, 1162, 9, 690, 413, 26, 288, 574, 275, 1109, 8, 1162, 59, 17, 566, 267, 9877, 14, 740, 6333, 21918, 582, 30279, 12, 298, 1532, 582, 2562, 12, 298, 585, 582, 574, 1552, 2286, 347, 1050, 21071, 8555, 8, 277, 12, 30279, 12, 1862, 304, 267, 291, 14, 525, 21071, 8, 277, 14, 21918, 63, 2758, 12, 30279, 12, 1862, 9, 5493, 347, 1050, 21071, 9637, 8, 277, 12, 30279, 12, 1862, 304, 267, 291, 14, 525, 21071, 8, 277, 14, 21918, 63, 3958, 12, 30279, 12, 1862, 9, 5493, 347, 1050, 8555, 83, 8, 277, 12, 486, 1038, 736, 304, 267, 367, 334, 21918, 12, 1862, 9, 315, 486, 1038, 736, 26, 288, 291, 14, 525, 21071, 8555, 8, 21918, 12, 1862, 9, 339, 347, 1050, 497, 2193, 8, 277, 12, 486, 1038, 736, 304, 267, 367, 334, 21918, 12, 1862, 9, 315, 486, 1038, 736, 26, 288, 291, 14, 525, 21071, 9637, 8, 21918, 12, 1862, 9, 2286, 347, 3272, 8, 277, 304, 267, 367, 486, 315, 291, 14, 21918, 63, 2758, 26, 288, 30279, 275, 486, 905, 21918, 937, 288, 3105, 480, 8555, 20899, 450, 68, 2, 450, 30279, 9, 288, 20899, 14, 409, 3481, 8, 21918, 12, 486, 905, 1532, 3135, 288, 340, 486, 905, 585, 937, 2356, 378, 436, 20899, 14, 362, 3481, 8, 21918, 9, 508, 20899, 14, 1877, 26, 355, 20899, 14, 25888, 3534, 8, 21918, 12, 486, 905, 585, 3135, 2286, 347, 4002, 8, 277, 304, 267, 367, 486, 315, 291, 14, 21918, 63, 3958, 26, 288, 30279, 275, 486, 905, 21918, 937, 288, 3105, 480, 9637, 20899, 450, 68, 2, 450, 30279, 9, 288, 20899, 14, 409, 3481, 8, 21918, 12, 486, 905, 1532, 3135, 288, 340, 486, 905, 585, 937, 2356, 378, 436, 20899, 14, 362, 3481, 8, 21918, 9, 508, 20899, 14, 1877, 26, 355, 20899, 14, 25888, 3534, 8, 21918, 12, 486, 905, 585, 3135, 5493, 347, 1104, 32660, 5358, 920, 2315, 8, 277, 12, 3623, 304, 267, 340, 440, 3623, 315, 291, 14, 3790, 26, 288, 746, 20899, 14, 3364, 5358, 1726, 480, 5358, 450, 68, 365, 440, 4370, 2, 450, 3623, 9, 5493, 347, 1104, 6564, 316, 3481, 16070, 8, 277, 304, 267, 340, 440, 291, 14, 1932, 63, 1593, 26, 288, 746, 1722, 480, 4030, 316, 805, 370, 5438, 20899, 440, 4370, 531, 2286, 347, 1104, 6564, 316, 1110, 16070, 8, 277, 304, 267, 340, 440, 291, 14, 1932, 63, 585, 26, 288, 746, 1722, 480, 4030, 316, 574, 370, 5438, 20899, 440, 4370, 531, 2286, 347, 636, 25888, 3284, 721, 277, 12, 3623, 304, 267, 291, 14, 1074, 32660, 5358, 920, 2315, 8, 2775, 9, 267, 372, 20899, 14, 25888, 3284, 8, 2775, 9, 2286, 347, 636, 25888, 3534, 721, 277, 12, 3623, 12, 574, 304, 267, 291, 14, 1074, 32660, 5358, 920, 2315, 8, 2775, 9, 267, 291, 14, 1074, 6564, 316, 1110, 16070, 342, 267, 20899, 14, 25888, 3534, 8, 2775, 12, 574, 9, 339, 347, 636, 362, 3481, 721, 277, 12, 3623, 304, 267, 291, 14, 1074, 32660, 5358, 920, 2315, 8, 2775, 9, 267, 372, 20899, 14, 362, 3481, 8, 2775, 9, 2286, 347, 636, 409, 3481, 721, 277, 12, 3623, 12, 574, 304, 267, 291, 14, 1074, 32660, 5358, 920, 2315, 8, 2775, 9, 267, 291, 14, 1074, 6564, 316, 3481, 16070, 342, 267, 20899, 14, 409, 3481, 8, 2775, 12, 574, 9, 5493, 347, 636, 719, 3284, 721, 277, 304, 267, 574, 275, 378, 267, 367, 284, 315, 291, 14, 3790, 26, 288, 574, 8901, 20899, 14, 25888, 3284, 8, 73, 9, 5213, 284, 267, 372, 574, 221, 15567, 347, 636, 719, 3534, 721, 277, 12, 574, 304, 267, 340, 822, 8, 277, 14, 3790, 9, 665, 13470, 26, 288, 367 ]
[ 257, 1898, 6029, 13, 6965, 662, 1567, 510, 502, 75, 446, 22621, 2133, 14, 957, 199, 3, 199, 3, 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 257, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 257, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 755, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 257, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 257, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 257, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 257, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 257, 4204, 1334, 314, 844, 14, 199, 199, 504, 3330, 73, 411, 73, 14, 1208, 14, 1313, 492, 603, 63, 6243, 199, 504, 3330, 73, 411, 73, 14, 1208, 14, 2921, 492, 3105, 199, 504, 3330, 73, 411, 73, 14, 6410, 14, 25888, 492, 598, 2252, 1938, 361, 199, 504, 3330, 73, 411, 73, 14, 11582, 14, 3911, 492, 1056, 12, 1177, 199, 893, 26, 272, 492, 485, 2520, 73, 411, 73, 14, 21071, 465, 20899, 199, 2590, 26, 272, 986, 199, 199, 18341, 275, 942, 199, 199, 533, 653, 1905, 21071, 8, 39, 2252, 1938, 361, 304, 272, 347, 636, 826, 721, 277, 304, 267, 598, 2252, 1938, 361, 855, 826, 721, 277, 12, 13470, 9, 267, 291, 14, 3790, 275, 1425, 8, 1477, 9, 267, 291, 14, 1932, 63, 585, 275, 715, 267, 291, 14, 1932, 63, 1593, 275, 715, 267, 291, 14, 21918, 63, 2758, 275, 942, 267, 291, 14, 21918, 63, 3958, 275, 942, 5493, 347, 636, 495, 721, 277, 304, 267, 372, 298, 21071, 2, 2286, 347, 1050, 21071, 8, 277, 12, 9877, 12, 30279, 12, 1862, 304, 267, 30279, 275, 1109, 8, 21918, 9, 267, 1862, 275, 1862, 14, 1294, 480, 6099, 267, 2562, 275, 1862, 59, 16, 1055, 2325, 342, 267, 340, 2562, 508, 298, 262, 582, 288, 2562, 275, 20899, 14, 568, 267, 916, 2562, 508, 298, 548, 582, 288, 2562, 275, 20899, 14, 1877, 267, 587, 26, 288, 746, 2186, 480, 5912, 805, 531, 2728, 574, 275, 446, 17, 267, 340, 822, 8, 1162, 9, 690, 413, 26, 288, 574, 275, 1109, 8, 1162, 59, 17, 566, 267, 9877, 14, 740, 6333, 21918, 582, 30279, 12, 298, 1532, 582, 2562, 12, 298, 585, 582, 574, 1552, 2286, 347, 1050, 21071, 8555, 8, 277, 12, 30279, 12, 1862, 304, 267, 291, 14, 525, 21071, 8, 277, 14, 21918, 63, 2758, 12, 30279, 12, 1862, 9, 5493, 347, 1050, 21071, 9637, 8, 277, 12, 30279, 12, 1862, 304, 267, 291, 14, 525, 21071, 8, 277, 14, 21918, 63, 3958, 12, 30279, 12, 1862, 9, 5493, 347, 1050, 8555, 83, 8, 277, 12, 486, 1038, 736, 304, 267, 367, 334, 21918, 12, 1862, 9, 315, 486, 1038, 736, 26, 288, 291, 14, 525, 21071, 8555, 8, 21918, 12, 1862, 9, 339, 347, 1050, 497, 2193, 8, 277, 12, 486, 1038, 736, 304, 267, 367, 334, 21918, 12, 1862, 9, 315, 486, 1038, 736, 26, 288, 291, 14, 525, 21071, 9637, 8, 21918, 12, 1862, 9, 2286, 347, 3272, 8, 277, 304, 267, 367, 486, 315, 291, 14, 21918, 63, 2758, 26, 288, 30279, 275, 486, 905, 21918, 937, 288, 3105, 480, 8555, 20899, 450, 68, 2, 450, 30279, 9, 288, 20899, 14, 409, 3481, 8, 21918, 12, 486, 905, 1532, 3135, 288, 340, 486, 905, 585, 937, 2356, 378, 436, 20899, 14, 362, 3481, 8, 21918, 9, 508, 20899, 14, 1877, 26, 355, 20899, 14, 25888, 3534, 8, 21918, 12, 486, 905, 585, 3135, 2286, 347, 4002, 8, 277, 304, 267, 367, 486, 315, 291, 14, 21918, 63, 3958, 26, 288, 30279, 275, 486, 905, 21918, 937, 288, 3105, 480, 9637, 20899, 450, 68, 2, 450, 30279, 9, 288, 20899, 14, 409, 3481, 8, 21918, 12, 486, 905, 1532, 3135, 288, 340, 486, 905, 585, 937, 2356, 378, 436, 20899, 14, 362, 3481, 8, 21918, 9, 508, 20899, 14, 1877, 26, 355, 20899, 14, 25888, 3534, 8, 21918, 12, 486, 905, 585, 3135, 5493, 347, 1104, 32660, 5358, 920, 2315, 8, 277, 12, 3623, 304, 267, 340, 440, 3623, 315, 291, 14, 3790, 26, 288, 746, 20899, 14, 3364, 5358, 1726, 480, 5358, 450, 68, 365, 440, 4370, 2, 450, 3623, 9, 5493, 347, 1104, 6564, 316, 3481, 16070, 8, 277, 304, 267, 340, 440, 291, 14, 1932, 63, 1593, 26, 288, 746, 1722, 480, 4030, 316, 805, 370, 5438, 20899, 440, 4370, 531, 2286, 347, 1104, 6564, 316, 1110, 16070, 8, 277, 304, 267, 340, 440, 291, 14, 1932, 63, 585, 26, 288, 746, 1722, 480, 4030, 316, 574, 370, 5438, 20899, 440, 4370, 531, 2286, 347, 636, 25888, 3284, 721, 277, 12, 3623, 304, 267, 291, 14, 1074, 32660, 5358, 920, 2315, 8, 2775, 9, 267, 372, 20899, 14, 25888, 3284, 8, 2775, 9, 2286, 347, 636, 25888, 3534, 721, 277, 12, 3623, 12, 574, 304, 267, 291, 14, 1074, 32660, 5358, 920, 2315, 8, 2775, 9, 267, 291, 14, 1074, 6564, 316, 1110, 16070, 342, 267, 20899, 14, 25888, 3534, 8, 2775, 12, 574, 9, 339, 347, 636, 362, 3481, 721, 277, 12, 3623, 304, 267, 291, 14, 1074, 32660, 5358, 920, 2315, 8, 2775, 9, 267, 372, 20899, 14, 362, 3481, 8, 2775, 9, 2286, 347, 636, 409, 3481, 721, 277, 12, 3623, 12, 574, 304, 267, 291, 14, 1074, 32660, 5358, 920, 2315, 8, 2775, 9, 267, 291, 14, 1074, 6564, 316, 3481, 16070, 342, 267, 20899, 14, 409, 3481, 8, 2775, 12, 574, 9, 5493, 347, 636, 719, 3284, 721, 277, 304, 267, 574, 275, 378, 267, 367, 284, 315, 291, 14, 3790, 26, 288, 574, 8901, 20899, 14, 25888, 3284, 8, 73, 9, 5213, 284, 267, 372, 574, 221, 15567, 347, 636, 719, 3534, 721, 277, 12, 574, 304, 267, 340, 822, 8, 277, 14, 3790, 9, 665, 13470, 26, 288, 367, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
lakshayg/tensorflow
tensorflow/python/tools/freeze_graph.py
25
13000
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== r"""Converts checkpoint variables into Const ops in a standalone GraphDef file. This script is designed to take a GraphDef proto, a SaverDef proto, and a set of variable values stored in a checkpoint file, and output a GraphDef with all of the variable ops converted into const ops containing the values of the variables. It's useful to do this when we need to load a single file in C++, especially in environments like mobile or embedded where we may not have access to the RestoreTensor ops and file loading calls that they rely on. An example of command-line usage is: bazel build tensorflow/python/tools:freeze_graph && \ bazel-bin/tensorflow/python/tools/freeze_graph \ --input_graph=some_graph_def.pb \ --input_checkpoint=model.ckpt-8361242 \ --output_graph=/tmp/frozen_graph.pb --output_node_names=softmax You can also look at freeze_graph_test.py for an example of how to use it. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import argparse import sys from google.protobuf import text_format from tensorflow.core.framework import graph_pb2 from tensorflow.core.protobuf import saver_pb2 from tensorflow.core.protobuf.meta_graph_pb2 import MetaGraphDef from tensorflow.python import pywrap_tensorflow from tensorflow.python.client import session from tensorflow.python.framework import graph_util from tensorflow.python.framework import importer from tensorflow.python.platform import app from tensorflow.python.platform import gfile from tensorflow.python.saved_model import loader from tensorflow.python.saved_model import tag_constants from tensorflow.python.tools import saved_model_utils from tensorflow.python.training import saver as saver_lib FLAGS = None def freeze_graph_with_def_protos(input_graph_def, input_saver_def, input_checkpoint, output_node_names, restore_op_name, filename_tensor_name, output_graph, clear_devices, initializer_nodes, variable_names_whitelist="", variable_names_blacklist="", input_meta_graph_def=None, input_saved_model_dir=None, saved_model_tags=None): """Converts all variables in a graph and checkpoint into constants.""" del restore_op_name, filename_tensor_name # Unused by updated loading code. # 'input_checkpoint' may be a prefix if we're using Saver V2 format if (not input_saved_model_dir and not saver_lib.checkpoint_exists(input_checkpoint)): print("Input checkpoint '" + input_checkpoint + "' doesn't exist!") return -1 if not output_node_names: print("You need to supply the name of a node to --output_node_names.") return -1 # Remove all the explicit device specifications for this node. This helps to # make the graph more portable. if clear_devices: if input_meta_graph_def: for node in input_meta_graph_def.graph_def.node: node.device = "" elif input_graph_def: for node in input_graph_def.node: node.device = "" if input_graph_def: _ = importer.import_graph_def(input_graph_def, name="") with session.Session() as sess: if input_saver_def: saver = saver_lib.Saver(saver_def=input_saver_def) saver.restore(sess, input_checkpoint) elif input_meta_graph_def: restorer = saver_lib.import_meta_graph( input_meta_graph_def, clear_devices=True) restorer.restore(sess, input_checkpoint) if initializer_nodes: sess.run(initializer_nodes.split(",")) elif input_saved_model_dir: if saved_model_tags is None: saved_model_tags = [] loader.load(sess, saved_model_tags, input_saved_model_dir) else: var_list = {} reader = pywrap_tensorflow.NewCheckpointReader(input_checkpoint) var_to_shape_map = reader.get_variable_to_shape_map() for key in var_to_shape_map: try: tensor = sess.graph.get_tensor_by_name(key + ":0") except KeyError: # This tensor doesn't exist in the graph (for example it's # 'global_step' or a similar housekeeping element) so skip it. continue var_list[key] = tensor saver = saver_lib.Saver(var_list=var_list) saver.restore(sess, input_checkpoint) if initializer_nodes: sess.run(initializer_nodes.split(",")) variable_names_whitelist = (variable_names_whitelist.split(",") if variable_names_whitelist else None) variable_names_blacklist = (variable_names_blacklist.split(",") if variable_names_blacklist else None) if input_meta_graph_def: output_graph_def = graph_util.convert_variables_to_constants( sess, input_meta_graph_def.graph_def, output_node_names.split(","), variable_names_whitelist=variable_names_whitelist, variable_names_blacklist=variable_names_blacklist) else: output_graph_def = graph_util.convert_variables_to_constants( sess, input_graph_def, output_node_names.split(","), variable_names_whitelist=variable_names_whitelist, variable_names_blacklist=variable_names_blacklist) # Write GraphDef to file if output path has been given. if output_graph: with gfile.GFile(output_graph, "wb") as f: f.write(output_graph_def.SerializeToString()) return output_graph_def def _parse_input_graph_proto(input_graph, input_binary): """Parser input tensorflow graph into GraphDef proto.""" if not gfile.Exists(input_graph): print("Input graph file '" + input_graph + "' does not exist!") return -1 input_graph_def = graph_pb2.GraphDef() mode = "rb" if input_binary else "r" with gfile.FastGFile(input_graph, mode) as f: if input_binary: input_graph_def.ParseFromString(f.read()) else: text_format.Merge(f.read(), input_graph_def) return input_graph_def def _parse_input_meta_graph_proto(input_graph, input_binary): """Parser input tensorflow graph into MetaGraphDef proto.""" if not gfile.Exists(input_graph): print("Input meta graph file '" + input_graph + "' does not exist!") return -1 input_meta_graph_def = MetaGraphDef() mode = "rb" if input_binary else "r" with gfile.FastGFile(input_graph, mode) as f: if input_binary: input_meta_graph_def.ParseFromString(f.read()) else: text_format.Merge(f.read(), input_meta_graph_def) print("Loaded meta graph file '" + input_graph) return input_meta_graph_def def _parse_input_saver_proto(input_saver, input_binary): """Parser input tensorflow Saver into SaverDef proto.""" if not gfile.Exists(input_saver): print("Input saver file '" + input_saver + "' does not exist!") return -1 mode = "rb" if input_binary else "r" with gfile.FastGFile(input_saver, mode) as f: saver_def = saver_pb2.SaverDef() if input_binary: saver_def.ParseFromString(f.read()) else: text_format.Merge(f.read(), saver_def) return saver_def def freeze_graph(input_graph, input_saver, input_binary, input_checkpoint, output_node_names, restore_op_name, filename_tensor_name, output_graph, clear_devices, initializer_nodes, variable_names_whitelist="", variable_names_blacklist="", input_meta_graph=None, input_saved_model_dir=None, saved_model_tags=tag_constants.SERVING): """Converts all variables in a graph and checkpoint into constants.""" input_graph_def = None if input_saved_model_dir: input_graph_def = saved_model_utils.get_meta_graph_def( input_saved_model_dir, saved_model_tags).graph_def elif input_graph: input_graph_def = _parse_input_graph_proto(input_graph, input_binary) input_meta_graph_def = None if input_meta_graph: input_meta_graph_def = _parse_input_meta_graph_proto( input_meta_graph, input_binary) input_saver_def = None if input_saver: input_saver_def = _parse_input_saver_proto(input_saver, input_binary) freeze_graph_with_def_protos( input_graph_def, input_saver_def, input_checkpoint, output_node_names, restore_op_name, filename_tensor_name, output_graph, clear_devices, initializer_nodes, variable_names_whitelist, variable_names_blacklist, input_meta_graph_def, input_saved_model_dir, saved_model_tags.split(",")) def main(unused_args): freeze_graph(FLAGS.input_graph, FLAGS.input_saver, FLAGS.input_binary, FLAGS.input_checkpoint, FLAGS.output_node_names, FLAGS.restore_op_name, FLAGS.filename_tensor_name, FLAGS.output_graph, FLAGS.clear_devices, FLAGS.initializer_nodes, FLAGS.variable_names_whitelist, FLAGS.variable_names_blacklist, FLAGS.input_meta_graph, FLAGS.input_saved_model_dir, FLAGS.saved_model_tags) if __name__ == "__main__": parser = argparse.ArgumentParser() parser.register("type", "bool", lambda v: v.lower() == "true") parser.add_argument( "--input_graph", type=str, default="", help="TensorFlow \'GraphDef\' file to load.") parser.add_argument( "--input_saver", type=str, default="", help="TensorFlow saver file to load.") parser.add_argument( "--input_checkpoint", type=str, default="", help="TensorFlow variables file to load.") parser.add_argument( "--output_graph", type=str, default="", help="Output \'GraphDef\' file name.") parser.add_argument( "--input_binary", nargs="?", const=True, type="bool", default=False, help="Whether the input files are in binary format.") parser.add_argument( "--output_node_names", type=str, default="", help="The name of the output nodes, comma separated.") parser.add_argument( "--restore_op_name", type=str, default="save/restore_all", help="""\ The name of the master restore operator. Deprecated, unused by updated \ loading code. """) parser.add_argument( "--filename_tensor_name", type=str, default="save/Const:0", help="""\ The name of the tensor holding the save path. Deprecated, unused by \ updated loading code. """) parser.add_argument( "--clear_devices", nargs="?", const=True, type="bool", default=True, help="Whether to remove device specifications.") parser.add_argument( "--initializer_nodes", type=str, default="", help="Comma separated list of initializer nodes to run before freezing.") parser.add_argument( "--variable_names_whitelist", type=str, default="", help="""\ Comma separated list of variables to convert to constants. If specified, \ only those variables will be converted to constants.\ """) parser.add_argument( "--variable_names_blacklist", type=str, default="", help="""\ Comma separated list of variables to skip converting to constants.\ """) parser.add_argument( "--input_meta_graph", type=str, default="", help="TensorFlow \'MetaGraphDef\' file to load.") parser.add_argument( "--input_saved_model_dir", type=str, default="", help="Path to the dir with TensorFlow \'SavedModel\' file and variables.") parser.add_argument( "--saved_model_tags", type=str, default="serve", help="""\ Group of tag(s) of the MetaGraphDef to load, in string format,\ separated by \',\'. For tag-set contains multiple tags, all tags \ must be passed in.\ """) FLAGS, unparsed = parser.parse_known_args() app.run(main=main, argv=[sys.argv[0]] + unparsed)
apache-2.0
[ 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 82, 624, 17729, 9997, 2860, 1901, 13435, 4156, 315, 282, 18042, 11513, 6172, 570, 14, 199, 199, 2765, 2884, 365, 19829, 370, 5452, 282, 11513, 6172, 4104, 12, 282, 428, 28396, 6172, 4104, 12, 436, 282, 663, 402, 199, 1975, 1338, 5489, 315, 282, 9997, 570, 12, 436, 1072, 282, 11513, 6172, 543, 1006, 402, 199, 1589, 1750, 4156, 6702, 1901, 950, 4156, 3035, 314, 1338, 402, 314, 199, 3669, 14, 199, 199, 7940, 1159, 2997, 370, 886, 642, 1380, 781, 1929, 370, 2248, 282, 2849, 570, 315, 445, 4176, 12, 24002, 315, 199, 26411, 2839, 21305, 503, 12169, 2382, 781, 1443, 440, 1172, 2879, 370, 314, 199, 21012, 3861, 4156, 436, 570, 8697, 4882, 626, 2985, 19687, 641, 14, 199, 199, 2493, 2893, 402, 1414, 13, 604, 4503, 365, 26, 199, 6185, 352, 1900, 3228, 15, 1548, 15, 2537, 26, 18459, 63, 2180, 10883, 971, 199, 6185, 352, 13, 1393, 15, 16008, 15, 1548, 15, 2537, 15, 18459, 63, 2180, 971, 199, 306, 1210, 63, 2180, 29, 3972, 63, 2180, 63, 318, 14, 3317, 971, 199, 306, 1210, 63, 10109, 29, 1238, 14, 24462, 13, 32283, 713, 2260, 971, 199, 306, 1199, 63, 2180, 13043, 2791, 15, 11202, 63, 2180, 14, 3317, 1553, 1199, 63, 932, 63, 1247, 29, 16395, 199, 199, 5556, 883, 2597, 3648, 737, 22778, 63, 2180, 63, 396, 14, 647, 367, 376, 2893, 402, 4212, 370, 675, 652, 14, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 7534, 199, 646, 984, 199, 199, 504, 6233, 14, 7204, 492, 1318, 63, 908, 199, 199, 504, 3228, 14, 1018, 14, 4857, 492, 3343, 63, 3317, 18, 199, 504, 3228, 14, 1018, 14, 7204, 492, 17559, 63, 3317, 18, 199, 504, 3228, 14, 1018, 14, 7204, 14, 2024, 63, 2180, 63, 3317, 18, 492, 6288, 31725, 199, 504, 3228, 14, 1548, 492, 1134, 3823, 63, 16008, 199, 504, 3228, 14, 1548, 14, 1258, 492, 2351, 199, 504, 3228, 14, 1548, 14, 4857, 492, 3343, 63, 1974, 199, 504, 3228, 14, 1548, 14, 4857, 492, 13479, 199, 504, 3228, 14, 1548, 14, 3246, 492, 1145, 199, 504, 3228, 14, 1548, 14, 3246, 492, 26532, 199, 504, 3228, 14, 1548, 14, 8420, 63, 1238, 492, 5077, 199, 504, 3228, 14, 1548, 14, 8420, 63, 1238, 492, 1947, 63, 5559, 199, 504, 3228, 14, 1548, 14, 2537, 492, 6290, 63, 1238, 63, 1208, 199, 504, 3228, 14, 1548, 14, 7588, 492, 17559, 465, 17559, 63, 773, 199, 199, 4831, 275, 488, 421, 199, 318, 22778, 63, 2180, 63, 1045, 63, 318, 63, 27478, 8, 1210, 63, 2180, 63, 318, 12, 639, 1324, 63, 21166, 63, 318, 12, 639, 1324, 63, 10109, 12, 639, 1072, 63, 932, 63, 1247, 12, 639, 9066, 63, 411, 63, 354, 12, 639, 1788, 63, 3128, 63, 354, 12, 639, 1072, 63, 2180, 12, 639, 5436, 63, 6410, 12, 639, 11130, 63, 2415, 12, 639, 1750, 63, 1247, 63, 14189, 8772, 639, 1750, 63, 1247, 63, 22126, 8772, 639, 1324, 63, 2024, 63, 2180, 63, 318, 29, 403, 12, 639, 1324, 63, 8420, 63, 1238, 63, 694, 29, 403, 12, 639, 6290, 63, 1238, 63, 2969, 29, 403, 304, 523, 408, 17729, 1006, 2860, 315, 282, 3343, 436, 9997, 1901, 5262, 1041, 523, 2150, 9066, 63, 411, 63, 354, 12, 1788, 63, 3128, 63, 354, 221, 327, 1910, 2972, 701, 4588, 8697, 1233, 14, 819, 327, 283, 1210, 63, 10109, 7, 1443, 506, 282, 2403, 340, 781, 3984, 1808, 428, 28396, 812, 18, 1475, 523, 340, 334, 1397, 1324, 63, 8420, 63, 1238, 63, 694, 436, 489, 440, 17559, 63, 773, 14, 10109, 63, 2444, 8, 1210, 63, 10109, 2298, 272, 870, 480, 3205, 9997, 5522, 435, 1324, 63, 10109, 435, 3546, 3181, 1133, 2187, 9124, 272, 372, 446, 17, 819, 340, 440, 1072, 63, 932, 63, 1247, 26, 272, 870, 480, 5556, 1929, 370, 17169, 314, 536, 402, 282, 1031, 370, 1553, 1199, 63, 932, 63, 1247, 2685, 272, 372, 446, 17, 819, 327, 5852, 1006, 314, 5027, 2243, 28754, 367, 642, 1031, 14, 961, 22577, 370, 523, 327, 1852, 314, 3343, 1655, 1844, 461, 14, 523, 340, 5436, 63, 6410, 26, 272, 340, 1324, 63, 2024, 63, 2180, 63, 318, 26, 489, 367, 1031, 315, 1324, 63, 2024, 63, 2180, 63, 318, 14, 2180, 63, 318, 14, 932, 26, 267, 1031, 14, 1782, 275, 3087, 272, 916, 1324, 63, 2180, 63, 318, 26, 489, 367, 1031, 315, 1324, 63, 2180, 63, 318, 14, 932, 26, 267, 1031, 14, 1782, 275, 3087, 819, 340, 1324, 63, 2180, 63, 318, 26, 272, 485, 275, 13479, 14, 646, 63, 2180, 63, 318, 8, 1210, 63, 2180, 63, 318, 12, 536, 18413, 523, 543, 2351, 14, 4434, 342, 465, 4043, 26, 272, 340, 1324, 63, 21166, 63, 318, 26, 489, 17559, 275, 17559, 63, 773, 14, 20829, 8, 21166, 63, 318, 29, 1210, 63, 21166, 63, 318, 9, 489, 17559, 14, 8011, 8, 5480, 12, 1324, 63, 10109, 9, 272, 916, 1324, 63, 2024, 63, 2180, 63, 318, 26, 489, 9066, 82, 275, 17559, 63, 773, 14, 646, 63, 2024, 63, 2180, 8, 881, 1324, 63, 2024, 63, 2180, 63, 318, 12, 5436, 63 ]
[ 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 82, 624, 17729, 9997, 2860, 1901, 13435, 4156, 315, 282, 18042, 11513, 6172, 570, 14, 199, 199, 2765, 2884, 365, 19829, 370, 5452, 282, 11513, 6172, 4104, 12, 282, 428, 28396, 6172, 4104, 12, 436, 282, 663, 402, 199, 1975, 1338, 5489, 315, 282, 9997, 570, 12, 436, 1072, 282, 11513, 6172, 543, 1006, 402, 199, 1589, 1750, 4156, 6702, 1901, 950, 4156, 3035, 314, 1338, 402, 314, 199, 3669, 14, 199, 199, 7940, 1159, 2997, 370, 886, 642, 1380, 781, 1929, 370, 2248, 282, 2849, 570, 315, 445, 4176, 12, 24002, 315, 199, 26411, 2839, 21305, 503, 12169, 2382, 781, 1443, 440, 1172, 2879, 370, 314, 199, 21012, 3861, 4156, 436, 570, 8697, 4882, 626, 2985, 19687, 641, 14, 199, 199, 2493, 2893, 402, 1414, 13, 604, 4503, 365, 26, 199, 6185, 352, 1900, 3228, 15, 1548, 15, 2537, 26, 18459, 63, 2180, 10883, 971, 199, 6185, 352, 13, 1393, 15, 16008, 15, 1548, 15, 2537, 15, 18459, 63, 2180, 971, 199, 306, 1210, 63, 2180, 29, 3972, 63, 2180, 63, 318, 14, 3317, 971, 199, 306, 1210, 63, 10109, 29, 1238, 14, 24462, 13, 32283, 713, 2260, 971, 199, 306, 1199, 63, 2180, 13043, 2791, 15, 11202, 63, 2180, 14, 3317, 1553, 1199, 63, 932, 63, 1247, 29, 16395, 199, 199, 5556, 883, 2597, 3648, 737, 22778, 63, 2180, 63, 396, 14, 647, 367, 376, 2893, 402, 4212, 370, 675, 652, 14, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 7534, 199, 646, 984, 199, 199, 504, 6233, 14, 7204, 492, 1318, 63, 908, 199, 199, 504, 3228, 14, 1018, 14, 4857, 492, 3343, 63, 3317, 18, 199, 504, 3228, 14, 1018, 14, 7204, 492, 17559, 63, 3317, 18, 199, 504, 3228, 14, 1018, 14, 7204, 14, 2024, 63, 2180, 63, 3317, 18, 492, 6288, 31725, 199, 504, 3228, 14, 1548, 492, 1134, 3823, 63, 16008, 199, 504, 3228, 14, 1548, 14, 1258, 492, 2351, 199, 504, 3228, 14, 1548, 14, 4857, 492, 3343, 63, 1974, 199, 504, 3228, 14, 1548, 14, 4857, 492, 13479, 199, 504, 3228, 14, 1548, 14, 3246, 492, 1145, 199, 504, 3228, 14, 1548, 14, 3246, 492, 26532, 199, 504, 3228, 14, 1548, 14, 8420, 63, 1238, 492, 5077, 199, 504, 3228, 14, 1548, 14, 8420, 63, 1238, 492, 1947, 63, 5559, 199, 504, 3228, 14, 1548, 14, 2537, 492, 6290, 63, 1238, 63, 1208, 199, 504, 3228, 14, 1548, 14, 7588, 492, 17559, 465, 17559, 63, 773, 199, 199, 4831, 275, 488, 421, 199, 318, 22778, 63, 2180, 63, 1045, 63, 318, 63, 27478, 8, 1210, 63, 2180, 63, 318, 12, 639, 1324, 63, 21166, 63, 318, 12, 639, 1324, 63, 10109, 12, 639, 1072, 63, 932, 63, 1247, 12, 639, 9066, 63, 411, 63, 354, 12, 639, 1788, 63, 3128, 63, 354, 12, 639, 1072, 63, 2180, 12, 639, 5436, 63, 6410, 12, 639, 11130, 63, 2415, 12, 639, 1750, 63, 1247, 63, 14189, 8772, 639, 1750, 63, 1247, 63, 22126, 8772, 639, 1324, 63, 2024, 63, 2180, 63, 318, 29, 403, 12, 639, 1324, 63, 8420, 63, 1238, 63, 694, 29, 403, 12, 639, 6290, 63, 1238, 63, 2969, 29, 403, 304, 523, 408, 17729, 1006, 2860, 315, 282, 3343, 436, 9997, 1901, 5262, 1041, 523, 2150, 9066, 63, 411, 63, 354, 12, 1788, 63, 3128, 63, 354, 221, 327, 1910, 2972, 701, 4588, 8697, 1233, 14, 819, 327, 283, 1210, 63, 10109, 7, 1443, 506, 282, 2403, 340, 781, 3984, 1808, 428, 28396, 812, 18, 1475, 523, 340, 334, 1397, 1324, 63, 8420, 63, 1238, 63, 694, 436, 489, 440, 17559, 63, 773, 14, 10109, 63, 2444, 8, 1210, 63, 10109, 2298, 272, 870, 480, 3205, 9997, 5522, 435, 1324, 63, 10109, 435, 3546, 3181, 1133, 2187, 9124, 272, 372, 446, 17, 819, 340, 440, 1072, 63, 932, 63, 1247, 26, 272, 870, 480, 5556, 1929, 370, 17169, 314, 536, 402, 282, 1031, 370, 1553, 1199, 63, 932, 63, 1247, 2685, 272, 372, 446, 17, 819, 327, 5852, 1006, 314, 5027, 2243, 28754, 367, 642, 1031, 14, 961, 22577, 370, 523, 327, 1852, 314, 3343, 1655, 1844, 461, 14, 523, 340, 5436, 63, 6410, 26, 272, 340, 1324, 63, 2024, 63, 2180, 63, 318, 26, 489, 367, 1031, 315, 1324, 63, 2024, 63, 2180, 63, 318, 14, 2180, 63, 318, 14, 932, 26, 267, 1031, 14, 1782, 275, 3087, 272, 916, 1324, 63, 2180, 63, 318, 26, 489, 367, 1031, 315, 1324, 63, 2180, 63, 318, 14, 932, 26, 267, 1031, 14, 1782, 275, 3087, 819, 340, 1324, 63, 2180, 63, 318, 26, 272, 485, 275, 13479, 14, 646, 63, 2180, 63, 318, 8, 1210, 63, 2180, 63, 318, 12, 536, 18413, 523, 543, 2351, 14, 4434, 342, 465, 4043, 26, 272, 340, 1324, 63, 21166, 63, 318, 26, 489, 17559, 275, 17559, 63, 773, 14, 20829, 8, 21166, 63, 318, 29, 1210, 63, 21166, 63, 318, 9, 489, 17559, 14, 8011, 8, 5480, 12, 1324, 63, 10109, 9, 272, 916, 1324, 63, 2024, 63, 2180, 63, 318, 26, 489, 9066, 82, 275, 17559, 63, 773, 14, 646, 63, 2024, 63, 2180, 8, 881, 1324, 63, 2024, 63, 2180, 63, 318, 12, 5436, 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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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 ]
xen0l/ansible
lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager.py
12
22222
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright (C) 2017 Google # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # ---------------------------------------------------------------------------- # # *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** # # ---------------------------------------------------------------------------- # # This file is automatically generated by Magic Modules and manual # changes will be clobbered when the file is regenerated. # # Please read more about how to change this file at # https://www.github.com/GoogleCloudPlatform/magic-modules # # ---------------------------------------------------------------------------- from __future__ import absolute_import, division, print_function __metaclass__ = type ################################################################################ # Documentation ################################################################################ ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: gcp_compute_instance_group_manager description: - Creates a managed instance group using the information that you specify in the request. After the group is created, it schedules an action to create instances in the group using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances. - A managed instance group can have up to 1000 VM instances per group. short_description: Creates a GCP InstanceGroupManager version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 - requests >= 2.18.4 - google-auth >= 1.3.0 options: state: description: - Whether the given object should exist in GCP choices: ['present', 'absent'] default: 'present' base_instance_name: description: - The base instance name to use for instances in this group. The value must be 1-58 characters long. Instances are named by appending a hyphen and a random four-character string to the base instance name. - The base instance name must comply with RFC1035. required: true description: description: - An optional description of this resource. Provide this property when you create the resource. required: false instance_template: description: - The instance template that is specified for this managed instance group. The group uses this template to create all new instances in the managed instance group. required: true name: description: - The name of the managed instance group. The name must be 1-63 characters long, and comply with RFC1035. required: true named_ports: description: - Named ports configured for the Instance Groups complementary to this Instance Group Manager. required: false suboptions: name: description: - The name for this named port. The name must be 1-63 characters long, and comply with RFC1035. required: false port: description: - The port number, which can be a value between 1 and 65535. required: false target_pools: description: - TargetPool resources to which instances in the instanceGroup field are added. The target pools automatically apply to all of the instances in the managed instance group. required: false target_size: description: - The target number of running instances for this managed instance group. Deleting or abandoning instances reduces this number. Resizing the group changes this number. required: false zone: description: - The zone the managed instance group resides. required: true extends_documentation_fragment: gcp ''' EXAMPLES = ''' - name: create a network gcp_compute_network: name: "network-instancetemplate" project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" state: present register: network - name: create a address gcp_compute_address: name: "address-instancetemplate" region: us-west1 project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" state: present register: address - name: create a instance template gcp_compute_instance_template: name: "{{ resource_name }}" properties: disks: - auto_delete: true boot: true initialize_params: source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts machine_type: n1-standard-1 network_interfaces: - network: "{{ network }}" access_configs: - name: test-config type: ONE_TO_ONE_NAT nat_ip: "{{ address }}" project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" state: present register: instancetemplate - name: create a instance group manager gcp_compute_instance_group_manager: name: "test_object" base_instance_name: test1-child instance_template: "{{ instancetemplate }}" target_size: 3 zone: us-west1-a project: "test_project" auth_kind: "service_account" service_account_file: "/tmp/auth.pem" state: present ''' RETURN = ''' base_instance_name: description: - The base instance name to use for instances in this group. The value must be 1-58 characters long. Instances are named by appending a hyphen and a random four-character string to the base instance name. - The base instance name must comply with RFC1035. returned: success type: str creation_timestamp: description: - The creation timestamp for this managed instance group in RFC3339 text format. returned: success type: str current_actions: description: - The list of instance actions and the number of instances in this managed instance group that are scheduled for each of those actions. returned: success type: complex contains: abandoning: description: - The total number of instances in the managed instance group that are scheduled to be abandoned. Abandoning an instance removes it from the managed instance group without deleting it. returned: success type: int creating: description: - The number of instances in the managed instance group that are scheduled to be created or are currently being created. If the group fails to create any of these instances, it tries again until it creates the instance successfully. - If you have disabled creation retries, this field will not be populated; instead, the creatingWithoutRetries field will be populated. returned: success type: int creating_without_retries: description: - The number of instances that the managed instance group will attempt to create. The group attempts to create each instance only once. If the group fails to create any of these instances, it decreases the group's targetSize value accordingly. returned: success type: int deleting: description: - The number of instances in the managed instance group that are scheduled to be deleted or are currently being deleted. returned: success type: int none: description: - The number of instances in the managed instance group that are running and have no scheduled actions. returned: success type: int recreating: description: - The number of instances in the managed instance group that are scheduled to be recreated or are currently being being recreated. - Recreating an instance deletes the existing root persistent disk and creates a new disk from the image that is defined in the instance template. returned: success type: int refreshing: description: - The number of instances in the managed instance group that are being reconfigured with properties that do not require a restart or a recreate action. For example, setting or removing target pools for the instance. returned: success type: int restarting: description: - The number of instances in the managed instance group that are scheduled to be restarted or are currently being restarted. returned: success type: int description: description: - An optional description of this resource. Provide this property when you create the resource. returned: success type: str id: description: - A unique identifier for this resource. returned: success type: int instance_group: description: - The instance group being managed. returned: success type: dict instance_template: description: - The instance template that is specified for this managed instance group. The group uses this template to create all new instances in the managed instance group. returned: success type: dict name: description: - The name of the managed instance group. The name must be 1-63 characters long, and comply with RFC1035. returned: success type: str named_ports: description: - Named ports configured for the Instance Groups complementary to this Instance Group Manager. returned: success type: complex contains: name: description: - The name for this named port. The name must be 1-63 characters long, and comply with RFC1035. returned: success type: str port: description: - The port number, which can be a value between 1 and 65535. returned: success type: int region: description: - The region this managed instance group resides (for regional resources). returned: success type: str target_pools: description: - TargetPool resources to which instances in the instanceGroup field are added. The target pools automatically apply to all of the instances in the managed instance group. returned: success type: list target_size: description: - The target number of running instances for this managed instance group. Deleting or abandoning instances reduces this number. Resizing the group changes this number. returned: success type: int zone: description: - The zone the managed instance group resides. returned: success type: str ''' ################################################################################ # Imports ################################################################################ from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict import json import re import time ################################################################################ # Main ################################################################################ def main(): """Main function""" module = GcpModule( argument_spec=dict( state=dict(default='present', choices=['present', 'absent'], type='str'), base_instance_name=dict(required=True, type='str'), description=dict(type='str'), instance_template=dict(required=True, type='dict'), name=dict(required=True, type='str'), named_ports=dict(type='list', elements='dict', options=dict( name=dict(type='str'), port=dict(type='int') )), target_pools=dict(type='list', elements='dict'), target_size=dict(type='int'), zone=dict(required=True, type='str') ) ) if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] state = module.params['state'] kind = 'compute#instanceGroupManager' fetch = fetch_resource(module, self_link(module), kind) changed = False if fetch: if state == 'present': if is_different(module, fetch): fetch = update(module, self_link(module), kind) changed = True else: delete(module, self_link(module), kind) fetch = {} changed = True else: if state == 'present': fetch = create(module, collection(module), kind) changed = True else: fetch = {} fetch.update({'changed': changed}) module.exit_json(**fetch) def create(module, link, kind): auth = GcpSession(module, 'compute') return wait_for_operation(module, auth.post(link, resource_to_request(module))) def update(module, link, kind): auth = GcpSession(module, 'compute') return wait_for_operation(module, auth.put(link, resource_to_request(module))) def delete(module, link, kind): auth = GcpSession(module, 'compute') return wait_for_operation(module, auth.delete(link)) def resource_to_request(module): request = { u'kind': 'compute#instanceGroupManager', u'baseInstanceName': module.params.get('base_instance_name'), u'description': module.params.get('description'), u'instanceTemplate': replace_resource_dict(module.params.get(u'instance_template', {}), 'selfLink'), u'name': module.params.get('name'), u'namedPorts': InstanceGroupManagerNamedPortsArray(module.params.get('named_ports', []), module).to_request(), u'targetPools': replace_resource_dict(module.params.get('target_pools', []), 'selfLink'), u'targetSize': module.params.get('target_size') } return_vals = {} for k, v in request.items(): if v: return_vals[k] = v return return_vals def fetch_resource(module, link, kind): auth = GcpSession(module, 'compute') return return_if_object(module, auth.get(link), kind) def self_link(module): return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{name}".format(**module.params) def collection(module): return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers".format(**module.params) def return_if_object(module, response, kind): # If not found, return nothing. if response.status_code == 404: return None # If no content, return nothing. if response.status_code == 204: return None try: module.raise_for_status(response) result = response.json() except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst: module.fail_json(msg="Invalid JSON response with error: %s" % inst) if navigate_hash(result, ['error', 'errors']): module.fail_json(msg=navigate_hash(result, ['error', 'errors'])) if result['kind'] != kind: module.fail_json(msg="Incorrect result: {kind}".format(**result)) return result def is_different(module, response): request = resource_to_request(module) response = response_to_hash(module, response) # Remove all output-only from response. response_vals = {} for k, v in response.items(): if k in request: response_vals[k] = v request_vals = {} for k, v in request.items(): if k in response: request_vals[k] = v return GcpRequest(request_vals) != GcpRequest(response_vals) # Remove unnecessary properties from the response. # This is for doing comparisons with Ansible's current parameters. def response_to_hash(module, response): return { u'baseInstanceName': response.get(u'baseInstanceName'), u'creationTimestamp': response.get(u'creationTimestamp'), u'currentActions': InstanceGroupManagerCurrentActions(response.get(u'currentActions', {}), module).from_response(), u'description': module.params.get('description'), u'id': response.get(u'id'), u'instanceGroup': response.get(u'instanceGroup'), u'instanceTemplate': response.get(u'instanceTemplate'), u'name': response.get(u'name'), u'namedPorts': InstanceGroupManagerNamedPortsArray(response.get(u'namedPorts', []), module).from_response(), u'region': response.get(u'region'), u'targetPools': response.get(u'targetPools'), u'targetSize': response.get(u'targetSize') } def region_selflink(name, params): if name is None: return url = r"https://www.googleapis.com/compute/v1/projects/.*/regions/[a-z1-9\-]*" if not re.match(url, name): name = "https://www.googleapis.com/compute/v1/projects/{project}/regions/%s".format(**params) % name return name def async_op_url(module, extra_data=None): if extra_data is None: extra_data = {} url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/operations/{op_id}" combined = extra_data.copy() combined.update(module.params) return url.format(**combined) def wait_for_operation(module, response): op_result = return_if_object(module, response, 'compute#operation') if op_result is None: return {} status = navigate_hash(op_result, ['status']) wait_done = wait_for_completion(status, op_result, module) return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#instanceGroupManager') def wait_for_completion(status, op_result, module): op_id = navigate_hash(op_result, ['name']) op_uri = async_op_url(module, {'op_id': op_id}) while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) if status not in ['PENDING', 'RUNNING', 'DONE']: module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result def raise_if_errors(response, err_path, module): errors = navigate_hash(response, err_path) if errors is not None: module.fail_json(msg=errors) class InstanceGroupManagerCurrentActions(object): def __init__(self, request, module): self.module = module if request: self.request = request else: self.request = {} def to_request(self): return remove_nones_from_dict({ u'abandoning': self.request.get('abandoning'), u'creating': self.request.get('creating'), u'creatingWithoutRetries': self.request.get('creating_without_retries'), u'deleting': self.request.get('deleting'), u'none': self.request.get('none'), u'recreating': self.request.get('recreating'), u'refreshing': self.request.get('refreshing'), u'restarting': self.request.get('restarting') }) def from_response(self): return remove_nones_from_dict({ u'abandoning': self.request.get(u'abandoning'), u'creating': self.request.get(u'creating'), u'creatingWithoutRetries': self.request.get(u'creatingWithoutRetries'), u'deleting': self.request.get(u'deleting'), u'none': self.request.get(u'none'), u'recreating': self.request.get(u'recreating'), u'refreshing': self.request.get(u'refreshing'), u'restarting': self.request.get(u'restarting') }) class InstanceGroupManagerNamedPortsArray(object): def __init__(self, request, module): self.module = module if request: self.request = request else: self.request = [] def to_request(self): items = [] for item in self.request: items.append(self._request_for_item(item)) return items def from_response(self): items = [] for item in self.request: items.append(self._response_from_item(item)) return items def _request_for_item(self, item): return remove_nones_from_dict({ u'name': item.get('name'), u'port': item.get('port') }) def _response_from_item(self, item): return remove_nones_from_dict({ u'name': item.get(u'name'), u'port': item.get(u'port') }) 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, 4475, 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, 27103, 199, 3, 199, 3, 258, 19688, 258, 25420, 29087, 6989, 22547, 259, 19688, 259, 25420, 29087, 6989, 22547, 258, 19688, 199, 3, 199, 3, 27103, 199, 3, 199, 3, 258, 961, 570, 365, 5847, 4046, 701, 603, 6573, 18167, 436, 8722, 199, 3, 258, 4493, 911, 506, 286, 1191, 18897, 1380, 314, 570, 365, 31904, 14, 199, 3, 199, 3, 258, 7754, 1586, 1655, 3595, 4212, 370, 1570, 642, 570, 737, 199, 3, 258, 4178, 921, 1544, 14, 5031, 14, 957, 15, 13266, 9089, 10397, 15, 11523, 13, 3112, 199, 3, 199, 3, 27103, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 13289, 199, 3, 15249, 199, 13289, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 2097, 7780, 2255, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 22088, 63, 3357, 63, 842, 63, 923, 63, 2609, 199, 1802, 26, 272, 446, 10560, 282, 12883, 1256, 1572, 1808, 314, 2556, 626, 1265, 4165, 315, 314, 1056, 14, 489, 12836, 314, 1572, 365, 2737, 12, 652, 8732, 83, 376, 1595, 370, 1218, 4454, 315, 314, 1572, 489, 1808, 314, 2013, 1256, 1978, 14, 961, 3439, 365, 11584, 465, 577, 4817, 1380, 314, 489, 1572, 365, 2737, 2755, 340, 314, 4454, 315, 314, 1572, 1172, 440, 5966, 2757, 2737, 14, 2047, 489, 1471, 18159, 4911, 314, 2004, 402, 314, 8212, 4454, 14, 272, 446, 437, 12883, 1256, 1572, 883, 1172, 1536, 370, 5198, 7525, 4454, 1126, 1572, 14, 199, 3612, 63, 1802, 26, 10560, 282, 30902, 10066, 2448, 2988, 199, 1023, 63, 3270, 26, 499, 14, 22, 199, 2502, 26, 4475, 3277, 14, 8593, 3098, 4091, 3246, 9, 199, 7538, 26, 272, 446, 2366, 2356, 499, 14, 22, 272, 446, 4145, 2356, 499, 14, 1085, 14, 20, 272, 446, 6233, 13, 1178, 2356, 413, 14, 19, 14, 16, 199, 1419, 26, 272, 1174, 26, 267, 1369, 26, 288, 446, 7480, 314, 1627, 909, 1077, 2187, 315, 30902, 267, 3415, 26, 788, 1881, 297, 283, 5575, 418, 267, 849, 26, 283, 1881, 7, 272, 1300, 63, 842, 63, 354, 26, 267, 1369, 26, 288, 446, 710, 1300, 1256, 536, 370, 675, 367, 4454, 315, 642, 1572, 14, 710, 574, 1471, 506, 413, 13, 2010, 1598, 4110, 1846, 14, 10066, 83, 787, 4310, 701, 24373, 282, 7188, 17579, 436, 282, 2196, 11648, 13, 10856, 1598, 1059, 370, 314, 1300, 1256, 536, 14, 288, 446, 710, 1300, 1256, 536, 1471, 1013, 590, 543, 7329, 709, 1276, 14, 267, 1415, 26, 2549, 272, 1369, 26, 267, 1369, 26, 288, 446, 1626, 2716, 1369, 402, 642, 2073, 14, 22896, 642, 3324, 1380, 1265, 1218, 1598, 314, 2073, 14, 267, 1415, 26, 3055, 272, 1256, 63, 1160, 26, 267, 1369, 26, 288, 446, 710, 1256, 1978, 626, 365, 2013, 367, 642, 12883, 1256, 1572, 14, 710, 1572, 1598, 4440, 642, 1978, 370, 1218, 1006, 892, 4454, 315, 314, 12883, 1256, 1572, 14, 267, 1415, 26, 2549, 272, 536, 26, 267, 1369, 26, 288, 446, 710, 536, 402, 314, 12883, 1256, 1572, 14, 710, 536, 1471, 506, 413, 13, 2766, 4110, 1846, 12, 436, 1598, 1013, 590, 543, 7329, 709, 1276, 14, 267, 1415, 26, 2549, 272, 4310, 63, 5203, 26, 267, 1369, 26, 288, 446, 16198, 8873, 7526, 367, 314, 10066, 25031, 2831, 434, 695, 370, 642, 10066, 5611, 1598, 13537, 14, 267, 1415, 26, 3055, 267, 26265, 26, 288, 536, 26, 355, 1369, 26, 490, 446, 710, 536, 367, 642, 4310, 1844, 14, 710, 536, 1471, 506, 413, 13, 2766, 4110, 1846, 12, 436, 1013, 590, 1993, 543, 7329, 709, 1276, 14, 355, 1415, 26, 3055, 288, 1844, 26, 355, 1369, 26, 490, 446, 710, 1844, 1329, 12, 1314, 883, 506, 282, 574, 3382, 413, 436, 18247, 14, 355, 1415, 26, 3055, 272, 1347, 63, 12406, 26, 267, 1369, 26, 288, 446, 10256, 5453, 5944, 370, 1314, 4454, 315, 314, 1256, 2448, 901, 787, 3483, 14, 710, 1598, 1347, 20092, 5847, 4838, 370, 1006, 402, 314, 4454, 315, 314, 12883, 1256, 1598, 1572, 14, 267, 1415, 26, 3055, 272, 1347, 63, 890, 26, 267, 1369, 26, 288, 446, 710, 1347, 1329, 402, 3879, 4454, 367, 642, 12883, 1256, 1572, 14, 15920, 1598, 503, 2236, 460, 19718, 4454, 295, 10569, 642, 1329, 14, 799, 30639, 314, 1572, 4493, 642, 1329, 14, 267, 1415, 26, 3055, 272, 5718, 26, 267, 1369, 26, 288, 446, 710, 5718, 314, 12883, 1256, 1572, 295, 19564, 14, 267, 1415, 26, 2549, 199, 11036, 63, 9970, 63, 7677, 26, 22088, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 1218, 282, 2784, 523, 22088, 63, 3357, 63, 1200, 26, 489, 536, 26, 298, 1200, 13, 842, 1160, 2, 489, 2199, 26, 7370, 22088, 63, 1715, 7820, 489, 1790, 63, 5091, 26, 7370, 22088, 63, 18639, 63, 5091, 7820, 489, 2435, 63, 2048, 63, 493, 26, 7370, 22088, 63, 18639, 63, 493, 7820, 489, 1174, 26, 3451, 523, 2274, 26, 2784, 199, 199, 13, 536, 26, 1218, 282, 2287, 523, 22088, 63, 3357, 63, 1562, 26, 489, 536, 26, 298, 1562, 13, 842, 1160, 2, 489, 4897, 26, 2739, 13, 19082, 17, 489, 2199, 26, 7370, 22088, 63, 1715, 7820, 489, 1790, 63, 5091, 26, 7370, 22088, 63, 18639, 63, 5091, 7820, 489, 2435, 63, 2048, 63, 493, 26, 7370, 22088, 63, 18639, 63, 493, 7820, 489, 1174, 26, 3451, 523, 2274, 26, 2287, 199, 199, 13, 536, 26, 1218, 282, 1256, 1978, 523, 22088, 63, 3357, 63, 842, 63, 1160, 26, 489, 536, 26, 7370, 2073, 63, 354, 7820, 489, 4382, 26, 267, 17602, 26, 267, 446, 2599, 63, 1807, 26, 2549, 881, 8498, 26, 2549, 881 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 9708, 4475, 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, 27103, 199, 3, 199, 3, 258, 19688, 258, 25420, 29087, 6989, 22547, 259, 19688, 259, 25420, 29087, 6989, 22547, 258, 19688, 199, 3, 199, 3, 27103, 199, 3, 199, 3, 258, 961, 570, 365, 5847, 4046, 701, 603, 6573, 18167, 436, 8722, 199, 3, 258, 4493, 911, 506, 286, 1191, 18897, 1380, 314, 570, 365, 31904, 14, 199, 3, 199, 3, 258, 7754, 1586, 1655, 3595, 4212, 370, 1570, 642, 570, 737, 199, 3, 258, 4178, 921, 1544, 14, 5031, 14, 957, 15, 13266, 9089, 10397, 15, 11523, 13, 3112, 199, 3, 199, 3, 27103, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 13289, 199, 3, 15249, 199, 13289, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 2097, 7780, 2255, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 22088, 63, 3357, 63, 842, 63, 923, 63, 2609, 199, 1802, 26, 272, 446, 10560, 282, 12883, 1256, 1572, 1808, 314, 2556, 626, 1265, 4165, 315, 314, 1056, 14, 489, 12836, 314, 1572, 365, 2737, 12, 652, 8732, 83, 376, 1595, 370, 1218, 4454, 315, 314, 1572, 489, 1808, 314, 2013, 1256, 1978, 14, 961, 3439, 365, 11584, 465, 577, 4817, 1380, 314, 489, 1572, 365, 2737, 2755, 340, 314, 4454, 315, 314, 1572, 1172, 440, 5966, 2757, 2737, 14, 2047, 489, 1471, 18159, 4911, 314, 2004, 402, 314, 8212, 4454, 14, 272, 446, 437, 12883, 1256, 1572, 883, 1172, 1536, 370, 5198, 7525, 4454, 1126, 1572, 14, 199, 3612, 63, 1802, 26, 10560, 282, 30902, 10066, 2448, 2988, 199, 1023, 63, 3270, 26, 499, 14, 22, 199, 2502, 26, 4475, 3277, 14, 8593, 3098, 4091, 3246, 9, 199, 7538, 26, 272, 446, 2366, 2356, 499, 14, 22, 272, 446, 4145, 2356, 499, 14, 1085, 14, 20, 272, 446, 6233, 13, 1178, 2356, 413, 14, 19, 14, 16, 199, 1419, 26, 272, 1174, 26, 267, 1369, 26, 288, 446, 7480, 314, 1627, 909, 1077, 2187, 315, 30902, 267, 3415, 26, 788, 1881, 297, 283, 5575, 418, 267, 849, 26, 283, 1881, 7, 272, 1300, 63, 842, 63, 354, 26, 267, 1369, 26, 288, 446, 710, 1300, 1256, 536, 370, 675, 367, 4454, 315, 642, 1572, 14, 710, 574, 1471, 506, 413, 13, 2010, 1598, 4110, 1846, 14, 10066, 83, 787, 4310, 701, 24373, 282, 7188, 17579, 436, 282, 2196, 11648, 13, 10856, 1598, 1059, 370, 314, 1300, 1256, 536, 14, 288, 446, 710, 1300, 1256, 536, 1471, 1013, 590, 543, 7329, 709, 1276, 14, 267, 1415, 26, 2549, 272, 1369, 26, 267, 1369, 26, 288, 446, 1626, 2716, 1369, 402, 642, 2073, 14, 22896, 642, 3324, 1380, 1265, 1218, 1598, 314, 2073, 14, 267, 1415, 26, 3055, 272, 1256, 63, 1160, 26, 267, 1369, 26, 288, 446, 710, 1256, 1978, 626, 365, 2013, 367, 642, 12883, 1256, 1572, 14, 710, 1572, 1598, 4440, 642, 1978, 370, 1218, 1006, 892, 4454, 315, 314, 12883, 1256, 1572, 14, 267, 1415, 26, 2549, 272, 536, 26, 267, 1369, 26, 288, 446, 710, 536, 402, 314, 12883, 1256, 1572, 14, 710, 536, 1471, 506, 413, 13, 2766, 4110, 1846, 12, 436, 1598, 1013, 590, 543, 7329, 709, 1276, 14, 267, 1415, 26, 2549, 272, 4310, 63, 5203, 26, 267, 1369, 26, 288, 446, 16198, 8873, 7526, 367, 314, 10066, 25031, 2831, 434, 695, 370, 642, 10066, 5611, 1598, 13537, 14, 267, 1415, 26, 3055, 267, 26265, 26, 288, 536, 26, 355, 1369, 26, 490, 446, 710, 536, 367, 642, 4310, 1844, 14, 710, 536, 1471, 506, 413, 13, 2766, 4110, 1846, 12, 436, 1013, 590, 1993, 543, 7329, 709, 1276, 14, 355, 1415, 26, 3055, 288, 1844, 26, 355, 1369, 26, 490, 446, 710, 1844, 1329, 12, 1314, 883, 506, 282, 574, 3382, 413, 436, 18247, 14, 355, 1415, 26, 3055, 272, 1347, 63, 12406, 26, 267, 1369, 26, 288, 446, 10256, 5453, 5944, 370, 1314, 4454, 315, 314, 1256, 2448, 901, 787, 3483, 14, 710, 1598, 1347, 20092, 5847, 4838, 370, 1006, 402, 314, 4454, 315, 314, 12883, 1256, 1598, 1572, 14, 267, 1415, 26, 3055, 272, 1347, 63, 890, 26, 267, 1369, 26, 288, 446, 710, 1347, 1329, 402, 3879, 4454, 367, 642, 12883, 1256, 1572, 14, 15920, 1598, 503, 2236, 460, 19718, 4454, 295, 10569, 642, 1329, 14, 799, 30639, 314, 1572, 4493, 642, 1329, 14, 267, 1415, 26, 3055, 272, 5718, 26, 267, 1369, 26, 288, 446, 710, 5718, 314, 12883, 1256, 1572, 295, 19564, 14, 267, 1415, 26, 2549, 199, 11036, 63, 9970, 63, 7677, 26, 22088, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 1218, 282, 2784, 523, 22088, 63, 3357, 63, 1200, 26, 489, 536, 26, 298, 1200, 13, 842, 1160, 2, 489, 2199, 26, 7370, 22088, 63, 1715, 7820, 489, 1790, 63, 5091, 26, 7370, 22088, 63, 18639, 63, 5091, 7820, 489, 2435, 63, 2048, 63, 493, 26, 7370, 22088, 63, 18639, 63, 493, 7820, 489, 1174, 26, 3451, 523, 2274, 26, 2784, 199, 199, 13, 536, 26, 1218, 282, 2287, 523, 22088, 63, 3357, 63, 1562, 26, 489, 536, 26, 298, 1562, 13, 842, 1160, 2, 489, 4897, 26, 2739, 13, 19082, 17, 489, 2199, 26, 7370, 22088, 63, 1715, 7820, 489, 1790, 63, 5091, 26, 7370, 22088, 63, 18639, 63, 5091, 7820, 489, 2435, 63, 2048, 63, 493, 26, 7370, 22088, 63, 18639, 63, 493, 7820, 489, 1174, 26, 3451, 523, 2274, 26, 2287, 199, 199, 13, 536, 26, 1218, 282, 1256, 1978, 523, 22088, 63, 3357, 63, 842, 63, 1160, 26, 489, 536, 26, 7370, 2073, 63, 354, 7820, 489, 4382, 26, 267, 17602, 26, 267, 446, 2599, 63, 1807, 26, 2549, 881, 8498, 26, 2549, 881, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
dtaht/ns-3-codel-dev
doc/models/source/conf.py
21
7002
# -*- coding: utf-8 -*- # # ns-3 documentation build configuration file, created by # sphinx-quickstart on Tue Dec 14 09:00:39 2010. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.pngmath'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'ns-3' copyright = u'2011, ns-3 project' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = 'ns-3-dev' # The full version, including alpha/beta/rc tags. release = 'ns-3-dev' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = [] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # "<project> v<release> documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a <link> tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'ns-3doc' # -- Options for LaTeX output -------------------------------------------------- # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'ns-3-model-library.tex', u'ns-3 Model Library', u'ns-3 project', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Additional stuff for the LaTeX preamble. #latex_preamble = '' # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'ns-3-model-library', u'ns-3 Model Library', [u'ns-3 project'], 1) ]
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 700, 13, 19, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 377, 310, 13966, 4329, 21798, 26, 383, 26, 1355, 7129, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 12, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 3, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 4524, 3442, 418, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 7, 561, 13, 19, 7, 199, 7307, 275, 399, 7, 8128, 12, 700, 13, 19, 2199, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 283, 561, 13, 19, 13, 2374, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 561, 13, 19, 13, 2374, 7, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 942, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 9527, 2595, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 885, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 3, 1360, 63, 7915, 63, 515, 275, 942, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 12, 652, 4243, 370, 199, 3, 3886, 1715, 30, 373, 28, 3221, 30, 3794, 1674, 199, 3, 1360, 63, 1213, 275, 488, 199, 199, 3, 437, 18299, 2538, 367, 314, 19191, 4681, 14, 221, 3758, 365, 314, 2011, 465, 3517, 63, 1213, 14, 199, 3, 1360, 63, 3612, 63, 1213, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 6188, 370, 642, 2082, 9, 370, 4192, 737, 314, 2746, 199, 3, 402, 314, 18437, 14, 199, 3, 1360, 63, 9733, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 12541, 314, 2955, 931, 9, 370, 675, 465, 29139, 402, 314, 199, 3, 9149, 14, 221, 961, 570, 1077, 506, 282, 5417, 7016, 570, 17048, 12802, 9, 3769, 3193, 88, 975, 503, 4337, 88, 708, 199, 3, 11094, 7031 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 700, 13, 19, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 377, 310, 13966, 4329, 21798, 26, 383, 26, 1355, 7129, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 12, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 3, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 4524, 3442, 418, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 7, 561, 13, 19, 7, 199, 7307, 275, 399, 7, 8128, 12, 700, 13, 19, 2199, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 283, 561, 13, 19, 13, 2374, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 561, 13, 19, 13, 2374, 7, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 942, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 9527, 2595, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 885, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 3, 1360, 63, 7915, 63, 515, 275, 942, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 12, 652, 4243, 370, 199, 3, 3886, 1715, 30, 373, 28, 3221, 30, 3794, 1674, 199, 3, 1360, 63, 1213, 275, 488, 199, 199, 3, 437, 18299, 2538, 367, 314, 19191, 4681, 14, 221, 3758, 365, 314, 2011, 465, 3517, 63, 1213, 14, 199, 3, 1360, 63, 3612, 63, 1213, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 6188, 370, 642, 2082, 9, 370, 4192, 737, 314, 2746, 199, 3, 402, 314, 18437, 14, 199, 3, 1360, 63, 9733, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 12541, 314, 2955, 931, 9, 370, 675, 465, 29139, 402, 314, 199, 3, 9149, 14, 221, 961, 570, 1077, 506, 282, 5417, 7016, 570, 17048, 12802, 9, 3769, 3193, 88, 975, 503, 4337, 88, 708, 199, 3, 11094, 7031, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hguemar/cinder
cinder/db/sqlalchemy/migrate_repo/versions/032_add_volume_type_projects.py
5
2576
# 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 Boolean, Column, DateTime, UniqueConstraint from sqlalchemy import Integer, MetaData, String, Table, ForeignKey from cinder.i18n import _ from cinder.openstack.common import log as logging LOG = logging.getLogger(__name__) def upgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine volume_types = Table('volume_types', meta, autoload=True) is_public = Column('is_public', Boolean) try: volume_types.create_column(is_public) # pylint: disable=E1120 volume_types.update().values(is_public=True).execute() except Exception: LOG.error(_("Column |%s| not created!"), repr(is_public)) raise volume_type_projects = Table( 'volume_type_projects', meta, Column('id', Integer, primary_key=True, nullable=False), Column('created_at', DateTime), Column('updated_at', DateTime), Column('deleted_at', DateTime), Column('volume_type_id', String(36), ForeignKey('volume_types.id')), Column('project_id', String(length=255)), Column('deleted', Boolean(create_constraint=True, name=None)), UniqueConstraint('volume_type_id', 'project_id', 'deleted'), mysql_engine='InnoDB', ) try: volume_type_projects.create() except Exception: LOG.error(_("Table |%s| not created!"), repr(volume_type_projects)) raise def downgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine volume_types = Table('volume_types', meta, autoload=True) is_public = volume_types.columns.is_public try: volume_types.drop_column(is_public) except Exception: LOG.error(_("volume_types.is_public column not dropped")) raise volume_type_projects = Table('volume_type_projects', meta, autoload=True) try: volume_type_projects.drop() except Exception: LOG.error(_("volume_type_projects table not dropped")) raise
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, 199, 199, 504, 8335, 492, 9411, 12, 4996, 12, 13686, 12, 18276, 8463, 199, 504, 8335, 492, 7225, 12, 24905, 12, 2624, 12, 6957, 12, 12718, 199, 199, 504, 13069, 14, 73, 1085, 78, 492, 485, 199, 504, 13069, 14, 8512, 14, 2330, 492, 943, 465, 2050, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 10754, 8, 8462, 63, 3908, 304, 272, 3404, 275, 24905, 342, 272, 3404, 14, 3409, 275, 12810, 63, 3908, 272, 3301, 63, 1313, 275, 6957, 360, 2405, 63, 1313, 297, 3404, 12, 2599, 912, 29, 549, 9, 272, 365, 63, 3455, 275, 4996, 360, 374, 63, 3455, 297, 9411, 9, 339, 862, 26, 267, 3301, 63, 1313, 14, 981, 63, 2301, 8, 374, 63, 3455, 9, 267, 327, 4287, 26, 3507, 29, 37, 6094, 16, 267, 3301, 63, 1313, 14, 873, 1252, 1459, 8, 374, 63, 3455, 29, 549, 680, 2526, 342, 272, 871, 2186, 26, 267, 5051, 14, 705, 6115, 4547, 1204, 5, 83, 92, 440, 2737, 1, 1288, 4700, 8, 374, 63, 3455, 430, 267, 746, 339, 3301, 63, 466, 63, 6776, 275, 6957, 8, 267, 283, 2405, 63, 466, 63, 6776, 297, 3404, 12, 267, 4996, 360, 344, 297, 7225, 12, 5062, 63, 498, 29, 549, 12, 7854, 29, 797, 395, 267, 4996, 360, 3966, 63, 292, 297, 13686, 395, 267, 4996, 360, 5334, 63, 292, 297, 13686, 395, 267, 4996, 360, 6062, 63, 292, 297, 13686, 395, 267, 4996, 360, 2405, 63, 466, 63, 344, 297, 2624, 8, 1344, 395, 2049, 12718, 360, 2405, 63, 1313, 14, 344, 3855, 267, 4996, 360, 1715, 63, 344, 297, 2624, 8, 1267, 29, 2299, 1826, 267, 4996, 360, 6062, 297, 9411, 8, 981, 63, 5631, 29, 549, 12, 536, 29, 403, 1826, 267, 18276, 8463, 360, 2405, 63, 466, 63, 344, 297, 283, 1715, 63, 344, 297, 283, 6062, 659, 267, 12896, 63, 3908, 534, 607, 889, 2846, 297, 272, 776, 339, 862, 26, 267, 3301, 63, 466, 63, 6776, 14, 981, 342, 272, 871, 2186, 26, 267, 5051, 14, 705, 6115, 3186, 1204, 5, 83, 92, 440, 2737, 1, 1288, 4700, 8, 2405, 63, 466, 63, 6776, 430, 267, 746, 421, 199, 318, 32498, 8, 8462, 63, 3908, 304, 272, 3404, 275, 24905, 342, 272, 3404, 14, 3409, 275, 12810, 63, 3908, 339, 3301, 63, 1313, 275, 6957, 360, 2405, 63, 1313, 297, 3404, 12, 2599, 912, 29, 549, 9, 272, 365, 63, 3455, 275, 3301, 63, 1313, 14, 3406, 14, 374, 63, 3455, 272, 862, 26, 267, 3301, 63, 1313, 14, 4824, 63, 2301, 8, 374, 63, 3455, 9, 272, 871, 2186, 26, 267, 5051, 14, 705, 6115, 2405, 63, 1313, 14, 374, 63, 3455, 2763, 440, 17481, 2237, 267, 746, 339, 3301, 63, 466, 63, 6776, 275, 6957, 360, 2405, 63, 466, 63, 6776, 297, 3404, 12, 2599, 912, 29, 549, 9, 272, 862, 26, 267, 3301, 63, 466, 63, 6776, 14, 4824, 342, 272, 871, 2186, 26, 267, 5051, 14, 705, 6115, 2405, 63, 466, 63, 6776, 1817, 440, 17481, 2237, 267, 746, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 8335, 492, 9411, 12, 4996, 12, 13686, 12, 18276, 8463, 199, 504, 8335, 492, 7225, 12, 24905, 12, 2624, 12, 6957, 12, 12718, 199, 199, 504, 13069, 14, 73, 1085, 78, 492, 485, 199, 504, 13069, 14, 8512, 14, 2330, 492, 943, 465, 2050, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 10754, 8, 8462, 63, 3908, 304, 272, 3404, 275, 24905, 342, 272, 3404, 14, 3409, 275, 12810, 63, 3908, 272, 3301, 63, 1313, 275, 6957, 360, 2405, 63, 1313, 297, 3404, 12, 2599, 912, 29, 549, 9, 272, 365, 63, 3455, 275, 4996, 360, 374, 63, 3455, 297, 9411, 9, 339, 862, 26, 267, 3301, 63, 1313, 14, 981, 63, 2301, 8, 374, 63, 3455, 9, 267, 327, 4287, 26, 3507, 29, 37, 6094, 16, 267, 3301, 63, 1313, 14, 873, 1252, 1459, 8, 374, 63, 3455, 29, 549, 680, 2526, 342, 272, 871, 2186, 26, 267, 5051, 14, 705, 6115, 4547, 1204, 5, 83, 92, 440, 2737, 1, 1288, 4700, 8, 374, 63, 3455, 430, 267, 746, 339, 3301, 63, 466, 63, 6776, 275, 6957, 8, 267, 283, 2405, 63, 466, 63, 6776, 297, 3404, 12, 267, 4996, 360, 344, 297, 7225, 12, 5062, 63, 498, 29, 549, 12, 7854, 29, 797, 395, 267, 4996, 360, 3966, 63, 292, 297, 13686, 395, 267, 4996, 360, 5334, 63, 292, 297, 13686, 395, 267, 4996, 360, 6062, 63, 292, 297, 13686, 395, 267, 4996, 360, 2405, 63, 466, 63, 344, 297, 2624, 8, 1344, 395, 2049, 12718, 360, 2405, 63, 1313, 14, 344, 3855, 267, 4996, 360, 1715, 63, 344, 297, 2624, 8, 1267, 29, 2299, 1826, 267, 4996, 360, 6062, 297, 9411, 8, 981, 63, 5631, 29, 549, 12, 536, 29, 403, 1826, 267, 18276, 8463, 360, 2405, 63, 466, 63, 344, 297, 283, 1715, 63, 344, 297, 283, 6062, 659, 267, 12896, 63, 3908, 534, 607, 889, 2846, 297, 272, 776, 339, 862, 26, 267, 3301, 63, 466, 63, 6776, 14, 981, 342, 272, 871, 2186, 26, 267, 5051, 14, 705, 6115, 3186, 1204, 5, 83, 92, 440, 2737, 1, 1288, 4700, 8, 2405, 63, 466, 63, 6776, 430, 267, 746, 421, 199, 318, 32498, 8, 8462, 63, 3908, 304, 272, 3404, 275, 24905, 342, 272, 3404, 14, 3409, 275, 12810, 63, 3908, 339, 3301, 63, 1313, 275, 6957, 360, 2405, 63, 1313, 297, 3404, 12, 2599, 912, 29, 549, 9, 272, 365, 63, 3455, 275, 3301, 63, 1313, 14, 3406, 14, 374, 63, 3455, 272, 862, 26, 267, 3301, 63, 1313, 14, 4824, 63, 2301, 8, 374, 63, 3455, 9, 272, 871, 2186, 26, 267, 5051, 14, 705, 6115, 2405, 63, 1313, 14, 374, 63, 3455, 2763, 440, 17481, 2237, 267, 746, 339, 3301, 63, 466, 63, 6776, 275, 6957, 360, 2405, 63, 466, 63, 6776, 297, 3404, 12, 2599, 912, 29, 549, 9, 272, 862, 26, 267, 3301, 63, 466, 63, 6776, 14, 4824, 342, 272, 871, 2186, 26, 267, 5051, 14, 705, 6115, 2405, 63, 466, 63, 6776, 1817, 440, 17481, 2237, 267, 746, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jruiperezv/ANALYSE
lms/djangoapps/instructor_task/api_helper.py
28
13664
""" Helper lib for instructor_tasks API. Includes methods to check args for rescoring task, encoding student input, and task submission logic, including handling the Celery backend. """ import hashlib import json import logging from celery.result import AsyncResult from celery.states import READY_STATES, SUCCESS, FAILURE, REVOKED from courseware.module_render import get_xqueue_callback_url_prefix from xmodule.modulestore.django import modulestore from opaque_keys.edx.keys import UsageKey from instructor_task.models import InstructorTask, PROGRESS log = logging.getLogger(__name__) class AlreadyRunningError(Exception): """Exception indicating that a background task is already running""" pass def _task_is_running(course_id, task_type, task_key): """Checks if a particular task is already running""" running_tasks = InstructorTask.objects.filter( course_id=course_id, task_type=task_type, task_key=task_key ) # exclude states that are "ready" (i.e. not "running", e.g. failure, success, revoked): for state in READY_STATES: running_tasks = running_tasks.exclude(task_state=state) return len(running_tasks) > 0 def _reserve_task(course_id, task_type, task_key, task_input, requester): """ Creates a database entry to indicate that a task is in progress. Throws AlreadyRunningError if the task is already in progress. Includes the creation of an arbitrary value for task_id, to be submitted with the task call to celery. The InstructorTask.create method makes sure the InstructorTask entry is committed. When called from any view that is wrapped by TransactionMiddleware, and thus in a "commit-on-success" transaction, an autocommit buried within here will cause any pending transaction to be committed by a successful save here. Any future database operations will take place in a separate transaction. Note that there is a chance of a race condition here, when two users try to run the same task at almost exactly the same time. One user could be after the check and before the create when the second user gets to the check. At that point, both users are able to run their tasks simultaneously. This is deemed a small enough risk to not put in further safeguards. """ if _task_is_running(course_id, task_type, task_key): log.warning("Duplicate task found for task_type %s and task_key %s", task_type, task_key) raise AlreadyRunningError("requested task is already running") try: most_recent_id = InstructorTask.objects.latest('id').id except InstructorTask.DoesNotExist: most_recent_id = "None found" finally: log.warning( "No duplicate tasks found: task_type %s, task_key %s, and most recent task_id = %s", task_type, task_key, most_recent_id ) # Create log entry now, so that future requests will know it's running. return InstructorTask.create(course_id, task_type, task_key, task_input, requester) def _get_xmodule_instance_args(request, task_id): """ Calculate parameters needed for instantiating xmodule instances. The `request_info` will be passed to a tracking log function, to provide information about the source of the task request. The `xqueue_callback_url_prefix` is used to permit old-style xqueue callbacks directly to the appropriate module in the LMS. The `task_id` is also passed to the tracking log function. """ request_info = {'username': request.user.username, 'ip': request.META['REMOTE_ADDR'], 'agent': request.META.get('HTTP_USER_AGENT', ''), 'host': request.META['SERVER_NAME'], } xmodule_instance_args = {'xqueue_callback_url_prefix': get_xqueue_callback_url_prefix(request), 'request_info': request_info, 'task_id': task_id, } return xmodule_instance_args def _update_instructor_task(instructor_task, task_result): """ Updates and possibly saves a InstructorTask entry based on a task Result. Used when updated status is requested. The `instructor_task` that is passed in is updated in-place, but is usually not saved. In general, tasks that have finished (either with success or failure) should have their entries updated by the task itself, so are not updated here. Tasks that are still running are not updated and saved while they run. The one exception to the no-save rule are tasks that are in a "revoked" state. This may mean that the task never had the opportunity to update the InstructorTask entry. Tasks that are in progress and have subtasks doing the processing do not look to the task's AsyncResult object. When subtasks are running, the InstructorTask object itself is updated with the subtasks' progress, not any AsyncResult object. In this case, the InstructorTask is not updated at all. Calculates json to store in "task_output" field of the `instructor_task`, as well as updating the task_state. For a successful task, the json contains the output of the task result. For a failed task, the json contains "exception", "message", and "traceback" keys. A revoked task just has a "message" stating it was revoked. """ # Pull values out of the result object as close to each other as possible. # If we wait and check the values later, the values for the state and result # are more likely to have changed. Pull the state out first, and # then code assuming that the result may not exactly match the state. task_id = task_result.task_id result_state = task_result.state returned_result = task_result.result result_traceback = task_result.traceback # Assume we don't always save the InstructorTask entry if we don't have to, # but that in most cases we will update the InstructorTask in-place with its # current progress. entry_needs_updating = True entry_needs_saving = False task_output = None if instructor_task.task_state == PROGRESS and len(instructor_task.subtasks) > 0: # This happens when running subtasks: the result object is marked with SUCCESS, # meaning that the subtasks have successfully been defined. However, the InstructorTask # will be marked as in PROGRESS, until the last subtask completes and marks it as SUCCESS. # We want to ignore the parent SUCCESS if subtasks are still running, and just trust the # contents of the InstructorTask. entry_needs_updating = False elif result_state in [PROGRESS, SUCCESS]: # construct a status message directly from the task result's result: # it needs to go back with the entry passed in. log.info("background task (%s), state %s: result: %s", task_id, result_state, returned_result) task_output = InstructorTask.create_output_for_success(returned_result) elif result_state == FAILURE: # on failure, the result's result contains the exception that caused the failure exception = returned_result traceback = result_traceback if result_traceback is not None else '' log.warning("background task (%s) failed: %s %s", task_id, returned_result, traceback) task_output = InstructorTask.create_output_for_failure(exception, result_traceback) elif result_state == REVOKED: # on revocation, the result's result doesn't contain anything # but we cannot rely on the worker thread to set this status, # so we set it here. entry_needs_saving = True log.warning("background task (%s) revoked.", task_id) task_output = InstructorTask.create_output_for_revoked() # save progress and state into the entry, even if it's not being saved: # when celery is run in "ALWAYS_EAGER" mode, progress needs to go back # with the entry passed in. if entry_needs_updating: instructor_task.task_state = result_state if task_output is not None: instructor_task.task_output = task_output if entry_needs_saving: instructor_task.save() def get_updated_instructor_task(task_id): """ Returns InstructorTask object corresponding to a given `task_id`. If the InstructorTask thinks the task is still running, then the task's result is checked to return an updated state and output. """ # First check if the task_id is known try: instructor_task = InstructorTask.objects.get(task_id=task_id) except InstructorTask.DoesNotExist: log.warning("query for InstructorTask status failed: task_id=(%s) not found", task_id) return None # if the task is not already known to be done, then we need to query # the underlying task's result object: if instructor_task.task_state not in READY_STATES: result = AsyncResult(task_id) _update_instructor_task(instructor_task, result) return instructor_task def get_status_from_instructor_task(instructor_task): """ Get the status for a given InstructorTask entry. Returns a dict, with the following keys: 'task_id': id assigned by LMS and used by celery. 'task_state': state of task as stored in celery's result store. 'in_progress': boolean indicating if task is still running. 'task_progress': dict containing progress information. This includes: 'attempted': number of attempts made 'succeeded': number of attempts that "succeeded" 'total': number of possible subtasks to attempt 'action_name': user-visible verb to use in status messages. Should be past-tense. 'duration_ms': how long the task has (or had) been running. 'exception': name of exception class raised in failed tasks. 'message': returned for failed and revoked tasks. 'traceback': optional, returned if task failed and produced a traceback. """ status = {} if instructor_task is not None: # status basic information matching what's stored in InstructorTask: status['task_id'] = instructor_task.task_id status['task_state'] = instructor_task.task_state status['in_progress'] = instructor_task.task_state not in READY_STATES if instructor_task.task_output is not None: status['task_progress'] = json.loads(instructor_task.task_output) return status def check_arguments_for_rescoring(usage_key): """ Do simple checks on the descriptor to confirm that it supports rescoring. Confirms first that the usage_key is defined (since that's currently typed in). An ItemNotFoundException is raised if the corresponding module descriptor doesn't exist. NotImplementedError is raised if the corresponding module doesn't support rescoring calls. """ descriptor = modulestore().get_item(usage_key) if not hasattr(descriptor, 'module_class') or not hasattr(descriptor.module_class, 'rescore_problem'): msg = "Specified module does not support rescoring." raise NotImplementedError(msg) def encode_problem_and_student_input(usage_key, student=None): # pylint: disable=invalid-name """ Encode optional usage_key and optional student into task_key and task_input values. Args: usage_key (Location): The usage_key identifying the problem. student (User): the student affected """ assert isinstance(usage_key, UsageKey) if student is not None: task_input = {'problem_url': usage_key.to_deprecated_string(), 'student': student.username} task_key_stub = "{student}_{problem}".format(student=student.id, problem=usage_key.to_deprecated_string()) else: task_input = {'problem_url': usage_key.to_deprecated_string()} task_key_stub = "_{problem}".format(problem=usage_key.to_deprecated_string()) # create the key value by using MD5 hash: task_key = hashlib.md5(task_key_stub).hexdigest() return task_input, task_key def submit_task(request, task_type, task_class, course_key, task_input, task_key): """ Helper method to submit a task. Reserves the requested task, based on the `course_key`, `task_type`, and `task_key`, checking to see if the task is already running. The `task_input` is also passed so that it can be stored in the resulting InstructorTask entry. Arguments are extracted from the `request` provided by the originating server request. Then the task is submitted to run asynchronously, using the specified `task_class` and using the task_id constructed for it. `AlreadyRunningError` is raised if the task is already running. The _reserve_task method makes sure the InstructorTask entry is committed. When called from any view that is wrapped by TransactionMiddleware, and thus in a "commit-on-success" transaction, an autocommit buried within here will cause any pending transaction to be committed by a successful save here. Any future database operations will take place in a separate transaction. """ # check to see if task is already running, and reserve it otherwise: instructor_task = _reserve_task(course_key, task_type, task_key, task_input, request.user) # submit task: task_id = instructor_task.task_id task_args = [instructor_task.id, _get_xmodule_instance_args(request, task_id)] # pylint: disable=E1101 task_class.apply_async(task_args, task_id=task_id) return instructor_task
agpl-3.0
[ 624, 199, 4433, 1973, 367, 17724, 63, 5054, 3261, 14, 199, 199, 22792, 3102, 370, 1104, 1249, 367, 522, 20624, 2120, 12, 2644, 6474, 1324, 12, 199, 460, 2120, 13071, 9661, 12, 5893, 7252, 314, 445, 19028, 4865, 14, 199, 624, 199, 646, 8337, 199, 646, 2022, 199, 646, 2050, 199, 199, 504, 22748, 14, 1099, 492, 15223, 2889, 199, 504, 22748, 14, 4981, 492, 16767, 57, 63, 23162, 12, 28364, 12, 10341, 3942, 12, 5363, 54, 3593, 1149, 199, 199, 504, 20736, 14, 578, 63, 3352, 492, 664, 63, 88, 1825, 63, 3058, 63, 633, 63, 1861, 199, 199, 504, 9872, 14, 10012, 14, 1176, 492, 10996, 199, 504, 15058, 63, 1612, 14, 8268, 14, 1612, 492, 11028, 1197, 199, 504, 17724, 63, 1765, 14, 992, 492, 31606, 12, 3611, 19568, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 21086, 9602, 547, 8, 1726, 304, 272, 408, 1726, 9297, 626, 282, 8020, 2120, 365, 2575, 3879, 624, 272, 986, 421, 199, 318, 485, 1765, 63, 374, 63, 5720, 8, 1972, 63, 344, 12, 2120, 63, 466, 12, 2120, 63, 498, 304, 272, 408, 11834, 340, 282, 6770, 2120, 365, 2575, 3879, 624, 272, 3879, 63, 5054, 275, 31606, 14, 1462, 14, 1541, 8, 267, 2518, 63, 344, 29, 1972, 63, 344, 12, 2120, 63, 466, 29, 1765, 63, 466, 12, 2120, 63, 498, 29, 1765, 63, 498, 272, 776, 272, 327, 5760, 6363, 626, 787, 298, 2179, 2, 334, 73, 14, 69, 14, 440, 298, 5720, 401, 325, 14, 71, 14, 5988, 12, 3182, 12, 6822, 7620, 304, 272, 367, 1174, 315, 16767, 57, 63, 23162, 26, 267, 3879, 63, 5054, 275, 3879, 63, 5054, 14, 5473, 8, 1765, 63, 929, 29, 929, 9, 272, 372, 822, 8, 5720, 63, 5054, 9, 690, 378, 421, 199, 318, 485, 19643, 63, 1765, 8, 1972, 63, 344, 12, 2120, 63, 466, 12, 2120, 63, 498, 12, 2120, 63, 1210, 12, 295, 18246, 304, 272, 408, 272, 10560, 282, 3050, 2397, 370, 6623, 626, 282, 2120, 365, 315, 6696, 14, 339, 3868, 3838, 21086, 9602, 547, 340, 314, 2120, 365, 2575, 315, 6696, 14, 272, 15783, 83, 314, 7143, 402, 376, 9697, 574, 367, 2120, 63, 344, 12, 370, 506, 272, 16930, 543, 314, 2120, 1240, 370, 22748, 14, 339, 710, 31606, 14, 981, 1083, 7704, 3238, 314, 31606, 2397, 365, 27659, 14, 272, 3979, 2797, 687, 1263, 2455, 626, 365, 8072, 701, 18244, 6608, 12, 272, 436, 12850, 315, 282, 298, 3543, 13, 265, 13, 3742, 2, 6008, 12, 376, 24845, 330, 2302, 379, 4453, 2348, 272, 911, 7675, 1263, 9413, 6008, 370, 506, 27659, 701, 282, 9512, 272, 3354, 2348, 14, 221, 6184, 6466, 3050, 5331, 911, 5452, 4192, 315, 282, 272, 7396, 6008, 14, 339, 3390, 626, 2337, 365, 282, 22044, 402, 282, 21209, 5558, 2348, 12, 1380, 2877, 4390, 272, 862, 370, 1255, 314, 2011, 2120, 737, 18871, 8840, 314, 2011, 900, 14, 221, 7309, 922, 272, 4293, 506, 2410, 314, 1104, 436, 2544, 314, 1218, 1380, 314, 3499, 922, 272, 7545, 370, 314, 1104, 14, 221, 2854, 626, 2376, 12, 3865, 4390, 787, 7688, 370, 1255, 3932, 272, 6527, 27008, 590, 14, 221, 961, 365, 27646, 3594, 282, 7425, 8321, 22633, 370, 440, 272, 5324, 315, 9848, 5048, 6051, 5596, 14, 272, 408, 339, 340, 485, 1765, 63, 374, 63, 5720, 8, 1972, 63, 344, 12, 2120, 63, 466, 12, 2120, 63, 498, 304, 267, 943, 14, 3764, 480, 14773, 2120, 1911, 367, 2120, 63, 466, 450, 83, 436, 2120, 63, 498, 450, 83, 401, 2120, 63, 466, 12, 2120, 63, 498, 9, 267, 746, 21086, 9602, 547, 480, 11151, 2120, 365, 2575, 3879, 531, 339, 862, 26, 267, 4750, 63, 14951, 63, 344, 275, 31606, 14, 1462, 14, 7410, 360, 344, 1959, 344, 272, 871, 31606, 14, 7400, 26, 267, 4750, 63, 14951, 63, 344, 275, 298, 403, 1911, 2, 272, 3753, 26, 267, 943, 14, 3764, 8, 288, 298, 1944, 9250, 6527, 1911, 26, 2120, 63, 466, 450, 83, 12, 2120, 63, 498, 450, 83, 12, 436, 4750, 8058, 2120, 63, 344, 275, 450, 83, 401, 288, 2120, 63, 466, 12, 288, 2120, 63, 498, 12, 288, 4750, 63, 14951, 63, 344, 267, 776, 339, 327, 2790, 943, 2397, 3063, 12, 880, 626, 6466, 4145, 911, 5715, 652, 1159, 3879, 14, 272, 372, 31606, 14, 981, 8, 1972, 63, 344, 12, 2120, 63, 466, 12, 2120, 63, 498, 12, 2120, 63, 1210, 12, 295, 18246, 9, 421, 199, 318, 485, 362, 63, 14293, 63, 842, 63, 589, 8, 1069, 12, 2120, 63, 344, 304, 272, 408, 272, 12707, 2633, 4346, 367, 9034, 1958, 9872, 4454, 14, 339, 710, 658, 1069, 63, 815, 64, 911, 506, 3032, 370, 282, 15161, 943, 805, 12, 370, 5647, 2556, 272, 3595, 314, 1350, 402, 314, 2120, 1056, 14, 257, 710, 658, 88, 1825, 63, 3058, 63, 633, 63, 1861, 64, 365, 1202, 370, 272, 11291, 2269, 13, 2487, 671, 1825, 13484, 5370, 370, 314, 5827, 859, 315, 314, 27540, 14, 272, 710, 658, 1765, 63, 344, 64, 365, 2597, 3032, 370, 314, 15161, 943, 805, 14, 272, 408, 272, 1056, 63, 815, 275, 791, 2473, 356, 1056, 14, 751, 14, 2473, 12, 490, 283, 711, 356, 1056, 14, 10614, 459, 16058, 63, 7803, 995, 490, 283, 4054, 356, 1056, 14, 10614, 14, 362, 360, 2856, 63, 3791, 63, 14565, 297, 9929, 490, 283, 1102, 356, 1056, 14, 10614, 459, 6613, 63, 2339, 995, 490, 789, 339, 9872, 63, 842, 63, 589, 275, 791, 88, 1825, 63, 3058, 63, 633, 63, 1861, 356, 664, 63, 88, 1825, 63, 3058, 63, 633, 63, 1861, 8, 1069, 395, 2490, 283, 1069, 63, 815, 356, 1056, 63, 815, 12, 2490, 283, 1765, 63, 344, 356, 2120, 63, 344, 12, 2490, 789, 272, 372, 9872, 63, 842, 63, 589, 421, 199, 318, 485, 873, 63, 14891, 63, 1765, 8, 14891, 63, 1765, 12, 2120, 63, 1099, 304, 272, 408, 272, 24663, 436, 12570, 23050, 282, 31606, 2397, 4079, 641, 282, 2120, 10695, 14, 339, 8051, 1380, 4588, 2004, 365, 5839, 14, 339, 710, 658, 14891, 63, 1765, 64, 626, 365, 3032, 315, 365 ]
[ 199, 4433, 1973, 367, 17724, 63, 5054, 3261, 14, 199, 199, 22792, 3102, 370, 1104, 1249, 367, 522, 20624, 2120, 12, 2644, 6474, 1324, 12, 199, 460, 2120, 13071, 9661, 12, 5893, 7252, 314, 445, 19028, 4865, 14, 199, 624, 199, 646, 8337, 199, 646, 2022, 199, 646, 2050, 199, 199, 504, 22748, 14, 1099, 492, 15223, 2889, 199, 504, 22748, 14, 4981, 492, 16767, 57, 63, 23162, 12, 28364, 12, 10341, 3942, 12, 5363, 54, 3593, 1149, 199, 199, 504, 20736, 14, 578, 63, 3352, 492, 664, 63, 88, 1825, 63, 3058, 63, 633, 63, 1861, 199, 199, 504, 9872, 14, 10012, 14, 1176, 492, 10996, 199, 504, 15058, 63, 1612, 14, 8268, 14, 1612, 492, 11028, 1197, 199, 504, 17724, 63, 1765, 14, 992, 492, 31606, 12, 3611, 19568, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 21086, 9602, 547, 8, 1726, 304, 272, 408, 1726, 9297, 626, 282, 8020, 2120, 365, 2575, 3879, 624, 272, 986, 421, 199, 318, 485, 1765, 63, 374, 63, 5720, 8, 1972, 63, 344, 12, 2120, 63, 466, 12, 2120, 63, 498, 304, 272, 408, 11834, 340, 282, 6770, 2120, 365, 2575, 3879, 624, 272, 3879, 63, 5054, 275, 31606, 14, 1462, 14, 1541, 8, 267, 2518, 63, 344, 29, 1972, 63, 344, 12, 2120, 63, 466, 29, 1765, 63, 466, 12, 2120, 63, 498, 29, 1765, 63, 498, 272, 776, 272, 327, 5760, 6363, 626, 787, 298, 2179, 2, 334, 73, 14, 69, 14, 440, 298, 5720, 401, 325, 14, 71, 14, 5988, 12, 3182, 12, 6822, 7620, 304, 272, 367, 1174, 315, 16767, 57, 63, 23162, 26, 267, 3879, 63, 5054, 275, 3879, 63, 5054, 14, 5473, 8, 1765, 63, 929, 29, 929, 9, 272, 372, 822, 8, 5720, 63, 5054, 9, 690, 378, 421, 199, 318, 485, 19643, 63, 1765, 8, 1972, 63, 344, 12, 2120, 63, 466, 12, 2120, 63, 498, 12, 2120, 63, 1210, 12, 295, 18246, 304, 272, 408, 272, 10560, 282, 3050, 2397, 370, 6623, 626, 282, 2120, 365, 315, 6696, 14, 339, 3868, 3838, 21086, 9602, 547, 340, 314, 2120, 365, 2575, 315, 6696, 14, 272, 15783, 83, 314, 7143, 402, 376, 9697, 574, 367, 2120, 63, 344, 12, 370, 506, 272, 16930, 543, 314, 2120, 1240, 370, 22748, 14, 339, 710, 31606, 14, 981, 1083, 7704, 3238, 314, 31606, 2397, 365, 27659, 14, 272, 3979, 2797, 687, 1263, 2455, 626, 365, 8072, 701, 18244, 6608, 12, 272, 436, 12850, 315, 282, 298, 3543, 13, 265, 13, 3742, 2, 6008, 12, 376, 24845, 330, 2302, 379, 4453, 2348, 272, 911, 7675, 1263, 9413, 6008, 370, 506, 27659, 701, 282, 9512, 272, 3354, 2348, 14, 221, 6184, 6466, 3050, 5331, 911, 5452, 4192, 315, 282, 272, 7396, 6008, 14, 339, 3390, 626, 2337, 365, 282, 22044, 402, 282, 21209, 5558, 2348, 12, 1380, 2877, 4390, 272, 862, 370, 1255, 314, 2011, 2120, 737, 18871, 8840, 314, 2011, 900, 14, 221, 7309, 922, 272, 4293, 506, 2410, 314, 1104, 436, 2544, 314, 1218, 1380, 314, 3499, 922, 272, 7545, 370, 314, 1104, 14, 221, 2854, 626, 2376, 12, 3865, 4390, 787, 7688, 370, 1255, 3932, 272, 6527, 27008, 590, 14, 221, 961, 365, 27646, 3594, 282, 7425, 8321, 22633, 370, 440, 272, 5324, 315, 9848, 5048, 6051, 5596, 14, 272, 408, 339, 340, 485, 1765, 63, 374, 63, 5720, 8, 1972, 63, 344, 12, 2120, 63, 466, 12, 2120, 63, 498, 304, 267, 943, 14, 3764, 480, 14773, 2120, 1911, 367, 2120, 63, 466, 450, 83, 436, 2120, 63, 498, 450, 83, 401, 2120, 63, 466, 12, 2120, 63, 498, 9, 267, 746, 21086, 9602, 547, 480, 11151, 2120, 365, 2575, 3879, 531, 339, 862, 26, 267, 4750, 63, 14951, 63, 344, 275, 31606, 14, 1462, 14, 7410, 360, 344, 1959, 344, 272, 871, 31606, 14, 7400, 26, 267, 4750, 63, 14951, 63, 344, 275, 298, 403, 1911, 2, 272, 3753, 26, 267, 943, 14, 3764, 8, 288, 298, 1944, 9250, 6527, 1911, 26, 2120, 63, 466, 450, 83, 12, 2120, 63, 498, 450, 83, 12, 436, 4750, 8058, 2120, 63, 344, 275, 450, 83, 401, 288, 2120, 63, 466, 12, 288, 2120, 63, 498, 12, 288, 4750, 63, 14951, 63, 344, 267, 776, 339, 327, 2790, 943, 2397, 3063, 12, 880, 626, 6466, 4145, 911, 5715, 652, 1159, 3879, 14, 272, 372, 31606, 14, 981, 8, 1972, 63, 344, 12, 2120, 63, 466, 12, 2120, 63, 498, 12, 2120, 63, 1210, 12, 295, 18246, 9, 421, 199, 318, 485, 362, 63, 14293, 63, 842, 63, 589, 8, 1069, 12, 2120, 63, 344, 304, 272, 408, 272, 12707, 2633, 4346, 367, 9034, 1958, 9872, 4454, 14, 339, 710, 658, 1069, 63, 815, 64, 911, 506, 3032, 370, 282, 15161, 943, 805, 12, 370, 5647, 2556, 272, 3595, 314, 1350, 402, 314, 2120, 1056, 14, 257, 710, 658, 88, 1825, 63, 3058, 63, 633, 63, 1861, 64, 365, 1202, 370, 272, 11291, 2269, 13, 2487, 671, 1825, 13484, 5370, 370, 314, 5827, 859, 315, 314, 27540, 14, 272, 710, 658, 1765, 63, 344, 64, 365, 2597, 3032, 370, 314, 15161, 943, 805, 14, 272, 408, 272, 1056, 63, 815, 275, 791, 2473, 356, 1056, 14, 751, 14, 2473, 12, 490, 283, 711, 356, 1056, 14, 10614, 459, 16058, 63, 7803, 995, 490, 283, 4054, 356, 1056, 14, 10614, 14, 362, 360, 2856, 63, 3791, 63, 14565, 297, 9929, 490, 283, 1102, 356, 1056, 14, 10614, 459, 6613, 63, 2339, 995, 490, 789, 339, 9872, 63, 842, 63, 589, 275, 791, 88, 1825, 63, 3058, 63, 633, 63, 1861, 356, 664, 63, 88, 1825, 63, 3058, 63, 633, 63, 1861, 8, 1069, 395, 2490, 283, 1069, 63, 815, 356, 1056, 63, 815, 12, 2490, 283, 1765, 63, 344, 356, 2120, 63, 344, 12, 2490, 789, 272, 372, 9872, 63, 842, 63, 589, 421, 199, 318, 485, 873, 63, 14891, 63, 1765, 8, 14891, 63, 1765, 12, 2120, 63, 1099, 304, 272, 408, 272, 24663, 436, 12570, 23050, 282, 31606, 2397, 4079, 641, 282, 2120, 10695, 14, 339, 8051, 1380, 4588, 2004, 365, 5839, 14, 339, 710, 658, 14891, 63, 1765, 64, 626, 365, 3032, 315, 365, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
houst0nn/android_kernel_lge_geeb
tools/perf/python/twatch.py
7370
1334
#! /usr/bin/python # -*- python -*- # -*- coding: utf-8 -*- # twatch - Experimental use of the perf python interface # Copyright (C) 2011 Arnaldo Carvalho de Melo <acme@redhat.com> # # This application is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; version 2. # # This application is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. import perf def main(): cpus = perf.cpu_map() threads = perf.thread_map() evsel = perf.evsel(task = 1, comm = 1, mmap = 0, wakeup_events = 1, watermark = 1, sample_id_all = 1, sample_type = perf.SAMPLE_PERIOD | perf.SAMPLE_TID | perf.SAMPLE_CPU | perf.SAMPLE_TID) evsel.open(cpus = cpus, threads = threads); evlist = perf.evlist(cpus, threads) evlist.add(evsel) evlist.mmap() while True: evlist.poll(timeout = -1) for cpu in cpus: event = evlist.read_on_cpu(cpu) if not event: continue print "cpu: %2d, pid: %4d, tid: %4d" % (event.sample_cpu, event.sample_pid, event.sample_tid), print event if __name__ == '__main__': main()
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2366, 1882, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 257, 307, 6821, 446, 23997, 279, 675, 402, 314, 8582, 2366, 3217, 199, 3, 257, 1898, 334, 35, 9, 7760, 1952, 78, 279, 1117, 14243, 637, 526, 477, 3194, 320, 665, 18107, 32, 17164, 14, 957, 30, 199, 3, 199, 3, 257, 961, 4223, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 257, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 257, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1015, 499, 14, 199, 3, 199, 3, 257, 961, 4223, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 257, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 646, 8582, 199, 199, 318, 2446, 837, 199, 198, 8896, 275, 8582, 14, 3541, 63, 1130, 342, 199, 198, 6962, 275, 8582, 14, 2671, 63, 1130, 342, 199, 198, 6857, 5891, 275, 8582, 14, 6857, 5891, 8, 1765, 275, 413, 12, 1923, 275, 413, 12, 21991, 275, 378, 12, 1585, 257, 21560, 384, 63, 4368, 275, 413, 12, 22834, 1657, 275, 413, 12, 1585, 257, 2690, 63, 344, 63, 452, 275, 413, 12, 1585, 257, 2690, 63, 466, 275, 8582, 14, 15827, 63, 27081, 1204, 8582, 14, 15827, 63, 52, 998, 1204, 8582, 14, 15827, 63, 11011, 1204, 8582, 14, 15827, 63, 52, 998, 9, 199, 198, 6857, 5891, 14, 1490, 8, 8896, 275, 24174, 12, 7183, 275, 7183, 2736, 199, 198, 6857, 513, 275, 8582, 14, 6857, 513, 8, 8896, 12, 7183, 9, 199, 198, 6857, 513, 14, 525, 8, 6857, 5891, 9, 199, 198, 6857, 513, 14, 20671, 342, 199, 198, 6710, 715, 26, 507, 198, 6857, 513, 14, 6843, 8, 2593, 275, 446, 17, 9, 507, 198, 509, 5033, 315, 24174, 26, 686, 198, 1430, 275, 8145, 513, 14, 739, 63, 265, 63, 3541, 8, 3541, 9, 686, 198, 692, 440, 1566, 26, 1585, 198, 6958, 686, 198, 1361, 298, 3541, 26, 450, 18, 68, 12, 4422, 26, 450, 20, 68, 12, 11559, 26, 450, 20, 68, 2, 450, 334, 1430, 14, 3271, 63, 3541, 12, 11674, 198, 1430, 14, 3271, 63, 3150, 12, 11674, 198, 1430, 14, 3271, 63, 5700, 395, 686, 198, 1361, 1566, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1182, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2366, 1882, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 257, 307, 6821, 446, 23997, 279, 675, 402, 314, 8582, 2366, 3217, 199, 3, 257, 1898, 334, 35, 9, 7760, 1952, 78, 279, 1117, 14243, 637, 526, 477, 3194, 320, 665, 18107, 32, 17164, 14, 957, 30, 199, 3, 199, 3, 257, 961, 4223, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 257, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 257, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1015, 499, 14, 199, 3, 199, 3, 257, 961, 4223, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 257, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 646, 8582, 199, 199, 318, 2446, 837, 199, 198, 8896, 275, 8582, 14, 3541, 63, 1130, 342, 199, 198, 6962, 275, 8582, 14, 2671, 63, 1130, 342, 199, 198, 6857, 5891, 275, 8582, 14, 6857, 5891, 8, 1765, 275, 413, 12, 1923, 275, 413, 12, 21991, 275, 378, 12, 1585, 257, 21560, 384, 63, 4368, 275, 413, 12, 22834, 1657, 275, 413, 12, 1585, 257, 2690, 63, 344, 63, 452, 275, 413, 12, 1585, 257, 2690, 63, 466, 275, 8582, 14, 15827, 63, 27081, 1204, 8582, 14, 15827, 63, 52, 998, 1204, 8582, 14, 15827, 63, 11011, 1204, 8582, 14, 15827, 63, 52, 998, 9, 199, 198, 6857, 5891, 14, 1490, 8, 8896, 275, 24174, 12, 7183, 275, 7183, 2736, 199, 198, 6857, 513, 275, 8582, 14, 6857, 513, 8, 8896, 12, 7183, 9, 199, 198, 6857, 513, 14, 525, 8, 6857, 5891, 9, 199, 198, 6857, 513, 14, 20671, 342, 199, 198, 6710, 715, 26, 507, 198, 6857, 513, 14, 6843, 8, 2593, 275, 446, 17, 9, 507, 198, 509, 5033, 315, 24174, 26, 686, 198, 1430, 275, 8145, 513, 14, 739, 63, 265, 63, 3541, 8, 3541, 9, 686, 198, 692, 440, 1566, 26, 1585, 198, 6958, 686, 198, 1361, 298, 3541, 26, 450, 18, 68, 12, 4422, 26, 450, 20, 68, 12, 11559, 26, 450, 20, 68, 2, 450, 334, 1430, 14, 3271, 63, 3541, 12, 11674, 198, 1430, 14, 3271, 63, 3150, 12, 11674, 198, 1430, 14, 3271, 63, 5700, 395, 686, 198, 1361, 1566, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
gcodetogit/depot_tools
third_party/logilab/common/__init__.py
64
5103
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This file is part of logilab-common. # # logilab-common is free software: you can redistribute it and/or modify it under # the terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 2.1 of the License, or (at your option) any # later version. # # logilab-common is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License along # with logilab-common. If not, see <http://www.gnu.org/licenses/>. """Logilab common library (aka Logilab's extension to the standard library). :type STD_BLACKLIST: tuple :var STD_BLACKLIST: directories ignored by default by the functions in this package which have to recurse into directories :type IGNORED_EXTENSIONS: tuple :var IGNORED_EXTENSIONS: file extensions that may usually be ignored """ __docformat__ = "restructuredtext en" from six.moves import range from logilab.common.__pkginfo__ import version as __version__ STD_BLACKLIST = ('CVS', '.svn', '.hg', 'debian', 'dist', 'build') IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc', '~', '.swp', '.orig') # set this to False if you've mx DateTime installed but you don't want your db # adapter to use it (should be set before you got a connection) USE_MX_DATETIME = True class attrdict(dict): """A dictionary for which keys are also accessible as attributes.""" def __getattr__(self, attr): try: return self[attr] except KeyError: raise AttributeError(attr) class dictattr(dict): def __init__(self, proxy): self.__proxy = proxy def __getitem__(self, attr): try: return getattr(self.__proxy, attr) except AttributeError: raise KeyError(attr) class nullobject(object): def __repr__(self): return '<nullobject>' def __bool__(self): return False __nonzero__ = __bool__ class tempattr(object): def __init__(self, obj, attr, value): self.obj = obj self.attr = attr self.value = value def __enter__(self): self.oldvalue = getattr(self.obj, self.attr) setattr(self.obj, self.attr, self.value) return self.obj def __exit__(self, exctype, value, traceback): setattr(self.obj, self.attr, self.oldvalue) # flatten ----- # XXX move in a specific module and use yield instead # do not mix flatten and translate # # def iterable(obj): # try: iter(obj) # except: return False # return True # # def is_string_like(obj): # try: obj +'' # except (TypeError, ValueError): return False # return True # #def is_scalar(obj): # return is_string_like(obj) or not iterable(obj) # #def flatten(seq): # for item in seq: # if is_scalar(item): # yield item # else: # for subitem in flatten(item): # yield subitem def flatten(iterable, tr_func=None, results=None): """Flatten a list of list with any level. If tr_func is not None, it should be a one argument function that'll be called on each final element. :rtype: list >>> flatten([1, [2, 3]]) [1, 2, 3] """ if results is None: results = [] for val in iterable: if isinstance(val, (list, tuple)): flatten(val, tr_func, results) elif tr_func is None: results.append(val) else: results.append(tr_func(val)) return results # XXX is function below still used ? def make_domains(lists): """ Given a list of lists, return a list of domain for each list to produce all combinations of possibles values. :rtype: list Example: >>> make_domains(['a', 'b'], ['c','d', 'e']) [['a', 'b', 'a', 'b', 'a', 'b'], ['c', 'c', 'd', 'd', 'e', 'e']] """ domains = [] for iterable in lists: new_domain = iterable[:] for i in range(len(domains)): domains[i] = domains[i]*len(iterable) if domains: missing = (len(domains[0]) - len(iterable)) / len(iterable) i = 0 for j in range(len(iterable)): value = iterable[j] for dummy in range(missing): new_domain.insert(i, value) i += 1 i += 1 domains.append(new_domain) return domains # private stuff ################################################################ def _handle_blacklist(blacklist, dirnames, filenames): """remove files/directories in the black list dirnames/filenames are usually from os.walk """ for norecurs in blacklist: if norecurs in dirnames: dirnames.remove(norecurs) elif norecurs in filenames: filenames.remove(norecurs)
bsd-3-clause
[ 3, 4248, 13004, 13, 8128, 5051, 1193, 1217, 428, 14, 33, 14, 334, 1262, 374, 12, 28671, 7140, 395, 1006, 4481, 4644, 14, 199, 3, 8966, 1455, 921, 1544, 14, 793, 24142, 14, 4391, 15, 1553, 6016, 475, 26, 7811, 32, 793, 24142, 14, 4391, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 943, 24142, 13, 2330, 14, 199, 3, 199, 3, 943, 24142, 13, 2330, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 2868, 199, 3, 2290, 2752, 12, 1902, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 199, 3, 2945, 1015, 14, 199, 3, 199, 3, 943, 24142, 13, 2330, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 3180, 199, 3, 543, 943, 24142, 13, 2330, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 2445, 24142, 2863, 3555, 334, 24685, 5297, 24142, 1159, 3329, 370, 314, 4465, 3555, 680, 199, 199, 26, 466, 30118, 63, 23113, 4924, 26, 2008, 199, 26, 1391, 30118, 63, 23113, 4924, 26, 6602, 5525, 701, 849, 701, 314, 3423, 315, 523, 642, 2559, 1314, 1172, 370, 18011, 1901, 6602, 199, 199, 26, 466, 27499, 25517, 63, 18451, 26, 2008, 199, 26, 1391, 27499, 25517, 63, 18451, 26, 570, 5478, 626, 1443, 9987, 506, 5525, 199, 624, 199, 363, 21841, 363, 275, 298, 26854, 655, 2, 199, 199, 504, 3816, 14, 4912, 492, 1425, 199, 199, 504, 943, 24142, 14, 2330, 855, 4600, 815, 363, 492, 1015, 465, 636, 1023, 363, 199, 199, 18472, 63, 23113, 4924, 275, 661, 35, 7428, 297, 1987, 6836, 297, 1987, 9208, 297, 283, 23204, 297, 283, 2686, 297, 283, 1506, 358, 199, 199, 3203, 25517, 63, 18451, 275, 23500, 11357, 297, 1987, 22345, 297, 1987, 352, 67, 297, 17352, 297, 1987, 3519, 80, 297, 1987, 2981, 358, 199, 199, 3, 663, 642, 370, 756, 340, 1265, 9064, 8728, 13686, 4903, 1325, 1265, 2793, 1133, 2934, 2195, 1592, 199, 3, 12146, 370, 675, 652, 334, 5626, 506, 663, 2544, 1265, 4788, 282, 1950, 9, 199, 4701, 63, 17401, 63, 12488, 275, 715, 421, 199, 533, 1921, 807, 8, 807, 304, 272, 408, 33, 2600, 367, 1314, 2883, 787, 2597, 17909, 465, 3004, 1041, 272, 347, 636, 5675, 721, 277, 12, 1921, 304, 267, 862, 26, 288, 372, 291, 59, 962, 61, 267, 871, 4067, 26, 288, 746, 4281, 8, 962, 9, 199, 199, 533, 1211, 962, 8, 807, 304, 272, 347, 636, 826, 721, 277, 12, 4566, 304, 267, 291, 855, 3280, 275, 4566, 339, 347, 636, 6095, 721, 277, 12, 1921, 304, 267, 862, 26, 288, 372, 2519, 8, 277, 855, 3280, 12, 1921, 9, 267, 871, 4281, 26, 288, 746, 4067, 8, 962, 9, 199, 199, 533, 302, 348, 27789, 8, 785, 304, 272, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 78, 348, 27789, 3524, 272, 347, 636, 2245, 721, 277, 304, 267, 372, 756, 272, 636, 10262, 363, 275, 636, 2245, 363, 199, 199, 533, 2388, 962, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1559, 12, 1921, 12, 574, 304, 267, 291, 14, 1113, 275, 1559, 267, 291, 14, 962, 275, 1921, 267, 291, 14, 585, 275, 574, 339, 347, 636, 4200, 721, 277, 304, 267, 291, 14, 1753, 585, 275, 2519, 8, 277, 14, 1113, 12, 291, 14, 962, 9, 267, 5371, 8, 277, 14, 1113, 12, 291, 14, 962, 12, 291, 14, 585, 9, 267, 372, 291, 14, 1113, 339, 347, 636, 2224, 721, 277, 12, 444, 3667, 12, 574, 12, 5190, 304, 267, 5371, 8, 277, 14, 1113, 12, 291, 14, 962, 12, 291, 14, 1753, 585, 9, 4388, 199, 3, 9378, 9063, 199, 3, 5787, 4057, 315, 282, 2488, 859, 436, 675, 1995, 3140, 199, 3, 886, 440, 13667, 9378, 436, 9028, 199, 3, 199, 3, 347, 6076, 8, 1113, 304, 199, 3, 259, 862, 26, 2740, 8, 1113, 9, 199, 3, 259, 871, 26, 372, 756, 199, 3, 259, 372, 715, 199, 3, 199, 3, 347, 365, 63, 875, 63, 2930, 8, 1113, 304, 199, 3, 259, 862, 26, 1559, 435, 891, 199, 3, 259, 871, 334, 4333, 12, 1722, 304, 372, 756, 199, 3, 259, 372, 715, 199, 3, 199, 3, 318, 365, 63, 7033, 8, 1113, 304, 199, 3, 259, 372, 365, 63, 875, 63, 2930, 8, 1113, 9, 503, 440, 6076, 8, 1113, 9, 199, 3, 199, 3, 318, 9378, 8, 3610, 304, 199, 3, 259, 367, 1242, 315, 5412, 26, 199, 3, 263, 340, 365, 63, 7033, 8, 1053, 304, 199, 3, 3322, 1995, 1242, 199, 3, 263, 587, 26, 199, 3, 3322, 367, 1007, 1053, 315, 9378, 8, 1053, 304, 199, 3, 5185, 1995, 1007, 1053, 199, 199, 318, 9378, 8, 8147, 12, 5651, 63, 1532, 29, 403, 12, 2058, 29, 403, 304, 272, 408, 29302, 282, 769, 402, 769, 543, 1263, 2166, 14, 339, 982, 5651, 63, 1532, 365, 440, 488, 12, 652, 1077, 506, 282, 1373, 1423, 805, 626, 7171, 506, 2797, 272, 641, 1924, 4242, 1819, 14, 339, 520, 4500, 26, 769, 339, 1306, 9378, 779, 17, 12, 359, 18, 12, 650, 3934, 272, 359, 17, 12, 499, 12, 650, 61, 272, 408, 272, 340, 2058, 365, 488, 26, 267, 2058, 275, 942, 272, 367, 1139, 315, 6076, 26, 267, 340, 1228, 8, 637, 12, 334, 513, 12, 2008, 2298, 288, 9378, 8, 637, 12, 5651, 63, 1532, 12, 2058, 9, 267, 916, 5651, 63, 1532, 365, 488, 26, 288, 2058, 14, 740, 8, 637, 9, 267, 587, 26, 288, 2058, 14, 740, 8, 454, 63, 1532, 8, 637, 430, 272, 372, 2058, 421, 199, 3, 5787, 365, 805, 5084, 5139, 1202, 5805, 199, 199 ]
[ 4248, 13004, 13, 8128, 5051, 1193, 1217, 428, 14, 33, 14, 334, 1262, 374, 12, 28671, 7140, 395, 1006, 4481, 4644, 14, 199, 3, 8966, 1455, 921, 1544, 14, 793, 24142, 14, 4391, 15, 1553, 6016, 475, 26, 7811, 32, 793, 24142, 14, 4391, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 943, 24142, 13, 2330, 14, 199, 3, 199, 3, 943, 24142, 13, 2330, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 2868, 199, 3, 2290, 2752, 12, 1902, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 199, 3, 2945, 1015, 14, 199, 3, 199, 3, 943, 24142, 13, 2330, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 3180, 199, 3, 543, 943, 24142, 13, 2330, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 2445, 24142, 2863, 3555, 334, 24685, 5297, 24142, 1159, 3329, 370, 314, 4465, 3555, 680, 199, 199, 26, 466, 30118, 63, 23113, 4924, 26, 2008, 199, 26, 1391, 30118, 63, 23113, 4924, 26, 6602, 5525, 701, 849, 701, 314, 3423, 315, 523, 642, 2559, 1314, 1172, 370, 18011, 1901, 6602, 199, 199, 26, 466, 27499, 25517, 63, 18451, 26, 2008, 199, 26, 1391, 27499, 25517, 63, 18451, 26, 570, 5478, 626, 1443, 9987, 506, 5525, 199, 624, 199, 363, 21841, 363, 275, 298, 26854, 655, 2, 199, 199, 504, 3816, 14, 4912, 492, 1425, 199, 199, 504, 943, 24142, 14, 2330, 855, 4600, 815, 363, 492, 1015, 465, 636, 1023, 363, 199, 199, 18472, 63, 23113, 4924, 275, 661, 35, 7428, 297, 1987, 6836, 297, 1987, 9208, 297, 283, 23204, 297, 283, 2686, 297, 283, 1506, 358, 199, 199, 3203, 25517, 63, 18451, 275, 23500, 11357, 297, 1987, 22345, 297, 1987, 352, 67, 297, 17352, 297, 1987, 3519, 80, 297, 1987, 2981, 358, 199, 199, 3, 663, 642, 370, 756, 340, 1265, 9064, 8728, 13686, 4903, 1325, 1265, 2793, 1133, 2934, 2195, 1592, 199, 3, 12146, 370, 675, 652, 334, 5626, 506, 663, 2544, 1265, 4788, 282, 1950, 9, 199, 4701, 63, 17401, 63, 12488, 275, 715, 421, 199, 533, 1921, 807, 8, 807, 304, 272, 408, 33, 2600, 367, 1314, 2883, 787, 2597, 17909, 465, 3004, 1041, 272, 347, 636, 5675, 721, 277, 12, 1921, 304, 267, 862, 26, 288, 372, 291, 59, 962, 61, 267, 871, 4067, 26, 288, 746, 4281, 8, 962, 9, 199, 199, 533, 1211, 962, 8, 807, 304, 272, 347, 636, 826, 721, 277, 12, 4566, 304, 267, 291, 855, 3280, 275, 4566, 339, 347, 636, 6095, 721, 277, 12, 1921, 304, 267, 862, 26, 288, 372, 2519, 8, 277, 855, 3280, 12, 1921, 9, 267, 871, 4281, 26, 288, 746, 4067, 8, 962, 9, 199, 199, 533, 302, 348, 27789, 8, 785, 304, 272, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 78, 348, 27789, 3524, 272, 347, 636, 2245, 721, 277, 304, 267, 372, 756, 272, 636, 10262, 363, 275, 636, 2245, 363, 199, 199, 533, 2388, 962, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1559, 12, 1921, 12, 574, 304, 267, 291, 14, 1113, 275, 1559, 267, 291, 14, 962, 275, 1921, 267, 291, 14, 585, 275, 574, 339, 347, 636, 4200, 721, 277, 304, 267, 291, 14, 1753, 585, 275, 2519, 8, 277, 14, 1113, 12, 291, 14, 962, 9, 267, 5371, 8, 277, 14, 1113, 12, 291, 14, 962, 12, 291, 14, 585, 9, 267, 372, 291, 14, 1113, 339, 347, 636, 2224, 721, 277, 12, 444, 3667, 12, 574, 12, 5190, 304, 267, 5371, 8, 277, 14, 1113, 12, 291, 14, 962, 12, 291, 14, 1753, 585, 9, 4388, 199, 3, 9378, 9063, 199, 3, 5787, 4057, 315, 282, 2488, 859, 436, 675, 1995, 3140, 199, 3, 886, 440, 13667, 9378, 436, 9028, 199, 3, 199, 3, 347, 6076, 8, 1113, 304, 199, 3, 259, 862, 26, 2740, 8, 1113, 9, 199, 3, 259, 871, 26, 372, 756, 199, 3, 259, 372, 715, 199, 3, 199, 3, 347, 365, 63, 875, 63, 2930, 8, 1113, 304, 199, 3, 259, 862, 26, 1559, 435, 891, 199, 3, 259, 871, 334, 4333, 12, 1722, 304, 372, 756, 199, 3, 259, 372, 715, 199, 3, 199, 3, 318, 365, 63, 7033, 8, 1113, 304, 199, 3, 259, 372, 365, 63, 875, 63, 2930, 8, 1113, 9, 503, 440, 6076, 8, 1113, 9, 199, 3, 199, 3, 318, 9378, 8, 3610, 304, 199, 3, 259, 367, 1242, 315, 5412, 26, 199, 3, 263, 340, 365, 63, 7033, 8, 1053, 304, 199, 3, 3322, 1995, 1242, 199, 3, 263, 587, 26, 199, 3, 3322, 367, 1007, 1053, 315, 9378, 8, 1053, 304, 199, 3, 5185, 1995, 1007, 1053, 199, 199, 318, 9378, 8, 8147, 12, 5651, 63, 1532, 29, 403, 12, 2058, 29, 403, 304, 272, 408, 29302, 282, 769, 402, 769, 543, 1263, 2166, 14, 339, 982, 5651, 63, 1532, 365, 440, 488, 12, 652, 1077, 506, 282, 1373, 1423, 805, 626, 7171, 506, 2797, 272, 641, 1924, 4242, 1819, 14, 339, 520, 4500, 26, 769, 339, 1306, 9378, 779, 17, 12, 359, 18, 12, 650, 3934, 272, 359, 17, 12, 499, 12, 650, 61, 272, 408, 272, 340, 2058, 365, 488, 26, 267, 2058, 275, 942, 272, 367, 1139, 315, 6076, 26, 267, 340, 1228, 8, 637, 12, 334, 513, 12, 2008, 2298, 288, 9378, 8, 637, 12, 5651, 63, 1532, 12, 2058, 9, 267, 916, 5651, 63, 1532, 365, 488, 26, 288, 2058, 14, 740, 8, 637, 9, 267, 587, 26, 288, 2058, 14, 740, 8, 454, 63, 1532, 8, 637, 430, 272, 372, 2058, 421, 199, 3, 5787, 365, 805, 5084, 5139, 1202, 5805, 199, 199, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
codeofdusk/ProjectMagenta
tools/pygettext.py
86
22104
#! /usr/bin/env python # -*- coding: iso-8859-1 -*- # Originally written by Barry Warsaw <barry@zope.com> # # Minimally patched to make it even more xgettext compatible # by Peter Funk <pf@artcom-gmbh.de> # # 2002-11-22 Jürgen Hermann <jh@web.de> # Added checks that _() only contains string literals, and # command line args are resolved to module lists, i.e. you # can now pass a filename, a module or package name, or a # directory (including globbing chars, important for Win32). # Made docstring fit in 80 chars wide displays using pydoc. # # for selftesting try: import fintl _ = fintl.gettext except ImportError: _ = lambda s: s __doc__ = _("""pygettext -- Python equivalent of xgettext(1) Many systems (Solaris, Linux, Gnu) provide extensive tools that ease the internationalization of C programs. Most of these tools are independent of the programming language and can be used from within Python programs. Martin von Loewis' work[1] helps considerably in this regard. There's one problem though; xgettext is the program that scans source code looking for message strings, but it groks only C (or C++). Python introduces a few wrinkles, such as dual quoting characters, triple quoted strings, and raw strings. xgettext understands none of this. Enter pygettext, which uses Python's standard tokenize module to scan Python source code, generating .pot files identical to what GNU xgettext[2] generates for C and C++ code. From there, the standard GNU tools can be used. A word about marking Python strings as candidates for translation. GNU xgettext recognizes the following keywords: gettext, dgettext, dcgettext, and gettext_noop. But those can be a lot of text to include all over your code. C and C++ have a trick: they use the C preprocessor. Most internationalized C source includes a #define for gettext() to _() so that what has to be written in the source is much less. Thus these are both translatable strings: gettext("Translatable String") _("Translatable String") Python of course has no preprocessor so this doesn't work so well. Thus, pygettext searches only for _() by default, but see the -k/--keyword flag below for how to augment this. [1] http://www.python.org/workshops/1997-10/proceedings/loewis.html [2] http://www.gnu.org/software/gettext/gettext.html NOTE: pygettext attempts to be option and feature compatible with GNU xgettext where ever possible. However some options are still missing or are not fully implemented. Also, xgettext's use of command line switches with option arguments is broken, and in these cases, pygettext just defines additional switches. Usage: pygettext [options] inputfile ... Options: -a --extract-all Extract all strings. -d name --default-domain=name Rename the default output file from messages.pot to name.pot. -E --escape Replace non-ASCII characters with octal escape sequences. -D --docstrings Extract module, class, method, and function docstrings. These do not need to be wrapped in _() markers, and in fact cannot be for Python to consider them docstrings. (See also the -X option). -h --help Print this help message and exit. -k word --keyword=word Keywords to look for in addition to the default set, which are: %(DEFAULTKEYWORDS)s You can have multiple -k flags on the command line. -K --no-default-keywords Disable the default set of keywords (see above). Any keywords explicitly added with the -k/--keyword option are still recognized. --no-location Do not write filename/lineno location comments. -n --add-location Write filename/lineno location comments indicating where each extracted string is found in the source. These lines appear before each msgid. The style of comments is controlled by the -S/--style option. This is the default. -o filename --output=filename Rename the default output file from messages.pot to filename. If filename is `-' then the output is sent to standard out. -p dir --output-dir=dir Output files will be placed in directory dir. -S stylename --style stylename Specify which style to use for location comments. Two styles are supported: Solaris # File: filename, line: line-number GNU #: filename:line The style name is case insensitive. GNU style is the default. -v --verbose Print the names of the files being processed. -V --version Print the version of pygettext and exit. -w columns --width=columns Set width of output to columns. -x filename --exclude-file=filename Specify a file that contains a list of strings that are not be extracted from the input files. Each string to be excluded must appear on a line by itself in the file. -X filename --no-docstrings=filename Specify a file that contains a list of files (one per line) that should not have their docstrings extracted. This is only useful in conjunction with the -D option above. If `inputfile' is -, standard input is read. """) import os import imp import sys import glob import time import getopt import token import tokenize import operator __version__ = '1.5' default_keywords = ['_'] DEFAULTKEYWORDS = ', '.join(default_keywords) EMPTYSTRING = '' # The normal pot-file header. msgmerge and Emacs's po-mode work better if it's # there. pot_header = _('''\ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR ORGANIZATION # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\\n" "POT-Creation-Date: %(time)s\\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n" "Language-Team: LANGUAGE <LL@li.org>\\n" "MIME-Version: 1.0\\n" "Content-Type: text/plain; charset=CHARSET\\n" "Content-Transfer-Encoding: ENCODING\\n" "Generated-By: pygettext.py %(version)s\\n" ''') def usage(code, msg=''): print >> sys.stderr, __doc__ % globals() if msg: print >> sys.stderr, msg sys.exit(code) escapes = [] def make_escapes(pass_iso8859): global escapes if pass_iso8859: # Allow iso-8859 characters to pass through so that e.g. 'msgid # "Höhe"' would result not result in 'msgid "H\366he"'. Otherwise we # escape any character outside the 32..126 range. mod = 128 else: mod = 256 for i in range(256): if 32 <= (i % mod) <= 126: escapes.append(chr(i)) else: escapes.append("\\%03o" % i) escapes[ord('\\')] = '\\\\' escapes[ord('\t')] = '\\t' escapes[ord('\r')] = '\\r' escapes[ord('\n')] = '\\n' escapes[ord('\"')] = '\\"' def escape(s): global escapes s = list(s) for i in range(len(s)): s[i] = escapes[ord(s[i])] return EMPTYSTRING.join(s) def safe_eval(s): # unwrap quotes, safely return eval(s, {'__builtins__':{}}, {}) def normalize(s): # This converts the various Python string types into a format that is # appropriate for .po files, namely much closer to C style. lines = s.split('\n') if len(lines) == 1: s = '"' + escape(s) + '"' else: if not lines[-1]: del lines[-1] lines[-1] = lines[-1] + '\n' for i in range(len(lines)): lines[i] = escape(lines[i]) lineterm = '\\n"\n"' s = '""\n"' + lineterm.join(lines) + '"' return s def containsAny(str, set): """Check whether 'str' contains ANY of the chars in 'set'""" return 1 in [c in str for c in set] def _visit_pyfiles(list, dirname, names): """Helper for getFilesForName().""" # get extension for python source files if not globals().has_key('_py_ext'): global _py_ext _py_ext = [triple[0] for triple in imp.get_suffixes() if triple[2] == imp.PY_SOURCE][0] # don't recurse into CVS directories if 'CVS' in names: names.remove('CVS') # add all *.py files to list list.extend( [os.path.join(dirname, file) for file in names if os.path.splitext(file)[1] == _py_ext] ) def _get_modpkg_path(dotted_name, pathlist=None): """Get the filesystem path for a module or a package. Return the file system path to a file for a module, and to a directory for a package. Return None if the name is not found, or is a builtin or extension module. """ # split off top-most name parts = dotted_name.split('.', 1) if len(parts) > 1: # we have a dotted path, import top-level package try: file, pathname, description = imp.find_module(parts[0], pathlist) if file: file.close() except ImportError: return None # check if it's indeed a package if description[2] == imp.PKG_DIRECTORY: # recursively handle the remaining name parts pathname = _get_modpkg_path(parts[1], [pathname]) else: pathname = None else: # plain name try: file, pathname, description = imp.find_module( dotted_name, pathlist) if file: file.close() if description[2] not in [imp.PY_SOURCE, imp.PKG_DIRECTORY]: pathname = None except ImportError: pathname = None return pathname def getFilesForName(name): """Get a list of module files for a filename, a module or package name, or a directory. """ if not os.path.exists(name): # check for glob chars if containsAny(name, "*?[]"): files = glob.glob(name) list = [] for file in files: list.extend(getFilesForName(file)) return list # try to find module or package name = _get_modpkg_path(name) if not name: return [] if os.path.isdir(name): # find all python files in directory list = [] os.path.walk(name, _visit_pyfiles, list) return list elif os.path.exists(name): # a single file return [name] return [] class TokenEater: def __init__(self, options): self.__options = options self.__messages = {} self.__state = self.__waiting self.__data = [] self.__lineno = -1 self.__freshmodule = 1 self.__curfile = None def __call__(self, ttype, tstring, stup, etup, line): # dispatch ## import token ## print >> sys.stderr, 'ttype:', token.tok_name[ttype], \ ## 'tstring:', tstring self.__state(ttype, tstring, stup[0]) def __waiting(self, ttype, tstring, lineno): opts = self.__options # Do docstring extractions, if enabled if opts.docstrings and not opts.nodocstrings.get(self.__curfile): # module docstring? if self.__freshmodule: if ttype == tokenize.STRING: self.__addentry(safe_eval(tstring), lineno, isdocstring=1) self.__freshmodule = 0 elif ttype not in (tokenize.COMMENT, tokenize.NL): self.__freshmodule = 0 return # class docstring? if ttype == tokenize.NAME and tstring in ('class', 'def'): self.__state = self.__suiteseen return if ttype == tokenize.NAME and tstring in opts.keywords: self.__state = self.__keywordseen def __suiteseen(self, ttype, tstring, lineno): # ignore anything until we see the colon if ttype == tokenize.OP and tstring == ':': self.__state = self.__suitedocstring def __suitedocstring(self, ttype, tstring, lineno): # ignore any intervening noise if ttype == tokenize.STRING: self.__addentry(safe_eval(tstring), lineno, isdocstring=1) self.__state = self.__waiting elif ttype not in (tokenize.NEWLINE, tokenize.INDENT, tokenize.COMMENT): # there was no class docstring self.__state = self.__waiting def __keywordseen(self, ttype, tstring, lineno): if ttype == tokenize.OP and tstring == '(': self.__data = [] self.__lineno = lineno self.__state = self.__openseen else: self.__state = self.__waiting def __openseen(self, ttype, tstring, lineno): if ttype == tokenize.OP and tstring == ')': # We've seen the last of the translatable strings. Record the # line number of the first line of the strings and update the list # of messages seen. Reset state for the next batch. If there # were no strings inside _(), then just ignore this entry. if self.__data: self.__addentry(EMPTYSTRING.join(self.__data)) self.__state = self.__waiting elif ttype == tokenize.STRING: self.__data.append(safe_eval(tstring)) elif ttype not in [tokenize.COMMENT, token.INDENT, token.DEDENT, token.NEWLINE, tokenize.NL]: # warn if we see anything else than STRING or whitespace print >> sys.stderr, _( '*** %(file)s:%(lineno)s: Seen unexpected token "%(token)s"' ) % { 'token': tstring, 'file': self.__curfile, 'lineno': self.__lineno } self.__state = self.__waiting def __addentry(self, msg, lineno=None, isdocstring=0): if lineno is None: lineno = self.__lineno if not msg in self.__options.toexclude: entry = (self.__curfile, lineno) self.__messages.setdefault(msg, {})[entry] = isdocstring def set_filename(self, filename): self.__curfile = filename self.__freshmodule = 1 def write(self, fp): options = self.__options timestamp = time.strftime('%Y-%m-%d %H:%M+%Z') # The time stamp in the header doesn't have the same format as that # generated by xgettext... print >> fp, pot_header % {'time': timestamp, 'version': __version__} # Sort the entries. First sort each particular entry's keys, then # sort all the entries by their first item. reverse = {} for k, v in self.__messages.items(): keys = v.keys() keys.sort() reverse.setdefault(tuple(keys), []).append((k, v)) rkeys = reverse.keys() rkeys.sort() for rkey in rkeys: rentries = reverse[rkey] rentries.sort() for k, v in rentries: isdocstring = 0 # If the entry was gleaned out of a docstring, then add a # comment stating so. This is to aid translators who may wish # to skip translating some unimportant docstrings. if reduce(operator.__add__, v.values()): isdocstring = 1 # k is the message string, v is a dictionary-set of (filename, # lineno) tuples. We want to sort the entries in v first by # file name and then by line number. v = v.keys() v.sort() if not options.writelocations: pass # location comments are different b/w Solaris and GNU: elif options.locationstyle == options.SOLARIS: for filename, lineno in v: d = {'filename': filename, 'lineno': lineno} print >>fp, _( '# File: %(filename)s, line: %(lineno)d') % d elif options.locationstyle == options.GNU: # fit as many locations on one line, as long as the # resulting line length doesn't exceeds 'options.width' locline = '#:' for filename, lineno in v: d = {'filename': filename, 'lineno': lineno} s = _(' %(filename)s:%(lineno)d') % d if len(locline) + len(s) <= options.width: locline = locline + s else: print >> fp, locline locline = "#:" + s if len(locline) > 2: print >> fp, locline if isdocstring: print >> fp, '#, docstring' print >> fp, 'msgid', normalize(k) print >> fp, 'msgstr ""\n' def main(): global default_keywords try: opts, args = getopt.getopt( sys.argv[1:], 'ad:DEhk:Kno:p:S:Vvw:x:X:', ['extract-all', 'default-domain=', 'escape', 'help', 'keyword=', 'no-default-keywords', 'add-location', 'no-location', 'output=', 'output-dir=', 'style=', 'verbose', 'version', 'width=', 'exclude-file=', 'docstrings', 'no-docstrings', ]) except getopt.error, msg: usage(1, msg) # for holding option values class Options: # constants GNU = 1 SOLARIS = 2 # defaults extractall = 0 # FIXME: currently this option has no effect at all. escape = 0 keywords = [] outpath = '' outfile = 'messages.pot' writelocations = 1 locationstyle = GNU verbose = 0 width = 78 excludefilename = '' docstrings = 0 nodocstrings = {} options = Options() locations = {'gnu' : options.GNU, 'solaris' : options.SOLARIS, } # parse options for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-a', '--extract-all'): options.extractall = 1 elif opt in ('-d', '--default-domain'): options.outfile = arg + '.pot' elif opt in ('-E', '--escape'): options.escape = 1 elif opt in ('-D', '--docstrings'): options.docstrings = 1 elif opt in ('-k', '--keyword'): options.keywords.append(arg) elif opt in ('-K', '--no-default-keywords'): default_keywords = [] elif opt in ('-n', '--add-location'): options.writelocations = 1 elif opt in ('--no-location',): options.writelocations = 0 elif opt in ('-S', '--style'): options.locationstyle = locations.get(arg.lower()) if options.locationstyle is None: usage(1, _('Invalid value for --style: %s') % arg) elif opt in ('-o', '--output'): options.outfile = arg elif opt in ('-p', '--output-dir'): options.outpath = arg elif opt in ('-v', '--verbose'): options.verbose = 1 elif opt in ('-V', '--version'): print _('pygettext.py (xgettext for Python) %s') % __version__ sys.exit(0) elif opt in ('-w', '--width'): try: options.width = int(arg) except ValueError: usage(1, _('--width argument must be an integer: %s') % arg) elif opt in ('-x', '--exclude-file'): options.excludefilename = arg elif opt in ('-X', '--no-docstrings'): fp = open(arg) try: while 1: line = fp.readline() if not line: break options.nodocstrings[line[:-1]] = 1 finally: fp.close() # calculate escapes make_escapes(options.escape) # calculate all keywords options.keywords.extend(default_keywords) # initialize list of strings to exclude if options.excludefilename: try: fp = open(options.excludefilename) options.toexclude = fp.readlines() fp.close() except IOError: print >> sys.stderr, _( "Can't read --exclude-file: %s") % options.excludefilename sys.exit(1) else: options.toexclude = [] # resolve args to module lists expanded = [] for arg in args: if arg == '-': expanded.append(arg) else: expanded.extend(getFilesForName(arg)) args = expanded # slurp through all the files eater = TokenEater(options) for filename in args: if filename == '-': if options.verbose: print _('Reading standard input') fp = sys.stdin closep = 0 else: if options.verbose: print _('Working on %s') % filename fp = open(filename) closep = 1 try: eater.set_filename(filename) try: tokenize.tokenize(fp.readline, eater) except tokenize.TokenError, e: print >> sys.stderr, '%s: %s, line %d, column %d' % ( e[0], filename, e[1][0], e[1][1]) finally: if closep: fp.close() # write the output if options.outfile == '-': fp = sys.stdout closep = 0 else: if options.outpath: options.outfile = os.path.join(options.outpath, options.outfile) fp = open(options.outfile, 'w') closep = 1 try: eater.write(fp) finally: if closep: fp.close() if __name__ == '__main__': main() # some more test strings _(u'a unicode string') # this one creates a warning _('*** Seen unexpected token "%(token)s"') % {'token': 'test'} _('more' 'than' 'one' 'string')
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 11601, 13, 4830, 13, 17, 1882, 199, 3, 31534, 1183, 5313, 701, 12377, 651, 644, 285, 2231, 87, 665, 1700, 651, 32, 90, 13458, 14, 957, 30, 199, 3, 199, 3, 10195, 1017, 1183, 19483, 370, 1852, 652, 2755, 1655, 671, 5152, 9025, 199, 3, 701, 22912, 481, 1778, 665, 9928, 32, 580, 957, 13, 71, 887, 72, 14, 271, 30, 199, 3, 199, 3, 14790, 13, 845, 13, 1081, 1603, 17709, 82, 2268, 18769, 20059, 665, 31623, 32, 2520, 14, 271, 30, 199, 3, 16230, 5920, 626, 485, 342, 1454, 3509, 1059, 18041, 12, 436, 199, 3, 1414, 1004, 1249, 787, 12152, 370, 859, 5548, 12, 284, 14, 69, 14, 1265, 199, 3, 883, 3063, 986, 282, 1788, 12, 282, 859, 503, 2559, 536, 12, 503, 282, 199, 3, 2082, 334, 15768, 5739, 10911, 8365, 12, 11012, 367, 13036, 708, 680, 199, 3, 603, 9587, 9214, 5542, 315, 5939, 8365, 20239, 17561, 1808, 29164, 14, 199, 3, 199, 199, 3, 367, 291, 4776, 199, 893, 26, 272, 492, 289, 442, 76, 272, 485, 275, 289, 442, 76, 14, 5152, 199, 2590, 3545, 26, 272, 485, 275, 2400, 308, 26, 308, 199, 199, 363, 1301, 363, 275, 485, 4852, 647, 5152, 1553, 2018, 7353, 402, 671, 5152, 8, 17, 9, 199, 199, 4089, 10460, 334, 27262, 4663, 12, 10130, 12, 598, 4850, 9, 5647, 2178, 3398, 7249, 626, 325, 482, 314, 199, 4404, 6279, 2072, 402, 445, 18572, 14, 17536, 402, 3520, 7249, 787, 12717, 402, 199, 1589, 31768, 2637, 436, 883, 506, 1202, 687, 4453, 2018, 18572, 14, 199, 45, 26788, 373, 265, 3835, 546, 374, 7, 1736, 59, 17, 61, 22577, 8219, 14411, 590, 315, 642, 8794, 14, 199, 199, 10924, 1159, 1373, 5160, 10617, 27, 671, 5152, 365, 314, 2240, 626, 4061, 796, 1350, 1233, 199, 11660, 316, 367, 1245, 3326, 12, 1325, 652, 486, 293, 6080, 1454, 445, 334, 269, 445, 4176, 680, 2018, 199, 18206, 10569, 282, 9284, 336, 12465, 2978, 12, 4066, 465, 21164, 18593, 4110, 12, 19671, 10999, 199, 5465, 12, 436, 3066, 3326, 14, 671, 5152, 1334, 26580, 7179, 402, 642, 14, 199, 199, 8468, 1134, 5152, 12, 1314, 4440, 2018, 1159, 4465, 13343, 859, 370, 8000, 199, 4718, 1350, 1233, 12, 12999, 1275, 14173, 1584, 13130, 370, 4052, 1664, 671, 5152, 59, 18, 61, 199, 2038, 2335, 367, 445, 436, 445, 4176, 1233, 14, 11606, 2337, 12, 314, 4465, 1664, 7249, 883, 506, 199, 2972, 14, 199, 199, 33, 4349, 3595, 31318, 2018, 3326, 465, 15101, 367, 7761, 14, 1664, 199, 88, 5152, 17319, 6491, 314, 2569, 7681, 26, 9796, 12, 366, 5152, 12, 12326, 5152, 12, 199, 460, 9796, 63, 12921, 14, 11017, 5204, 883, 506, 282, 13918, 402, 1318, 370, 2387, 1006, 1806, 2195, 199, 600, 14, 445, 436, 445, 4176, 1172, 282, 20907, 26, 2985, 675, 314, 445, 22335, 14, 17536, 199, 4404, 6279, 1759, 445, 1350, 6952, 282, 327, 4640, 367, 9796, 342, 370, 485, 342, 880, 626, 199, 10058, 965, 370, 506, 5313, 315, 314, 1350, 365, 8298, 6656, 14, 20227, 3520, 787, 3865, 199, 1515, 25099, 3326, 26, 339, 9796, 480, 3188, 25099, 2624, 531, 272, 3824, 3188, 25099, 2624, 531, 199, 199, 4718, 402, 2518, 965, 949, 22335, 880, 642, 3181, 1133, 1736, 880, 5521, 14, 221, 20227, 12, 199, 647, 5152, 21858, 1454, 367, 485, 342, 701, 849, 12, 1325, 1937, 314, 446, 75, 25695, 6691, 3305, 199, 12843, 367, 4212, 370, 18336, 434, 642, 14, 421, 359, 17, 61, 1455, 921, 1544, 14, 1548, 14, 1308, 15, 800, 609, 1483, 15, 7155, 23, 13, 709, 15, 496, 15648, 780, 15, 320, 546, 374, 14, 1360, 199, 359, 18, 61, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 15619, 15, 5152, 15, 5152, 14, 1360, 199, 199, 19855, 26, 1134, 5152, 12454, 370, 506, 945, 436, 3878, 9025, 543, 1664, 199, 88, 5152, 2382, 14433, 3962, 14, 9738, 2005, 1511, 787, 5139, 4124, 503, 787, 199, 1397, 9999, 6366, 14, 6121, 12, 671, 5152, 1159, 675, 402, 1414, 1004, 24563, 543, 199, 1422, 2368, 365, 10529, 12, 436, 315, 3520, 5560, 12, 1134, 5152, 2951, 7890, 199, 8460, 24563, 14, 199, 199, 7692, 26, 1134, 5152, 359, 1419, 61, 1324, 493, 2263, 199, 199, 4558, 26, 339, 446, 65, 272, 1553, 5005, 13, 452, 267, 12892, 1006, 3326, 14, 339, 446, 68, 536, 272, 1553, 885, 13, 2261, 29, 354, 267, 22756, 314, 849, 1072, 570, 687, 3788, 14, 14173, 370, 536, 14, 14173, 14, 339, 446, 37, 272, 1553, 3765, 267, 14402, 2222, 13, 12292, 4110, 543, 30100, 4772, 8013, 14, 339, 446, 36, 272, 1553, 1301, 5465, 267, 12892, 859, 12, 1021, 12, 1083, 12, 436, 805, 20964, 14, 221, 5723, 886, 267, 440, 1929, 370, 506, 8072, 315, 485, 342, 14327, 12, 436, 315, 10572, 3913, 506, 367, 267, 2018, 370, 11201, 3062, 20964, 14, 334, 9295, 2597, 314, 446, 56, 945, 680, 339, 446, 72, 272, 1553, 3437, 267, 9101, 642, 1720, 1245, 436, 4458, 14, 339, 446, 75, 4349, 272, 1553, 6691, 29, 1027, 267, 2606, 3148, 370, 3648, 367, 315, 10234, 370, 314, 849, 663, 12, 1314, 787, 26, 267, 2818, 3472, 32187, 9, 83, 398, 2047, 883, 1172, 3663, 446, 75, 3285, 641, 314, 1414, 1004, 14, 339, 446, 43, 272, 1553, 889, 13, 885, 13, 7511, 267, 17534, 314, 849, 663, 402, 7681, 334, 3239, 3432, 680, 221, 6184, 7681, 267, 7662, 3483, 543, 314, 446, 75, 25695, 6691, 945, 787, 5139, 18054, 14, 339, 1553, 889, 13, 1985, 267, 4226, 440, 2218, 1788, 15, 3469, 2909, 6786, 14, 339, 446, 78, 272, 1553, 525, 13, 1985, 267, 6990, 1788, 15, 3469, 2909, 6786, 9297, 2382, 1924, 267, 12509, 1059, 365, 1911, 315, 314, 1350, 14, 221, 5723, 2385, 7468, 2544, 267, 1924, 17879, 14, 221, 710, 3449, 402, 6786, 365, 22284, 701, 314, 446, 51, 25695, 2487, 267, 945, 14, 221, 961, 365, 314, 849, 14, 339, 446, 79, 1788, 272, 1553, 1199, 29, 1501, 267, 22756, 314, 849, 1072, 570, 687, 3788, 14, 14173, 370, 1788, 14, 221, 982, 267, 1788, 365, 658, 15668 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 11601, 13, 4830, 13, 17, 1882, 199, 3, 31534, 1183, 5313, 701, 12377, 651, 644, 285, 2231, 87, 665, 1700, 651, 32, 90, 13458, 14, 957, 30, 199, 3, 199, 3, 10195, 1017, 1183, 19483, 370, 1852, 652, 2755, 1655, 671, 5152, 9025, 199, 3, 701, 22912, 481, 1778, 665, 9928, 32, 580, 957, 13, 71, 887, 72, 14, 271, 30, 199, 3, 199, 3, 14790, 13, 845, 13, 1081, 1603, 17709, 82, 2268, 18769, 20059, 665, 31623, 32, 2520, 14, 271, 30, 199, 3, 16230, 5920, 626, 485, 342, 1454, 3509, 1059, 18041, 12, 436, 199, 3, 1414, 1004, 1249, 787, 12152, 370, 859, 5548, 12, 284, 14, 69, 14, 1265, 199, 3, 883, 3063, 986, 282, 1788, 12, 282, 859, 503, 2559, 536, 12, 503, 282, 199, 3, 2082, 334, 15768, 5739, 10911, 8365, 12, 11012, 367, 13036, 708, 680, 199, 3, 603, 9587, 9214, 5542, 315, 5939, 8365, 20239, 17561, 1808, 29164, 14, 199, 3, 199, 199, 3, 367, 291, 4776, 199, 893, 26, 272, 492, 289, 442, 76, 272, 485, 275, 289, 442, 76, 14, 5152, 199, 2590, 3545, 26, 272, 485, 275, 2400, 308, 26, 308, 199, 199, 363, 1301, 363, 275, 485, 4852, 647, 5152, 1553, 2018, 7353, 402, 671, 5152, 8, 17, 9, 199, 199, 4089, 10460, 334, 27262, 4663, 12, 10130, 12, 598, 4850, 9, 5647, 2178, 3398, 7249, 626, 325, 482, 314, 199, 4404, 6279, 2072, 402, 445, 18572, 14, 17536, 402, 3520, 7249, 787, 12717, 402, 199, 1589, 31768, 2637, 436, 883, 506, 1202, 687, 4453, 2018, 18572, 14, 199, 45, 26788, 373, 265, 3835, 546, 374, 7, 1736, 59, 17, 61, 22577, 8219, 14411, 590, 315, 642, 8794, 14, 199, 199, 10924, 1159, 1373, 5160, 10617, 27, 671, 5152, 365, 314, 2240, 626, 4061, 796, 1350, 1233, 199, 11660, 316, 367, 1245, 3326, 12, 1325, 652, 486, 293, 6080, 1454, 445, 334, 269, 445, 4176, 680, 2018, 199, 18206, 10569, 282, 9284, 336, 12465, 2978, 12, 4066, 465, 21164, 18593, 4110, 12, 19671, 10999, 199, 5465, 12, 436, 3066, 3326, 14, 671, 5152, 1334, 26580, 7179, 402, 642, 14, 199, 199, 8468, 1134, 5152, 12, 1314, 4440, 2018, 1159, 4465, 13343, 859, 370, 8000, 199, 4718, 1350, 1233, 12, 12999, 1275, 14173, 1584, 13130, 370, 4052, 1664, 671, 5152, 59, 18, 61, 199, 2038, 2335, 367, 445, 436, 445, 4176, 1233, 14, 11606, 2337, 12, 314, 4465, 1664, 7249, 883, 506, 199, 2972, 14, 199, 199, 33, 4349, 3595, 31318, 2018, 3326, 465, 15101, 367, 7761, 14, 1664, 199, 88, 5152, 17319, 6491, 314, 2569, 7681, 26, 9796, 12, 366, 5152, 12, 12326, 5152, 12, 199, 460, 9796, 63, 12921, 14, 11017, 5204, 883, 506, 282, 13918, 402, 1318, 370, 2387, 1006, 1806, 2195, 199, 600, 14, 445, 436, 445, 4176, 1172, 282, 20907, 26, 2985, 675, 314, 445, 22335, 14, 17536, 199, 4404, 6279, 1759, 445, 1350, 6952, 282, 327, 4640, 367, 9796, 342, 370, 485, 342, 880, 626, 199, 10058, 965, 370, 506, 5313, 315, 314, 1350, 365, 8298, 6656, 14, 20227, 3520, 787, 3865, 199, 1515, 25099, 3326, 26, 339, 9796, 480, 3188, 25099, 2624, 531, 272, 3824, 3188, 25099, 2624, 531, 199, 199, 4718, 402, 2518, 965, 949, 22335, 880, 642, 3181, 1133, 1736, 880, 5521, 14, 221, 20227, 12, 199, 647, 5152, 21858, 1454, 367, 485, 342, 701, 849, 12, 1325, 1937, 314, 446, 75, 25695, 6691, 3305, 199, 12843, 367, 4212, 370, 18336, 434, 642, 14, 421, 359, 17, 61, 1455, 921, 1544, 14, 1548, 14, 1308, 15, 800, 609, 1483, 15, 7155, 23, 13, 709, 15, 496, 15648, 780, 15, 320, 546, 374, 14, 1360, 199, 359, 18, 61, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 15619, 15, 5152, 15, 5152, 14, 1360, 199, 199, 19855, 26, 1134, 5152, 12454, 370, 506, 945, 436, 3878, 9025, 543, 1664, 199, 88, 5152, 2382, 14433, 3962, 14, 9738, 2005, 1511, 787, 5139, 4124, 503, 787, 199, 1397, 9999, 6366, 14, 6121, 12, 671, 5152, 1159, 675, 402, 1414, 1004, 24563, 543, 199, 1422, 2368, 365, 10529, 12, 436, 315, 3520, 5560, 12, 1134, 5152, 2951, 7890, 199, 8460, 24563, 14, 199, 199, 7692, 26, 1134, 5152, 359, 1419, 61, 1324, 493, 2263, 199, 199, 4558, 26, 339, 446, 65, 272, 1553, 5005, 13, 452, 267, 12892, 1006, 3326, 14, 339, 446, 68, 536, 272, 1553, 885, 13, 2261, 29, 354, 267, 22756, 314, 849, 1072, 570, 687, 3788, 14, 14173, 370, 536, 14, 14173, 14, 339, 446, 37, 272, 1553, 3765, 267, 14402, 2222, 13, 12292, 4110, 543, 30100, 4772, 8013, 14, 339, 446, 36, 272, 1553, 1301, 5465, 267, 12892, 859, 12, 1021, 12, 1083, 12, 436, 805, 20964, 14, 221, 5723, 886, 267, 440, 1929, 370, 506, 8072, 315, 485, 342, 14327, 12, 436, 315, 10572, 3913, 506, 367, 267, 2018, 370, 11201, 3062, 20964, 14, 334, 9295, 2597, 314, 446, 56, 945, 680, 339, 446, 72, 272, 1553, 3437, 267, 9101, 642, 1720, 1245, 436, 4458, 14, 339, 446, 75, 4349, 272, 1553, 6691, 29, 1027, 267, 2606, 3148, 370, 3648, 367, 315, 10234, 370, 314, 849, 663, 12, 1314, 787, 26, 267, 2818, 3472, 32187, 9, 83, 398, 2047, 883, 1172, 3663, 446, 75, 3285, 641, 314, 1414, 1004, 14, 339, 446, 43, 272, 1553, 889, 13, 885, 13, 7511, 267, 17534, 314, 849, 663, 402, 7681, 334, 3239, 3432, 680, 221, 6184, 7681, 267, 7662, 3483, 543, 314, 446, 75, 25695, 6691, 945, 787, 5139, 18054, 14, 339, 1553, 889, 13, 1985, 267, 4226, 440, 2218, 1788, 15, 3469, 2909, 6786, 14, 339, 446, 78, 272, 1553, 525, 13, 1985, 267, 6990, 1788, 15, 3469, 2909, 6786, 9297, 2382, 1924, 267, 12509, 1059, 365, 1911, 315, 314, 1350, 14, 221, 5723, 2385, 7468, 2544, 267, 1924, 17879, 14, 221, 710, 3449, 402, 6786, 365, 22284, 701, 314, 446, 51, 25695, 2487, 267, 945, 14, 221, 961, 365, 314, 849, 14, 339, 446, 79, 1788, 272, 1553, 1199, 29, 1501, 267, 22756, 314, 849, 1072, 570, 687, 3788, 14, 14173, 370, 1788, 14, 221, 982, 267, 1788, 365, 658, 15668, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ageron/tensorflow
tensorflow/python/keras/estimator/__init__.py
10
2884
# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Keras estimator API.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.python.util.tf_export import keras_export # Keras has undeclared dependency on tensorflow/estimator:estimator_py. # As long as you depend //third_party/py/tensorflow:tensorflow target # everything will work as normal. # LINT.IfChange @keras_export('keras.estimator.model_to_estimator') def model_to_estimator( keras_model=None, keras_model_path=None, custom_objects=None, model_dir=None, config=None): """Constructs an `Estimator` instance from given keras model. For usage example, please see: [Creating estimators from Keras Models](https://tensorflow.org/guide/estimators#model_to_estimator). Args: keras_model: A compiled Keras model object. This argument is mutually exclusive with `keras_model_path`. keras_model_path: Path to a compiled Keras model saved on disk, in HDF5 format, which can be generated with the `save()` method of a Keras model. This argument is mutually exclusive with `keras_model`. custom_objects: Dictionary for custom objects. model_dir: Directory to save `Estimator` model parameters, graph, summary files for TensorBoard, etc. config: `RunConfig` to config `Estimator`. Returns: An Estimator from given keras model. Raises: ValueError: if neither keras_model nor keras_model_path was given. ValueError: if both keras_model and keras_model_path was given. ValueError: if the keras_model_path is a GCS URI. ValueError: if keras_model has not been compiled. """ try: from tensorflow_estimator.python.estimator import keras as keras_lib # pylint: disable=g-import-not-at-top except ImportError: raise NotImplementedError( 'tf.keras.estimator.model_to_estimator function not available in your ' 'installation.') return keras_lib.model_to_estimator( keras_model=keras_model, keras_model_path=keras_model_path, custom_objects=custom_objects, model_dir=model_dir, config=config) # LINT.ThenChange(//tensorflow_estimator/python/estimator/keras.py)
apache-2.0
[ 3, 1898, 14894, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 43, 30037, 8943, 3261, 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, 1974, 14, 3249, 63, 3790, 492, 11708, 63, 3790, 199, 199, 3, 1804, 30037, 965, 625, 13545, 5936, 641, 3228, 15, 8627, 26, 8627, 63, 647, 14, 199, 3, 3709, 1846, 465, 1265, 11687, 5001, 11470, 63, 7522, 15, 647, 15, 16008, 26, 16008, 1347, 199, 3, 8137, 911, 1736, 465, 3293, 14, 421, 199, 3, 491, 2919, 14, 3917, 4001, 199, 32, 8811, 63, 3790, 360, 8811, 14, 8627, 14, 1238, 63, 475, 63, 8627, 358, 199, 318, 1402, 63, 475, 63, 8627, 8, 272, 11708, 63, 1238, 29, 403, 12, 272, 11708, 63, 1238, 63, 515, 29, 403, 12, 272, 3537, 63, 1462, 29, 403, 12, 272, 1402, 63, 694, 29, 403, 12, 272, 1101, 29, 403, 304, 523, 408, 27943, 376, 658, 13183, 64, 1256, 687, 1627, 11708, 1402, 14, 819, 2104, 4503, 2893, 12, 8749, 1937, 26, 523, 359, 14380, 23155, 687, 1804, 30037, 523, 29941, 8738, 2859, 921, 16008, 14, 1308, 15, 17348, 15, 10646, 3, 1238, 63, 475, 63, 8627, 680, 819, 3033, 26, 272, 11708, 63, 1238, 26, 437, 10311, 1804, 30037, 1402, 909, 14, 961, 1423, 365, 16108, 489, 13914, 543, 658, 8811, 63, 1238, 63, 515, 2313, 272, 11708, 63, 1238, 63, 515, 26, 6912, 370, 282, 10311, 1804, 30037, 1402, 6290, 641, 4543, 12, 315, 24521, 21, 489, 1475, 12, 1314, 883, 506, 4046, 543, 314, 658, 2117, 11995, 1083, 402, 282, 1804, 30037, 1402, 14, 489, 961, 1423, 365, 16108, 13914, 543, 658, 8811, 63, 1238, 2313, 272, 3537, 63, 1462, 26, 11932, 367, 3537, 2251, 14, 272, 1402, 63, 694, 26, 15191, 370, 3354, 658, 13183, 64, 1402, 2633, 12, 3343, 12, 6212, 489, 1584, 367, 5878, 18995, 12, 5423, 14, 272, 1101, 26, 658, 2540, 2028, 64, 370, 1101, 658, 13183, 2313, 819, 1803, 26, 272, 1626, 28992, 687, 1627, 11708, 1402, 14, 819, 6218, 26, 272, 1722, 26, 340, 15564, 11708, 63, 1238, 6590, 11708, 63, 1238, 63, 515, 1990, 1627, 14, 272, 1722, 26, 340, 3865, 11708, 63, 1238, 436, 11708, 63, 1238, 63, 515, 1990, 1627, 14, 272, 1722, 26, 340, 314, 11708, 63, 1238, 63, 515, 365, 282, 598, 3298, 9022, 14, 272, 1722, 26, 340, 11708, 63, 1238, 965, 440, 2757, 10311, 14, 523, 408, 523, 862, 26, 272, 687, 3228, 63, 8627, 14, 1548, 14, 8627, 492, 11708, 465, 11708, 63, 773, 221, 327, 4287, 26, 3507, 29, 71, 13, 646, 13, 1397, 13, 292, 13, 2119, 523, 871, 3545, 26, 272, 746, 4279, 8, 267, 283, 3249, 14, 8811, 14, 8627, 14, 1238, 63, 475, 63, 8627, 805, 440, 2808, 315, 2195, 283, 267, 283, 23048, 2659, 523, 372, 11708, 63, 773, 14, 1238, 63, 475, 63, 8627, 8, 489, 11708, 63, 1238, 29, 8811, 63, 1238, 12, 489, 11708, 63, 1238, 63, 515, 29, 8811, 63, 1238, 63, 515, 12, 489, 3537, 63, 1462, 29, 4229, 63, 1462, 12, 489, 1402, 63, 694, 29, 1238, 63, 694, 12, 489, 1101, 29, 888, 9, 199, 199, 3, 491, 2919, 14, 28226, 4001, 8, 501, 16008, 63, 8627, 15, 1548, 15, 8627, 15, 8811, 14, 647, 9, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 14894, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 43, 30037, 8943, 3261, 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, 1974, 14, 3249, 63, 3790, 492, 11708, 63, 3790, 199, 199, 3, 1804, 30037, 965, 625, 13545, 5936, 641, 3228, 15, 8627, 26, 8627, 63, 647, 14, 199, 3, 3709, 1846, 465, 1265, 11687, 5001, 11470, 63, 7522, 15, 647, 15, 16008, 26, 16008, 1347, 199, 3, 8137, 911, 1736, 465, 3293, 14, 421, 199, 3, 491, 2919, 14, 3917, 4001, 199, 32, 8811, 63, 3790, 360, 8811, 14, 8627, 14, 1238, 63, 475, 63, 8627, 358, 199, 318, 1402, 63, 475, 63, 8627, 8, 272, 11708, 63, 1238, 29, 403, 12, 272, 11708, 63, 1238, 63, 515, 29, 403, 12, 272, 3537, 63, 1462, 29, 403, 12, 272, 1402, 63, 694, 29, 403, 12, 272, 1101, 29, 403, 304, 523, 408, 27943, 376, 658, 13183, 64, 1256, 687, 1627, 11708, 1402, 14, 819, 2104, 4503, 2893, 12, 8749, 1937, 26, 523, 359, 14380, 23155, 687, 1804, 30037, 523, 29941, 8738, 2859, 921, 16008, 14, 1308, 15, 17348, 15, 10646, 3, 1238, 63, 475, 63, 8627, 680, 819, 3033, 26, 272, 11708, 63, 1238, 26, 437, 10311, 1804, 30037, 1402, 909, 14, 961, 1423, 365, 16108, 489, 13914, 543, 658, 8811, 63, 1238, 63, 515, 2313, 272, 11708, 63, 1238, 63, 515, 26, 6912, 370, 282, 10311, 1804, 30037, 1402, 6290, 641, 4543, 12, 315, 24521, 21, 489, 1475, 12, 1314, 883, 506, 4046, 543, 314, 658, 2117, 11995, 1083, 402, 282, 1804, 30037, 1402, 14, 489, 961, 1423, 365, 16108, 13914, 543, 658, 8811, 63, 1238, 2313, 272, 3537, 63, 1462, 26, 11932, 367, 3537, 2251, 14, 272, 1402, 63, 694, 26, 15191, 370, 3354, 658, 13183, 64, 1402, 2633, 12, 3343, 12, 6212, 489, 1584, 367, 5878, 18995, 12, 5423, 14, 272, 1101, 26, 658, 2540, 2028, 64, 370, 1101, 658, 13183, 2313, 819, 1803, 26, 272, 1626, 28992, 687, 1627, 11708, 1402, 14, 819, 6218, 26, 272, 1722, 26, 340, 15564, 11708, 63, 1238, 6590, 11708, 63, 1238, 63, 515, 1990, 1627, 14, 272, 1722, 26, 340, 3865, 11708, 63, 1238, 436, 11708, 63, 1238, 63, 515, 1990, 1627, 14, 272, 1722, 26, 340, 314, 11708, 63, 1238, 63, 515, 365, 282, 598, 3298, 9022, 14, 272, 1722, 26, 340, 11708, 63, 1238, 965, 440, 2757, 10311, 14, 523, 408, 523, 862, 26, 272, 687, 3228, 63, 8627, 14, 1548, 14, 8627, 492, 11708, 465, 11708, 63, 773, 221, 327, 4287, 26, 3507, 29, 71, 13, 646, 13, 1397, 13, 292, 13, 2119, 523, 871, 3545, 26, 272, 746, 4279, 8, 267, 283, 3249, 14, 8811, 14, 8627, 14, 1238, 63, 475, 63, 8627, 805, 440, 2808, 315, 2195, 283, 267, 283, 23048, 2659, 523, 372, 11708, 63, 773, 14, 1238, 63, 475, 63, 8627, 8, 489, 11708, 63, 1238, 29, 8811, 63, 1238, 12, 489, 11708, 63, 1238, 63, 515, 29, 8811, 63, 1238, 63, 515, 12, 489, 3537, 63, 1462, 29, 4229, 63, 1462, 12, 489, 1402, 63, 694, 29, 1238, 63, 694, 12, 489, 1101, 29, 888, 9, 199, 199, 3, 491, 2919, 14, 28226, 4001, 8, 501, 16008, 63, 8627, 15, 1548, 15, 8627, 15, 8811, 14, 647, 9, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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